PAPI 7.1.0.0
Loading...
Searching...
No Matches
PAPI_mix_hl_ll.c
Go to the documentation of this file.
1/*****************************************************************************
2 * This example compares the measurement of IPC using the high-level API *
3 * 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 the high-level API. *
7 * *
8 * Hint: Use PAPI's high-level output script to print the measurement report *
9 * of the high-level API. *
10 * *
11 * ../high-level/scripts/papi_hl_output_writer.py --type=accumulate *
12 *****************************************************************************/
13
14
15#include <stdio.h>
16#include <stdlib.h>
17#include "papi.h"
18
19#define THRESHOLD 10000
20#define ERROR_RETURN(retval) { fprintf(stderr, "Error %d %s:line %d: \n", retval,__FILE__,__LINE__); exit(retval); }
21
22int your_slow_code();
23
24int main()
25{
26 float ipc;
27 int retval;
28 int EventSet = PAPI_NULL;
30
31 if ( (retval = PAPI_hl_region_begin("slow_code")) < PAPI_OK )
33
35
36 if ( (retval = PAPI_hl_region_end("slow_code")) < PAPI_OK )
38
39 if ( (retval = PAPI_hl_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.
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...
Stop a running high-level event set.
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