PAPI 7.1.0.0
Loading...
Searching...
No Matches
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
21int 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
45
47
48 /*Here you get final cycles and time */
50
52
54
56
57 printf("Wallclock cycles : %lld\nWallclock time(ms): %lld\n",e-s,e1-s1);
58
59 /* clean up */
61
62 exit(0);
63}
64
65
66
int your_slow_code()
int main()
double tmp
int i
double s
Definition: byte_profile.c:36
get real time counter value in clock cycles Returns the total real time passed since some arbitrary s...
get real time counter value 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