From d6ba60ce19ac593de280c8dd791ee33d1df81bb9 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Tue, 12 Nov 2019 11:48:38 +0100 Subject: [PATCH] s4u::Actor: Merge signals on_migration_start/end into on_host_change --- ChangeLog | 3 +++ include/simgrid/s4u/Actor.hpp | 9 ++++++--- src/instr/instr_platform.cpp | 13 ++++--------- src/s4u/s4u_Actor.cpp | 29 +++++++++++++++++++++++++---- 4 files changed, 38 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2e47233f68..08789773d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,9 @@ SimGrid (3.24.1) NOT RELEASED YET (v3.25 expected December 22. 2029, 04:19 UTC) +S4U: +- Actor: Merge signals on_migration_start/end into on_host_change + Kernel: - In simgrid::kernel::resource::Model, the methods next_occuring_event*() have been renamed to fix a spelling error. As usual, the previous definitions are diff --git a/include/simgrid/s4u/Actor.hpp b/include/simgrid/s4u/Actor.hpp index d0b6d4c091..725c8ec7a0 100644 --- a/include/simgrid/s4u/Actor.hpp +++ b/include/simgrid/s4u/Actor.hpp @@ -74,10 +74,13 @@ public: static xbt::signal on_sleep; /** Signal to others that an actor wakes up for a sleep **/ static xbt::signal on_wake_up; - /** Signal to others that an actor is going to migrated to another host**/ - static xbt::signal on_migration_start; /** Signal to others that an actor is has been migrated to another host **/ - static xbt::signal on_migration_end; + static xbt::signal on_host_change; +#ifndef DOXYGEN + static xbt::signal on_migration_start; // XBT_ATTRIB_DEPRECATED_v329 + static xbt::signal on_migration_end; // XBT_ATTRIB_DEPRECATED_v329 +#endif + /** Signal indicating that an actor terminated its code. * The actor may continue to exist if it is still referenced in the simulation, but it's not active anymore. * If you want to free extra data when the actor's destructor is called, use Actor::on_destruction. diff --git a/src/instr/instr_platform.cpp b/src/instr/instr_platform.cpp index f72c308a71..56f47476be 100644 --- a/src/instr/instr_platform.cpp +++ b/src/instr/instr_platform.cpp @@ -312,20 +312,16 @@ static void instr_actor_on_creation(simgrid::s4u::Actor const& actor) }); } -static long long int counter = 0; - -static void instr_actor_on_migration_start(simgrid::s4u::Actor const& actor) +static void instr_actor_on_host_change(simgrid::s4u::Actor const& actor, + simgrid::s4u::Host const& /*previous_location*/) { + static long long int counter = 0; // start link container_t container = simgrid::instr::Container::by_name(instr_pid(actor)); simgrid::instr::Container::get_root()->get_link("ACTOR_LINK")->start_event(container, "M", std::to_string(counter)); // destroy existing container of this process container->remove_from_parent(); -} - -static void instr_actor_on_migration_end(simgrid::s4u::Actor const& actor) -{ // create new container on the new_host location simgrid::instr::Container::by_name(actor.get_host()->get_name())->create_child(instr_pid(actor), "ACTOR"); // end link @@ -403,8 +399,7 @@ void instr_define_callbacks() simgrid::s4u::Comm::on_completion.connect([](simgrid::s4u::Actor const& actor) { simgrid::instr::Container::by_name(instr_pid(actor))->get_state("ACTOR_STATE")->pop_event(); }); - simgrid::s4u::Actor::on_migration_start.connect(instr_actor_on_migration_start); - simgrid::s4u::Actor::on_migration_end.connect(instr_actor_on_migration_end); + simgrid::s4u::Actor::on_host_change.connect(instr_actor_on_host_change); } if (TRACE_vm_is_enabled()) { diff --git a/src/s4u/s4u_Actor.cpp b/src/s4u/s4u_Actor.cpp index 10e25304e8..7a50472137 100644 --- a/src/s4u/s4u_Actor.cpp +++ b/src/s4u/s4u_Actor.cpp @@ -28,8 +28,9 @@ xbt::signal s4u::Actor::on_suspend; xbt::signal s4u::Actor::on_resume; xbt::signal s4u::Actor::on_sleep; xbt::signal s4u::Actor::on_wake_up; -xbt::signal s4u::Actor::on_migration_start; -xbt::signal s4u::Actor::on_migration_end; +xbt::signal s4u::Actor::on_migration_start; // deprecated +xbt::signal s4u::Actor::on_migration_end; // deprecated +xbt::signal s4u::Actor::on_host_change; xbt::signal s4u::Actor::on_termination; xbt::signal s4u::Actor::on_destruction; @@ -127,7 +128,17 @@ void Actor::on_exit(const std::function& fun) const void Actor::migrate(Host* new_host) { - s4u::Actor::on_migration_start(*this); + if (s4u::Actor::on_migration_start.get_slot_count() > 0) { // XBT_ATTRIB_DEPRECATED_v329 + static bool already_warned = false; + if (not already_warned) { + XBT_INFO("Please use s4u::Actor::on_host_change instead of s4u::Actor::on_migration_start. This will be removed " + "in v3.29"); + already_warned = true; + } + s4u::Actor::on_migration_start(*this); + } + + auto* previous_location = get_host(); kernel::actor::simcall([this, new_host]() { if (pimpl_->waiting_synchro != nullptr) { @@ -141,7 +152,17 @@ void Actor::migrate(Host* new_host) this->pimpl_->set_host(new_host); }); - s4u::Actor::on_migration_end(*this); + if (s4u::Actor::on_migration_end.get_slot_count() > 0) { // XBT_ATTRIB_DEPRECATED_v329 + static bool already_warned = false; + if (not already_warned) { + XBT_INFO("Please use s4u::Actor::on_host_change instead of s4u::Actor::on_migration_end. This will be removed in " + "v3.29"); + already_warned = true; + } + s4u::Actor::on_migration_end(*this); + } + + s4u::Actor::on_host_change(*this, *previous_location); } s4u::Host* Actor::get_host() const -- 2.20.1