src/components/rocm/linux-rocm.c
// ----------------------------------------------------------------------------
// Callback function that adds individual events.
Callback function that adds individual events.
Callback function that adds individual events .
static hsa_status_t _rocm_add_native_events_callback(const rocprofiler_info_data_t info, void * arg)
{
    uint32_t ui;
    events_callback_arg_t * callback_arg = (events_callback_arg_t*) arg;
    _rocm_context_t * ctx = callback_arg->ctx;
    const uint32_t eventDeviceNum = callback_arg->device_num;
    const uint32_t count = callback_arg->count;
          uint32_t index = ctx->availEventSize;
    const uint32_t instances = info.metric.instances;   
    if (index + instances > count) return HSA_STATUS_ERROR; 
    for (ui=0; ui<instances; ui++) {
      char ROCMname[PAPI_MAX_STR_LEN];
        if (instances > 1) {
            snprintf(ctx->availEventDesc[index].name,
                PAPI_MAX_STR_LEN, "%s:device=%d:instance=%d",       
                info.metric.name, eventDeviceNum, ui);
            snprintf(ROCMname, PAPI_MAX_STR_LEN, "%s[%d]",
                info.metric.name, ui);                               
        } else {
            snprintf(ctx->availEventDesc[index].name,
                PAPI_MAX_STR_LEN, "%s:device=%d",                   
                info.metric.name, eventDeviceNum);
            snprintf(ROCMname, PAPI_MAX_STR_LEN, "%s",
                info.metric.name);                                  
        }
        ROCMname[PAPI_MAX_STR_LEN - 1] = '\0';                      
        strncpy(ctx->availEventDesc[index].description, info.metric.description, PAPI_2MAX_STR_LEN);
        ctx->availEventDesc[index].description[PAPI_2MAX_STR_LEN - 1] = '\0';   
        EventID eventId;                                            
        eventId.kind = ROCPROFILER_FEATURE_KIND_METRIC;
        eventId.name = strdup(ROCMname);                            
        eventId.parameters = NULL;                                  
        eventId.parameter_count=0;                                  
        ctx->availEventDeviceNum[index] = eventDeviceNum;
        ctx->availEventIDArray[index] = eventId;
        index++;                                                    
        ctx->availEventSize = index;                                
    } 
    return HSA_STATUS_SUCCESS;
}
static hsa_status_t _rocm_add_native_events_callback ( const rocprofiler_info_data_t info , void * arg ) { uint32_t ui ; events_callback_arg_t * callback_arg = ( events_callback_arg_t * ) arg ; _rocm_context_t * ctx = callback_arg -> ctx ; const uint32_t eventDeviceNum = callback_arg -> device_num ; const uint32_t count = callback_arg -> count ; uint32_t index = ctx -> availEventSize ; const uint32_t instances = info . metric . instances ; if ( index + instances > count ) return HSA_STATUS_ERROR ; for ( ui = 0 ; ui < instances ; ui ++ ) { char ROCMname [ PAPI_MAX_STR_LEN ] ; if ( instances > 1 ) { snprintf ( ctx -> availEventDesc [ index ] . name , PAPI_MAX_STR_LEN , " " , info . metric . name , eventDeviceNum , ui ) ; snprintf ( ROCMname , PAPI_MAX_STR_LEN , " " , info . metric . name , ui ) ; } else { snprintf ( ctx -> availEventDesc [ index ] . name , PAPI_MAX_STR_LEN , " " , info . metric . name , eventDeviceNum ) ; snprintf ( ROCMname , PAPI_MAX_STR_LEN , " " , info . metric . name ) ; } ROCMname [ PAPI_MAX_STR_LEN - 1 ] = ' \0 ' ; strncpy ( ctx -> availEventDesc [ index ] . description , info . metric . description , PAPI_2MAX_STR_LEN ) ; ctx -> availEventDesc [ index ] . description [ PAPI_2MAX_STR_LEN - 1 ] = ' \0 ' ; EventID eventId ; eventId . kind = ROCPROFILER_FEATURE_KIND_METRIC ; eventId . name = strdup ( ROCMname ) ; eventId . parameters = NULL ; eventId . parameter_count = 0 ; ctx -> availEventDeviceNum [ index ] = eventDeviceNum ; ctx -> availEventIDArray [ index ] = eventId ; index ++ ; ctx -> availEventSize = index ; } return HSA_STATUS_SUCCESS ; }
Callback function that adds individual events.
Callback function that adds individual events .
// short cut to instances. //  information about AMD Event. //   fprintf(stderr, "%s:%i name=%s block_name=%s, instances=%i block_counters=%i.\n", //      __FILE__, __LINE__, info.metric.name, info.metric.block_name, info.metric.instances, //      info.metric.block_counters); // Should have enough space. // What PAPI user sees. // use indexed version. // What PAPI user sees. // use non-indexed version. // ensure z-terminated. // ensure z-terminated. // Removed declaration init. // what ROCM needs to see. // Not currently used, but init for safety. // Not currently used, but init for safety. // increment index. // Always set availEventSize. // end for each instance.