Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
s4u::Actor: Rename migrate() into set_host()
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 12 Nov 2019 11:05:01 +0000 (12:05 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 12 Nov 2019 11:26:01 +0000 (12:26 +0100)
ChangeLog
examples/python/actor-migrate/actor-migrate.py
examples/s4u/actor-migrate/s4u-actor-migrate.cpp
include/simgrid/actor.h
include/simgrid/s4u/Actor.hpp
src/bindings/python/simgrid_python.cpp
src/msg/msg_legacy.cpp
src/s4u/s4u_Actor.cpp
src/smpi/plugins/sampi_loadbalancer.cpp
teshsuite/s4u/actor-migration/actor-migration.cpp

index 0878977..4d2b347 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,7 @@ 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
+- Actor: Rename migrate() into set_host()
 
 Kernel:
 - In simgrid::kernel::resource::Model, the methods next_occuring_event*() have
index 2e0f42e..c48a0eb 100644 (file)
@@ -25,7 +25,7 @@ def worker(first_host, second_host):
     this_actor.info("Let's move to {:s} to execute {:.2f} Mflops (5sec on {:s} and 5sec on {:s})".format(
         first_host.name, flop_amount / 1e6, first_host.name, second_host.name))
 
-    this_actor.migrate(first_host)
+    this_actor.set_host(first_host)
     this_actor.execute(flop_amount)
 
     this_actor.info("I wake up on {:s}. Let's suspend a bit".format(
@@ -48,12 +48,12 @@ def monitor():
 
     this_actor.info(
         "After 5 seconds, move the process to {:s}".format(jacquelin.name))
-    actor.migrate(jacquelin)
+    actor.host = jacquelin
 
     this_actor.sleep_until(15)
     this_actor.info(
         "At t=15, move the process to {:s} and resume it.".format(fafard.name))
-    actor.migrate(fafard)
+    actor.host = fafard
     actor.resume()
 
 
index c1b3608..be035df 100644 (file)
@@ -28,7 +28,7 @@ static void worker(simgrid::s4u::Host* first, simgrid::s4u::Host* second)
   XBT_INFO("Let's move to %s to execute %.2f Mflops (5sec on %s and 5sec on %s)", first->get_cname(), flopAmount / 1e6,
            first->get_cname(), second->get_cname());
 
-  simgrid::s4u::this_actor::migrate(first);
+  simgrid::s4u::this_actor::set_host(first);
   simgrid::s4u::this_actor::execute(flopAmount);
 
   XBT_INFO("I wake up on %s. Let's suspend a bit", simgrid::s4u::this_actor::get_host()->get_cname());
@@ -50,11 +50,11 @@ static void monitor()
   simgrid::s4u::this_actor::sleep_for(5);
 
   XBT_INFO("After 5 seconds, move the process to %s", jacquelin->get_cname());
-  actor->migrate(jacquelin);
+  actor->set_host(jacquelin);
 
   simgrid::s4u::this_actor::sleep_until(15);
   XBT_INFO("At t=15, move the process to %s and resume it.", fafard->get_cname());
-  actor->migrate(fafard);
+  actor->set_host(fafard);
   actor->resume();
 }
 
index b50b957..abab87e 100644 (file)
@@ -38,7 +38,10 @@ XBT_PUBLIC int sg_actor_is_suspended(sg_actor_t actor);
 XBT_PUBLIC sg_actor_t sg_actor_restart(sg_actor_t actor);
 void sg_actor_set_auto_restart(sg_actor_t actor, int auto_restart);
 XBT_PUBLIC void sg_actor_daemonize(sg_actor_t actor);
-XBT_PUBLIC void sg_actor_migrate(sg_actor_t process, sg_host_t host);
+XBT_PUBLIC
+XBT_ATTRIB_DEPRECATED_v329("Please use sg_actor_set_host() instead") void sg_actor_migrate(sg_actor_t process,
+                                                                                           sg_host_t host);
+XBT_PUBLIC void sg_actor_set_host(sg_actor_t process, sg_host_t host);
 XBT_PUBLIC void sg_actor_join(sg_actor_t actor, double timeout);
 XBT_PUBLIC void sg_actor_kill(sg_actor_t actor);
 XBT_PUBLIC void sg_actor_kill_all();
index 725c8ec..7131856 100644 (file)
@@ -180,7 +180,10 @@ public:
    * Asynchronous activities started by the actor are not migrated automatically, so you have
    * to take care of this yourself (only you knows which ones should be migrated).
    */
-  void migrate(Host * new_host);
+  void set_host(Host* new_host);
+#ifndef DOXYGEN
+  XBT_ATTRIB_DEPRECATED_v329("Please use set_host() instead") void migrate(Host* new_host) { set_host(new_host); }
+#endif
 
   /** Ask the actor to die.
    *
@@ -363,7 +366,11 @@ XBT_PUBLIC void exit();
 XBT_PUBLIC void on_exit(const std::function<void(bool)>& fun);
 
 /** @brief Migrate the current actor to a new host. */
-XBT_PUBLIC void migrate(Host* new_host);
+XBT_PUBLIC void set_host(Host* new_host);
+#ifndef DOXYGEN
+XBT_PUBLIC
+XBT_ATTRIB_DEPRECATED_v329("Please use set_host() instead") void migrate(Host* new_host);
+#endif
 
 /** @} */
 }
index 8277188..2cc272a 100644 (file)
@@ -83,8 +83,9 @@ PYBIND11_MODULE(simgrid, m)
          py::arg("flops"), py::arg("priority") = 1);
   m2.def("exec_init", [](double flops){return simgrid::s4u::this_actor::exec_init(flops);});
   m2.def("get_host", &simgrid::s4u::this_actor::get_host, "Retrieves host on which the current actor is located");
-  m2.def("migrate", &simgrid::s4u::this_actor::migrate, "Moves the current actor to another host, see :cpp:func:`void simgrid::s4u::this_actor::migrate()`",
-      py::arg("dest"));
+  m2.def("set_host", &simgrid::s4u::this_actor::set_host,
+         "Moves the current actor to another host, see :cpp:func:`void simgrid::s4u::this_actor::set_host()`",
+         py::arg("dest"));
   m2.def("sleep_for", sleep_for_fun,
       "Block the actor sleeping for that amount of seconds, see :cpp:func:`void simgrid::s4u::this_actor::sleep_for`", py::arg("duration"));
   m2.def("sleep_until", sleep_until_fun,
@@ -251,7 +252,7 @@ PYBIND11_MODULE(simgrid, m)
              });
            },
            "Create an actor from a function or an object.")
-      .def_property("host", &Actor::get_host, &Actor::migrate, "The host on which this actor is located")
+      .def_property("host", &Actor::get_host, &Actor::set_host, "The host on which this actor is located")
       .def_property_readonly("name", &Actor::get_cname, "The name of this actor.")
       .def_property_readonly("pid", &Actor::get_pid, "The PID (unique identifier) of this actor.")
       .def_property_readonly("ppid", &Actor::get_ppid,
@@ -267,8 +268,6 @@ PYBIND11_MODULE(simgrid, m)
            "Wait for the actor to finish (more info in the C++ documentation).", py::arg("timeout"))
       .def("kill", [](ActorPtr act) { act->kill(); }, "Kill that actor")
       .def("kill_all", &Actor::kill_all, "Kill all actors but the caller.")
-      .def("migrate", &Actor::migrate, "Moves that actor to another host (more info in the C++ documentation).",
-           py::arg("dest"))
       .def("self", &Actor::self, "Retrieves the current actor.")
       .def("is_suspended", &Actor::is_suspended, "Returns True if that actor is currently suspended.")
       .def("suspend", &Actor::suspend, "Suspend that actor, that is blocked until resume()ed by another actor.")
index 6240acd..124b077 100644 (file)
@@ -102,7 +102,7 @@ void MSG_process_daemonize(sg_actor_t actor)
 }
 void MSG_process_migrate(sg_actor_t actor, sg_host_t host)
 {
-  sg_actor_migrate(actor, host);
+  sg_actor_set_host(actor, host);
 }
 void MSG_process_join(sg_actor_t actor, double timeout)
 {
index 7a50472..c188ca3 100644 (file)
@@ -126,7 +126,7 @@ void Actor::on_exit(const std::function<void(bool /*failed*/)>& fun) const
   kernel::actor::simcall([this, &fun] { SIMIX_process_on_exit(pimpl_, fun); });
 }
 
-void Actor::migrate(Host* new_host)
+void Actor::set_host(Host* new_host)
 {
   if (s4u::Actor::on_migration_start.get_slot_count() > 0) { // XBT_ATTRIB_DEPRECATED_v329
     static bool already_warned = false;
@@ -446,9 +446,13 @@ void on_exit(const std::function<void(bool)>& fun)
  *
  * @see simgrid::s4u::Actor::migrate() for more information
  */
-void migrate(Host* new_host)
+void set_host(Host* new_host)
 {
-  SIMIX_process_self()->iface()->migrate(new_host);
+  SIMIX_process_self()->iface()->set_host(new_host);
+}
+void migrate(Host* new_host) // deprecated
+{
+  set_host(new_host);
 }
 
 } // namespace this_actor
@@ -615,9 +619,13 @@ void sg_actor_daemonize(sg_actor_t actor)
  *
  * This function changes the value of the #sg_host_t on  which @a actor is running.
  */
-void sg_actor_migrate(sg_actor_t process, sg_host_t host)
+void sg_actor_set_host(sg_actor_t process, sg_host_t host)
+{
+  process->set_host(host);
+}
+void sg_actor_migrate(sg_actor_t process, sg_host_t host) // deprecated
 {
-  process->migrate(host);
+  process->set_host(host);
 }
 
 /** @ingroup m_actor_management
index c58d907..7e09b46 100644 (file)
@@ -93,7 +93,7 @@ public:
       // Update the process and host mapping in SimGrid.
       XBT_DEBUG("Migrating process %li from %s to %s", my_proc_id, cur_host->get_cname(), migrate_to_host->get_cname());
       TRACE_smpi_process_change_host(my_proc_id, migrate_to_host);
-      simgrid::s4u::this_actor::migrate(migrate_to_host);
+      simgrid::s4u::this_actor::set_host(migrate_to_host);
     }
 
     smpilb_bar.wait();
index 7138a05..28e1a3e 100644 (file)
@@ -14,15 +14,15 @@ static simgrid::s4u::ActorPtr controlled_process;
 static void emigrant()
 {
   XBT_INFO("I'll look for a new job on another machine ('Boivin') where the grass is greener.");
-  simgrid::s4u::this_actor::migrate(
+  simgrid::s4u::this_actor::set_host(
       simgrid::s4u::Host::by_name("Boivin")); /* - First, move to another host by myself */
 
   XBT_INFO("Yeah, found something to do");
   simgrid::s4u::this_actor::execute(98095000); /* - Execute some work there */
   simgrid::s4u::this_actor::sleep_for(2);
   XBT_INFO("Moving back home after work");
-  simgrid::s4u::this_actor::migrate(simgrid::s4u::Host::by_name("Jacquelin")); /* - Move back to original location */
-  simgrid::s4u::this_actor::migrate(simgrid::s4u::Host::by_name("Boivin"));    /* - Go back to the other host to sleep*/
+  simgrid::s4u::this_actor::set_host(simgrid::s4u::Host::by_name("Jacquelin")); /* - Move back to original location */
+  simgrid::s4u::this_actor::set_host(simgrid::s4u::Host::by_name("Boivin")); /* - Go back to the other host to sleep*/
   simgrid::s4u::this_actor::sleep_for(4);
   controlled_process = simgrid::s4u::Actor::self(); /* - Get controlled at checkpoint */
   barrier->wait();
@@ -37,7 +37,7 @@ static void policeman()
 {
   XBT_INFO("Wait at the checkpoint."); /* - block on the mutex+condition */
   barrier->wait();
-  controlled_process->migrate(simgrid::s4u::Host::by_name("Jacquelin")); /* - Move an emigrant to Jacquelin */
+  controlled_process->set_host(simgrid::s4u::Host::by_name("Jacquelin")); /* - Move an emigrant to Jacquelin */
   XBT_INFO("I moved the emigrant");
   controlled_process->resume();
 }