16 void Reset_(
const char *func,
const char *file,
int line);
28 #if QUDA_NVTX_VERSION == 3
29 #include "nvtx3/nvToolsExt.h"
31 #include "nvToolsExt.h"
63 void Start(
const char *func,
const char *file,
int line) {
65 printfQuda(
"ERROR: Cannot start an already running timer (%s:%d in %s())\n", file, line, func);
68 gettimeofday(&
start, NULL);
72 void Stop(
const char *func,
const char *file,
int line) {
74 printfQuda(
"ERROR: Cannot stop an unstarted timer (%s:%d in %s())\n", file, line, func);
77 gettimeofday(&
stop, NULL);
81 last = ds + 0.000001*dus;
90 void Reset(
const char *func,
const char *file,
int line) {
92 printfQuda(
"ERROR: Cannot reset a started timer (%s:%d in %s())\n", file, line, func);
153 #ifdef INTERFACE_NVTX
155 #define PUSH_RANGE(name,cid) { \
156 int color_id = cid; \
157 color_id = color_id%nvtx_num_colors;\
158 nvtxEventAttributes_t eventAttrib = {0}; \
159 eventAttrib.version = NVTX_VERSION; \
160 eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE; \
161 eventAttrib.colorType = NVTX_COLOR_ARGB; \
162 eventAttrib.color = nvtx_colors[color_id]; \
163 eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII; \
164 eventAttrib.message.ascii = name; \
165 eventAttrib.category = cid;\
166 nvtxRangePushEx(&eventAttrib); \
168 #define POP_RANGE nvtxRangePop();
170 #define PUSH_RANGE(name,cid)
176 #ifdef INTERFACE_NVTX
177 static const uint32_t nvtx_colors[];
178 static const int nvtx_num_colors;
191 static void StopGlobal(
const char *func,
const char *file,
int line,
QudaProfileType idx) {
193 global_total_level[idx]--;
194 if (global_total_level[idx]==0) global_profile[idx].
Stop(func,file,line);
197 if (global_switchOff[idx]) {
198 global_total_level[idx]--;
199 if (global_total_level[idx]==0) global_profile[idx].
Stop(func,file,line);
200 global_switchOff[idx] =
false;
204 static void StartGlobal(
const char *func,
const char *file,
int line,
QudaProfileType idx) {
206 if (!global_profile[idx].running) {
207 global_profile[idx].
Start(func,file,line);
208 global_total_level[idx]++;
209 global_switchOff[idx] =
true;
212 if (global_total_level[idx]==0) global_profile[idx].
Start(func,file,line);
213 global_total_level[idx]++;
231 profile[idx].
Start(func, file, line);
233 if (use_global) StartGlobal(func,file,line,idx);
238 profile[idx].
Stop(func, file, line);
246 if (use_global) StopGlobal(func,file,line,idx);
249 void Reset_(
const char *func,
const char *file,
int line) {
251 profile[idx].Reset(func, file, line);
255 return profile[idx].
last;
272 #define TPSTART(idx) Start_(__func__, __FILE__, __LINE__, idx)
273 #define TPSTOP(idx) Stop_(__func__, __FILE__, __LINE__, idx)
274 #define TPRESET() Reset_(__func__, __FILE__, __LINE__)
TimeProfile(std::string fname, bool use_global)
static void PrintGlobal()
double Last(QudaProfileType idx)
void Start_(const char *func, const char *file, int line, QudaProfileType idx)
bool isRunning(QudaProfileType idx)
TimeProfile(std::string fname)
void Stop_(const char *func, const char *file, int line, QudaProfileType idx)
void Reset_(const char *func, const char *file, int line)
@ QUDA_PROFILE_MEMCPY_H2D_ASYNC
@ QUDA_PROFILE_EVENT_SYNCHRONIZE
@ QUDA_PROFILE_FUNC_SET_ATTRIBUTE
@ QUDA_PROFILE_MEMCPY_D2D_ASYNC
@ QUDA_PROFILE_DEVICE_SYNCHRONIZE
@ QUDA_PROFILE_STREAM_SYNCHRONIZE
@ QUDA_PROFILE_EVENT_QUERY
@ QUDA_PROFILE_HOST_COMPUTE
@ QUDA_PROFILE_STREAM_WAIT_EVENT
@ QUDA_PROFILE_MEMCPY_DEFAULT_ASYNC
@ QUDA_PROFILE_MEMCPY_D2H_ASYNC
@ QUDA_PROFILE_LAUNCH_KERNEL
@ QUDA_PROFILE_LOWER_LEVEL
@ QUDA_PROFILE_EVENT_RECORD
@ QUDA_PROFILE_COMMS_QUERY
@ QUDA_PROFILE_MEMCPY2D_D2H_ASYNC
@ QUDA_PROFILE_COMMS_START
@ QUDA_PROFILE_PACK_KERNEL
@ QUDA_PROFILE_DSLASH_KERNEL
void Stop(const char *func, const char *file, int line)
void Reset(const char *func, const char *file, int line)
void Start(const char *func, const char *file, int line)
#define PUSH_RANGE(name, cid)