Skip to content

Commit

Permalink
Merge pull request #179 from adanalis/2024.04.SDE.code_to_info
Browse files Browse the repository at this point in the history
SDE: Adding ntv_code_to_info functionality.
  • Loading branch information
adanalis authored Apr 3, 2024
2 parents 40df2b4 + 3b4ce82 commit e811329
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/components/sde/sde.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,46 @@ _sde_ntv_code_to_descr( unsigned int EventCode, char *descr, int len )
return ret_val;
}

/** Takes a native event code and passes back the event info
* @param EventCode is the native event code
* @param info is a pointer to a PAPI_event_info_t structure where the event information will be stored.
*/
static int
_sde_ntv_code_to_info( unsigned int EventCode, PAPI_event_info_t *info)
{
int ret_val = PAPI_OK;
unsigned int code = EventCode & PAPI_NATIVE_AND_MASK;

SUBDBG("_sde_ntv_code_to_info %u\n", code);

info->event_code = EventCode;
info->component_index = _sde_vector.cmp_info.CmpIdx;

_papi_hwi_lock(_sde_component_lock);

char *ev_name = sde_ti_get_event_name_ptr((uint32_t)code);
char *ev_descr = sde_ti_get_event_description_ptr((uint32_t)code);
if( (NULL == ev_descr) || (NULL == ev_name) ){
ret_val = PAPI_ENOEVNT;
goto fnct_exit;
}
SUBDBG("Event (code = %d) name: %s \n", code, ev_name);
SUBDBG("Event (code = %d) description: %s\n", code, ev_descr);

(void)strncpy( info->symbol, ev_name, PAPI_HUGE_STR_LEN-1 );
info->symbol[PAPI_HUGE_STR_LEN-1] = '\0';

(void)strncpy( info->long_descr, ev_descr, PAPI_HUGE_STR_LEN-1 );
info->long_descr[PAPI_HUGE_STR_LEN-1] = '\0';

(void)strncpy( info->short_descr, ev_descr, PAPI_MIN_STR_LEN-1 );
info->long_descr[PAPI_MIN_STR_LEN-1] = '\0';

fnct_exit:
_papi_hwi_unlock(_sde_component_lock);
return ret_val;
}

/** Takes a native event name and passes back the code
* @param event_name -- a pointer for the name to be copied to
* @param event_code -- the native event code
Expand Down Expand Up @@ -1090,6 +1130,7 @@ papi_vector_t _sde_vector = {
.ntv_enum_events = _sde_ntv_enum_events,
.ntv_code_to_name = _sde_ntv_code_to_name,
.ntv_code_to_descr = _sde_ntv_code_to_descr,
.ntv_code_to_info = _sde_ntv_code_to_info,
/* if .ntv_name_to_code not available, PAPI emulates */
/* it by enumerating all events and looking manually */
.ntv_name_to_code = _sde_ntv_name_to_code,
Expand Down

0 comments on commit e811329

Please sign in to comment.