Skip to content

Commit 07c0b68

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]> (back-ported from commit 9bcadbd)
1 parent 9c7ebf0 commit 07c0b68

File tree

1 file changed

+11
-27
lines changed

1 file changed

+11
-27
lines changed

ompi/mca/coll/libnbc/nbc_ireduce.c

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
* rights reserved.
88
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
99
* reserved.
10-
* Copyright (c) 2014-2016 Research Organization for Information Science
10+
* Copyright (c) 2014-2017 Research Organization for Information Science
1111
* and Technology (RIST). All rights reserved.
12-
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1312
*
1413
* Author(s): Torsten Hoefler <[email protected]>
1514
*
@@ -426,39 +425,24 @@ static inline int red_sched_chain (int rank, int p, int root, const void *sendbu
426425

427426
/* last node does not recv */
428427
if (vrank != p-1) {
429-
if (vrank == 0) {
430-
if (sendbuf != recvbuf) {
431-
// for regular src, recv into recvbuf
432-
res = NBC_Sched_recv ((char *)recvbuf+offset, false, thiscount, datatype, rpeer, schedule, true);
433-
} else {
434-
// but for any-src, recv into tmpbuf
435-
// because for MPI_IN_PLACE if we recved into recvbuf here we'd be
436-
// overwriting our sendbuf, and we use it in the operation
437-
// that happens further down
438-
res = NBC_Sched_recv ((char *)offset, true, thiscount, datatype, rpeer, schedule, true);
439-
}
428+
if (vrank == 0 && sendbuf != recvbuf) {
429+
res = NBC_Sched_recv ((char *)recvbuf+offset, false, thiscount, datatype, rpeer, schedule, true);
440430
} else {
441-
if (sendbuf != recvbuf) {
442-
// for regular src, add sendbuf into recvbuf
443-
// (here recvbuf holds the reduction from 1..n-1)
444-
res = NBC_Sched_op ((char *) sendbuf + offset, false, (char *) recvbuf + offset, false,
445-
thiscount, datatype, op, schedule, true);
446-
} else {
447-
// for MPI_IN_PLACE, add tmpbuf into recvbuf
448-
// (here tmpbuf holds the reduction from 1..n-1) and
449-
// recvbuf is our sendbuf
450-
res = NBC_Sched_op ((char *) offset, true, (char *) recvbuf + offset, false,
451-
thiscount, datatype, op, schedule, true);
452-
}
431+
res = NBC_Sched_recv ((char *)offset, true, thiscount, datatype, rpeer, schedule, true);
453432
}
454433
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
455434
return res;
456435
}
457436

458437
/* root reduces into receivebuf */
459438
if(vrank == 0) {
460-
res = NBC_Sched_op ((char *) sendbuf + offset, false, (char *) recvbuf + offset, false,
461-
thiscount, datatype, op, schedule, true);
439+
if (sendbuf != recvbuf) {
440+
res = NBC_Sched_op ((char *) sendbuf + offset, false, (char *) recvbuf + offset, false,
441+
thiscount, datatype, op, schedule, true);
442+
} else {
443+
res = NBC_Sched_op ((char *)offset, true, (char *) recvbuf + offset, false,
444+
thiscount, datatype, op, schedule, true);
445+
}
462446
} else {
463447
res = NBC_Sched_op ((char *) sendbuf + offset, false, (char *) offset, true, thiscount,
464448
datatype, op, schedule, true);

0 commit comments

Comments
 (0)