From aa1e6cc790aa637bae2c2fd03e3cf2c5365ae478 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Thu, 14 May 2020 18:23:02 +0200 Subject: [PATCH] save the source and destination hosts in the NetworkAction --- src/surf/network_cm02.cpp | 2 +- src/surf/network_cm02.hpp | 3 ++- src/surf/network_constant.cpp | 7 ++++--- src/surf/network_constant.hpp | 2 +- src/surf/network_interface.hpp | 13 +++++++++++-- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index 28b678eaaa..9f69a5101e 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -186,7 +186,7 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz std::any_of(back_route.begin(), back_route.end(), [](const LinkImpl* link) { return not link->is_on(); }); } - auto* action = new NetworkCm02Action(this, size, failed); + auto* action = new NetworkCm02Action(this, *src, *dst, size, failed); action->sharing_penalty_ = latency; action->latency_ = latency; action->rate_ = rate; diff --git a/src/surf/network_cm02.hpp b/src/surf/network_cm02.hpp index e6648394f5..4f90b1ded2 100644 --- a/src/surf/network_cm02.hpp +++ b/src/surf/network_cm02.hpp @@ -60,7 +60,8 @@ class NetworkCm02Action : public NetworkAction { friend Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate); public: - NetworkCm02Action(Model* model, double cost, bool failed) : NetworkAction(model, cost, failed){}; + NetworkCm02Action(Model* model, s4u::Host& src, s4u::Host& dst, double cost, bool failed) + : NetworkAction(model, src, dst, cost, failed){}; virtual ~NetworkCm02Action() = default; void update_remains_lazy(double now) override; }; diff --git a/src/surf/network_constant.cpp b/src/surf/network_constant.cpp index ad2f6e0531..939ca95d6b 100644 --- a/src/surf/network_constant.cpp +++ b/src/surf/network_constant.cpp @@ -71,7 +71,7 @@ void NetworkConstantModel::update_actions_state(double /*now*/, double delta) Action* NetworkConstantModel::communicate(s4u::Host* src, s4u::Host* dst, double size, double) { - auto* action = new NetworkConstantAction(this, size, sg_latency_factor); + auto* action = new NetworkConstantAction(this, *src, *dst, size, sg_latency_factor); s4u::Link::on_communicate(*action, src, dst); return action; @@ -80,8 +80,9 @@ Action* NetworkConstantModel::communicate(s4u::Host* src, s4u::Host* dst, double /********** * Action * **********/ -NetworkConstantAction::NetworkConstantAction(NetworkConstantModel* model_, double size, double latency) - : NetworkAction(model_, size, false), initial_latency_(latency) +NetworkConstantAction::NetworkConstantAction(NetworkConstantModel* model_, s4u::Host& src, s4u::Host& dst, double size, + double latency) + : NetworkAction(model_, src, dst, size, false), initial_latency_(latency) { latency_ = latency; if (latency_ <= 0.0) diff --git a/src/surf/network_constant.hpp b/src/surf/network_constant.hpp index f007fcb1e6..282a7d2ce0 100644 --- a/src/surf/network_constant.hpp +++ b/src/surf/network_constant.hpp @@ -27,7 +27,7 @@ public: class NetworkConstantAction : public NetworkAction { public: - NetworkConstantAction(NetworkConstantModel* model_, double size, double latency); + NetworkConstantAction(NetworkConstantModel* model_, s4u::Host& src, s4u::Host& dst, double size, double latency); ~NetworkConstantAction(); double initial_latency_; void update_remains_lazy(double now) override; diff --git a/src/surf/network_interface.hpp b/src/surf/network_interface.hpp index 33515e8fb3..7c6d824847 100644 --- a/src/surf/network_interface.hpp +++ b/src/surf/network_interface.hpp @@ -167,6 +167,9 @@ public: * @details A NetworkAction represents a communication between two [hosts](@ref simgrid::surf::HostImpl) */ class NetworkAction : public Action { + s4u::Host& src_; + s4u::Host& dst_; + public: /** @brief Constructor * @@ -174,7 +177,10 @@ public: * @param cost The cost of this NetworkAction in [TODO] * @param failed [description] */ - NetworkAction(Model* model, double cost, bool failed) : Action(model, cost, failed) {} + NetworkAction(Model* model, s4u::Host& src, s4u::Host& dst, double cost, bool failed) + : Action(model, cost, failed), src_(src), dst_(dst) + { + } /** * @brief NetworkAction constructor @@ -184,7 +190,8 @@ public: * @param failed Actions can be created in a failed state * @param var The lmm variable associated to this Action if it is part of a LMM component */ - NetworkAction(Model* model, double cost, bool failed, lmm::Variable* var) : Action(model, cost, failed, var){}; + NetworkAction(Model* model, s4u::Host& src, s4u::Host& dst, double cost, bool failed, lmm::Variable* var) + : Action(model, cost, failed, var), src_(src), dst_(dst){}; void set_state(Action::State state) override; virtual std::list get_links() const; @@ -193,6 +200,8 @@ public: double lat_current_ = {}; double sharing_penalty_ = {}; double rate_ = {}; + s4u::Host& get_src() { return src_; } + s4u::Host& get_dst() { return dst_; } }; } // namespace resource } // namespace kernel -- 2.20.1