Next: Glossary
Up: UsersGuideStable
Previous: Recovery Invocation
Contents
Clocks for Timing
To add a Cactus clock, you need to write several functions to provide the
timer functionality (see Section B10.1), and then register these
functions with the flesh as a named clock.
The function pointers are placed in function pointer fields of a
cClockFuncs structure. The fields of this structure are are:
- create
- void *(*create)(int)
- destroy
- void (*destroy)(int, void *)
- start
- void (*start)(int, void *)
- stop
- void (*stop)(int, void *)
- reset
- void (*reset)(int, void *)
- >et
- void (*get)(int, void *, cTimerVal *)
- set
- void (*set)(int, void *, cTimerVal *)
- n_vals
- int
The first int argument of the functions may be used in any way
you see fit.
The n_vals field holds the number of elements in the
vals array field of the cTimerVal structure
used by your timer (usually 1).
The return value of the create function will be a pointer to
a new structure representing your clock.
The second void* argument of all the other functions will be the
pointer returned from the create function.
The get and set functions should write to and read from
(respectively) a structure pointed to by the cTimerVal* argument:
typedef enum {val_none, val_int, val_long, val_double} cTimerValType;
typedef struct
{
cTimerValType type;
const char *heading;
const char *units;
union
{
int i;
long int l;
double d;
} val;
double seconds;
double resolution;
} cTimerVal;
The heading field is the name of the clock, the units
field holds a string describing the type held in the val field,
and the seconds field is the time elapsed in seconds. The
resolution field is the smallest non-zero difference in values
of two calls to the timer, in seconds. For example, it could reflect
that the clock saves the time value internally as an integer value
representing milliseconds.
To name and register the clock with the flesh, call the function
CCTK_ClockRegister( "my_clock_name", &clock_func ).
Appendices
45#45
3#3
Note that these appendices appear (identically) in both the
Cactus Users' Guide and the Cactus Reference Manual.
Next: Glossary
Up: UsersGuideStable
Previous: Recovery Invocation
Contents
|