Skip to content

Commit 625556d

Browse files
authored
Deprecated Handler in favor of Handler2. (#1300)
1 parent 30c40ff commit 625556d

17 files changed

+141
-106
lines changed

src/sst/core/interfaces/simpleNetwork.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,40 @@ class SimpleNetwork : public SubComponent
215215
template <typename classT, typename dataT = void>
216216
using Handler = SSTHandler<bool, int, classT, dataT>;
217217

218+
/**
219+
Used to create checkpointable handlers to notify the endpoint
220+
when the SimpleNetwork sends or recieves a packet.. The
221+
callback function is expected to be in the form of:
222+
223+
bool func(int vn)
224+
225+
In which case, the class is created with:
226+
227+
new SimpleNetwork::Handler2<classname, &classname::function_name>(this)
228+
229+
Or, to add static data, the callback function is:
230+
231+
bool func(int vn, dataT data)
232+
233+
and the class is created with:
234+
235+
new SimpleNetwork::Handler<classname, &classname::function_name, dataT>(this, data)
236+
237+
In both cases, the boolean that's returned indicates whether
238+
the handler should be kept in the list or not. On return
239+
of true, the handler will be kept. On return of false, the
240+
handler will be removed from the clock list.
241+
*/
242+
template <typename classT, auto funcT, typename dataT = void>
243+
using Handler2 = SSTHandler2<bool, int, classT, dataT, funcT>;
244+
218245

219246
public:
220247
/** Constructor, designed to be used via 'loadUserSubComponent or loadAnonymousSubComponent'. */
221248
SimpleNetwork(SST::ComponentId_t id) : SubComponent(id) {}
222249

250+
SimpleNetwork() : SubComponent() {} // For serialization
251+
223252
/**
224253
* Sends a network request during untimed phases (init() and
225254
* complete()).
@@ -318,6 +347,9 @@ class SimpleNetwork : public SubComponent
318347
* @return Link bandwidth of associated link
319348
*/
320349
virtual const UnitAlgebra& getLinkBW() const = 0;
350+
351+
void serialize_order(SST::Core::Serialization::serializer& ser) override { SubComponent::serialize_order(ser); }
352+
ImplementVirtualSerializable(SST::Interfaces::SimpleNetwork)
321353
};
322354

323355
} // namespace SST::Interfaces

src/sst/core/interfaces/stdMem.h

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,24 @@ class StandardMem : public SubComponent
9898
template <typename classT, typename dataT = void>
9999
using Handler = SSTHandler<void, Request*, classT, dataT>;
100100

101-
// /**
102-
// New style (checkpointable) SSTHandler
103-
// */
101+
/**
102+
Used to create checkpointable handlers for request handling.
103+
The callback function is expected to be in the form of:
104+
105+
void func(Request* event)
106+
107+
In which case, the class is created with:
108+
109+
new StdMem::Handler<classname, &classname::function_name>(this)
110+
111+
Or, to add static data, the callback function is:
112+
113+
void func(Request* event, dataT data)
114+
115+
and the class is created with:
116+
117+
new stdMem::Handler<classname, &classname::function_name, dataT>(this, data)
118+
*/
104119
template <typename classT, auto funcT, typename dataT = void>
105120
using Handler2 = SSTHandler2<void, Request*, classT, dataT, funcT>;
106121

src/sst/core/oneshot.h

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class OneShot : public Action
3838
using HandlerBase = SSTHandlerBaseNoArgs<void>;
3939

4040
/**
41-
Used to create handlers for clock. The callback function is
41+
Used to create handlers for OneShot. The callback function is
4242
expected to be in the form of:
4343
4444
void func()
@@ -58,6 +58,27 @@ class OneShot : public Action
5858
template <typename classT, typename dataT = void>
5959
using Handler = SSTHandlerNoArgs<void, classT, dataT>;
6060

61+
/**
62+
Used to create checkpointable handlers for OneShot. The callback function is
63+
expected to be in the form of:
64+
65+
void func()
66+
67+
In which case, the class is created with:
68+
69+
new OneShot::Handler2<classname, &classname::function_name>(this)
70+
71+
Or, to add static data, the callback function is:
72+
73+
void func(dataT data)
74+
75+
and the class is created with:
76+
77+
new OneShot::Handler2<classname, &classname::function_name, dataT>(this, data)
78+
*/
79+
template <typename classT, auto funcT, typename dataT = void>
80+
using Handler2 = SSTHandler2<void, void, classT, dataT, funcT>;
81+
6182

6283
/////////////////////////////////////////////////
6384

