PAPI  5.4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
PAPI_get_virt_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_virt_cyc *
3  * and PAPI_get_virt_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 
10 int i;
11 double tmp;
12 
14 {
15 
16  for(i=1; i<200000; i++)
17  {
18  tmp= (tmp+i)/2;
19  }
20  return 0;
21 }
22 
23 int main()
24 {
25  long long s,s1, e, e1;
26  int retval;
27 
28 
29  /****************************************************************************
30  * This part initializes the library and compares the version number of the *
31  * header file, to the version of the library, if these don't match then it *
32  * is likely that PAPI won't work correctly.If there is an error, retval *
33  * keeps track of the version number. *
34  ****************************************************************************/
35 
37  {
38  printf("Library initialization error! \n");
39  exit(1);
40  }
41 
42  /* Here you get initial cycles and time */
43  /* No error checking is done here because this function call is always
44  successful */
45 
46  s = PAPI_get_virt_cyc();
47 
49 
50  /*Here you get final cycles and time */
51  e = PAPI_get_virt_cyc();
52 
53  s1= PAPI_get_virt_usec();
54 
56 
57  e1= PAPI_get_virt_usec();
58 
59  printf("Virtual cycles : %lld\nVirtual time(ms): %lld\n",e-s,e1-s1);
60 
61  /* clean up */
62  PAPI_shutdown();
63 
64  exit(0);
65 }
66 
long long PAPI_get_virt_usec(void)
Definition: papi.c:6298
long long PAPI_get_virt_cyc(void)
Definition: papi.c:6226
#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:497
int i
Definition: fileop.c:140
void PAPI_shutdown(void)
Definition: papi.c:4400
s
Definition: iozone.c:20289
ssize_t retval
Definition: libasync.c:338
long long tmp
Definition: iozone.c:12031
#define PAPI_VER_CURRENT
Definition: papi.h:223
int main(int argc, char **argv)
List all appio events codes and names.
void exit()