Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Don't build useless temporary object (sonar, c++17).
[simgrid.git] / src / smpi / internals / smpi_deployment.cpp
index f1656e5..921f3c0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2021. The SimGrid Team.
+/* Copyright (c) 2004-2022. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -26,9 +26,9 @@ public:
     auto* group = new simgrid::smpi::Group(size_);
     comm_world_ = new simgrid::smpi::Comm(group, nullptr, false, -1);
     universe_size += max_no_processes;
-    bar_ = new s4u::Barrier(size_);
+    bar_ = s4u::Barrier::create(size_);
   }
-  s4u::Barrier* bar_;
+  s4u::BarrierPtr bar_;
   unsigned int size_;
   unsigned int finalized_ranks_ = 0;
   MPI_Comm comm_world_;
@@ -56,16 +56,13 @@ void SMPI_app_instance_register(const char *name, xbt_main_func_t code, int num_
   if (code != nullptr) // When started with smpirun, we will not execute a function
     simgrid::s4u::Engine::get_instance()->register_function(name, code);
 
-  Instance instance(num_processes);
-
-  smpi_instances.insert(std::pair<std::string, Instance>(name, instance));
+  smpi_instances.try_emplace(name, num_processes);
 }
 
 void smpi_deployment_register_process(const std::string& instance_id, int rank, const simgrid::s4u::Actor* actor)
 {
   const Instance& instance = smpi_instances.at(instance_id);
   instance.comm_world_->group()->set_mapping(actor->get_pid(), rank);
-
 }
 
 void smpi_deployment_startup_barrier(const std::string& instance_id)
@@ -81,7 +78,6 @@ void smpi_deployment_unregister_process(const std::string& instance_id)
 
   if (instance.finalized_ranks_ == instance.size_) {
     simgrid::smpi::Comm::destroy(instance.comm_world_);
-    delete instance.bar_;
     smpi_instances.erase(instance_id);
   }
 }