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 #if CUDART_VERSION >= 10000 53 #include <nvtx3/nvToolsExt.h> 54 #include <nvtx3/nvToolsExtCuda.h> 56 #error NVTXv3 requires CUDA 10.0 or greater 59 #include <cuda_profiler_api.h> 62 #define NAMD_PROFILE_START() \ 64 cudaProfilerStart(); \ 65 } while (0) // must terminate with semi-colon 68 #define NAMD_PROFILE_STOP() \ 71 } while (0) // must terminate with semi-colon 75 const uint32_t NAMD_nvtx_colors[] = {
88 const int NAMD_nvtx_colors_len =
sizeof(NAMD_nvtx_colors)/
sizeof(uint32_t);
90 #define NAMD_REGISTER_EVENT(name,cid) \ 91 do { } while(0) // must terminate with semi-colon 94 #define NAMD_EVENT_START(eon,id) \ 98 color_id = color_id % NAMD_nvtx_colors_len; \ 99 nvtxEventAttributes_t eventAttrib = {0}; \ 100 eventAttrib.version = NVTX_VERSION; \ 101 eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE; \ 102 eventAttrib.colorType = NVTX_COLOR_ARGB; \ 103 eventAttrib.color = NAMD_nvtx_colors[color_id]; \ 104 eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII; \ 105 eventAttrib.message.ascii = NamdProfileEventStr[id]; \ 106 nvtxRangePushEx(&eventAttrib); \ 108 } while(0) // must terminate with semi-colon 111 #define NAMD_EVENT_START_EX(eon,id,str) \ 115 color_id = color_id % NAMD_nvtx_colors_len; \ 116 nvtxEventAttributes_t eventAttrib = {0}; \ 117 eventAttrib.version = NVTX_VERSION; \ 118 eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE; \ 119 eventAttrib.colorType = NVTX_COLOR_ARGB; \ 120 eventAttrib.color = NAMD_nvtx_colors[color_id]; \ 121 eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII; \ 122 eventAttrib.message.ascii = str; \ 123 nvtxRangePushEx(&eventAttrib); \ 125 } while(0) // must terminate with semi-colon 128 #define NAMD_EVENT_STOP(eon,id) \ 133 } while (0) // must terminate with semi-colon 136 class NAMD_NVTX_Tracer {
140 NAMD_NVTX_Tracer(
int eon,
int id = 0) : evon(eon) {
148 #define NAMD_EVENT_RANGE(eon,id) \ 149 NAMD_NVTX_Tracer namd_nvtx_tracer(eon,id) 152 #if defined(NAMD_PROFILE_EVENT_LAYER_2) 153 #define NAMD_EVENT_RANGE_2(eon,id) \ 154 NAMD_EVENT_RANGE(eon,id) 156 #define NAMD_EVENT_RANGE_2(eon,id) \ 157 do { } while(0) // must terminate with semi-colon 160 #elif defined(NAMD_HIP) && defined(NAMD_ROCTX_ENABLED) 162 #include <roctracer.h> 163 #include <roctracer_ext.h> 167 #define NAMD_PROFILE_START() \ 170 } while (0) // must terminate with semi-colon 173 #define NAMD_PROFILE_STOP() \ 176 } while (0) // must terminate with semi-colon 178 #define NAMD_REGISTER_EVENT(name,cid) \ 179 do { } while(0) // must terminate with semi-colon 182 #define NAMD_EVENT_START(eon,id) \ 185 roctxRangePush(NamdProfileEventStr[id]); \ 187 } while(0) // must terminate with semi-colon 190 #define NAMD_EVENT_START_EX(eon,id,str) \ 193 roctxRangePush(str); \ 195 } while(0) // must terminate with semi-colon 198 #define NAMD_EVENT_STOP(eon,id) \ 203 } while (0) // must terminate with semi-colon 206 class NAMD_ROCTX_Tracer {
210 NAMD_ROCTX_Tracer(
int eon,
int id = 0) : evon(eon) {
218 #define NAMD_EVENT_RANGE(eon,id) \ 219 NAMD_ROCTX_Tracer namd_roctx_tracer(eon,id) 222 #if defined(NAMD_PROFILE_EVENT_LAYER_2) 223 #define NAMD_EVENT_RANGE_2(eon,id) \ 224 NAMD_EVENT_RANGE(eon,id) 226 #define NAMD_EVENT_RANGE_2(eon,id) \ 227 do { } while(0) // must terminate with semi-colon 233 #elif defined(CMK_TRACE_ENABLED) && defined(NAMD_CMK_TRACE_ENABLED) 237 #define SEQUENCER_EVENT_ID_START 150 239 #define NAMD_PROFILE_START() \ 240 do { } while(0) // must terminate with semi-colon 242 #define NAMD_PROFILE_STOP() \ 243 do { } while(0) // must terminate with semi-colon 245 #define NAMD_REGISTER_EVENT(name,id) \ 247 int eventID = SEQUENCER_EVENT_ID_START+id; \ 248 traceRegisterUserEvent(name, eventID); \ 249 } while(0) // must terminate with semi-colon 251 #define NAMD_EVENT_START(eon,id) \ 254 int eventID = SEQUENCER_EVENT_ID_START+id; \ 255 traceBeginUserBracketEvent(eventID); \ 257 } while(0) // must terminate with semi-colon 259 #define NAMD_EVENT_START_EX(eon,id,str) \ 260 NAMD_EVENT_START(eon,id) 262 #define NAMD_EVENT_STOP(eon,id) \ 265 int eventID = SEQUENCER_EVENT_ID_START+id; \ 266 traceEndUserBracketEvent(eventID); \ 268 } while(0) // must terminate with semi-colon 271 class NAMD_Sequencer_Events_Tracer {
275 NAMD_Sequencer_Events_Tracer(
int eon,
int id = 0)
276 : tEventOn(eon), tEventID(id) {
279 ~NAMD_Sequencer_Events_Tracer() {
286 #define NAMD_EVENT_RANGE(eon,id) \ 287 NAMD_Sequencer_Events_Tracer namd_events_tracer(eon,id) 290 #if defined(NAMD_PROFILE_EVENT_LAYER_2) 291 #define NAMD_EVENT_RANGE_2(eon,id) \ 292 NAMD_EVENT_RANGE(eon,id) 294 #define NAMD_EVENT_RANGE_2(eon,id) \ 295 do { } while(0) // must terminate with semi-colon 303 #define NAMD_PROFILE_START() \ 304 do { } while(0) // must terminate with semi-colon 306 #define NAMD_PROFILE_STOP() \ 307 do { } while(0) // must terminate with semi-colon 309 #define NAMD_REGISTER_EVENT(name,cid) \ 310 do { } while(0) // must terminate with semi-colon 312 #define NAMD_EVENT_START(eon,id) \ 313 do { } while(0) // must terminate with semi-colon 315 #define NAMD_EVENT_START_EX(eon,id,str) \ 316 do { } while(0) // must terminate with semi-colon 318 #define NAMD_EVENT_STOP(eon,id) \ 319 do { } while(0) // must terminate with semi-colon 321 #define NAMD_EVENT_RANGE(eon,id) \ 322 do { } while(0) // must terminate with semi-colon 324 #define NAMD_EVENT_RANGE_2(eon,id) \ 325 do { } while(0) // must terminate with semi-colon 327 #endif // NAMD_CUDA && NAMD_NVTX_ENABLED #define NAMD_EVENT_STOP(eon, id)
char const *const NamdProfileEventStr[]
#define NAMD_EVENT_START(eon, id)