From fdbc52907d138de71505e054454de0f33954598f Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Thu, 14 May 2020 18:29:42 +0200 Subject: [PATCH] remove the src and dst from the Link::on_communicate callback since it's now in the action --- include/simgrid/s4u/Link.hpp | 2 +- src/plugins/host_dvfs.cpp | 11 +++++------ src/plugins/link_energy.cpp | 3 +-- src/s4u/s4u_Link.cpp | 2 +- src/surf/network_cm02.cpp | 2 +- src/surf/network_constant.cpp | 2 +- src/surf/network_ib.cpp | 7 +++---- 7 files changed, 13 insertions(+), 16 deletions(-) diff --git a/include/simgrid/s4u/Link.hpp b/include/simgrid/s4u/Link.hpp index d5d13bba1d..89f4f792d4 100644 --- a/include/simgrid/s4u/Link.hpp +++ b/include/simgrid/s4u/Link.hpp @@ -99,7 +99,7 @@ public: static xbt::signal on_bandwidth_change; /** @brief Callback signal fired when a communication starts */ - static xbt::signal on_communicate; + static xbt::signal on_communicate; /** @brief Callback signal fired when a communication changes it state (ready/done/cancel) */ static xbt::signal diff --git a/src/plugins/host_dvfs.cpp b/src/plugins/host_dvfs.cpp index 2232332b1e..b46ed2d000 100644 --- a/src/plugins/host_dvfs.cpp +++ b/src/plugins/host_dvfs.cpp @@ -304,12 +304,11 @@ public: }); // FIXME I think that this fires at the same time for all hosts, so when the src sends something, // the dst will be notified even though it didn't even arrive at the recv yet - simgrid::s4u::Link::on_communicate.connect( - [this](const kernel::resource::NetworkAction&, const s4u::Host* src, const s4u::Host* dst) { - if ((get_host() == src || get_host() == dst) && iteration_running) { - post_task(); - } - }); + simgrid::s4u::Link::on_communicate.connect([this](const kernel::resource::NetworkAction& act) { + if ((get_host() == &act.get_src() || get_host() == &act.get_dst()) && iteration_running) { + post_task(); + } + }); } std::string get_name() const override { return "Adagio"; } diff --git a/src/plugins/link_energy.cpp b/src/plugins/link_energy.cpp index e75c128cb2..4f076c0687 100644 --- a/src/plugins/link_energy.cpp +++ b/src/plugins/link_energy.cpp @@ -148,8 +148,7 @@ double LinkEnergy::get_consumed_energy() using simgrid::plugin::LinkEnergy; /* **************************** events callback *************************** */ -static void on_communicate(const simgrid::kernel::resource::NetworkAction& action, const simgrid::s4u::Host*, - const simgrid::s4u::Host*) +static void on_communicate(const simgrid::kernel::resource::NetworkAction& action) { XBT_DEBUG("onCommunicate is called"); for (simgrid::kernel::resource::LinkImpl* link : action.get_links()) { diff --git a/src/s4u/s4u_Link.cpp b/src/s4u/s4u_Link.cpp index 44742271e1..bec2b9e757 100644 --- a/src/s4u/s4u_Link.cpp +++ b/src/s4u/s4u_Link.cpp @@ -23,7 +23,7 @@ xbt::signal Link::on_creation; xbt::signal Link::on_destruction; xbt::signal Link::on_state_change; xbt::signal Link::on_bandwidth_change; -xbt::signal Link::on_communicate; +xbt::signal Link::on_communicate; xbt::signal Link::on_communication_state_change; diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index 9f69a5101e..0e7d31becc 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -287,7 +287,7 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz } XBT_OUT(); - simgrid::s4u::Link::on_communicate(*action, src, dst); + simgrid::s4u::Link::on_communicate(*action); return action; } diff --git a/src/surf/network_constant.cpp b/src/surf/network_constant.cpp index 939ca95d6b..0b7e322a34 100644 --- a/src/surf/network_constant.cpp +++ b/src/surf/network_constant.cpp @@ -73,7 +73,7 @@ Action* NetworkConstantModel::communicate(s4u::Host* src, s4u::Host* dst, double { auto* action = new NetworkConstantAction(this, *src, *dst, size, sg_latency_factor); - s4u::Link::on_communicate(*action, src, dst); + s4u::Link::on_communicate(*action); return action; } diff --git a/src/surf/network_ib.cpp b/src/surf/network_ib.cpp index 90cb7daabd..dfcaf91401 100644 --- a/src/surf/network_ib.cpp +++ b/src/surf/network_ib.cpp @@ -41,12 +41,11 @@ static void IB_action_state_changed_callback(simgrid::kernel::resource::NetworkA ((NetworkIBModel*)surf_network_model)->active_comms.erase(&action); } -static void IB_action_init_callback(simgrid::kernel::resource::NetworkAction& action, const simgrid::s4u::Host* src, - const simgrid::s4u::Host* dst) +static void IB_action_init_callback(simgrid::kernel::resource::NetworkAction& action) { simgrid::kernel::resource::NetworkIBModel* ibModel = (simgrid::kernel::resource::NetworkIBModel*)surf_network_model; - simgrid::kernel::resource::IBNode* act_src = &ibModel->active_nodes.at(src->get_name()); - simgrid::kernel::resource::IBNode* act_dst = &ibModel->active_nodes.at(dst->get_name()); + simgrid::kernel::resource::IBNode* act_src = &ibModel->active_nodes.at(action.get_src().get_name()); + simgrid::kernel::resource::IBNode* act_dst = &ibModel->active_nodes.at(action.get_dst().get_name()); ibModel->active_comms[&action] = std::make_pair(act_src, act_dst); ibModel->updateIBfactors(&action, act_src, act_dst, 0); -- 2.30.2