From f22a52b8c1ce7b1e8f6f03d4501a9537d689eb8f Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Mon, 30 Jan 2017 15:35:05 +0900 Subject: [PATCH] coll/libnbc: fix the red_schain algo of ireduce with MPI_IN_PLACE this fixes a regression introduced in open-mpi/ompi@045d0c5f4caffdf31fb2dd1cb4d7b8940c07d365 Fixes open-mpi/ompi#2879 Signed-off-by: Gilles Gouaillardet (back-ported from commit open-mpi/ompi@9bcadbd51bbb310903232f054d514497dc1a5147) --- ompi/mca/coll/libnbc/nbc_ireduce.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ompi/mca/coll/libnbc/nbc_ireduce.c b/ompi/mca/coll/libnbc/nbc_ireduce.c index cf3f18b19e6..cf78d073b16 100644 --- a/ompi/mca/coll/libnbc/nbc_ireduce.c +++ b/ompi/mca/coll/libnbc/nbc_ireduce.c @@ -7,7 +7,7 @@ * rights reserved. * Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2014-2016 Research Organization for Information Science + * Copyright (c) 2014-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * * Author(s): Torsten Hoefler @@ -425,10 +425,10 @@ static inline int red_sched_chain (int rank, int p, int root, const void *sendbu /* last node does not recv */ if (vrank != p-1) { - if (vrank == 0) { + if (vrank == 0 && sendbuf != recvbuf) { res = NBC_Sched_recv ((char *)recvbuf+offset, false, thiscount, datatype, rpeer, schedule, true); } else { - res = NBC_Sched_recv ((char *) offset, true, thiscount, datatype, rpeer, schedule, true); + res = NBC_Sched_recv ((char *)offset, true, thiscount, datatype, rpeer, schedule, true); } if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { return res; @@ -436,8 +436,13 @@ static inline int red_sched_chain (int rank, int p, int root, const void *sendbu /* root reduces into receivebuf */ if(vrank == 0) { - res = NBC_Sched_op ((char *) sendbuf + offset, false, (char *) recvbuf + offset, false, - thiscount, datatype, op, schedule, true); + if (sendbuf != recvbuf) { + res = NBC_Sched_op ((char *) sendbuf + offset, false, (char *) recvbuf + offset, false, + thiscount, datatype, op, schedule, true); + } else { + res = NBC_Sched_op ((char *)offset, true, (char *) recvbuf + offset, false, + thiscount, datatype, op, schedule, true); + } } else { res = NBC_Sched_op ((char *) sendbuf + offset, false, (char *) offset, true, thiscount, datatype, op, schedule, true);