12#ifndef SST_CORE_CORETEST_MESSAGEMESH_ENCLOSINGCOMPONENT_H
13#define SST_CORE_CORETEST_MESSAGEMESH_ENCLOSINGCOMPONENT_H
15#include "sst/core/testElements/message_mesh/messageEvent.h"
17#include "sst/core/component.h"
18#include "sst/core/event.h"
19#include "sst/core/link.h"
20#include "sst/core/rng/rng.h"
21#include "sst/core/ssthandler.h"
22#include "sst/core/subcomponent.h"
28namespace SST::CoreTest::MessageMesh {
35 explicit PortInterface(ComponentId_t
id) :
39 virtual ~PortInterface() {}
65 template <
typename classT, auto funcT,
typename dataT =
void>
68 virtual void setNotifyOnReceive(
HandlerBase* functor) { functor_ = functor; }
72 virtual size_t getPortCount() = 0;
76 SubComponent::serialize_order(ser);
90 explicit RouteInterface(ComponentId_t
id) :
94 virtual ~RouteInterface() {}
96 virtual void send(
MessageEvent* ev,
int incoming_port) = 0;
98 virtual void sendInitialEvents(
int mod) = 0;
108 SST_ELI_REGISTER_COMPONENT(
111 "message_mesh.enclosing_component",
112 SST_ELI_ELEMENT_VERSION(1,0,0),
113 "Base element that encloses the SubComponents that actually provide the functionality",
114 COMPONENT_CATEGORY_NETWORK
117 SST_ELI_DOCUMENT_PARAMS(
118 {
"id",
"Id for this component",
""},
119 {
"mod",
"Port modulus to restrict number of initial events",
"1"},
120 {
"verbose",
"Print message count at end of simulation",
"True"},
121 {
"stats",
"Statistics per component",
"0"}
124 SST_ELI_DOCUMENT_STATISTICS(
125 {
"stat",
"Test statistic",
"count", 1},
128 SST_ELI_DOCUMENT_PORTS(
131 SST_ELI_DOCUMENT_SUBCOMPONENT_SLOTS(
132 {
"ports",
"Slot that the ports objects go in",
"SST::CoreTest::MessageMesh::PortInterface" },
133 {
"route",
"Slot that the route object goes in",
"SST::CoreTest::MessageMesh::RouteInterface" }
136 SST_ELI_IS_CHECKPOINTABLE()
138 EnclosingComponent(ComponentId_t
id,
Params& params);
139 EnclosingComponent() {}
140 ~EnclosingComponent() {}
142 void setup()
override;
151 std::vector<PortInterface*> ports_;
155 std::vector<Statistic<uint64_t>*> stats_;
158 int message_count_ = 0;
160 bool verbose_ =
true;
165class PortSlot :
public PortInterface
169 SST_ELI_REGISTER_SUBCOMPONENT(
172 "message_mesh.port_slot",
173 SST_ELI_ELEMENT_VERSION(1,0,0),
174 "SubComponent implementing PortInterface that simply defers to another loaded PortInterface",
178 SST_ELI_DOCUMENT_PARAMS(
181 SST_ELI_DOCUMENT_STATISTICS(
184 SST_ELI_DOCUMENT_PORTS(
187 SST_ELI_DOCUMENT_SUBCOMPONENT_SLOTS(
188 {
"port",
"Slot to load the real PortInterface object",
"SST::CoreTest::MessageMesh::PortInterface" }
191 SST_ELI_IS_CHECKPOINTABLE()
193 PortSlot(ComponentId_t
id,
Params& params);
197 void send(
MessageEvent* ev,
size_t index)
override { port_->send(ev, index); }
198 void setNotifyOnReceive(
HandlerBase* functor)
override { port_->setNotifyOnReceive(functor); }
199 size_t getPortCount()
override {
return port_->getPortCount(); }
206 PortInterface* port_ =
nullptr;
210class MessagePort :
public PortInterface
214 SST_ELI_REGISTER_SUBCOMPONENT(
217 "message_mesh.message_port",
218 SST_ELI_ELEMENT_VERSION(1,0,0),
219 "SubComponent implementing PortInterface for sending and receiving messages",
223 SST_ELI_DOCUMENT_PARAMS(
226 SST_ELI_DOCUMENT_STATISTICS(
229 SST_ELI_DOCUMENT_PORTS(
230 {
"port%d",
"Port to send or receive on", {
"" } },
233 SST_ELI_DOCUMENT_SUBCOMPONENT_SLOTS(
236 MessagePort(ComponentId_t
id,
Params& params);
241 void handleEvent(
Event* ev);
242 size_t getPortCount()
override {
return links_.size(); }
248 std::vector<Link*> links_;
251class RouteMessage :
public RouteInterface
255 SST_ELI_REGISTER_SUBCOMPONENT(
258 "message_mesh.route_message",
259 SST_ELI_ELEMENT_VERSION(1,0,0),
260 "SubComponent implementing message routing",
264 SST_ELI_DOCUMENT_PARAMS(
267 SST_ELI_DOCUMENT_STATISTICS(
268 {
"msg_count",
"Message counter",
"count", 1},
271 SST_ELI_DOCUMENT_PORTS(
274 SST_ELI_DOCUMENT_SUBCOMPONENT_SLOTS(
277 SST_ELI_IS_CHECKPOINTABLE()
279 RouteMessage(ComponentId_t
id,
Params& params, std::vector<PortInterface*>& ports,
int my_id);
283 void send(
MessageEvent* ev,
int incoming_port)
override;
285 void sendInitialEvents(
int mod)
override;
291 std::vector<PortInterface*> ports_;
292 std::vector<size_t> counts_;
Main component object for the simulation.
Definition component.h:32
Definition enclosingComponent.h:105
void finish() override
Called after complete phase, but before objects are destroyed.
Definition enclosingComponent.cc:84
void setup() override
Called after all components have been constructed and initialization has completed,...
Definition enclosingComponent.cc:72
Definition messageEvent.h:20
Definition enclosingComponent.h:211
Definition enclosingComponent.h:31
SSTHandlerBase< void, Event * > HandlerBase
Base handler for event delivery.
Definition enclosingComponent.h:44
SSTHandler< void, Event *, classT, dataT, funcT > Handler
Used to create checkpointable handlers to notify the component when a message has arrived.
Definition enclosingComponent.h:66
Definition enclosingComponent.h:166
Definition enclosingComponent.h:86
Definition enclosingComponent.h:252
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
Parameter store.
Definition params.h:65
Implements the base class for random number generators for the SST core.
Definition rng.h:30
Base template for handlers which take a class defined argument.
Definition ssthandler.h:79
Base template for the class.
Definition ssthandler.h:1102
Forms the template defined base class for statistics gathering within SST.
Definition statbase.h:369
SubComponent is a class loadable through the factory which allows dynamic functionality to be added t...
Definition subcomponent.h:29