Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Welcome to simgrid::smpi::Op
[simgrid.git] / src / smpi / smpi_base.cpp
index 6efaa9b..94fa819 100644 (file)
@@ -323,7 +323,7 @@ void smpi_mpi_reduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datat
   int rank = comm->rank();
   int size = comm->size();
   //non commutative case, use a working algo from openmpi
-  if(!smpi_op_is_commute(op)){
+  if(op != MPI_OP_NULL && !op->is_commutative()){
     smpi_coll_tuned_reduce_ompi_basic_linear(sendtmpbuf, recvbuf, count, datatype, op, root, comm);
     return;
   }
@@ -367,7 +367,7 @@ void smpi_mpi_reduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datat
         Request::unuse(&requests[index]);
       }
       if(op) /* op can be MPI_OP_NULL that does nothing */
-        smpi_op_apply(op, tmpbufs[index], recvbuf, &count, &datatype);
+        if(op!=MPI_OP_NULL) op->apply( tmpbufs[index], recvbuf, &count, &datatype);
     }
       for(index = 0; index < size - 1; index++) {
         smpi_free_tmp_buffer(tmpbufs[index]);
@@ -417,7 +417,7 @@ void smpi_mpi_scan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatyp
   // Wait for completion of all comms.
   Request::startall(size - 1, requests);
 
-  if(smpi_op_is_commute(op)){
+  if(op != MPI_OP_NULL && op->is_commutative()){
     for (int other = 0; other < size - 1; other++) {
       index = Request::waitany(size - 1, requests, MPI_STATUS_IGNORE);
       if(index == MPI_UNDEFINED) {
@@ -425,7 +425,7 @@ void smpi_mpi_scan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatyp
       }
       if(index < rank) {
         // #Request is below rank: it's a irecv
-        smpi_op_apply(op, tmpbufs[index], recvbuf, &count, &datatype);
+        if(op!=MPI_OP_NULL) op->apply( tmpbufs[index], recvbuf, &count, &datatype);
       }
     }
   }else{
@@ -433,7 +433,7 @@ void smpi_mpi_scan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatyp
     for (int other = 0; other < size - 1; other++) {
       Request::wait(&(requests[other]), MPI_STATUS_IGNORE);
       if(index < rank) {
-        smpi_op_apply(op, tmpbufs[other], recvbuf, &count, &datatype);
+        if(op!=MPI_OP_NULL) op->apply( tmpbufs[other], recvbuf, &count, &datatype);
       }
     }
   }
@@ -474,7 +474,7 @@ void smpi_mpi_exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datat
   // Wait for completion of all comms.
   Request::startall(size - 1, requests);
 
-  if(smpi_op_is_commute(op)){
+  if(op != MPI_OP_NULL && op->is_commutative()){
     for (int other = 0; other < size - 1; other++) {
       index = Request::waitany(size - 1, requests, MPI_STATUS_IGNORE);
       if(index == MPI_UNDEFINED) {
@@ -486,7 +486,7 @@ void smpi_mpi_exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datat
           recvbuf_is_empty=0;
         } else
           // #Request is below rank: it's a irecv
-          smpi_op_apply(op, tmpbufs[index], recvbuf, &count, &datatype);
+          if(op!=MPI_OP_NULL) op->apply( tmpbufs[index], recvbuf, &count, &datatype);
       }
     }
   }else{
@@ -498,7 +498,7 @@ void smpi_mpi_exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datat
           smpi_datatype_copy(tmpbufs[other], count, datatype, recvbuf, count, datatype);
           recvbuf_is_empty = 0;
         } else
-          smpi_op_apply(op, tmpbufs[other], recvbuf, &count, &datatype);
+          if(op!=MPI_OP_NULL) op->apply( tmpbufs[other], recvbuf, &count, &datatype);
       }
     }
   }