PAPI  5.7.0.0
PAPI_reset.c File Reference
Include dependency graph for PAPI_reset.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 poorly_tuned_function ()
 
int main ()
 

Macro Definition Documentation

◆ ERROR_RETURN

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

Definition at line 9 of file PAPI_reset.c.

Function Documentation

◆ main()

int main ( )

Definition at line 23 of file PAPI_reset.c.

24 {
25  int EventSet = PAPI_NULL;
26  /*must be initialized to PAPI_NULL before calling PAPI_create_event*/
27 
28  int retval;
29  unsigned int event_code=PAPI_TOT_INS;
30  /* By default monitor total instructions */
31 
32  char errstring[PAPI_MAX_STR_LEN];
33  long long values[1];
34 
35  /****************************************************************************
36  * This part initializes the library and compares the version number of the *
37  * header file, to the version of the library, if these don't match then it *
38  * is likely that PAPI won't work correctly.If there is an error, retval *
39  * keeps track of the version number. *
40  ****************************************************************************/
41 
43  {
44  printf("Library initialization error! \n");
45  exit(1);
46  }
47 
48  /* Creating the eventset */
51 
52  /* Add Total Instructions Executed to our EventSet */
53  if ((retval=PAPI_add_event(EventSet, event_code)) != PAPI_OK)
55 
56  /* Start counting */
59 
61 
62  /* Stop counting */
65 
66 
67  printf("The first time read value is %lld\n",values[0]);
68 
69  /* This zeroes out the counters on the eventset that was created */
72 
73  /* Start counting */
76 
78 
79  /* Stop counting */
82 
83  printf("The second time read value is %lld\n",values[0]);
84 
85  /* free the resources used by PAPI */
86  PAPI_shutdown();
87 
88  exit(0);
89 }
#define PAPI_OK
Definition: fpapi.h:105
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2314
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1663
int PAPI_reset(int EventSet)
Definition: papi.c:2459
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
int EventSet
int retval
Definition: zero_fork.c:53
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
#define PAPI_NULL
Definition: fpapi.h:13
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1464
#define ERROR_RETURN(retval)
Definition: PAPI_reset.c:9
int poorly_tuned_function()
Definition: PAPI_reset.c:11
int PAPI_start(int EventSet)
Definition: papi.c:2096
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
void exit()
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
Here is the call graph for this function:

◆ poorly_tuned_function()

int poorly_tuned_function ( )

Definition at line 11 of file PAPI_reset.c.

12 {
13  float tmp;
14  int i;
15 
16  for(i=1; i<2000; i++)
17  {
18  tmp=(tmp+100)/i;
19  }
20  return 0;
21 }
double tmp
int i
Definition: fileop.c:140
Here is the caller graph for this function: