1
1

* Clean up a little #if logic in MPI_WTICK / MPI_WTIME

* Update MPI_WTICK / MPI_WTIME man pages:
   * Fix C++ declarations
   * Note that we may use better than gettimeofday() on some platforms
 * Add "MPI_WTIME support" ("options:mpi-wtime") flag in ompi_info
   output indicating whether we use "native" or "gettimeofday" for
   MPI_WTIME

This commit was SVN r16774.
Этот коммит содержится в:
Jeff Squyres 2007-11-26 18:23:53 +00:00
родитель edb9d8e354
Коммит cf98657adb
5 изменённых файлов: 41 добавлений и 23 удалений

Просмотреть файл

@ -9,6 +9,7 @@
* University of Stuttgart. All rights reserved. * University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California. * Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved. * All rights reserved.
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
* *
* Additional copyrights may follow * Additional copyrights may follow
@ -42,17 +43,16 @@ double MPI_Wtick(void)
OPAL_CR_TEST_CHECKPOINT_READY(); OPAL_CR_TEST_CHECKPOINT_READY();
#if OPAL_TIMER_USEC_NATIVE #if OPAL_TIMER_USEC_NATIVE
/* We may or may not have native usec precision on Windows, so put
this #if before the #ifdef checking for Windows. */
return 0.000001; return 0.000001;
#else #elif defined(__WINDOWS__)
#if defined(__WINDOWS__)
if( (opal_timer_t)0 == opal_timer_base_get_freq() ) { if( (opal_timer_t)0 == opal_timer_base_get_freq() ) {
opal_output( 0, "No timer frequency\n" ); opal_output( 0, "No timer frequency\n" );
} }
return (double)opal_timer_base_get_freq(); return (double)opal_timer_base_get_freq();
#else #else
/* Otherwise, we already return usec precision. */
return 0.000001; return 0.000001;
#endif /* defined(__WINDOWS__) */ #endif
#endif /* OPAL_TIMER_USEC_NATIVE */
} }

Просмотреть файл

@ -44,20 +44,19 @@ double MPI_Wtime(void)
double wtime; double wtime;
#if OPAL_TIMER_USEC_NATIVE #if OPAL_TIMER_USEC_NATIVE
wtime = (double)opal_timer_base_get_usec() / 1000000.0; /* We may or may not have native usec precision on Windows, so put
#else this #if before the #ifdef checking for Windows. */
wtime = ((double) opal_timer_base_get_usec()) / 1000000.0;
#if defined(__WINDOWS__) #elif defined(__WINDOWS__)
wtime = ((double)opal_timer_base_get_cycles()) / ((double)opal_timer_base_get_freq()); wtime = ((double) opal_timer_base_get_cycles()) /
return wtime; ((double) opal_timer_base_get_freq());
#else #else
/* Fall back to gettimeofday() if we have nothing else */
struct timeval tv; struct timeval tv;
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
wtime = tv.tv_sec; wtime = tv.tv_sec;
wtime += (double)tv.tv_usec / 1000000.0; wtime += (double)tv.tv_usec / 1000000.0;
#endif /* defined(__WINDOWS__) */ #endif
#endif /* OPAL_TIMER_USEC_NATIVE */
OPAL_CR_TEST_CHECKPOINT_READY(); OPAL_CR_TEST_CHECKPOINT_READY();

Просмотреть файл

