12
12
* All rights reserved.
13
13
* Copyright (c) 2013 Los Alamos National Security, LLC. All Rights
14
14
* reserved.
15
- * Copyright (c) 2015 Research Organization for Information Science
15
+ * Copyright (c) 2015-2016 Research Organization for Information Science
16
16
* and Technology (RIST). All rights reserved.
17
17
* $COPYRIGHT$
18
18
*
@@ -485,6 +485,7 @@ int ompi_coll_base_reduce_intra_in_order_binary( const void *sendbuf, void *recv
485
485
int ret , rank , size , io_root , segcount = count ;
486
486
void * use_this_sendbuf = NULL ;
487
487
void * use_this_recvbuf = NULL ;
488
+ char * tmpbuf_free = NULL ;
488
489
size_t typelng ;
489
490
mca_coll_base_module_t * base_module = (mca_coll_base_module_t * ) module ;
490
491
mca_coll_base_comm_t * data = base_module -> base_data ;
@@ -515,24 +516,26 @@ int ompi_coll_base_reduce_intra_in_order_binary( const void *sendbuf, void *recv
515
516
use_this_recvbuf = recvbuf ;
516
517
if (io_root != root ) {
517
518
ptrdiff_t dsize , gap ;
518
- char * tmpbuf = NULL ;
519
+ char * tmpbuf ;
519
520
520
521
dsize = opal_datatype_span (& datatype -> super , count , & gap );
521
522
522
523
if ((root == rank ) && (MPI_IN_PLACE == sendbuf )) {
523
- tmpbuf = (char * ) malloc (dsize );
524
- if (NULL == tmpbuf ) {
524
+ tmpbuf_free = (char * ) malloc (dsize );
525
+ if (NULL == tmpbuf_free ) {
525
526
return MPI_ERR_INTERN ;
526
527
}
528
+ tmpbuf = tmpbuf_free - gap ;
527
529
ompi_datatype_copy_content_same_ddt (datatype , count ,
528
530
(char * )tmpbuf ,
529
531
(char * )recvbuf );
530
532
use_this_sendbuf = tmpbuf ;
531
533
} else if (io_root == rank ) {
532
- tmpbuf = (char * ) malloc (dsize );
533
- if (NULL == tmpbuf ) {
534
+ tmpbuf_free = (char * ) malloc (dsize );
535
+ if (NULL == tmpbuf_free ) {
534
536
return MPI_ERR_INTERN ;
535
537
}
538
+ tmpbuf = tmpbuf_free - gap ;
536
539
use_this_recvbuf = tmpbuf ;
537
540
}
538
541
}
@@ -552,19 +555,18 @@ int ompi_coll_base_reduce_intra_in_order_binary( const void *sendbuf, void *recv
552
555
MCA_COLL_BASE_TAG_REDUCE , comm ,
553
556
MPI_STATUS_IGNORE ));
554
557
if (MPI_SUCCESS != ret ) { return ret ; }
555
- if (MPI_IN_PLACE == sendbuf ) {
556
- free (use_this_sendbuf );
557
- }
558
558
559
559
} else if (io_root == rank ) {
560
560
/* Send result from use_this_recvbuf to root */
561
561
ret = MCA_PML_CALL (send (use_this_recvbuf , count , datatype , root ,
562
562
MCA_COLL_BASE_TAG_REDUCE ,
563
563
MCA_PML_BASE_SEND_STANDARD , comm ));
564
564
if (MPI_SUCCESS != ret ) { return ret ; }
565
- free (use_this_recvbuf );
566
565
}
567
566
}
567
+ if (NULL != tmpbuf_free ) {
568
+ free (tmpbuf_free );
569
+ }
568
570
569
571
return MPI_SUCCESS ;
570
572
}
0 commit comments