Ejemplo n.º 1
0
void dump_avail(char * (*get_avail(unsigned *)))
{
  unsigned n_avail, i;
  char *ptr, ** avail = get_avail(&n_avail);
  int eventcode = PAPI_NULL, retval;
  PAPI_event_info_t info;

  for(i=0;i<n_avail;i++){
    if(get_avail == get_native_avail_papi_counters || get_avail == get_preset_avail_papi_counters){
      PAPI_event_name_to_code(avail[i],&eventcode);
      PAPI_get_event_info(eventcode, &info);
      printf("\t%s%*s, %s\n",info.symbol, (int)(40-strlen(info.symbol))," ", info.long_descr);
      
      if(get_avail == get_native_avail_papi_counters &&
	 PAPI_enum_event(&eventcode, PAPI_NTV_ENUM_UMASKS) == PAPI_OK){
	printf("\t\t%s%*s, %s\n","Masks", (int)(20-strlen("Masks"))," ", "Mask description");
	do{
	  retval = PAPI_get_event_info(eventcode, &info);
	  if (retval == PAPI_OK){
	    if(parse_unit_masks(&info)){
	      printf("\t\t%s%*s, %s\n",info.symbol, (int)(20-strlen(info.symbol))," ",info.long_descr);
	    }
	  }
	} while ( PAPI_enum_event( &eventcode, PAPI_NTV_ENUM_UMASKS) == PAPI_OK );
      }
    }
    else
      printf("%s\n",avail[i]);

    free(avail[i]);
  }
  free(avail);
}
Ejemplo n.º 2
0
int main(int argc, char **argv)
{
   int i,j;
   int retval;
   int print_avail_only = 0;
   PAPI_event_info_t info;
   const PAPI_hw_info_t *hwinfo = NULL;

   tests_quiet(argc, argv);     /* Set TESTS_QUIET variable */
   for (i = 0; i < argc; i++)
      if (argv[i]) {
         if (strstr(argv[i], "-a"))
            print_avail_only = PAPI_PRESET_ENUM_AVAIL;
         if (strstr(argv[i], "-h")) {
            print_help();
            exit(1);
         }
      }

   retval = PAPI_library_init(PAPI_VER_CURRENT);
   if (retval != PAPI_VER_CURRENT)
      test_fail(__FILE__, __LINE__, "PAPI_library_init", retval);

   if (!TESTS_QUIET) {
      retval = PAPI_set_debug(PAPI_VERB_ECONT);
      if (retval != PAPI_OK)
         test_fail(__FILE__, __LINE__, "PAPI_set_debug", retval);
   }

   if ((hwinfo = PAPI_get_hardware_info()) == NULL)
      test_fail(__FILE__, __LINE__, "PAPI_get_hardware_info", 2);

   i = PAPI_PRESET_MASK;
   printf("name,derived,postfix,short_descr,long_descr,note,[native,...]\n\n");

   do {
      if (PAPI_get_event_info(i, &info) == PAPI_OK) {
	      printf("%s,%s,%s,", info.symbol, info.derived, info.postfix);
         if (info.short_descr[0]) { printf("\"%s\",", info.short_descr); }
         else { printf(","); }
         if (info.long_descr[0]) { printf("\"%s\",", info.long_descr); }
         else { printf(","); }
	      if (info.note[0]) printf("\"%s\"", info.note);

         for (j=0;j<(int)info.count;j++) printf(",%s",info.name[j]);
         printf("\n");
	   }
   } while (PAPI_enum_event(&i, print_avail_only) == PAPI_OK);
   exit(1);
}
Ejemplo n.º 3
0
int main() {
    int EventCode, retval;
    char EventCodeStr[PAPI_MAX_STR_LEN];

    /* Initialize the library */
    retval = PAPI_library_init(PAPI_VER_CURRENT);

    if (retval != PAPI_VER_CURRENT) {
        fprintf(stderr, "PAPI library init error!\n");
        exit(1);
    }

    EventCode = 0 | 0x40000000;
    do {
        /* Translate the integer code to a string */
        if (PAPI_event_code_to_name(EventCode, EventCodeStr) == PAPI_OK)

            /* Print all the native events for this platform */
            printf("Name: %s\nCode: %x\n", EventCodeStr, EventCode);

    } while (PAPI_enum_event(&EventCode, 0) == PAPI_OK);
}
Ejemplo n.º 4
0
void printAllAvailableCounters(){
    // initialize papi library and assert that it's successful
    assert( PAPI_library_init( PAPI_VER_CURRENT ) == PAPI_VER_CURRENT );    

    // print header
    printf( "--- Available events ---\n" );
    printf( "%-15s %s\n", "Name", "Description" );
    // loop through all PAPI events supported on this plattform
    int event = 0 | PAPI_PRESET_MASK; // the first event
    do {
        // ignore unsupported events
        if ( PAPI_query_event( event ) != PAPI_OK ) continue; 

        // get event info
        PAPI_event_info_t info;
        (void) PAPI_get_event_info( event, &info);

        // print
        printf( "%-15s %s\n", info.symbol, info.long_descr );
    } while ( PAPI_enum_event( &event, PAPI_ENUM_ALL ) == PAPI_OK );


}
Ejemplo n.º 5
0
int
main( int argc, char **argv )
{
	int i, j = 0, k;
	int retval;
	PAPI_event_info_t info;
	const PAPI_hw_info_t *hwinfo = NULL;
	command_flags_t flags;
	int enum_modifier;
	int numcmp, cid;

	/* Set TESTS_QUIET variable */
	tests_quiet( argc, argv );

	/* Initialize before parsing the input arguments */
	retval = PAPI_library_init( PAPI_VER_CURRENT );
	if ( retval != PAPI_VER_CURRENT ) {
		test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
	}

	/* Parse the command-line arguments */
	parse_args( argc, argv, &flags );

	/* Set enum modifier mask */
	if ( flags.dear )
		enum_modifier = PAPI_NTV_ENUM_DEAR;
	else if ( flags.darr )
		enum_modifier = PAPI_NTV_ENUM_DARR;
	else if ( flags.iear )
		enum_modifier = PAPI_NTV_ENUM_IEAR;
	else if ( flags.iarr )
		enum_modifier = PAPI_NTV_ENUM_IARR;
	else if ( flags.opcm )
		enum_modifier = PAPI_NTV_ENUM_OPCM;
	else
		enum_modifier = PAPI_ENUM_EVENTS;


	if ( !TESTS_QUIET ) {
	   retval = PAPI_set_debug( PAPI_VERB_ECONT );
	   if ( retval != PAPI_OK ) {
	      test_fail( __FILE__, __LINE__, "PAPI_set_debug", retval );
	   }
	}

	retval = papi_print_header( "Available native events and hardware information.\n", &hwinfo );
	if ( retval != PAPI_OK ) {
		test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
	}


	/* Do this code if an event name was specified on the commandline */
	if ( flags.named ) {
	   if ( PAPI_event_name_to_code( flags.name, &i ) == PAPI_OK ) {
	      if ( PAPI_get_event_info( i, &info ) == PAPI_OK ) {
		 printf( "%-30s%s\n%-30s%d\n",
			 "Event name:", info.symbol,
			 "Number of Register Values:", info.count );
		 printf( "%-29s|%s|\n", "Description:", info.long_descr );
		 for ( k = 0; k < ( int ) info.count; k++ )
		     printf( " Register[%2d]:               |%s|\n", 
			     k, info.name[k] );

		     /* if unit masks exist but none specified, process all */
		     if ( !strchr( flags.name, ':' ) ) {
			if ( PAPI_enum_event( &i, PAPI_NTV_ENUM_UMASKS ) == PAPI_OK ) {
			   printf( "\nUnit Masks:\n" );
			   do {
			      retval = PAPI_get_event_info( i, &info );
			      if ( retval == PAPI_OK ) {
				 if ( parse_unit_masks( &info ) ) {
				    printf( "%-29s|%s|%s|\n", " Mask Info:",
					    info.symbol, info.long_descr );
				    for ( k = 0; k < ( int ) info.count; k++ )
					printf( "  Register[%2d]:  0x%08x  |%s|\n",
					       k, info.code[k], info.name[k] );
				 }
			      }
			   } while ( PAPI_enum_event( &i, PAPI_NTV_ENUM_UMASKS ) == PAPI_OK );
			}
		     }
	      }
	   } else {
	     printf("Sorry, an event by the name '%s' could not be found.\n",
		    flags.name);
	     printf("Is it typed correctly?\n\n");
	     exit( 1 );
	   }
	}
        else {

	   /* Print *ALL* available events */


	   numcmp = PAPI_num_components(  );

	   j = 0;

	   for ( cid = 0; cid < numcmp; cid++ ) {

	       const PAPI_component_info_t *component;
	       component=PAPI_get_component_info(cid);

	       /* Skip if requested enumeration not available */
	       if (( flags.dear ) && !( component->cntr_DEAR_events )) {
		 continue;
	       }
	       if (( flags.darr ) && !( component->data_address_range)) {
		 continue;
	       }
               if (( flags.iear ) && !( component->cntr_IEAR_events )) {
		 continue;
	       }
	       if (( flags.iarr ) && !( component->instr_address_range )) {
		 continue;
	       }
	       if (( flags.opcm ) && !( component->cntr_OPCM_events )) {
		 continue;
	       }


	       printf( "===============================================================================\n" );
	       printf( " Events in Component: %s\n",component->name);
	       printf( "===============================================================================\n" );
	     
	       /* Always ASK FOR the first event */
	       /* Don't just assume it'll be the first numeric value */
	       i = 0 | PAPI_NATIVE_MASK | PAPI_COMPONENT_MASK( cid );

	       /* UGH PAPI_enum_event() really needs a component field */
	       PAPI_enum_event( &i, PAPI_ENUM_FIRST );

	       do {
		  memset( &info, 0, sizeof ( info ) );
		  retval = PAPI_get_event_info( i, &info );

		  /* This event may not exist */
		  if ( retval != PAPI_OK )
		     continue;

		  /* count only events that as supported by host cpu */
		  j++;

		  print_event( &info, 0 );

		  /* Does this matter on anything but perfctr? */
		  if ( flags.details ) {
		     for ( k = 0; k < ( int ) info.count; k++ ) {
			 if ( strlen( info.name[k] ) ) {
			    printf( "  Register[%d] Name: %-20s  Value: 0x%-28x|\n",
				    k, info.name[k], info.code[k] );
			 }
		     }
		  }

/*		modifier = PAPI_NTV_ENUM_GROUPS returns event codes with a
			groups id for each group in which this
			native event lives, in bits 16 - 23 of event code
			terminating with PAPI_ENOEVNT at the end of the list.
*/

		  /* This is an IBM Power issue */
		  if ( flags.groups ) {
		     k = i;
		     if ( PAPI_enum_event( &k, PAPI_NTV_ENUM_GROUPS ) == PAPI_OK ) {
			printf( "Groups: " );
			do {
			  printf( "%4d", ( ( k & PAPI_NTV_GROUP_AND_MASK ) >>
					     PAPI_NTV_GROUP_SHIFT ) - 1 );
			} while ( PAPI_enum_event( &k, PAPI_NTV_ENUM_GROUPS ) ==PAPI_OK );
			printf( "\n" );
		     }
		  }

		  /* Print umasks */
		  /* components that don't have them can just ignore */

	          if ( flags.umask ) { 
		     k = i;
		     if ( PAPI_enum_event( &k, PAPI_NTV_ENUM_UMASKS ) == PAPI_OK ) {
		        do {
			   retval = PAPI_get_event_info( k, &info );
			   if ( retval == PAPI_OK ) {
			      if ( parse_unit_masks( &info ) )
			         print_event( &info, 2 );
			   }
		        } while ( PAPI_enum_event( &k, PAPI_NTV_ENUM_UMASKS ) == PAPI_OK );
		     }

		  }
		  printf( "--------------------------------------------------------------------------------\n" );

	       } while ( PAPI_enum_event( &i, enum_modifier ) == PAPI_OK );
	   }
Ejemplo n.º 6
0
int main()
{
    double *a;
    double *b;
    double *c;
    int i = 0, j = 0, k = 0;
    int *events;                        // Array of events
    long long *values;                  // Array of values events
    int EventSet = PAPI_NULL;           // Handle for a PAPI event set as created by PAPI_create_eventset (3) 
    int retval;                         // Test fail function
    int num_event = 0;                  // Number of events
    int max_event;                      // Number of available events
    int EventCode = 0;                  // Event code
    PAPI_event_info_t pset;             // PAPI_event_info_t Struct Reference
    char evname[PAPI_MAX_STR_LEN];      // Symbol event
   
    /* Memory asignament to matrixs*/   
    if((a = (double *)malloc(mrows * ncolumns * sizeof(double))) == NULL)
        printf("Error malloc matrix a[%d]\n",mrows * ncolumns);
    if((b = (double *)malloc(ncolumns * pcolumns * sizeof(double))) == NULL)
        printf("Error malloc matrix b[%d]\n",mrows * ncolumns);
    if((c = (double *)malloc(mrows * pcolumns * sizeof(double))) == NULL)
        printf("Error malloc matrix c[%d]\n",mrows * ncolumns);

    /* Initialize the Matrix arrays */
    initmat(a, b, mrows, ncolumns, pcolumns);

    /* Initialize the PAPI library */
    retval = PAPI_library_init(PAPI_VER_CURRENT);
    if (retval != PAPI_VER_CURRENT)
        test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );

    /* Enable and initialize multiplex support */
    retval = PAPI_multiplex_init();
    if ( retval != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI_multiplex_init", retval );
 
    /* Create an EventSet */
    retval = PAPI_create_eventset(&EventSet);
    if ( retval != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
 
    /* Assign it to the CPU component */
    retval = PAPI_assign_eventset_component(EventSet, 0);
    if ( retval != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI_assign_eventset_component", retval );
 
    /* Convert the EventSet to a multiplexed event set */
    retval = PAPI_set_multiplex(EventSet);
    if ( retval != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI_set_multiplex", retval );

    /* Obtaining the number of available events */
    max_event = PAPI_get_opt( PAPI_MAX_MPX_CTRS, NULL );
    printf("\nNumber of available events: %d", max_event );
 
    /* Fill up the event set with as many non-derived events as we can */
    EventCode = PAPI_PRESET_MASK;
    do {
        if ( PAPI_get_event_info( EventCode, &pset ) == PAPI_OK ) {
            if ( pset.count && ( strcmp( pset.derived, "NOT_DERIVED" ) == 0 ) ) {
                retval = PAPI_add_event( EventSet, ( int ) pset.event_code );
                if ( retval != PAPI_OK )
                    test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
                else {
                    //printf( "Added %s\n", pset.symbol );
                    num_event++;
                }
            }
        }
    } while ( ( PAPI_enum_event( &EventCode, PAPI_PRESET_ENUM_AVAIL ) == PAPI_OK ) && ( num_event < max_event ) );
    
    /* Memory asignament to values and events*/    
    events = ( int * ) malloc( ( size_t ) num_event * sizeof ( int ) );
    if ( events == NULL )
        test_fail( __FILE__, __LINE__, "Error malloc events", 0 );
    values = ( long long * ) malloc( ( size_t ) num_event * sizeof ( long long ) );
    if ( values == NULL )
        test_fail( __FILE__, __LINE__, "Erro malloc values", 0 );

    /* Start counting events */
    if ((retval=PAPI_start(EventSet)) != PAPI_OK)
        test_fail(__FILE__, __LINE__, "PAPI_start", retval);

    /* Matrix-Matrix multiply */
    matmul(a, b, c, mrows, ncolumns, pcolumns);

    /* Read the counters */
    if ((retval=PAPI_read( EventSet, values )) != PAPI_OK)
        test_fail(__FILE__, __LINE__, "PAPI_read_counters", retval);
   
    /* Stop counting events */
    if ((retval=PAPI_stop( EventSet, values )) != PAPI_OK)
        test_fail(__FILE__, __LINE__, "PAPI_stop_counters", retval);

    /* List the events in the event set */
    retval = PAPI_list_events( EventSet, events, &num_event );
    if ( retval != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI_list_events", retval );

    /* Print results */
    printf("\nNumber of non-zero events: %d\n", num_event );
    printf( "\nCounts of non-zero available events........................................................\n" );
    printf("Name: \t\t\t  Value: \t Description:\n");
    for ( i = 0; i < num_event; i++ ) {
        PAPI_event_code_to_name( events[i], evname );   // Obtaining name of available events
        PAPI_get_event_info(events[i], &pset);
        if ( values[i] != 0 )  printf("%s \t %15lld \t %s\n", evname, values[i], pset.long_descr);
    }
    printf( "\nCounts of zero available events............................................................\n" );
    printf("Name: \t\t\t  Value: \t Description:\n");
    for ( i = 0; i < num_event; i++ ) {
        PAPI_event_code_to_name( events[i], evname );   // Obtaining name of available events
        PAPI_get_event_info(events[i], &pset);
        if ( values[i] == 0 )  printf("%s \t %15lld \t %s\n", evname, values[i], pset.long_descr);
    }

    /* Check if counter pair(s) had identical values */
    for ( i = 0; i < num_event; i++ ) {
        for ( i = j+1; j < num_event; j++ ) {
            if ( ( i != j ) && ( values[i] == values[j] ) ) k++;  
        }
    }
    if ( k != 0 ) {
        printf( "\nCaution: %d counter pair(s) had identical values\n", k );
    }
    printf("\n");

    /* Free memory */
    free( events );
    free( values );
    free( a );
    free( b );
    free( c );

    /* Cleaning events */
    retval = PAPI_cleanup_eventset( EventSet );
    if ( retval != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval );
    
    /* Destroying events */
    retval = PAPI_destroy_eventset( &EventSet );
    if ( retval != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval );

    return 0;
}
Ejemplo n.º 7
0
int
native(  )
{
	int i, j, k;
	int retval, added;
	const PAPI_component_info_t *c = NULL;
	PAPI_event_info_t info;

	j = 0;
	c = PAPI_get_component_info( 0 );

	/* For platform independence, always ASK FOR the first event */
	/* Don't just assume it'll be the first numeric value */
	i = 0 | PAPI_NATIVE_MASK;
	PAPI_enum_event( &i, PAPI_ENUM_FIRST );

	do {
		/* If unit masks are supported, perfmon requires that at least one
		   mask bit be set before adding the event.
		 */
		if ( c->cntr_umasks ) {
			k = i;
			/* modifier = PAPI_NTV_ENUM_UMASKS returns an event code for each
			   unit mask bit defined for this native event. This can be used
			   to get event info for that mask bit. It terminates
			   with PAPI_ENOEVNT at the end of the list.
			 */
			if ( PAPI_enum_event( &k, PAPI_NTV_ENUM_UMASKS ) == PAPI_OK ) {
				if ( ( added = add_remove_event( EventSet, k ) ) == PAPI_OK ) {
					show_event_info( i );
					do {
						retval = PAPI_get_event_info( k, &info );
						if ( retval == PAPI_OK ) {
							printf( "    0x%-10x%s  |%s|\n", info.event_code,
									strchr( info.symbol, ':' ),
									strchr( info.long_descr, ':' ) + 1 );
						}
					} while ( PAPI_enum_event( &k, PAPI_NTV_ENUM_UMASKS ) ==
							  PAPI_OK );
					j++;
				}
			} else {
				if ( ( added = add_remove_event( EventSet, i ) ) == PAPI_OK ) {
					show_event_info( i );
					j++;
				}
			}
		} else {
			if ( ( added = add_remove_event( EventSet, i ) ) == PAPI_OK ) {
				show_event_info( i );
				j++;
			}
		}
		if ( added == PAPI_OK ) {
			/* modifier = PAPI_NTV_ENUM_GROUPS returns event codes with a
			   groups id for each group in which this
			   native event lives, in bits 16 - 23 of event code
			   terminating with PAPI_ENOEVNT at the end of the list.
			 */
			if ( c->cntr_groups ) {
				k = i;
				if ( PAPI_enum_event( &k, PAPI_NTV_ENUM_GROUPS ) == PAPI_OK ) {
					printf( "Groups: " );
					do {
						printf( "%4d",
								( ( k & PAPI_NTV_GROUP_AND_MASK ) >>
								  PAPI_NTV_GROUP_SHIFT ) - 1 );
					} while ( PAPI_enum_event( &k, PAPI_NTV_ENUM_GROUPS ) ==
							  PAPI_OK );
					printf( "\n" );
				}
			}
			printf
				( "-------------------------------------------------------------------------\n" );
		}
Ejemplo n.º 8
0
Archivo: papi.c Proyecto: DundalkIT/pcp
static int
papi_internal_init(pmdaInterface *dp)
{
    int ec;
    int sts;
    PAPI_event_info_t info;
    char entry[PAPI_HUGE_STR_LEN+12]; // the length papi uses for the symbol name
    unsigned int i = 0;
    pmID pmid;

    sts = sprintf(papi_version, "%d.%d.%d", PAPI_VERSION_MAJOR(PAPI_VERSION),
	    PAPI_VERSION_MINOR(PAPI_VERSION), PAPI_VERSION_REVISION(PAPI_VERSION));
    if (sts < 0) {
	__pmNotifyErr(LOG_ERR, "%s failed to create papi version metric.\n",pmProgname);
	return PM_ERR_GENERIC;
    }

    if ((sts = __pmNewPMNS(&papi_tree)) < 0) {
	__pmNotifyErr(LOG_ERR, "%s failed to create dynamic papi pmns: %s\n",
		      pmProgname, pmErrStr(sts));
	papi_tree = NULL;
	return PM_ERR_GENERIC;
    }

    number_of_counters = PAPI_num_counters();
    if (number_of_counters < 0) {
	__pmNotifyErr(LOG_ERR, "hardware does not support performance counters\n");
	return PM_ERR_APPVERSION;
    }
    else if (number_of_counters == 0) {
	__pmNotifyErr(LOG_WARNING, "no performance counters\n");
    }

    sts = PAPI_library_init(PAPI_VER_CURRENT);
    if (sts != PAPI_VER_CURRENT) {
	__pmNotifyErr(LOG_ERR, "PAPI_library_init error (%d)\n", sts);
	return PM_ERR_GENERIC;
    }

    ec = PAPI_PRESET_MASK;
    PAPI_enum_event(&ec, PAPI_ENUM_FIRST);
    do {
	if (PAPI_get_event_info(ec, &info) == PAPI_OK) {
	    if (info.count && PAPI_PRESET_ENUM_AVAIL) {
		expand_papi_info(i);
		memcpy(&papi_info[i].info, &info, sizeof(PAPI_event_info_t));
		memcpy(&papi_info[i].papi_string_code, info.symbol + 5, strlen(info.symbol)-5);
		snprintf(entry, sizeof(entry),"papi.system.%s", papi_info[i].papi_string_code);
		pmid = pmid_build(dp->domain, CLUSTER_PAPI, i);
		papi_info[i].pmid = pmid;
		__pmAddPMNSNode(papi_tree, pmid, entry);
		memset(&entry[0], 0, sizeof(entry));
		papi_info[i].position = -1;
		papi_info[i].metric_enabled = 0;
		expand_values(i);
		i++;
	    }
	}
    } while(PAPI_enum_event(&ec, 0) == PAPI_OK);

#if defined(HAVE_PAPI_DISABLED_COMP)
    char *tokenized_string;
    int number_of_components;
    int component_id;
    int native;

    number_of_components = PAPI_num_components();
    native = 0 | PAPI_NATIVE_MASK;
    for (component_id = 0; component_id < number_of_components; component_id++) {
	const PAPI_component_info_t *component;
	component = PAPI_get_component_info(component_id);
	if (component->disabled || (strcmp("perf_event", component->name)
				    && strcmp("perf_event_uncore", component->name)))
	    continue;
	sts = PAPI_enum_cmp_event (&native, PAPI_ENUM_FIRST, component_id);
	if (sts == PAPI_OK)
	do {
	    if (PAPI_get_event_info(native, &info) == PAPI_OK) {
		char local_native_metric_name[PAPI_HUGE_STR_LEN] = "";
		int was_tokenized = 0;
		expand_papi_info(i);
		memcpy(&papi_info[i].info, &info, sizeof(PAPI_event_info_t));
		tokenized_string = strtok(info.symbol, "::: -");
		while (tokenized_string != NULL) {
		    size_t remaining = sizeof(local_native_metric_name) -
			strlen(local_native_metric_name) - 1;
		    if (remaining < 1)
			break;
		    strncat(local_native_metric_name, tokenized_string, remaining);
		    was_tokenized = 1;
		    tokenized_string=strtok(NULL, "::: -");
		    if (tokenized_string) {
			remaining = sizeof(local_native_metric_name) -
			    strlen(local_native_metric_name) - 1;
			if (remaining < 1)
			    break;
			strncat(local_native_metric_name, ".", remaining);
		    }
		}
		if (!was_tokenized) {
		    strncpy(papi_info[i].papi_string_code, info.symbol,
			    sizeof(papi_info[i].papi_string_code) - 1);
		}
		else {
		    strncpy(papi_info[i].papi_string_code,
			    local_native_metric_name,
			    sizeof(papi_info[i].papi_string_code) - 1);
		}
		snprintf(entry, sizeof(entry),"papi.system.%s", papi_info[i].papi_string_code);
		pmid = pmid_build(dp->domain, CLUSTER_PAPI, i);
		papi_info[i].pmid = pmid;
		__pmAddPMNSNode(papi_tree, pmid, entry);
		memset(&entry[0], 0, sizeof(entry));
		papi_info[i].position = -1;
		papi_info[i].metric_enabled = 0;
		expand_values(i);
		i++;
	    }
	} while (PAPI_enum_cmp_event(&native, PAPI_ENUM_EVENTS, component_id) == PAPI_OK);
    }
#endif
    pmdaTreeRebuildHash(papi_tree, number_of_events);

    /* Set one-time settings for all future EventSets. */
    if ((sts = PAPI_set_domain(PAPI_DOM_ALL)) != PAPI_OK) {
	handle_papi_error(sts, 0);
	return PM_ERR_GENERIC;
    }
    if ((sts = PAPI_multiplex_init()) != PAPI_OK) {
	handle_papi_error(sts, 0);
	return PM_ERR_GENERIC;
    }

    sts = refresh_metrics(0);
    if (sts != PAPI_OK)
	return PM_ERR_GENERIC;
    return 0;
}
Ejemplo n.º 9
0
int main (int argc, char **argv)
{

        int retval,i;
	int EventSet = PAPI_NULL;
	long long values[NUM_EVENTS];
	const PAPI_component_info_t *cmpinfo = NULL;
	int numcmp,cid,example_cid=-1;
	int code,maximum_code=0;
	char event_name[PAPI_MAX_STR_LEN];
	PAPI_event_info_t event_info;

        /* Set TESTS_QUIET variable */
        tests_quiet( argc, argv );      

	/* PAPI Initialization */
	retval = PAPI_library_init( PAPI_VER_CURRENT );
	if ( retval != PAPI_VER_CURRENT ) {
	   test_fail(__FILE__, __LINE__,"PAPI_library_init failed\n",retval);
	}

	if (!TESTS_QUIET) {
	   printf( "Testing example component with PAPI %d.%d.%d\n",
			PAPI_VERSION_MAJOR( PAPI_VERSION ),
			PAPI_VERSION_MINOR( PAPI_VERSION ),
			PAPI_VERSION_REVISION( PAPI_VERSION ) );
	}

	/* Find our component */

	numcmp = PAPI_num_components();
	for( cid=0; cid<numcmp; cid++) {
	   if ( (cmpinfo = PAPI_get_component_info(cid)) == NULL) {
	      test_fail(__FILE__, __LINE__,
                           "PAPI_get_component_info failed\n", 0);
	   }
	   if (!TESTS_QUIET) {
	      printf("\tComponent %d - %d events - %s\n", cid, 
		     cmpinfo->num_native_events,
		     cmpinfo->name);
	   }
	   if (strstr(cmpinfo->name,"example.c")) {
	      /* FOUND! */
	      example_cid=cid;
	   }
	}
	

	if (example_cid<0) {
	   test_skip(__FILE__, __LINE__,
		     "Example component not found\n", 0);
	}

	if (!TESTS_QUIET) {
	  printf("\nFound Example Component at id %d\n",example_cid);
	  printf("\nListing all events in this component:\n");
	}

	/**************************************************/
	/* Listing all available events in this component */
	/* Along with descriptions                        */
	/**************************************************/
	code = PAPI_NATIVE_MASK | PAPI_COMPONENT_MASK(example_cid);

	retval = PAPI_enum_event( &code, PAPI_ENUM_FIRST );

	while ( retval == PAPI_OK ) {
	  if (PAPI_event_code_to_name( code, event_name )!=PAPI_OK) {
	     printf("Error translating %x\n",code);
	     test_fail( __FILE__, __LINE__, 
		       "PAPI_event_code_to_name", retval );
	  }

	  if (PAPI_get_event_info( code, &event_info)!=PAPI_OK) {
	     printf("Error getting info for event %x\n",code);
	     test_fail( __FILE__, __LINE__, 
		       "PAPI_get_event_info()", retval );
	  }

	  if (!TESTS_QUIET) {
	    printf("\tEvent 0x%x: %s -- %s\n",
		   code,event_name,event_info.long_descr);
	  }

	  maximum_code=code;

	  retval = PAPI_enum_event( &code, PAPI_ENUM_EVENTS );

	}
	if (!TESTS_QUIET) printf("\n");

	/**********************************/
	/* Try accessing an invalid event */
	/**********************************/
	
	retval=PAPI_event_code_to_name( maximum_code+10, event_name );
	if (retval!=PAPI_ENOEVNT) {
	   test_fail( __FILE__, __LINE__, 
		    "Failed to return PAPI_ENOEVNT on invalid event", retval );
	}

	/***********************************/
	/* Test the EXAMPLE_ZERO event     */
	/***********************************/

	retval = PAPI_create_eventset( &EventSet );
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__,
		      "PAPI_create_eventset() failed\n", retval );
	}

	retval = PAPI_event_name_to_code("EXAMPLE_ZERO", &code);
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__, 
		      "EXAMPLE_ZERO not found\n",retval );
	}

	retval = PAPI_add_event( EventSet, code);
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__,
		      "PAPI_add_events failed\n", retval );
	}

	retval = PAPI_start( EventSet );
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__, 
		      "PAPI_start failed\n",retval );
	}
	
	retval = PAPI_stop( EventSet, values );
	if ( retval != PAPI_OK ) {
	   test_fail(  __FILE__, __LINE__, "PAPI_stop failed\n", retval);
	}

	if (!TESTS_QUIET) printf("Testing EXAMPLE_ZERO: %lld\n",values[0]);

	if (values[0]!=0) {
	   test_fail(  __FILE__, __LINE__, "Result should be 0!\n", 0);
	}

	retval = PAPI_cleanup_eventset(EventSet);
	if (retval != PAPI_OK) {
	   test_fail(  __FILE__, __LINE__, "PAPI_cleanup_eventset!\n", retval);
	}

	retval = PAPI_destroy_eventset(&EventSet);
	if (retval != PAPI_OK) {
	   test_fail(  __FILE__, __LINE__, "PAPI_destroy_eventset!\n", retval);
	}

	EventSet=PAPI_NULL;


	/***********************************/
	/* Test the EXAMPLE_CONSTANT event */
	/***********************************/

	retval = PAPI_create_eventset( &EventSet );
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__,
		      "PAPI_create_eventset() failed\n", retval );
	}

	retval = PAPI_event_name_to_code("EXAMPLE_CONSTANT", &code);
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__, 
		      "EXAMPLE_CONSTANT not found\n",retval );
	}

	retval = PAPI_add_event( EventSet, code);
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__,
		      "PAPI_add_events failed\n", retval );
	}

	retval = PAPI_start( EventSet );
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__, 
		      "PAPI_start failed\n",retval );
	}
	
	retval = PAPI_stop( EventSet, values );
	if ( retval != PAPI_OK ) {
	   test_fail(  __FILE__, __LINE__, "PAPI_stop failed\n", retval);
	}

	if (!TESTS_QUIET) printf("Testing EXAMPLE_CONSTANT: %lld\n",values[0]);

	if (values[0]!=42) {
	   test_fail(  __FILE__, __LINE__, "Result should be 42!\n", 0);
	}

	retval = PAPI_cleanup_eventset(EventSet);
	if (retval != PAPI_OK) {
	   test_fail(  __FILE__, __LINE__, "PAPI_cleanup_eventset!\n", retval);
	}

	retval = PAPI_destroy_eventset(&EventSet);
	if (retval != PAPI_OK) {
	   test_fail(  __FILE__, __LINE__, "PAPI_destroy_eventset!\n", retval);
	}

	EventSet=PAPI_NULL;



	/***********************************/
	/* Test the EXAMPLE_AUTOINC event  */
	/***********************************/

	retval = PAPI_create_eventset( &EventSet );
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__,
		      "PAPI_create_eventset() failed\n", retval );
	}

	retval = PAPI_event_name_to_code("EXAMPLE_AUTOINC", &code);
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__, 
		      "EXAMPLE_AUTOINC not found\n",retval );
	}

	retval = PAPI_add_event( EventSet, code);
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__,
		      "PAPI_add_events failed\n", retval );
	}

	if (!TESTS_QUIET) printf("Testing EXAMPLE_AUTOINC: ");

	for(i=0;i<10;i++) {

	   retval = PAPI_start( EventSet );
	   if ( retval != PAPI_OK ) {
	      test_fail( __FILE__, __LINE__, 
		      "PAPI_start failed\n",retval );
	   }
	
	   retval = PAPI_stop( EventSet, values );
	   if ( retval != PAPI_OK ) {
	      test_fail(  __FILE__, __LINE__, "PAPI_stop failed\n", retval);
	   }

	   if (!TESTS_QUIET) printf("%lld ",values[0]);

	   if (values[0]!=i) {
	      test_fail(  __FILE__, __LINE__, "Result wrong!\n", 0);
	   }
	}

	if (!TESTS_QUIET) printf("\n");


	/***********************************/
	/* Test multiple reads             */
        /***********************************/
   
	retval = PAPI_start( EventSet );
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__, 
		      "PAPI_start failed\n",retval );
	}

	for(i=0;i<10;i++) {

	  retval=PAPI_read( EventSet, values);
	  if ( retval != PAPI_OK ) {
	     test_fail(  __FILE__, __LINE__, "PAPI_read failed\n", retval);
	  }
	  if (!TESTS_QUIET) printf("%lld ",values[0]);
	}
	
	retval = PAPI_stop( EventSet, values );
	if ( retval != PAPI_OK ) {
	   test_fail(  __FILE__, __LINE__, "PAPI_stop failed\n", retval);
	}
	if (!TESTS_QUIET) printf("%lld\n",values[0]);

	//	if (values[0]!=i) {
	//   test_fail(  __FILE__, __LINE__, "Result wrong!\n", 0);
	//}

	/***********************************/
	/* Test PAPI_reset()               */
	/***********************************/

	retval = PAPI_reset( EventSet);
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__, 
		      "PAPI_reset() failed\n",retval );
	}

	retval = PAPI_start( EventSet );
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__, 
		      "PAPI_start failed\n",retval );
	}
	
	retval = PAPI_reset( EventSet);
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__, 
		      "PAPI_reset() failed\n",retval );
	}

	retval = PAPI_stop( EventSet, values );
	if ( retval != PAPI_OK ) {
	   test_fail(  __FILE__, __LINE__, "PAPI_stop failed\n", retval);
	}


	if (!TESTS_QUIET) printf("Testing EXAMPLE_AUTOINC after PAPI_reset(): %lld\n",
				 values[0]);

	if (values[0]!=0) {
	  	   test_fail(  __FILE__, __LINE__, "Result not zero!\n", 0);
	}

	retval = PAPI_cleanup_eventset(EventSet);
	if (retval != PAPI_OK) {
	   test_fail(  __FILE__, __LINE__, "PAPI_cleanup_eventset!\n", retval);
	}

	retval = PAPI_destroy_eventset(&EventSet);
	if (retval != PAPI_OK) {
	   test_fail(  __FILE__, __LINE__, "PAPI_destroy_eventset!\n", retval);
	}

	EventSet=PAPI_NULL;


	/***********************************/
	/* Test multiple events            */
	/***********************************/

   	if (!TESTS_QUIET) printf("Testing Multiple Events: ");
   
   	retval = PAPI_create_eventset( &EventSet );
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__,
		      "PAPI_create_eventset() failed\n", retval );
	}

	retval = PAPI_event_name_to_code("EXAMPLE_CONSTANT", &code);
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__, 
		      "EXAMPLE_CONSTANT not found\n",retval );
	}

	retval = PAPI_add_event( EventSet, code);
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__,
		      "PAPI_add_events failed\n", retval );
	}
   
   	retval = PAPI_event_name_to_code("EXAMPLE_GLOBAL_AUTOINC", &code);
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__, 
		      "EXAMPLE_GLOBAL_AUTOINC not found\n",retval );
	}

	retval = PAPI_add_event( EventSet, code);
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__,
		      "PAPI_add_events failed\n", retval );
	}
   
   	retval = PAPI_event_name_to_code("EXAMPLE_ZERO", &code);
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__, 
		      "EXAMPLE_ZERO not found\n",retval );
	}

	retval = PAPI_add_event( EventSet, code);
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__,
		      "PAPI_add_events failed\n", retval );
	}

   
	retval = PAPI_start( EventSet );
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__, 
		      "PAPI_start failed\n",retval );
	}
	
	retval = PAPI_stop( EventSet, values );
	if ( retval != PAPI_OK ) {
	   test_fail(  __FILE__, __LINE__, "PAPI_stop failed\n", retval);
	}
	   
        if (!TESTS_QUIET) {
           for(i=0;i<3;i++) {
              printf("%lld ",values[i]);
	   }
	   printf("\n");
	}

	if (values[0]!=42) {
	   test_fail(  __FILE__, __LINE__, "Result should be 42!\n", 0);
	}
   
   	if (values[2]!=0) {
	   test_fail(  __FILE__, __LINE__, "Result should be 0!\n", 0);
	}

	retval = PAPI_cleanup_eventset(EventSet);
	if (retval != PAPI_OK) {
	   test_fail(  __FILE__, __LINE__, "PAPI_cleanup_eventset!\n", retval);
	}

	retval = PAPI_destroy_eventset(&EventSet);
	if (retval != PAPI_OK) {
	   test_fail(  __FILE__, __LINE__, "PAPI_destroy_eventset!\n", retval);
	}

	EventSet=PAPI_NULL;
   
	/***********************************/
	/* Test writing to an event        */
	/***********************************/

   	if (!TESTS_QUIET) printf("Testing Write\n");
   
   	retval = PAPI_create_eventset( &EventSet );
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__,
		      "PAPI_create_eventset() failed\n", retval );
	}

	retval = PAPI_event_name_to_code("EXAMPLE_CONSTANT", &code);
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__, 
		      "EXAMPLE_CONSTANT not found\n",retval );
	}

	retval = PAPI_add_event( EventSet, code);
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__,
		      "PAPI_add_events failed\n", retval );
	}
   
   	retval = PAPI_event_name_to_code("EXAMPLE_GLOBAL_AUTOINC", &code);
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__, 
		      "EXAMPLE_GLOBAL_AUTOINC not found\n",retval );
	}

	retval = PAPI_add_event( EventSet, code);
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__,
		      "PAPI_add_events failed\n", retval );
	}
   
   	retval = PAPI_event_name_to_code("EXAMPLE_ZERO", &code);
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__, 
		      "EXAMPLE_ZERO not found\n",retval );
	}

	retval = PAPI_add_event( EventSet, code);
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__,
		      "PAPI_add_events failed\n", retval );
	}

   
	retval = PAPI_start( EventSet );
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__, 
		      "PAPI_start failed\n",retval );
	}

        retval = PAPI_read ( EventSet, values );
   	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__, 
		      "PAPI_read failed\n",retval );
	}
   
        if (!TESTS_QUIET) {
	   printf("Before values: ");
           for(i=0;i<3;i++) {
              printf("%lld ",values[i]);
	   }
	   printf("\n");
	}
   
        values[0]=100;
        values[1]=200;
        values[2]=300;
      
        retval = PAPI_write ( EventSet, values );
   	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__, 
		      "PAPI_write failed\n",retval );
	}
   
	retval = PAPI_stop( EventSet, values );
	if ( retval != PAPI_OK ) {
	   test_fail(  __FILE__, __LINE__, "PAPI_stop failed\n", retval);
	}
	   
        if (!TESTS_QUIET) {
	   printf("After values: ");
           for(i=0;i<3;i++) {
              printf("%lld ",values[i]);
	   }
	   printf("\n");
	}
   

	if (values[0]!=42) {
	   test_fail(  __FILE__, __LINE__, "Result should be 42!\n", 0);
	}
   
   	if (values[1]!=200) {
	   test_fail(  __FILE__, __LINE__, "Result should be 200!\n", 0);
	}
   
   	if (values[2]!=0) {
	   test_fail(  __FILE__, __LINE__, "Result should be 0!\n", 0);
	}

	retval = PAPI_cleanup_eventset(EventSet);
	if (retval != PAPI_OK) {
	   test_fail(  __FILE__, __LINE__, "PAPI_cleanup_eventset!\n", retval);
	}

	retval = PAPI_destroy_eventset(&EventSet);
	if (retval != PAPI_OK) {
	   test_fail(  __FILE__, __LINE__, "PAPI_destroy_eventset!\n", retval);
	}

	EventSet=PAPI_NULL;
   
   
        /************/
        /* All Done */
        /************/
   
	if (!TESTS_QUIET) printf("\n");

	test_pass( __FILE__, NULL, 0 );
		
	return 0;
}
Ejemplo n.º 10
0
SEXP papi_event_avail(SEXP which)
{
    SEXP val,name,desc;
    int i;
    int unpt;
    int num;
    const int which_num = NUM_EVENTS;
    SEXP ret;
    int papiret;
    int id;
    PAPI_event_info_t ev;
    char *namep;


    if(which_num>0 && TYPEOF(which)==STRSXP)
    {
        num=which_num;
        PROTECT(ret=allocVector(VECSXP,3));
        PROTECT(name=allocVector(STRSXP,num));
        PROTECT(val=allocVector(LGLSXP,num));
        PROTECT(desc=allocVector(STRSXP,num));
        for (i=0; i<num; i++)
        {
            namep=CHARPT(which,i);
            papiret=PAPI_event_name_to_code(namep,&id);
            if(papiret!=PAPI_OK)
            {
                unpt=i+3;
                UNPROTECT(unpt);
                return R_papi_error(PAPI_ENOEVNT); // Should we make a custom error?
            }

            /* TODO: find out what this returns */
            PAPI_get_event_info(id,&ev);

            LOGICAL(val)[i]=ev.count>0;
            SET_STRING_ELT(name, i, mkChar(namep));
            SET_STRING_ELT(desc, i, mkChar(ev.long_descr));
        }

        unpt=4;
    }
    else  /* Get all events */
    {
        i=num=0;
        id=0|PAPI_PRESET_MASK;
        PAPI_enum_event(&id,PAPI_ENUM_FIRST);

        do
        {
            num++;
        }
        while(PAPI_enum_event(&id,PAPI_ENUM_EVENTS)==PAPI_OK);  // PAPI_PRESET_ENUM_AVAIL might also be useful

        PROTECT(ret=allocVector(VECSXP,3));
        PROTECT(name=allocVector(STRSXP,num));
        PROTECT(val=allocVector(LGLSXP,num));
        PROTECT(desc=allocVector(STRSXP,num));

        id=0|PAPI_PRESET_MASK;
        PAPI_enum_event(&id,PAPI_ENUM_FIRST);

        do
        {
            PAPI_get_event_info(id,&ev);

            LOGICAL(val)[i]=ev.count>0;
            SET_STRING_ELT(name, i, mkChar(ev.symbol));
            SET_STRING_ELT(desc, i, mkChar(ev.long_descr));

            i++;
        }
        while(PAPI_enum_event(&id,PAPI_ENUM_EVENTS)==PAPI_OK);  // PAPI_PRESET_ENUM_AVAIL might also be useful

        unpt=4;
    }

    SET_VECTOR_ELT(ret,0,name);
    SET_VECTOR_ELT(ret,1,val);
    SET_VECTOR_ELT(ret,2,desc);

    UNPROTECT(unpt);

    return ret;
}
Ejemplo n.º 11
0
/* add native events to use all counters */
int
enum_add_native_events( int *num_events, int **evtcodes, 
			int need_interrupt, int no_software_events )
{
	/* query and set up the right event to monitor */
     int EventSet = PAPI_NULL;
     int i = 0, k, event_code, retval;
     int counters, event_found = 0;
     PAPI_event_info_t info;
     const PAPI_component_info_t *s = NULL;
     const PAPI_hw_info_t *hw_info = NULL;
   
     s = PAPI_get_component_info( 0 );
     if ( s == NULL ) {
	test_fail( __FILE__, __LINE__, 
			   "PAPI_get_component_info", PAPI_ESBSTR );
     }

     hw_info = PAPI_get_hardware_info(  );
     if ( hw_info == NULL ) {
        test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
     }
   
     counters = PAPI_num_hwctrs(  );
     if (counters<1) {
	test_fail(__FILE__,__LINE__, "No counters available!\n",1);
     }

     if (!TESTS_QUIET) printf("Trying to fill %d hardware counters...\n",
			      counters);
   
     if (need_interrupt) {
        if ( (!strcmp(hw_info->model_string,"POWER6")) ||
	     (!strcmp(hw_info->model_string,"POWER5")) ) {
	   
	   test_warn(__FILE__, __LINE__,
		    "Limiting num_counters because of LIMITED_PMC on Power5 and Power6",1);
           counters=4;
	}
     }

     ( *evtcodes ) = ( int * ) calloc( counters, sizeof ( int ) );

     retval = PAPI_create_eventset( &EventSet );
     if ( retval != PAPI_OK ) {
	test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
     }

     /* For platform independence, always ASK FOR the first event */
     /* Don't just assume it'll be the first numeric value */
     i = 0 | PAPI_NATIVE_MASK;
     PAPI_enum_event( &i, PAPI_ENUM_FIRST );

     do {
        retval = PAPI_get_event_info( i, &info );

	/* HACK! FIXME */
        if (no_software_events && ( strstr(info.symbol,"PERF_COUNT_SW") || strstr(info.long_descr, "PERF_COUNT_SW") ) ) {
	   if (!TESTS_QUIET) {
	      printf("Blocking event %s as a SW event\n", info.symbol);
	   }
	   continue;
	}

	if ( s->cntr_umasks ) {
	   k = i;
			
	   if ( PAPI_enum_event( &k, PAPI_NTV_ENUM_UMASKS ) == PAPI_OK ) {
	      do {
	         retval = PAPI_get_event_info( k, &info );
		 event_code = ( int ) info.event_code;

		 retval = PAPI_add_event( EventSet, event_code );
		 if ( retval == PAPI_OK ) {
		    ( *evtcodes )[event_found] = event_code;
		    if ( !TESTS_QUIET ) {
		       printf( "event_code[%d] = 0x%x (%s)\n",
			       event_found, event_code, info.symbol );
		    }
		    event_found++;
		 } else {
		    if ( !TESTS_QUIET ) {
		       printf( "0x%x (%s) can't be added to the EventSet.\n",
			       event_code, info.symbol );
		    }
		 }
	      } while ( PAPI_enum_event( &k, PAPI_NTV_ENUM_UMASKS ) == PAPI_OK
						&& event_found < counters );
	   } else {
	      event_code = ( int ) info.event_code;
	      retval = PAPI_add_event( EventSet, event_code );
	      if ( retval == PAPI_OK ) {
		  ( *evtcodes )[event_found] = event_code;
		  if ( !TESTS_QUIET ) {
		     printf( "event_code[%d] = 0x%x (%s)\n",
			       event_found, event_code, info.symbol );
		  }
		  event_found++;
	      }
	   }
	   if ( !TESTS_QUIET && retval == PAPI_OK ) {
	     /* */
	   }
	} else {
			event_code = ( int ) info.event_code;
			retval = PAPI_add_event( EventSet, event_code );
			if ( retval == PAPI_OK ) {
				( *evtcodes )[event_found] = event_code;
				event_found++;
			} else {
				if ( !TESTS_QUIET )
					fprintf( stdout, "0x%x is not available.\n", event_code );
			}
		}
	}
	while ( PAPI_enum_event( &i, PAPI_ENUM_EVENTS ) == PAPI_OK &&
			event_found < counters );

	*num_events = ( int ) event_found;

	if (!TESTS_QUIET) printf("Tried to fill %d counters with events, "
				 "found %d\n",counters,event_found);

	return EventSet;
}
Ejemplo n.º 12
0
int case1(void)
{
	int retval, i, EventSet = PAPI_NULL, j = 0, k = 0, allvalid = 1;
	int max_mux, nev, *events;
	long long *values;
	PAPI_event_info_t pset;
	char evname[PAPI_MAX_STR_LEN];

	init_papi();
	init_multiplex();

	retval = PAPI_create_eventset(&EventSet);
	if (retval != PAPI_OK)
		test_fail(__FILE__, __LINE__, "PAPI_create_eventset", retval);

	/* In Component PAPI, EventSets must be assigned a component index
		before you can fiddle with their internals.
		0 is always the cpu component */
	retval = PAPI_assign_eventset_component(EventSet, 0);
	if (retval != PAPI_OK)
		test_fail(__FILE__, __LINE__, "PAPI_assign_eventset_component", retval);

	retval = PAPI_set_multiplex(EventSet);
	if (retval != PAPI_OK)
		test_fail(__FILE__, __LINE__, "PAPI_set_multiplex", retval);

	max_mux = PAPI_get_opt(PAPI_MAX_MPX_CTRS, NULL);
	if (max_mux > 32) max_mux = 32;

	/* Fill up the event set with as many non-derived events as we can */
	printf("\nFilling the event set with as many non-derived events as we can...\n");

	i = PAPI_PRESET_MASK;
	do {
		if (PAPI_get_event_info(i, &pset) == PAPI_OK) 
		{
			if (pset.count && (strcmp(pset.derived,"NOT_DERIVED") == 0))
			{
				retval = PAPI_add_event(EventSet, pset.event_code);
				if (retval != PAPI_OK)
					test_fail(__FILE__, __LINE__, "PAPI_add_event", retval);
				else
				{
					printf("Added %s\n", pset.symbol);
					j++;
				}
			}
		}
	} while ((PAPI_enum_event(&i, PAPI_PRESET_ENUM_AVAIL) == PAPI_OK) && (j < max_mux));

	events = (int *) malloc(j * sizeof(int));
	if (events == NULL)
		test_fail(__FILE__, __LINE__, "malloc events", 0);

	values = (long long *) malloc(j * sizeof(long long));
	if (values == NULL)
		test_fail(__FILE__, __LINE__, "malloc values", 0);

	do_stuff();

	if (PAPI_start(EventSet) != PAPI_OK)
		test_fail(__FILE__, __LINE__, "PAPI_start", retval);

	do_stuff();

	retval = PAPI_stop(EventSet, values);
	if (retval != PAPI_OK)
		test_fail(__FILE__, __LINE__, "PAPI_stop", retval);

	nev =j;
	retval = PAPI_list_events(EventSet, events, &nev);
	if (retval != PAPI_OK)
		test_fail(__FILE__, __LINE__, "PAPI_list_events", retval);

	printf("\nEvent Counts:\n");
	for (i = 0, allvalid = 0; i < j; i++) {
		PAPI_event_code_to_name(events[i], evname);
		printf(TAB1, evname, values[i]);
		if (values[i] == 0)
			allvalid++;
	}
	printf("\n");
	if (allvalid){
		printf("Caution: %d counters had zero values\n", allvalid);
	}

	for (i = 0, allvalid = 0; i < j; i++) {
		for (k = i+1; k < j; k++) {
			if ((i != k) && (values[i] == values[k]))
			{
				allvalid++;
				break;
			}
		}
	}

	if (allvalid){
		printf("Caution: %d counter pair(s) had identical values\n", allvalid);
	}

	free(events);
	free(values);

	retval = PAPI_cleanup_eventset(EventSet);
	if (retval != PAPI_OK)
		test_fail(__FILE__, __LINE__, "PAPI_cleanup_eventset", retval);

	retval = PAPI_destroy_eventset(&EventSet);
	if (retval != PAPI_OK)
		test_fail(__FILE__, __LINE__, "PAPI_destroy_eventset", retval);

	return (SUCCESS);
}
Ejemplo n.º 13
0
int
main( int argc, char **argv )
{
	int i, k, add_count = 0, err_count = 0, 
            unc_count = 0, offcore_count = 0;
	int retval;
	PAPI_event_info_t info, info1;
	const PAPI_hw_info_t *hwinfo = NULL;
	char *Intel_i7;
	int event_code;
	const PAPI_component_info_t *s = NULL;
	int numcmp, cid;

	tests_quiet( argc, argv );	/* Set TESTS_QUIET variable */

	retval = PAPI_library_init( PAPI_VER_CURRENT );
	if ( retval != PAPI_VER_CURRENT ) {
	   test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
	}

	retval = papi_print_header( "Test case ALL_NATIVE_EVENTS: Available "
				    "native events and hardware "
				    "information.\n",
				    0, &hwinfo );
	if ( retval != PAPI_OK ) {
	   test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
	}

	numcmp = PAPI_num_components(  );

	/* we need a little exception processing if it's a Core i7 */
	/* Unfortunately, this test never succeeds... */
	Intel_i7 = strstr( hwinfo->model_string, "Intel Core i7" );

	for ( cid = 0; cid < numcmp; cid++ ) {

		if ( ( s = PAPI_get_component_info( cid ) ) == NULL )
			test_fail( __FILE__, __LINE__, "PAPI_get_substrate_info", 2 );

		/* For platform independence, always ASK FOR the first event */
		/* Don't just assume it'll be the first numeric value */
		i = 0 | PAPI_NATIVE_MASK | PAPI_COMPONENT_MASK( cid );
		PAPI_enum_event( &i, PAPI_ENUM_FIRST );

		do {
			retval = PAPI_get_event_info( i, &info );
			if ( Intel_i7 || ( hwinfo->vendor == PAPI_VENDOR_INTEL ) ) {
				if ( !strncmp( info.symbol, "UNC_", 4 ) ) {
					unc_count++;
					continue;
				}
				if ( !strncmp( info.symbol, "OFFCORE_RESPONSE_0", 18 ) ) {
				        offcore_count++;
					continue;
				}
			}
			if ( s->cntr_umasks ) {
				k = i;
				if ( PAPI_enum_event( &k, PAPI_NTV_ENUM_UMASKS ) == PAPI_OK ) {
					do {
						retval = PAPI_get_event_info( k, &info1 );
						event_code = ( int ) info1.event_code;
						if ( check_event
							 ( event_code, info1.symbol ) )
							add_count++;
						else
							err_count++;
					} while ( PAPI_enum_event( &k, PAPI_NTV_ENUM_UMASKS ) ==
							  PAPI_OK );
				} else {
					event_code = ( int ) info.event_code;
					if ( check_event( event_code, info.symbol ) )
						add_count++;
					else
						err_count++;
				}
			} else {
				event_code = ( int ) info.event_code;
				if ( s->cntr_groups )
					event_code &= ~PAPI_NTV_GROUP_AND_MASK;
				if ( check_event( event_code, info.symbol ) )
					add_count++;
				else
					err_count++;
			}
		} while ( PAPI_enum_event( &i, PAPI_ENUM_EVENTS ) == PAPI_OK );

	}
	printf( "\n\nSuccessfully found and added %d events (in %d eventsets).\n",
			add_count , add_count);
	if ( err_count )
		printf( "Failed to add %d events.\n", err_count );
	if (( unc_count ) || (offcore_count)) {
	   char warning[BUFSIZ];
	   sprintf(warning,"%d Uncore and %d Offcore events were ignored",
		   unc_count,offcore_count);
	   test_warn( __FILE__, __LINE__, warning, 1 );
	}
	if ( add_count > 0 )
		test_pass( __FILE__, NULL, 0 );
	else
		test_fail( __FILE__, __LINE__, "No events added", 1 );
	exit( 1 );
}
Ejemplo n.º 14
0
int main(int argc, char **argv) {

    int retval,max_multiplex,i,EventSet=PAPI_NULL;
    PAPI_event_info_t info;
    int added=0;
    int events_tried=0;

    /* Set TESTS_QUIET variable */
    tests_quiet( argc, argv );

    /* Initialize the library */
    retval = PAPI_library_init( PAPI_VER_CURRENT );
    if ( retval != PAPI_VER_CURRENT ) {
        test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
    }

    retval = PAPI_multiplex_init(  );
    if ( retval != PAPI_OK) {
        test_fail(__FILE__, __LINE__, "Multiplex not supported", 1);
    }

    max_multiplex=PAPI_get_opt( PAPI_MAX_MPX_CTRS, NULL );

    if (!TESTS_QUIET) {
        printf("Maximum multiplexed counters=%d\n",max_multiplex);
    }

    if (!TESTS_QUIET) {
        printf("Trying to multiplex as many as possible:\n");
    }

    retval = PAPI_create_eventset( &EventSet );
    if ( retval != PAPI_OK ) {
        test_fail(__FILE__, __LINE__, "PAPI_create_eventset", retval );
    }

    retval = PAPI_assign_eventset_component( EventSet, 0 );
    if ( retval != PAPI_OK ) {
        test_fail(__FILE__, __LINE__, "PAPI_assign_eventset_component",
                  retval );
    }

    retval = PAPI_set_multiplex( EventSet );
    if ( retval != PAPI_OK ) {
        test_fail(__FILE__, __LINE__, "PAPI_create_multiplex", retval );
    }


    i = 0 | PAPI_PRESET_MASK;
    PAPI_enum_event( &i, PAPI_ENUM_FIRST );
    do {
        retval = PAPI_get_event_info( i, &info );
        if (retval==PAPI_OK) {
            if (!TESTS_QUIET) printf("Adding %s: ",info.symbol);
        }

        retval = PAPI_add_event( EventSet, info.event_code );
        if (retval!=PAPI_OK) {
            if (!TESTS_QUIET) printf("Fail!\n");
        }
        else {
            if (!TESTS_QUIET) printf("Success!\n");
            added++;
        }
        events_tried++;

    } while (PAPI_enum_event( &i, PAPI_PRESET_ENUM_AVAIL ) == PAPI_OK );

    PAPI_shutdown(  );

    if (!TESTS_QUIET) {
        printf("Added %d of theoretical max %d\n",added,max_multiplex);
    }

    if (events_tried<max_multiplex) {
        if (!TESTS_QUIET) {
            printf("Ran out of events before we ran out of room\n");
        }
    }
    else if (added!=max_multiplex) {
        test_fail(__FILE__, __LINE__,
                  "Couldn't max out multiplexed events", 1);
    }

    test_pass( __FILE__, NULL, 0 );
    exit( 0 );
}
Ejemplo n.º 15
0
int
main( int argc, char **argv )
{
	int retval;
	int code = PAPI_TOT_CYC, last;
	char event_name[PAPI_MAX_STR_LEN];
	const PAPI_hw_info_t *hwinfo = NULL;
	const PAPI_component_info_t *cmp_info;

	tests_quiet( argc, argv );	/* Set TESTS_QUIET variable */

	retval = PAPI_library_init( PAPI_VER_CURRENT );
	if ( retval != PAPI_VER_CURRENT )
		test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );

	retval =
		papi_print_header
		( "Test case code2name.c: Check limits and indexing of event tables.\n",
		  &hwinfo );
	if ( retval != PAPI_OK )
		test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );

	printf( "Looking for PAPI_TOT_CYC...\n" );
	retval = PAPI_event_code_to_name( code, event_name );
	if ( retval != PAPI_OK )
		test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
	printf( "Found |%s|\n", event_name );

	code = PAPI_FP_OPS;
	printf( "Looking for highest defined preset event (PAPI_FP_OPS): 0x%x...\n",
			code );
	retval = PAPI_event_code_to_name( code, event_name );
	if ( retval != PAPI_OK )
		test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
	printf( "Found |%s|\n", event_name );

	code = PAPI_PRESET_MASK | ( PAPI_MAX_PRESET_EVENTS - 1 );
	printf( "Looking for highest allocated preset event: 0x%x...\n", code );
	retval = PAPI_event_code_to_name( code, event_name );
	if ( retval != PAPI_OK )
		test_continue( "PAPI_event_code_to_name", retval );
	else
		printf( "Found |%s|\n", event_name );

	code = PAPI_PRESET_MASK | ( int ) PAPI_NATIVE_AND_MASK;
	printf( "Looking for highest possible preset event: 0x%x...\n", code );
	retval = PAPI_event_code_to_name( code, event_name );
	if ( retval != PAPI_OK )
		test_continue( "PAPI_event_code_to_name", retval );
	else
		printf( "Found |%s|\n", event_name );

	/* Find the first defined native event */
	/* For platform independence, always ASK FOR the first event */
	/* Don't just assume it'll be the first numeric value */
	code = PAPI_NATIVE_MASK;
	PAPI_enum_event( &code, PAPI_ENUM_FIRST );

	printf( "Looking for first native event: 0x%x...\n", code );
	retval = PAPI_event_code_to_name( code, event_name );
	if ( retval != PAPI_OK ) {
	  test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
	}
	else {
	  printf( "Found |%s|\n", event_name );
	}

	/* Find the last defined native event */
	cmp_info = PAPI_get_component_info( 0 );
	if ( cmp_info == NULL )
		test_fail( __FILE__, __LINE__, "PAPI_get_component_info", PAPI_ESBSTR );

	code = PAPI_NATIVE_MASK;
	PAPI_enum_event( &code, PAPI_ENUM_FIRST );

	while ( PAPI_enum_event( &code, PAPI_ENUM_EVENTS ) == PAPI_OK ) {
	  last=code;
	}

	code = last;
	printf( "Looking for last native event: 0x%x...\n", code );
	retval = PAPI_event_code_to_name( code, event_name );
	if ( retval != PAPI_OK ) {
		test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
	}
	else {
	   printf( "Found |%s|\n", event_name );
	}

	/* Highly doubtful we have this many natives */
	/* Turn on all bits *except* PRESET bit and COMPONENT bits */
	code = PAPI_PRESET_AND_MASK & PAPI_COMPONENT_AND_MASK;
	printf( "Looking for highest definable native event: 0x%x...\n", code );
	retval = PAPI_event_code_to_name( code, event_name );
	if ( retval != PAPI_OK )
		test_continue( "PAPI_event_code_to_name", retval );
	else
		printf( "Found |%s|\n", event_name );
	if ( ( retval == PAPI_ENOEVNT ) || ( retval == PAPI_OK ) )
		test_pass( __FILE__, 0, 0 );

	test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", PAPI_EBUG );

	exit( 1 );
}
Ejemplo n.º 16
0
int
main( int argc, char **argv )
{
	int nthreads = 8, ret, i;
	PAPI_event_info_t info;
	pthread_t *threads;
	const PAPI_hw_info_t *hw_info;

	tests_quiet( argc, argv );	/* Set TESTS_QUIET variable */

	if ( !TESTS_QUIET ) {
		if ( argc > 1 ) {
			int tmp = atoi( argv[1] );
			if ( tmp >= 1 )
				nthreads = tmp;
		}
	}

	ret = PAPI_library_init( PAPI_VER_CURRENT );
	if ( ret != PAPI_VER_CURRENT ) {
		test_fail( __FILE__, __LINE__, "PAPI_library_init", ret );
	}

	hw_info = PAPI_get_hardware_info(  );
	if ( hw_info == NULL )
		test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );

	if ( strcmp( hw_info->model_string, "POWER6" ) == 0 ) {
		ret = PAPI_set_domain( PAPI_DOM_ALL );
		if ( ret != PAPI_OK ) {
			test_fail( __FILE__, __LINE__, "PAPI_set_domain", ret );
		}
	}

	ret = PAPI_thread_init( ( unsigned long ( * )( void ) ) pthread_self );
	if ( ret != PAPI_OK ) {
		test_fail( __FILE__, __LINE__, "PAPI_thread_init", ret );
	}

	ret = PAPI_multiplex_init(  );
	if ( ret != PAPI_OK ) {
		test_fail( __FILE__, __LINE__, "PAPI_multiplex_init", ret );
	}

	/* Fill up the event set with as many non-derived events as we can */

	i = PAPI_PRESET_MASK;
	do {
		if ( PAPI_get_event_info( i, &info ) == PAPI_OK ) {
			if ( info.count == 1 ) {
				events[numevents++] = ( int ) info.event_code;
				printf( "Added %s\n", info.symbol );
			} else {
				printf( "Skipping derived event %s\n", info.symbol );
			}
		}
	} while ( ( PAPI_enum_event( &i, PAPI_PRESET_ENUM_AVAIL ) == PAPI_OK )
			  && ( numevents < PAPI_MPX_DEF_DEG ) );

	printf( "Found %d events\n", numevents );

	do_stuff(  );

	printf( "Creating %d threads:\n", nthreads );

	threads =
		( pthread_t * ) malloc( ( size_t ) nthreads * sizeof ( pthread_t ) );
	if ( threads == NULL ) {
		test_fail( __FILE__, __LINE__, "malloc", PAPI_ENOMEM );
	}

	/* Create the threads */
	for ( i = 0; i < nthreads; i++ ) {
		ret = pthread_create( &threads[i], NULL, thread, NULL );
		if ( ret != 0 ) {
			test_fail( __FILE__, __LINE__, "pthread_create", PAPI_ESYS );
		}
	}

	/* Wait for thread completion */
	for ( i = 0; i < nthreads; i++ ) {
		ret = pthread_join( threads[i], NULL );
		if ( ret != 0 ) {
			test_fail( __FILE__, __LINE__, "pthread_join", PAPI_ESYS );
		}
	}

	printf( "Done." );
	test_pass( __FILE__, NULL, 0 );
	pthread_exit( NULL );
	exit( 0 );
}
Ejemplo n.º 17
0
int main( int argc, char **argv ) {

  int i, k, num_umasks;
    int retval,rc;
    PAPI_event_info_t info;
    int numcmp, cid;
    int quiet;
    char test_string[]="Checking for event create race...";
    char *ptr;
    char temp_name[BUFSIZ];

    pthread_attr_t attr;
    pthread_t threads[NUM_THREADS];

    quiet=test_quiet();

	/* Initialize PAPI library */
    retval = PAPI_library_init( PAPI_VER_CURRENT );
    if ( retval != PAPI_VER_CURRENT ) {
       test_fail(test_string);
    }

    numcmp = PAPI_num_components(  );

    num_events = 0;

    for(cid=0; cid<numcmp; cid++ ) {
       i = 0 | PAPI_NATIVE_MASK;
       PAPI_enum_cmp_event( &i, PAPI_ENUM_FIRST, cid );

       do {
          memset( &info, 0, sizeof ( info ) );
	  retval = PAPI_get_event_info( i, &info );

	      /* This event may not exist */
	  if ( retval != PAPI_OK ) continue;

	      /* save the main event name */
	  strncpy(temp_name,info.symbol,BUFSIZ);

	      /* Handle umasks */
		
	  k = i;
	  num_umasks=0;
	  if ( PAPI_enum_event( &k, PAPI_NTV_ENUM_UMASKS ) == PAPI_OK ) {
	     do {
		retval = PAPI_get_event_info( k, &info );
		if ( retval == PAPI_OK ) {
		      /* handle libpfm4-style events which have a */
		      /* pmu::event type event name               */
                   if ((ptr=strstr(info.symbol, "::"))) {
                      ptr+=2;
		   }
                   else {
                      ptr=info.symbol;
		   }

                   if ( ( strchr( ptr, ':' ) ) == NULL ) {
		      /* shouldn't happen */
		      if (!quiet) printf("Weird umask!\n");
		      test_fail(test_string);
		   }
		   else {
		     //	      if (!quiet) printf("%s\n",info.symbol);
		      num_umasks++;
	              if (num_events<MAX_EVENTS) {
			 strncpy(event_names[num_events],info.symbol,BUFSIZ);
		      }
		      num_events++;
		   }
		}
	     } while ( PAPI_enum_event( &k,PAPI_NTV_ENUM_UMASKS) == PAPI_OK );
		  
	  }
	  if (num_umasks==0) {
	    //	     if (!quiet) printf("%s\n",temp_name);
	     if (num_events<MAX_EVENTS) {
	        strncpy(event_names[num_events],temp_name,BUFSIZ);
	     }
	     num_events++;
	  }

       } while ( PAPI_enum_event( &i, PAPI_ENUM_EVENTS ) == PAPI_OK );

    }

    if (!quiet) printf( "Total events reported: %d\n", num_events );
    if (num_events>MAX_EVENTS) num_events=MAX_EVENTS;


    /* shut down the library */
    PAPI_shutdown();
    
	/* Initialize PAPI library again */
    retval = PAPI_library_init( PAPI_VER_CURRENT );
    if ( retval != PAPI_VER_CURRENT ) {
       test_fail(test_string);
    }

    //    for(i=0;i<num_events;i++) {
    //  PAPI_event_name_to_code (event_names[i], &event_codes[i]);
    //}


    /* start some threads */


    retval = PAPI_thread_init( ( unsigned long ( * )( void ) ) 
			       ( pthread_self ) );

    pthread_attr_init( &attr );

    if (!quiet) printf("Starting threads...\n");

    for(i=0;i<NUM_THREADS;i++) {
      rc = pthread_create( &threads[i], &attr, our_thread, NULL);
      if ( rc ) {
         test_fail( test_string);
      }
    }


    pthread_attr_destroy( &attr );

    for(i=0;i<NUM_THREADS;i++) {
       pthread_join( threads[i], NULL );
    }

    if (!quiet) printf("Done with threads...\n");

    for(i=0;i<num_events;i++) {
      if (!quiet) printf("%x %s\n",event_codes[i],event_names[i]);
    }

    /* shut down the library again */
    PAPI_shutdown();

    test_pass(test_string);

    //    pthread_exit( NULL );


    return 0;

}