Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
have last algos use also temporary buffers
authorAugustin Degomme <augustin.degomme@imag.fr>
Mon, 29 Sep 2014 13:17:04 +0000 (15:17 +0200)
committerAugustin Degomme <augustin.degomme@imag.fr>
Mon, 29 Sep 2014 13:17:04 +0000 (15:17 +0200)
src/smpi/colls/allreduce-ompi-ring-segmented.c
src/smpi/colls/gather-ompi.c
src/smpi/colls/reduce-flat-tree.c
src/smpi/colls/scatter-ompi.c

index d230b91..2812d86 100644 (file)
@@ -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;
 }
index 7b4bd61..b0da94d 100644 (file)
@@ -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 */
index 78be7fd..8a3140d 100644 (file)
@@ -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;
index 2d3dacd..9eace67 100644 (file)
@@ -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);