PAPI 7.1.0.0
Loading...
Searching...
No Matches
all_events.c File Reference
Include dependency graph for all_events.c:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 17 of file all_events.c.

18{
19 int retval, i;
20 int EventSet = PAPI_NULL, count = 0, err_count = 0;
21 long long values;
23 int quiet=0;
24 char error_message[BUFSIZ];
25
26 /* Set TESTS_QUIET variable */
27 quiet=tests_quiet( argc, argv );
28
29 if (!quiet) {
30 printf("\nTrying all pre-defined events:\n");
31 }
32
33 /* Initialize PAPI */
35 if ( retval != PAPI_VER_CURRENT ) {
36 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
37 }
38
39 /* Create an EventSet */
41 if ( retval != PAPI_OK ) {
42 test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
43 }
44
45 /* Add all preset events */
46 for ( i = 0; i < PAPI_MAX_PRESET_EVENTS; i++ ) {
47
48 if ( PAPI_get_event_info( PAPI_PRESET_MASK | i, &info ) != PAPI_OK )
49 continue;
50
51 if ( !( info.count ) )
52 continue;
53
54 if (!quiet) printf( "Adding %-14s", info.symbol );
55
56 retval = PAPI_add_event( EventSet, ( int ) info.event_code );
57 if ( retval != PAPI_OK ) {
58 if (!quiet) {
59 printf("Error adding event %s\n",info.symbol);
60 if (retval==PAPI_ECNFLCT) {
61 printf("Probably NMI watchdog related\n");
62 }
63 }
64 if (retval==PAPI_ECNFLCT) {
65 sprintf(error_message,"Problem adding %s (probably NMI Watchdog related)",info.symbol);
66 }
67 else {
68 sprintf(error_message,"Problem adding %s",info.symbol);
69 }
70 test_warn( __FILE__, __LINE__, error_message, retval );
71 err_count++;
72 } else {
74 if ( retval != PAPI_OK ) {
75 PAPI_perror( "PAPI_start" );
76 err_count++;
77 } else {
79 if ( retval != PAPI_OK ) {
80 PAPI_perror( "PAPI_stop" );
81 err_count++;
82 } else {
83 if (!quiet) printf( "successful\n" );
84 count++;
85 }
86 }
88 if ( retval != PAPI_OK )
89 test_fail( __FILE__, __LINE__, "PAPI_remove_event", retval );
90 }
91 }
93 if ( retval != PAPI_OK )
94 test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval );
95
96 if (!quiet) {
97 printf( "Successfully added, started and stopped %d events.\n", count );
98 }
99
100 if ( err_count ) {
101 if (!quiet) printf( "Failed to add, start or stop %d events.\n", err_count );
102 }
103
104 if (count<=0) {
105 test_fail( __FILE__, __LINE__, "No events added", 1 );
106 }
107
108 test_pass( __FILE__ );
109
110 return 0;
111
112}
int i
static long count
add PAPI preset or native hardware event to an event set
Create a new empty PAPI EventSet.
Empty and destroy an EventSet.
Get the event's name and description info.
initialize the PAPI library.
Produces a string on standard error, describing the last library error.
removes a hardware event from a PAPI event set.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_NULL
Definition: f90papi.h:78
#define PAPI_ECNFLCT
Definition: f90papi.h:234
static int EventSet
Definition: init_fini.c:8
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
#define PAPI_PRESET_MASK
#define PAPI_MAX_PRESET_EVENTS
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:491
void PAPI_NORETURN test_pass(const char *filename)
Definition: test_utils.c:432
void test_warn(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:547
int quiet
Definition: rapl_overflow.c:19
unsigned int count
Definition: papi.h:981
unsigned int event_code
Definition: papi.h:958
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:960
int retval
Definition: zero_fork.c:53
Here is the call graph for this function: