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"
32namespace SST::Profile {
39 SST_ELI_DOCUMENT_PARAMS(
40 {
"level",
"Level at which to track profile (global, type, component, subcomponent)",
"type" },
41 {
"track_ports",
"Controls whether to track by individual ports",
"false" },
42 {
"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" },
43 {
"profile_receives",
"Controls whether receives are profiled",
"true" },
46 enum class Profile_Level { Global, Type,
Component, Subcomponent };
48 EventHandlerProfileTool(
const std::string& name,
Params& params);
51 bool profileSends() {
return profile_sends_; }
52 bool profileReceives() {
return profile_receives_; }
56 void beforeHandler(uintptr_t UNUSED(key),
const Event* UNUSED(event))
override {}
57 void afterHandler(uintptr_t UNUSED(key))
override {}
58 void eventSent(uintptr_t UNUSED(key),
Event*& UNUSED(ev))
override {}
64 Profile_Level profile_level_;
68 bool profile_receives_;
90 SST_ELI_REGISTER_PROFILETOOL(
94 "profile.handler.event.count",
95 SST_ELI_ELEMENT_VERSION(0, 1, 0),
96 "Profiler that will count calls to handler functions"
106 void beforeHandler(uintptr_t key,
const SST::Event* event)
override;
112 std::map<std::string, event_data_t> counts_;
120class EventHandlerProfileToolTime :
public EventHandlerProfileTool
136 EventHandlerProfileToolTime(
const std::string& name,
Params& params);
138 virtual ~EventHandlerProfileToolTime() {}
143 void beforeHandler(uintptr_t UNUSED(key),
const Event* UNUSED(event))
override { start_time_ = T::now(); }
145 void afterHandler(uintptr_t key)
override
147 auto total_time = T::now() - start_time_;
148 event_data_t* entry =
reinterpret_cast<event_data_t*
>(key);
149 entry->recv_time += std::chrono::duration_cast<std::chrono::nanoseconds>(total_time).count();
153 void eventSent(uintptr_t key,
Event*& UNUSED(ev))
override {
reinterpret_cast<event_data_t*
>(key)->send_count++; }
158 typename T::time_point start_time_;
159 std::map<std::string, event_data_t> times_;
Main component object for the simulation.
Definition component.h:32
Base class for Events - Items sent across links to communicate between components.
Definition event.h:41
Attach point for inspecting, modifying or dropping events sent on the Link.
Definition link.h:74
Parameter store.
Definition params.h:65
Definition perfReporter.h:64