PAPI  5.3.2.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
PAPI_get_real_cyc.c
Go to the documentation of this file.
1 /******************************************************************************
2  * This is an example to show how to use low level function PAPI_get_real_cyc *
3  * and PAPI_get_real_usec. *
4  ******************************************************************************/
5 
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include "papi.h" /* This needs to be included every time you use PAPI */
9 
11 {
12  int i,tmp;
13 
14  for(i=1; i<20000; i++)
15  {
16  tmp=(tmp+100)/i;
17  }
18  return 0;
19 }
20 
21 int main()
22 {
23  long long s,s1, e, e1;
24  int retval;
25 
26 
27  /****************************************************************************
28  * This part initializes the library and compares the version number of the *
29  * header file, to the version of the library, if these don't match then it *
30  * is likely that PAPI won't work correctly.If there is an error, retval *
31  * keeps track of the version number. *
32  ****************************************************************************/
33 
35  {
36  printf("Library initialization error! \n");
37  exit(1);
38  }
39 
40  /* Here you get initial cycles and time */
41  /* No error checking is done here because this function call is always
42  successful */
43 
44  s = PAPI_get_real_cyc();
45 
47 
48  /*Here you get final cycles and time */
49  e = PAPI_get_real_cyc();
50 
51  s1= PAPI_get_real_usec();
52 
54 
55  e1= PAPI_get_real_usec();
56 
57  printf("Wallclock cycles : %lld\nWallclock time(ms): %lld\n",e-s,e1-s1);
58 
59  /* clean up */
60  PAPI_shutdown();
61 
62  exit(0);
63 }
64 
65 
66 
#define printf
Definition: papi_test.h:125
Return codes and api definitions.
int your_slow_code()
Definition: PAPI_flips.c:63
int PAPI_library_init(int version)
Definition: papi.c:495
int i
Definition: fileop.c:140
void PAPI_shutdown(void)
Definition: papi.c:4357
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
s
Definition: iozone.c:20289
long long PAPI_get_real_usec(void)
Definition: papi.c:6138
long long PAPI_get_real_cyc(void)
Definition: papi.c:6091
ssize_t retval
Definition: libasync.c:338
long long tmp
Definition: iozone.c:12031
int main(int argc, char **argv)
List all appio events codes and names.
void exit()