X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/15c8d6afaea3db0bc2e17884aa87868d987c2752..21446da234b79358c6f7ed918e582e7e5a36d8b3:/src/smpi/colls/reduce-mvapich-two-level.c diff --git a/src/smpi/colls/reduce-mvapich-two-level.c b/src/smpi/colls/reduce-mvapich-two-level.c index 8014a14481..be67ddd958 100644 --- a/src/smpi/colls/reduce-mvapich-two-level.c +++ b/src/smpi/colls/reduce-mvapich-two-level.c @@ -123,7 +123,7 @@ int smpi_coll_tuned_reduce_mvapich2_two_level( void *sendbuf, if (stride <= MV2_INTRA_SHMEM_REDUCE_MSG && is_commutative == 1) { if (local_rank == 0 ) { - tmp_buf=(void *)xbt_malloc( count * + tmp_buf=(void *)smpi_get_tmp_sendbuffer( count * (MAX(extent, true_extent))); tmp_buf = (void *) ((char *) tmp_buf - true_lb); } @@ -191,7 +191,7 @@ int smpi_coll_tuned_reduce_mvapich2_two_level( void *sendbuf, } leader_comm_size = smpi_comm_size(leader_comm); leader_comm_rank = smpi_comm_rank(leader_comm); - tmp_buf=(void *)xbt_malloc(count * + tmp_buf=(void *)smpi_get_tmp_sendbuffer(count * (MAX(extent, true_extent))); tmp_buf = (void *) ((char *) tmp_buf - true_lb); } @@ -233,6 +233,7 @@ int smpi_coll_tuned_reduce_mvapich2_two_level( void *sendbuf, intra_node_root, shmem_comm); } } else { + smpi_free_tmp_buffer((void *) ((char *) tmp_buf + true_lb)); tmp_buf = in_buf; } @@ -251,7 +252,7 @@ int smpi_coll_tuned_reduce_mvapich2_two_level( void *sendbuf, out_buf = recvbuf; } else { - in_buf = (char *)xbt_malloc(count* + in_buf = (char *)smpi_get_tmp_sendbuffer(count* smpi_datatype_get_extent(datatype)); smpi_datatype_copy(tmp_buf, count, datatype, in_buf, count, datatype); @@ -259,7 +260,7 @@ int smpi_coll_tuned_reduce_mvapich2_two_level( void *sendbuf, out_buf = recvbuf; } } else { - in_buf = (char *)xbt_malloc(count* + in_buf = (char *)smpi_get_tmp_sendbuffer(count* smpi_datatype_get_extent(datatype)); smpi_datatype_copy(tmp_buf, count, datatype, in_buf, count, datatype); @@ -286,15 +287,23 @@ int smpi_coll_tuned_reduce_mvapich2_two_level( void *sendbuf, smpi_mpi_send(tmp_buf, count, datatype, root, COLL_TAG_REDUCE+1, comm); } - if ((local_rank != 0) && (root == my_rank)) { smpi_mpi_recv(recvbuf, count, datatype, leader_of_root, COLL_TAG_REDUCE+1, comm, MPI_STATUS_IGNORE); } + smpi_free_tmp_buffer((void *) ((char *) tmp_buf + true_lb)); + + if (leader_comm_rank == leader_root) { + if (my_rank != root || (my_rank == root && tmp_buf == recvbuf)) { + smpi_free_tmp_buffer(in_buf); + } + } } + + fn_exit: return mpi_errno; }