PAPI 7.1.0.0
Loading...
Searching...
No Matches
rocs.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ROCS_EVENTS_OPENED   (0x1)
 
#define ROCS_EVENTS_RUNNING   (0x2)
 

Functions

int rocs_init (void)
 
int rocs_shutdown (void)
 
int rocs_evt_enum (unsigned int *event_code, int modifier)
 
int rocs_evt_code_to_descr (unsigned int event_code, char *descr, int len)
 
int rocs_evt_name_to_code (const char *name, unsigned int *event_code)
 
int rocs_evt_code_to_name (unsigned int event_code, char *name, int len)
 
int rocs_err_get_last (const char **err_string)
 
int rocs_ctx_open (unsigned int *event_ids, int num_events, rocs_ctx_t *ctx)
 
int rocs_ctx_close (rocs_ctx_t ctx)
 
int rocs_ctx_start (rocs_ctx_t ctx)
 
int rocs_ctx_stop (rocs_ctx_t ctx)
 
int rocs_ctx_read (rocs_ctx_t ctx, long long **counts)
 
int rocs_ctx_write (rocs_ctx_t ctx, long long *counts)
 
int rocs_ctx_reset (rocs_ctx_t ctx)
 

Macro Definition Documentation

◆ ROCS_EVENTS_OPENED

#define ROCS_EVENTS_OPENED   (0x1)

Definition at line 4 of file rocs.h.

◆ ROCS_EVENTS_RUNNING

#define ROCS_EVENTS_RUNNING   (0x2)

Definition at line 5 of file rocs.h.

Function Documentation

◆ rocs_ctx_close()

int rocs_ctx_close ( rocs_ctx_t  ctx)

Definition at line 519 of file rocs.c.

520{
521 int papi_errno = PAPI_OK;
522
524
525 int i;
526 for (i = 0; i < rocs_ctx->num_events; ++i) {
527 int id = rocs_ctx->events_id[i];
528 papi_errno = ntv_table_p->events[id].close_func_p(&ntv_table_p->events[id]);
529 if (papi_errno != PAPI_OK) {
530 goto fn_fail;
531 }
532 }
533
537
538 fn_exit:
540 return papi_errno;
541 fn_fail:
542 goto fn_exit;
543}
int i
#define PAPI_OK
Definition: f90papi.h:73
#define papi_free(a)
Definition: papi_memory.h:35
static int release_devices(int32_t *)
Definition: rocs.c:979
static ntv_event_table_t * ntv_table_p
Definition: rocs.c:325
unsigned int _rocm_smi_lock
Definition: rocs.c:11
close_function_f close_func_p
Definition: rocs.c:294
ntv_event_t * events
Definition: roc_profiler.c:50
Definition: rocs.c:305
int32_t device_mask
Definition: rocs.c:310
int num_events
Definition: rocs.c:308
int64_t * counters
Definition: rocs.c:309
unsigned int * events_id
Definition: rocs.c:307
inline_static int _papi_hwi_lock(int lck)
Definition: threads.h:69
inline_static int _papi_hwi_unlock(int lck)
Definition: threads.h:83
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rocs_ctx_open()

int rocs_ctx_open ( unsigned int event_ids,
int  num_events,
rocs_ctx_t *  ctx 
)

Definition at line 461 of file rocs.c.

