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