15#include "libperfctr.h"
48 for ( gnum = 0; gnum < group_info->
maxgroups; gnum++ ) {
59 for ( gnum = 0; gnum < group_info->
maxgroups; gnum++ ) {
75 int pmc, ev,
i, j, index;
87 for ( pmc = 0; pmc < info->
maxpmcs; pmc++ ) {
88 wevp = info->
wev[pmc];
89 for ( ev = 0; ev < info->
maxevents[pmc]; ev++, wevp++ ) {
90 for (
i = 0;
i < index;
i++ ) {
103 (
char * ) malloc( strlen( wevp->
symbol ) + 1 );
114 SUBDBG(
"native_name_map has a NULL at position %i\n",
117 (
"Inconsistency between events_map file and events header." );
132 (
"No match found between native_name_map and native_table. "
133 "Values was %s at position %i in native_table.\n",
136 (
"Inconsistency between native_name_map and events file." );
146 SUBDBG(
"%i events found in native_table, but really should be %i\n",
149 (
"Inconsistent cardinality between native_name_map and events file",
155 if ( gp_info == NULL ) {
180 SUBDBG(
"%i is the number of elements apparently in native_name, "
181 "but really should be %i, according to native_name_map.\n",
184 (
"Inconsistent cardinality between native_name and native_name_map "
185 "detected in preliminary check\n" );
202 SUBDBG(
"Inconsistency between native_name_map and native_name. "
203 "%i events matched, but really should be %i\n", itemCount,
206 (
"Inconsistent cardinality between native_name and native_name_map\n" );
218 char *dot_dot =
"..";
221#elif defined(_POWER5)
223#elif defined(_PPC970)
228 char *dir = (
char * ) getenv(
"PAPI_EVENTFILE_PATH" );
238 char *relative_pathname = (
char * ) malloc( strlen(
"/" ) +
239 strlen(
"event_data" ) +
240 strlen(
"/" ) + strlen( cpu ) +
242 strlen( fname ) + 1 );
243 strcpy( relative_pathname,
"/" );
244 strcat( relative_pathname,
"event_data" );
245 strcat( relative_pathname,
"/" );
246 strcat( relative_pathname, cpu );
247 strcat( relative_pathname,
"/" );
248 strcat( relative_pathname, fname );
252 (
char * ) malloc( strlen( dir ) + strlen( relative_pathname ) + 4 );
254 if ( strcmp( dir, dot ) == 0 )
259 while (
file == NULL && keep_trying-- ) {
260 strcpy( pathname, dir );
261 strcat( pathname, relative_pathname );
262 file = fopen( pathname,
"r" );
263 if ( strcmp( dir, dot ) == 0 ) {
268 SUBDBG(
"Attempt to open event data file %s %s successful.\n", pathname,
269 (
file == NULL ) ?
"was not" :
"was" );
270 memset( pathname,
'\0',
sizeof ( pathname ) );
274 free( relative_pathname );
286 for ( cnt = 0; cnt < maxevents; cnt++, cur_wev++ ) {
290 (
char * ) malloc( strlen(
events[cnt].short_description ) );
293 (
char * ) malloc( strlen(
events[cnt].description ) );
305 int line_counter_flag = 0;
306 char line_data[1024];
312 while ( fgets( data, 1022, evfile ) ) {
313 if ( feof( evfile ) )
315 if ( strlen( data ) < 2 )
318 if ( strncmp( data,
"$$$$", 4 ) == 0 ) {
319 line_counter_flag = 0;
325 switch ( line_counter_flag ) {
327 if ( sscanf( data,
"{ counter %u", &counter ) == 1 ) {
328 line_counter_flag = 1;
334 if ( sscanf( data,
"#%u", &event ) != 1 ) {
335 fprintf(
stderr,
"EVS file format error 1 (%s)\n", data );
339 fprintf(
stderr,
"EVS file format error 1 (%s)\n", data );
343 len = strlen( data );
345 for (
i = cc = 0;
i < len;
i++ ) {
346 if ( data[
i] ==
',' )
348 if ( cc == 5 && !symb_found ) {
349 strcpy( line_data, &data[
i + 1] );
351 while ( line_data[j] !=
',' )
357 }
else if ( cc == 6 ) {
358 len = strlen( &data[
i + 1] );
360 (
char * ) malloc( len );
367 line_counter_flag = 2;
370 line_counter_flag = 3;
373 len = strlen( data );
377 line_counter_flag = 1;
382 if ( counter == 0 ) {
383 free( ntv_evt_info );
398 for ( j = 0; j < size; j++ ) {
409 unsigned int mmcr0, mmcr1H, mmcr1L, mmcra;
416 while ( fgets( data, 1022, grp_file ) ) {
417 if ( feof( grp_file ) || ( strlen( data ) < 2 ) )
422#if defined(_POWER5) || defined(_POWER5p)
424 ( data,
"#%u,%u,%u,%u,%u,%u,%u", &g, &event_num[0],
425 &event_num[1], &event_num[2], &event_num[3], &event_num[4],
426 &event_num[5] ) == 7 ) {
429 fprintf(
stderr,
"ERROR: Maximum events exceeded\n" );
435 ( data,
"#%u,%u,%u,%u,%u,%u,%u,%u,%u", &g, &event_num[0],
436 &event_num[1], &event_num[2], &event_num[3], &event_num[4],
437 &event_num[5], &event_num[6], &event_num[7] ) == 9 ) {
440 fprintf(
stderr,
"ERROR: Maximum events exceeded\n" );
461 if ( sscanf( data,
"%#x,%#x,%#x,%#x", &mmcr0, &mmcr1H, &mmcr1L, &mmcra )
463 fprintf(
stderr,
"GPS file format error 1 (%s)\n", data );
487 if ( evt_file != NULL ) {
498 FILE *grp_file = NULL;
499 if ( ( grp_file =
open_file(
"groups" ) ) != NULL ) {
PPC64_native_map_t native_name_map[PAPI_MAX_NATIVE_EVENTS]
#define MAX_NATNAME_MAP_INDEX
#define PAPI_MAX_NATIVE_EVENTS
char events[MAX_EVENTS][BUFSIZ]
#define SUBDBG(format, args...)
int fclose(FILE *__stream)
void PAPIERROR(char *format,...)
#define EVENT_INFO_FILE_ERROR
papi_mdi_t _papi_hwi_system_info
static const pmg_power_group_t * groups
void perfctr_ppc64_setup_gps(int total, ntv_event_group_info_t *group_info)
static int any_counter_invalid(int event_id[], int size)
hwd_groups_t group_map[MAX_GROUPS]
ntv_event_group_info_t * perfctr_get_native_group_info(void)
void perfctr_initialize_native_table()
native_event_entry_t native_table[PAPI_MAX_NATIVE_EVENTS]
ntv_event_info_t * perfctr_get_native_evt_info(void)
static ntv_event_t * copy_buffer(ntv_event_t events[], int maxevents)
static ntv_event_group_info_t * parse_groupfile(FILE *grp_file)
static FILE * open_file(const char *fname)
static ntv_event_info_t * parse_eventfile(FILE *evfile)
int perfctr_ppc64_setup_native_table()
unsigned int events[MAX_COUNTERS]
char name[PAPI_MAX_STR_LEN]
event_group_t * event_groups[MAX_GROUPS]
int maxevents[MAX_COUNTERS]
ntv_event_t * wev[MAX_COUNTERS]
char symbol[PAPI_MAX_STR_LEN]