Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Constify pointer and reference local variables in src/smpi/.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 23 Dec 2019 21:47:37 +0000 (22:47 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 23 Dec 2019 23:33:39 +0000 (00:33 +0100)
13 files changed:
src/smpi/bindings/smpi_pmpi_topo.cpp
src/smpi/include/smpi_keyvals.hpp
src/smpi/internals/instr_smpi.cpp
src/smpi/internals/smpi_bench.cpp
src/smpi/internals/smpi_deployment.cpp
src/smpi/internals/smpi_global.cpp
src/smpi/internals/smpi_memory.cpp
src/smpi/internals/smpi_replay.cpp
src/smpi/internals/smpi_shared.cpp
src/smpi/mpi/smpi_request.cpp
src/smpi/mpi/smpi_topo.cpp
src/smpi/mpi/smpi_win.cpp
src/smpi/plugins/load_balancer/LoadBalancer.cpp

index 8165328..1f38d48 100644 (file)
@@ -24,7 +24,8 @@ int PMPI_Cart_create(MPI_Comm comm_old, int ndims, const int* dims, const int* p
   CHECK_NEGATIVE(2, MPI_ERR_ARG, ndims)
   for (int i = 0; i < ndims; i++)
     CHECK_NEGATIVE(2, MPI_ERR_ARG, dims[i])
   CHECK_NEGATIVE(2, MPI_ERR_ARG, ndims)
   for (int i = 0; i < ndims; i++)
     CHECK_NEGATIVE(2, MPI_ERR_ARG, dims[i])
-  simgrid::smpi::Topo_Cart* topo = new simgrid::smpi::Topo_Cart(comm_old, ndims, dims, periodic, reorder, comm_cart);
+  const simgrid::smpi::Topo_Cart* topo =
+      new simgrid::smpi::Topo_Cart(comm_old, ndims, dims, periodic, reorder, comm_cart);
   if (*comm_cart == MPI_COMM_NULL) {
     delete topo;
   } else {
   if (*comm_cart == MPI_COMM_NULL) {
     delete topo;
   } else {
@@ -113,7 +114,7 @@ int PMPI_Cart_sub(MPI_Comm comm, const int* remain_dims, MPI_Comm* comm_new) {
   if (topo==nullptr) {
     return MPI_ERR_ARG;
   }
   if (topo==nullptr) {
     return MPI_ERR_ARG;
   }
-  MPIR_Cart_Topology cart = topo->sub(remain_dims, comm_new);
+  const simgrid::smpi::Topo_Cart* cart = topo->sub(remain_dims, comm_new);
   if(*comm_new==MPI_COMM_NULL)
       delete cart;
   if(cart==nullptr)
   if(*comm_new==MPI_COMM_NULL)
       delete cart;
   if(cart==nullptr)
index a23be10..a9af670 100644 (file)
@@ -112,7 +112,7 @@ template <typename T> int Keyval::attr_delete(int keyval){
 
 
 template <typename T> int Keyval::attr_get(int keyval, void* attr_value, int* flag){
 
 
 template <typename T> int Keyval::attr_get(int keyval, void* attr_value, int* flag){
-  smpi_key_elem elem = T::keyvals_.at(keyval);
+  const s_smpi_key_elem_t* elem = T::keyvals_.at(keyval);
   if(elem==nullptr)
     return MPI_ERR_ARG;
   if(attributes()->empty()){
   if(elem==nullptr)
     return MPI_ERR_ARG;
   if(attributes()->empty()){
index 30b9bf1..5c0f4e9 100644 (file)
@@ -156,7 +156,7 @@ void TRACE_smpi_init(int rank)
   TRACE_smpi_setup_container(rank, sg_host_self());
   simgrid::s4u::this_actor::on_exit([self](bool) { smpi_container(self->get_pid())->remove_from_parent(); });
 #if HAVE_PAPI
   TRACE_smpi_setup_container(rank, sg_host_self());
   simgrid::s4u::this_actor::on_exit([self](bool) { smpi_container(self->get_pid())->remove_from_parent(); });
 #if HAVE_PAPI
-  container_t container   = smpi_container(rank);
+  const simgrid::instr::Container* container = smpi_container(rank);
   papi_counter_t counters = smpi_process()->papi_counters();
 
   for (auto const& it : counters) {
   papi_counter_t counters = smpi_process()->papi_counters();
 
   for (auto const& it : counters) {
index d32f115..c52478a 100644 (file)
@@ -162,9 +162,9 @@ void smpi_bench_end()
 
 #if HAVE_PAPI
   if (not smpi_cfg_papi_events_file().empty() && TRACE_smpi_is_enabled()) {
 
 #if HAVE_PAPI
   if (not smpi_cfg_papi_events_file().empty() && TRACE_smpi_is_enabled()) {
-    container_t container =
+    const simgrid::instr::Container* container =
         simgrid::instr::Container::by_name(std::string("rank-") + std::to_string(simgrid::s4u::this_actor::get_pid()));
         simgrid::instr::Container::by_name(std::string("rank-") + std::to_string(simgrid::s4u::this_actor::get_pid()));
-    papi_counter_t& counter_data = smpi_process()->papi_counters();
+    const papi_counter_t& counter_data = smpi_process()->papi_counters();
 
     for (auto const& pair : counter_data) {
       simgrid::instr::VariableType* variable = static_cast<simgrid::instr::VariableType*>(container->type_->by_name(pair.first));
 
     for (auto const& pair : counter_data) {
       simgrid::instr::VariableType* variable = static_cast<simgrid::instr::VariableType*>(container->type_->by_name(pair.first));
@@ -376,7 +376,7 @@ int smpi_sample_2(int global, const char *file, int line, int iter_count)
   auto sample = samples.find(loc);
   if (sample == samples.end())
     xbt_die("Y U NO use SMPI_SAMPLE_* macros? Stop messing directly with smpi_sample_* functions!");
   auto sample = samples.find(loc);
   if (sample == samples.end())
     xbt_die("Y U NO use SMPI_SAMPLE_* macros? Stop messing directly with smpi_sample_* functions!");
-  LocalData& data = sample->second;
+  const LocalData& data = sample->second;
 
   if (data.benching) {
     // we need to run a new bench
 
   if (data.benching) {
     // we need to run a new bench
@@ -446,7 +446,7 @@ int smpi_sample_exit(int global, const char *file, int line, int iter_count){
       xbt_die("Y U NO use SMPI_SAMPLE_* macros? Stop messing directly with smpi_sample_* functions!");
   
     if (smpi_process()->sampling()){//end of loop, but still sampling needed
       xbt_die("Y U NO use SMPI_SAMPLE_* macros? Stop messing directly with smpi_sample_* functions!");
   
     if (smpi_process()->sampling()){//end of loop, but still sampling needed
-      LocalData& data = sample->second;
+      const LocalData& data = sample->second;
       smpi_process()->set_sampling(0);
       smpi_execute(data.mean * iter_count);
       smpi_bench_begin();
       smpi_process()->set_sampling(0);
       smpi_execute(data.mean * iter_count);
       smpi_bench_begin();
index 5cf91eb..7bbf747 100644 (file)
@@ -67,7 +67,7 @@ void SMPI_app_instance_register(const char *name, xbt_main_func_t code, int num_
 
 void smpi_deployment_register_process(const std::string& instance_id, int rank, simgrid::s4u::Actor* actor)
 {
 
 void smpi_deployment_register_process(const std::string& instance_id, int rank, simgrid::s4u::Actor* actor)
 {
-  Instance& instance = smpi_instances.at(instance_id);
+  const Instance& instance = smpi_instances.at(instance_id);
   instance.comm_world_->group()->set_mapping(actor, rank);
 }
 
   instance.comm_world_->group()->set_mapping(actor, rank);
 }
 
index 4834e84..3922c63 100644 (file)
@@ -383,7 +383,7 @@ static void smpi_copy_file(const std::string& src, const std::string& target, of
     if (got == -1) {
       xbt_assert(errno == EINTR, "Cannot read from %s", src.c_str());
     } else {
     if (got == -1) {
       xbt_assert(errno == EINTR, "Cannot read from %s", src.c_str());
     } else {
-      char* p  = buf;
+      const char* p = buf;
       int todo = got;
       while (int done = write(fdout, p, todo)) {
         if (done == -1) {
       int todo = got;
       while (int done = write(fdout, p, todo)) {
         if (done == -1) {
index 8a99ebc..55b7551 100644 (file)
@@ -56,7 +56,7 @@ void smpi_prepare_global_memory_segment()
 static void smpi_get_executable_global_size()
 {
   char buffer[PATH_MAX];
 static void smpi_get_executable_global_size()
 {
   char buffer[PATH_MAX];
-  char* full_name = realpath(simgrid::xbt::binary_name.c_str(), buffer);
+  const char* full_name = realpath(simgrid::xbt::binary_name.c_str(), buffer);
   xbt_assert(full_name != nullptr, "Could not resolve real path of binary file '%s'",
              simgrid::xbt::binary_name.c_str());
 
   xbt_assert(full_name != nullptr, "Could not resolve real path of binary file '%s'",
              simgrid::xbt::binary_name.c_str());
 
@@ -194,7 +194,7 @@ void smpi_switch_data_segment(simgrid::s4u::ActorPtr actor)
   XBT_DEBUG("Switching data frame to the one of process %ld", actor->get_pid());
   simgrid::smpi::ActorExt* process = smpi_process_remote(actor);
   int current                     = process->privatized_region()->file_descriptor;
   XBT_DEBUG("Switching data frame to the one of process %ld", actor->get_pid());
   simgrid::smpi::ActorExt* process = smpi_process_remote(actor);
   int current                     = process->privatized_region()->file_descriptor;
-  void* tmp = mmap(TOPAGE(smpi_data_exe_start), smpi_data_exe_size, PROT_RW, MAP_FIXED | MAP_SHARED, current, 0);
+  const void* tmp = mmap(TOPAGE(smpi_data_exe_start), smpi_data_exe_size, PROT_RW, MAP_FIXED | MAP_SHARED, current, 0);
   if (tmp != TOPAGE(smpi_data_exe_start))
     xbt_die("Couldn't map the new region (errno %d): %s", errno, strerror(errno));
   smpi_loaded_page = actor->get_pid();
   if (tmp != TOPAGE(smpi_data_exe_start))
     xbt_die("Couldn't map the new region (errno %d): %s", errno, strerror(errno));
   smpi_loaded_page = actor->get_pid();
index 5d2619c..27f4605 100644 (file)
@@ -102,7 +102,7 @@ public:
 
     void get_requests(std::vector<MPI_Request>& vec)
     {
 
     void get_requests(std::vector<MPI_Request>& vec)
     {
-      for (auto& pair : store) {
+      for (auto const& pair : store) {
         auto& req = pair.second;
         auto my_proc_id = simgrid::s4u::this_actor::get_pid();
         if (req != MPI_REQUEST_NULL && (req->src() == my_proc_id || req->dst() == my_proc_id)) {
         auto& req = pair.second;
         auto my_proc_id = simgrid::s4u::this_actor::get_pid();
         if (req != MPI_REQUEST_NULL && (req->src() == my_proc_id || req->dst() == my_proc_id)) {
@@ -558,7 +558,7 @@ void WaitAllAction::kernel(simgrid::xbt::ReplayAction&)
     std::vector<std::pair</*sender*/int,/*recv*/int>> sender_receiver;
     std::vector<MPI_Request> reqs;
     req_storage.get_requests(reqs);
     std::vector<std::pair</*sender*/int,/*recv*/int>> sender_receiver;
     std::vector<MPI_Request> reqs;
     req_storage.get_requests(reqs);
-    for (const auto& req : reqs) {
+    for (auto const& req : reqs) {
       if (req && (req->flags() & MPI_REQ_RECV)) {
         sender_receiver.push_back({req->src(), req->dst()});
       }
       if (req && (req->flags() & MPI_REQ_RECV)) {
         sender_receiver.push_back({req->src(), req->dst()});
       }
@@ -566,7 +566,7 @@ void WaitAllAction::kernel(simgrid::xbt::ReplayAction&)
     Request::waitall(count_requests, &(reqs.data())[0], MPI_STATUSES_IGNORE);
     req_storage.get_store().clear();
 
     Request::waitall(count_requests, &(reqs.data())[0], MPI_STATUSES_IGNORE);
     req_storage.get_store().clear();
 
-    for (auto& pair : sender_receiver) {
+    for (auto const& pair : sender_receiver) {
       TRACE_smpi_recv(pair.first, pair.second, 0);
     }
     TRACE_smpi_comm_out(my_proc_id);
       TRACE_smpi_recv(pair.first, pair.second, 0);
     }
     TRACE_smpi_comm_out(my_proc_id);
index ef02210..e84aa48 100644 (file)
@@ -208,7 +208,7 @@ void* smpi_shared_malloc_partial(size_t size, size_t* shared_block_offsets, int
     smpi_shared_malloc_bogusfile = mkstemp(name);
     XBT_DEBUG("bogusfile         : %s\n", name);
     unlink(name);
     smpi_shared_malloc_bogusfile = mkstemp(name);
     XBT_DEBUG("bogusfile         : %s\n", name);
     unlink(name);
-    char* dumb  = new char[smpi_shared_malloc_blocksize](); // zero initialized
+    const char* dumb = new char[smpi_shared_malloc_blocksize](); // zero initialized
     ssize_t err = write(smpi_shared_malloc_bogusfile, dumb, smpi_shared_malloc_blocksize);
     if(err<0)
       xbt_die("Could not write bogus file for shared malloc");
     ssize_t err = write(smpi_shared_malloc_bogusfile, dumb, smpi_shared_malloc_blocksize);
     if(err<0)
       xbt_die("Could not write bogus file for shared malloc");
@@ -240,8 +240,7 @@ void* smpi_shared_malloc_partial(size_t size, size_t* shared_block_offsets, int
     for (size_t offset = start_block_offset; offset < stop_block_offset; offset += smpi_shared_malloc_blocksize) {
       XBT_DEBUG("\t\tglobal shared allocation, mmap block offset %zx", offset);
       void* pos = (void*)((unsigned long)mem + offset);
     for (size_t offset = start_block_offset; offset < stop_block_offset; offset += smpi_shared_malloc_blocksize) {
       XBT_DEBUG("\t\tglobal shared allocation, mmap block offset %zx", offset);
       void* pos = (void*)((unsigned long)mem + offset);
-      void* res = mmap(pos, smpi_shared_malloc_blocksize, PROT_READ | PROT_WRITE, mmap_flag,
-                       huge_fd, 0);
+      const void* res = mmap(pos, smpi_shared_malloc_blocksize, PROT_READ | PROT_WRITE, mmap_flag, huge_fd, 0);
       xbt_assert(res == pos, "Could not map folded virtual memory (%s). Do you perhaps need to increase the "
                              "size of the mapped file using --cfg=smpi/shared-malloc-blocksize:newvalue (default 1048576) ? "
                              "You can also try using  the sysctl vm.max_map_count. "
       xbt_assert(res == pos, "Could not map folded virtual memory (%s). Do you perhaps need to increase the "
                              "size of the mapped file using --cfg=smpi/shared-malloc-blocksize:newvalue (default 1048576) ? "
                              "You can also try using  the sysctl vm.max_map_count. "
@@ -254,8 +253,9 @@ void* smpi_shared_malloc_partial(size_t size, size_t* shared_block_offsets, int
     if(low_page_start_offset < low_page_stop_offset) {
       XBT_DEBUG("\t\tglobal shared allocation, mmap block start");
       void* pos = (void*)((unsigned long)mem + low_page_start_offset);
     if(low_page_start_offset < low_page_stop_offset) {
       XBT_DEBUG("\t\tglobal shared allocation, mmap block start");
       void* pos = (void*)((unsigned long)mem + low_page_start_offset);
-      void* res = mmap(pos, low_page_stop_offset-low_page_start_offset, PROT_READ | PROT_WRITE, mmap_base_flag, // not a full huge page
-                       smpi_shared_malloc_bogusfile, 0);
+      const void* res = mmap(pos, low_page_stop_offset - low_page_start_offset, PROT_READ | PROT_WRITE,
+                             mmap_base_flag, // not a full huge page
+                             smpi_shared_malloc_bogusfile, 0);
       xbt_assert(res == pos, "Could not map folded virtual memory (%s). Do you perhaps need to increase the "
                              "size of the mapped file using --cfg=smpi/shared-malloc-blocksize:newvalue (default 1048576) ?"
                              "You can also try using  the sysctl vm.max_map_count",
       xbt_assert(res == pos, "Could not map folded virtual memory (%s). Do you perhaps need to increase the "
                              "size of the mapped file using --cfg=smpi/shared-malloc-blocksize:newvalue (default 1048576) ?"
                              "You can also try using  the sysctl vm.max_map_count",
@@ -266,8 +266,9 @@ void* smpi_shared_malloc_partial(size_t size, size_t* shared_block_offsets, int
       size_t high_page_stop_offset = stop_offset == size ? size : ALIGN_DOWN((int64_t)stop_offset, PAGE_SIZE);
       if(high_page_stop_offset > stop_block_offset) {
         void* pos = (void*)((unsigned long)mem + stop_block_offset);
       size_t high_page_stop_offset = stop_offset == size ? size : ALIGN_DOWN((int64_t)stop_offset, PAGE_SIZE);
       if(high_page_stop_offset > stop_block_offset) {
         void* pos = (void*)((unsigned long)mem + stop_block_offset);
-        void* res = mmap(pos, high_page_stop_offset-stop_block_offset, PROT_READ | PROT_WRITE, mmap_base_flag, // not a full huge page
-                         smpi_shared_malloc_bogusfile, 0);
+        const void* res = mmap(pos, high_page_stop_offset - stop_block_offset, PROT_READ | PROT_WRITE,
+                               mmap_base_flag, // not a full huge page
+                               smpi_shared_malloc_bogusfile, 0);
         xbt_assert(res == pos, "Could not map folded virtual memory (%s). Do you perhaps need to increase the "
                                "size of the mapped file using --cfg=smpi/shared-malloc-blocksize:newvalue (default 1048576) ?"
                                "You can also try using  the sysctl vm.max_map_count",
         xbt_assert(res == pos, "Could not map folded virtual memory (%s). Do you perhaps need to increase the "
                                "size of the mapped file using --cfg=smpi/shared-malloc-blocksize:newvalue (default 1048576) ?"
                                "You can also try using  the sysctl vm.max_map_count",
index 6418c65..b9ac2b3 100644 (file)
@@ -784,7 +784,7 @@ void Request::iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status*
 
   if (request->action_ != nullptr){
     kernel::activity::CommImplPtr sync_comm = boost::static_pointer_cast<kernel::activity::CommImpl>(request->action_);
 
   if (request->action_ != nullptr){
     kernel::activity::CommImplPtr sync_comm = boost::static_pointer_cast<kernel::activity::CommImpl>(request->action_);
-    MPI_Request req                         = static_cast<MPI_Request>(sync_comm->src_data_);
+    const Request* req                      = static_cast<MPI_Request>(sync_comm->src_data_);
     *flag = 1;
     if (status != MPI_STATUS_IGNORE && (req->flags_ & MPI_REQ_PREPARED) == 0) {
       status->MPI_SOURCE = comm->group()->rank(req->src_);
     *flag = 1;
     if (status != MPI_STATUS_IGNORE && (req->flags_ & MPI_REQ_PREPARED) == 0) {
       status->MPI_SOURCE = comm->group()->rank(req->src_);
index b79cefc..2dbbcd4 100644 (file)
@@ -273,7 +273,7 @@ int Topo_Cart::Dims_create(int nnodes, int ndims, int dims[])
   /* Get # of free-to-be-assigned processes and # of free dimensions */
   int freeprocs = nnodes;
   int freedims = 0;
   /* Get # of free-to-be-assigned processes and # of free dimensions */
   int freeprocs = nnodes;
   int freedims = 0;
-  int *p = dims;
+  const int* p  = dims;
   for (int i = 0; i < ndims; ++i) {
     if (*p == 0) {
       ++freedims;
   for (int i = 0; i < ndims; ++i) {
     if (*p == 0) {
       ++freedims;
index 19ca7be..1dfda94 100644 (file)
@@ -207,7 +207,7 @@ int Win::put(const void *origin_addr, int origin_count, MPI_Datatype origin_data
               MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Request* request)
 {
   //get receiver pointer
               MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Request* request)
 {
   //get receiver pointer
-  MPI_Win recv_win = connected_wins_[target_rank];
+  const Win* recv_win = connected_wins_[target_rank];
 
   if(opened_==0){//check that post/start has been done
     // no fence or start .. lock ok ?
 
   if(opened_==0){//check that post/start has been done
     // no fence or start .. lock ok ?
@@ -267,7 +267,7 @@ int Win::get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype,
               MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Request* request)
 {
   //get sender pointer
               MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Request* request)
 {
   //get sender pointer
-  MPI_Win send_win = connected_wins_[target_rank];
+  const Win* send_win = connected_wins_[target_rank];
 
   if(opened_==0){//check that post/start has been done
     // no fence or start .. lock ok ?
 
   if(opened_==0){//check that post/start has been done
     // no fence or start .. lock ok ?
@@ -282,7 +282,7 @@ int Win::get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype,
   if(target_count*target_datatype->get_extent()>send_win->size_)
     return MPI_ERR_ARG;
 
   if(target_count*target_datatype->get_extent()>send_win->size_)
     return MPI_ERR_ARG;
 
-  void* send_addr = static_cast<void*>(static_cast<char*>(send_win->base_) + target_disp * send_win->disp_unit_);
+  const void* send_addr = static_cast<void*>(static_cast<char*>(send_win->base_) + target_disp * send_win->disp_unit_);
   XBT_DEBUG("Entering MPI_Get from %d", target_rank);
 
   if(target_rank != comm_->rank()){
   XBT_DEBUG("Entering MPI_Get from %d", target_rank);
 
   if(target_rank != comm_->rank()){
@@ -326,7 +326,7 @@ int Win::accumulate(const void *origin_addr, int origin_count, MPI_Datatype orig
 {
   XBT_DEBUG("Entering MPI_Win_Accumulate");
   //get receiver pointer
 {
   XBT_DEBUG("Entering MPI_Win_Accumulate");
   //get receiver pointer
-  MPI_Win recv_win = connected_wins_[target_rank];
+  const Win* recv_win = connected_wins_[target_rank];
 
   if(opened_==0){//check that post/start has been done
     // no fence or start .. lock ok ?
 
   if(opened_==0){//check that post/start has been done
     // no fence or start .. lock ok ?
@@ -382,7 +382,7 @@ int Win::get_accumulate(const void* origin_addr, int origin_count, MPI_Datatype
                         int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Request*)
 {
   //get sender pointer
                         int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Request*)
 {
   //get sender pointer
-  MPI_Win send_win = connected_wins_[target_rank];
+  const Win* send_win = connected_wins_[target_rank];
 
   if(opened_==0){//check that post/start has been done
     // no fence or start .. lock ok ?
 
   if(opened_==0){//check that post/start has been done
     // no fence or start .. lock ok ?
@@ -418,7 +418,7 @@ int Win::compare_and_swap(const void *origin_addr, void *compare_addr,
         void *result_addr, MPI_Datatype datatype, int target_rank,
         MPI_Aint target_disp){
   //get sender pointer
         void *result_addr, MPI_Datatype datatype, int target_rank,
         MPI_Aint target_disp){
   //get sender pointer
-  MPI_Win send_win = connected_wins_[target_rank];
+  const Win* send_win = connected_wins_[target_rank];
 
   if(opened_==0){//check that post/start has been done
     // no fence or start .. lock ok ?
 
   if(opened_==0){//check that post/start has been done
     // no fence or start .. lock ok ?
@@ -732,7 +732,7 @@ int Win::finish_comms(int rank){
 
 int Win::shared_query(int rank, MPI_Aint* size, int* disp_unit, void* baseptr)
 {
 
 int Win::shared_query(int rank, MPI_Aint* size, int* disp_unit, void* baseptr)
 {
-  MPI_Win target_win = rank != MPI_PROC_NULL ? connected_wins_[rank] : nullptr;
+  const Win* target_win = rank != MPI_PROC_NULL ? connected_wins_[rank] : nullptr;
   for (int i = 0; not target_win && i < comm_->size(); i++) {
     if (connected_wins_[i]->size_ > 0)
       target_win = connected_wins_[i];
   for (int i = 0; not target_win && i < comm_->size(); i++) {
     if (connected_wins_[i]->size_ > 0)
       target_win = connected_wins_[i];
index cc67e00..c748eb5 100644 (file)
@@ -54,7 +54,7 @@ void LoadBalancer::run()
   std::vector<simgrid::s4u::ActorPtr> all_actors =
       engine->get_filtered_actors([](simgrid::s4u::ActorPtr actor) { return not actor->is_daemon(); });
 
   std::vector<simgrid::s4u::ActorPtr> all_actors =
       engine->get_filtered_actors([](simgrid::s4u::ActorPtr actor) { return not actor->is_daemon(); });
 
-  for (auto& actor : all_actors) {
+  for (auto const& actor : all_actors) {
     new_mapping.assign(actor, actor->get_host());
   }
   // Sort the actors, from highest to lowest load; we then just iterate over these actors
     new_mapping.assign(actor, actor->get_host());
   }
   // Sort the actors, from highest to lowest load; we then just iterate over these actors
@@ -76,7 +76,7 @@ void LoadBalancer::run()
     heap_handle update_handle                  = usable_hosts.push(host); // Required to update elements in the heap
     additional_load[host]                      = {update_handle, 0};      // Save the handle for later
     const double total_flops_computed          = sg_host_get_computed_flops(host);
     heap_handle update_handle                  = usable_hosts.push(host); // Required to update elements in the heap
     additional_load[host]                      = {update_handle, 0};      // Save the handle for later
     const double total_flops_computed          = sg_host_get_computed_flops(host);
-    for (auto& actor : actors) {
+    for (auto const& actor : actors) {
       additional_load[host].load += actor_computation[actor->get_pid()] / total_flops_computed; // Normalize load - this allows comparison
                                                                                                 // even between hosts with different frequencies
       XBT_DEBUG("Actor %li -> %f", actor->get_pid(), actor_computation[actor->get_pid()]);
       additional_load[host].load += actor_computation[actor->get_pid()] / total_flops_computed; // Normalize load - this allows comparison
                                                                                                 // even between hosts with different frequencies
       XBT_DEBUG("Actor %li -> %f", actor->get_pid(), actor_computation[actor->get_pid()]);
@@ -86,7 +86,7 @@ void LoadBalancer::run()
   }
 
   // Implementation of the Greedy algorithm
   }
 
   // Implementation of the Greedy algorithm
-  for (auto& actor : all_actors) {
+  for (auto const& actor : all_actors) {
     simgrid::s4u::Host* target_host = usable_hosts.top(); // This is the host with the lowest load
 
     simgrid::s4u::Host* cur_mapped_host = new_mapping.get_host(actor);
     simgrid::s4u::Host* target_host = usable_hosts.top(); // This is the host with the lowest load
 
     simgrid::s4u::Host* cur_mapped_host = new_mapping.get_host(actor);