This is the README for the dl_timer library. The package aims to provide a simple, lightweight and portable timing API. It supports both shared- memory (OpenMP) and distributed memory (MPI) parallelism. However, mixed-mode/hybrid parallelism is not yet supported.
By default the library is configured to use the POSIX monotonic clock (as that has consistently good resolution). The following timers/clocks are also supported:
- the intrinsic Fortran timer (precision may be limited);
- the Intel RDTSC processor counter (requires Intel compiler);
- the C gettimeofday() routine (microsecond precision);
- the OpenMP omp_get_wtime() routine.
The timer to use may be changed at compile time by editing src/dl_timer.f90 and setting 'base_timer' to the appropriate value.
Two makefile targets are supported; sm_lib and dm_lib (for shared-memory and distributed-memory support, respectively). If OpenMP support is required then OMPFLAGS must be set appropriately (see below). In order to compile the dm_lib target you will require a working MPI installation.
The Makefiles pick up the compiler to use etc. from the following environment variables:
- F90 - the command with which to invoke the Fortran compiler
- F90FLAGS - flags to pass to the compiler, e.g. -g
- OMPFLAGS - the flag(s) required to enable OpenMP with the chosen compiler
- MPIF90 - the wrapper with which to invoke the Fortran compiler when building (and linking) with MPI. N.B. this is only required if MPI support is desired - i.e. the dm_lib target.
- CC - the command with which to invoke the C compiler
- CFLAGS - flags to pass to the C compiler
e.g. to build with Gnu Fortran I use:
export F90=gfortran
export F90FLAGS=-O3
export OMPFLAGS=-fopenmp
export MPIF90=mpif90
Common ways to set these variables for various compilers are provided in the compiler_setup directory.
There are examples of the usage of dl_timer in the test directory. In short though, it is used like so:
use dl_timer
integer :: itimer0
! Initialise timing system
call timer_init()
call timer_start(itimer0, label='Time-stepping')
... do some stuff
! Stop the timer for the time-stepping section
call timer_stop(itimer0)
call timer_report()
It is possible to pre-register timers in order to reduce the overhead associated with calling the timer_start() routine, e.g.:
! Initialise timing system
call timer_init()
call timer_register(itimer0, label='Time-stepping')
...
call timer_start(itimer0)
... do some stuff
! Stop the timer for the time-stepping section
call timer_stop(itimer0)
Note that dl_timer measures associated overheads at initialisation and outputs them in the report generated by timer_report().