PAPI  5.4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
PAPI_state.c File Reference
Include dependency graph for PAPI_state.c:

Go to the source code of this file.

Macros

#define ERROR_RETURN(retval)   { fprintf(stderr, "Error %d %s:line %d: \n", retval,__FILE__,__LINE__); exit(retval); }
 

Functions

int main ()
 
int printstate (int status)
 

Macro Definition Documentation

#define ERROR_RETURN (   retval)    { fprintf(stderr, "Error %d %s:line %d: \n", retval,__FILE__,__LINE__); exit(retval); }

Definition at line 12 of file PAPI_state.c.

Function Documentation

int main ( )

Definition at line 15 of file PAPI_state.c.

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 */
36  if((retval = PAPI_create_eventset(&EventSet)) != PAPI_OK)
37  ERROR_RETURN(retval);
38 
39  /* Add Total Instructions Executed to our EventSet */
40  if ((retval=PAPI_add_event(EventSet, PAPI_TOT_INS)) != PAPI_OK)
41  ERROR_RETURN(retval);
42 
43  if ((retval=PAPI_state(EventSet, &status)) != PAPI_OK)
44  ERROR_RETURN(retval);
45 
46  printstate(status);
47 
48  /* Start counting */
49  if ((retval=PAPI_start(EventSet)) != PAPI_OK)
50  ERROR_RETURN(retval);
51 
52  if (PAPI_state(EventSet, &status) != PAPI_OK)
53  ERROR_RETURN(retval);
54 
55  printstate(status);
56 
57  /* free the resources used by PAPI */
58  PAPI_shutdown();
59 
60  exit(0);
61 }
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1622
#define PAPI_NULL
Definition: papi.h:290
int EventSet
Definition: data_range.c:25
#define PAPI_TOT_INS
return PAPI_OK
Definition: linux-nvml.c:458
int printstate(int status)
Definition: PAPI_state.c:63
#define printf
Definition: papi_test.h:125
int PAPI_library_init(int version)
Definition: papi.c:497
void PAPI_shutdown(void)
Definition: papi.c:4400
int PAPI_state(int EventSet, int *status)
Definition: papi.c:2997
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1424
long long status
Definition: iozone.c:1335
#define ERROR_RETURN(retval)
Definition: PAPI_state.c:12
int PAPI_start(int EventSet)
Definition: papi.c:2053
ssize_t retval
Definition: libasync.c:338
#define PAPI_VER_CURRENT
Definition: papi.h:223
void exit()

Here is the call graph for this function:

int printstate ( int  status)

Definition at line 63 of file PAPI_state.c.

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_OVERFLOWING
Definition: papi.h:376
#define PAPI_MULTIPLEXING
Definition: papi.h:378
#define printf
Definition: papi_test.h:125
long long status
Definition: iozone.c:1335
#define PAPI_PROFILING
Definition: papi.h:377
#define PAPI_RUNNING
Definition: papi.h:373
#define PAPI_STOPPED
Definition: papi.h:372
#define PAPI_PAUSED
Definition: papi.h:374
#define PAPI_NOT_INIT
Definition: papi.h:375

Here is the caller graph for this function: