7 #ifndef NAMDEVENTSPROFILING_H
8 #define NAMDEVENTSPROFILING_H
23 #define NAMD_PROFILE_EVENT(a,b) a,
24 #include "NamdEventsProfiling.def"
25 #undef NAMD_PROFILE_EVENT
31 #define NAMD_PROFILE_EVENT(a,b) b,
32 #include "NamdEventsProfiling.def"
33 #undef NAMD_PROFILE_EVENT
37 #undef NAMD_PROFILE_START
38 #undef NAMD_PROFILE_STOP
39 #undef NAMD_REGISTER_EVENT
40 #undef NAMD_EVENT_START
41 #undef NAMD_EVENT_START_EX
42 #undef NAMD_EVENT_STOP
43 #undef NAMD_EVENT_RANGE
44 #undef NAMD_EVENT_RANGE_2
50 #if defined(NAMD_CUDA) && defined(NAMD_NVTX_ENABLED)
52 #include <nvToolsExt.h>
53 #include <cuda_profiler_api.h>
56 #define NAMD_PROFILE_START() \
58 cudaProfilerStart(); \
59 } while (0) // must terminate with semi-colon
62 #define NAMD_PROFILE_STOP() \
65 } while (0) // must terminate with semi-colon
69 const uint32_t NAMD_nvtx_colors[] = {
82 const int NAMD_nvtx_colors_len =
sizeof(NAMD_nvtx_colors)/
sizeof(uint32_t);
84 #define NAMD_REGISTER_EVENT(name,cid) \
85 do { } while(0) // must terminate with semi-colon
88 #define NAMD_EVENT_START(eon,id) \
92 color_id = color_id % NAMD_nvtx_colors_len; \
93 nvtxEventAttributes_t eventAttrib = {0}; \
94 eventAttrib.version = NVTX_VERSION; \
95 eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE; \
96 eventAttrib.colorType = NVTX_COLOR_ARGB; \
97 eventAttrib.color = NAMD_nvtx_colors[color_id]; \
98 eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII; \
99 eventAttrib.message.ascii = NamdProfileEventStr[id]; \
100 nvtxRangePushEx(&eventAttrib); \
102 } while(0) // must terminate with semi-colon
105 #define NAMD_EVENT_START_EX(eon,id,str) \
109 color_id = color_id % NAMD_nvtx_colors_len; \
110 nvtxEventAttributes_t eventAttrib = {0}; \
111 eventAttrib.version = NVTX_VERSION; \
112 eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE; \
113 eventAttrib.colorType = NVTX_COLOR_ARGB; \
114 eventAttrib.color = NAMD_nvtx_colors[color_id]; \
115 eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII; \
116 eventAttrib.message.ascii = str; \
117 nvtxRangePushEx(&eventAttrib); \
119 } while(0) // must terminate with semi-colon
122 #define NAMD_EVENT_STOP(eon,id) \
127 } while (0) // must terminate with semi-colon
130 class NAMD_NVTX_Tracer {
134 NAMD_NVTX_Tracer(
int eon,
int id = 0) : evon(eon) {
142 #define NAMD_EVENT_RANGE(eon,id) \
143 NAMD_NVTX_Tracer namd_nvtx_tracer(eon,id)
146 #if defined(NAMD_PROFILE_EVENT_LAYER_2)
147 #define NAMD_EVENT_RANGE_2(eon,id) \
148 NAMD_EVENT_RANGE(eon,id)
150 #define NAMD_EVENT_RANGE_2(eon,id) \
151 do { } while(0) // must terminate with semi-colon
154 #elif defined(NAMD_HIP) && defined(NAMD_ROCTX_ENABLED)
156 #include <roctracer.h>
157 #include <roctracer_ext.h>
161 #define NAMD_PROFILE_START() \
164 } while (0) // must terminate with semi-colon
167 #define NAMD_PROFILE_STOP() \
170 } while (0) // must terminate with semi-colon
172 #define NAMD_REGISTER_EVENT(name,cid) \
173 do { } while(0) // must terminate with semi-colon
176 #define NAMD_EVENT_START(eon,id) \
179 roctxRangePush(NamdProfileEventStr[id]); \
181 } while(0) // must terminate with semi-colon
184 #define NAMD_EVENT_START_EX(eon,id,str) \
187 roctxRangePush(str); \
189 } while(0) // must terminate with semi-colon
192 #define NAMD_EVENT_STOP(eon,id) \
197 } while (0) // must terminate with semi-colon
200 class NAMD_ROCTX_Tracer {
204 NAMD_ROCTX_Tracer(
int eon,
int id = 0) : evon(eon) {
212 #define NAMD_EVENT_RANGE(eon,id) \
213 NAMD_ROCTX_Tracer namd_roctx_tracer(eon,id)
216 #if defined(NAMD_PROFILE_EVENT_LAYER_2)
217 #define NAMD_EVENT_RANGE_2(eon,id) \
218 NAMD_EVENT_RANGE(eon,id)
220 #define NAMD_EVENT_RANGE_2(eon,id) \
221 do { } while(0) // must terminate with semi-colon
227 #elif defined(CMK_TRACE_ENABLED) && defined(NAMD_CMK_TRACE_ENABLED)
231 #define SEQUENCER_EVENT_ID_START 150
233 #define NAMD_PROFILE_START() \
234 do { } while(0) // must terminate with semi-colon
236 #define NAMD_PROFILE_STOP() \
237 do { } while(0) // must terminate with semi-colon
239 #define NAMD_REGISTER_EVENT(name,id) \
241 int eventID = SEQUENCER_EVENT_ID_START+id; \
242 traceRegisterUserEvent(name, eventID); \
243 } while(0) // must terminate with semi-colon
245 #define NAMD_EVENT_START(eon,id) \
248 int eventID = SEQUENCER_EVENT_ID_START+id; \
249 traceBeginUserBracketEvent(eventID); \
251 } while(0) // must terminate with semi-colon
253 #define NAMD_EVENT_START_EX(eon,id,str) \
254 NAMD_EVENT_START(eon,id)
256 #define NAMD_EVENT_STOP(eon,id) \
259 int eventID = SEQUENCER_EVENT_ID_START+id; \
260 traceEndUserBracketEvent(eventID); \
262 } while(0) // must terminate with semi-colon
265 class NAMD_Sequencer_Events_Tracer {
269 NAMD_Sequencer_Events_Tracer(
int eon,
int id = 0)
270 : tEventOn(eon), tEventID(id) {
273 ~NAMD_Sequencer_Events_Tracer() {
280 #define NAMD_EVENT_RANGE(eon,id) \
281 NAMD_Sequencer_Events_Tracer namd_events_tracer(eon,id)
284 #if defined(NAMD_PROFILE_EVENT_LAYER_2)
285 #define NAMD_EVENT_RANGE_2(eon,id) \
286 NAMD_EVENT_RANGE(eon,id)
288 #define NAMD_EVENT_RANGE_2(eon,id) \
289 do { } while(0) // must terminate with semi-colon
297 #define NAMD_PROFILE_START() \
298 do { } while(0) // must terminate with semi-colon
300 #define NAMD_PROFILE_STOP() \
301 do { } while(0) // must terminate with semi-colon
303 #define NAMD_REGISTER_EVENT(name,cid) \
304 do { } while(0) // must terminate with semi-colon
306 #define NAMD_EVENT_START(eon,id) \
307 do { } while(0) // must terminate with semi-colon
309 #define NAMD_EVENT_START_EX(eon,id,str) \
310 do { } while(0) // must terminate with semi-colon
312 #define NAMD_EVENT_STOP(eon,id) \
313 do { } while(0) // must terminate with semi-colon
315 #define NAMD_EVENT_RANGE(eon,id) \
316 do { } while(0) // must terminate with semi-colon
318 #define NAMD_EVENT_RANGE_2(eon,id) \
319 do { } while(0) // must terminate with semi-colon
321 #endif // NAMD_CUDA && NAMD_NVTX_ENABLED
#define NAMD_EVENT_STOP(eon, id)
char const *const NamdProfileEventStr[]
#define NAMD_EVENT_START(eon, id)