PAPI 7.1.0.0
Loading...
Searching...
No Matches
high_level.c
Go to the documentation of this file.
1/*****************************************************************************
2* This example code shows how to use PAPI's High level functions. *
3* Events to be recorded are determined via an environment variable *
4* PAPI_EVENTS that lists comma separated events for any component. *
5* If events are not specified via the environment variable PAPI_EVENTS, an *
6* output with default events is generated after the run. If supported by *
7* the respective machine the following default events are recorded: *
8* perf::TASK-CLOCK *
9* PAPI_TOT_INS *
10* PAPI_TOT_CYC *
11* PAPI_FP_INS *
12* PAPI_FP_OPS or PAPI_DP_OPS or PAPI_SP_OPS *
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
22/* stupid codes to be monitored */
24{
25 double tmp=1.0;
26 int i=1;
27 for( i = 1; i < THRESHOLD; i++ )
28 {
29 tmp = tmp*i;
30 }
31}
32
33/* stupid codes to be monitored */
35{
36 int tmp = 0;
37 int i=0;
38
39 for( i = 0; i < THRESHOLD; i++ )
40 {
41 tmp = tmp + i;
42 }
43
44}
45
46
47int main()
48{
49 int retval;
50 char errstring[PAPI_MAX_STR_LEN];
51
52 retval = PAPI_hl_region_begin("computation_add");
53 if ( retval != PAPI_OK )
55
56 /* Your code goes here*/
58
59 retval = PAPI_hl_read("computation_add");
60 if ( retval != PAPI_OK )
62
63 /* Your code goes here*/
65
66 retval = PAPI_hl_region_end("computation_add");
67 if ( retval != PAPI_OK )
69
70
71 retval = PAPI_hl_region_begin("computation_mult");
72 if ( retval != PAPI_OK )
74
75 /* Your code goes here*/
77
78 retval = PAPI_hl_region_end("computation_mult");
79 if ( retval != PAPI_OK )
81
82 exit(0);
83}
double tmp
int i
Read performance events inside of a region and store the difference to the corresponding beginning of...
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...
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
void computation_add()
Definition: high_level.c:34
#define THRESHOLD
Definition: high_level.c:19
#define ERROR_RETURN(retval)
Definition: high_level.c:20
void computation_mult()
Definition: high_level.c:23
int main()
Definition: high_level.c:47
Return codes and api definitions.
int retval
Definition: zero_fork.c:53