Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix dead assignments.
[simgrid.git] / src / smpi / colls / scatter-ompi.c
index 205d602..2d3dacd 100644 (file)
@@ -1,3 +1,9 @@
+/* Copyright (c) 2013-2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
 /*
  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
  *                         University Research and Technology
  *                         University of Stuttgart.  All rights reserved.
  * Copyright (c) 2004-2005 The Regents of the University of California.
  *                         All rights reserved.
- * $COPYRIGHT$
  *
  * Additional copyrights may follow
- *
- * $HEADER$
  */
 
 
 #include "colls_private.h"
 #include "coll_tuned_topo.h"
 
-#define MCA_COLL_BASE_TAG_SCATTER 111
 
 int
 smpi_coll_tuned_scatter_ompi_binomial(void *sbuf, int scount,
@@ -101,7 +103,7 @@ smpi_coll_tuned_scatter_ompi_binomial(void *sbuf, int scount,
        }
        total_send = scount;
     } else if (!(vrank % 2)) {
-       /* non-root, non-leaf nodes, allocte temp buffer for recv
+       /* 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);
        if (NULL == tempbuf) {
@@ -123,10 +125,9 @@ smpi_coll_tuned_scatter_ompi_binomial(void *sbuf, int scount,
        if (rank != root) {
            /* recv from parent on non-root */
            smpi_mpi_recv(ptmp, rcount*size, rdtype, bmtree->tree_prev,
-                                   MCA_COLL_BASE_TAG_SCATTER, comm, &status);
+                                   COLL_TAG_SCATTER, comm, &status);
            /* local copy to rbuf */
-           err = smpi_datatype_copy(ptmp, scount, sdtype,
-                                 rbuf, rcount, rdtype);
+           smpi_datatype_copy(ptmp, scount, sdtype, rbuf, rcount, rdtype);
        }
        /* send to children on all non-leaf */
        for (i = 0; i < bmtree->tree_nextsize; i++) {
@@ -140,20 +141,24 @@ smpi_coll_tuned_scatter_ompi_binomial(void *sbuf, int scount,
 
            smpi_mpi_send(ptmp + total_send*sextent, mycount, sdtype,
                                    bmtree->tree_next[i],
-                                   MCA_COLL_BASE_TAG_SCATTER,
+                                   COLL_TAG_SCATTER,
                                     comm);
 
            total_send += mycount;
        }
 
-       if (NULL != tempbuf) 
-           free(tempbuf);
+
     } else {
        /* recv from parent on leaf nodes */
        smpi_mpi_recv(ptmp, rcount, rdtype, bmtree->tree_prev,
-                               MCA_COLL_BASE_TAG_SCATTER, comm, &status);
+                               COLL_TAG_SCATTER, comm, &status);
     }
 
+    if (NULL != tempbuf)
+      free(tempbuf);
+    //!FIXME : store the tree, as done in ompi, instead of calculating it each time ?
+    xbt_free(bmtree);
+
     return MPI_SUCCESS;
 
  err_hndl:
@@ -207,7 +212,7 @@ smpi_coll_tuned_scatter_ompi_basic_linear(void *sbuf, int scount,
 
     if (rank != root) {
         smpi_mpi_recv(rbuf, rcount, rdtype, root,
-                                MCA_COLL_BASE_TAG_SCATTER,
+                                COLL_TAG_SCATTER,
                                 comm, MPI_STATUS_IGNORE);
         return MPI_SUCCESS;
     }
@@ -232,7 +237,7 @@ smpi_coll_tuned_scatter_ompi_basic_linear(void *sbuf, int scount,
             }
         } else {
             smpi_mpi_send(ptmp, scount, sdtype, i,
-                                    MCA_COLL_BASE_TAG_SCATTER,
+                                    COLL_TAG_SCATTER,
                                      comm);
         }
         if (MPI_SUCCESS != err) {