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