BeBOP Optimized Sparse Kernel Interface Library  1.0.1h
Defines
timing.h File Reference

Timing wrapper macros. More...

#include <oski/timer.h>
#include "stat.h"

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.

Detailed Description

Timing wrapper macros.


Define Documentation

#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.

Parameters:
[in]CODECode to benchmark.
[in]PRE_CODECode to execute before each inner loop.
[in]POST_CODECode to execute after each inner loop.
[in]min_timeMinimum desired inner loop execution time.
[out]num_itersMinimum number of inner iterations needed to obtain the minimum desired inner loop execution time.

util/timing.h included.

#define TIMING_LOOP_BASIC (   CODE,
  num_trials,
  num_ops,
  speed 
)
Value:
{ \
        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.

Parameters:
[in]CODECode to execute.
[in]num_trialsNumber of trials.
[in]num_opsNumber of operations per execution of CODE.
[out]speedBest observed speed.
Returns:
Sets the argument 'speed' to the best observed speed (in operations per second) over all outer loop executions.

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
Parameters:
[in]CODECode to benchmark.
[in]PRE_CODECode executed just before the call to start the timer (executed once per outer iteration).
[in]POST_CODECode executed just before the call to stop the timer (executed once per outer iteration).
[in]inner_itersThe number of inner iterations.
[in]outer_itersThe number of outer iterations.
[in,out]timesA pre-allocated array for storing the mean inner-iteration execution times.