src/components/rocm/linux-rocm.c
/* Initialize hardware counters, setup the function vector table
 * and get hardware information, this routine is called when the
 * PAPI process is initialized (IE PAPI_library_init)
 */
Initialize hardware counters, setup the function vector table
and get hardware information, this routine is called when the
PAPI process is initialized
Initialize hardware counters setup the function vector table and get hardware information this routine is called when the PAPI process is initialized
static int _rocm_init_component(int cidx)
{
    ROCMDBG("Entering _rocm_init_component\n");
    if(_rocm_linkRocmLibraries() != PAPI_OK) {
        SUBDBG("Dynamic link of ROCM libraries failed, component will be disabled.\n");
        SUBDBG("See disable reason in papi_component_avail output for more details.\n");
        return (PAPI_ENOSUPP);
    }
    ROCM_CALL_CK(hsa_init, (), return (PAPI_EMISC));
    if(global__rocm_context == NULL)
        global__rocm_context = (_rocm_context_t *) papi_calloc(1, sizeof(_rocm_context_t));
    ROCM_CALL_CK(hsa_iterate_agents, (_rocm_get_gpu_handle, global__rocm_context), return (PAPI_EMISC));
    int rv;
    rv = _rocm_add_native_events(global__rocm_context);
    if(rv != 0)
        return (rv);
    _rocm_vector.cmp_info.CmpIdx = cidx;
    _rocm_vector.cmp_info.num_native_events = global__rocm_context->availEventSize;
    _rocm_vector.cmp_info.num_cntrs = _rocm_vector.cmp_info.num_native_events;
    _rocm_vector.cmp_info.num_mpx_cntrs = _rocm_vector.cmp_info.num_native_events;
    ROCMDBG("Exiting _rocm_init_component cidx %d num_native_events %d num_cntrs %d num_mpx_cntrs %d\n",
        cidx,
        _rocm_vector.cmp_info.num_native_events,
        _rocm_vector.cmp_info.num_cntrs,
        _rocm_vector.cmp_info.num_mpx_cntrs);
    if (_rocm_vector.cmp_info.num_native_events == 0) {
        char *metrics = getenv("ROCP_METRICS");
        if (metrics == NULL) {
            strncpy(_rocm_vector.cmp_info.disabled_reason, "Environment Variable ROCP_METRICS is not defined, should point to a valid metrics.xml.", PAPI_MAX_STR_LEN);
            return (PAPI_EMISC);
        }
        snprintf(_rocm_vector.cmp_info.disabled_reason, PAPI_MAX_STR_LEN, "No events.  Ensure ROCP_METRICS=%s is correct.", metrics);
        return (PAPI_EMISC);
    }
    return (PAPI_OK);
}
static int _rocm_init_component ( int cidx ) { ROCMDBG ( " \n " ) ; if ( _rocm_linkRocmLibraries ( ) != PAPI_OK ) { SUBDBG ( " \n " ) ; SUBDBG ( " \n " ) ; return ( PAPI_ENOSUPP ) ; } ROCM_CALL_CK ( hsa_init , ( ) , return ( PAPI_EMISC ) ) ; if ( global__rocm_context == NULL ) global__rocm_context = ( _rocm_context_t * ) papi_calloc ( 1 , sizeof ( _rocm_context_t ) ) ; ROCM_CALL_CK ( hsa_iterate_agents , ( _rocm_get_gpu_handle , global__rocm_context ) , return ( PAPI_EMISC ) ) ; int rv ; rv = _rocm_add_native_events ( global__rocm_context ) ; if ( rv != 0 ) return ( rv ) ; _rocm_vector . cmp_info . CmpIdx = cidx ; _rocm_vector . cmp_info . num_native_events = global__rocm_context -> availEventSize ; _rocm_vector . cmp_info . num_cntrs = _rocm_vector . cmp_info . num_native_events ; _rocm_vector . cmp_info . num_mpx_cntrs = _rocm_vector . cmp_info . num_native_events ; ROCMDBG ( " \n " , cidx , _rocm_vector . cmp_info . num_native_events , _rocm_vector . cmp_info . num_cntrs , _rocm_vector . cmp_info . num_mpx_cntrs ) ; if ( _rocm_vector . cmp_info . num_native_events == 0 ) { char * metrics = getenv ( " " ) ; if ( metrics == NULL ) { strncpy ( _rocm_vector . cmp_info . disabled_reason , " " , PAPI_MAX_STR_LEN ) ; return ( PAPI_EMISC ) ; } snprintf ( _rocm_vector . cmp_info . disabled_reason , PAPI_MAX_STR_LEN , " " , metrics ) ; return ( PAPI_EMISC ) ; } return ( PAPI_OK ) ; }
Initialize hardware counters, setup the function vector table
 and get hardware information, this routine is called when the
 PAPI process is initialized (IE PAPI_library_init)
Initialize hardware counters setup the function vector table and get hardware information this routine is called when the PAPI process is initialized ( IE PAPI_library_init )
/* link in all the rocm libraries and resolve the symbols we need to use */ /* Create the structure */ /* Get GPU agent */ /* Get list of all native ROCM events supported */ /* Export some information */