SST  15.1.0
StructuralSimulationToolkit
coreTest_MemPoolTest.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_MEMPOOLTEST_H
13 #define SST_CORE_CORETEST_MEMPOOLTEST_H
14 
15 #include "sst/core/component.h"
16 #include "sst/core/link.h"
17 
18 #include <cstdint>
19 #include <string>
20 #include <vector>
21 
22 namespace SST::CoreTestMemPoolTest {
23 
24 // We'll have 4 different sized events
25 
27 {
28 public:
30  SST::Event()
31  {}
32 
33  void serialize_order(SST::Core::Serialization::serializer& ser) override
34  {
35  Event::serialize_order(ser);
36  SST_SER(array);
37  }
38 
39  ImplementSerializable(SST::CoreTestMemPoolTest::MemPoolTestEvent1);
40 
41  std::string toString() const override
42  {
43  return std::string("MemPoolTestEvent1 to be delivered at ") + std::to_string(getDeliveryTime());
44  }
45 
46 private:
47  uint64_t array[1];
48 };
49 
51 {
52 public:
54  SST::Event()
55  {}
56 
57  void serialize_order(SST::Core::Serialization::serializer& ser) override
58  {
59  Event::serialize_order(ser);
60  SST_SER(array);
61  }
62 
63  ImplementSerializable(SST::CoreTestMemPoolTest::MemPoolTestEvent2);
64 
65  std::string toString() const override
66  {
67  return std::string("MemPoolTestEvent2 to be delivered at ") + std::to_string(getDeliveryTime());
68  }
69 
70 private:
71  uint64_t array[2];
72 };
73 
75 {
76 public:
78  SST::Event()
79  {}
80 
81  void serialize_order(SST::Core::Serialization::serializer& ser) override
82  {
83  Event::serialize_order(ser);
84  SST_SER(array);
85  }
86 
87  ImplementSerializable(SST::CoreTestMemPoolTest::MemPoolTestEvent3);
88 
89  std::string toString() const override
90  {
91  return std::string("MemPoolTestEvent3 to be delivered at ") + std::to_string(getDeliveryTime());
92  }
93 
94 private:
95  uint64_t array[3];
96 };
97 
99 {
100 public:
102  SST::Event()
103  {}
104 
105  void serialize_order(SST::Core::Serialization::serializer& ser) override
106  {
107  Event::serialize_order(ser);
108  SST_SER(array);
109  }
110 
111  ImplementSerializable(SST::CoreTestMemPoolTest::MemPoolTestEvent4);
112 
113  std::string toString() const override
114  {
115  return std::string("MemPoolTestEvent4 to be delivered at ") + std::to_string(getDeliveryTime());
116  }
117 
118 private:
119  uint64_t array[4];
120 };
121 
123 {
124 public:
126  SST::Event()
127  {}
128 
129  double rate;
130 
131  void serialize_order(SST::Core::Serialization::serializer& ser) override
132  {
133  Event::serialize_order(ser);
134  SST_SER(rate);
135  }
136 
138 };
139 
140 
141 // Class will just send messages to other side of link. They can be
142 // configured to send different size events to test the mempool
143 // overflow feature
145 {
146 public:
147  SST_ELI_REGISTER_COMPONENT(
149  "coreTestElement",
150  "memPoolTestComponent",
151  SST_ELI_ELEMENT_VERSION(1,0,0),
152  "Test MemPool overflow",
153  COMPONENT_CATEGORY_UNCATEGORIZED
154  )
155 
156  SST_ELI_DOCUMENT_PARAMS(
157  { "event_size", "Size of event to sent (valid sizes: 1-4).", "1" },
158  { "initial_events", "Number of events to send to each other component", "256" },
159  { "undeleted_events", "Number of events to leave undeleted", "0" },
160  { "check_overflow", "Check to see whether MemPool overflow is working correctly", "true"}
161  )
162 
163  SST_ELI_DOCUMENT_PORTS(
164  {"port%d", "Links to other test components", { "CoreTestMemPoolTest.MemPoolTestEvent", "" } }
165  )
166 
167  SST_ELI_DOCUMENT_ATTRIBUTES(
168  { "test_element", "true" }
169  )
170 
171  MemPoolTestComponent(ComponentId_t id, Params& params);
173 
174  void eventHandler(Event* ev, int port);
175  void setup() override;
176  void finish() override;
177  void complete(unsigned int phase) override;
178 
179 private:
180  int event_size;
181  std::vector<Link*> links;
182  int events_sent;
183  int events_recv;
184  int initial_events;
185  double event_rate;
186  int undeleted_events;
187  bool check_overflow;
188 
189  Event* createEvent();
190 };
191 
192 } // namespace SST::CoreTestMemPoolTest
193 
194 #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:42
Main component object for the simulation.
Definition: component.h:30
Definition: coreTest_MemPoolTest.h:74
Definition: coreTest_MemPoolTest.h:22
Definition: coreTest_MemPoolTest.h:50
Definition: coreTest_MemPoolTest.h:26
Definition: coreTest_MemPoolTest.h:98
void finish() override
Called after complete phase, but before objects are destroyed.
Definition: coreTest_MemPoolTest.cc:130
std::string toString() const override
Get a string represenation of the event.
Definition: coreTest_MemPoolTest.h:41
SimTime_t getDeliveryTime() const
Return the time at which this Activity will be delivered.
Definition: activity.h:150
std::string toString() const override
Get a string represenation of the event.
Definition: coreTest_MemPoolTest.h:113
Parameter store.
Definition: params.h:63
void setup() override
Called after all components have been constructed and initialization has completed, but before simulation time has begun.
Definition: coreTest_MemPoolTest.cc:87
std::string toString() const override
Get a string represenation of the event.
Definition: coreTest_MemPoolTest.h:89
Base class for Events - Items sent across links to communicate between components.
Definition: event.h:40
Definition: coreTest_MemPoolTest.h:144
Definition: coreTest_MemPoolTest.h:122
std::string toString() const override
Get a string represenation of the event.
Definition: coreTest_MemPoolTest.h:65