52 SST_ELI_DOCUMENT_PARAMS(
53 {
"level",
"Level at which to track profile (global, type, component, subcomponent)",
"type" },
54 {
"track_points",
"Determines whether independent profiling points are tracked",
"true" },
57 enum class Profile_Level { Global, Type,
Component, Subcomponent };
59 ComponentProfileTool(
const std::string& name,
Params& params);
62 virtual uintptr_t registerProfilePoint(
63 const std::string& point, ComponentId_t
id,
const std::string& name,
const std::string& type) = 0;
64 std::string getKeyForCodeSegment(
65 const std::string& point, ComponentId_t
id,
const std::string& name,
const std::string& type);
68 Profile_Level profile_level_;
77class ComponentCodeSegmentProfileTool :
public ComponentProfileTool
79 friend class BaseComponent;
84 ComponentCodeSegmentProfileTool(
const std::string& name,
Params& params);
86 virtual void codeSegmentStart(uintptr_t UNUSED(key)) {}
87 virtual void codeSegmentEnd(uintptr_t UNUSED(key)) {}
95 inline void codeSegmentStart()
97 for (
auto& x : tools ) {
98 x.first->codeSegmentStart(x.second);
101 inline void codeSegmentEnd()
103 for (
auto& x : tools ) {
104 x.first->codeSegmentEnd(x.second);
108 void registerProfilePoint(ComponentCodeSegmentProfileTool* tool,
const std::string& point, ComponentId_t
id,
109 const std::string& name,
const std::string& type)
111 uintptr_t key = tool->registerProfilePoint(point,
id, name, type);
112 tools.push_back(std::make_pair(tool, key));
116 std::vector<std::pair<ComponentCodeSegmentProfileTool*, uintptr_t>> tools;
128 SST_ELI_REGISTER_PROFILETOOL(
132 "profile.component.codesegment.count",
133 SST_ELI_ELEMENT_VERSION(0, 1, 0),
134 "Profiler that will count times through a marked code segment"
141 uintptr_t registerProfilePoint(
142 const std::string& point, ComponentId_t
id,
const std::string& name,
const std::string& type)
override;
144 void codeSegmentStart(uintptr_t key)
override;
146 void outputData(FILE* fp)
override;
149 std::map<std::string, uint64_t> counts_;
157class ComponentCodeSegmentProfileToolTime :
public ComponentCodeSegmentProfileTool
159 struct segment_data_t
171 ComponentCodeSegmentProfileToolTime(
const std::string& name,
Params& params);
173 virtual ~ComponentCodeSegmentProfileToolTime() {}
175 uintptr_t registerProfilePoint(
176 const std::string& point, ComponentId_t
id,
const std::string& name,
const std::string& type)
override;
178 void codeSegmentStart(uintptr_t UNUSED(key))
override { start_time_ = T::now(); }
180 void codeSegmentEnd(uintptr_t key)
override
182 auto total_time = T::now() - start_time_;
183 segment_data_t* entry =
reinterpret_cast<segment_data_t*
>(key);
184 entry->time += std::chrono::duration_cast<std::chrono::nanoseconds>(total_time).count();
188 void outputData(FILE* fp)
override;
191 typename T::time_point start_time_;
192 std::map<std::string, segment_data_t> times_;