src/sst/core/ssthandler.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,9 @@ using SSTHandlerBaseNoArgs = SSTHandlerBase<returnT, void>;
11291129
* Handler class with user-data argument
11301130
*/
11311131
template <typename returnT, typename argT, typename classT, typename dataT = void>
1132-
class SSTHandler : public SSTHandlerBase<returnT, argT>
1132+
class [[deprecated(
1133+
"Handler has been deprecated. Please use Handler2 instead as it supports checkpointing")]] SSTHandler :
1134+
public SSTHandlerBase<returnT, argT>
11331135
{
11341136
private:
11351137
using PtrMember = returnT (classT::*)(argT, dataT);
@@ -1163,7 +1165,8 @@ class SSTHandler : public SSTHandlerBase<returnT, argT>
11631165
* Event Handler class with no user-data.
11641166
*/
11651167
template <typename returnT, typename argT, typename classT>
1166-
class SSTHandler<returnT, argT, classT, void> : public SSTHandlerBase<returnT, argT>
1168+
class [[deprecated("Handler has been deprecated. Please use Handler2 instead as it supports "
1169+
"checkpointing")]] SSTHandler<returnT, argT, classT, void> : public SSTHandlerBase<returnT, argT>
11671170
{
11681171
private:
11691172
using PtrMember = returnT (classT::*)(argT);
@@ -1191,7 +1194,9 @@ class SSTHandler<returnT, argT, classT, void> : public SSTHandlerBase<returnT, a
11911194
* Event Handler class with user-data argument
11921195
*/
11931196
template <typename returnT, typename classT, typename dataT = void>
1194-
class SSTHandlerNoArgs : public SSTHandlerBaseNoArgs<returnT>
1197+
class [[deprecated(
1198+
"Handler has been deprecated. Please use Handler2 instead as it supports checkpointing")]] SSTHandlerNoArgs :
1199+
public SSTHandlerBaseNoArgs<returnT>
11951200
{
11961201
private:
11971202
using PtrMember = returnT (classT::*)(dataT);
@@ -1225,7 +1230,8 @@ class SSTHandlerNoArgs : public SSTHandlerBaseNoArgs<returnT>
12251230
* Event Handler class with no user-data.
12261231
*/
12271232
template <typename returnT, typename classT>
1228-
class SSTHandlerNoArgs<returnT, classT, void> : public SSTHandlerBaseNoArgs<returnT>
1233+
class [[deprecated("Handler has been deprecated. Please use Handler2 instead as it supports "
1234+
"checkpointing")]] SSTHandlerNoArgs<returnT, classT, void> : public SSTHandlerBaseNoArgs<returnT>
12291235
{
12301236
private:
12311237
using PtrMember = returnT (classT::*)();

src/sst/core/statapi/statbase.cc

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -198,58 +198,6 @@ StatisticBase::operator==(StatisticBase& check_stat)
198198
return (getFullStatName() == check_stat.getFullStatName());
199199
}
200200

201-
// GV_TODO: Potentially remove this. It doesn't work as intended and delays should be user-set, not component-set
202-
void
203-
StatisticBase::delayOutput(const char* delay_time)
204-
{
205-
// Make sure only a single output delay is active
206-
if ( false == info_->output_delayed_ ) {
207-
208-
// Save the Stat Output Enable setting and then disable the output
209-
info_->saved_output_enabled_ = info_->output_enabled_;
210-
info_->output_enabled_ = false;
211-
info_->output_delayed_ = true;
212-
213-
Simulation_impl::getSimulation()->registerOneShot(
214-
delay_time, new OneShot::Handler<StatisticBase>(this, &StatisticBase::delayOutputExpiredHandler),
215-
STATISTICCLOCKPRIORITY);
216-
}
217-
}
218-
219-
// GV_TODO: Potentially remove this. It doesn't work as intended and delays should be user-set, not component-set
220-
void
221-
StatisticBase::delayCollection(const char* delay_time)
222-
{
223-
// Make sure only a single collection delay is active
224-
if ( false == info_->collection_delayed_ ) {
225-
226-
// Save the Stat Enable setting and then disable the Stat for collection
227-
info_->saved_stat_enabled_ = info_->stat_enabled_;
228-
info_->stat_enabled_ = false;
229-
info_->collection_delayed_ = true;
230-
231-
Simulation_impl::getSimulation()->registerOneShot(
232-
delay_time, new OneShot::Handler<StatisticBase>(this, &StatisticBase::delayCollectionExpiredHandler),
233-
STATISTICCLOCKPRIORITY);
234-
}
235-
}
236-
237-
void
238-
StatisticBase::delayOutputExpiredHandler()
239-
{
240-
// Restore the Output Enable to its stored value
241-
info_->output_enabled_ = info_->saved_output_enabled_;
242-
info_->output_delayed_ = false;
243-
}
244-
245-
void
246-
StatisticBase::delayCollectionExpiredHandler()
247-
{
248-
// Restore the Statistic Enable to its stored value
249-
info_->stat_enabled_ = info_->saved_stat_enabled_;
250-
info_->collection_delayed_ = false;
251-
}
252-
253201
void
254202
StatisticBase::serialize_order(SST::Core::Serialization::serializer& ser)
255203
{

src/sst/core/statapi/statbase.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -171,17 +171,6 @@ class StatisticBase
171171
/** Return the collection mode that is registered */
172172
StatMode_t getRegisteredCollectionMode() const { return info_->registered_collection_mode_; }
173173

174-
// Delay Methods (Uses OneShot to disable Statistic or Collection)
175-
/** Delay the statistic from outputting data for a specified delay time
176-
* @param delay_time - Value in UnitAlgebra format for delay (i.e. 10ns).
177-
*/
178-
void delayOutput(const char* delay_time);
179-
180-
/** Delay the statistic from collecting data for a specified delay time.
181-
* @param delayTime - Value in UnitAlgebra format for delay (i.e. 10ns).
182-
*/
183-
void delayCollection(const char* delay_time);
184-
185174
// Status of Statistic
186175
/** Indicate that the Statistic is Ready to be used */
187176
virtual bool isReady() const { return true; }
@@ -258,10 +247,6 @@ class StatisticBase
258247

259248
void checkEventForOutput();
260249

261-
// OneShot Callbacks:
262-
void delayOutputExpiredHandler(); // Enable Output in handler
263-
void delayCollectionExpiredHandler(); // Enable Collection in Handler
264-
265250
const StatisticGroup* getGroup() const { return info_->group_; }
266251
void setGroup(const StatisticGroup* group) { info_->group_ = group; }
267252

src/sst/core/statapi/statengine.cc

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,9 @@ StatisticProcessingEngine::finalizeInitialization()
185185
if ( g.outputFreq.getValue() != 0 ) {
186186
Simulation_impl::getSimulation()->registerClock(
187187
g.outputFreq,
188-
new Clock::Handler<StatisticProcessingEngine, StatisticGroup*>(
189-
this, &StatisticProcessingEngine::handleGroupClockEvent, &g),
188+
new Clock::Handler2<
189+
StatisticProcessingEngine, &StatisticProcessingEngine::handleGroupClockEvent, StatisticGroup*>(
190+
this, &g),
190191
STATISTICCLOCKPRIORITY);
191192
}
192193
}
@@ -304,8 +305,9 @@ StatisticProcessingEngine::addPeriodicBasedStatistic(const UnitAlgebra& freq, St
304305
if ( 0 != freq.getValue() ) {
305306

306307
// This tcFactor is not found in the map, so create a new clock handler.
307-
ClockHandler = new Clock::Handler<StatisticProcessingEngine, SimTime_t>(
308-
this, &StatisticProcessingEngine::handleStatisticEngineClockEvent, tcFactor);
308+
ClockHandler = new Clock::Handler2<
309+
StatisticProcessingEngine, &StatisticProcessingEngine::handleStatisticEngineClockEvent, SimTime_t>(
310+
this, tcFactor);
309311

310312
// Set the clock priority so that normal clocks events will occur before
311313
// this clock event.
@@ -357,8 +359,9 @@ StatisticProcessingEngine::setStatisticStartTime(StatisticBase* stat)
357359
// See if the map contains an entry for this factor
358360
if ( m_StartTimeMap.find(tcFactor) == m_StartTimeMap.end() ) {
359361
// This tcFactor is not found in the map, so create a new OneShot handler.
360-
OneShot::HandlerBase* OneShotHandler = new OneShot::Handler<StatisticProcessingEngine, SimTime_t>(
361-
this, &StatisticProcessingEngine::handleStatisticEngineStartTimeEvent, tcFactor);
362+
OneShot::HandlerBase* OneShotHandler = new OneShot::Handler2<
363+
StatisticProcessingEngine, &StatisticProcessingEngine::handleStatisticEngineStartTimeEvent, SimTime_t>(
364+
this, tcFactor);
362365

363366
// Set the OneShot priority so that normal events will occur before this event.
364367
sim->registerOneShot(startTime, OneShotHandler, STATISTICCLOCKPRIORITY);
@@ -393,8 +396,9 @@ StatisticProcessingEngine::setStatisticStopTime(StatisticBase* stat)
393396
// See if the map contains an entry for this factor
394397
if ( m_StopTimeMap.find(tcFactor) == m_StopTimeMap.end() ) {
395398
// This tcFactor is not found in the map, so create a new OneShot handler.
396-
OneShot::HandlerBase* OneShotHandler = new OneShot::Handler<StatisticProcessingEngine, SimTime_t>(
397-
this, &StatisticProcessingEngine::handleStatisticEngineStopTimeEvent, tcFactor);
399+
OneShot::HandlerBase* OneShotHandler = new OneShot::Handler2<
400+
StatisticProcessingEngine, &StatisticProcessingEngine::handleStatisticEngineStopTimeEvent, SimTime_t>(
401+
this, tcFactor);
398402

399403
// Set the OneShot priority so that normal events will occur before this event.
400404
sim->registerOneShot(stopTime, OneShotHandler, STATISTICCLOCKPRIORITY);

src/sst/core/testElements/coreTest_ClockerComponent.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,27 @@ coreTestClockerComponent::coreTestClockerComponent(ComponentId_t id, Params& par
3030

3131
// set our Main Clock
3232
registerClock(
33-
clock_frequency_str, new Clock::Handler<coreTestClockerComponent>(this, &coreTestClockerComponent::tick));
33+
clock_frequency_str, new Clock::Handler2<coreTestClockerComponent, &coreTestClockerComponent::tick>(this));
3434

3535
// Set some other clocks
3636
// Second Clock (5ns)
3737
std::cout << "REGISTER CLOCK #2 at 5 ns" << std::endl;
3838
registerClock(
3939
"5 ns",
40-
new Clock::Handler<coreTestClockerComponent, uint32_t>(this, &coreTestClockerComponent::Clock2Tick, 222));
40+
new Clock::Handler2<coreTestClockerComponent, &coreTestClockerComponent::Clock2Tick, uint32_t>(this, 222));
4141

4242
// Third Clock (15ns)
4343
std::cout << "REGISTER CLOCK #3 at 15 ns" << std::endl;
4444
Clock3Handler =
45-
new Clock::Handler<coreTestClockerComponent, uint32_t>(this, &coreTestClockerComponent::Clock3Tick, 333);
45+
new Clock::Handler2<coreTestClockerComponent, &coreTestClockerComponent::Clock3Tick, uint32_t>(this, 333);
4646
tc = registerClock("15 ns", Clock3Handler);
4747

4848
// Create the OneShot Callback Handlers
49-
callback1Handler = new OneShot::Handler<coreTestClockerComponent, uint32_t>(
50-
this, &coreTestClockerComponent::Oneshot1Callback, 456);
49+
callback1Handler =
50+
new OneShot::Handler2<coreTestClockerComponent, &coreTestClockerComponent::Oneshot1Callback, uint32_t>(
51+
this, 456);
5152
callback2Handler =
52-
new OneShot::Handler<coreTestClockerComponent>(this, &coreTestClockerComponent::Oneshot2Callback);
53+
new OneShot::Handler2<coreTestClockerComponent, &coreTestClockerComponent::Oneshot2Callback>(this);
5354
}
5455

5556
coreTestClockerComponent::coreTestClockerComponent() : Component(-1)

src/sst/core/testElements/coreTest_DistribComponent.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ coreTestDistribComponent::coreTestDistribComponent(ComponentId_t id, Params& par
103103
}
104104

105105
// set our clock
106-
registerClock("1GHz", new Clock::Handler<coreTestDistribComponent>(this, &coreTestDistribComponent::tick));
106+
registerClock("1GHz", new Clock::Handler2<coreTestDistribComponent, &coreTestDistribComponent::tick>(this));
107107
}
108108

109109
coreTestDistribComponent::coreTestDistribComponent() : Component(-1)

src/sst/core/testElements/coreTest_Links.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ coreTestLinks::coreTestLinks(ComponentId_t id, Params& params) : Component(id),
3636
// configure out links
3737
E = configureLink(
3838
"Elink", link_tb.toString(),
39-
new Event::Handler<coreTestLinks, std::string>(this, &coreTestLinks::handleEvent, "East"));
39+
new Event::Handler2<coreTestLinks, &coreTestLinks::handleEvent, std::string>(this, "East"));
4040
W = configureLink(
4141
"Wlink", link_tb.toString(),
42-
new Event::Handler<coreTestLinks, std::string>(this, &coreTestLinks::handleEvent, "West"));
42+
new Event::Handler2<coreTestLinks, &coreTestLinks::handleEvent, std::string>(this, "West"));
4343

4444
if ( found_sendlat ) {
4545
E->addSendLatency(1, send_lat.toString());
@@ -52,7 +52,7 @@ coreTestLinks::coreTestLinks(ComponentId_t id, Params& params) : Component(id),
5252
}
5353

5454
// set our clock
55-
registerClock("100 MHz", new Clock::Handler<coreTestLinks>(this, &coreTestLinks::clockTic));
55+
registerClock("100 MHz", new Clock::Handler2<coreTestLinks, &coreTestLinks::clockTic>(this));
5656
}
5757

5858
// incoming events are scanned and deleted

0 commit comments

Comments
 (0)