PAPI  5.3.2.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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

#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

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 */
49  if ( (retval=PAPI_create_eventset(&EventSet)) != PAPI_OK)
50  ERROR_RETURN(retval);
51 
52  /* Add Total Instructions Executed to our EventSet */
53  if ((retval=PAPI_add_event(EventSet, event_code)) != PAPI_OK)
54  ERROR_RETURN(retval);
55 
56  /* Start counting */
57  if((retval=PAPI_start(EventSet)) != PAPI_OK)
58  ERROR_RETURN(retval);
59 
61 
62  /* Stop counting */
63  if((retval=PAPI_stop(EventSet, values)) != PAPI_OK)
64  ERROR_RETURN(retval);
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 */
70  if((retval=PAPI_reset(EventSet)) != PAPI_OK)
71  ERROR_RETURN(retval);
72 
73  /* Start counting */
74  if((retval=PAPI_start(EventSet)) != PAPI_OK)
75  ERROR_RETURN(retval);
76 
78 
79  /* Stop counting */
80  if((retval=PAPI_stop(EventSet, values)) != PAPI_OK)
81  ERROR_RETURN(retval);
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 }
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2232
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1604
int PAPI_reset(int EventSet)
Definition: papi.c:2377
#define PAPI_NULL
Definition: fpapi.h:13
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
#define PAPI_TOT_INS
Definition: fpapi.h:185
return PAPI_OK
Definition: linux-nvml.c:458
#define printf
Definition: papi_test.h:125
int poorly_tuned_function()
Definition: PAPI_get_opt.c:14
int PAPI_library_init(int version)
Definition: papi.c:495
void PAPI_shutdown(void)
Definition: papi.c:4357
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1406
int EventSet
#define ERROR_RETURN(retval)
Definition: PAPI_reset.c:9
int PAPI_start(int EventSet)
Definition: papi.c:2026
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
void exit()

Here is the call graph for this 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 }
int i
Definition: fileop.c:140
long long tmp
Definition: iozone.c:12031