From: Fabien Chaix Date: Tue, 17 May 2022 11:00:53 +0000 (+0300) Subject: Move hosts_ to ActivityImpl_ to allow tracking of detached comms by maestro X-Git-Tag: v3.32~233^2~5 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/e8189846950b9f46f726ad4b7c06ff162feb7e2c?ds=inline Move hosts_ to ActivityImpl_ to allow tracking of detached comms by maestro --- diff --git a/include/simgrid/s4u/Comm.hpp b/include/simgrid/s4u/Comm.hpp index 84b0cbbb3f..0acc9d25fa 100644 --- a/include/simgrid/s4u/Comm.hpp +++ b/include/simgrid/s4u/Comm.hpp @@ -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). */ diff --git a/src/kernel/activity/ActivityImpl.hpp b/src/kernel/activity/ActivityImpl.hpp index 68defdbbb9..a5feea5a0a 100644 --- a/src/kernel/activity/ActivityImpl.hpp +++ b/src/kernel/activity/ActivityImpl.hpp @@ -38,6 +38,10 @@ public: resource::Action* surf_action_ = nullptr; protected: + + std::vector 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& get_hosts() const { return hosts_;} ; + void register_simcall(actor::Simcall* simcall); void unregister_simcall(actor::Simcall* simcall); void handle_activity_waitany(actor::Simcall* simcall); diff --git a/src/kernel/activity/CommImpl.cpp b/src/kernel/activity/CommImpl.cpp index 0dc962a8f6..67ef311ab9 100644 --- a/src/kernel/activity/CommImpl.cpp +++ b/src/kernel/activity/CommImpl.cpp @@ -11,6 +11,7 @@ #define SIMIX_H_NO_DEPRECATED_WARNING // avoid deprecation warning on include (remove with XBT_ATTRIB_DEPRECATED_v333) #include +#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; } diff --git a/src/kernel/activity/ExecImpl.hpp b/src/kernel/activity/ExecImpl.hpp index 079402b30f..a6c691b423 100644 --- a/src/kernel/activity/ExecImpl.hpp +++ b/src/kernel/activity/ExecImpl.hpp @@ -18,7 +18,6 @@ class XBT_PUBLIC ExecImpl : public ActivityImpl_T { nullptr, [](resource::Action* a) { a->unref(); }}; double sharing_penalty_ = 1.0; double bound_ = 0.0; - std::vector hosts_; std::vector flops_amounts_; std::vector bytes_amounts_; int thread_count_ = 1; diff --git a/src/surf/HostImpl.cpp b/src/surf/HostImpl.cpp index 5e7d0da0e6..4f39fab210 100644 --- a/src/surf/HostImpl.cpp +++ b/src/surf/HostImpl.cpp @@ -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.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); } } }