Skip to content
This repository was archived by the owner on Sep 30, 2022. It is now read-only.

Commit 65ce601

Browse files
bosilcaggouaillardet
authored andcommitted
Give a boost to MPI_Barrier.
Based on current implementation it is faster to use a blocking send than the non-blocking version. Switch the exchange function used in the barrier to use the blocking version combined with the non-blocking version of the receive. (cherry picked from commit open-mpi/ompi@223d755)
1 parent 977a96e commit 65ce601

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

ompi/mca/coll/base/coll_base_barrier.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,26 @@
4141
* signal a two peer synchronization.
4242
*/
4343
static inline int
44-
ompi_coll_base_sendrecv_zero(int dest, int stag,
44+
ompi_coll_base_sendrecv_zero( int dest, int stag,
4545
int source, int rtag,
46-
MPI_Comm comm)
46+
MPI_Comm comm )
4747

4848
{
49-
int err, line = 0;
50-
ompi_request_t* reqs[2];
51-
ompi_status_public_t statuses[2];
49+
int err, rc, line = 0;
50+
ompi_request_t* reqs[1];
51+
ompi_status_public_t statuses[1];
5252

5353
/* post new irecv */
5454
err = MCA_PML_CALL(irecv( NULL, 0, MPI_BYTE, source, rtag,
55-
comm, &reqs[0]));
55+
comm, &reqs[0] ));
5656
if (err != MPI_SUCCESS) { line = __LINE__; goto error_handler; }
5757

5858
/* send data to children */
59-
err = MCA_PML_CALL(isend( NULL, 0, MPI_BYTE, dest, stag,
60-
MCA_PML_BASE_SEND_STANDARD, comm, &reqs[1]));
61-
if (err != MPI_SUCCESS) { line = __LINE__; goto error_handler; }
59+
rc = MCA_PML_CALL(send( NULL, 0, MPI_BYTE, dest, stag,
60+
MCA_PML_BASE_SEND_STANDARD, comm ));
61+
if (rc != MPI_SUCCESS) { line = __LINE__; err = rc; goto error_handler; }
6262

63-
err = ompi_request_wait_all( 2, reqs, statuses );
63+
err = ompi_request_wait( &reqs[0], &statuses[0] );
6464
if( MPI_ERR_IN_STATUS == err ) { line = __LINE__;
6565
/* As we use wait_all we will get MPI_ERR_IN_STATUS which is not an error
6666
* code that we can propagate up the stack. Instead, look for the real
@@ -199,8 +199,8 @@ int ompi_coll_base_barrier_intra_recursivedoubling(struct ompi_communicator_t *c
199199
/* send message to lower ranked node */
200200
remote = rank - adjsize;
201201
err = ompi_coll_base_sendrecv_zero(remote, MCA_COLL_BASE_TAG_BARRIER,
202-
remote, MCA_COLL_BASE_TAG_BARRIER,
203-
comm);
202+
remote, MCA_COLL_BASE_TAG_BARRIER,
203+
comm);
204204
if (err != MPI_SUCCESS) { line = __LINE__; goto err_hndl;}
205205

206206
} else if (rank < (size - adjsize)) {
@@ -224,8 +224,8 @@ int ompi_coll_base_barrier_intra_recursivedoubling(struct ompi_communicator_t *c
224224

225225
/* post receive from the remote node */
226226
err = ompi_coll_base_sendrecv_zero(remote, MCA_COLL_BASE_TAG_BARRIER,
227-
remote, MCA_COLL_BASE_TAG_BARRIER,
228-
comm);
227+
remote, MCA_COLL_BASE_TAG_BARRIER,
228+
comm);
229229
if (err != MPI_SUCCESS) { line = __LINE__; goto err_hndl;}
230230
}
231231
}
@@ -273,8 +273,8 @@ int ompi_coll_base_barrier_intra_bruck(struct ompi_communicator_t *comm,
273273

274274
/* send message to lower ranked node */
275275
err = ompi_coll_base_sendrecv_zero(to, MCA_COLL_BASE_TAG_BARRIER,
276-
from, MCA_COLL_BASE_TAG_BARRIER,
277-
comm);
276+
from, MCA_COLL_BASE_TAG_BARRIER,
277+
comm);
278278
if (err != MPI_SUCCESS) { line = __LINE__; goto err_hndl;}
279279
}
280280

@@ -307,8 +307,8 @@ int ompi_coll_base_barrier_intra_two_procs(struct ompi_communicator_t *comm,
307307
remote = (remote + 1) & 0x1;
308308

309309
err = ompi_coll_base_sendrecv_zero(remote, MCA_COLL_BASE_TAG_BARRIER,
310-
remote, MCA_COLL_BASE_TAG_BARRIER,
311-
comm);
310+
remote, MCA_COLL_BASE_TAG_BARRIER,
311+
comm);
312312
return (err);
313313
}
314314

0 commit comments

Comments
 (0)