@@ -48,7 +48,7 @@ mca_coll_inter_allreduce_inter(const void *sbuf, void *rbuf, int count,
4848 mca_coll_base_module_t * module )
4949{
5050 int err , rank , root = 0 ;
51- char * tmpbuf = NULL , * pml_buffer = NULL ;
51+ char * tmpbuf = NULL , * pml_buffer = NULL , * source ;
5252 ptrdiff_t gap , span ;
5353
5454 rank = ompi_comm_rank (comm );
@@ -58,20 +58,21 @@ mca_coll_inter_allreduce_inter(const void *sbuf, void *rbuf, int count,
5858
5959 tmpbuf = (char * ) malloc (span );
6060 if (NULL == tmpbuf ) {
61- return OMPI_ERR_OUT_OF_RESOURCE ;
61+ return OMPI_ERR_OUT_OF_RESOURCE ;
6262 }
6363 pml_buffer = tmpbuf - gap ;
64+ source = (MPI_IN_PLACE == sbuf ) ? rbuf : sbuf ;
6465
65- err = comm -> c_local_comm -> c_coll -> coll_reduce (sbuf , pml_buffer , count ,
66- dtype , op , root ,
67- comm -> c_local_comm ,
68- comm -> c_local_comm -> c_coll -> coll_reduce_module );
66+ err = comm -> c_local_comm -> c_coll -> coll_reduce (source , pml_buffer , count ,
67+ dtype , op , root ,
68+ comm -> c_local_comm ,
69+ comm -> c_local_comm -> c_coll -> coll_reduce_module );
6970 if (OMPI_SUCCESS != err ) {
70- goto exit ;
71+ goto exit ;
7172 }
7273
7374 if (rank == root ) {
74- /* Do a send-recv between the two root procs. to avoid deadlock */
75+ /* Do a send-recv between the two root procs. to avoid deadlock */
7576 err = ompi_coll_base_sendrecv_actual (pml_buffer , count , dtype , 0 ,
7677 MCA_COLL_BASE_TAG_ALLREDUCE ,
7778 rbuf , count , dtype , 0 ,
@@ -84,8 +85,8 @@ mca_coll_inter_allreduce_inter(const void *sbuf, void *rbuf, int count,
8485
8586 /* bcast the message to all the local processes */
8687 err = comm -> c_local_comm -> c_coll -> coll_bcast (rbuf , count , dtype ,
87- root , comm -> c_local_comm ,
88- comm -> c_local_comm -> c_coll -> coll_bcast_module );
88+ root , comm -> c_local_comm ,
89+ comm -> c_local_comm -> c_coll -> coll_bcast_module );
8990 if (OMPI_SUCCESS != err ) {
9091 goto exit ;
9192 }
0 commit comments