Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Do not ask for memory info when restarting in refork mode
[simgrid.git] / src / mc / api / RemoteApp.cpp
index 114c7e4..b53ef17 100644 (file)
@@ -29,11 +29,8 @@ XBT_LOG_EXTERNAL_CATEGORY(mc_global);
 
 namespace simgrid::mc {
 
-RemoteApp::RemoteApp(const std::vector<char*>& args, bool need_memory_introspection)
+RemoteApp::RemoteApp(const std::vector<char*>& args, bool need_memory_introspection) : app_args_(args)
 {
-  for (auto* arg : args)
-    app_args_.push_back(arg);
-
   checker_side_ = std::make_unique<simgrid::mc::CheckerSide>(app_args_, need_memory_introspection);
 
   if (need_memory_introspection)
@@ -51,7 +48,7 @@ void RemoteApp::restore_initial_state()
   if (initial_snapshot_ == nullptr) { // No memory introspection
     // We need to destroy the existing CheckerSide before creating the new one, or libevent gets crazy
     checker_side_.reset(nullptr);
-    checker_side_.reset(new simgrid::mc::CheckerSide(app_args_, true));
+    checker_side_.reset(new simgrid::mc::CheckerSide(app_args_, false));
   } else
     initial_snapshot_->restore(*checker_side_->get_remote_memory());
 }
@@ -94,11 +91,6 @@ void RemoteApp::get_actors_status(std::map<aid_t, ActorState>& whereto) const
 
   // Message sanity checks
   xbt_assert(answer.count >= 0, "Received an ACTOR_STATUS_REPLY message with an actor count of '%d' < 0", answer.count);
-  xbt_assert(answer.transition_count >= 0, "Received an ACTOR_STATUS_REPLY message with transition_count '%d' < 0",
-             answer.transition_count);
-  xbt_assert(answer.transition_count == 0 || answer.count >= 0,
-             "Received an ACTOR_STATUS_REPLY message with no actor data "
-             "but with transition data nonetheless");
 
   std::vector<s_mc_message_actors_status_one_t> status(answer.count);
   if (answer.count > 0) {
@@ -107,39 +99,20 @@ void RemoteApp::get_actors_status(std::map<aid_t, ActorState>& whereto) const
     xbt_assert(static_cast<size_t>(received) == size);
   }
 
-  // Ensures that each actor sends precisely `answer.transition_count` transitions. While technically
-  // this doesn't catch the edge case where actor A sends 3 instead of 2 and actor B sends 2 instead
-  // of 3 transitions, that is ignored here since that invariant needs to be enforced on the AppSide
-  const auto expected_transitions = std::accumulate(
-      status.begin(), status.end(), 0, [](int total, const auto& actor) { return total + actor.n_transitions; });
-  xbt_assert(expected_transitions == answer.transition_count,
-             "Expected to receive %d transition(s) but was only notified of %d by the app side", expected_transitions,
-             answer.transition_count);
-
-  std::vector<s_mc_message_simcall_probe_one_t> probes(answer.transition_count);
-  if (answer.transition_count > 0) {
-    for (auto& probe : probes) {
+  whereto.clear();
+
+  for (const auto& actor : status) {
+    std::vector<std::shared_ptr<Transition>> actor_transitions;
+    int n_transitions = actor.enabled ? actor.max_considered : 0;
+    for (int times_considered = 0; times_considered < n_transitions; times_considered++) {
+      s_mc_message_simcall_probe_one_t probe;
       ssize_t received = checker_side_->get_channel().receive(probe);
       xbt_assert(received >= 0, "Could not receive response to ACTORS_PROBE message (%s)", strerror(errno));
       xbt_assert(static_cast<size_t>(received) == sizeof probe,
                  "Could not receive response to ACTORS_PROBE message (%zd bytes received != %zu bytes expected",
                  received, sizeof probe);
-    }
-  }
-
-  whereto.clear();
-  std::move_iterator probes_iter(probes.begin());
 
-  for (const auto& actor : status) {
-    xbt_assert(actor.n_transitions == 0 || actor.n_transitions == actor.max_considered,
-               "If any transitions are serialized for an actor, it must match the "
-               "total number of transitions that can be considered for the actor "
-               "(currently %d), but only %d transition(s) was/were said to be encoded",
-               actor.max_considered, actor.n_transitions);
-
-    std::vector<std::shared_ptr<Transition>> actor_transitions;
-    for (int times_considered = 0; times_considered < actor.n_transitions; times_considered++, probes_iter++) {
-      std::stringstream stream((*probes_iter).buffer.data());
+      std::stringstream stream(probe.buffer.data());
       actor_transitions.emplace_back(deserialize_transition(actor.aid, times_considered, stream));
     }
 
@@ -185,8 +158,7 @@ Transition* RemoteApp::handle_simcall(aid_t aid, int times_considered, bool new_
   m.times_considered_              = times_considered;
   checker_side_->get_channel().send(m);
 
-  auto* memory = get_remote_process_memory();
-  if (memory != nullptr)
+  if (auto* memory = get_remote_process_memory(); memory != nullptr)
     memory->clear_cache();
   if (checker_side_->running())
     checker_side_->dispatch_events(); // The app may send messages while processing the transition