462{
463 int papi_errno = PAPI_OK;
464 int64_t *counters = NULL;
465 int i = 0, j;
466
468
469 int32_t bitmask;
470 if (acquire_devices(events_id, num_events, &bitmask) != PAPI_OK) {
471 papi_errno = PAPI_ECNFLCT;
472 goto fn_fail;
473 }
474
475 (*rocs_ctx) = papi_calloc(1, sizeof(struct rocs_ctx));
476 if ((*rocs_ctx) == NULL) {
477 papi_errno = PAPI_ENOMEM;
478 goto fn_fail;
479 }
480
481 counters = papi_calloc(num_events, sizeof(int64_t));
482 if (counters == NULL) {
483 papi_errno = PAPI_ENOMEM;
484 goto fn_fail;
485 }
486
487 for (i = 0; i < num_events; ++i) {
488 int id = events_id[i];
489 papi_errno = ntv_table_p->events[id].open_func_p(&ntv_table_p->events[id]);
490 if (papi_errno != PAPI_OK) {
491 goto fn_fail;
492 }
493 }
494
495 (*rocs_ctx)->state |= ROCS_EVENTS_OPENED;
496 (*rocs_ctx)->events_id = events_id;
497 (*rocs_ctx)->num_events = num_events;
498 (*rocs_ctx)->counters = counters;
499 (*rocs_ctx)->device_mask = bitmask;
500
501 fn_exit:
503 return papi_errno;
504 fn_fail:
505 for (j = 0; j < i; ++j) {
506 int id = events_id[j];
508 }
509 if (counters) {
510 papi_free(counters);
511 }
512 if (*rocs_ctx) {
514 }
515 goto fn_exit;
516}
#define PAPI_ECNFLCT
Definition: f90papi.h:234
#define PAPI_ENOMEM
Definition: f90papi.h:16
static int num_events
#define papi_calloc(a, b)
Definition: papi_memory.h:37
uint64_t * events_id
static int acquire_devices(unsigned int *, int, int32_t *)
Definition: rocs.c:955
#define ROCS_EVENTS_OPENED
Definition: rocs.h:4
open_function_f open_func_p
Definition: rocs.c:293
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rocs_ctx_read()

int rocs_ctx_read ( rocs_ctx_t  ctx,
long long **  counts 
)

Definition at line 605 of file rocs.c.

606{
607 int papi_errno = PAPI_OK;
608
609 int i;
610 for (i = 0; i < rocs_ctx->num_events; ++i) {
611 int id = rocs_ctx->events_id[i];
613 if (papi_errno != PAPI_OK) {
614 return papi_errno;
615 }
617 }
618 *counts = (long long *) rocs_ctx->counters;
619
620 return papi_errno;
621}
@ ROCS_ACCESS_MODE__READ
Definition: rocs.c:88
access_function_f access_func_p
Definition: rocs.c:297
int64_t value
Definition: rocs.c:290
Here is the caller graph for this function:

◆ rocs_ctx_reset()

int rocs_ctx_reset ( rocs_ctx_t  ctx)

Definition at line 642 of file rocs.c.

643{
644 int i;
645 for (i = 0; i < rocs_ctx->num_events; ++i) {
646 int id = rocs_ctx->events_id[i];
647 ntv_table_p->events[id].value = 0;
648 rocs_ctx->counters[i] = 0;
649 }
650
651 return PAPI_OK;
652}
Here is the caller graph for this function:

◆ rocs_ctx_start()

int rocs_ctx_start ( rocs_ctx_t  ctx)

Definition at line 546 of file rocs.c.

547{
548 int papi_errno = PAPI_OK;
549
551 return PAPI_ECMP;
552 }
553
555 return PAPI_ECMP;
556 }
557
558 int i, j;
559 for (i = 0; i < rocs_ctx->num_events; ++i) {
560 int id = rocs_ctx->events_id[i];
561 papi_errno = ntv_table_p->events[id].start_func_p(&ntv_table_p->events[id]);
562 if (papi_errno != PAPI_OK) {
563 goto fn_fail;
564 }
565 }
566
568
569 fn_exit:
570 return papi_errno;
571 fn_fail:
572 for (j = 0; j < i; ++j) {
573 int id = rocs_ctx->events_id[i];
575 }
576 goto fn_exit;
577}
#define PAPI_ECMP
Definition: f90papi.h:214
#define ROCS_EVENTS_RUNNING
Definition: rocs.h:5
stop_function_f stop_func_p
Definition: rocs.c:296
start_function_f start_func_p
Definition: rocs.c:295
int state
Definition: rocs.c:306
Here is the caller graph for this function:

