PAPI 7.1.0.0
Loading...
Searching...
No Matches
PAPI_mix_hl_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 high-level region instrumentation. Both methods should *
4 * deliver the same result for IPC. *
5 * Hint: Use PAPI's high-level output script to print the measurement report *
6 * of the high-level API. *
7 * *
8 * ../high-level/scripts/papi_hl_output_writer.py --type=accumulate *
9 *****************************************************************************/
10
11
12#include <stdio.h>
13#include <stdlib.h>
14#include "papi.h"
15
16#define THRESHOLD 10000
17#define ERROR_RETURN(retval) { fprintf(stderr, "Error %d %s:line %d: \n", retval,__FILE__,__LINE__); exit(retval); }
18
19int your_slow_code();
20
21int main()
22{
23 float real_time, proc_time,ipc;
24 long long ins;
25 int retval;
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("Real_time: %f Proc_time: %f Instructions: %lld IPC: %f\n",
36 real_time, proc_time,ins,ipc);
37
38
39 if ( (retval = PAPI_hl_region_begin("slow_code")) < PAPI_OK )
41
43
44 if ( (retval = PAPI_hl_region_end("slow_code")) < PAPI_OK )
46
47
48 if ( (retval = PAPI_ipc(&real_time, &proc_time, &ins ,&ipc)) < PAPI_OK )
50
52
53 if ( (retval = PAPI_ipc( &real_time, &proc_time, &ins, &ipc)) < PAPI_OK )
55
56 printf("Real_time: %f Proc_time: %f Instructions: %lld IPC: %f\n",
57 real_time, proc_time,ins,ipc);
58
59 if ( (retval = PAPI_rate_stop()) < PAPI_OK )
61
62 exit(0);
63}
64
66{
67 int i;
68 double tmp=1.1;
69
70 for(i=1; i<2000; i++)
71 {
72 tmp=(tmp+100)/i;
73 }
74 return 0;
75}
76
double tmp
int i
#define ERROR_RETURN(retval)
int your_slow_code()
int main()
Read performance events at the beginning of a region.
Read performance events at the end of a region and store the difference to the corresponding beginnin...
Simplified call to get instructions per cycle, real and processor time.
Stop a running event set of a rate function.
#define PAPI_OK
Definition: f90papi.h:73
Return codes and api definitions.
int retval
Definition: zero_fork.c:53