PAPI  5.4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
all_events.c
Go to the documentation of this file.
1 /* This file tries to add,start,stop all events in a component it
2  * is meant not to test the accuracy of the mapping but to make sure
3  * that all events in the component will at least start (Helps to
4  * catch typos.
5  *
6  * Author: Kevin London
7  * london@cs.utk.edu
8  */
9 #include "papi_test.h"
10 
11 int
12 main( int argc, char **argv )
13 {
14  int retval, i;
15  int EventSet = PAPI_NULL, count = 0, err_count = 0;
16  long long values;
17  PAPI_event_info_t info;
18 
19 
20  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
21 
23  if ( retval != PAPI_VER_CURRENT )
24  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
25 
26  retval = PAPI_create_eventset( &EventSet );
27  if ( retval != PAPI_OK )
28  test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
29 
30  for ( i = 0; i < PAPI_MAX_PRESET_EVENTS; i++ ) {
31  if ( PAPI_get_event_info( PAPI_PRESET_MASK | i, &info ) != PAPI_OK )
32  continue;
33  if ( !( info.count ) )
34  continue;
35  printf( "Adding %-14s", info.symbol );
36  retval = PAPI_add_event( EventSet, ( int ) info.event_code );
37  if ( retval != PAPI_OK ) {
38  PAPI_perror( "PAPI_add_event" );
39  err_count++;
40  } else {
41  retval = PAPI_start( EventSet );
42  if ( retval != PAPI_OK ) {
43  PAPI_perror( "PAPI_start" );
44  err_count++;
45  } else {
46  retval = PAPI_stop( EventSet, &values );
47  if ( retval != PAPI_OK ) {
48  PAPI_perror( "PAPI_stop" );
49  err_count++;
50  } else {
51  printf( "successful\n" );
52  count++;
53  }
54  }
55  retval = PAPI_remove_event( EventSet, ( int ) info.event_code );
56  if ( retval != PAPI_OK )
57  test_fail( __FILE__, __LINE__, "PAPI_remove_event", retval );
58  }
59  }
60  retval = PAPI_destroy_eventset( &EventSet );
61  if ( retval != PAPI_OK )
62  test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval );
63 
64  printf( "Successfully added, started and stopped %d events.\n", count );
65  if ( err_count )
66  printf( "Failed to add, start or stop %d events.\n", err_count );
67  if ( count > 0 )
68  test_pass( __FILE__, NULL, 0 );
69  else
70  test_fail( __FILE__, __LINE__, "No events added", 1 );
71  exit( 1 );
72 }
unsigned int count
Definition: papi.h:984
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2258
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1622
void PAPI_perror(char *msg)
Definition: papi.c:4579
int PAPI_remove_event(int EventSet, int EventCode)
Definition: papi.c:1717
#define PAPI_NULL
Definition: papi.h:290
int EventSet
Definition: data_range.c:25
#define PAPI_MAX_PRESET_EVENTS
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:963
return PAPI_OK
Definition: linux-nvml.c:458
int count
Definition: iozone.c:22422
tests_quiet(argc, argv)
#define PAPI_PRESET_MASK
#define printf
Definition: papi_test.h:125
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
Definition: papi.c:846
char ** argv
Definition: iozone.c:1610
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_library_init(int version)
Definition: papi.c:497
int i
Definition: fileop.c:140
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1424
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:1971
int PAPI_start(int EventSet)
Definition: papi.c:2053
unsigned int event_code
Definition: papi.h:961
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
#define PAPI_VER_CURRENT
Definition: papi.h:223
int main(int argc, char **argv)
List all appio events codes and names.
void exit()