33 #ifndef __H__UG__COMMON__PROFILER__
34 #define __H__UG__COMMON__PROFILER__
39 #define CPU_FREQ_BEGIN_AUTO_END(id, file, line) \
40 static unsigned long __freq__##id = FreqAdaptValues::freq(file, line); \
41 AutoFreqAdaptNode __node__freq__##id((__freq__##id));
43 #define CPU_FREQ_END() \
44 FreqAdaptNodeManager::release_latest();
46 #define CPU_FREQ_BEGIN_AUTO_END(name, file, line)
47 #define CPU_FREQ_END()
59 #ifdef UG_PROFILER_SHINY
62 #define SHINY_PROFILER TRUE
63 #include "src/ShinyManager.h"
64 #include "src/ShinyNode.h"
68 #define PROFILE_BEGIN_AUTO_END(id, name, group, file, line) \
70 CPU_FREQ_BEGIN_AUTO_END(id, file, line); \
72 static Shiny::ProfileZone __ShinyZone_##id = { \
73 NULL, Shiny::ProfileZone::STATE_HIDDEN, name, \
75 { { 0, 0 }, { 0, 0 }, { 0, 0 } } \
78 static Shiny::ProfileNodeCache cache = \
79 &Shiny::ProfileNode::_dummy; \
81 Shiny::ProfileManager::instance._beginNode(&cache, &__ShinyZone_##id);\
83 PROFILE_LOG_CALL_START()
90 #define PROFILE_BEGIN(name) \
91 PROFILE_BEGIN_AUTO_END(apn_##name, #name, NULL, __FILE__, __LINE__)
94 #define PROFILE_END() \
95 ProfileNodeManager::release_latest(); \
99 #define PROFILE_FUNC() \
100 PROFILE_BEGIN_AUTO_END(__ShinyFunction, __FUNCTION__, NULL, __FILE__, __LINE__)
102 #define PROFILE_BEGIN_GROUP(name, group) \
103 PROFILE_BEGIN_AUTO_END(apn_##name, #name, group, __FILE__, __LINE__)
105 #define PROFILE_FUNC_GROUP(group) \
106 PROFILE_BEGIN_AUTO_END(__ShinyFunction, __FUNCTION__, group, __FILE__, __LINE__)
109 #define PROFILER_UPDATE \
110 Shiny::ProfileManager::instance.update
113 #define PROFILER_OUTPUT \
114 Shiny::ProfileManager::instance.output
119 #ifdef UG_PROFILER_SCALASCA
120 #include "epik_user.h"
123 #define PROFILE_STRINGIFY(x) #x
124 #define PROFILE_TOSTRING(x) PROFILE_STRINGIFY(x)
129 #define PROFILE_BEGIN(name) \
130 EPIK_USER_REG(__##name, PROFILE_TOSTRING(name)); \
131 EPIK_USER_START(__##name); \
132 AutoProfileNode apn_##name(__##name); \
135 #define PROFILE_END() \
136 ProfileNodeManager::release_latest()
139 #define PROFILE_FUNC() \
140 EPIK_TRACER(__FUNCTION__)
142 #define PROFILE_BEGIN_GROUP(name, group) \
145 #define PROFILE_FUNC_GROUP(group) \
149 inline void Update(
float a = 0.0f) {}
150 inline bool Output(
const char *a = NULL) {
return false;}
151 inline bool Output(std::ostream &a) {
return false;}
154 #define PROFILER_UPDATE ProfilerDummy::Update
155 #define PROFILER_OUTPUT ProfilerDummy::Output
159 #ifdef UG_PROFILER_VAMPIR
163 #define PROFILE_STRINGIFY(x) #x
164 #define PROFILE_TOSTRING(x) PROFILE_STRINGIFY(x)
169 #define PROFILE_BEGIN(name) \
170 VT_USER_START(PROFILE_TOSTRING(name)); \
171 AutoProfileNode apn_##name(PROFILE_TOSTRING(name)); \
174 #define PROFILE_END() \
175 ProfileNodeManager::release_latest()
178 #define PROFILE_FUNC() \
179 VT_TRACER((char*)__FUNCTION__)
181 #define PROFILE_BEGIN_GROUP(name, group) \
184 #define PROFILE_FUNC_GROUP(group) \
188 inline void Update(
float a = 0.0f) {}
189 inline bool Output(
const char *a = NULL) {
return false;}
190 inline bool Output(std::ostream &a) {
return false;}
193 #define PROFILER_UPDATE ProfilerDummy::Update
194 #define PROFILER_OUTPUT ProfilerDummy::Output
198 #ifdef UG_PROFILER_SCOREP
199 #include <scorep/SCOREP_User.h>
202 #define PROFILE_STRINGIFY(x) #x
203 #define PROFILE_TOSTRING(x) PROFILE_STRINGIFY(x)
208 #define PROFILE_BEGIN(name) \
209 SCOREP_USER_REGION_DEFINE( __scorephandle__##name ) \
210 SCOREP_USER_REGION_BEGIN( __scorephandle__##name, PROFILE_TOSTRING(name), \
211 SCOREP_USER_REGION_TYPE_COMMON ) \
212 AutoProfileNode apn_##name(__scorephandle__##name);
215 #define PROFILE_END() \
216 ProfileNodeManager::release_latest()
219 #define PROFILE_FUNC() \
220 SCOREP_USER_REGION(__FUNCTION__, SCOREP_USER_REGION_TYPE_FUNCTION )
222 #define PROFILE_BEGIN_GROUP(name, group) \
225 #define PROFILE_FUNC_GROUP(group) \
229 inline void Update(
float a = 0.0f) {}
230 inline bool Output(
const char *a = NULL) {
return false;}
231 inline bool Output(std::ostream &a) {
return false;}
234 #define PROFILER_UPDATE ProfilerDummy::Update
235 #define PROFILER_OUTPUT ProfilerDummy::Output
239 #define PROFILE_END_(name) \
240 assert(&(apn_##name) == ProfileNodeManager::inst().m_nodes.top()); \
241 struct apn_already_ended_##name { } ; \
249 inline bool Output(
const char *a = NULL) {
return false;}
250 inline bool Output(std::ostream &a) {
return false;}
254 #define PROFILE_BEGIN(name) CPU_FREQ_BEGIN_AUTO_END(apn_##name, __FILE__, __LINE__);
255 #define PROFILE_BEGIN_GROUP(name, groups) PROFILE_BEGIN(name)
256 #define PROFILE_END() CPU_FREQ_END();
257 #define PROFILE_FUNC() CPU_FREQ_BEGIN_AUTO_END(apn##__FUNCTION__, __FILE__, __LINE__);
258 #define PROFILE_FUNC_GROUP(groups) PROFILE_FUNC()
259 #define PROFILER_UPDATE ProfilerDummy::Update
260 #define PROFILER_OUTPUT ProfilerDummy::Output
262 #define PROFILE_END_(name)
Definition: profiler.h:247
bool Output(const char *a=NULL)
Definition: profiler.h:249
void Update(float a=0.0f)
Definition: profiler.h:248