Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Throw std::invalid_argument.
[simgrid.git] / src / smpi / colls / allreduce / allreduce-mvapich-two-level.cpp
index 9b8c0ad..3250168 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2014. The SimGrid Team.
+/* Copyright (c) 2013-2019. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  *      See COPYRIGHT in top-level directory.
  */
 
-#include "../colls_private.h"
+#include "../colls_private.hpp"
 
 #define MPIR_Allreduce_pt2pt_rd_MV2 Coll_allreduce_rdb::allreduce
 #define MPIR_Allreduce_pt2pt_rs_MV2 Coll_allreduce_mvapich2_rs::allreduce
 
-extern int (*MV2_Allreducection)(void *sendbuf,
+extern int (*MV2_Allreducection)(const void *sendbuf,
     void *recvbuf,
     int count,
     MPI_Datatype datatype,
     MPI_Op op, MPI_Comm comm);
 
 
-extern int (*MV2_Allreduce_intra_function)( void *sendbuf,
+extern int (*MV2_Allreduce_intra_function)(const void *sendbuf,
     void *recvbuf,
     int count,
     MPI_Datatype datatype,
     MPI_Op op, MPI_Comm comm);
-    
-    
+
+
 namespace simgrid{
 namespace smpi{
-static  int MPIR_Allreduce_reduce_p2p_MV2( void *sendbuf,
+static  int MPIR_Allreduce_reduce_p2p_MV2(const void *sendbuf,
     void *recvbuf,
     int count,
     MPI_Datatype datatype,
@@ -66,7 +66,7 @@ static  int MPIR_Allreduce_reduce_p2p_MV2( void *sendbuf,
   return MPI_SUCCESS;
 }
 
-static  int MPIR_Allreduce_reduce_shmem_MV2( void *sendbuf,
+static  int MPIR_Allreduce_reduce_shmem_MV2(const void *sendbuf,
     void *recvbuf,
     int count,
     MPI_Datatype datatype,
@@ -76,9 +76,9 @@ static  int MPIR_Allreduce_reduce_shmem_MV2( void *sendbuf,
   return MPI_SUCCESS;
 }
 
-    
+
 /* general two level allreduce helper function */
-int Coll_allreduce_mvapich2_two_level::allreduce(void *sendbuf,
+int Coll_allreduce_mvapich2_two_level::allreduce(const void *sendbuf,
                              void *recvbuf,
                              int count,
                              MPI_Datatype datatype,
@@ -95,11 +95,11 @@ int Coll_allreduce_mvapich2_two_level::allreduce(void *sendbuf,
       MV2_Allreduce_intra_function = Coll_allreduce_mpich::allreduce;
     if(MV2_Allreducection==NULL)
       MV2_Allreducection = Coll_allreduce_rdb::allreduce;
-    
+
     if(comm->get_leaders_comm()==MPI_COMM_NULL){
       comm->init_smp();
     }
-  
+
     if (count == 0) {
         return MPI_SUCCESS;
     }
@@ -122,7 +122,7 @@ int Coll_allreduce_mvapich2_two_level::allreduce(void *sendbuf,
 
     /* Doing the shared memory gather and reduction by the leader */
     if (local_rank == 0) {
-        if ((MV2_Allreduce_intra_function == &MPIR_Allreduce_reduce_shmem_MV2) || 
+        if ((MV2_Allreduce_intra_function == &MPIR_Allreduce_reduce_shmem_MV2) ||
               (MV2_Allreduce_intra_function == &MPIR_Allreduce_reduce_p2p_MV2) ) {
         mpi_errno =
         MV2_Allreduce_intra_function(sendbuf, recvbuf, count, datatype,
@@ -135,7 +135,7 @@ int Coll_allreduce_mvapich2_two_level::allreduce(void *sendbuf,
         }
 
         if (local_size != total_size) {
-          void* sendtmpbuf = (char *)smpi_get_tmp_sendbuffer(count*datatype->get_extent());
+          unsigned char* sendtmpbuf = smpi_get_tmp_sendbuffer(count * datatype->get_extent());
           Datatype::copy(recvbuf, count, datatype,sendtmpbuf, count, datatype);
             /* inter-node allreduce */
             if(MV2_Allreducection == &MPIR_Allreduce_pt2pt_rd_MV2){
@@ -151,7 +151,7 @@ int Coll_allreduce_mvapich2_two_level::allreduce(void *sendbuf,
         }
     } else {
         /* insert the first reduce here */
-        if ((MV2_Allreduce_intra_function == &MPIR_Allreduce_reduce_shmem_MV2) || 
+        if ((MV2_Allreduce_intra_function == &MPIR_Allreduce_reduce_shmem_MV2) ||
               (MV2_Allreduce_intra_function == &MPIR_Allreduce_reduce_p2p_MV2) ) {
         mpi_errno =
         MV2_Allreduce_intra_function(sendbuf, recvbuf, count, datatype,