This implements a PAPI component that enables PAPI-C to access hardware monitoring counters for AMD ROCM GPU devices through the ROC-profiler library.
More...
Go to the source code of this file.
|
| static int | rocm_init_component (int cid) |
| |
| static int | rocm_init_thread (hwd_context_t *ctx) |
| |
| static int | rocm_init_control_state (hwd_control_state_t *ctl) |
| |
| static int | rocm_init_private (void) |
| |
| static int | rocm_shutdown_component (void) |
| |
| static int | rocm_shutdown_thread (hwd_context_t *ctx) |
| |
| static int | rocm_cleanup_eventset (hwd_control_state_t *ctl) |
| |
| static void | rocm_dispatch_timer (int n, hwd_siginfo_t *info, void *uc) |
| |
| static int | rocm_update_control_state (hwd_control_state_t *ctl, NativeInfo_t *ntv_info, int ntv_count, hwd_context_t *ctx) |
| |
| static int | rocm_set_domain (hwd_control_state_t *ctl, int domain) |
| |
| static int | rocm_ctrl (hwd_context_t *ctx, int code, _papi_int_option_t *option) |
| |
| static int | rocm_start (hwd_context_t *ctx, hwd_control_state_t *ctl) |
| |
| static int | rocm_read (hwd_context_t *ctx, hwd_control_state_t *ctl, long long **val, int flags) |
| |
| static int | rocm_stop (hwd_context_t *ctx, hwd_control_state_t *ctl) |
| |
| static int | rocm_reset (hwd_context_t *ctx, hwd_control_state_t *ctl) |
| |
| static int | rocm_ntv_enum_events (unsigned int *event_code, int modifier) |
| |
| static int | rocm_ntv_code_to_name (unsigned int event_code, char *name, int len) |
| |
| static int | rocm_ntv_name_to_code (const char *name, unsigned int *event_code) |
| |
| static int | rocm_ntv_code_to_descr (unsigned int event_code, char *descr, int len) |
| |
| static int | rocm_ntv_code_to_info (unsigned int event_code, PAPI_event_info_t *info) |
| |
| static int | check_n_initialize (void) |
| |
| int | rocm_init_control_state (hwd_control_state_t *ctl __attribute__((unused))) |
| |
| static int | evt_get_count (int *count) |
| |
| static int | counter_sampling_compatible_with_prof_mode (void) |
| |
| void | rocm_dispatch_timer (int n __attribute__((unused)), hwd_siginfo_t *info, void *uc) |
| |
| static int | update_native_events (rocm_control_t *, NativeInfo_t *, int) |
| |
| static int | try_open_events (rocm_control_t *) |
| |
| int | rocm_update_control_state (hwd_control_state_t *ctl, NativeInfo_t *ntv_info, int ntv_count, hwd_context_t *ctx __attribute__((unused))) |
| |
| static int | compare (const void *a, const void *b) |
| |
| int | rocm_set_domain (hwd_control_state_t *ctl __attribute__((unused)), int domain __attribute__((unused))) |
| |
| int | rocm_ctrl (hwd_context_t *ctx __attribute__((unused)), int code __attribute__((unused)), _papi_int_option_t *option __attribute__((unused))) |
| |
| int | rocm_read (hwd_context_t *ctx __attribute__((unused)), hwd_control_state_t *ctl, long long **val, int flags __attribute__((unused))) |
| |
| int | rocm_reset (hwd_context_t *ctx __attribute__((unused)), hwd_control_state_t *ctl) |
| |
- Author
- Giuseppe Congiu gcong.nosp@m.iu@i.nosp@m.cl.ut.nosp@m.k.ed.nosp@m.u
The open source software license for PAPI conforms to the BSD License template.
Definition in file rocm.c.
◆ check_n_initialize()
| int check_n_initialize |
( |
void |
| ) |
|
|
static |
Definition at line 676 of file rocm.c.
677{
680 }
682}
papi_vector_t _rocm_vector
static int rocm_init_private(void)
PAPI_component_info_t cmp_info
◆ compare()
| static int compare |
( |
const void * |
a, |
|
|
const void * |
b |
|
) |
| |
|
static |
Definition at line 384 of file rocm.c.
385{
389}
static double a[MATRIX_SIZE][MATRIX_SIZE]
static double b[MATRIX_SIZE][MATRIX_SIZE]
◆ counter_sampling_compatible_with_prof_mode()
| static int counter_sampling_compatible_with_prof_mode |
( |
void |
| ) |
|
|
static |
Definition at line 291 of file rocm.c.
292{
294}
unsigned int rocm_prof_mode
#define ROCM_PROFILE_SAMPLING_MODE
◆ evt_get_count()
| static int evt_get_count |
( |
int * |
count | ) |
|
|
static |
Definition at line 179 of file rocm.c.
180{
181 uint64_t event_code = 0;
182
184 ++(*count);
185 }
187 ++(*count);
188 }
189
191}
int rocd_evt_enum(uint64_t *event_code, int modifier)
◆ rocm_cleanup_eventset()
Definition at line 274 of file rocm.c.
275{
277
279 SUBDBG(
"Cannot cleanup an eventset that is running.");
281 }
282
286
288}
#define SUBDBG(format, args...)
◆ rocm_ctrl() [1/2]
◆ rocm_ctrl() [2/2]
◆ rocm_dispatch_timer() [1/2]
| void rocm_dispatch_timer |
( |
int n |
__attribute__(unused), |
|
|
hwd_siginfo_t * |
info, |
|
|
void * |
uc |
|
) |
| |
Definition at line 297 of file rocm.c.
298{
304
306 SUBDBG(
"Counter sampling is not compatible with intercept mode");
307 return;
308 }
309
311
314
316 SUBDBG(
"thread == NULL in user_signal_handler!");
317 goto fn_exit;
318 }
319
322
324 SUBDBG(
"ESI == NULL in user_signal_handler!");
325 goto fn_exit;
326 }
327
328 hw_context.
si = info;
330
332
335
336 fn_exit:
338 return;
339}
#define GET_OVERFLOW_ADDRESS(ctx)
static int counter_sampling_compatible_with_prof_mode(void)
hwd_control_state_t * ctl_state
hwd_ucontext_t * ucontext
inline_static ThreadInfo_t * _papi_hwi_lookup_thread(int custom_tid)
inline_static int _papi_hwi_lock(int lck)
inline_static int _papi_hwi_unlock(int lck)
◆ rocm_dispatch_timer() [2/2]
◆ rocm_init_component()
| int rocm_init_component |
( |
int |
cid | ) |
|
|
static |
Definition at line 128 of file rocm.c.
129{
134 SUBDBG(
"ENTER: cid: %d\n", cid);
135
140 const char *err_string;
145 SUBDBG(
"disabled_reason truncated");
146 }
147 goto fn_fail;
148 }
149
151 "Not initialized. Access component events to initialize it.");
154
155 fn_exit:
157 return papi_errno;
158 fn_fail:
159 goto fn_exit;
160}
Returns a string describing the PAPI error code.
int rocd_err_get_last(const char **error_str)
int rocd_init_environment(void)
char disabled_reason[PAPI_HUGE_STR_LEN]
◆ rocm_init_control_state() [1/2]
Definition at line 173 of file rocm.c.
174{
176}
static int check_n_initialize(void)
◆ rocm_init_control_state() [2/2]
◆ rocm_init_private()
| int rocm_init_private |
( |
void |
| ) |
|
|
static |
Definition at line 194 of file rocm.c.
195{
197
200
203 goto fn_exit;
204 }
205
209 const char *err_string;
214 SUBDBG(
"disabled_reason truncated");
215 }
216
217 goto fn_fail;
218 }
219
224
225 fn_exit:
230 return papi_errno;
231 fn_fail:
232 goto fn_exit;
233}
static int evt_get_count(int *count)
◆ rocm_init_thread()
Definition at line 163 of file rocm.c.
164{
166 memset(rocm_ctx, 0, sizeof(*rocm_ctx));
170}
◆ rocm_ntv_code_to_descr()
| int rocm_ntv_code_to_descr |
( |
unsigned int |
event_code, |
|
|
char * |
descr, |
|
|
int |
len |
|
) |
| |
|
static |
Definition at line 640 of file rocm.c.
641{
642 SUBDBG(
"ENTER: event_code: %u, descr: %p, len: %d\n", event_code,
descr, len);
645 goto fn_fail;
646 }
647
649
650 fn_exit:
652 return papi_errno;
653 fn_fail:
654 goto fn_exit;
655}
int rocd_evt_code_to_descr(uint64_t event_code, char *descr, int len)
◆ rocm_ntv_code_to_info()
Definition at line 658 of file rocm.c.
659{
660 SUBDBG(
"ENTER: event_code: %u, info: %p\n", event_code, info);
663 goto fn_fail;
664 }
665
667
668 fn_exit:
670 return papi_errno;
671 fn_fail:
672 goto fn_exit;
673}
int rocd_evt_code_to_info(uint64_t event_code, PAPI_event_info_t *info)
◆ rocm_ntv_code_to_name()
| int rocm_ntv_code_to_name |
( |
unsigned int |
event_code, |
|
|
char * |
name, |
|
|
int |
len |
|
) |
| |
|
static |
Definition at line 602 of file rocm.c.
603{
604 SUBDBG(
"ENTER: event_code: %u, name: %p, len: %d\n", event_code,
name, len);
607 goto fn_fail;
608 }
609
611
612 fn_exit:
614 return papi_errno;
615 fn_fail:
616 goto fn_exit;
617}
int rocd_evt_code_to_name(uint64_t event_code, char *name, int len)
◆ rocm_ntv_enum_events()
| int rocm_ntv_enum_events |
( |
unsigned int * |
event_code, |
|
|
int |
modifier |
|
) |
| |
|
static |
Definition at line 582 of file rocm.c.
583{
584 SUBDBG(
"ENTER: event_code: %u, modifier: %d\n", *event_code, modifier);
587 goto fn_fail;
588 }
589
590 uint64_t code = *(uint64_t *) event_code;
592 *event_code = (
unsigned int) code;
593
594 fn_exit:
596 return papi_errno;
597 fn_fail:
598 goto fn_exit;
599}
◆ rocm_ntv_name_to_code()
| int rocm_ntv_name_to_code |
( |
const char * |
name, |
|
|
unsigned int * |
event_code |
|
) |
| |
|
static |
Definition at line 620 of file rocm.c.
621{
622 SUBDBG(
"ENTER: name: %s, code: %p\n",
name, code);
625 goto fn_fail;
626 }
627
628 uint64_t event_code;
630 *code = (
unsigned int) event_code;
631
632 fn_exit:
634 return papi_errno;
635 fn_fail:
636 goto fn_exit;
637}
int rocd_evt_name_to_code(const char *name, uint64_t *event_code)
◆ rocm_read() [1/2]
Definition at line 510 of file rocm.c.
512{
515 SUBDBG(
"ENTER: ctx: %p, ctl: %p, val: %p, flags: %d\n", ctx, ctl, val, flags);
516
518 SUBDBG(
"Error! Cannot PAPI_read counters for an eventset that has not been PAPI_start'ed.");
520 goto fn_fail;
521 }
522
524
525 fn_exit:
527 return papi_errno;
528 fn_fail:
529 goto fn_exit;
530}
int rocd_ctx_read(rocd_ctx_t ctx, long long **counters)
◆ rocm_read() [2/2]
◆ rocm_reset() [1/2]
Definition at line 569 of file rocm.c.
570{
572
574 SUBDBG(
"Cannot reset counters for an eventset that has not been started.");
576 }
577
579}
int rocd_ctx_reset(rocd_ctx_t ctx)
◆ rocm_reset() [2/2]
◆ rocm_set_domain() [1/2]
◆ rocm_set_domain() [2/2]
◆ rocm_shutdown_component()
| int rocm_shutdown_component |
( |
void |
| ) |
|
|
static |
Definition at line 236 of file rocm.c.
237{
242
244 goto fn_exit;
245 }
246
248 goto fn_exit;
249 }
250
253 goto fn_fail;
254 }
255
256 fn_exit:
258 return papi_errno;
259 fn_fail:
261 goto fn_exit;
262}
◆ rocm_shutdown_thread()
◆ rocm_start()
Definition at line 470 of file rocm.c.
471{
475 SUBDBG(
"ENTER: ctx: %p, ctl: %p\n", ctx, ctl);
476
478 SUBDBG(
"Error! Cannot PAPI_start more than one eventset at a time for every component.");
480 goto fn_fail;
481 }
482
486 goto fn_fail;
487 }
488
490
493 goto fn_fail;
494 }
495
497
498 fn_exit:
500 return papi_errno;
501 fn_fail:
504 }
506 goto fn_exit;
507}
int rocd_ctx_open(uint64_t *events_id, int num_events, rocd_ctx_t *ctx)
int rocd_ctx_start(rocd_ctx_t ctx)
int rocd_ctx_close(rocd_ctx_t ctx)
#define ROCM_EVENTS_RUNNING
#define ROCM_EVENTS_OPENED
◆ rocm_stop()
Definition at line 533 of file rocm.c.
534{
538 SUBDBG(
"ENTER: ctx: %p, ctl: %p\n", ctx, ctl);
539
541 SUBDBG(
"Error! Cannot PAPI_stop counters for an eventset that has not been PAPI_start'ed.");
543 goto fn_fail;
544 }
545
548 goto fn_fail;
549 }
550
551 rocm_ctx->
state &= ~ROCM_EVENTS_RUNNING;
552
555 goto fn_fail;
556 }
557
560
561 fn_exit:
563 return papi_errno;
564 fn_fail:
565 goto fn_exit;
566}
int rocd_ctx_stop(rocd_ctx_t ctx)
◆ rocm_update_control_state() [1/2]
Definition at line 345 of file rocm.c.
348{
349 SUBDBG(
"ENTER: ctl: %p, ntv_info: %p, ntv_count: %d, ctx: %p\n", ctl, ntv_info, ntv_count, ctx);
352 goto fn_fail;
353 }
354
356
358 SUBDBG(
"Cannot update events in an eventset that has been already "
359 "started.");
361 goto fn_fail;
362 }
363
366 goto fn_fail;
367 }
368
370
371 fn_exit:
373 return papi_errno;
374 fn_fail:
375 goto fn_exit;
376}
static int update_native_events(rocm_control_t *, NativeInfo_t *, int)
static int try_open_events(rocm_control_t *)
◆ rocm_update_control_state() [2/2]
◆ try_open_events()
Definition at line 430 of file rocm.c.
431{
434
436
437 return papi_errno;
438 }
439
442 }
443
448 return papi_errno;
449 }
450
452}
static int rocm_cleanup_eventset(hwd_control_state_t *ctl)
◆ update_native_events()
Definition at line 392 of file rocm.c.
394{
397
403 goto fn_fail;
404 }
405
407 }
408
410 for (
i = 0;
i < ntv_count; ++
i) {
411 sorted_events[
i].event_id = ntv_info[
i].
ni_event;
412 sorted_events[
i].frontend_idx =
i;
413 }
414
416
417 for (
i = 0;
i < ntv_count; ++
i) {
420 }
421
422 fn_exit:
423 return papi_errno;
424 fn_fail:
426 goto fn_exit;
427}
#define papi_realloc(a, b)
#define PAPI_ROCM_MAX_COUNTERS
static int compare(const void *a, const void *b)
◆ _rocm_vector