MPI_WTIME(3)
π NAME π
MPI_Wtime β returns an elapsed time on the calling processor. that's it, that's the whole function, it's a stopwatch bestie π«Ά this page lives in the Open MPI manual set, so if you typed man MPI_Wtime and landed here, you're exactly where you're supposed to be.
β¨ SYNTAX β¨
C Syntax
#include <mpi.h>
double MPI_Wtime()
Fortran Syntax
USE MPI
! or the older form: INCLUDE 'mpif.h'
DOUBLE PRECISION MPI_WTIME()
Fortran 2008 Syntax
USE mpi_f08
DOUBLE PRECISION MPI_WTIME()
π RETURN VALUE π
Time in seconds since an arbitrary time in the past. yeah. arbitrary. it's not midnight, it's not the epoch, it's just some moment, and you only ever use it by subtracting two of them π
πΈ DESCRIPTION πΈ
MPI_Wtime hands you back a floating-point number of seconds β elapsed wall-clock time since some time in the past. like a stopwatch that started at a mystery moment and never told you which one π°οΈ
That "time in the past" is guaranteed not to change during the life of the process</>, so your deltas stay honest. But converting giant piles of seconds into other units (minutes, hours, "how long is this build gonna take", whatever) is on you β the function is not doing that math, bestie.
The whole point of this function is that it's:
- portable β it returns seconds, not "ticks", so your numbers mean something everywhere
- high resolution, no cap
- and it carries no unnecessary baggage. iconic behavior honestly π
you'd 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 you get back are local to the node that called them. there is no requirement that different nodes return the "same" time. so yes, node A and node B can just. disagree. and that's legal π don't do math across nodes assuming they match, okay?
π NOTES π
The boolean variable MPI_WTIME_IS_GLOBAL β a predefined attribute key that's supposed to tell you whether clocks are synchronized β does not have a valid value in Open MPI, because the clocks are not guaranteed to be synchronized. so like. don't trust it. it's giving empty promise π
This function is meant to be a high-resolution, elapsed (or wall) clock. to figure out the resolution of MPI_Wtime, go see MPI_Wtick.
On POSIX platforms, this function may use a timer that's cheaper to invoke than the gettimeofday() system call β but it'll fall back to gettimeofday() if a cheap high-resolution timer isn't available. you can consult the ompi_info(1) command to see whether Open MPI supports a native high-resolution timer on your platform. look for the value of βMPI_Wtime supportβ (or βoptions:mpi-wtimeβ when you're looking at the parsable output). if that value is βnativeβ, then a method that's likely cheaper than gettimeofday() is what's grabbing the time when MPI_Wtime gets invoked π₯
for example, on platforms that support it, the clock_gettime() function will be used to get a monotonic clock value with whatever precision that platform supports (e.g., nanoseconds β¨).
also worth knowing: the MCA parameter opal_timer_require_monotonic can influence this behavior. it defaults to true, but if you set it to false, Open MPI may use a finer-grained timing mechanism (e.g., the RDTSC/RDTSCP clock ticks on x86_64 platforms) β but that is not guaranteed to be monotonic in some cases, for example if the MPI process is not bound to a single processor core. ask yourself if you really want that tradeoff, bestie π
β οΈ This function does not return an error value. Consequently, the result of calling it beforeMPI_Initor afterMPI_Finalizeis undefined. like, undefined undefined. no error, no warning, just vibes. don't do it π
See also:
MPI_Wtick
π Copyright π
2003-2026, The Open MPI Community
and that's the whole page, bestie β you now know more about wall-clock timing than like 90% of people π¦ this was the MPI_WTIME(3) page, part of the Open MPI manual, dated Sep 10, 2026. go time something. slay. periodt π
β¨
π¦ where this page comes from
- ubuntu stonking: openmpi-doc 5.0.10-6 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms