Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use type 'bool' for boolean variables.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 16 Feb 2022 21:23:55 +0000 (22:23 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 16 Feb 2022 21:23:55 +0000 (22:23 +0100)
src/kernel/context/Context.cpp
src/kernel/context/Context.hpp
src/smpi/include/smpi_comm.hpp
src/smpi/mpi/smpi_comm.cpp

index c638be3..51dd90b 100644 (file)
@@ -25,7 +25,7 @@ unsigned stack_size;
 unsigned guard_size;
 
 /** @brief Returns whether some parallel threads are used for the user contexts. */
-int is_parallel()
+bool is_parallel()
 {
   return parallel_contexts > 1;
 }
index edb1e62..dfba34c 100644 (file)
@@ -110,7 +110,7 @@ XBT_PRIVATE ContextFactory* sysv_factory();
 XBT_PRIVATE ContextFactory* raw_factory();
 XBT_PRIVATE ContextFactory* boost_factory();
 
-XBT_PUBLIC int is_parallel();
+XBT_PUBLIC bool is_parallel();
 XBT_PUBLIC int get_nthreads();
 XBT_PUBLIC void set_nthreads(int nb_threads);
 XBT_PUBLIC void set_parallel_mode(e_xbt_parmap_mode_t mode);
index 7f9f5dd..87ff9b2 100644 (file)
@@ -28,9 +28,9 @@ class Comm : public F2C, public Keyval{
   MPI_Comm intra_comm_   = MPI_COMM_NULL; // intra-node communicator. For MPI_COMM_WORLD this can't be used, as var is
                                           // global. Use an intracomm stored in the process data instead
   int* leaders_map_     = nullptr;        // who is the leader of each process
-  int is_uniform_       = 1;
+  bool is_uniform_      = true;
   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 ?
+  bool is_blocked_      = false;   // are ranks allocated on the same smp node contiguous?
   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.
index 683a64a..b482e21 100644 (file)
@@ -242,14 +242,14 @@ bool Comm::is_uniform() const
 {
   if (this == MPI_COMM_UNINITIALIZED)
     return smpi_process()->comm_world()->is_uniform();
-  return is_uniform_ != 0;
+  return is_uniform_;
 }
 
 bool Comm::is_blocked() const
 {
   if (this == MPI_COMM_UNINITIALIZED)
     return smpi_process()->comm_world()->is_blocked();
-  return is_blocked_ != 0;
+  return is_blocked_;
 }
 
 bool Comm::is_smp_comm() const
@@ -474,8 +474,9 @@ void Comm::init_smp(){
 
   // Are the nodes uniform ? = same number of process/node
   int my_local_size=comm_intra->size();
+  int is_uniform;
   if(comm_intra->rank()==0) {
-    int is_uniform       = 1;
+    is_uniform            = 1;
     auto* non_uniform_map = xbt_new0(int, leader_group_size);
     allgather__ring(&my_local_size, 1, MPI_INT,
         non_uniform_map, 1, MPI_INT, leader_comm);
@@ -490,9 +491,9 @@ void Comm::init_smp(){
     }else{
       xbt_free(non_uniform_map);
     }
-    is_uniform_=is_uniform;
   }
-  bcast__scatter_LR_allgather(&is_uniform_, 1, MPI_INT, 0, comm_intra);
+  bcast__scatter_LR_allgather(&is_uniform, 1, MPI_INT, 0, comm_intra);
+  is_uniform_ = (is_uniform != 0);
 
   // we need to switch as the called function may silently touch global variables
   smpi_switch_data_segment(s4u::Actor::self());
@@ -512,13 +513,8 @@ void Comm::init_smp(){
   int global_blocked;
   allreduce__default(&is_blocked, &global_blocked, 1, MPI_INT, MPI_LAND, this);
 
-  if(MPI_COMM_WORLD==MPI_COMM_UNINITIALIZED || this==MPI_COMM_WORLD){
-    if(this->rank()==0){
-      is_blocked_ = global_blocked;
-    }
-  }else{
-    is_blocked_=global_blocked;
-  }
+  if ((MPI_COMM_WORLD != MPI_COMM_UNINITIALIZED && this != MPI_COMM_WORLD) || this->rank() == 0)
+    is_blocked_ = (global_blocked != 0);
   delete[] leader_list;
 
   if(replaying)