PAPI 7.1.0.0
Loading...
Searching...
No Matches
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
10int i;
11double tmp;
12
14{
15
16 for(i=1; i<200000; i++)
17 {
18 tmp= (tmp+i)/2;
19 }
20 return 0;
21}
22
23int 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
47
49
50 /*Here you get final cycles and time */
52
54
56
58
59 printf("Virtual cycles : %lld\nVirtual time(ms): %lld\n",e-s,e1-s1);
60
61 /* clean up */
63
64 exit(0);
65}
66
double tmp
int your_slow_code()
int i
int main()
double s
Definition: byte_profile.c:36
get virtual time counter value in clock cycles
get virtual time counter values in microseconds
initialize the PAPI library.
Finish using PAPI and free all related resources.
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
Return codes and api definitions.
int retval
Definition: zero_fork.c:53