[Developers] Proposed Cactus Timer API Completion

Steve White swhite at aei.mpg.de
Tue Aug 3 07:54:35 CDT 2004

The existing API for Cactus Timers provides accessors for Timers, but
peters out when it comes to getting information for a particular clock
within a timer value.  The interface consists of a structure definition
(see Chapter B10.1 of the Users' Guide).

There is something a bit wrong-headed about the existing clock structure.  
It records information as a type that is convenient for the low-level
timer (as an int, long, or double), although the user invariably wants the
time period in seconds.  There are outstanding bug reports to this effect.

Accordingly, I propose to add the following functions to the Timer API:

unsigned int
CCTK_NumTimerClocks( const cTimerData *info )
	// Gets the number of clocks recorded in a timer measurement

const cTimerVal *
CCTK_GetClockValNumber( int clockno, const cTimerData *info );
	// Gets the clock value with the given number from the 
	// timer measurement

const cTimerVal *
CCTK_GetClockValNamed( const char * name, const cTimerData *info );
	// Gets the clock value for the clock with the given name
	// from the timer measurement

const char *
CCTK_TimerClockName( const cTimerVal *clockVal );
        // Gets the name of the clock corresponding to the clock value

CCTK_TimerClockSeconds( const cTimerVal *clockVal );
	// Gets the value of the measurement in seconds from the clock
	// value
The intent is to protect the user entirely from the internals of the
cTimerVal and cTimerData structures.

The code snippet in B10.1.4 "Accessing the timer results" becomes

   cTimerData *info = CCTK_TimerCreateData();
   int nclocks = CCTK_NumTimerClocks( info );

   for (i = 0; i < numclocks; i++)
     const cTimerVal   *clock = CCTK_GetClockValNumber( i, info );
     printf ("\t%s: %.3f %s\n", CCTK_TimerClockName( clock ),
                                CCTK_TimerClockSeconds( clock ), "secs" );
   CCTK_TimerDestroyData (info);

Steve White : Programmer
Max-Planck-Institut für Gravitationsphysik      Albert-Einstein-Institut
Am Mühlenberg 1, D-14476 Golm, Germany                  +49-331-567-7329

More information about the Developers mailing list