Skip to content

Commit e66203b

Browse files
Merge pull request #1189 from sstsimulator/devel
Automatically Merged using SST Master Branch Merger
2 parents 744bb94 + 357aa44 commit e66203b

21 files changed

+945
-334
lines changed

src/sst/core/Makefile.am

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ sst_core_sources = \
216216
unitAlgebra.cc \
217217
module.cc \
218218
realtime.cc \
219-
ssthandler.cc \
220219
sstpart.cc \
221220
timeVortex.cc \
222221
serialization/objectMap.cc \

src/sst/core/baseComponent.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ BaseComponent::registerClock_impl(TimeConverter* tc, Clock::HandlerBase* handler
129129
for ( auto* tool : tools ) {
130130
ClockHandlerMetaData mdata(my_info->getID(), getName(), getType());
131131
// Add the receive profiler to the handler
132-
handler->addProfileTool(tool, mdata);
132+
handler->attachTool(tool, mdata);
133133
}
134134

135135
// if regAll is true set tc as the default for the component and
@@ -295,10 +295,10 @@ BaseComponent::configureLink(const std::string& name, TimeConverter* time_base,
295295
EventHandlerMetaData mdata(my_info->getID(), getName(), getType(), name);
296296

297297
// Add the receive profiler to the handler
298-
if ( tool->profileReceives() ) handler->addProfileTool(tool, mdata);
298+
if ( tool->profileReceives() ) handler->attachTool(tool, mdata);
299299

300300
// Add the send profiler to the link
301-
if ( tool->profileSends() ) tmp->addProfileTool(tool, mdata);
301+
if ( tool->profileSends() ) tmp->attachTool(tool, mdata);
302302
}
303303
}
304304
if ( nullptr != time_base )

src/sst/core/clock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class Clock : public Action
120120
};
121121

122122

123-
class ClockHandlerMetaData : public HandlerMetaData
123+
class ClockHandlerMetaData : public AttachPointMetaData
124124
{
125125
public:
126126
const ComponentId_t comp_id;

src/sst/core/event.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class EmptyEvent : public Event
217217
ImplementSerializable(SST::EmptyEvent)
218218
};
219219

220-
class EventHandlerMetaData : public HandlerMetaData
220+
class EventHandlerMetaData : public AttachPointMetaData
221221
{
222222
public:
223223
const ComponentId_t comp_id;

src/sst/core/link.cc

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -461,28 +461,6 @@ class NullEvent : public Event
461461
};
462462

463463

464-
class LinkSendProfileToolList
465-
{
466-
public:
467-
LinkSendProfileToolList() {}
468-
469-
inline void eventSent(Event* ev)
470-
{
471-
for ( auto& x : tools ) {
472-
x.first->eventSent(x.second, ev);
473-
}
474-
}
475-
476-
void addProfileTool(SST::Profile::EventHandlerProfileTool* tool, const EventHandlerMetaData& mdata)
477-
{
478-
auto key = tool->registerHandler(mdata);
479-
tools.push_back(std::make_pair(tool, key));
480-
}
481-
482-
private:
483-
std::vector<std::pair<SST::Profile::EventHandlerProfileTool*, uintptr_t>> tools;
484-
};
485-
486464
Link::Link(LinkId_t tag) :
487465
send_queue(nullptr),
488466
delivery_info(0),
@@ -631,7 +609,7 @@ Link::replaceFunctor(Event::HandlerBase* functor)
631609
type = HANDLER;
632610
if ( pair_link->delivery_info ) {
633611
auto* handler = reinterpret_cast<Event::HandlerBase*>(pair_link->delivery_info);
634-
functor->transferProfilingInfo(handler);
612+
functor->transferAttachedToolInfo(handler);
635613
delete handler;
636614
}
637615
pair_link->delivery_info = reinterpret_cast<uintptr_t>(functor);
@@ -663,7 +641,13 @@ Link::send_impl(SimTime_t delay, Event* event)
663641
event->addRecvComponent(pair_link->comp, pair_link->ctype, pair_link->port);
664642
#endif
665643

