183. Timers and Synchronization


Up: Contents Next: Startup Previous: Error Classes, Error Codes, and Error Handlers

MPI defines a timer. A timer is specified even though it is not ``message-passing,'' because timing parallel programs is important in ``performance debugging'' and because existing timers (both in POSIX 1003.1-1988 and 1003.4D 14.1 and in Fortran 90) are either inconvenient or do not provide adequate access to high-resolution timers. See also Section Functions and Macros on page Functions and Macros .

double MPI_Wtime(void)
DOUBLE PRECISION MPI_WTIME()
{ double MPI::Wtime() (binding deprecated, see Section Deprecated since MPI-2.2 ) }
MPI_WTIME returns a floating-point number of seconds, representing elapsed wall-clock time since some time in the past.

The ``time in the past'' is guaranteed not to change during the life of the process. The user is responsible for converting large numbers of seconds to other units if they are preferred.

This function is portable (it returns seconds, not ``ticks''), it allows high-resolution, and carries no unnecessary baggage. One would use it like this:


{ 
   double starttime, endtime; 
   starttime = MPI_Wtime(); 
    ....  stuff to be timed  ... 
   endtime   = MPI_Wtime(); 
   printf("That took %f seconds\n",endtime-starttime); 
} 

The times returned are local to the node that called them. There is no requirement that different nodes return ``the same time.'' (But see also the discussion of MPI_WTIME_IS_GLOBAL).

double MPI_Wtick(void)
DOUBLE PRECISION MPI_WTICK()
{ double MPI::Wtick() (binding deprecated, see Section Deprecated since MPI-2.2 ) }
MPI_WTICK returns the resolution of MPI_WTIME in seconds. That is, it returns, as a double precision value, the number of seconds between successive clock ticks. For example, if the clock is implemented by the hardware as a counter that is incremented every millisecond, the value returned by MPI_WTICK should be 10-3.



Up: Contents Next: Startup Previous: Error Classes, Error Codes, and Error Handlers


Return to MPI-2.2 Standard Index
Return to MPI Forum Home Page

(Unofficial) MPI-2.2 of September 4, 2009
HTML Generated on September 10, 2009