Skip to content

Commit 223d755

Browse files
committed
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.
1 parent 3b68c1f commit 223d755

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
@@ -201,8 +201,8 @@ int ompi_coll_base_barrier_intra_recursivedoubling(struct ompi_communicator_t *c
201201
/* send message to lower ranked node */
202202
remote = rank - adjsize;
203203
err = ompi_coll_base_sendrecv_zero(remote, MCA_COLL_BASE_TAG_BARRIER,
204-
remote, MCA_COLL_BASE_TAG_BARRIER,
205-
comm);
204+
remote, MCA_COLL_BASE_TAG_BARRIER,
205+
comm);
206206
if (err != MPI_SUCCESS) { line = __LINE__; goto err_hndl;}
207207

208208
} else if (rank < (size - adjsize)) {
@@ -226,8 +226,8 @@ int ompi_coll_base_barrier_intra_recursivedoubling(struct ompi_communicator_t *c
226226

227227
/* post receive from the remote node */
228228
err = ompi_coll_base_sendrecv_zero(remote, MCA_COLL_BASE_TAG_BARRIER,
229-
remote, MCA_COLL_BASE_TAG_BARRIER,
230-
comm);
229+
remote, MCA_COLL_BASE_TAG_BARRIER,
230+
comm);
231231
if (err != MPI_SUCCESS) { line = __LINE__; goto err_hndl;}
232232
}
233233
}
@@ -276,8 +276,8 @@ int ompi_coll_base_barrier_intra_bruck(struct ompi_communicator_t *comm,
276276

277277
/* send message to lower ranked node */
278278
err = ompi_coll_base_sendrecv_zero(to, MCA_COLL_BASE_TAG_BARRIER,
279-
from, MCA_COLL_BASE_TAG_BARRIER,
280-
comm);
279+
from, MCA_COLL_BASE_TAG_BARRIER,
280+
comm);
281281
if (err != MPI_SUCCESS) { line = __LINE__; goto err_hndl;}
282282
}
283283

@@ -311,8 +311,8 @@ int ompi_coll_base_barrier_intra_two_procs(struct ompi_communicator_t *comm,
311311
remote = (remote + 1) & 0x1;
312312

313313
err = ompi_coll_base_sendrecv_zero(remote, MCA_COLL_BASE_TAG_BARRIER,
314-
remote, MCA_COLL_BASE_TAG_BARRIER,
315-
comm);
314+
remote, MCA_COLL_BASE_TAG_BARRIER,
315+
comm);
316316
return (err);
317317
}
318318

0 commit comments

Comments
 (0)