666-
if ( profile_tools ) profile_tools->eventSent(event);
644+
if ( profile_tools ) {
645+
for ( auto& x : *profile_tools ) {
646+
x.first->eventSent(x.second, event);
647+
// Check to see if the event was deleted. If so, return.
648+
if ( nullptr == event ) return;
649+
}
650+
}
667651
send_queue->insert(event);
668652
}
669653

@@ -803,10 +787,11 @@ Link::createUniqueGlobalLinkName(RankInfo local_rank, uintptr_t local_ptr, RankI
803787
}
804788

805789
void
806-
Link::addProfileTool(SST::Profile::EventHandlerProfileTool* tool, const EventHandlerMetaData& mdata)
790+
Link::attachTool(AttachPoint* tool, const AttachPointMetaData& mdata)
807791
{
808-
if ( !profile_tools ) profile_tools = new LinkSendProfileToolList();
809-
profile_tools->addProfileTool(tool, mdata);
792+
if ( !profile_tools ) profile_tools = new ToolList();
793+
auto key = tool->registerLinkAttachTool(mdata);
794+
profile_tools->push_back(std::make_pair(tool, key));
810795
}
811796

812797

src/sst/core/link.h

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class LinkPair;
2828
class Simulation_impl;
2929

3030
class UnitAlgebra;
31-
class LinkSendProfileToolList;
3231