◆ rocs_ctx_stop()

int rocs_ctx_stop ( rocs_ctx_t  ctx)

Definition at line 580 of file rocs.c.

581{
583 return PAPI_ECMP;
584 }
585
587 return PAPI_ECMP;
588 }
589
590 int i;
591 for (i = 0; i < rocs_ctx->num_events; ++i) {
592 int id = rocs_ctx->events_id[i];
593 int papi_errno = ntv_table_p->events[id].stop_func_p(&ntv_table_p->events[id]);
594 if (papi_errno != PAPI_OK) {
595 return papi_errno;
596 }
597 }
598
599 rocs_ctx->state &= ~ROCS_EVENTS_RUNNING;
600
601 return PAPI_OK;
602}
Here is the caller graph for this function:

◆ rocs_ctx_write()

int rocs_ctx_write ( rocs_ctx_t  ctx,
long long counts 
)

Definition at line 624 of file rocs.c.

625{
626 int papi_errno = PAPI_OK;
627
628 int i;
629 for (i = 0; i < rocs_ctx->num_events; ++i) {
630 int id = rocs_ctx->events_id[i];
631 ntv_table_p->events[id].value = counts[i];
633 if (papi_errno != PAPI_OK) {
634 return papi_errno;
635 }
636 }
637
638 return papi_errno;
639}
@ ROCS_ACCESS_MODE__WRITE
Definition: rocs.c:89
Here is the caller graph for this function:

◆ rocs_err_get_last()

int rocs_err_get_last ( const char **  err_string)

Definition at line 450 of file rocs.c.

451{
452 *err_string = error_string;
453 return PAPI_OK;
454}
static char error_string[PAPI_MAX_STR_LEN+1]
Definition: rocs.c:327
Here is the caller graph for this function:

◆ rocs_evt_code_to_descr()

int rocs_evt_code_to_descr ( unsigned int  event_code,
char *  descr,
int  len 
)

Definition at line 410 of file rocs.c.

411{
412 if (event_code >= (unsigned int) ntv_table_p->count) {
413 return PAPI_EINVAL;
414 }
415 /* FIXME: make sure descr is not longer than len */
416 strncpy(descr, ntv_table_p->events[event_code].descr, len);
417 return PAPI_OK;
418}
#define PAPI_EINVAL
Definition: f90papi.h:115
char * descr
Definition: roc_profiler.c:44
char * descr
Here is the caller graph for this function:

◆ rocs_evt_code_to_name()

int rocs_evt_code_to_name ( unsigned int  event_code,
char *  name,
int  len 
)

Definition at line 440 of file rocs.c.

441{
442 if (event_code >= (unsigned int) ntv_table_p->count) {
443 return PAPI_EINVAL;
444 }
445 strncpy(name, ntv_table_p->events[event_code].name, len);
446 return PAPI_OK;
447}
const char * name
Definition: rocs.c:225
char * name
Definition: roc_profiler.c:43
Here is the caller graph for this function:

◆ rocs_evt_enum()

int rocs_evt_enum ( unsigned int event_code,
int  modifier 
)

Definition at line 384 of file rocs.c.

385{
386 int papi_errno = PAPI_OK;
387
388 switch(modifier) {
389 case PAPI_ENUM_FIRST:
390 if (ntv_table_p->count == 0) {
391 papi_errno = PAPI_ENOEVNT;
392 }
393 *event_code = 0;
394 break;
395 case PAPI_ENUM_EVENTS:
396 if (*event_code + 1 < (unsigned int) ntv_table_p->count) {
397 ++(*event_code);
398 } else {
399 papi_errno = PAPI_END;
400 }
401 break;
402 default:
403 papi_errno = PAPI_EINVAL;
404 }
405
406 return papi_errno;
407}
#define PAPI_ENUM_EVENTS
Definition: f90papi.h:224
#define PAPI_ENUM_FIRST
Definition: f90papi.h:85
#define PAPI_ENOEVNT
Definition: f90papi.h:139
#define PAPI_END
Definition: f90papi.h:303
Here is the caller graph for this function:

