From eafd94505db08868b1544f81da7d10a5c805a693 Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Mon, 29 Sep 2014 15:17:04 +0200 Subject: [PATCH] have last algos use also temporary buffers --- src/smpi/colls/allreduce-ompi-ring-segmented.c | 12 ++++++------ src/smpi/colls/gather-ompi.c | 6 +++--- src/smpi/colls/reduce-flat-tree.c | 4 ++-- src/smpi/colls/scatter-ompi.c | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/smpi/colls/allreduce-ompi-ring-segmented.c b/src/smpi/colls/allreduce-ompi-ring-segmented.c index d230b911ec..2812d86668 100644 --- a/src/smpi/colls/allreduce-ompi-ring-segmented.c +++ b/src/smpi/colls/allreduce-ompi-ring-segmented.c @@ -228,10 +228,10 @@ smpi_coll_tuned_allreduce_ompi_ring_segmented(void *sbuf, void *rbuf, int count, max_real_segsize = true_extent + (max_segcount - 1) * extent; /* Allocate and initialize temporary buffers */ - inbuf[0] = (char*)malloc(max_real_segsize); + inbuf[0] = (char*)smpi_get_tmp_sendbuffer(max_real_segsize); if (NULL == inbuf[0]) { ret = -1; line = __LINE__; goto error_hndl; } if (size > 2) { - inbuf[1] = (char*)malloc(max_real_segsize); + inbuf[1] = (char*)smpi_get_tmp_recvbuffer(max_real_segsize); if (NULL == inbuf[1]) { ret = -1; line = __LINE__; goto error_hndl; } } @@ -374,15 +374,15 @@ smpi_coll_tuned_allreduce_ompi_ring_segmented(void *sbuf, void *rbuf, int count, } - if (NULL != inbuf[0]) free(inbuf[0]); - if (NULL != inbuf[1]) free(inbuf[1]); + if (NULL != inbuf[0]) smpi_free_tmp_buffer(inbuf[0]); + if (NULL != inbuf[1]) smpi_free_tmp_buffer(inbuf[1]); return MPI_SUCCESS; error_hndl: XBT_DEBUG("%s:%4d\tRank %d Error occurred %d\n", __FILE__, line, rank, ret); - if (NULL != inbuf[0]) free(inbuf[0]); - if (NULL != inbuf[1]) free(inbuf[1]); + if (NULL != inbuf[0]) smpi_free_tmp_buffer(inbuf[0]); + if (NULL != inbuf[1]) smpi_free_tmp_buffer(inbuf[1]); return ret; } diff --git a/src/smpi/colls/gather-ompi.c b/src/smpi/colls/gather-ompi.c index 7b4bd61fa0..b0da94d480 100644 --- a/src/smpi/colls/gather-ompi.c +++ b/src/smpi/colls/gather-ompi.c @@ -77,7 +77,7 @@ smpi_coll_tuned_gather_ompi_binomial(void *sbuf, int scount, } else { /* root is not on 0, allocate temp buffer for recv, * rotate data at the end */ - tempbuf = (char *) malloc(rtrue_extent + (rcount*size - 1) * rextent); + tempbuf = (char *) smpi_get_tmp_recvbuffer(rtrue_extent + (rcount*size - 1) * rextent); if (NULL == tempbuf) { err= MPI_ERR_OTHER; line = __LINE__; goto err_hndl; } @@ -99,7 +99,7 @@ smpi_coll_tuned_gather_ompi_binomial(void *sbuf, int scount, /* other non-leaf nodes, allocate temp buffer for data received from * children, the most we need is half of the total data elements due * to the property of binimoal tree */ - tempbuf = (char *) malloc(strue_extent + (scount*size - 1) * sextent); + tempbuf = (char *) smpi_get_tmp_sendbuffer(strue_extent + (scount*size - 1) * sextent); if (NULL == tempbuf) { err= MPI_ERR_OTHER; line = __LINE__; goto err_hndl; } @@ -169,7 +169,7 @@ smpi_coll_tuned_gather_ompi_binomial(void *sbuf, int scount, (char *) rbuf,rcount*root,rdtype); if (MPI_SUCCESS != err) { line = __LINE__; goto err_hndl; } - free(tempbuf); + smpi_free_tmp_buffer(tempbuf); } } else if (!(vrank % 2)) { /* other non-leaf nodes */ diff --git a/src/smpi/colls/reduce-flat-tree.c b/src/smpi/colls/reduce-flat-tree.c index 78be7fd1f1..8a3140d5e0 100644 --- a/src/smpi/colls/reduce-flat-tree.c +++ b/src/smpi/colls/reduce-flat-tree.c @@ -35,7 +35,7 @@ smpi_coll_tuned_reduce_flat_tree(void *sbuf, void *rbuf, int count, messages. */ if (size > 1) - origin = (char *) xbt_malloc(count * extent); + origin = (char *) smpi_get_tmp_recvbuffer(count * extent); /* Initialize the receive buffer. */ @@ -61,7 +61,7 @@ smpi_coll_tuned_reduce_flat_tree(void *sbuf, void *rbuf, int count, } if (origin) - free(origin); + smpi_free_tmp_buffer(origin); /* All done */ return 0; diff --git a/src/smpi/colls/scatter-ompi.c b/src/smpi/colls/scatter-ompi.c index 2d3dacd2cf..9eace67529 100644 --- a/src/smpi/colls/scatter-ompi.c +++ b/src/smpi/colls/scatter-ompi.c @@ -77,7 +77,7 @@ smpi_coll_tuned_scatter_ompi_binomial(void *sbuf, int scount, } } else { /* root is not on 0, allocate temp buffer for send */ - tempbuf = (char *) malloc(strue_extent + (scount*size - 1) * sextent); + tempbuf = (char *) smpi_get_tmp_sendbuffer(strue_extent + (scount*size - 1) * sextent); if (NULL == tempbuf) { err = MPI_ERR_OTHER; line = __LINE__; goto err_hndl; } @@ -105,7 +105,7 @@ smpi_coll_tuned_scatter_ompi_binomial(void *sbuf, int scount, } else if (!(vrank % 2)) { /* non-root, non-leaf nodes, allocate temp buffer for recv * the most we need is rcount*size/2 */ - tempbuf = (char *) malloc(rtrue_extent + (rcount*size - 1) * rextent); + tempbuf = (char *) smpi_get_tmp_recvbuffer(rtrue_extent + (rcount*size - 1) * rextent); if (NULL == tempbuf) { err= MPI_ERR_OTHER; line = __LINE__; goto err_hndl; } @@ -155,7 +155,7 @@ smpi_coll_tuned_scatter_ompi_binomial(void *sbuf, int scount, } if (NULL != tempbuf) - free(tempbuf); + smpi_free_tmp_buffer(tempbuf); //!FIXME : store the tree, as done in ompi, instead of calculating it each time ? xbt_free(bmtree); -- 2.20.1