Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of framagit.org:simgrid/simgrid
[simgrid.git] / src / smpi / colls / smpi_default_selector.cpp
index 546c2b7..3b8252a 100644 (file)
@@ -1,13 +1,12 @@
 /* selector with default/naive Simgrid algorithms. These should not be trusted for performance evaluations */
 
-/* Copyright (c) 2009-2010, 2013-2017. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2009-2019. 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. */
 
-#include "colls_private.h"
-#include "src/smpi/smpi_process.hpp"
+#include "colls_private.hpp"
+#include "src/smpi/include/smpi_actor.hpp"
 
 namespace simgrid{
 namespace smpi{
@@ -213,8 +212,10 @@ int Coll_reduce_default::reduce(void *sendbuf, void *recvbuf, int count, MPI_Dat
 
   int rank = comm->rank();
   int size = comm->size();
+  if (size <= 0)
+    return MPI_ERR_COMM;
   //non commutative case, use a working algo from openmpi
-  if(op != MPI_OP_NULL && !op->is_commutative()){
+  if (op != MPI_OP_NULL && not op->is_commutative()) {
     return Coll_reduce_ompi_basic_linear::reduce(sendtmpbuf, recvbuf, count, datatype, op, root, comm);
   }
 
@@ -222,7 +223,7 @@ int Coll_reduce_default::reduce(void *sendbuf, void *recvbuf, int count, MPI_Dat
     sendtmpbuf = static_cast<char *>(smpi_get_tmp_sendbuffer(count*datatype->get_extent()));
     Datatype::copy(recvbuf, count, datatype,sendtmpbuf, count, datatype);
   }
-  
+
   if(rank != root) {
     // Send buffer to root
     Request::send(sendtmpbuf, count, datatype, root, system_tag, comm);
@@ -237,7 +238,7 @@ int Coll_reduce_default::reduce(void *sendbuf, void *recvbuf, int count, MPI_Dat
     int index = 0;
     for (int src = 0; src < size; src++) {
       if (src != root) {
-         if (!smpi_process()->replaying())
+        if (not smpi_process()->replaying())
           tmpbufs[index] = xbt_malloc(count * dataext);
          else
            tmpbufs[index] = smpi_get_tmp_sendbuffer(count * dataext);
@@ -275,9 +276,9 @@ int Coll_reduce_default::reduce(void *sendbuf, void *recvbuf, int count, MPI_Dat
 int Coll_allreduce_default::allreduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
 {
   int ret;
-  ret = Colls::reduce(sendbuf, recvbuf, count, datatype, op, 0, comm);
+  ret = Coll_reduce_default::reduce(sendbuf, recvbuf, count, datatype, op, 0, comm);
   if(ret==MPI_SUCCESS)
-    ret = Colls::bcast(recvbuf, count, datatype, 0, comm);
+    ret = Coll_bcast_default::bcast(recvbuf, count, datatype, 0, comm);
   return ret;
 }
 
@@ -337,7 +338,7 @@ int Coll_alltoallv_default::alltoallv(void *sendbuf, int *sendcounts, int *sendd
     XBT_DEBUG("<%d> wait for %d requests", rank, count);
     Request::waitall(count, requests, MPI_STATUS_IGNORE);
     for(i = 0; i < count; i++) {
-      if(requests[i]!=MPI_REQUEST_NULL) 
+      if(requests[i]!=MPI_REQUEST_NULL)
         Request::unref(&requests[i]);
     }
     xbt_free(requests);