@ -19,7 +19,7 @@ DOUBLE PRECISION MPI_WTICK()
.SH C++ Syntax .SH C++ Syntax
.nf .nf
#include <mpi.h> #include <mpi.h>
double Wtick() double MPI::Wtick()
.SH RETURN VALUE .SH RETURN VALUE
.ft R .ft R
@ -27,16 +27,22 @@ Time in seconds of resolution of MPI_Wtime.
.SH DESCRIPTION .SH DESCRIPTION
.ft R .ft R
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. 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.
.PP
Note that on POSIX platforms, Open MPI should always return 10^-3 for
MPI_Wtick. The returned value may be different on Windows platforms.
.PP .PP
.SH NOTE
This function does not return an error value. Consequently, the result of calling it before MPI_Init or after MPI_Finalize is undefined.
.SH NOTE
This function does not return an error value. Consequently, the result
of calling it before MPI_Init or after MPI_Finalize is undefined.
.SH SEE ALSO .SH SEE ALSO
.ft R .ft R
.sp .sp
MPI_Wtime MPI_Wtime
' @(#)MPI_Wtick.3 1.21 06/03/09 ' @(#)MPI_Wtick.3 1.21 06/03/09

Просмотреть файл

@ -19,7 +19,7 @@ DOUBLE PRECISION MPI_WTIME()
.SH C++ Syntax .SH C++ Syntax
.nf .nf
#include <mpi.h> #include <mpi.h>
double Wtime() double MPI::Wtime()
.SH RETURN VALUE .SH RETURN VALUE
.ft R .ft R
@ -48,7 +48,17 @@ The times returned are local to the node that called them. There is no requireme
The boolean variable MPI_WTIME_IS_GLOBAL, a predefined attribute key that indicates whether clocks are synchronized, does not have a valid value in Open MPI, as the clocks are not guaranteed to be synchronized. The boolean variable MPI_WTIME_IS_GLOBAL, a predefined attribute key that indicates whether clocks are synchronized, does not have a valid value in Open MPI, as the clocks are not guaranteed to be synchronized.
.PP .PP
This is intended to be a high-resolution, elapsed (or wall) clock. See MPI_Wtick to determine the resolution of MPI_Wtime. This function is intended to be a high-resolution, elapsed (or wall) clock. See MPI_Wtick to determine the resolution of MPI_Wtime.
.PP
On POSIX platforms, this function may utilize a timer that is cheaper
to invoke than the gettimeofday() system call, but will fall back to
gettimeofday() if a cheap high-resolution timer is not available. The
ompi_info command can be consulted to see if Open MPI supports a
native high-resolution timer on your platform; see the value for "MPI_WTIME
support" (or "options:mpi-wtime" when viewing the parsable
output). If this value is "native", a method that is likely to be
cheaper than gettimeofday() will be used to obtain the time when
MPI_Wtime is invoked.
.PP .PP
This function does not return an error value. Consequently, the result of calling it before MPI_Init or after MPI_Finalize is undefined. This function does not return an error value. Consequently, the result of calling it before MPI_Init or after MPI_Finalize is undefined.

Просмотреть файл

@ -33,6 +33,7 @@
#include <netdb.h> #include <netdb.h>
#endif #endif
#include MCA_timer_IMPLEMENTATION_HEADER
#include "opal/mca/installdirs/installdirs.h" #include "opal/mca/installdirs/installdirs.h"
#include "opal/class/opal_value_array.h" #include "opal/class/opal_value_array.h"
#include "opal/util/printf.h" #include "opal/util/printf.h"
@ -353,6 +354,7 @@ void ompi_info::do_config(bool want_all)
"yes" : "no"); "yes" : "no");
const string sparse_groups(OMPI_GROUP_SPARSE ? "yes" : "no"); const string sparse_groups(OMPI_GROUP_SPARSE ? "yes" : "no");
const string have_mpi_io(OMPI_PROVIDE_MPI_FILE_INTERFACE ? "yes" : "no"); const string have_mpi_io(OMPI_PROVIDE_MPI_FILE_INTERFACE ? "yes" : "no");
const string wtime_support(OPAL_TIMER_USEC_NATIVE ? "native" : "gettimeofday");
if (OMPI_HAVE_SOLARIS_THREADS || OMPI_HAVE_POSIX_THREADS) { if (OMPI_HAVE_SOLARIS_THREADS || OMPI_HAVE_POSIX_THREADS) {
threads = OMPI_HAVE_SOLARIS_THREADS ? "solaris" : threads = OMPI_HAVE_SOLARIS_THREADS ? "solaris" :
@ -589,4 +591,5 @@ void ompi_info::do_config(bool want_all)
out("mpirun default --prefix", "mpirun:prefix_by_default", out("mpirun default --prefix", "mpirun:prefix_by_default",
mpirun_prefix_by_default); mpirun_prefix_by_default);
out("MPI I/O support", "options:mpi-io", have_mpi_io); out("MPI I/O support", "options:mpi-io", have_mpi_io);
out("MPI_WTIME support", "options:mpi-wtime", wtime_support);
} }