PAPI 7.1.0.0
Loading...
Searching...
No Matches
PAPI_mix_ll_rate.c
Go to the documentation of this file.
1/*****************************************************************************
2 * This example compares the measurement of IPC using the rate function *
3 * PAPI_ipc and the low-level API. Both methods should deliver the same *
4 * result for IPC. *
5 * Note: There is no need to initialize PAPI for the low-level functions *
6 * since this is done by PAPI_ipc. *
7 *****************************************************************************/
8
9
10#include <stdio.h>
11#include <stdlib.h>
12#include "papi.h"
13
14#define THRESHOLD 10000
15#define ERROR_RETURN(retval) { fprintf(stderr, "Error %d %s:line %d: \n", retval,__FILE__,__LINE__); exit(retval); }
16
17int your_slow_code();
18
19int main()
20{
21 float real_time, proc_time, ipc;
22 long long ins;
23 int retval;
24 int EventSet = PAPI_NULL;
26
27 if ( (retval = PAPI_ipc(&real_time, &proc_time, &ins ,&ipc)) < PAPI_OK )
29
31
32 if ( (retval = PAPI_ipc( &real_time, &proc_time, &ins, &ipc)) < PAPI_OK )
34
35 printf("Results from PAPI_ipc:\n");
36 printf("Real_time: %f Proc_time: %f Instructions: %lld IPC: %f\n",
37 real_time, proc_time,ins,ipc);
38
39 if ( (retval = PAPI_rate_stop()) < PAPI_OK )
41
42 /* get IPC using low-level API */
45
50
51 if ( (retval = PAPI_start(EventSet)) < PAPI_OK )
53
55
58
59 ipc = (float) ((float)values[0] / (float) ( values[1]));
60
61 printf("Results from the low-level API:\n");
62 printf("IPC: %f\n", ipc);
63
64 exit(0);
65}
66
68{
69 int i;
70 double tmp=1.1;
71
72 for(i=1; i<2000; i++)
73 {
74 tmp=(tmp+100)/i;
75 }
76 return 0;
77}
78
double tmp
int i
#define ERROR_RETURN(retval)
int your_slow_code()
int main()
add PAPI preset or native hardware event to an event set
Create a new empty PAPI EventSet.
Simplified call to get instructions per cycle, real and processor time.
Stop a running event set of a rate function.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_NULL
Definition: f90papi.h:78
#define PAPI_TOT_CYC
Definition: f90papi.h:308
#define PAPI_TOT_INS
Definition: f90papi.h:317
static int EventSet
Definition: init_fini.c:8
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
Return codes and api definitions.
#define long_long
Definition: papi.h:559
int retval
Definition: zero_fork.c:53