|
9 | 9 | * reserved.
|
10 | 10 | * Copyright (c) 2014-2017 Research Organization for Information Science
|
11 | 11 | * and Technology (RIST). All rights reserved.
|
| 12 | + * Copyright (c) 2017 IBM Corporation. All rights reserved. |
12 | 13 | *
|
13 | 14 | * Author(s): Torsten Hoefler <[email protected]>
|
14 | 15 | *
|
@@ -427,9 +428,29 @@ static inline int red_sched_chain (int rank, int p, int root, const void *sendbu
|
427 | 428 | /* last node does not recv */
|
428 | 429 | if (vrank != p-1) {
|
429 | 430 | if (vrank == 0) {
|
430 |
| - res = NBC_Sched_recv ((char *)recvbuf+offset, false, thiscount, datatype, rpeer, schedule, true); |
| 431 | + if (sendbuf != recvbuf) { |
| 432 | + // for regular src, recv into recvbuf |
| 433 | + res = NBC_Sched_recv ((char *)recvbuf+offset, false, thiscount, datatype, rpeer, schedule, true); |
| 434 | + } else { |
| 435 | + // but for any-src, recv into tmpbuf |
| 436 | + // because for any-src 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 |
| 439 | + res = NBC_Sched_recv ((char *)offset, true, thiscount, datatype, rpeer, schedule, true); |
| 440 | + } |
431 | 441 | } else {
|
432 |
| - res = NBC_Sched_recv ((char *) offset, true, thiscount, datatype, rpeer, schedule, true); |
| 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 any-src, 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 | + } |
433 | 454 | }
|
434 | 455 | if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
|
435 | 456 | return res;
|
|
0 commit comments