PAPI
7.1.0.0
Loading...
Searching...
No Matches
busy_work.c
Go to the documentation of this file.
1
#include <stdio.h>
2
#include <sys/time.h>
3
4
/* Repeat doing some busy-work floating point */
5
/* Until at least len seconds have passed */
6
7
double
8
do_cycles
(
int
minimum_time )
9
{
10
struct
timeval
start
, now;
11
double
x
, sum;
12
13
gettimeofday( &
start
, NULL );
14
15
for
( ;; ) {
16
sum = 1.0;
17
for
(
x
= 1.0;
x
< 250000.0;
x
+= 1.0 ) {
18
sum +=
x
;
19
}
20
if
( sum < 0.0 ) {
21
printf(
"==>> SUM IS NEGATIVE !! <<==\n"
);
22
}
23
24
gettimeofday( &now, NULL );
25
if
( now.
tv_sec
>=
start
.
tv_sec
+ minimum_time ) {
26
break
;
27
}
28
}
29
return
sum;
30
}
31
do_cycles
double do_cycles(int minimum_time)
Definition:
busy_work.c:8
start
static struct timeval start
Definition:
krentel_pthreads.c:27
timeval
Definition:
papi_fwrappers_.c:1278
timeval::tv_sec
__time_t tv_sec
Definition:
papi_fwrappers_.c:1283
x
volatile double x
Definition:
timing_kernels.c:12
src
validation_tests
busy_work.c
Generated on Wed Dec 20 2023 18:12:52 for PAPI by
1.9.6