PAPI 7.1.0.0
Loading...
Searching...
No Matches
PAPI_epc.c
Go to the documentation of this file.
1/*****************************************************************************
2 * This example demonstrates the usage of the function PAPI_epc which *
3 * measures arbitrary events per cpu cycle *
4 *****************************************************************************/
5
6/*****************************************************************************
7 * The first call to PAPI_epc() will initialize the PAPI interface, *
8 * set up the counters to monitor the user specified event, PAPI_TOT_CYC, *
9 * and PAPI_REF_CYC (if it exists) and start the counters. Subsequent calls *
10 * will read the counters and return real time, process time, event counts, *
11 * the core and reference cycle count and EPC rate since the latest call to *
12 * PAPI_epc(). *
13 *****************************************************************************/
14
15
16
17#include <stdio.h>
18#include <stdlib.h>
19#include "papi.h"
20
21int your_slow_code();
22
23int main()
24{
25 float real_time, proc_time, epc;
26 long long ref, core, evt;
27 float real_time_i, proc_time_i, epc_i;
28 long long ref_i, core_i, evt_i;
29 int retval;
30
31 if((retval=PAPI_epc(PAPI_TOT_INS, &real_time_i, &proc_time_i, &ref_i, &core_i, &evt_i, &epc_i)) < PAPI_OK)
32 {
33 printf("Could not initialise PAPI_epc \n");
34 printf("retval: %d\n", retval);
35 exit(1);
36 }
37
39
40
41 if((retval=PAPI_epc(PAPI_TOT_INS, &real_time, &proc_time, &ref, &core, &evt, &epc))<PAPI_OK)
42 {
43 printf("retval: %d\n", retval);
44 exit(1);
45 }
46
47
48 printf("Real_time: %f Proc_time: %f Ref_clock: %lld Core_clock: %lld Events: %lld EPC: %f\n",
49 real_time, proc_time, ref, core, evt, epc);
50
51 /* clean up */
53 exit(0);
54}
55
57{
58 int i;
59 double tmp=1.1;
60
61 for(i=1; i<2000; i++)
62 {
63 tmp=(tmp+100)/i;
64 }
65 return 0;
66}
67
int your_slow_code()
Definition: PAPI_epc.c:56
int main()
Definition: PAPI_epc.c:23
double tmp
int i
Simplified call to get arbitrary events per cycle, real and processor time.
Finish using PAPI and free all related resources.
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_TOT_INS
Definition: f90papi.h:317
Return codes and api definitions.
int retval
Definition: zero_fork.c:53