|
Packit |
577717 |
/* This file tries to add,start,stop, and remove all pre-defined events.
|
|
Packit |
577717 |
* It is meant not to test the accuracy of the mapping but to make sure
|
|
Packit |
577717 |
* that all events in the component will at least start (Helps to
|
|
Packit |
577717 |
* catch typos).
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* Author: Kevin London
|
|
Packit |
577717 |
* london@cs.utk.edu
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#include <stdio.h>
|
|
Packit |
577717 |
#include <stdlib.h>
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#include "papi.h"
|
|
Packit |
577717 |
#include "papi_test.h"
|
|
Packit |
577717 |
|
|
Packit |
577717 |
int
|
|
Packit |
577717 |
main( int argc, char **argv )
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
int retval, i;
|
|
Packit |
577717 |
int EventSet = PAPI_NULL, count = 0, err_count = 0;
|
|
Packit |
577717 |
long long values;
|
|
Packit |
577717 |
PAPI_event_info_t info;
|
|
Packit |
577717 |
int quiet=0;
|
|
Packit |
577717 |
char error_message[BUFSIZ];
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Set TESTS_QUIET variable */
|
|
Packit |
577717 |
quiet=tests_quiet( argc, argv );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (!quiet) {
|
|
Packit |
577717 |
printf("\nTrying all pre-defined events:\n");
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Initialize PAPI */
|
|
Packit |
577717 |
retval = PAPI_library_init( PAPI_VER_CURRENT );
|
|
Packit |
577717 |
if ( retval != PAPI_VER_CURRENT ) {
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Create an EventSet */
|
|
Packit |
577717 |
retval = PAPI_create_eventset( &EventSet );
|
|
Packit |
577717 |
if ( retval != PAPI_OK ) {
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Add all preset events */
|
|
Packit |
577717 |
for ( i = 0; i < PAPI_MAX_PRESET_EVENTS; i++ ) {
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if ( PAPI_get_event_info( PAPI_PRESET_MASK | i, &info ) != PAPI_OK )
|
|
Packit |
577717 |
continue;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if ( !( info.count ) )
|
|
Packit |
577717 |
continue;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (!quiet) printf( "Adding %-14s", info.symbol );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
retval = PAPI_add_event( EventSet, ( int ) info.event_code );
|
|
Packit |
577717 |
if ( retval != PAPI_OK ) {
|
|
Packit |
577717 |
if (!quiet) {
|
|
Packit |
577717 |
printf("Error adding event %s\n",info.symbol);
|
|
Packit |
577717 |
if (retval==PAPI_ECNFLCT) {
|
|
Packit |
577717 |
printf("Probably NMI watchdog related\n");
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
if (retval==PAPI_ECNFLCT) {
|
|
Packit |
577717 |
sprintf(error_message,"Problem adding %s (probably NMI Watchdog related)",info.symbol);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
else {
|
|
Packit |
577717 |
sprintf(error_message,"Problem adding %s",info.symbol);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
test_warn( __FILE__, __LINE__, error_message, retval );
|
|
Packit |
577717 |
err_count++;
|
|
Packit |
577717 |
} else {
|
|
Packit |
577717 |
retval = PAPI_start( EventSet );
|
|
Packit |
577717 |
if ( retval != PAPI_OK ) {
|
|
Packit |
577717 |
PAPI_perror( "PAPI_start" );
|
|
Packit |
577717 |
err_count++;
|
|
Packit |
577717 |
} else {
|
|
Packit |
577717 |
retval = PAPI_stop( EventSet, &values );
|
|
Packit |
577717 |
if ( retval != PAPI_OK ) {
|
|
Packit |
577717 |
PAPI_perror( "PAPI_stop" );
|
|
Packit |
577717 |
err_count++;
|
|
Packit |
577717 |
} else {
|
|
Packit |
577717 |
if (!quiet) printf( "successful\n" );
|
|
Packit |
577717 |
count++;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
retval = PAPI_remove_event( EventSet, ( int ) info.event_code );
|
|
Packit |
577717 |
if ( retval != PAPI_OK )
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_remove_event", retval );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
retval = PAPI_destroy_eventset( &EventSet );
|
|
Packit |
577717 |
if ( retval != PAPI_OK )
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (!quiet) {
|
|
Packit |
577717 |
printf( "Successfully added, started and stopped %d events.\n", count );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if ( err_count ) {
|
|
Packit |
577717 |
if (!quiet) printf( "Failed to add, start or stop %d events.\n", err_count );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (count<=0) {
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "No events added", 1 );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
test_pass( __FILE__ );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
return 0;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
}
|