3332
namespace Profile {
3433
class EventHandlerProfileTool;
@@ -56,6 +55,43 @@ class alignas(64) Link
5655
friend class SST::Core::Serialization::serialize_impl<Link*>;
5756

5857
public:
58+
/**
59+
Attach point for inspecting, modifying or dropping events
60+
sent on the Link.
61+
62+
NOTE: Using the Link::AttachPoint will noticeably affect the
63+
performance of sending events on Links and it is recommended
64+
that, if possible, Event::HandlerBase::AttachPoint or
65+
Event::HandlerBase::InterceptPoint be used instead.
66+
*/
67+
class AttachPoint
68+
{
69+
public:
70+
/**
71+
Function that will be called when an attach point is
72+
registered with the tool implementing the attach point.
73+
The metadata passed in will be dependent on what type of
74+
tool this is attached to. The uintptr_t returned from this
75+
function will be passed into the eventSent() function.
76+
77+
@param mdata Metadata to be passed into the tool
78+
79+
@return Opaque key that will be passed back into
80+
eventSent() to identify the source of the call
81+
*/
82+
virtual uintptr_t registerLinkAttachTool(const AttachPointMetaData& mdata) = 0;
83+
84+
/**
85+
Function that will be called when an event is sent on a
86+
link with registered attach points. If ev is set to
87+
nullptr, then the event will not be delivered and the tool
88+
should delete the original event.
89+
90+
@param key Opaque key returned from registerLinkAttachTool()
91+
*/
92+
virtual void eventSent(uintptr_t key, Event*& ev) = 0;
93+
};
94+
5995
friend class LinkPair;
6096
friend class RankSync;
6197
friend class ThreadSync;
@@ -285,10 +321,11 @@ class alignas(64) Link
285321
createUniqueGlobalLinkName(RankInfo local_rank, uintptr_t local_ptr, RankInfo remote_rank, uintptr_t remote_ptr);
286322

287323

288-
void addProfileTool(SST::Profile::EventHandlerProfileTool* tool, const EventHandlerMetaData& mdata);
324+
void attachTool(AttachPoint* tool, const AttachPointMetaData& mdata);
289325

290326

291-
LinkSendProfileToolList* profile_tools;
327+
using ToolList = std::vector<std::pair<AttachPoint*, uintptr_t>>;
328+
ToolList* profile_tools;
292329

293330

294331
#ifdef __SST_DEBUG_EVENT_TRACKING__

src/sst/core/profile/clockHandlerProfileTool.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace SST {
2323
namespace Profile {
2424

2525

26-
ClockHandlerProfileTool::ClockHandlerProfileTool(const std::string& name, Params& params) : HandlerProfileToolAPI(name)
26+
ClockHandlerProfileTool::ClockHandlerProfileTool(const std::string& name, Params& params) : ProfileTool(name)
2727
{
2828
std::string level = params.find<std::string>("level", "type");
2929
if ( level == "global" )
@@ -41,7 +41,7 @@ ClockHandlerProfileTool::ClockHandlerProfileTool(const std::string& name, Params
4141
}
4242

4343
std::string
44-
ClockHandlerProfileTool::getKeyForHandler(const HandlerMetaData& mdata)
44+
ClockHandlerProfileTool::getKeyForHandler(const AttachPointMetaData& mdata)
4545
{
4646
const ClockHandlerMetaData& data = dynamic_cast<const ClockHandlerMetaData&>(mdata);
4747

@@ -71,13 +71,13 @@ ClockHandlerProfileToolCount::ClockHandlerProfileToolCount(const std::string& na
7171
{}
7272

7373
uintptr_t
74-
ClockHandlerProfileToolCount::registerHandler(const HandlerMetaData& mdata)
74+
ClockHandlerProfileToolCount::registerHandler(const AttachPointMetaData& mdata)
7575
{
7676
return reinterpret_cast<uintptr_t>(&counts_[getKeyForHandler(mdata)]);
7777
}
7878

7979
void
80-
ClockHandlerProfileToolCount::handlerStart(uintptr_t key)
80+
ClockHandlerProfileToolCount::beforeHandler(uintptr_t key, const Cycle_t& UNUSED(cycle))
8181
{
8282
(*reinterpret_cast<uint64_t*>(key))++;
8383
}
@@ -101,7 +101,7 @@ ClockHandlerProfileToolTime<T>::ClockHandlerProfileToolTime(const std::string& n
101101

102102
template <typename T>
103103
uintptr_t
104-
ClockHandlerProfileToolTime<T>::registerHandler(const HandlerMetaData& mdata)
104+
ClockHandlerProfileToolTime<T>::registerHandler(const AttachPointMetaData& mdata)
105105
{
106106
return reinterpret_cast<uintptr_t>(&times_[getKeyForHandler(mdata)]);
107107
}

src/sst/core/profile/clockHandlerProfileTool.h

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ namespace SST {
2626
namespace Profile {
2727

2828

29-
class ClockHandlerProfileTool : public HandlerProfileToolAPI
29+
class ClockHandlerProfileTool : public ProfileTool, public Clock::HandlerBase::AttachPoint
3030
{
3131
public:
32-
SST_ELI_REGISTER_PROFILETOOL_DERIVED_API(SST::Profile::ClockHandlerProfileTool, SST::HandlerProfileToolAPI, Params&)
32+
SST_ELI_REGISTER_PROFILETOOL_DERIVED_API(SST::Profile::ClockHandlerProfileTool, SST::Profile::ProfileTool, Params&)
3333

3434
SST_ELI_DOCUMENT_PARAMS(
3535
{ "level", "Level at which to track profile (global, type, component, subcomponent)", "type" },
@@ -39,8 +39,13 @@ class ClockHandlerProfileTool : public HandlerProfileToolAPI
3939

4040
ClockHandlerProfileTool(const std::string& name, Params& params);
4141

42+
// Default implementations of attach point functions for profile
43+
// tools that don't use them
44+
void beforeHandler(uintptr_t UNUSED(key), const Cycle_t& UNUSED(cycle)) override {}
45+
void afterHandler(uintptr_t UNUSED(key), const bool& UNUSED(remove)) override {}
46+
4247
protected:
43-
std::string getKeyForHandler(const HandlerMetaData& mdata);
48+
std::string getKeyForHandler(const AttachPointMetaData& mdata);
4449

4550
Profile_Level profile_level_;
4651
};
@@ -66,9 +71,9 @@ class ClockHandlerProfileToolCount : public ClockHandlerProfileTool
6671

6772
virtual ~ClockHandlerProfileToolCount() {}
6873

69-
uintptr_t registerHandler(const HandlerMetaData& mdata) override;
74+
uintptr_t registerHandler(const AttachPointMetaData& mdata) override;
7075

71-
void handlerStart(uintptr_t key) override;
76+
void beforeHandler(uintptr_t key, const Cycle_t& cycle) override;
7277

7378
void outputData(FILE* fp) override;
7479

@@ -96,11 +101,11 @@ class ClockHandlerProfileToolTime : public ClockHandlerProfileTool
96101

97102
virtual ~ClockHandlerProfileToolTime() {}
98103

99-
uintptr_t registerHandler(const HandlerMetaData& mdata) override;
104+
uintptr_t registerHandler(const AttachPointMetaData& mdata) override;
100105

101-
void handlerStart(uintptr_t UNUSED(key)) override { start_time_ = T::now(); }
106+
void beforeHandler(uintptr_t UNUSED(key), const Cycle_t& UNUSED(cycle)) override { start_time_ = T::now(); }
102107

103-
void handlerEnd(uintptr_t key) override
108+
void afterHandler(uintptr_t key, const bool& UNUSED(remove)) override
104109
{
105110
auto total_time = T::now() - start_time_;
106111
clock_data_t* entry = reinterpret_cast<clock_data_t*>(key);

src/sst/core/profile/eventHandlerProfileTool.cc

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace SST {
2323
namespace Profile {
2424

2525

26-
EventHandlerProfileTool::EventHandlerProfileTool(const std::string& name, Params& params) : HandlerProfileToolAPI(name)
26+
EventHandlerProfileTool::EventHandlerProfileTool(const std::string& name, Params& params) : ProfileTool(name)
2727
{
2828
std::string level = params.find<std::string>("level", "type");
2929
if ( level == "global" )
@@ -46,7 +46,7 @@ EventHandlerProfileTool::EventHandlerProfileTool(const std::string& name, Params
4646
}
4747

4848
std::string
49-
EventHandlerProfileTool::getKeyForHandler(const HandlerMetaData& mdata)
49+
EventHandlerProfileTool::getKeyForHandler(const AttachPointMetaData& mdata)
5050
{
5151
const EventHandlerMetaData& data = dynamic_cast<const EventHandlerMetaData&>(mdata);
5252

@@ -78,19 +78,25 @@ EventHandlerProfileToolCount::EventHandlerProfileToolCount(const std::string& na
7878
{}
7979

8080
uintptr_t
81-
EventHandlerProfileToolCount::registerHandler(const HandlerMetaData& mdata)
81+
EventHandlerProfileToolCount::registerHandler(const AttachPointMetaData& mdata)
82+
{
83+
return reinterpret_cast<uintptr_t>(&counts_[getKeyForHandler(mdata)]);
84+
}
85+
86+
uintptr_t
87+
EventHandlerProfileToolCount::registerLinkAttachTool(const AttachPointMetaData& mdata)
8288
{
8389
return reinterpret_cast<uintptr_t>(&counts_[getKeyForHandler(mdata)]);
8490
}
8591

8692
void
87-
EventHandlerProfileToolCount::handlerStart(uintptr_t key)
93+
EventHandlerProfileToolCount::beforeHandler(uintptr_t key, const Event* UNUSED(event))
8894
{
8995
reinterpret_cast<event_data_t*>(key)->recv_count++;
9096
}
9197

9298
void
93-
EventHandlerProfileToolCount::eventSent(uintptr_t key, Event* UNUSED(ev))
99+
EventHandlerProfileToolCount::eventSent(uintptr_t key, Event*& UNUSED(ev))
94100
{
95101
reinterpret_cast<event_data_t*>(key)->send_count++;
96102
}
@@ -120,7 +126,14 @@ EventHandlerProfileToolTime<T>::EventHandlerProfileToolTime(const std::string& n
120126

121127
template <typename T>
122128
uintptr_t
123-
EventHandlerProfileToolTime<T>::registerHandler(const HandlerMetaData& mdata)
129+
EventHandlerProfileToolTime<T>::registerHandler(const AttachPointMetaData& mdata)
130+
{
131+
return reinterpret_cast<uintptr_t>(&times_[getKeyForHandler(mdata)]);
132+
}
133+
134+
template <typename T>
135+
uintptr_t
136+
EventHandlerProfileToolTime<T>::registerLinkAttachTool(const AttachPointMetaData& mdata)
124137
{
125138
return reinterpret_cast<uintptr_t>(&times_[getKeyForHandler(mdata)]);
126139
}

0 commit comments

Comments
 (0)