X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/15c8d6afaea3db0bc2e17884aa87868d987c2752..21446da234b79358c6f7ed918e582e7e5a36d8b3:/src/smpi/colls/reduce-scatter-gather.c diff --git a/src/smpi/colls/reduce-scatter-gather.c b/src/smpi/colls/reduce-scatter-gather.c index 30d5e6e9b4..98f2a097fa 100644 --- a/src/smpi/colls/reduce-scatter-gather.c +++ b/src/smpi/colls/reduce-scatter-gather.c @@ -21,7 +21,7 @@ int smpi_coll_tuned_reduce_scatter_gather(void *sendbuf, void *recvbuf, int recv_idx, last_idx = 0, newdst; int dst, send_cnt, recv_cnt, newroot, newdst_tree_root; int newroot_tree_root, new_count; - int tag = COLL_TAG_REDUCE; + int tag = COLL_TAG_REDUCE,temporary_buffer=0; void *send_ptr, *recv_ptr, *tmp_buf; cnts = NULL; @@ -40,7 +40,8 @@ int smpi_coll_tuned_reduce_scatter_gather(void *sendbuf, void *recvbuf, /* If I'm not the root, then my recvbuf may not be valid, therefore I have to allocate a temporary one */ if (rank != root && !recvbuf) { - recvbuf = (void *)xbt_malloc(count * extent); + temporary_buffer=1; + recvbuf = (void *)smpi_get_tmp_recvbuffer(count * extent); } /* find nearest power-of-two less than or equal to comm_size */ pof2 = 1; @@ -50,9 +51,9 @@ int smpi_coll_tuned_reduce_scatter_gather(void *sendbuf, void *recvbuf, if (count < comm_size) { new_count = comm_size; - send_ptr = (void *) xbt_malloc(new_count * extent); - recv_ptr = (void *) xbt_malloc(new_count * extent); - tmp_buf = (void *) xbt_malloc(new_count * extent); + send_ptr = (void *) smpi_get_tmp_sendbuffer(new_count * extent); + recv_ptr = (void *) smpi_get_tmp_recvbuffer(new_count * extent); + tmp_buf = (void *) smpi_get_tmp_sendbuffer(new_count * extent); memcpy(send_ptr, sendbuf, extent * count); //if ((rank != root)) @@ -223,13 +224,13 @@ int smpi_coll_tuned_reduce_scatter_gather(void *sendbuf, void *recvbuf, } } memcpy(recvbuf, recv_ptr, extent * count); - free(send_ptr); - free(recv_ptr); + smpi_free_tmp_buffer(send_ptr); + smpi_free_tmp_buffer(recv_ptr); } else /* (count >= comm_size) */ { - tmp_buf = (void *) xbt_malloc(count * extent); + tmp_buf = (void *) smpi_get_tmp_sendbuffer(count * extent); //if ((rank != root)) smpi_mpi_sendrecv(sendbuf, count, datatype, rank, tag, @@ -400,7 +401,8 @@ int smpi_coll_tuned_reduce_scatter_gather(void *sendbuf, void *recvbuf, } } if (tmp_buf) - free(tmp_buf); + smpi_free_tmp_buffer(tmp_buf); + if(temporary_buffer==1) smpi_free_tmp_buffer(recvbuf); if (cnts) free(cnts); if (disps)