Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use type bool for boolean variables in smpi::Comm too.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 26 Dec 2019 23:00:36 +0000 (00:00 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 27 Dec 2019 11:13:49 +0000 (12:13 +0100)
Don't touch members is_blocked_ and is_uniform_ which are used by MPI
communications with type MPI_INT.

src/smpi/colls/allgather/allgather-mvapich-smp.cpp
src/smpi/colls/smpi_mpich_selector.cpp
src/smpi/include/smpi_comm.hpp
src/smpi/mpi/smpi_comm.cpp

index c8e0600..f1d2855 100644 (file)
@@ -100,7 +100,7 @@ int allgather__mvapich2_smp(const void *sendbuf,int sendcnt, MPI_Datatype sendty
     /* Exchange the data between the node leaders*/
     if (local_rank == 0 && (leader_comm_size > 1)) {
         /*When data in each socket is different*/
-        if (comm->is_uniform() != 1) {
+        if (not comm->is_uniform()) {
 
             int *node_sizes = NULL;
             int i = 0;
index b5a9c68..f2c5af3 100644 (file)
@@ -69,7 +69,7 @@ int allreduce__mpich(const void *sbuf, void *rbuf, int count,
     block_dsize = dsize * count;
 
     /*MPICH uses SMP algorithms for all commutative ops now*/
-    if(!comm->is_smp_comm()){
+    if (not comm->is_smp_comm()) {
       if(comm->get_leaders_comm()==MPI_COMM_NULL){
         comm->init_smp();
       }
@@ -263,7 +263,7 @@ int bcast__mpich(void *buff, int count,
     //int segsize = 0;
     size_t message_size, dsize;
 
-    if(!comm->is_smp_comm()){
+    if (not comm->is_smp_comm()) {
       if(comm->get_leaders_comm()==MPI_COMM_NULL){
         comm->init_smp();
       }
@@ -359,7 +359,7 @@ int reduce__mpich(const void *sendbuf, void *recvbuf,
     int communicator_size=0;
     size_t message_size, dsize;
 
-    if(!comm->is_smp_comm()){
+    if (not comm->is_smp_comm()) {
       if(comm->get_leaders_comm()==MPI_COMM_NULL){
         comm->init_smp();
       }
index 06280b2..9a416d6 100644 (file)
@@ -29,7 +29,8 @@ class Comm : public F2C, public Keyval{
   int is_uniform_       = 1;
   int* non_uniform_map_ = nullptr; // set if smp nodes have a different number of processes allocated
   int is_blocked_       = 0;       // are ranks allocated on the same smp node contiguous ?
-  int is_smp_comm_;             // set to 0 in case this is already an intra-comm or a leader-comm to avoid recursion
+  bool is_smp_comm_     = false;   // set to false in case this is already an intra-comm or a leader-comm to avoid
+                                   // recursion
   std::list<MPI_Win> rma_wins_; // attached windows for synchronization.
   std::string name_;
   MPI_Info info_ = MPI_INFO_NULL;
@@ -41,7 +42,7 @@ public:
   static int keyval_id_;
 
   Comm() = default;
-  Comm(MPI_Group group, MPI_Topology topo, int smp = 0, int id=MPI_UNDEFINED);
+  Comm(MPI_Group group, MPI_Topology topo, bool smp = false, int id = MPI_UNDEFINED);
   int dup(MPI_Comm* newcomm);
   int dup_with_info(MPI_Info info, MPI_Comm* newcomm);
   MPI_Group group();
@@ -62,9 +63,9 @@ public:
   MPI_Comm get_leaders_comm();
   MPI_Comm get_intra_comm();
   MPI_Comm find_intra_comm(int* leader);
-  int is_uniform();
-  int is_blocked();
-  int is_smp_comm();
+  bool is_uniform();
+  bool is_blocked();
+  bool is_smp_comm();
   MPI_Comm split(int color, int key);
   void cleanup_smp();
   void ref();
index 85267e8..4fe6185 100644 (file)
@@ -28,7 +28,8 @@ namespace smpi{
 std::unordered_map<int, smpi_key_elem> Comm::keyvals_;
 int Comm::keyval_id_=0;
 
-Comm::Comm(MPI_Group group, MPI_Topology topo, int smp, int in_id) : group_(group), topo_(topo),is_smp_comm_(smp), id_(in_id)
+Comm::Comm(MPI_Group group, MPI_Topology topo, bool smp, int in_id)
+    : group_(group), topo_(topo), is_smp_comm_(smp), id_(in_id)
 {
   errhandler_->ref();
   //First creation of comm is done before SIMIX_run, so only do comms for others
@@ -202,19 +203,22 @@ MPI_Comm Comm::get_intra_comm(){
   else return intra_comm_;
 }
 
-int Comm::is_uniform(){
+bool Comm::is_uniform()
+{
   if (this == MPI_COMM_UNINITIALIZED)
     return smpi_process()->comm_world()->is_uniform();
-  return is_uniform_;
+  return is_uniform_ != 0;
 }
 
-int Comm::is_blocked(){
+bool Comm::is_blocked()
+{
   if (this == MPI_COMM_UNINITIALIZED)
     return smpi_process()->comm_world()->is_blocked();
-  return is_blocked_;
+  return is_blocked_ != 0;
 }
 
-int Comm::is_smp_comm(){
+bool Comm::is_smp_comm()
+{
   if (this == MPI_COMM_UNINITIALIZED)
     return smpi_process()->comm_world()->is_smp_comm();
   return is_smp_comm_;
@@ -456,7 +460,7 @@ void Comm::init_smp(){
         break;
       }
     }
-    if(is_uniform==0 && this->is_uniform()!=0){
+    if (is_uniform == 0 && this->is_uniform()) {
       non_uniform_map_ = non_uniform_map;
     }else{
       xbt_free(non_uniform_map);