@@ -427,39 +427,24 @@ static inline int red_sched_chain (int rank, int p, int root, const void *sendbu
427
427
428
428
/* last node does not recv */
429
429
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 ) {
433
431
res = NBC_Sched_recv ((char * )recvbuf + offset , false, thiscount , datatype , rpeer , schedule , true);
434
432
} 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
439
433
res = NBC_Sched_recv ((char * )offset , true, thiscount , datatype , rpeer , schedule , true);
440
434
}
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
- }
455
435
if (OPAL_UNLIKELY (OMPI_SUCCESS != res )) {
456
436
return res ;
457
437
}
458
438
459
439
/* root reduces into receivebuf */
460
440
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
+ }
463
448
} else {
464
449
res = NBC_Sched_op ((char * ) sendbuf + offset , false, (char * ) offset , true, thiscount ,
465
450
datatype , op , schedule , true);
0 commit comments