PAPI  5.7.0.0
PAPI_state.c
Go to the documentation of this file.
1 /*****************************************************************************
2  * We use PAPI_state to get the counting state of an EventSet.This function *
3  * returns the state of the entire EventSet. *
4  *****************************************************************************/
5 
6 
7 
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include "papi.h" /* This needs to be included every time you use PAPI */
11 
12 #define ERROR_RETURN(retval) { fprintf(stderr, "Error %d %s:line %d: \n", retval,__FILE__,__LINE__); exit(retval); }
13 
14 
15 int main()
16 {
17 
18  int retval;
19  int status = 0;
20  int EventSet = PAPI_NULL;
21 
22  /****************************************************************************
23  * This part initializes the library and compares the version number of the *
24  * header file, to the version of the library, if these don't match then it *
25  * is likely that PAPI won't work correctly.If there is an error, retval *
26  * keeps track of the version number. *
27  ****************************************************************************/
28 
30  {
31  printf("Library initialization error! \n");
32  exit(-1);
33  }
34 
35  /*Creating the Eventset */
38 
39  /* Add Total Instructions Executed to our EventSet */
42 
45 
47 
48  /* Start counting */
51 
54 
56 
57  /* free the resources used by PAPI */
58  PAPI_shutdown();
59 
60  exit(0);
61 }
62 
64 {
65  if(status & PAPI_STOPPED)
66  printf("Eventset is currently stopped or inactive \n");
67  if(status & PAPI_RUNNING)
68  printf("Eventset is currently running \n");
69  if(status & PAPI_PAUSED)
70  printf("Eventset is currently Paused \n");
71  if(status & PAPI_NOT_INIT)
72  printf(" Eventset defined but not initialized \n");
74  printf(" Eventset has overflowing enabled \n");
76  printf(" Eventset has profiling enabled \n");
78  printf(" Eventset has multiplexing enabled \n");
79  return 0;
80 }
#define PAPI_OK
Definition: fpapi.h:105
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1663
#define PAPI_NOT_INIT
Definition: fpapi.h:32
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
int EventSet
int retval
Definition: zero_fork.c:53
int printstate(int status)
Definition: PAPI_state.c:63
Return codes and api definitions.
#define PAPI_RUNNING
Definition: fpapi.h:30
int PAPI_library_init(int version)
Definition: papi.c:500
#define PAPI_TOT_INS
Definition: fpapi.h:186
void PAPI_shutdown(void)
Definition: papi.c:4461
int PAPI_state(int EventSet, int *status)
Definition: papi.c:3053
#define PAPI_MULTIPLEXING
Definition: fpapi.h:35
#define PAPI_NULL
Definition: fpapi.h:13
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1464
#define PAPI_STOPPED
Definition: fpapi.h:29
long long status
Definition: iozone.c:1335
#define ERROR_RETURN(retval)
Definition: PAPI_state.c:12
#define PAPI_OVERFLOWING
Definition: fpapi.h:33
int PAPI_start(int EventSet)
Definition: papi.c:2096
void exit()
#define PAPI_PROFILING
Definition: fpapi.h:34
int main()
Definition: PAPI_state.c:15
#define PAPI_PAUSED
Definition: fpapi.h:31