Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branches 'master' and 'master' of github.com:simgrid/simgrid
[simgrid.git] / src / smpi / colls / smpi_mpich_selector.cpp
index 8a9ffcd..7fd3910 100644 (file)
@@ -1,6 +1,6 @@
 /* selector for collective algorithms based on mpich decision logic */
 
-/* Copyright (c) 2009-2010, 2013-2014. The SimGrid Team.
+/* Copyright (c) 2009-2010, 2013-2017. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -56,6 +56,8 @@
 
    End Algorithm: MPI_Allreduce
 */
+namespace simgrid{
+namespace smpi{
 int Coll_allreduce_mpich::allreduce(void *sbuf, void *rbuf, int count,
                         MPI_Datatype dtype, MPI_Op op, MPI_Comm comm)
 {
@@ -358,9 +360,8 @@ int Coll_reduce_mpich::reduce( void *sendbuf, void *recvbuf,
     while (pof2 <= communicator_size) pof2 <<= 1;
     pof2 >>= 1;
 
-
-    if ((count < pof2) || (message_size < 2048) || (op!=MPI_OP_NULL && !op->is_commutative())) {
-        return Coll_reduce_binomial::reduce (sendbuf, recvbuf, count, datatype, op, root, comm); 
+    if ((count < pof2) || (message_size < 2048) || (op != MPI_OP_NULL && not op->is_commutative())) {
+      return Coll_reduce_binomial::reduce(sendbuf, recvbuf, count, datatype, op, root, comm); 
     }
         return Coll_reduce_scatter_gather::reduce(sendbuf, recvbuf, count, datatype, op, root, comm/*, module,
                                                      segsize, max_requests*/);
@@ -440,26 +441,27 @@ int Coll_reduce_scatter_mpich::reduce_scatter( void *sbuf, void *rbuf,
     if( (op==MPI_OP_NULL || op->is_commutative()) &&  total_message_size > 524288) { 
         return Coll_reduce_scatter_mpich_pair::reduce_scatter (sbuf, rbuf, rcounts, 
                                                                     dtype, op, 
-                                                                    comm); 
-    }else if ((op!=MPI_OP_NULL && !op->is_commutative())) {
-        int is_block_regular = 1;
-        for (i = 0; i < (comm_size - 1); ++i) {
-            if (rcounts[i] != rcounts[i+1]) {
-                is_block_regular = 0;
-                break;
-            }
+                                                                    comm);
+    } else if ((op != MPI_OP_NULL && not op->is_commutative())) {
+      int is_block_regular = 1;
+      for (i = 0; i < (comm_size - 1); ++i) {
+        if (rcounts[i] != rcounts[i + 1]) {
+          is_block_regular = 0;
+          break;
         }
+      }
 
-        /* slightly retask pof2 to mean pof2 equal or greater, not always greater as it is above */
-        int pof2 = 1;
-        while (pof2 < comm_size) pof2 <<= 1;
+      /* slightly retask pof2 to mean pof2 equal or greater, not always greater as it is above */
+      int pof2 = 1;
+      while (pof2 < comm_size)
+        pof2 <<= 1;
 
-        if (pof2 == comm_size && is_block_regular) {
-            /* noncommutative, pof2 size, and block regular */
-            return Coll_reduce_scatter_mpich_noncomm::reduce_scatter(sbuf, rbuf, rcounts, dtype, op, comm);
-        }
+      if (pof2 == comm_size && is_block_regular) {
+        /* noncommutative, pof2 size, and block regular */
+        return Coll_reduce_scatter_mpich_noncomm::reduce_scatter(sbuf, rbuf, rcounts, dtype, op, comm);
+      }
 
-       return Coll_reduce_scatter_mpich_rdb::reduce_scatter(sbuf, rbuf, rcounts, dtype, op, comm);
+      return Coll_reduce_scatter_mpich_rdb::reduce_scatter(sbuf, rbuf, rcounts, dtype, op, comm);
     }else{      
        return Coll_reduce_scatter_mpich_rdb::reduce_scatter(sbuf, rbuf, rcounts, dtype, op, comm);
     }
@@ -646,8 +648,6 @@ int Coll_allgatherv_mpich::allgatherv(void *sbuf, int scount,
 
    End Algorithm: MPI_Gather
 */
-namespace simgrid{
-namespace smpi{
 
 int Coll_gather_mpich::gather(void *sbuf, int scount, 
                                            MPI_Datatype sdtype,
@@ -662,9 +662,6 @@ int Coll_gather_mpich::gather(void *sbuf, int scount,
                                                       root, comm);
 }
 
-}
-}
-
 /* This is the default implementation of scatter. The algorithm is:
    
    Algorithm: MPI_Scatter
@@ -707,4 +704,6 @@ int Coll_scatter_mpich::scatter(void *sbuf, int scount,
   }
   return ret;
 }
+}
+}