PAPI 7.1.0.0
Loading...
Searching...
No Matches
PAPI_reset.c
Go to the documentation of this file.
1/*****************************************************************************
2 * PAPI_reset - resets the hardware event counters used by an EventSet. *
3 *****************************************************************************/
4
5#include <stdio.h>
6#include <stdlib.h>
7#include "papi.h" /* This needs to be included every time you use PAPI */
8
9#define ERROR_RETURN(retval) { fprintf(stderr, "Error %d %s:line %d: \n", retval,__FILE__,__LINE__); exit(retval); }
10
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}
22
23int main()
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 */
87
88 exit(0);
89}
90
91
double tmp
int i
int poorly_tuned_function()
Definition: PAPI_reset.c:11
#define ERROR_RETURN(retval)
Definition: PAPI_reset.c:9
int main()
Definition: PAPI_reset.c:23
add PAPI preset or native hardware event to an event set
Create a new empty PAPI EventSet.
initialize the PAPI library.
Reset the hardware event counts in an event set.
Finish using PAPI and free all related resources.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_NULL
Definition: f90papi.h:78
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
#define PAPI_TOT_INS
Definition: f90papi.h:317
static int EventSet
Definition: init_fini.c:8
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
Return codes and api definitions.
int retval
Definition: zero_fork.c:53