12 #ifndef SST_CORE_PROFILE_EVENTHANDLERPROFILETOOL_H 13 #define SST_CORE_PROFILE_EVENTHANDLERPROFILETOOL_H 15 #include "sst/core/eli/elementinfo.h" 16 #include "sst/core/event.h" 17 #include "sst/core/link.h" 18 #include "sst/core/profile/profiletool.h" 19 #include "sst/core/sst_types.h" 20 #include "sst/core/ssthandler.h" 21 #include "sst/core/warnmacros.h" 35 SST_ELI_DOCUMENT_PARAMS(
36 {
"level",
"Level at which to track profile (global, type, component, subcomponent)",
"type" },
37 {
"track_ports",
"Controls whether to track by individual ports",
"false" },
38 {
"profile_sends",
"Controls whether sends are profiled (due to location of profiling point in the code, turning on send profiling will incur relatively high overhead)",
"false" },
39 {
"profile_receives",
"Controls whether receives are profiled",
"true" },
42 enum class Profile_Level { Global, Type,
Component, Subcomponent };
47 bool profileSends() {
return profile_sends_; }
48 bool profileReceives() {
return profile_receives_; }
52 void beforeHandler(uintptr_t UNUSED(key),
const Event* UNUSED(event))
override {}
53 void afterHandler(uintptr_t UNUSED(key))
override {}
54 void eventSent(uintptr_t UNUSED(key),
Event*& UNUSED(ev))
override {}
60 Profile_Level profile_level_;
64 bool profile_receives_;
86 SST_ELI_REGISTER_PROFILETOOL(
90 "profile.handler.event.count",
91 SST_ELI_ELEMENT_VERSION(0, 1, 0),
92 "Profiler that will count calls to handler functions" 102 void beforeHandler(uintptr_t key,
const SST::Event* event)
override;
105 void outputData(FILE* fp)
override;
108 std::map<std::string, event_data_t> counts_;
115 template <
typename T>
139 void beforeHandler(uintptr_t UNUSED(key),
const Event* UNUSED(event))
override { start_time_ = T::now(); }
141 void afterHandler(uintptr_t key)
override 143 auto total_time = T::now() - start_time_;
144 event_data_t* entry =
reinterpret_cast<event_data_t*
>(key);
145 entry->recv_time += std::chrono::duration_cast<std::chrono::nanoseconds>(total_time).count();
149 void eventSent(uintptr_t key,
Event*& UNUSED(ev))
override {
reinterpret_cast<event_data_t*
>(key)->send_count++; }
151 void outputData(FILE* fp)
override;
154 typename T::time_point start_time_;
155 std::map<std::string, event_data_t> times_;
160 #endif // SST_CORE_PROFILE_EVENTHANDLERPROFILETOOL_H Main component object for the simulation.
Definition: component.h:30
Attach Point to get notified when a handler starts and stops.
Definition: ssthandler.h:117
Parameter store.
Definition: params.h:63
Attach point for inspecting, modifying or dropping events sent on the Link.
Definition: link.h:73
Base class for Events - Items sent across links to communicate between components.
Definition: event.h:40