cloud-capping cloud-migration cloud-simple
energy-exec energy-boot energy-link energy-vm
engine-filtering
- exec-async exec-basic exec-dvfs exec-monitor exec-ptask exec-remote
+ exec-async exec-basic exec-dvfs exec-ptask exec-remote
io-async io-file-system io-file-remote io-storage-raw
platform-failures platform-profile platform-properties
plugin-hostload
background threads.
|br| `examples/s4u/exec-async/s4u-exec-async.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/exec-async/s4u-exec-async.cpp>`_
- - **Monitoring asynchronous executions:**
- This example shows how to start an asynchronous execution, and
- monitor its status.
- |br| `examples/s4u/exec-monitor/s4u-exec-monitor.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/exec-monitor/s4u-exec-monitor.cpp>`_
-
- **Remote execution:**
- Before its start, you can change the host on which a given execution will occur.
+ You can start executions on remote hosts, or even change the host
+ on which they occur during their execution.
|br| `examples/s4u/exec-remote/s4u-exec-remote.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/exec-remote/s4u-exec-remote.cpp>`_
- **Using Pstates on a host:**
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
-static void test(double computation_amount, double priority)
+/* This actor simply waits for its task completion after starting it.
+ * That's exactly equivalent to synchronous execution. */
+static void waiter()
{
- XBT_INFO("Hello! Execute %g flops with priority %g", computation_amount, priority);
+ double computation_amount = simgrid::s4u::this_actor::get_host()->get_speed();
+ XBT_INFO("Execute %g flops, should take 1 second.", computation_amount);
simgrid::s4u::ExecPtr activity = simgrid::s4u::this_actor::exec_init(computation_amount);
- activity->set_priority(priority);
activity->start();
activity->wait();
XBT_INFO("Goodbye now!");
}
-static void test_cancel(double computation_amount)
+/* This actor tests the ongoing execution until its completion, and don't wait before it's terminated. */
+static void monitor()
{
- XBT_INFO("Hello! Execute %g flops, should take 1 second", computation_amount);
+ double computation_amount = simgrid::s4u::this_actor::get_host()->get_speed();
+ XBT_INFO("Execute %g flops, should take 1 second.", computation_amount);
+ simgrid::s4u::ExecPtr activity = simgrid::s4u::this_actor::exec_init(computation_amount);
+ activity->start();
+
+ while (not activity->test()) {
+ XBT_INFO("Remaining amount of flops: %g (%.0f%%)", activity->get_remaining(),
+ 100 * activity->get_remaining_ratio());
+ simgrid::s4u::this_actor::sleep_for(0.3);
+ }
+ activity->wait();
+
+ XBT_INFO("Goodbye now!");
+}
+
+/* This actor cancels the ongoing execution after a while. */
+static void canceller()
+{
+ double computation_amount = simgrid::s4u::this_actor::get_host()->get_speed();
+
+ XBT_INFO("Execute %g flops, should take 1 second.", computation_amount);
simgrid::s4u::ExecPtr activity = simgrid::s4u::this_actor::exec_async(computation_amount);
simgrid::s4u::this_actor::sleep_for(0.5);
XBT_INFO("I changed my mind, cancel!");
{
simgrid::s4u::Engine e(&argc, argv);
e.load_platform(argv[1]);
- simgrid::s4u::Actor::create("test", simgrid::s4u::Host::by_name("Fafard"), test, 7.6296e+07, 1.0);
- simgrid::s4u::Actor::create("test", simgrid::s4u::Host::by_name("Fafard"), test, 7.6296e+07, 2.0);
- simgrid::s4u::Actor::create("test_cancel", simgrid::s4u::Host::by_name("Boivin"), test_cancel, 98.095e+07);
+
+ simgrid::s4u::Host* fafard = simgrid::s4u::Host::by_name("Fafard");
+ simgrid::s4u::Host* ginette = simgrid::s4u::Host::by_name("Ginette");
+ simgrid::s4u::Host* boivin = simgrid::s4u::Host::by_name("Boivin");
+
+ simgrid::s4u::Actor::create("wait", fafard, waiter);
+ simgrid::s4u::Actor::create("monitor", ginette, monitor);
+ simgrid::s4u::Actor::create("cancel", boivin, canceller);
e.run();
#!/usr/bin/env tesh
-! output sort 19
$ $SG_TEST_EXENV ${bindir:=.}/s4u-exec-async$EXEEXT ${platfdir}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
-> [ 0.000000] (1:test@Fafard) Hello! Execute 7.6296e+07 flops with priority 1
-> [ 0.000000] (2:test@Fafard) Hello! Execute 7.6296e+07 flops with priority 2
-> [ 0.000000] (3:test_cancel@Boivin) Hello! Execute 9.8095e+08 flops, should take 1 second
-> [ 0.500000] (3:test_cancel@Boivin) I changed my mind, cancel!
-> [ 0.500000] (3:test_cancel@Boivin) Goodbye now!
-> [ 1.500000] (2:test@Fafard) Goodbye now!
-> [ 2.000000] (0:maestro@) Simulation time 2
-> [ 2.000000] (1:test@Fafard) Goodbye now!
+> [ 0.000000] (1:wait@Fafard) Execute 7.6296e+07 flops, should take 1 second.
+> [ 0.000000] (2:monitor@Ginette) Execute 4.8492e+07 flops, should take 1 second.
+> [ 0.000000] (3:cancel@Boivin) Execute 9.8095e+07 flops, should take 1 second.
+> [ 0.000000] (2:monitor@Ginette) Remaining amount of flops: 4.8492e+07 (100%)
+> [ 0.300000] (2:monitor@Ginette) Remaining amount of flops: 3.39444e+07 (70%)
+> [ 0.500000] (3:cancel@Boivin) I changed my mind, cancel!
+> [ 0.500000] (3:cancel@Boivin) Goodbye now!
+> [ 0.600000] (2:monitor@Ginette) Remaining amount of flops: 1.93968e+07 (40%)
+> [ 0.900000] (2:monitor@Ginette) Remaining amount of flops: 4.8492e+06 (10%)
+> [ 1.000000] (1:wait@Fafard) Goodbye now!
+> [ 1.200000] (2:monitor@Ginette) Goodbye now!
+> [ 1.200000] (0:maestro@) Simulation time 1.2
+++ /dev/null
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#include "simgrid/s4u.hpp"
-
-XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
-
-static void monitor(simgrid::s4u::ExecPtr activity)
-{
- while (not activity->test()) {
- XBT_INFO("activity remaining duration: %g (%.0f%%)", activity->get_remaining(),
- 100 * activity->get_remaining_ratio());
- simgrid::s4u::this_actor::sleep_for(5);
- }
- XBT_INFO("My task is over.");
-}
-
-static void executor()
-{
- XBT_INFO("Create one monitored task, and wait for it");
- simgrid::s4u::ExecPtr activity = simgrid::s4u::this_actor::exec_async(1e9);
- simgrid::s4u::Actor::create("monitor 1", simgrid::s4u::Host::by_name("Tremblay"), monitor, activity);
- activity->wait(); // This blocks until the activity is over
- XBT_INFO("The monitored task is over. Let's start 3 of them now.");
- simgrid::s4u::Actor::create("monitor 2", simgrid::s4u::Host::by_name("Jupiter"), monitor,
- simgrid::s4u::this_actor::exec_async(1e9));
- simgrid::s4u::Actor::create("monitor 3", simgrid::s4u::Host::by_name("Ginette"), monitor,
- simgrid::s4u::this_actor::exec_async(1e9));
- simgrid::s4u::Actor::create("monitor 4", simgrid::s4u::Host::by_name("Bourassa"), monitor,
- simgrid::s4u::this_actor::exec_async(1e9));
- XBT_INFO("All activities are started; finish now");
- // Waiting execution activities is not mandatory: they go to completion once started
-
- // No memory is leaked here: activities are automatically refcounted, thanks to C++ smart pointers
-}
-
-int main(int argc, char* argv[])
-{
- simgrid::s4u::Engine e(&argc, argv);
- e.load_platform(argv[1]);
-
- simgrid::s4u::Actor::create("executor", simgrid::s4u::Host::by_name("Fafard"), executor);
-
- e.run();
-
- return 0;
-}
+++ /dev/null
-#!/usr/bin/env tesh
-
-p Start several asynchronous tasks and monitor them
-
-$ $SG_TEST_EXENV ${bindir:=.}/s4u-exec-monitor$EXEEXT ${platfdir}/small_platform.xml
-> [Fafard:executor:(1) 0.000000] [s4u_test/INFO] Create one monitored task, and wait for it
-> [Tremblay:monitor 1:(2) 0.000000] [s4u_test/INFO] activity remaining duration: 1e+09 (100%)
-> [Tremblay:monitor 1:(2) 5.000000] [s4u_test/INFO] activity remaining duration: 6.1852e+08 (62%)
-> [Tremblay:monitor 1:(2) 10.000000] [s4u_test/INFO] activity remaining duration: 2.3704e+08 (24%)
-> [Fafard:executor:(1) 13.106847] [s4u_test/INFO] The monitored task is over. Let's start 3 of them now.
-> [Jupiter:monitor 2:(3) 13.106847] [s4u_test/INFO] activity remaining duration: 1e+09 (100%)
-> [Fafard:executor:(1) 13.106847] [s4u_test/INFO] All activities are started; finish now
-> [Ginette:monitor 3:(4) 13.106847] [s4u_test/INFO] activity remaining duration: 1e+09 (100%)
-> [Bourassa:monitor 4:(5) 13.106847] [s4u_test/INFO] activity remaining duration: 1e+09 (100%)
-> [Tremblay:monitor 1:(2) 15.000000] [s4u_test/INFO] My task is over.
-> [Bourassa:monitor 4:(5) 18.106847] [s4u_test/INFO] activity remaining duration: 8.7284e+08 (87%)
-> [Ginette:monitor 3:(4) 18.106847] [s4u_test/INFO] activity remaining duration: 8.7284e+08 (87%)
-> [Jupiter:monitor 2:(3) 18.106847] [s4u_test/INFO] activity remaining duration: 8.7284e+08 (87%)
-> [Jupiter:monitor 2:(3) 23.106847] [s4u_test/INFO] activity remaining duration: 7.4568e+08 (75%)
-> [Ginette:monitor 3:(4) 23.106847] [s4u_test/INFO] activity remaining duration: 7.4568e+08 (75%)
-> [Bourassa:monitor 4:(5) 23.106847] [s4u_test/INFO] activity remaining duration: 7.4568e+08 (75%)
-> [Bourassa:monitor 4:(5) 28.106847] [s4u_test/INFO] activity remaining duration: 6.1852e+08 (62%)
-> [Ginette:monitor 3:(4) 28.106847] [s4u_test/INFO] activity remaining duration: 6.1852e+08 (62%)
-> [Jupiter:monitor 2:(3) 28.106847] [s4u_test/INFO] activity remaining duration: 6.1852e+08 (62%)
-> [Jupiter:monitor 2:(3) 33.106847] [s4u_test/INFO] activity remaining duration: 4.9136e+08 (49%)
-> [Ginette:monitor 3:(4) 33.106847] [s4u_test/INFO] activity remaining duration: 4.9136e+08 (49%)
-> [Bourassa:monitor 4:(5) 33.106847] [s4u_test/INFO] activity remaining duration: 4.9136e+08 (49%)
-> [Bourassa:monitor 4:(5) 38.106847] [s4u_test/INFO] activity remaining duration: 3.642e+08 (36%)
-> [Ginette:monitor 3:(4) 38.106847] [s4u_test/INFO] activity remaining duration: 3.642e+08 (36%)
-> [Jupiter:monitor 2:(3) 38.106847] [s4u_test/INFO] activity remaining duration: 3.642e+08 (36%)
-> [Jupiter:monitor 2:(3) 43.106847] [s4u_test/INFO] activity remaining duration: 2.3704e+08 (24%)
-> [Ginette:monitor 3:(4) 43.106847] [s4u_test/INFO] activity remaining duration: 2.3704e+08 (24%)
-> [Bourassa:monitor 4:(5) 43.106847] [s4u_test/INFO] activity remaining duration: 2.3704e+08 (24%)
-> [Bourassa:monitor 4:(5) 48.106847] [s4u_test/INFO] activity remaining duration: 1.0988e+08 (11%)
-> [Ginette:monitor 3:(4) 48.106847] [s4u_test/INFO] activity remaining duration: 1.0988e+08 (11%)
-> [Jupiter:monitor 2:(3) 48.106847] [s4u_test/INFO] activity remaining duration: 1.0988e+08 (11%)
-> [Jupiter:monitor 2:(3) 53.106847] [s4u_test/INFO] My task is over.
-> [Ginette:monitor 3:(4) 53.106847] [s4u_test/INFO] My task is over.
-> [Bourassa:monitor 4:(5) 53.106847] [s4u_test/INFO] My task is over.