Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move hosts_ to ActivityImpl_ to allow tracking of detached comms by maestro
authorFabien Chaix <chaix@ics.forth.gr>
Tue, 17 May 2022 11:00:53 +0000 (14:00 +0300)
committerFabien Chaix <chaix@ics.forth.gr>
Wed, 18 May 2022 14:32:27 +0000 (17:32 +0300)
include/simgrid/s4u/Comm.hpp
src/kernel/activity/ActivityImpl.hpp
src/kernel/activity/CommImpl.cpp
src/kernel/activity/ExecImpl.hpp
src/surf/HostImpl.cpp

index 84b0cbb..0acc9d2 100644 (file)
@@ -158,6 +158,8 @@ public:
     return detach();
   }
 
+  Comm* abort_me();
+
   Comm* wait_for(double timeout) override;
 
   /*! take a vector s4u::CommPtr and return the rank of the first finished one (or -1 if none is done). */
index 68defdb..a5feea5 100644 (file)
@@ -38,6 +38,10 @@ public:
   resource::Action* surf_action_ = nullptr;
 
 protected:
+
+  std::vector<s4u::Host*> hosts_;
+
+
   void inline set_name(std::string_view name)
   {
     // This is to keep name_ private while allowing ActivityImpl_T<??> to set it and then return a Ptr to qualified
@@ -81,6 +85,8 @@ public:
   virtual void finish() = 0; // Unlock all simcalls blocked on that activity, either because it was marked as done by
                              // the model or because it terminated without waiting for the model
 
+  virtual const std::vector<s4u::Host*>& get_hosts() const { return hosts_;} ;
+
   void register_simcall(actor::Simcall* simcall);
   void unregister_simcall(actor::Simcall* simcall);
   void handle_activity_waitany(actor::Simcall* simcall);
index 0dc962a..67ef311 100644 (file)
@@ -11,6 +11,7 @@
 #define SIMIX_H_NO_DEPRECATED_WARNING // avoid deprecation warning on include (remove with XBT_ATTRIB_DEPRECATED_v333)
 #include <simgrid/simix.h>
 
+#include "src/kernel/EngineImpl.hpp"
 #include "src/kernel/activity/CommImpl.hpp"
 #include "src/kernel/activity/MailboxImpl.hpp"
 #include "src/kernel/actor/SimcallObserver.hpp"
@@ -61,13 +62,17 @@ CommImpl& CommImpl::set_type(CommImplType type)
 
 CommImpl& CommImpl::set_source(s4u::Host* from)
 {
+  xbt_assert( from_ == nullptr );
   from_ = from;
+  hosts_.push_back(from);
   return *this;
 }
 
 CommImpl& CommImpl::set_destination(s4u::Host* to)
 {
+  xbt_assert( to_ == nullptr );
   to_ = to;
+  hosts_.push_back(to_);
   return *this;
 }
 
index 079402b..a6c691b 100644 (file)
@@ -18,7 +18,6 @@ class XBT_PUBLIC ExecImpl : public ActivityImpl_T<ExecImpl> {
       nullptr, [](resource::Action* a) { a->unref(); }};
   double sharing_penalty_             = 1.0;
   double bound_                       = 0.0;
-  std::vector<s4u::Host*> hosts_;
   std::vector<double> flops_amounts_;
   std::vector<double> bytes_amounts_;
   int thread_count_ = 1;
index 5e7d0da..4f39fab 100644 (file)
@@ -95,12 +95,11 @@ void HostImpl::turn_off(const actor::ActorImpl* issuer)
     issuer->kill(&actor);
   }
   for (const auto& activity : EngineImpl::get_instance()->get_maestro()->activities_) {
-    auto* exec = dynamic_cast<activity::ExecImpl*>(activity.get());
-    if (exec != nullptr) {
-      auto hosts = exec->get_hosts();
+    if (activity != nullptr) {
+      auto hosts = activity->get_hosts();
       if (std::find(hosts.begin(), hosts.end(), &piface_) != hosts.end()) {
-        exec->cancel();
-        exec->set_state(activity::State::FAILED);
+        activity->cancel();
+        activity->set_state(activity::State::FAILED);
       }
     }
   }