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

Go to the source code of this file.

Macros

#define NUM_EVENTS   6
 

Functions

 __attribute__ ((constructor))
 
 __attribute__ ((destructor))
 

Variables

static int EventSet = PAPI_NULL
 
static const char * names [NUM_EVENTS] = {"READ_CALLS", "READ_BYTES","READ_USEC","WRITE_CALLS","WRITE_BYTES","WRITE_USEC"}
 
static long long values [NUM_EVENTS]
 

Macro Definition Documentation

◆ NUM_EVENTS

#define NUM_EVENTS   6

Definition at line 7 of file init_fini.c.

Function Documentation

◆ __attribute__() [1/2]

__attribute__ ( (constructor)  )

Definition at line 12 of file init_fini.c.

12 {
13 //fprintf(stderr, "appio: constructor started\n");
16 fprintf(stderr, "PAPI_library_init version mismatch\n");
17 exit(1);
18 }
19 else {
20 fprintf(stderr, "appio: PAPI library initialized\n");
21 }
22
23 /* Create the Event Set */
25 fprintf(stderr, "Error creating event set\n");
26 exit(2);
27 }
28
29 int retval;
30 int e;
31 int event_code;
32 for (e=0; e<NUM_EVENTS; e++) {
33 retval = PAPI_event_name_to_code((char*)names[e], &event_code);
34 if (retval != PAPI_OK) {
35 fprintf(stderr, "Error getting code for %s\n", names[e]);
36 exit(2);
37 }
38 retval = PAPI_add_event(EventSet, event_code);
39 if (retval != PAPI_OK) {
40 fprintf(stderr, "Error adding %s to event set\n", names[e]);
41 exit(2);
42 }
43 }
44
45 /* Start counting events */
46 fprintf(stderr, "appio: starting PAPI counters; main program will follow\n");
47 if (PAPI_start(EventSet) != PAPI_OK) {
48 fprintf(stderr, "Error in PAPI_start\n");
49 exit(1);
50 }
51 return;
52}
add PAPI preset or native hardware event to an event set
Create a new empty PAPI EventSet.
Convert a name to a numeric hardware event code.
initialize the PAPI library.
Start counting hardware events in an event set.
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_OK
Definition: f90papi.h:73
static const char * names[NUM_EVENTS]
Definition: init_fini.c:9
static int EventSet
Definition: init_fini.c:8
#define NUM_EVENTS
Definition: init_fini.c:7
uint8_t version
FILE * stderr
int retval
Definition: zero_fork.c:53

◆ __attribute__() [2/2]

__attribute__ ( (destructor)  )

Definition at line 54 of file init_fini.c.

54 {
55 int e;
56 //fprintf(stderr, "appio: destructor called\n");
58 fprintf(stderr, "Error in PAPI_stop_counters\n");
59 }
60 fprintf(stderr, "\nappio: PAPI counts (for pid=%6d)\n"
61 "appio: ----------------------------\n", (int)getpid());
62 for (e=0; e<NUM_EVENTS; e++)
63 fprintf(stderr, "appio: %s : %lld\n", names[e], values[e]);
64 return;
65}
Stop counting hardware events in an event set.
static long long values[NUM_EVENTS]
Definition: init_fini.c:10

Variable Documentation

◆ EventSet

int EventSet = PAPI_NULL
static

Definition at line 8 of file init_fini.c.

◆ names

const char* names[NUM_EVENTS] = {"READ_CALLS", "READ_BYTES","READ_USEC","WRITE_CALLS","WRITE_BYTES","WRITE_USEC"}
static

Definition at line 9 of file init_fini.c.

◆ values

long long values[NUM_EVENTS]
static

Definition at line 10 of file init_fini.c.