Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add sg_actor_parallel_execute and rename sg_actor_self_execute
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 25 Feb 2020 10:14:30 +0000 (11:14 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 25 Feb 2020 10:53:13 +0000 (11:53 +0100)
if a sg_actor_* function has no actor as first parameter, it is
executed by this_actor

12 files changed:
examples/c/actor-daemon/actor-daemon.c
examples/c/actor-exiting/actor-exiting.c
examples/c/actor-kill/actor-kill.c
examples/c/actor-migrate/actor-migrate.c
examples/c/actor-suspend/actor-suspend.c
examples/c/cloud-simple/cloud-simple.c
examples/c/energy-exec/energy-exec.c
examples/c/energy-vm/energy-vm.c
examples/c/exec-dvfs/exec-dvfs.c
examples/c/plugin-hostload/plugin-hostload.c
include/simgrid/actor.h
src/s4u/s4u_Actor.cpp

index 56e0f62..9e1bd7e 100644 (file)
@@ -15,7 +15,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(actor_daemon, "Messages specific for this example")
 static void worker(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
 {
   XBT_INFO("Let's do some work (for 10 sec on Boivin).");
-  sg_actor_self_execute(980.95e6);
+  sg_actor_execute(980.95e6);
   XBT_INFO("I'm done now. I leave even if it makes the daemon die.");
 }
 
index c556c15..cde29b7 100644 (file)
@@ -36,7 +36,7 @@ static void actor_fun(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[]
   // Register a lambda function to be executed once it stops
   sg_actor_on_exit(&my_on_exit, NULL);
 
-  sg_actor_self_execute(1e9);
+  sg_actor_execute(1e9);
 }
 
 int main(int argc, char* argv[])
index d0795cd..8a8a9be 100644 (file)
@@ -25,7 +25,7 @@ static void victimA_fun(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv
   XBT_INFO("Suspending myself");
   sg_actor_suspend(sg_actor_self()); /* - First suspend itself */
   XBT_INFO("OK, OK. Let's work");    /* - Then is resumed and start to execute a task */
-  sg_actor_self_execute(1e9);
+  sg_actor_execute(1e9);
   XBT_INFO("Bye!"); /* - But will never reach the end of it */
 }
 
index 0f28565..ce36bb3 100644 (file)
@@ -25,7 +25,7 @@ static void worker(int argc, char* argv[])
            argv[2]);
 
   sg_actor_set_host(sg_actor_self(), first);
-  sg_actor_self_execute(flopAmount);
+  sg_actor_execute(flopAmount);
 
   XBT_INFO("I wake up on %s. Let's suspend a bit", sg_host_get_name(sg_host_self()));
 
index 2a01be8..604dfc0 100644 (file)
@@ -29,7 +29,7 @@ static void lazy_guy(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
   XBT_INFO("Waking up once for all!");
 
   XBT_INFO("Ok, let's do some work, then (for 10 sec on Boivin).");
-  sg_actor_self_execute(980.95e6);
+  sg_actor_execute(980.95e6);
 
   XBT_INFO("Mmmh, I'm done now. Goodbye.");
 }
index 2247ee7..6d20bb0 100644 (file)
@@ -21,7 +21,7 @@ static void computation_fun(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char*
   const char* host_name = sg_host_get_name(sg_host_self());
 
   double clock_sta = simgrid_get_clock();
-  sg_actor_self_execute(1000000);
+  sg_actor_execute(1000000);
   double clock_end = simgrid_get_clock();
 
   XBT_INFO("%s:%s task executed %g", host_name, pr_name, clock_end - clock_sta);
index bddb036..e223218 100644 (file)
@@ -31,7 +31,7 @@ static void dvfs(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
   // Run a task
   start = simgrid_get_clock();
   XBT_INFO("Run a task of %.0E flops", 100E6);
-  sg_actor_self_execute(100E6);
+  sg_actor_execute(100E6);
   XBT_INFO("Task done (duration: %.2f s). Current peak speed=%.0E flop/s; Current consumption: from %.0fW to %.0fW"
            " depending on load; Energy dissipated=%.0f J",
            simgrid_get_clock() - start, sg_host_speed(host), sg_host_get_wattmin_at(host, sg_host_get_pstate(host)),
@@ -46,7 +46,7 @@ static void dvfs(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
   // Run a second task
   start = simgrid_get_clock();
   XBT_INFO("Run a task of %.0E flops", 100E6);
-  sg_actor_self_execute(100E6);
+  sg_actor_execute(100E6);
   XBT_INFO("Task done (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
            simgrid_get_clock() - start, sg_host_speed(host), sg_host_get_consumed_energy(host));
 
index f3e25b9..9a20d33 100644 (file)
@@ -16,7 +16,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(energy_vm, "Messages of this example");
 
 static void worker_func(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
 {
-  sg_actor_self_execute(300E6);
+  sg_actor_execute(300E6);
   XBT_INFO("This worker is done.");
 }
 
index 0d14933..8956538 100644 (file)
@@ -23,7 +23,7 @@ static void dvfs(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
   double current_peak = sg_host_speed(host);
   XBT_INFO("Current power peak=%f", current_peak);
 
-  sg_actor_self_execute(100E6);
+  sg_actor_execute(100E6);
 
   double task_time = simgrid_get_clock();
   XBT_INFO("Task1 simulation time: %e", task_time);
@@ -41,7 +41,7 @@ static void dvfs(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
   current_peak = sg_host_speed(host);
   XBT_INFO("Current power peak=%f", current_peak);
 
-  sg_actor_self_execute(100E6);
+  sg_actor_execute(100E6);
 
   task_time = simgrid_get_clock() - task_time;
   XBT_INFO("Task2 simulation time: %e", task_time);
index b698fbc..dff588d 100644 (file)
@@ -34,7 +34,7 @@ static void execute_load_test(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char
   // Run a task
   start = simgrid_get_clock();
   XBT_INFO("Run a task of %.0E flops at current speed of %.0E flop/s", 200e6, sg_host_speed(host));
-  sg_actor_self_execute(200e6);
+  sg_actor_execute(200e6);
 
   XBT_INFO("Done working on my task; this took %.2fs; current peak speed: %.0E flop/s (when I started the computation, "
            "the speed was set to %.0E flop/s); number of flops computed so "
@@ -54,7 +54,7 @@ static void execute_load_test(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char
   // Run a second task
   start = simgrid_get_clock();
   XBT_INFO("Run a task of %.0E flops", 100e6);
-  sg_actor_self_execute(100e6);
+  sg_actor_execute(100e6);
   XBT_INFO("Done working on my task; this took %.2fs; current peak speed: %.0E flop/s; number of flops computed so "
            "far: %.2E",
            simgrid_get_clock() - start, sg_host_speed(host), sg_host_get_computed_flops(host));
index b5de5fd..b006a24 100644 (file)
@@ -64,7 +64,9 @@ XBT_PUBLIC aid_t sg_actor_self_get_ppid();
 XBT_PUBLIC const char* sg_actor_self_get_name();
 XBT_PUBLIC void* sg_actor_self_data();
 XBT_PUBLIC void sg_actor_self_data_set(void* data);
-XBT_PUBLIC void sg_actor_self_execute(double flops);
+XBT_ATTRIB_DEPRECATED_v330("Please use sg_actor_execute() instead") XBT_PUBLIC void sg_actor_self_execute(double flops);
+XBT_PUBLIC void sg_actor_execute(double flops);
+void sg_actor_parallel_execute(int host_nb, sg_host_t* host_list, double* flops_amount, double* bytes_amount);
 XBT_PUBLIC void sg_actor_ref(const_sg_actor_t actor);
 XBT_PUBLIC void sg_actor_unref(const_sg_actor_t actor);
 XBT_PUBLIC void* sg_actor_data(const_sg_actor_t actor);
index e230a33..b539dbd 100644 (file)
@@ -739,11 +739,29 @@ sg_actor_t sg_actor_self()
   return simgrid::s4u::Actor::self();
 }
 
-void sg_actor_self_execute(double flops)
+void sg_actor_self_execute(double flops) // XBT_DEPRECATED_v330
 {
   simgrid::s4u::this_actor::execute(flops);
 }
 
+void sg_actor_execute(double flops)
+{
+  simgrid::s4u::this_actor::execute(flops);
+}
+
+void sg_actor_parallel_execute(int host_nb, sg_host_t* host_list, double* flops_amount, double* bytes_amount)
+{
+  std::vector<simgrid::s4u::Host*> hosts(host_list, host_list + host_nb);
+  std::vector<double> flops;
+  std::vector<double> bytes;
+  if (flops_amount != nullptr)
+    flops = std::vector<double>(flops_amount, flops_amount + host_nb);
+  if (bytes_amount != nullptr)
+    bytes = std::vector<double>(bytes_amount, bytes_amount + host_nb * host_nb);
+
+  simgrid::s4u::this_actor::parallel_execute(hosts, flops, bytes);
+}
+
 /** @brief Take an extra reference on that actor to prevent it to be garbage-collected */
 void sg_actor_ref(const_sg_actor_t actor)
 {