Skip to content

Commit 9bcadbd

Browse files
committed
coll/libnbc: fix the red_schain algo of ireduce with MPI_IN_PLACE
this fixes a regression introduced in 045d0c5 Fixes #2879 Signed-off-by: Gilles Gouaillardet <[email protected]>
1 parent b12ab2b commit 9bcadbd

File tree

1 file changed

+8
-23
lines changed

1 file changed

+8
-23
lines changed

ompi/mca/coll/libnbc/nbc_ireduce.c

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -427,39 +427,24 @@ static inline int red_sched_chain (int rank, int p, int root, const void *sendbu
427427

428428
/* last node does not recv */
429429
if (vrank != p-1) {
430-
if (vrank == 0) {
431-
if (sendbuf != recvbuf) {
432-
// for regular src, recv into recvbuf
430+
if (vrank == 0 && sendbuf != recvbuf) {
433431
res = NBC_Sched_recv ((char *)recvbuf+offset, false, thiscount, datatype, rpeer, schedule, true);
434432
} else {
435-
// but for any-src, recv into tmpbuf
436-
// because for MPI_IN_PLACE if we recved into recvbuf here we'd be
437-
// overwriting our sendbuf, and we use it in the operation
438-
// that happens further down
439433
res = NBC_Sched_recv ((char *)offset, true, thiscount, datatype, rpeer, schedule, true);
440434
}
441-
} else {
442-
if (sendbuf != recvbuf) {
443-
// for regular src, add sendbuf into recvbuf
444-
// (here recvbuf holds the reduction from 1..n-1)
445-
res = NBC_Sched_op ((char *) sendbuf + offset, false, (char *) recvbuf + offset, false,
446-
thiscount, datatype, op, schedule, true);
447-
} else {
448-
// for MPI_IN_PLACE, add tmpbuf into recvbuf
449-
// (here tmpbuf holds the reduction from 1..n-1) and
450-
// recvbuf is our sendbuf
451-
res = NBC_Sched_op ((char *) offset, true, (char *) recvbuf + offset, false,
452-
thiscount, datatype, op, schedule, true);
453-
}
454-
}
455435
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
456436
return res;
457437
}
458438

459439
/* root reduces into receivebuf */
460440
if(vrank == 0) {
461-
res = NBC_Sched_op ((char *) sendbuf + offset, false, (char *) recvbuf + offset, false,
462-
thiscount, datatype, op, schedule, true);
441+
if (sendbuf != recvbuf) {
442+
res = NBC_Sched_op ((char *) sendbuf + offset, false, (char *) recvbuf + offset, false,
443+
thiscount, datatype, op, schedule, true);
444+
} else {
445+
res = NBC_Sched_op ((char *)offset, true, (char *) recvbuf + offset, false,
446+
thiscount, datatype, op, schedule, true);
447+
}
463448
} else {
464449
res = NBC_Sched_op ((char *) sendbuf + offset, false, (char *) offset, true, thiscount,
465450
datatype, op, schedule, true);

0 commit comments

Comments
 (0)