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"
27namespace SST::Profile {
34 SST_ELI_DOCUMENT_PARAMS(
35 {
"level",
"Level at which to track profile (global, type, component, subcomponent)",
"type" },
36 {
"track_ports",
"Controls whether to track by individual ports",
"false" },
37 {
"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" },
38 {
"profile_receives",
"Controls whether receives are profiled",
"true" },
41 enum class Profile_Level { Global, Type,
Component, Subcomponent };
43 EventHandlerProfileTool(
const std::string& name,
Params& params);
46 bool profileSends() {
return profile_sends_; }
47 bool profileReceives() {
return profile_receives_; }
51 void beforeHandler(uintptr_t UNUSED(key),
const Event* UNUSED(event))
override {}
52 void afterHandler(uintptr_t UNUSED(key))
override {}
53 void eventSent(uintptr_t UNUSED(key),
Event*& UNUSED(ev))
override {}
59 Profile_Level profile_level_;
63 bool profile_receives_;
85 SST_ELI_REGISTER_PROFILETOOL(
89 "profile.handler.event.count",
90 SST_ELI_ELEMENT_VERSION(0, 1, 0),
91 "Profiler that will count calls to handler functions"
101 void beforeHandler(uintptr_t key,
const SST::Event* event)
override;
104 void outputData(FILE* fp)
override;
107 std::map<std::string, event_data_t> counts_;
115class EventHandlerProfileToolTime :
public EventHandlerProfileTool
131 EventHandlerProfileToolTime(
const std::string& name,
Params& params);
133 virtual ~EventHandlerProfileToolTime() {}
138 void beforeHandler(uintptr_t UNUSED(key),
const Event* UNUSED(event))
override { start_time_ = T::now(); }
140 void afterHandler(uintptr_t key)
override
142 auto total_time = T::now() - start_time_;
143 event_data_t* entry =
reinterpret_cast<event_data_t*
>(key);
144 entry->recv_time += std::chrono::duration_cast<std::chrono::nanoseconds>(total_time).count();
148 void eventSent(uintptr_t key,
Event*& UNUSED(ev))
override {
reinterpret_cast<event_data_t*
>(key)->send_count++; }
150 void outputData(FILE* fp)
override;
153 typename T::time_point start_time_;
154 std::map<std::string, event_data_t> times_;
Main component object for the simulation.
Definition component.h:31
Base class for Events - Items sent across links to communicate between components.
Definition event.h:35
Attach point for inspecting, modifying or dropping events sent on the Link.
Definition link.h:72
Parameter store.
Definition params.h:58