Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Further simplify the way host failures are detected
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 26 Feb 2023 11:11:49 +0000 (12:11 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 26 Feb 2023 11:19:30 +0000 (12:19 +0100)
Do as it's done in links and communications: when the resource is
turned off, simply mark the actions it hosts as FAILED.

That's much simpler than the convoluted existing code, which relied on
the Host::on_state_change signal. Each activity pushed a callback to
check whether it was its host which failed. Gosh, so convoluted...

The current change is not completely applied to CpuTI model, which
seems to have another way to mark the actions as failing. So I
override CpuTI::turn_off() to not mark the actions as failing to avoid
a segfault. It's a bit lame, but CpuTI is too different, I feel lazy.

src/kernel/activity/ExecImpl.cpp
src/kernel/resource/CpuImpl.cpp
src/kernel/resource/CpuImpl.hpp
src/kernel/resource/models/cpu_ti.cpp
src/kernel/resource/models/cpu_ti.hpp

index d9badf2..6d66a12 100644 (file)
@@ -88,15 +88,6 @@ ExecImpl* ExecImpl::start()
     set_start_time(model_action_->get_start_time());
   }
 
-  /* Allow execs to fail if any their host fail (or any of their host for parallel execs) */
-  cb_id_ = s4u::Host::on_state_change.connect([this](s4u::Host const& h) {
-    if (not h.is_on() && get_state() == kernel::activity::State::RUNNING &&
-        std::find(get_hosts().begin(), get_hosts().end(), &h) != get_hosts().end()) {
-      set_state(kernel::activity::State::FAILED);
-      finish();
-    }
-  });
-
   XBT_DEBUG("Create execute synchro %p: %s", this, get_cname());
   return this;
 }
index b2b8101..c69d23a 100644 (file)
@@ -4,6 +4,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "src/kernel/resource/CpuImpl.hpp"
+#include "src/kernel/EngineImpl.hpp"
 #include "src/kernel/resource/models/cpu_ti.hpp"
 #include "src/kernel/resource/profile/Profile.hpp"
 #include "src/simgrid/math_utils.h"
@@ -151,6 +152,23 @@ void CpuImpl::seal()
   Resource::seal();
 }
 
+void CpuImpl::turn_off()
+{
+  if (is_on()) {
+    Resource::turn_off();
+
+    const kernel::lmm::Element* elem = nullptr;
+    double now                       = EngineImpl::get_clock();
+    while (const auto* var = get_constraint()->get_variable(&elem)) {
+      Action* action = var->get_id();
+      if (action->get_state() == Action::State::INITED || action->get_state() == Action::State::STARTED) {
+        action->set_finish_time(now);
+        action->set_state(Action::State::FAILED);
+      }
+    }
+  }
+}
+
 /**********
  * Action *
  **********/
index af08d0c..6237702 100644 (file)
@@ -78,6 +78,8 @@ public:
   CpuImpl* set_core_count(int core_count);
   virtual int get_core_count() const { return core_count_; }
 
+  void turn_off() override;
+
   bool is_used() const override { return true; }
 
   void seal() override;
index 401a212..c927bec 100644 (file)
@@ -337,6 +337,16 @@ CpuTi::~CpuTi()
   delete speed_integrated_trace_;
 }
 
+void CpuTi::turn_off()
+{
+  /* Skip CpuImpl::turn_off() that marks the actions as failing, as it seems to be done otherwise in CPU TI.
+   * So, just avoid the segfault for now.
+   *
+   * TODO: a proper solution would be to understand and adapt the way actions are marked FAILED in here,
+   * and adapt it to align with the other resources. */
+  Resource::turn_off();
+}
+
 CpuImpl* CpuTi::set_speed_profile(kernel::profile::Profile* profile)
 {
   delete speed_integrated_trace_;
index 214013f..9def4f1 100644 (file)
@@ -107,6 +107,7 @@ public:
   ~CpuTi() override;
 
   CpuImpl* set_speed_profile(profile::Profile* profile) override;
+  void turn_off() override;
 
   void apply_event(profile::Event* event, double value) override;
   void update_actions_finish_time(double now);