◆ rocs_evt_name_to_code()

int rocs_evt_name_to_code ( const char *  name,
unsigned int event_code 
)

Definition at line 421 of file rocs.c.

422{
423 int papi_errno = PAPI_OK;
424 int htable_errno;
425
426 ntv_event_t *event;
427 htable_errno = htable_find(htable, name, (void **) &event);
428 if (htable_errno != HTABLE_SUCCESS) {
429 papi_errno = (htable_errno == HTABLE_ENOVAL) ?
431 goto fn_exit;
432 }
433 *event_code = event->id;
434
435 fn_exit:
436 return papi_errno;
437}
#define HTABLE_ENOVAL
Definition: cuda/htable.h:18
#define HTABLE_SUCCESS
Definition: cuda/htable.h:17
static int htable_find(void *handle, const char *key, void **out)
Definition: cuda/htable.h:161
static void * htable
Definition: rocs.c:326
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rocs_init()

int rocs_init ( void  )

Definition at line 333 of file rocs.c.

334{
335 int papi_errno;
336
337 papi_errno = load_rsmi_sym();
338 if (papi_errno != PAPI_OK) {
339 return papi_errno;
340 }
341
342 rsmi_status_t status = rsmi_init_p(0);
343 if (status != RSMI_STATUS_SUCCESS) {
344 const char *status_string = NULL;
345 rsmi_status_string_p(status, &status_string);
346 strcpy(error_string, status_string);
347 return PAPI_EMISC;
348 }
349
351
352 status = rsmi_num_monitor_dev_p((uint32_t *)&device_count);
353 if (status != RSMI_STATUS_SUCCESS) {
354 sprintf(error_string, "Error while counting available devices.");
355 papi_errno = PAPI_EMISC;
356 goto fn_fail;
357 }
358
359 papi_errno = init_device_table();
360 if (papi_errno != PAPI_OK) {
361 sprintf(error_string, "Error while initializing device tables.");
362 goto fn_fail;
363 }
364
365 papi_errno = init_event_table();
366 if (papi_errno != PAPI_OK) {
367 sprintf(error_string, "Error while initializing the native event table.");
368 goto fn_fail;
369 }
370
372
373 fn_exit:
374 return papi_errno;
375 fn_fail:
380 goto fn_exit;
381}
static int htable_shutdown(void *handle)
Definition: cuda/htable.h:76
static int htable_init(void **handle)
Definition: cuda/htable.h:55
#define PAPI_EMISC
Definition: f90papi.h:122
static rsmi_status_t(* rsmi_num_monitor_dev_p)(uint32_t *)
Definition: rocs.c:13
static ntv_event_table_t ntv_table
Definition: rocs.c:324
static int load_rsmi_sym(void)
Definition: rocs.c:665
static rsmi_status_t(* rsmi_shut_down_p)(void)
Definition: rocs.c:66
static int shutdown_device_table(void)
Definition: rocs.c:1046
static rsmi_status_t(* rsmi_init_p)(uint64_t)
Definition: rocs.c:65
static int init_device_table(void)
Definition: rocs.c:994
static int init_event_table(void)
Definition: rocs.c:906
static int shutdown_event_table(void)
Definition: rocs.c:940
static int32_t device_count
Definition: rocs.c:328
static rsmi_status_t(* rsmi_status_string_p)(rsmi_status_t, const char **)
Definition: rocs.c:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rocs_shutdown()

int rocs_shutdown ( void  )

Definition at line 655 of file rocs.c.

656{
661 return unload_rsmi_sym();
662}
static int unload_rsmi_sym(void)
Definition: rocs.c:829
Here is the call graph for this function:
Here is the caller graph for this function: