SST 15.0
Structural Simulation Toolkit
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
22namespace SST::CoreTestMemPoolTest {
23
24// We'll have 4 different sized events
25
26class MemPoolTestEvent1 : public SST::Event
27{
28public:
29 MemPoolTestEvent1() :
31 {}
32
33 void serialize_order(SST::Core::Serialization::serializer& ser) override
34 {
35 Event::serialize_order(ser);
36 SST_SER(array);
37 }
38
40
41 std::string toString() const override
42 {
43 return std::string("MemPoolTestEvent1 to be delivered at ") + std::to_string(getDeliveryTime());
44 }
45
46private:
47 uint64_t array[1];
48};
49
50class MemPoolTestEvent2 : public SST::Event
51{
52public:
53 MemPoolTestEvent2() :
55 {}
56
57 void serialize_order(SST::Core::Serialization::serializer& ser) override
58 {
59 Event::serialize_order(ser);
60 SST_SER(array);
61 }
62
64
65 std::string toString() const override
66 {
67 return std::string("MemPoolTestEvent2 to be delivered at ") + std::to_string(getDeliveryTime());
68 }
69
70private:
71 uint64_t array[2];
72};
73
74class MemPoolTestEvent3 : public SST::Event
75{
76public:
77 MemPoolTestEvent3() :
79 {}
80
81 void serialize_order(SST::Core::Serialization::serializer& ser) override
82 {
83 Event::serialize_order(ser);
84 SST_SER(array);
85 }
86
88
89 std::string toString() const override
90 {
91 return std::string("MemPoolTestEvent3 to be delivered at ") + std::to_string(getDeliveryTime());
92 }
93
94private:
95 uint64_t array[3];
96};
97
98class MemPoolTestEvent4 : public SST::Event
99{
100public:
101 MemPoolTestEvent4() :
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
118private:
119 uint64_t array[4];
120};
121
122class MemPoolTestPerformanceEvent : public SST::Event
123{
124public:
125 MemPoolTestPerformanceEvent() :
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{
146public:
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
179private:
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
SimTime_t getDeliveryTime() const
Return the time at which this Activity will be delivered.
Definition activity.h:148
Main component object for the simulation.
Definition component.h:31
Definition coreTest_MemPoolTest.h:145
void setup() override
Called after all components have been constructed and initialization has completed,...
Definition coreTest_MemPoolTest.cc:86
void finish() override
Called after complete phase, but before objects are destroyed.
Definition coreTest_MemPoolTest.cc:129
Definition coreTest_MemPoolTest.h:27
std::string toString() const override
Get a string represenation of the event.
Definition coreTest_MemPoolTest.h:41
Definition coreTest_MemPoolTest.h:51
std::string toString() const override
Get a string represenation of the event.
Definition coreTest_MemPoolTest.h:65
Definition coreTest_MemPoolTest.h:75
std::string toString() const override
Get a string represenation of the event.
Definition coreTest_MemPoolTest.h:89
Definition coreTest_MemPoolTest.h:99
std::string toString() const override
Get a string represenation of the event.
Definition coreTest_MemPoolTest.h:113
Definition coreTest_MemPoolTest.h:123
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition serializer.h:45
Base class for Events - Items sent across links to communicate between components.
Definition event.h:35
Parameter store.
Definition params.h:58