Grid 0.7.0
Tracing.h
Go to the documentation of this file.
1#pragma once
2
4
5#ifdef GRID_TRACING_NVTX
6#include <nvToolsExt.h>
7class GridTracer {
8public:
9 GridTracer(const char* name) {
10 nvtxRangePushA(name);
11 }
12 ~GridTracer() {
13 nvtxRangePop();
14 }
15};
16inline void tracePush(const char *name) { nvtxRangePushA(name); }
17inline void tracePop(const char *name) { nvtxRangePop(); }
18inline int traceStart(const char *name) { }
19inline void traceStop(int ID) { }
20#endif
21
22#ifdef GRID_TRACING_ROCTX
23#include <roctracer/roctx.h>
24class GridTracer {
25 public:
26 GridTracer(const char* name) {
27 roctxRangePushA(name);
28 std::cout << "roctxRangePush "<<name<<std::endl;
29 }
30 ~GridTracer() {
31 roctxRangePop();
32 std::cout << "roctxRangePop "<<std::endl;
33 }
34};
35inline void tracePush(const char *name) { roctxRangePushA(name); }
36inline void tracePop(const char *name) { roctxRangePop(); }
37inline int traceStart(const char *name) { return roctxRangeStart(name); }
38inline void traceStop(int ID) { roctxRangeStop(ID); }
39#endif
40
41#ifdef GRID_TRACING_TIMER
42class GridTracer {
43 public:
44 const char *name;
45 double elapsed;
46 GridTracer(const char* _name) {
47 name = _name;
48 elapsed=-usecond();
49 }
50 ~GridTracer() {
51 elapsed+=usecond();
52 std::cout << GridLogTracing << name << " took " <<elapsed<< " us" <<std::endl;
53 }
54};
55inline void tracePush(const char *name) { }
56inline void tracePop(const char *name) { }
57inline int traceStart(const char *name) { return 0; }
58inline void traceStop(int ID) { }
59#endif
60
61#ifdef GRID_TRACING_NONE
62#define GRID_TRACE(name)
63inline void tracePush(const char *name) { }
64inline void tracePop(const char *name) { }
65inline int traceStart(const char *name) { return 0; }
66inline void traceStop(int ID) { }
67#else
68#define GRID_TRACE(name) GridTracer uniq_name_using_macros##__COUNTER__(name);
69#endif
GridLogger GridLogTracing(1, "Tracing", GridLogColours, "NORMAL")
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
double usecond(void)
Definition Timer.h:50