Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of framagit.org:simgrid/simgrid
[simgrid.git] / src / smpi / internals / smpi_replay.cpp
index 9f4bba0..218f14d 100644 (file)
@@ -97,10 +97,7 @@ static MPI_Datatype parse_datatype(const simgrid::xbt::ReplayAction& action, uns
   return i < action.size() ? simgrid::smpi::Datatype::decode(action[i]) : simgrid::smpi::replay::MPI_DEFAULT_TYPE;
 }
 
-namespace simgrid {
-namespace smpi {
-
-namespace replay {
+namespace simgrid::smpi::replay {
 MPI_Datatype MPI_DEFAULT_TYPE;
 
 class RequestStorage {
@@ -118,8 +115,7 @@ public:
 
   void get_requests(std::vector<MPI_Request>& vec) const
   {
-    for (auto const& pair : store) {
-      auto& reqs       = pair.second;
+    for (auto const& [_, reqs] : store) {
       aid_t my_proc_id = simgrid::s4u::this_actor::get_pid();
       for (auto& req: reqs){
         if (req != MPI_REQUEST_NULL && (req->src() == my_proc_id || req->dst() == my_proc_id)) {
@@ -145,9 +141,6 @@ public:
   void add(MPI_Request req)
   {
     if (req != MPI_REQUEST_NULL){ // Can and does happen in the case of TestAction
-      auto it = store.find(req_key_t(req->src()-1, req->dst()-1, req->tag()));
-      if (it == store.end())
-        store.insert({req_key_t(req->src()-1, req->dst()-1, req->tag()), std::list<MPI_Request>()});
       store[req_key_t(req->src()-1, req->dst()-1, req->tag())].push_back(req);
     }
   }
@@ -157,9 +150,6 @@ public:
   {
     int src_pid = MPI_COMM_WORLD->group()->actor(src) - 1;
     int dest_pid = MPI_COMM_WORLD->group()->actor(dst) - 1;
-    auto it = store.find(req_key_t(src_pid, dest_pid, tag));
-    if (it == store.end())
-      store.insert({req_key_t(src_pid, dest_pid, tag), std::list<MPI_Request>()});
     store[req_key_t(src_pid, dest_pid, tag)].push_back(MPI_REQUEST_NULL);
   }
 };
@@ -594,8 +584,8 @@ void WaitAllAction::kernel(simgrid::xbt::ReplayAction&)
       if (req != MPI_REQUEST_NULL)
         Request::unref(&req);
 
-    for (auto const& pair : sender_receiver) {
-      TRACE_smpi_recv(pair.first, pair.second, 0);
+    for (auto const& [src, dst] : sender_receiver) {
+      TRACE_smpi_recv(src, dst, 0);
     }
     TRACE_smpi_comm_out(get_pid());
   }
@@ -808,8 +798,7 @@ void AllToAllVAction::kernel(simgrid::xbt::ReplayAction&)
 
   TRACE_smpi_comm_out(get_pid());
 }
-} // Replay Namespace
-}} // namespace simgrid::smpi
+} // namespace simgrid::smpi::replay
 
 static std::unordered_map<aid_t, simgrid::smpi::replay::RequestStorage> storage;
 /** @brief Only initialize the replay, don't do it for real */
@@ -885,9 +874,9 @@ void smpi_replay_main(int rank, const char* private_trace_filename)
     std::vector<MPI_Request> requests(count_requests);
     unsigned int i=0;
 
-    for (auto const& pair : storage[simgrid::s4u::this_actor::get_pid()].get_store()) {
-      for (auto& req: pair.second){
-        requests[i] = req;
+    for (auto const& [_, reqs] : storage[simgrid::s4u::this_actor::get_pid()].get_store()) {
+      for (auto& req : reqs) {
+        requests[i] = req; // FIXME: overwritten at each iteration?
       }
       i++;
     }