Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move ::wait_for() from ExecImpl and IoImpl to ActivityImpl.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 10 Feb 2020 15:02:14 +0000 (16:02 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 10 Feb 2020 15:08:10 +0000 (16:08 +0100)
src/kernel/activity/ActivityImpl.cpp
src/kernel/activity/ActivityImpl.hpp
src/kernel/activity/ExecImpl.cpp
src/kernel/activity/ExecImpl.hpp
src/kernel/activity/IoImpl.cpp
src/kernel/activity/IoImpl.hpp

index a4060f6..86aeca3 100644 (file)
@@ -4,6 +4,8 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "src/kernel/activity/ActivityImpl.hpp"
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "src/kernel/activity/ActivityImpl.hpp"
+#include "simgrid/modelchecker.h"
+#include "src/mc/mc_replay.hpp"
 #include "src/simix/smx_private.hpp"
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_process);
 #include "src/simix/smx_private.hpp"
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_process);
@@ -46,6 +48,38 @@ bool ActivityImpl::test()
   return false;
 }
 
   return false;
 }
 
+void ActivityImpl::wait_for(actor::ActorImpl* issuer, double timeout)
+{
+  XBT_DEBUG("Wait for execution of synchro %p, state %d", this, (int)state_);
+  xbt_assert(std::isfinite(timeout), "timeout is not finite!");
+
+  /* Associate this simcall to the synchro */
+  register_simcall(&issuer->simcall);
+
+  if (MC_is_active() || MC_record_replay_is_active()) {
+    int idx = SIMCALL_GET_MC_VALUE(issuer->simcall);
+    if (idx == 0) {
+      state_ = simgrid::kernel::activity::State::DONE;
+    } else {
+      /* If we reached this point, the wait simcall must have a timeout */
+      /* Otherwise it shouldn't be enabled and executed by the MC */
+      if (timeout < 0.0)
+        THROW_IMPOSSIBLE;
+      state_ = simgrid::kernel::activity::State::TIMEOUT;
+    }
+    finish();
+    return;
+  }
+
+  /* If the synchro is already finished then perform the error handling */
+  if (state_ != simgrid::kernel::activity::State::RUNNING)
+    finish();
+  else {
+    /* we need a sleep action (even when there is no timeout) to be notified of host failures */
+    set_timeout(timeout);
+  }
+}
+
 void ActivityImpl::suspend()
 {
   if (surf_action_ == nullptr)
 void ActivityImpl::suspend()
 {
   if (surf_action_ == nullptr)
index dbc48bd..c2636da 100644 (file)
@@ -45,6 +45,7 @@ public:
   resource::Action* surf_action_ = nullptr;
 
   bool test();
   resource::Action* surf_action_ = nullptr;
 
   bool test();
+  void wait_for(actor::ActorImpl* issuer, double timeout);
   virtual ActivityImpl& set_timeout(double timeout) { THROW_UNIMPLEMENTED; }
 
   virtual void suspend();
   virtual ActivityImpl& set_timeout(double timeout) { THROW_UNIMPLEMENTED; }
 
   virtual void suspend();
index fc685ed..433d9ba 100644 (file)
@@ -120,37 +120,6 @@ ExecImpl* ExecImpl::start()
   return this;
 }
 
   return this;
 }
 
-void ExecImpl::wait_for(actor::ActorImpl* issuer, double timeout)
-{
-  XBT_DEBUG("Wait for execution of synchro %p, state %d", this, (int)state_);
-  xbt_assert(std::isfinite(timeout), "timeout is not finite!");
-
-  /* Associate this simcall to the synchro */
-  register_simcall(&issuer->simcall);
-
-  if (MC_is_active() || MC_record_replay_is_active()) {
-    int idx = SIMCALL_GET_MC_VALUE(issuer->simcall);
-    if (idx == 0) {
-      state_ = simgrid::kernel::activity::State::DONE;
-    } else {
-      /* If we reached this point, the wait simcall must have a timeout */
-      /* Otherwise it shouldn't be enabled and executed by the MC */
-      if (timeout < 0.0)
-        THROW_IMPOSSIBLE;
-      state_ = simgrid::kernel::activity::State::TIMEOUT;
-    }
-    finish();
-    return;
-  }
-
-  /* If the synchro is already finished then perform the error handling */
-  if (state_ != simgrid::kernel::activity::State::RUNNING) {
-    finish();
-  } else { /* we need a sleep action (even when there is no timeout) to be notified of host failures */
-    set_timeout(timeout);
-  }
-}
-
 double ExecImpl::get_seq_remaining_ratio()
 {
   return (surf_action_ == nullptr) ? 0 : surf_action_->get_remains() / surf_action_->get_cost();
 double ExecImpl::get_seq_remaining_ratio()
 {
   return (surf_action_ == nullptr) ? 0 : surf_action_->get_remains() / surf_action_->get_cost();
index 0a3180c..b233677 100644 (file)
@@ -42,7 +42,6 @@ public:
   virtual ActivityImpl* migrate(s4u::Host* to);
 
   ExecImpl* start();
   virtual ActivityImpl* migrate(s4u::Host* to);
 
   ExecImpl* start();
-  void wait_for(actor::ActorImpl* issuer, double timeout);
   void post() override;
   void finish() override;
 
   void post() override;
   void finish() override;
 
index a246446..0a7cc64 100644 (file)
@@ -71,37 +71,6 @@ IoImpl* IoImpl::start()
   return this;
 }
 
   return this;
 }
 
-void IoImpl::wait_for(actor::ActorImpl* issuer, double timeout)
-{
-  XBT_DEBUG("Wait for execution of synchro %p, state %d", this, (int)state_);
-
-  /* Associate this simcall to the synchro */
-  register_simcall(&issuer->simcall);
-
-  if (MC_is_active() || MC_record_replay_is_active()) {
-    int idx = SIMCALL_GET_MC_VALUE(issuer->simcall);
-    if (idx == 0) {
-      state_ = simgrid::kernel::activity::State::DONE;
-    } else {
-      /* If we reached this point, the wait simcall must have a timeout */
-      /* Otherwise it shouldn't be enabled and executed by the MC */
-      if (timeout < 0.0)
-        THROW_IMPOSSIBLE;
-      state_ = simgrid::kernel::activity::State::TIMEOUT;
-    }
-    finish();
-    return;
-  }
-
-  /* If the synchro is already finished then perform the error handling */
-  if (state_ != simgrid::kernel::activity::State::RUNNING)
-    finish();
-  else {
-    /* we need a sleep action (even when there is no timeout) to be notified of host failures */
-    set_timeout(timeout);
-  }
-}
-
 void IoImpl::post()
 {
   performed_ioops_ = surf_action_->get_cost();
 void IoImpl::post()
 {
   performed_ioops_ = surf_action_->get_cost();
index 92680f7..707372e 100644 (file)
@@ -34,7 +34,6 @@ public:
   resource::StorageImpl* get_storage() const { return storage_; }
 
   IoImpl* start();
   resource::StorageImpl* get_storage() const { return storage_; }
 
   IoImpl* start();
-  void wait_for(actor::ActorImpl* issuer, double timeout);
   void post() override;
   void finish() override;
 
   void post() override;
   void finish() override;