GHOST  1.1.2
General, Hybrid, and Optimized Sparse Toolkit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Classes | Macros | Typedefs | Functions
timing.h File Reference

Functions and types related to time measurement. More...

#include <float.h>
#include "error.h"
Include dependency graph for timing.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ghost_timing_region
 Information about a timed region. More...
 

Macros

#define MIN(x, y)   ((x)<(y)?(x):(y))
 
#define MAX(x, y)   ((x)<(y)?(y):(x))
 
#define GHOST_TIME(nIter, func,...)
 Measure the execution time of a function with a given numbe of iterations. More...
 

Typedefs

typedef int(* ghost_compute_performance_func )(double *perf, double time, void *arg)
 

Functions

void ghost_timing_tick (const char *tag)
 Save the start time for a region. More...
 
void ghost_timing_tock (const char *tag)
 Save the runtime for a region using the start time from ghost_timing_tick(). More...
 
ghost_error ghost_timing_summarystring (char **str)
 Summarize all timed regions into a string. More...
 
ghost_error ghost_timing_region_create (ghost_timing_region **region, const char *tag)
 Obtain timing info about a specific region. More...
 
void ghost_timing_region_destroy (ghost_timing_region *region)
 Destroy a timing region. More...
 
ghost_error ghost_timing_wc (double *time)
 Get the wallclock time in seconds. More...
 
ghost_error ghost_timing_wcmilli (double *time)
 Get the wallclock time in milliseconds. More...
 
void ghost_timing_set_perfFunc (const char *prefix, const char *tag, ghost_compute_performance_func func, void *arg, size_t sizeofarg, const char *unit)
 Set a performance computation function to a given tag. More...
 
void ghost_timing_destroy ()
 Free timing data structures. More...
 
ghost_error ghost_timing_start ()
 
ghost_error ghost_timing_elapsed (double *time)
 

Detailed Description

Functions and types related to time measurement.

Author
Moritz Kreutzer morit.nosp@m.z.kr.nosp@m.eutze.nosp@m.r@fa.nosp@m.u.de

Macro Definition Documentation

#define GHOST_TIME (   nIter,
  func,
  ... 
)
Value:
double func ## _start, func ## _end, func ## _tstart, func ## _tend;\
double func ## _tmin = DBL_MAX;\
double func ## _tmax = 0.;\
double func ## _tavg = 0.;\
int func ## _it;\
ghost_timing_wc(&func ## _tstart);\
for (func ## _it=0; func ## _it<nIter; func ## _it++) {\
ghost_timing_wc(&func ## _start);\
func(__VA_ARGS__);\
ghost_timing_wc(&func ## _end);\
func ## _tmin = MIN(func ## _end-func ## _start,func ## _tmin);\
func ## _tmax = MAX(func ## _end-func ## _start,func ## _tmax);\
}\
ghost_timing_wc(&func ## _tend);\
func ## _tavg = (func ## _tend - func ## _tstart)/((double)nIter);\
#define MAX(x, y)
Definition: timing.h:17
ghost_error ghost_timing_wc(double *time)
Get the wallclock time in seconds.
Definition: timing.c:25
#define MIN(x, y)
Definition: timing.h:14

Measure the execution time of a function with a given numbe of iterations.

Parameters
nIterThe number of iterations.
funcThe function.
...The function's arguments.

This macro creates the variables <func>_tmin/_tmax/_tavg of type double holding the minimal, maximal and average execution time.

#define MAX (   x,
 
)    ((x)<(y)?(y):(x))
#define MIN (   x,
 
)    ((x)<(y)?(x):(y))

Typedef Documentation

typedef int(* ghost_compute_performance_func)(double *perf, double time, void *arg)

Function Documentation

void ghost_timing_destroy ( )

Free timing data structures.

ghost_error ghost_timing_elapsed ( double *  time)

Here is the call graph for this function:

ghost_error ghost_timing_region_create ( ghost_timing_region **  region,
const char *  tag 
)

Obtain timing info about a specific region.

Parameters
regionWhere to store the information.
tagThe region tag.
Returns
GHOST_SUCCESS on success or an error indicator.

Here is the call graph for this function:

void ghost_timing_region_destroy ( ghost_timing_region region)

Destroy a timing region.

Parameters
regionThe region.
void ghost_timing_set_perfFunc ( const char *  prefix,
const char *  tag,
ghost_compute_performance_func  func,
void *  arg,
size_t  sizeofarg,
const char *  unit 
)

Set a performance computation function to a given tag.

Parameters
[in]prefixThe prefix of the region tag. Usually the variable __ghost_functag can be used here.
[in]tagThe region tag.
[in]funcThe performance callback function.
[in]argArgument to the function.
[in]sizeofargSize of the arg struct.
[in]unitThe unit of performance.

Here is the call graph for this function:

ghost_error ghost_timing_start ( )

Here is the call graph for this function:

ghost_error ghost_timing_summarystring ( char **  str)

Summarize all timed regions into a string.

Parameters
strWhere to store the string.
Returns
GHOST_SUCCESS on success or an error indicator.

Here is the call graph for this function:

void ghost_timing_tick ( const char *  tag)

Save the start time for a region.

Parameters
tagThe region tag.

Here is the call graph for this function:

void ghost_timing_tock ( const char *  tag)

Save the runtime for a region using the start time from ghost_timing_tick().

Parameters
tagThe region tag.

Here is the call graph for this function:

ghost_error ghost_timing_wc ( double *  time)

Get the wallclock time in seconds.

Parameters
timeWhere to store the time.
Returns
GHOST_SUCCESS on success or an error indicator.
ghost_error ghost_timing_wcmilli ( double *  time)

Get the wallclock time in milliseconds.

Parameters
timeWhere to store the time.
Returns
GHOST_SUCCESS on success or an error indicator.