|
PAPI
5.0.1.0
|

Go to the source code of this file.
Data Structures | |
| struct | hwi_search_t |
| struct | hwi_presets_t |
| struct | hwi_describe_t |
Functions | |
| int | _papi_hwi_setup_all_presets (hwi_search_t *findem, int cidx) |
| int | _papi_hwi_cleanup_all_presets (void) |
| int | _xml_papi_hwi_setup_all_presets (char *arch) |
| int | _papi_load_preset_table (char *name, int type, int cidx) |
Variables | |
| hwi_search_t * | preset_search_map |
| hwi_presets_t | _papi_hwi_presets [PAPI_MAX_PRESET_EVENTS] |
Definition in file papi_preset.h.
| int _papi_hwi_cleanup_all_presets | ( | void | ) |
< No error
Definition at line 107 of file papi_preset.c.
{
int preset_index,cidx;
unsigned int j;
for ( preset_index = 0; preset_index < PAPI_MAX_PRESET_EVENTS;
preset_index++ ) {
if ( _papi_hwi_presets[preset_index].postfix != NULL ) {
free( _papi_hwi_presets[preset_index].postfix );
_papi_hwi_presets[preset_index].postfix = NULL;
}
if ( _papi_hwi_presets[preset_index].note != NULL ) {
free( _papi_hwi_presets[preset_index].note );
_papi_hwi_presets[preset_index].note = NULL;
}
for(j=0; j<_papi_hwi_presets[preset_index].count;j++) {
free(_papi_hwi_presets[preset_index].name[j]);
}
}
for(cidx=0;cidx<papi_num_components;cidx++) {
_papi_hwd[cidx]->cmp_info.num_preset_events = 0;
}
#if defined(ITANIUM2) || defined(ITANIUM3)
/* NOTE: This memory may need to be freed for BG/P builds as well */
if ( preset_search_map != NULL ) {
papi_free( preset_search_map );
preset_search_map = NULL;
}
#endif
return PAPI_OK;
}

| int _papi_hwi_setup_all_presets | ( | hwi_search_t * | findem, |
| int | cidx | ||
| ) |
<A nonexistent hardware event used as a placeholder
<A nonexistent hardware event used as a placeholder
< No error
< Event does not exist
Definition at line 37 of file papi_preset.c.
{
int i, pnum, did_something = 0;
unsigned int preset_index, j, k;
/* dense array of events is terminated with a 0 preset.
don't do anything if NULL pointer. This allows just notes to be loaded.
It's also good defensive programming.
*/
if ( findem != NULL ) {
for ( pnum = 0; ( pnum < PAPI_MAX_PRESET_EVENTS ) &&
( findem[pnum].event_code != 0 ); pnum++ ) {
/* find the index for the event to be initialized */
preset_index = ( findem[pnum].event_code & PAPI_PRESET_AND_MASK );
/* count and set the number of native terms in this event,
these items are contiguous.
PAPI_EVENTS_IN_DERIVED_EVENT is arbitrarily defined in the high
level to be a reasonable number of terms to use in a derived
event linear expression, currently 8.
This wastes space for components with less than 8 counters,
but keeps the framework independent of the components.
The 'native' field below is an arbitrary opaque identifier
that points to information on an actual native event.
It is not an event code itself (whatever that might mean).
By definition, this value can never == PAPI_NULL.
- dkt */
INTDBG( "Counting number of terms for preset index %d, "
"search map index %d.\n", preset_index, pnum );
i = 0;
j = 0;
while ( i < PAPI_EVENTS_IN_DERIVED_EVENT ) {
if ( findem[pnum].native[i] != PAPI_NULL ) {
j++;
}
else if ( j ) {
break;
}
i++;
}
INTDBG( "This preset has %d terms.\n", j );
_papi_hwi_presets[preset_index].count = j;
_papi_hwi_presets[preset_index].derived_int = findem[pnum].derived;
for(k=0;k<j;k++) {
_papi_hwi_presets[preset_index].code[k] =
findem[pnum].native[k];
}
/* preset code list must be PAPI_NULL terminated */
if (k<PAPI_EVENTS_IN_DERIVED_EVENT) {
_papi_hwi_presets[preset_index].code[k] = PAPI_NULL;
}
_papi_hwi_presets[preset_index].postfix=
strdup(findem[pnum].operation);
did_something++;
}
}
_papi_hwd[cidx]->cmp_info.num_preset_events += did_something;
return ( did_something ? PAPI_OK : PAPI_ENOEVNT );
}

