SST  14.1.0
StructuralSimulationToolkit
coreTest_Component.h
1 // Copyright 2009-2024 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-2024, 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_H
13 #define SST_CORE_CORETEST_COMPONENT_H
14 
15 #include "sst/core/component.h"
16 #include "sst/core/link.h"
17 #include "sst/core/rng/marsaglia.h"
18 
19 namespace SST {
20 namespace CoreTestComponent {
21 
22 // These first two classes are just base classes to test ELI
23 // inheritance. The definition of the ELI items are spread through 2
24 // component base classes to make sure they get inherited in the
25 // actual component that can be instanced.
27 {
28 public:
29  SST_ELI_REGISTER_COMPONENT_BASE(SST::CoreTestComponent::coreTestComponentBase)
30 
31  SST_ELI_DOCUMENT_PARAMS(
32  { "workPerCycle", "Count of busy work to do during a clock tick.", NULL},
33  { "clockFrequency", "Frequency of the clock", "1GHz"}
34  )
35 
36  SST_ELI_DOCUMENT_STATISTICS(
37  { "N", "events sent on N link", "counts", 1 }
38  )
39 
40  SST_ELI_DOCUMENT_PORTS(
41  {"Nlink", "Link to the coreTestComponent to the North", { "coreTestComponent.coreTestComponentEvent", "" } }
42  )
43 
44  SST_ELI_DOCUMENT_ATTRIBUTES(
45  { "test_element", "true" }
46  )
47 
48  coreTestComponentBase(ComponentId_t id) : SST::Component(id) {}
51  void serialize_order(SST::Core::Serialization::serializer& ser) override { SST::Component::serialize_order(ser); }
53 };
54 
56 {
57 public:
58  SST_ELI_REGISTER_COMPONENT_DERIVED_BASE(
60 
61  SST_ELI_DOCUMENT_PARAMS(
62  { "commFreq", "There is a 1/commFreq chance each clock cycle of sending an event to a neighbor", NULL}
63  )
64 
65  SST_ELI_DOCUMENT_STATISTICS(
66  { "S", "events sent on S link", "counts", 1 }
67  )
68 
69  SST_ELI_DOCUMENT_PORTS(
70  {"Slink", "Link to the coreTestComponent to the South", { "coreTestComponent.coreTestComponentEvent", "" } }
71  )
72 
73  coreTestComponentBase2(ComponentId_t id) : coreTestComponentBase(id) {}
75 
77 
78  void serialize_order(SST::Core::Serialization::serializer& ser) override
79  {
80  SST::CoreTestComponent::coreTestComponentBase::serialize_order(ser);
81  }
83 };
84 
86 {
87 public:
88  // REGISTER THIS COMPONENT INTO THE ELEMENT LIBRARY
89  SST_ELI_REGISTER_COMPONENT(
91  "coreTestElement",
92  "coreTestComponent",
93  SST_ELI_ELEMENT_VERSION(1,0,0),
94  "CoreTest Test Component",
95  COMPONENT_CATEGORY_PROCESSOR
96  )
97 
98  SST_ELI_DOCUMENT_PARAMS(
99  { "commSize", "Size of communication to send.", "16"}
100  )
101 
102  SST_ELI_DOCUMENT_STATISTICS(
103  { "E", "events sent on E link", "counts", 1 },
104  { "W", "events sent on W link", "counts", 1 }
105  )
106 
107  SST_ELI_DOCUMENT_PORTS(
108  {"Elink", "Link to the coreTestComponent to the East", { "coreTestComponent.coreTestComponentEvent", "" } },
109  {"Wlink", "Link to the coreTestComponent to the West", { "coreTestComponent.coreTestComponentEvent", "" } }
110  )
111 
112  // Optional since there is nothing to document
113  SST_ELI_DOCUMENT_SUBCOMPONENT_SLOTS(
114  )
115 
116  coreTestComponent(SST::ComponentId_t id, SST::Params& params);
118 
119  void setup() override {}
120  void finish() override { printf("Component Finished.\n"); }
121 
122  void serialize_order(SST::Core::Serialization::serializer& ser) override;
123  ImplementSerializable(SST::CoreTestComponent::coreTestComponent)
124  coreTestComponent(); // for serialization only
125 
126 private:
127  coreTestComponent(const coreTestComponent&); // do not implement
128  void operator=(const coreTestComponent&); // do not implement
129 
130  void handleEvent(SST::Event* ev);
131  virtual bool clockTic(SST::Cycle_t);
132 
133  int workPerCycle;
134  int commFreq;
135  int commSize;
136  int neighbor;
137 
139  SST::Link* N;
140  SST::Link* S;
141  SST::Link* E;
142  SST::Link* W;
147 };
148 
149 } // namespace CoreTestComponent
150 } // namespace SST
151 
152 #endif // SST_CORE_CORETEST_COMPONENT_H
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:43
Main component object for the simulation.
Definition: component.h:30
Definition: coreTest_Component.h:85
void finish() override
Called after complete phase, but before objects are destroyed.
Definition: coreTest_Component.h:120
Definition: action.cc:18
Definition: coreTest_Component.h:26
Definition: coreTest_Component.h:55
void setup() override
Called after all components have been constructed and initialization has completed, but before simulation time has begun.
Definition: coreTest_Component.h:119
Implements a random number generator using the Marsaglia method.
Definition: marsaglia.h:40
Parameter store.
Definition: params.h:55
Base class for Events - Items sent across links to communicate between components.
Definition: event.h:34