Skip to content

Commit 6989a73

Browse files
committed
ompi/util/timings.h: use back-end OMPI calls
Noticed this while looking into other things: we have some timing macros in MPI_INIT and MPI_FINALIZE that were calling MPI_* functions. Change them to use the corresponding back-end ompi_* and pointer-based function calls so that we don't accidentally pollute calls to a profiled MPI library. Signed-off-by: Jeff Squyres <[email protected]>
1 parent 14fc749 commit 6989a73

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

ompi/util/timings.h

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
* Copyright (c) 2017-2018 Mellanox Technologies Ltd. All rights reserved.
33
* Copyright (c) 2017 Intel, Inc. All rights reserved.
4+
* Copyright (c) 2021-2022 Cisco Systems, Inc. All rights reserved
45
* $COPYRIGHT$
56
*
67
* Additional copyrights may follow
@@ -12,7 +13,6 @@
1213
#define OMPI_UTIL_TIMING_H
1314

1415
#include "opal/util/timings.h"
15-
/* TODO: we need access to MPI_* functions */
1616

1717
#if (OPAL_ENABLE_TIMING)
1818

@@ -166,14 +166,15 @@ typedef struct ompi_timing_t {
166166
#define OMPI_TIMING_OUT \
167167
do { \
168168
if (OMPI_TIMING.enabled) { \
169-
int i, size, rank; \
170-
MPI_Comm_size(MPI_COMM_WORLD, &size); \
171-
MPI_Comm_rank(MPI_COMM_WORLD, &rank); \
169+
int i; \
170+
int size = ompi_comm_size(MPI_COMM_WORLD); \
171+
int rank = ompi_comm_rank(MPI_COMM_WORLD); \
172172
int error = 0; \
173173
int imported = 0; \
174174
\
175-
MPI_Reduce(&OMPI_TIMING.error, &error, 1, \
176-
MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD); \
175+
MPI_COMM_WORLD->c_coll->coll_reduce(&OMPI_TIMING.error, &error, 1, \
176+
MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD, \
177+
MPI_COMM_WORLD->c_coll->coll_reduce_module); \
177178
\
178179
if (error) { \
179180
if (0 == rank) { \
@@ -196,12 +197,15 @@ typedef struct ompi_timing_t {
196197
do { \
197198
int use; \
198199
for (use = 0; use < timing->use; use++) { \
199-
MPI_Reduce(&timing->val[use].ts, avg + i, 1, \
200-
MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD); \
201-
MPI_Reduce(&timing->val[use].ts, min + i, 1, \
202-
MPI_DOUBLE, MPI_MIN, 0, MPI_COMM_WORLD); \
203-
MPI_Reduce(&timing->val[use].ts, max + i, 1, \
204-
MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD); \
200+
MPI_COMM_WORLD->c_coll->coll_reduce(&timing->val[use].ts, avg + i, 1, \
201+
MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD, \
202+
MPI_COMM_WORLD->c_coll->coll_reduce_module); \
203+
MPI_COMM_WORLD->c_coll->coll_reduce(&timing->val[use].ts, min + i, 1, \
204+
MPI_DOUBLE, MPI_MIN, 0, MPI_COMM_WORLD, \
205+
MPI_COMM_WORLD->c_coll->coll_reduce_module); \
206+
MPI_COMM_WORLD->c_coll->coll_reduce(&timing->val[use].ts, max + i, 1, \
207+
MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD, \
208+
MPI_COMM_WORLD->c_coll->coll_reduce_module); \
205209
desc[i] = timing->val[use].desc; \
206210
prefix[i] = timing->val[use].prefix; \
207211
file[i] = timing->val[use].file; \

0 commit comments

Comments
 (0)