| int _papi_load_preset_table | ( | char * | name, |
| int | type, | ||
| int | cidx | ||
| ) |
< A System/C library call failed
< No error
< No error
< Process counters based on specified postfix string
< No error
<A nonexistent hardware event used as a placeholder
< No error
Definition at line 299 of file papi_preset.c.
{
(void) cidx; /* We'll use this later */
char pmu_name[PAPI_MIN_STR_LEN];
char line[LINE_MAX];
char name[PATH_MAX] = "builtin papi_events_table";
char *tmp_papi_events_table = NULL;
char *tmpn;
FILE *table;
int ret;
unsigned int event_idx;
int invalid_event;
int line_no = 1, derived = 0, insert = 0, preset = 0;
int get_presets = 0; /* only get PRESETS after CPU is identified */
int found_presets = 0; /* only terminate search after PRESETS are found */
/* this allows support for synonyms for CPU names*/
SUBDBG("ENTER\n");
/* copy the pmu identifier, stripping commas if found */
tmpn = pmu_name;
while ( *pmu_str ) {
if ( *pmu_str != ',' ) *tmpn++ = *pmu_str;
pmu_str++;
}
*tmpn = '\0';
/* try the environment variable first */
if ( ( tmpn = getenv( "PAPI_CSV_EVENT_FILE" ) ) &&
( strlen( tmpn ) != 0 ) ) {
sprintf( name, "%s", tmpn );
table = fopen( name, "r" );
}
/* if no valid environment variable, look for built-in table */
else if ( papi_events_table ) {
tmp_papi_events_table = papi_events_table;
table = NULL;
}
/* if no env var and no built-in, search for default file */
else {
#ifdef PAPI_DATADIR
sprintf( name, "%s/%s", PAPI_DATADIR, PAPI_EVENT_FILE );
#else
sprintf( name, "%s", PAPI_EVENT_FILE );
#endif
table = open_event_table( name );
}
/* if no valid file or built-in table, bail */
if ( table == NULL && tmp_papi_events_table == NULL ) {
PAPIERROR( "fopen(%s): %s, please set the PAPI_CSV_EVENT_FILE "
"env. variable", name, strerror( errno ) );
return PAPI_ESYS;
}
/* at this point either a valid file pointer or built-in table pointer */
while ( get_event_line( line, table, &tmp_papi_events_table ) ) {
char *t;
int i;
t = trim_string( strtok( line, "," ) );
/* Skip blank lines */
if ( ( t == NULL ) || ( strlen( t ) == 0 ) ) continue;
/* Skip comments */
if ( t[0] == '#' ) {
goto nextline;
}
if ( strcasecmp( t, "CPU" ) == 0 ) {
if ( get_presets != 0 && found_presets != 0 ) {
SUBDBG( "Ending preset scanning at line %d of %s.\n",
line_no, name );
get_presets=0; found_presets=0;
}
t = trim_string( strtok( NULL, "," ) );
if ( ( t == NULL ) || ( strlen( t ) == 0 ) ) {
PAPIERROR( "Expected name after CPU token at line %d of %s "
"-- ignoring", line_no, name );
goto nextline;
}
SUBDBG( "Examining CPU (%s) vs. (%s)\n", t, pmu_name );
if ( strcasecmp( t, pmu_name ) == 0 ) {
int type;
SUBDBG( "Found CPU %s at line %d of %s.\n", t, line_no, name );
t = trim_string( strtok( NULL, "," ) );
if ( ( t == NULL ) || ( strlen( t ) == 0 ) ) {
SUBDBG("No additional qualifier found, matching on string.\n");
get_presets = 1;
} else if ( ( sscanf( t,"%d",&type )==1) && (type==pmu_type) ) {
SUBDBG( "Found CPU %s type %d at line %d of %s.\n",
pmu_name, type, line_no, name );
get_presets = 1;
} else {
SUBDBG( "Additional qualifier match failed %d vs %d.\n",
pmu_type, type );
}
}
} else if ( strcasecmp( t, "PRESET" ) == 0 ) {
if ( get_presets == 0 ) goto nextline;
found_presets = 1;
t = trim_string( strtok( NULL, "," ) );
if ( ( t == NULL ) || ( strlen( t ) == 0 ) ) {
PAPIERROR( "Expected name after PRESET token at line %d of %s "
"-- ignoring", line_no, name );
goto nextline;
}
SUBDBG( "Examining preset %s\n", t );
if ( find_preset_code( t, &preset ) != PAPI_OK ) {
PAPIERROR ( "Invalid preset name %s after PRESET token "
"at line %d of %s -- ignoring",
t, line_no, name );
goto nextline;
}
SUBDBG( "Found 0x%08x for %s\n", preset, t );
t = trim_string( strtok( NULL, "," ) );
if ( ( t == NULL ) || ( strlen( t ) == 0 ) ) {
PAPIERROR( "Expected derived type after PRESET token at "
"line %d of %s -- ignoring", line_no, name );
goto nextline;
}
if ( _papi_hwi_derived_type( t, &derived ) != PAPI_OK ) {
PAPIERROR( "Invalid derived name %s after PRESET token at "
"line %d of %s -- ignoring",
t, line_no, name );
goto nextline;
}
/****************************************/
/* Have a preset, let's start assigning */
/****************************************/
SUBDBG( "Found %d for %s\n", derived, t );
SUBDBG( "Adding 0x%x,%d to preset search table.\n",
preset, derived );
insert=preset&PAPI_PRESET_AND_MASK;
/* _papi_hwi_presets[insert].event_code = preset; */
_papi_hwi_presets[insert].derived_int = derived;
/* Derived support starts here */
/* Special handling for postfix */
if ( derived == DERIVED_POSTFIX ) {
t = trim_string( strtok( NULL, "," ) );
if ( ( t == NULL ) || ( strlen( t ) == 0 ) ) {
PAPIERROR( "Expected Operation string after derived type "
"DERIVED_POSTFIX at line %d of %s -- ignoring",
line_no, name );
goto nextline;
}
SUBDBG( "Saving PostFix operations %s\n", t );
_papi_hwi_presets[insert].postfix=strdup(t);
}
/* All derived terms collected here */
i = 0;
invalid_event=0;
do {
t = trim_string( strtok( NULL, "," ) );
if ( ( t == NULL ) || ( strlen( t ) == 0 ) ) break;
if ( strcasecmp( t, "NOTE" ) == 0 ) break;
_papi_hwi_presets[insert].name[i]=strdup(t);
SUBDBG( "Adding term (%d) %s to preset event 0x%x.\n",
i, t, preset );
SUBDBG("Looking up: %s\n",t);
ret=_papi_hwd[cidx]->ntv_name_to_code(t, &event_idx);
if (ret==PAPI_OK) {
_papi_hwi_presets[insert].code[i]=
_papi_hwi_native_to_eventcode(cidx,event_idx);
SUBDBG("Found: %s %x c%d e%d\n",t,
_papi_hwi_presets[insert].code[i],
cidx,event_idx);
}
else {
PAPIERROR("papi_preset: Error finding event %s",t);
invalid_event=1;
}
} while ( ++i < PAPI_EVENTS_IN_DERIVED_EVENT );
/* preset code list must be PAPI_NULL terminated */
if (i<PAPI_EVENTS_IN_DERIVED_EVENT) {
_papi_hwi_presets[insert].code[i] = PAPI_NULL;
}
if (invalid_event) {
/* We signify a valid preset if count > 0 */
_papi_hwi_presets[insert].count=0;
} else {
_papi_hwi_presets[insert].count=i;
}
/* End of derived support */
if ( i == 0 ) {
PAPIERROR( "Expected PFM event after DERIVED token at "
"line %d of %s -- ignoring", line_no, name );
goto nextline;
}
if ( i == PAPI_EVENTS_IN_DERIVED_EVENT ) {
t = trim_string( strtok( NULL, "," ) );
}
/* Handle optional NOTEs */
if ( t && ( strcasecmp( t, "NOTE" ) == 0 ) ) {
SUBDBG( "%s found on line %d\n", t, line_no );
/* read the rest of the line */
t = trim_note( strtok( NULL, "" ) );
if ( ( t == NULL ) || ( strlen( t ) == 0 ) ) {
PAPIERROR( "Expected Note string at line %d of %s\n",
line_no, name );
}
else {
_papi_hwi_presets[insert].note = strdup( t );
SUBDBG( "NOTE: --%s-- found on line %d\n", t, line_no );
}
}
_papi_hwd[cidx]->cmp_info.num_preset_events++;
} else {
PAPIERROR( "Unrecognized token %s at line %d of %s -- ignoring",
t, line_no, name );
goto nextline;
}
nextline:
line_no++;
}
if ( table ) {
fclose( table );
}
SUBDBG("Done parsing preset table\n");
return PAPI_OK;
}


| int _xml_papi_hwi_setup_all_presets | ( | char * | arch | ) |
Definition at line 6 of file papi_common_strings.h.
Definition at line 1080 of file perfmon-ia64.c.