IBAMR  IBAMR version 0.19.
Static Public Member Functions | Static Private Attributes | List of all members
SAMRAI::tbox::Clock Struct Reference

#include <tbox/Clock.h>

Static Public Member Functions

static void initialize (clock_t &clock)
 
static void initialize (double &clock)
 
static void timestamp (clock_t &user, clock_t &sys, clock_t &wall)
 
static void timestamp (clock_t &user, clock_t &sys, double &wall)
 
static double getClockCycle ()
 

Static Private Attributes

static struct tms s_tms_buffer
 
static clock_t s_null_clock_t
 

Detailed Description

Class Clock serves as a single point of access for system clock information. System and user time are computed via the POSIX compliant times() function. This is described on p. 137, Lewine, POSIX programmers guide, 1992. The methods and structs used in this utility are defined in <sys/times.h>. Start and end times are stored as variables of type clock_t. A clock_t value can be converted to seconds by dividing by CLK_TCK (which is defined in <sys/times.h>). Different systems may use different CLK_TCK. Time is accessed by calling the times() function which takes as an argument a reference to an object of type struct tms. This object will record the system and user time (obj.tms_utime & obj.tms_stime) and will return the time since the system was started.

The return value from the call to times() can be used to compute elapsed wallclock time. Alternatively, one can use MPI_Wtime() if MPI libraries are included. Two methods are defined for accessing system time - one that has a clock_t struct argument for wallclock time (the non-MPI case) and one that has a double argument to record the value of MPI_Wtime().

Computing user/system/wallclock time with the times() function is performed as follows:

*    struct tms buffer;
*    clock_t wtime_start = times(&buffer);
*    clock_t stime_start = buffer.tms_stime;
*    clock_t utime_start = buffer.tms_utime;
*     (do some computational work)
*    clock_t wtime_stop  = times(&buffer);
*    clock_t stime_stop  = buffer.tms_stime;
*    clock_t utime_stop  = buffer.tms_utime;
*    double wall_time   = double(wtime_stop-wtime_start)/double(CLK_TCK);
*    double user_time   = double(utime_stop-utime_start)/double(CLK_TCK);
*    double sys_time    = double(stime_stop-stime_start)/double(CLK_TCK);
* 

Member Function Documentation

◆ initialize() [1/2]

static void SAMRAI::tbox::Clock::initialize ( clock_t &  clock)
static

Initialize system clock. Argument must be in the "clock_t" format which is a standard POSIX struct provided on most systems in the <sys/times.h> include file. On Microsoft systems, it is provided in <time.h>.

◆ initialize() [2/2]

static void SAMRAI::tbox::Clock::initialize ( double clock)
static

Initialize system clock, where clock is in double format.

◆ timestamp() [1/2]

static void SAMRAI::tbox::Clock::timestamp ( clock_t &  user,
clock_t &  sys,
clock_t &  wall 
)
static

Timestamp clocks for user, system, and wallclock times.

◆ timestamp() [2/2]

static void SAMRAI::tbox::Clock::timestamp ( clock_t &  user,
clock_t &  sys,
double wall 
)
static

Timestamp user, system, and walltime clocks. Wallclock argument is in double format since it will access wallclock times from MPI_Wtime() function.

◆ getClockCycle()

static double SAMRAI::tbox::Clock::getClockCycle ( )
static

Returns clock cycle for the system.

Member Data Documentation

◆ s_tms_buffer

struct tms SAMRAI::tbox::Clock::s_tms_buffer
staticprivate

◆ s_null_clock_t

clock_t SAMRAI::tbox::Clock::s_null_clock_t
staticprivate

The documentation for this struct was generated from the following file: