SST  15.1.0
StructuralSimulationToolkit
coreTest_ComponentExtension.h
1 // Copyright 2009-2025 NTESS. Under the terms
2 // of Contract DE-NA0003525 with NTESS, the U.S.
3 // Government retains certain rights in this software.
4 //
5 // Copyright (c) 2009-2025, NTESS
6 // All rights reserved.
7 //
8 // This file is part of the SST software package. For license
9 // information, see the LICENSE file in the top level directory of the
10 // distribution.
11 
12 #ifndef SST_CORE_CORETEST_COMPONENT_EXT_H
13 #define SST_CORE_CORETEST_COMPONENT_EXT_H
14 
15 #include "sst/core/component.h"
16 #include "sst/core/componentExtension.h"
17 #include "sst/core/link.h"
18 #include "sst/core/rng/marsaglia.h"
19 
20 #include <cstddef>
21 #include <cstdint>
22 #include <cstdio>
23 
24 namespace SST::CoreTestComponent {
25 
26 // Split the CoreTest_Component functionality into a component and extension
28 {
29 public:
30  coreTestComponentExt2(SST::ComponentId_t id, int neighbor);
31  coreTestComponentExt2() = default; // for serialization only
32  ~coreTestComponentExt2() = default;
33 
34  void send(Event* ev);
35 
36  void serialize_order(SST::Core::Serialization::serializer& ser) override;
38 
39 private:
40  coreTestComponentExt2(const coreTestComponentExt2&) = delete; // do not implement
41  coreTestComponentExt2& operator=(const coreTestComponentExt2&) = delete; // do not implement
42 
43  void handleEvent(SST::Event* ev);
44 
45  int neighbor_;
46 
47  SST::Link* N_;
48  SST::Link* S_;
49  SST::Link* E_;
50  SST::Link* W_;
55 };
56 
58 {
59 public:
61  SST::ComponentId_t id, int64_t comm_freq, std::string clk, int64_t work_per_cycle, int64_t comm_size);
63 
64  int32_t generateNext();
65  bool communicate();
66 
67  void serialize_order(SST::Core::Serialization::serializer& ser) override;
69  coreTestComponentExt() = default; // for serialization only
70 
71 private:
72  coreTestComponentExt(const coreTestComponentExt&) = delete; // do not implement
73  coreTestComponentExt& operator=(const coreTestComponentExt&) = delete; // do not implement
74 
75  bool clockTic(SST::Cycle_t);
76 
79  int comm_freq_;
80  int comm_size_;
81  int work_per_cycle_;
82 };
83 
84 
86 {
87 public:
88  // REGISTER THIS COMPONENT INTO THE ELEMENT LIBRARY
89  SST_ELI_REGISTER_COMPONENT(
91  "coreTestElement",
92  "coreTestComponentExtension",
93  SST_ELI_ELEMENT_VERSION(1,0,0),
94  "CoreTest Test Component for ComponentExtensions",
95  COMPONENT_CATEGORY_PROCESSOR
96  )
97 
98  SST_ELI_DOCUMENT_PARAMS(
99  { "workPerCycle", "Count of busy work to do during a clock tick.", NULL},
100  { "clockFrequency", "Frequency of the clock", "1GHz"},
101  { "commFreq", "There is a 1/commFreq chance each clock cycle of sending an event to a neighbor", NULL},
102  { "commSize", "Size of communication to send.", "16"}
103  )
104 
105  SST_ELI_DOCUMENT_STATISTICS(
106  { "N", "events sent on N link", "counts", 1 },
107  { "S", "events sent on S link", "counts", 1 },
108  { "E", "events sent on E link", "counts", 1 },
109  { "W", "events sent on W link", "counts", 1 }
110  )
111 
112  SST_ELI_DOCUMENT_PORTS(
113  {"Nlink", "Link to the coreTestComponentExtension to the North", { "coreTestComponent.coreTestComponentEvent", "" } },
114  {"Slink", "Link to the coreTestComponentExtension to the South", { "coreTestComponent.coreTestComponentEvent", "" } },
115  {"Elink", "Link to the coreTestComponentExtension to the East", { "coreTestComponent.coreTestComponentEvent", "" } },
116  {"Wlink", "Link to the coreTestComponentExtension to the West", { "coreTestComponent.coreTestComponentEvent", "" } }
117  )
118 
119  SST_ELI_DOCUMENT_ATTRIBUTES(
120  { "test_element", "true" }
121  )
122 
123  // Optional since there is nothing to document
124  SST_ELI_DOCUMENT_SUBCOMPONENT_SLOTS(
125  )
126 
127  SST_ELI_IS_CHECKPOINTABLE()
128 
129  coreTestComponentExtMain(SST::ComponentId_t id, SST::Params& params);
131 
132  void setup() override {}
133  void finish() override { printf("Component Finished.\n"); }
134 
135  void serialize_order(SST::Core::Serialization::serializer& ser) override;
137  coreTestComponentExtMain() = default; // for serialization only
138 
139 private:
140  coreTestComponentExtMain(const coreTestComponentExtMain&) = delete; // do not implement
141  coreTestComponentExtMain& operator=(const coreTestComponentExtMain&) = delete; // do not implement
142 
143  coreTestComponentExt* ext_;
144 };
145 
146 
147 } // namespace SST::CoreTestComponent
148 
149 #endif // SST_CORE_CORETEST_COMPONENT_EXT_H
Definition: coreTest_Component.h:22
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:42
Main component object for the simulation.
Definition: component.h:30
ComponentExtension is a class that can be loaded using loadComponentExtension<T>(...).
Definition: componentExtension.h:28
void setup() override
Called after all components have been constructed and initialization has completed, but before simulation time has begun.
Definition: coreTest_ComponentExtension.h:132
Definition: coreTest_ComponentExtension.h:57
Definition: coreTest_ComponentExtension.h:85
Implements a random number generator using the Marsaglia method.
Definition: marsaglia.h:40
Parameter store.
Definition: params.h:63
void finish() override
Called after complete phase, but before objects are destroyed.
Definition: coreTest_ComponentExtension.h:133
Base class for Events - Items sent across links to communicate between components.
Definition: event.h:40
Definition: coreTest_ComponentExtension.h:27