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/sst_types.h"
18#include "sst/core/ssthandler.h"
19#include "sst/core/warnmacros.h"
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 };
45 virtual void eventSent(uintptr_t UNUSED(key),
Event* UNUSED(ev)) {}
47 bool profileSends() {
return profile_sends_; }
48 bool profileReceives() {
return profile_receives_; }
53 Profile_Level profile_level_;
57 bool profile_receives_;
72 event_data_t() : recv_count(0), send_count(0) {}
76 SST_ELI_REGISTER_PROFILETOOL(
80 "profile.handler.event.count",
81 SST_ELI_ELEMENT_VERSION(0, 1, 0),
82 "Profiler that will count calls to handler functions"
91 void handlerStart(uintptr_t key)
override;
92 void eventSent(uintptr_t UNUSED(key),
Event* UNUSED(ev))
override;
94 void outputData(FILE* fp)
override;
97 std::map<std::string, event_data_t> counts_;
113 event_data_t() : recv_time(0), recv_count(0), send_count(0) {}
123 void handlerStart(uintptr_t UNUSED(key))
override { start_time_ = T::now(); }
125 void handlerEnd(uintptr_t key)
override
127 auto total_time = T::now() - start_time_;
128 event_data_t* entry =
reinterpret_cast<event_data_t*
>(key);
129 entry->recv_time += std::chrono::duration_cast<std::chrono::nanoseconds>(total_time).count();
133 void eventSent(uintptr_t key,
Event* UNUSED(ev))
override {
reinterpret_cast<event_data_t*
>(key)->send_count++; }
135 void outputData(FILE* fp)
override;
138 typename T::time_point start_time_;
139 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
Parameter store.
Definition: params.h:56