77 * of Tennessee Research Foundation. All rights
88 * reserved.
99 * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved.
10+ * Copyright (c) 2024 NVIDIA Corporation. All rights reserved.
1011 * $COPYRIGHT$
1112 *
1213 * Additional copyrights may follow
5354#include "ompi/mca/topo/base/base.h"
5455#include "opal/mca/pmix/base/base.h"
5556
56- #include "opal/mca/mpool/base/mpool_base_tree.h"
5757#include "ompi/mca/pml/base/pml_base_bsend.h"
5858#include "ompi/util/timings.h"
59+ #include "opal/mca/mpool/base/mpool_base_tree.h"
5960#include "opal/mca/pmix/pmix-internal.h"
61+ #include "opal/util/clock_gettime.h"
6062
6163ompi_predefined_instance_t ompi_mpi_instance_null = {{{{0 }}}};
6264
@@ -74,6 +76,14 @@ __opal_attribute_constructor__ static void instance_lock_init(void) {
7476/** MPI_Init instance */
7577ompi_instance_t * ompi_mpi_instance_default = NULL ;
7678
79+ /**
80+ * @brief: Base timer initialization. All timers returned to the user via MPI_Wtime
81+ * are relative to this timer. Setting it early in during the common
82+ * initialization (world or session model) allows for measuring the cost of
83+ * the MPI initialization.
84+ */
85+ struct timespec ompi_wtime_time_origin = {.tv_sec = 0 };
86+
7787enum {
7888 OMPI_INSTANCE_INITIALIZING = -1 ,
7989 OMPI_INSTANCE_FINALIZING = -2 ,
@@ -358,6 +368,10 @@ static int ompi_mpi_instance_init_common (int argc, char **argv)
358368 opal_pmix_lock_t mylock ;
359369 OMPI_TIMING_INIT (64 );
360370
371+ // We intentionally don't use the OPAL timer framework here. See
372+ // https://github.com/open-mpi/ompi/issues/3003 for more details.
373+ (void ) opal_clock_gettime (& ompi_wtime_time_origin );
374+
361375 ret = ompi_mpi_instance_retain ();
362376 if (OPAL_UNLIKELY (OMPI_SUCCESS != ret )) {
363377 return ret ;
0 commit comments