12 #ifndef SST_CORE_PROFILE_COMPONENTPROFILETOOL_H
13 #define SST_CORE_PROFILE_COMPONENTPROFILETOOL_H
15 #include "sst/core/eli/elementinfo.h"
16 #include "sst/core/profile/profiletool.h"
17 #include "sst/core/sst_types.h"
18 #include "sst/core/warnmacros.h"
50 SST_ELI_DOCUMENT_PARAMS(
51 {
"level",
"Level at which to track profile (global, type, component, subcomponent)",
"type" },
52 {
"track_points",
"Determines whether independent profiling points are tracked",
"true" },
55 enum class Profile_Level { Global, Type,
Component, Subcomponent };
60 virtual uintptr_t registerProfilePoint(
61 const std::string& point, ComponentId_t
id,
const std::string& name,
const std::string& type) = 0;
63 getKeyForCodeSegment(
const std::string& point, ComponentId_t
id,
const std::string& name,
const std::string& type);
66 Profile_Level profile_level_;
84 virtual void codeSegmentStart(uintptr_t UNUSED(key)) {}
85 virtual void codeSegmentEnd(uintptr_t UNUSED(key)) {}
93 inline void codeSegmentStart()
95 for (
auto& x : tools ) {
96 x.first->codeSegmentStart(x.second);
99 inline void codeSegmentEnd()
101 for (
auto& x : tools ) {
102 x.first->codeSegmentEnd(x.second);
106 void registerProfilePoint(
108 const std::string& type)
110 uintptr_t key = tool->registerProfilePoint(point,
id, name, type);
111 tools.push_back(std::make_pair(tool, key));
115 std::vector<std::pair<ComponentCodeSegmentProfileTool*, uintptr_t>> tools;
127 SST_ELI_REGISTER_PROFILETOOL(
131 "profile.component.codesegment.count",
132 SST_ELI_ELEMENT_VERSION(0, 1, 0),
133 "Profiler that will count times through a marked code segment"
140 uintptr_t registerProfilePoint(
141 const std::string& point, ComponentId_t
id,
const std::string& name,
const std::string& type)
override;
143 void codeSegmentStart(uintptr_t key)
override;
145 void outputData(FILE* fp)
override;
148 std::map<std::string, uint64_t> counts_;
155 template <
typename T>
158 struct segment_data_t
163 segment_data_t() : time(0), count(0) {}
171 uintptr_t registerProfilePoint(
172 const std::string& point, ComponentId_t
id,
const std::string& name,
const std::string& type)
override;
174 void codeSegmentStart(uintptr_t UNUSED(key))
override { start_time_ = T::now(); }
176 void codeSegmentEnd(uintptr_t key)
override
178 auto total_time = T::now() - start_time_;
179 segment_data_t* entry =
reinterpret_cast<segment_data_t*
>(key);
180 entry->time += std::chrono::duration_cast<std::chrono::nanoseconds>(total_time).count();
184 void outputData(FILE* fp)
override;
187 typename T::time_point start_time_;
188 std::map<std::string, segment_data_t> times_;
Main component object for the simulation.
Definition: baseComponent.h:52
Main component object for the simulation.
Definition: component.h:31
Parameter store.
Definition: params.h:56