PAPI 7.1.0.0
Loading...
Searching...
No Matches
Simple2_NoPAPI_Driver.c File Reference
Include dependency graph for Simple2_NoPAPI_Driver.c:

Go to the source code of this file.

Functions

void simple_init (void)
 
double simple_compute (double x)
 
int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 9 of file Simple2_NoPAPI_Driver.c.

9 {
10 int i;
11 int be_verbose = 0;
12
13 if( (argc > 1) && !strcmp(argv[1], "-verbose") )
14 be_verbose = 1;
15
17
18 for(i=0; i<10; i++){
19 double sum;
20
21 sum = simple_compute(0.87*i);
22 if( be_verbose) printf("sum=%lf\n",sum);
23 }
24
25 // This test exists just to check that a code that links against libsde
26 // _without_ linking against libpapi will still compile and run. Therefore,
27 // if we got to this point then the test has passed.
28 fprintf( stdout, "%sPASSED%s\n","\033[1;32m","\033[0m");
29
30 return 0;
31}
int be_verbose
int i
void simple_init(void)
Definition: Simple_Lib.c:25
double simple_compute(double x)
Definition: Simple_Lib.c:45
FILE * stdout
Here is the call graph for this function:

◆ simple_compute()

double simple_compute ( double  x)

Definition at line 45 of file Simple_Lib.c.

45 {
46 double sum = 0.0;
47 int lcl_iter = 0;
48
49 if( x > 1.0 )
50 x = 1.0/x;
51 if( x < 0.000001 )
52 x += 0.3579;
53
54 while( 1 ){
55 double y,x2,x3,x4;
56 lcl_iter++;
57
58 // Compute a function with range [0:1] so we can iterate
59 // multiple times without diverging or creating FP exceptions.
60 x2 = x*x;
61 x3 = x2*x;
62 x4 = x2*x2;
63 y = 42.53*x4 -67.0*x3 +25.0*x2 +x/2.15;
64 y = y*y;
65 if( y < 0.01 )
66 y = 0.5-y;
67
68 // Now set the next x to be the current y, so we can iterate again.
69 x = y;
70
71 // Add y to sum unconditionally
72 sum += y;
73
74 if( y < 0.1 ){
75 low_wtrmrk++;
76 continue;
77 }
78
79 if( y > 0.9 ){
81 continue;
82 }
83
84 // Only add y to comp_value if y is between the low and high watermarks.
85 comp_value += y;
86
87 // If some condition is met, terminate the loop
88 if( 0.61 < y && y < 0.69 )
89 break;
90 }
91 total_iter_cnt += lcl_iter;
92
93 return sum;
94}
static long long int total_iter_cnt
Definition: Simple_Lib.c:14
static long long int high_wtrmrk
Definition: Simple_Lib.c:14
static long long int low_wtrmrk
Definition: Simple_Lib.c:14
static double comp_value
Definition: Simple_Lib.c:13
volatile double y
volatile double x
Here is the caller graph for this function:

◆ simple_init()

void simple_init ( void  )

Definition at line 25 of file Simple_Lib.c.

25 {
26
27 // Initialize library specific variables
28 comp_value = 0.0;
30 low_wtrmrk = 0;
31 high_wtrmrk = 0;
32
33 // Initialize PAPI SDEs
34 handle = papi_sde_init("Simple");
39
40 return;
41}
static const char * ev_names[4]
Definition: Simple_Lib.c:17
static papi_handle_t handle
Definition: Simple_Lib.c:15
papi_handle_t papi_sde_init(const char *name_of_library)
Definition: sde_lib.c:119
int papi_sde_register_counter(papi_handle_t handle, const char *event_name, int cntr_mode, int cntr_type, void *counter)
Definition: sde_lib.c:276
#define PAPI_SDE_double
Definition: sde_lib.h:30
#define PAPI_SDE_long_long
Definition: sde_lib.h:28
#define PAPI_SDE_RO
Definition: sde_lib.h:23
#define PAPI_SDE_INSTANT
Definition: sde_lib.h:26
#define PAPI_SDE_DELTA
Definition: sde_lib.h:25
Here is the call graph for this function:
Here is the caller graph for this function: