|
BeBOP Optimized Sparse Kernel Interface Library
1.0.1h
|
Timing wrapper macros. More...
Go to the source code of this file.
Defines | |
| #define | INC_UTIL_TIMING_H |
| util/timing.h included. | |
| #define | TIMING_LOOP_CORE(CODE, PRE_CODE, POST_CODE, outer_iters, inner_iters, times) |
| Generic macro to time an arbitrary piece of C code using the BeBOP Tempo timer (see oski/timer.h). | |
| #define | CALC_MIN_ITERS(CODE, PRE_CODE, POST_CODE, min_time, num_iters) |
| Compute the minimum number of inner iterations needed to consume some minimum amount of execution time. | |
| #define | DUMMY_CODE |
| Do nothing code. | |
| #define | TIMING_LOOP_BASIC(CODE, num_trials, num_ops, speed) |
| Basic timing loop. | |
Timing wrapper macros.
| #define CALC_MIN_ITERS | ( | CODE, | |
| PRE_CODE, | |||
| POST_CODE, | |||
| min_time, | |||
| num_iters | |||
| ) |
Compute the minimum number of inner iterations needed to consume some minimum amount of execution time.
| [in] | CODE | Code to benchmark. |
| [in] | PRE_CODE | Code to execute before each inner loop. |
| [in] | POST_CODE | Code to execute after each inner loop. |
| [in] | min_time | Minimum desired inner loop execution time. |
| [out] | num_iters | Minimum number of inner iterations needed to obtain the minimum desired inner loop execution time. |
| #define INC_UTIL_TIMING_H |
util/timing.h included.
| #define TIMING_LOOP_BASIC | ( | CODE, | |
| num_trials, | |||
| num_ops, | |||
| speed | |||
| ) |
{ \
double* outer_times_; \
size_t min_inner_; \
\
outer_times_ = oski_Malloc( double, (num_trials) ); \
ABORT( outer_times_ == NULL, TIMING_LOOP_BASIC, ERR_OUT_OF_MEMORY ); \
\
CALC_MIN_ITERS( CODE, DUMMY_CODE, DUMMY_CODE, .2, min_inner_ ); \
TIMING_LOOP_CORE( CODE, DUMMY_CODE, DUMMY_CODE, \
(num_trials), min_inner_, outer_times_ ); \
(speed) = \
(double)(num_ops) / stat_CalcMin(outer_times_, num_trials); \
\
oski_Free( outer_times_ ); \
}
Basic timing loop.
| [in] | CODE | Code to execute. |
| [in] | num_trials | Number of trials. |
| [in] | num_ops | Number of operations per execution of CODE. |
| [out] | speed | Best observed speed. |
Referenced by main().
| #define TIMING_LOOP_CORE | ( | CODE, | |
| PRE_CODE, | |||
| POST_CODE, | |||
| outer_iters, | |||
| inner_iters, | |||
| times | |||
| ) |
Generic macro to time an arbitrary piece of C code using the BeBOP Tempo timer (see oski/timer.h).
The timing loop is actually a doubly-nested loop: an 'outer' loop, and an 'inner' loop structured roughly as follows:
FOR i = 1 to outer_iters DO
EXECUTE caller's PRE_CODE.
Start_timer();
FOR j = 1 to inner_iters DO
EXECUTE CODE.
END
Stop_timer();
EXECUTE caller's POST_CODE.
t = Read_elapsed_time();
times[i] = t / inner_iters;
END
| [in] | CODE | Code to benchmark. |
| [in] | PRE_CODE | Code executed just before the call to start the timer (executed once per outer iteration). |
| [in] | POST_CODE | Code executed just before the call to stop the timer (executed once per outer iteration). |
| [in] | inner_iters | The number of inner iterations. |
| [in] | outer_iters | The number of outer iterations. |
| [in,out] | times | A pre-allocated array for storing the mean inner-iteration execution times. |
1.7.6.1