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" 54 SST_ELI_DOCUMENT_PARAMS(
55 {
"level",
"Level at which to track profile (global, type, component, subcomponent)",
"type" },
56 {
"track_points",
"Determines whether independent profiling points are tracked",
"true" },
59 enum class Profile_Level { Global, Type,
Component, Subcomponent };
64 virtual uintptr_t registerProfilePoint(
65 const std::string& point, ComponentId_t
id,
const std::string& name,
const std::string& type) = 0;
66 std::string getKeyForCodeSegment(
67 const std::string& point, ComponentId_t
id,
const std::string& name,
const std::string& type);
70 Profile_Level profile_level_;
88 virtual void codeSegmentStart(uintptr_t UNUSED(key)) {}
89 virtual void codeSegmentEnd(uintptr_t UNUSED(key)) {}
97 inline void codeSegmentStart()
99 for (
auto& x : tools ) {
100 x.first->codeSegmentStart(x.second);
103 inline void codeSegmentEnd()
105 for (
auto& x : tools ) {
106 x.first->codeSegmentEnd(x.second);
111 const std::string& name,
const std::string& type)
113 uintptr_t key = tool->registerProfilePoint(point,
id, name, type);
114 tools.push_back(std::make_pair(tool, key));
118 std::vector<std::pair<ComponentCodeSegmentProfileTool*, uintptr_t>> tools;
130 SST_ELI_REGISTER_PROFILETOOL(
134 "profile.component.codesegment.count",
135 SST_ELI_ELEMENT_VERSION(0, 1, 0),
136 "Profiler that will count times through a marked code segment" 143 uintptr_t registerProfilePoint(
144 const std::string& point, ComponentId_t
id,
const std::string& name,
const std::string& type)
override;
146 void codeSegmentStart(uintptr_t key)
override;
148 void outputData(FILE* fp)
override;
151 std::map<std::string, uint64_t> counts_;
158 template <
typename T>
161 struct segment_data_t
177 uintptr_t registerProfilePoint(
178 const std::string& point, ComponentId_t
id,
const std::string& name,
const std::string& type)
override;
180 void codeSegmentStart(uintptr_t UNUSED(key))
override { start_time_ = T::now(); }
182 void codeSegmentEnd(uintptr_t key)
override 184 auto total_time = T::now() - start_time_;
185 segment_data_t* entry =
reinterpret_cast<segment_data_t*
>(key);
186 entry->time += std::chrono::duration_cast<std::chrono::nanoseconds>(total_time).count();
190 void outputData(FILE* fp)
override;
193 typename T::time_point start_time_;
194 std::map<std::string, segment_data_t> times_;
199 #endif // SST_CORE_PROFILE_COMPONENTPROFILETOOL_H
Main component object for the simulation.
Definition: component.h:30
Main component object for the simulation.
Definition: baseComponent.h:64
Parameter store.
Definition: params.h:63