Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move Tasks from a plugin to s4u
authorFred Suter <suterf@ornl.gov>
Tue, 20 Jun 2023 13:24:41 +0000 (09:24 -0400)
committerFred Suter <suterf@ornl.gov>
Tue, 20 Jun 2023 14:16:28 +0000 (10:16 -0400)
16 files changed:
ChangeLog
MANIFEST.in
examples/cpp/task-io/s4u-task-io.cpp
examples/cpp/task-simple/s4u-task-simple.cpp
examples/cpp/task-storm/s4u-task-storm.cpp
examples/cpp/task-switch-host/s4u-task-switch-host.cpp
examples/cpp/task-variable-load/s4u-task-variable-load.cpp
examples/python/task-io/task-io.py
examples/python/task-simple/task-simple.py
examples/python/task-switch-host/task-switch-host.py
examples/python/task-variable-load/task-variable-load.py
include/simgrid/s4u.hpp
include/simgrid/s4u/Task.hpp [moved from include/simgrid/plugins/task.hpp with 93% similarity]
src/bindings/python/simgrid_python.cpp
src/s4u/s4u_Task.cpp [moved from src/plugins/task.cpp with 82% similarity]
tools/cmake/DefinePackages.cmake

index 78392f1..9ae720e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,13 +17,15 @@ S4U:
    Comm::set_payload_size() to change the size of the simulated data.
  - New function: Engine::flatify_platform(), to get a fully detailed vision of the
    configured platform.
+ - New Task abstraction: They are designed to represent dataflows, i.e, graphs of repeatable Activities.
+   See the examples under examples/cpp/task-* and the associated documentation.
  - Full simDAG integration: Activity::start() actually starts only when all dependencies
    are fullfiled. If it cannot be started right away, it will start as soon as it becomes
    possible.
  - Allow to set a concurrency limit on disks and hosts, as it was already the case for links.
  - Rename Link::get_usage() to Link::get_load() for consistency with Host::
  - Every signal now come with a static version that is invoked for every object of that class,
-   and an instance version that is invoked for this specific object only. For example, 
+   and an instance version that is invoked for this specific object only. For example,
    s4u::Actor::on_suspend_cb() adds a callback that is invoked for the suspend of any actor while
    s4u::Actor::on_this_suspend_cb() adds a callback for this specific actor only.
  - Activity::on_suspended_cb() is renamed to Activity::on_suspend_cb(), and fired right before the suspend.
@@ -34,8 +36,6 @@ S4U:
    That is, callbacks registered in Exec::on_suspend_cb will not be fired for Comms nor Ios.
 
 New S4U plugins:
- - Task: They are designed to represent dataflows, i.e, graphs of repeatable Activities.
-   See the examples under examples/cpp/task-* and the documentation in the Plugins page.
  - Battery: Enable the management of batteries on hosts.
    See the examples under examples/cpp/battery-* and the documentation in the Plugins page.
  - Photovoltaic: Enable the management of photovoltaic panels on hosts.
index 13eeb1e..76abec2 100644 (file)
@@ -399,7 +399,7 @@ include examples/cpp/task-io/s4u-task-io.tesh
 include examples/cpp/task-simple/s4u-task-simple.cpp
 include examples/cpp/task-simple/s4u-task-simple.tesh
 include examples/cpp/task-storm/s4u-task-storm.cpp
-include examples/cpp/task-storm/s4u-task-storm.thesh
+include examples/cpp/task-storm/s4u-task-storm.tesh
 include examples/cpp/task-switch-host/s4u-task-switch-host.cpp
 include examples/cpp/task-switch-host/s4u-task-switch-host.tesh
 include examples/cpp/task-variable-load/s4u-task-variable-load.cpp
@@ -1947,7 +1947,6 @@ include include/simgrid/plugins/live_migration.h
 include include/simgrid/plugins/load.h
 include include/simgrid/plugins/ns3.hpp
 include include/simgrid/plugins/photovoltaic.hpp
-include include/simgrid/plugins/task.hpp
 include include/simgrid/s4u.hpp
 include include/simgrid/s4u/Activity.hpp
 include include/simgrid/s4u/Actor.hpp
@@ -1964,6 +1963,7 @@ include include/simgrid/s4u/Mailbox.hpp
 include include/simgrid/s4u/Mutex.hpp
 include include/simgrid/s4u/NetZone.hpp
 include include/simgrid/s4u/Semaphore.hpp
+include include/simgrid/s4u/Task.hpp
 include include/simgrid/s4u/VirtualMachine.hpp
 include include/simgrid/semaphore.h
 include include/simgrid/simix.h
@@ -2230,9 +2230,9 @@ include src/mc/explo/udpor/Configuration_test.cpp
 include src/mc/explo/udpor/EventSet.cpp
 include src/mc/explo/udpor/EventSet.hpp
 include src/mc/explo/udpor/EventSet_test.cpp
-include src/mc/explo/udpor/ExtensionSet_test.cpp
 include src/mc/explo/udpor/ExtensionSetCalculator.cpp
 include src/mc/explo/udpor/ExtensionSetCalculator.hpp
+include src/mc/explo/udpor/ExtensionSet_test.cpp
 include src/mc/explo/udpor/History.cpp
 include src/mc/explo/udpor/History.hpp
 include src/mc/explo/udpor/History_test.cpp
@@ -2324,7 +2324,6 @@ include src/plugins/link_energy.cpp
 include src/plugins/link_energy_wifi.cpp
 include src/plugins/link_load.cpp
 include src/plugins/photovoltaic.cpp
-include src/plugins/task.cpp
 include src/plugins/vm/VmLiveMigration.cpp
 include src/plugins/vm/VmLiveMigration.hpp
 include src/plugins/vm/dirty_page_tracking.cpp
@@ -2343,6 +2342,7 @@ include src/s4u/s4u_Mailbox.cpp
 include src/s4u/s4u_Mutex.cpp
 include src/s4u/s4u_Netzone.cpp
 include src/s4u/s4u_Semaphore.cpp
+include src/s4u/s4u_Task.cpp
 include src/s4u/s4u_VirtualMachine.cpp
 include src/simgrid/Exception.cpp
 include src/simgrid/math_utils.h
index 6301657..19102f2 100644 (file)
@@ -3,7 +3,7 @@
 /* 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. */
 
-/* This example demonstrate basic use of the task plugin.
+/* This example demonstrate basic use of tasks.
  *
  * We model the following graph:
  *
  * comm is a communication task.
  */
 
-#include "simgrid/plugins/task.hpp"
+#include "simgrid/s4u/Task.hpp"
 #include "simgrid/s4u.hpp"
 #include <simgrid/plugins/file_system.h>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(task_simple, "Messages specific for this task example");
+namespace sg4 = simgrid::s4u;
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   e.load_platform(argv[1]);
-  simgrid::plugins::Task::init();
 
   // Retrieve hosts
   auto* bob  = e.host_by_name("bob");
   auto* carl = e.host_by_name("carl");
 
   // Create tasks
-  auto exec1 = simgrid::plugins::ExecTask::init("exec1", 1e9, bob);
-  auto exec2 = simgrid::plugins::ExecTask::init("exec2", 1e9, carl);
-  auto write = simgrid::plugins::IoTask::init("write", 1e7, bob->get_disks().front(), simgrid::s4u::Io::OpType::WRITE);
-  auto read  = simgrid::plugins::IoTask::init("read", 1e7, carl->get_disks().front(), simgrid::s4u::Io::OpType::READ);
+  auto exec1 = sg4::ExecTask::init("exec1", 1e9, bob);
+  auto exec2 = sg4::ExecTask::init("exec2", 1e9, carl);
+  auto write = sg4::IoTask::init("write", 1e7, bob->get_disks().front(), sg4::Io::OpType::WRITE);
+  auto read  = sg4::IoTask::init("read", 1e7, carl->get_disks().front(), sg4::Io::OpType::READ);
 
   // Create the graph by defining dependencies between tasks
   exec1->add_successor(write);
@@ -41,7 +41,7 @@ int main(int argc, char* argv[])
   read->add_successor(exec2);
 
   // Add a function to be called when tasks end for log purpose
-  simgrid::plugins::Task::on_end_cb([](const simgrid::plugins::Task* t) {
+  sg4::Task::on_end_cb([](const sg4::Task* t) {
     XBT_INFO("Task %s finished (%d)", t->get_name().c_str(), t->get_count());
   });
 
index 3e9d14f..dc3df1d 100644 (file)
@@ -3,7 +3,7 @@
 /* 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. */
 
-/* This example demonstrate basic use of the task plugin.
+/* This example demonstrate basic use of tasks.
  *
  * We model the following graph:
  *
  * comm is a communication task.
  */
 
-#include "simgrid/plugins/task.hpp"
 #include "simgrid/s4u.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(task_simple, "Messages specific for this task example");
 
+namespace sg4 = simgrid::s4u;
+
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   e.load_platform(argv[1]);
-  simgrid::plugins::Task::init();
 
   // Retrieve hosts
   auto* tremblay = e.host_by_name("Tremblay");
   auto* jupiter  = e.host_by_name("Jupiter");
 
   // Create tasks
-  auto exec1 = simgrid::plugins::ExecTask::init("exec1", 1e9, tremblay);
-  auto exec2 = simgrid::plugins::ExecTask::init("exec2", 1e9, jupiter);
-  auto comm  = simgrid::plugins::CommTask::init("comm", 1e7, tremblay, jupiter);
+  auto exec1 = sg4::ExecTask::init("exec1", 1e9, tremblay);
+  auto exec2 = sg4::ExecTask::init("exec2", 1e9, jupiter);
+  auto comm  = sg4::CommTask::init("comm", 1e7, tremblay, jupiter);
 
   // Create the graph by defining dependencies between tasks
   exec1->add_successor(comm);
   comm->add_successor(exec2);
 
   // Add a function to be called when tasks end for log purpose
-  simgrid::plugins::Task::on_end_cb([](const simgrid::plugins::Task* t) {
+  sg4::Task::on_end_cb([](const sg4::Task* t) {
     XBT_INFO("Task %s finished (%d)", t->get_name().c_str(), t->get_count());
   });
 
index 7c02415..bfd52b7 100644 (file)
@@ -7,12 +7,12 @@
    and use them to build a simulation of a stream processing application
 
    Spout SA produces data every 100ms. The volume produced is alternatively 1e3, 1e6 and 1e9 bytes.
-   Spout SB produces 1e6 bytes every 200ms.  
-   
+   Spout SB produces 1e6 bytes every 200ms.
+
    Bolt B1 and B2 processes data from Spout SA alternatively. The quantity of work to process this data is 10 flops per bytes
    Bolt B3 processes data from Spout SB.
    Bolt B4 processes data from Bolt B3.
-   
+
                         Fafard
                         ┌────┐
                     ┌──►│ B1 │
           ┌────┐     │          │
           │ SB ├─────┤ B3 ──► B4│
           └────┘     │          │
-                     └──────────┘     
+                     └──────────┘
  */
 
-#include "simgrid/plugins/task.hpp"
 #include "simgrid/s4u.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(task_storm, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   e.load_platform(argv[1]);
-  simgrid::plugins::Task::init();
 
   // Retrieve hosts
   auto tremblay = e.host_by_name("Tremblay");
@@ -51,17 +50,17 @@ int main(int argc, char* argv[])
   auto bourassa = e.host_by_name("Bourassa");
 
   // Create execution tasks
-  auto SA = simgrid::plugins::ExecTask::init("SA", tremblay->get_speed() * 0.1, tremblay);
-  auto SB = simgrid::plugins::ExecTask::init("SB", jupiter->get_speed() * 0.2, jupiter);
-  auto B1 = simgrid::plugins::ExecTask::init("B1", 1e8, fafard);
-  auto B2 = simgrid::plugins::ExecTask::init("B2", 1e8, ginette);
-  auto B3 = simgrid::plugins::ExecTask::init("B3", 1e8, bourassa);
-  auto B4 = simgrid::plugins::ExecTask::init("B4", 2e8, bourassa);
+  auto SA = sg4::ExecTask::init("SA", tremblay->get_speed() * 0.1, tremblay);
+  auto SB = sg4::ExecTask::init("SB", jupiter->get_speed() * 0.2, jupiter);
+  auto B1 = sg4::ExecTask::init("B1", 1e8, fafard);
+  auto B2 = sg4::ExecTask::init("B2", 1e8, ginette);
+  auto B3 = sg4::ExecTask::init("B3", 1e8, bourassa);
+  auto B4 = sg4::ExecTask::init("B4", 2e8, bourassa);
 
   // Create communication tasks
-  auto SA_to_B1 = simgrid::plugins::CommTask::init("SA_to_B1", 0, tremblay, fafard); 
-  auto SA_to_B2 = simgrid::plugins::CommTask::init("SA_to_B2", 0, tremblay, ginette);
-  auto SB_to_B3 = simgrid::plugins::CommTask::init("SB_to_B3", 1e6, jupiter, bourassa);
+  auto SA_to_B1 = sg4::CommTask::init("SA_to_B1", 0, tremblay, fafard);
+  auto SA_to_B2 = sg4::CommTask::init("SA_to_B2", 0, tremblay, ginette);
+  auto SB_to_B3 = sg4::CommTask::init("SB_to_B3", 1e6, jupiter, bourassa);
 
   // Create the graph by defining dependencies between tasks
   // Some dependencies are defined dynamically
@@ -75,9 +74,9 @@ int main(int argc, char* argv[])
      Alternatively we: remove/add the link between SA and SA_to_B2
                        add/remove the link between SA and SA_to_B1
   */
-  SA->on_this_start_cb([&](simgrid::plugins::Task* t) {
+  SA->on_this_start_cb([&](sg4::Task* t) {
     int count = t->get_count();
-    simgrid::plugins::CommTaskPtr comm;
+    sg4::CommTaskPtr comm;
     if (count % 2 == 0) {
       t->remove_successor(SA_to_B2);
       t->add_successor(SA_to_B1);
@@ -90,27 +89,27 @@ int main(int argc, char* argv[])
     }
     std::vector<double> amount = {1e3,1e6,1e9};
     comm->set_amount(amount[count % 3]);
-    auto token = std::make_shared<simgrid::plugins::Token>();
+    auto token = std::make_shared<sg4::Token>();
     token->set_data(new double(amount[count % 3]));
     t->set_token(token);
   });
 
   // The token sent by SA is forwarded by both communication tasks
-  SA_to_B1->on_this_start_cb([&](simgrid::plugins::Task* t) {
+  SA_to_B1->on_this_start_cb([&](sg4::Task* t) {
     t->set_token(t->get_next_token_from(SA));
   });
-  SA_to_B2->on_this_start_cb([&](simgrid::plugins::Task* t) {
+  SA_to_B2->on_this_start_cb([&](sg4::Task* t) {
     t->set_token(t->get_next_token_from(SA));
   });
 
   /* B1 and B2 read the value of the token received by their predecessors
      and use it to adapt their amount of work to do.
-  */ 
-  B1->on_this_start_cb([&](simgrid::plugins::Task* t) {
+  */
+  B1->on_this_start_cb([&](sg4::Task* t) {
     auto data = t->get_next_token_from(SA_to_B1)->get_unique_data<double>();
     t->set_amount(*data * 10);
   });
-  B2->on_this_start_cb([&](simgrid::plugins::Task* t) {
+  B2->on_this_start_cb([&](sg4::Task* t) {
     auto data = t->get_next_token_from(SA_to_B2)->get_unique_data<double>();
     t->set_amount(*data * 10);
   });
@@ -120,8 +119,8 @@ int main(int argc, char* argv[])
   SB->enqueue_execs(5);
 
   // Add a function to be called when tasks end for log purpose
-  simgrid::plugins::Task::on_end_cb([]
-  (const simgrid::plugins::Task* t) {
+  sg4::Task::on_end_cb([]
+  (const sg4::Task* t) {
     XBT_INFO("Task %s finished (%d)", t->get_name().c_str(), t->get_count());
   });
 
index 6ebca12..ae19ebc 100644 (file)
  * With exec1 and exec2 on different hosts.
  */
 
-#include "simgrid/plugins/task.hpp"
 #include "simgrid/s4u.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(task_switch_host, "Messages specific for this task example");
+namespace sg4 = simgrid::s4u;
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   e.load_platform(argv[1]);
-  simgrid::plugins::Task::init();
 
   // Retrieve hosts
   auto* tremblay = e.host_by_name("Tremblay");
@@ -33,13 +32,13 @@ int main(int argc, char* argv[])
   auto* fafard   = e.host_by_name("Fafard");
 
   // Create tasks
-  auto comm0 = simgrid::plugins::CommTask::init("comm0");
+  auto comm0 = sg4::CommTask::init("comm0");
   comm0->set_bytes(1e7);
   comm0->set_source(tremblay);
-  auto exec1 = simgrid::plugins::ExecTask::init("exec1", 1e9, jupiter);
-  auto exec2 = simgrid::plugins::ExecTask::init("exec2", 1e9, fafard);
-  auto comm1 = simgrid::plugins::CommTask::init("comm1", 1e7, jupiter, tremblay);
-  auto comm2 = simgrid::plugins::CommTask::init("comm2", 1e7, fafard, tremblay);
+  auto exec1 = sg4::ExecTask::init("exec1", 1e9, jupiter);
+  auto exec2 = sg4::ExecTask::init("exec2", 1e9, fafard);
+  auto comm1 = sg4::CommTask::init("comm1", 1e7, jupiter, tremblay);
+  auto comm2 = sg4::CommTask::init("comm2", 1e7, fafard, tremblay);
 
   // Create the initial graph by defining dependencies between tasks
   comm0->add_successor(exec2);
@@ -47,15 +46,15 @@ int main(int argc, char* argv[])
   exec2->add_successor(comm2);
 
   // Add a function to be called when tasks end for log purpose
-  simgrid::plugins::Task::on_end_cb([](const simgrid::plugins::Task* t) {
+  sg4::Task::on_end_cb([](const sg4::Task* t) {
     XBT_INFO("Task %s finished (%d)", t->get_name().c_str(), t->get_count());
   });
 
   // Add a function to be called before each executions of comm0
   // This function modifies the graph of tasks by adding or removing
   // successors to comm0
-  comm0->on_this_start_cb([exec1, exec2, jupiter, fafard](simgrid::plugins::Task* t) {
-    auto* comm0      = dynamic_cast<simgrid::plugins::CommTask*>(t);
+  comm0->on_this_start_cb([exec1, exec2, jupiter, fafard](sg4::Task* t) {
+    auto* comm0      = dynamic_cast<sg4::CommTask*>(t);
     static int count = 0;
     if (count % 2 == 0) {
       comm0->set_destination(jupiter);
index 960fb66..b0d3efd 100644 (file)
  * With a heavy load there is a burst of comm before the exec task can even finish once.
  */
 
-#include "simgrid/plugins/task.hpp"
 #include "simgrid/s4u.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(task_variable_load, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
-static void variable_load(simgrid::plugins::TaskPtr t)
+static void variable_load(sg4::TaskPtr t)
 {
   XBT_INFO("--- Small load ---");
   for (int i = 0; i < 3; i++) {
     t->enqueue_execs(1);
-    simgrid::s4u::this_actor::sleep_for(100);
+    sg4::this_actor::sleep_for(100);
   }
-  simgrid::s4u::this_actor::sleep_until(1000);
+  sg4::this_actor::sleep_until(1000);
   XBT_INFO("--- Heavy load ---");
   for (int i = 0; i < 3; i++) {
     t->enqueue_execs(1);
-    simgrid::s4u::this_actor::sleep_for(1);
+    sg4::this_actor::sleep_for(1);
   }
 }
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   e.load_platform(argv[1]);
-  simgrid::plugins::Task::init();
 
   // Retreive hosts
   auto* tremblay = e.host_by_name("Tremblay");
   auto* jupiter  = e.host_by_name("Jupiter");
 
   // Create tasks
-  auto comm = simgrid::plugins::CommTask::init("comm", 1e7, tremblay, jupiter);
-  auto exec = simgrid::plugins::ExecTask::init("exec", 1e9, jupiter);
+  auto comm = sg4::CommTask::init("comm", 1e7, tremblay, jupiter);
+  auto exec = sg4::ExecTask::init("exec", 1e9, jupiter);
 
   // Create the graph by defining dependencies between tasks
   comm->add_successor(exec);
 
   // Add a function to be called when tasks end for log purpose
-  simgrid::plugins::Task::on_end_cb([](const simgrid::plugins::Task* t) {
+  sg4::Task::on_end_cb([](const sg4::Task* t) {
     XBT_INFO("Task %s finished (%d)", t->get_name().c_str(), t->get_count());
   });
 
   // Create the actor that will inject load during the simulation
-  simgrid::s4u::Actor::create("input", tremblay, variable_load, comm);
+  sg4::Actor::create("input", tremblay, variable_load, comm);
 
   // Start the simulation
   e.run();
index b74c411..431a789 100644 (file)
@@ -24,7 +24,6 @@ if __name__ == '__main__':
     args = parse()
     e = Engine(sys.argv)
     e.load_platform(args.platform)
-    Task.init()
 
     # Retrieve hosts
     bob = e.host_by_name('bob')
index 1219906..4ac876e 100644 (file)
@@ -34,7 +34,6 @@ if __name__ == '__main__':
     args = parse()
     e = Engine(sys.argv)
     e.load_platform(args.platform)
-    Task.init()
 
     # Retrieve hosts
     tremblay = e.host_by_name('Tremblay')
@@ -57,4 +56,3 @@ if __name__ == '__main__':
 
     # runs the simulation
     e.run()
-
index a95db16..f56bc40 100644 (file)
@@ -55,7 +55,6 @@ if __name__ == '__main__':
     args = parse()
     e = Engine(sys.argv)
     e.load_platform(args.platform)
-    Task.init()
 
     # Retrieve hosts
     tremblay = e.host_by_name('Tremblay')
index 7310584..63925d9 100644 (file)
@@ -45,7 +45,6 @@ if __name__ == '__main__':
     args = parse()
     e = Engine(sys.argv)
     e.load_platform(args.platform)
-    Task.init()
 
     # Retrieve hosts
     tremblay = e.host_by_name('Tremblay')
index f694696..77a71df 100644 (file)
@@ -22,6 +22,7 @@
 #include <simgrid/s4u/Mutex.hpp>
 #include <simgrid/s4u/NetZone.hpp>
 #include <simgrid/s4u/Semaphore.hpp>
+#include <simgrid/s4u/Task.hpp>
 #include <simgrid/s4u/VirtualMachine.hpp>
 
 #include <simgrid/Exception.hpp>
similarity index 93%
rename from include/simgrid/plugins/task.hpp
rename to include/simgrid/s4u/Task.hpp
index 87a357b..ef78734 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef SIMGRID_PLUGINS_TASK_H_
-#define SIMGRID_PLUGINS_TASK_H_
+#ifndef SIMGRID_S4U_TASK_H_
+#define SIMGRID_S4U_TASK_H_
 
 #include <simgrid/s4u/Activity.hpp>
 #include <simgrid/s4u/Io.hpp>
@@ -11,7 +11,7 @@
 #include <memory>
 #include <set>
 
-namespace simgrid::plugins {
+namespace simgrid::s4u {
 
 class Task;
 using TaskPtr = boost::intrusive_ptr<Task>;
@@ -24,11 +24,6 @@ using CommTaskPtr = boost::intrusive_ptr<CommTask>;
 class IoTask;
 using IoTaskPtr = boost::intrusive_ptr<IoTask>;
 
-struct ExtendedAttributeActivity {
-  static simgrid::xbt::Extension<simgrid::s4u::Activity, ExtendedAttributeActivity> EXTENSION_ID;
-  Task* task_;
-};
-
 class XBT_PUBLIC Token : public xbt::Extendable<Token> {};
 
 class Task {
@@ -37,7 +32,6 @@ class Task {
 
   bool ready_to_run() const;
   void receive(Task* source);
-  void complete();
 
 protected:
   std::string name_;
@@ -54,13 +48,13 @@ protected:
   explicit Task(const std::string& name);
   virtual ~Task()     = default;
   virtual void fire() = 0;
+  void complete();
 
   static xbt::signal<void(Task*)> on_start;
   static xbt::signal<void(Task*)> on_end;
   std::atomic_int_fast32_t refcount_{0};
 
 public:
-  static void init();
   const std::string& get_name() const { return name_; }
   const char* get_cname() const { return name_.c_str(); }
   void enqueue_execs(int n);
@@ -145,5 +139,5 @@ public:
   IoTaskPtr set_op_type(s4u::Io::OpType type);
   s4u::Io::OpType get_op_type() const { return type_; }
 };
-} // namespace simgrid::plugins
+} // namespace simgrid::s4u
 #endif
index 5f0f335..52f5ca6 100644 (file)
@@ -11,7 +11,6 @@
 #include "simgrid/kernel/ProfileBuilder.hpp"
 #include "simgrid/kernel/routing/NetPoint.hpp"
 #include <simgrid/Exception.hpp>
-#include <simgrid/plugins/task.hpp>
 #include <simgrid/s4u/Actor.hpp>
 #include <simgrid/s4u/Barrier.hpp>
 #include <simgrid/s4u/Comm.hpp>
@@ -25,6 +24,7 @@
 #include <simgrid/s4u/Mutex.hpp>
 #include <simgrid/s4u/NetZone.hpp>
 #include <simgrid/s4u/Semaphore.hpp>
+#include <simgrid/s4u/Task.hpp>
 #include <simgrid/version.h>
 
 #include <algorithm>
 #include <vector>
 
 namespace py = pybind11;
-using simgrid::plugins::CommTask;
-using simgrid::plugins::CommTaskPtr;
-using simgrid::plugins::ExecTask;
-using simgrid::plugins::ExecTaskPtr;
-using simgrid::plugins::IoTask;
-using simgrid::plugins::IoTaskPtr;
-using simgrid::plugins::Task;
-using simgrid::plugins::TaskPtr;
+using simgrid::s4u::CommTask;
+using simgrid::s4u::CommTaskPtr;
+using simgrid::s4u::ExecTask;
+using simgrid::s4u::ExecTaskPtr;
+using simgrid::s4u::IoTask;
+using simgrid::s4u::IoTaskPtr;
+using simgrid::s4u::Task;
+using simgrid::s4u::TaskPtr;
 using simgrid::s4u::Actor;
 using simgrid::s4u::ActorPtr;
 using simgrid::s4u::Barrier;
@@ -921,7 +921,6 @@ PYBIND11_MODULE(simgrid, m)
 
   /* Class Task */
   py::class_<Task, TaskPtr>(m, "Task", "Task. See the C++ documentation for details.")
-      .def_static("init", &Task::init)
       .def_static(
           "on_start_cb",
           [](py::object cb) {
similarity index 82%
rename from src/plugins/task.cpp
rename to src/s4u/s4u_Task.cpp
index 835b307..c0a6e38 100644 (file)
@@ -1,6 +1,6 @@
 #include <memory>
 #include <simgrid/Exception.hpp>
-#include <simgrid/plugins/task.hpp>
+#include <simgrid/s4u/Task.hpp>
 #include <simgrid/s4u/Comm.hpp>
 #include <simgrid/s4u/Exec.hpp>
 #include <simgrid/s4u/Io.hpp>
@@ -9,16 +9,13 @@
 #include "src/simgrid/module.hpp"
 
 SIMGRID_REGISTER_PLUGIN(task, "Battery management", nullptr)
-/** @defgroup plugin_task plugin_task Plugin Task
-
+/**
   @beginrst
 
-This is the task plugin, enabling management of Tasks.
-To activate this plugin, first call :cpp:func:`Task::init`.
 
 Tasks are designed to represent dataflows, i.e, graphs of Tasks.
 Tasks can only be instancied using either
-:cpp:func:`simgrid::plugins::ExecTask::init` or :cpp:func:`simgrid::plugins::CommTask::init`
+:cpp:func:`simgrid::s4u::ExecTask::init` or :cpp:func:`simgrid::s4u::CommTask::init`
 An ExecTask is an Execution Task. Its underlying Activity is an :ref:`Exec <API_s4u_Exec>`.
 A CommTask is a Communication Task. Its underlying Activity is a :ref:`Comm <API_s4u_Comm>`.
 
@@ -26,9 +23,7 @@ A CommTask is a Communication Task. Its underlying Activity is a :ref:`Comm <API
  */
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(Task, kernel, "Logging specific to the task plugin");
 
-namespace simgrid::plugins {
-
-xbt::Extension<s4u::Activity, ExtendedAttributeActivity> ExtendedAttributeActivity::EXTENSION_ID;
+namespace simgrid::s4u {
 
 xbt::signal<void(Task*)> Task::on_start;
 xbt::signal<void(Task*)> Task::on_end;
@@ -94,28 +89,7 @@ void Task::complete()
     fire();
 }
 
-/** @ingroup plugin_task
- *  @brief Init the Task plugin.
- *  @note Add a completion callback to all Activities to call Task::complete().
- */
-void Task::init()
-{
-  static bool inited = false;
-  if (inited)
-    return;
-
-  inited                                  = true;
-  ExtendedAttributeActivity::EXTENSION_ID = simgrid::s4u::Activity::extension_create<ExtendedAttributeActivity>();
-  simgrid::s4u::Exec::on_completion_cb(
-      [](simgrid::s4u::Exec const& exec) { exec.extension<ExtendedAttributeActivity>()->task_->complete(); });
-  simgrid::s4u::Comm::on_completion_cb(
-      [](simgrid::s4u::Comm const& comm) { comm.extension<ExtendedAttributeActivity>()->task_->complete(); });
-  simgrid::s4u::Io::on_completion_cb(
-      [](simgrid::s4u::Io const& io) { io.extension<ExtendedAttributeActivity>()->task_->complete(); });
-}
-
-/** @ingroup plugin_task
- *  @param n The number of executions to enqueue.
+/** @param n The number of executions to enqueue.
  *  @brief Enqueue executions.
  *  @note Immediatly starts an execution if possible.
  */
@@ -128,8 +102,7 @@ void Task::enqueue_execs(int n)
   });
 }
 
-/** @ingroup plugin_task
- *  @param amount The amount to set.
+/** @param amount The amount to set.
  *  @brief Set the amout of work to do.
  *  @note Amount in flop for ExecTask and in bytes for CommTask.
  */
@@ -138,8 +111,7 @@ void Task::set_amount(double amount)
   simgrid::kernel::actor::simcall_answered([this, amount] { amount_ = amount; });
 }
 
-/** @ingroup plugin_task
- *  @param token The token to set.
+/** @param token The token to set.
  *  @brief Set the token to send to successors.
  *  @note The token is passed to each successor after the task end, i.e., after the on_end callback.
  */
@@ -148,8 +120,7 @@ void Task::set_token(std::shared_ptr<Token> token)
   simgrid::kernel::actor::simcall_answered([this, token] { token_ = token; });
 }
 
-/** @ingroup plugin_task
- *  @return Map of tokens received for the next execution.
+/** @return Map of tokens received for the next execution.
  *  @note If there is no queued execution for this task the map might not exist or be partially empty.
  */
 std::shared_ptr<Token> Task::get_next_token_from(TaskPtr t)
@@ -157,8 +128,7 @@ std::shared_ptr<Token> Task::get_next_token_from(TaskPtr t)
   return tokens_received_.front()[t];
 }
 
-/** @ingroup plugin_task
- *  @param successor The Task to add.
+/** @param successor The Task to add.
  *  @brief Add a successor to this Task.
  *  @note It also adds this as a predecessor of successor.
  */
@@ -170,8 +140,7 @@ void Task::add_successor(TaskPtr successor)
   });
 }
 
-/** @ingroup plugin_task
- *  @param successor The Task to remove.
+/** @param successor The Task to remove.
  *  @brief Remove a successor from this Task.
  *  @note It also remove this from the predecessors of successor.
  */
@@ -261,8 +230,7 @@ void ExecTask::fire()
   exec->set_flops_amount(amount_);
   exec->set_host(host_);
   exec->start();
-  exec->extension_set(new ExtendedAttributeActivity());
-  exec->extension<ExtendedAttributeActivity>()->task_ = this;
+  exec->on_this_completion_cb([this](Exec const& exec) { this->complete(); });
   current_activity_                                   = exec;
 }
 
@@ -323,8 +291,7 @@ void CommTask::fire()
   comm->set_name(name_);
   comm->set_payload_size(amount_);
   comm->start();
-  comm->extension_set(new ExtendedAttributeActivity());
-  comm->extension<ExtendedAttributeActivity>()->task_ = this;
+  comm->on_this_completion_cb([this](Comm const& comm) { this->complete(); });
   current_activity_                                   = comm;
 }
 
@@ -418,9 +385,8 @@ void IoTask::fire()
   io->set_disk(disk_);
   io->set_op_type(type_);
   io->start();
-  io->extension_set(new ExtendedAttributeActivity());
-  io->extension<ExtendedAttributeActivity>()->task_ = this;
-  current_activity_                                 = io;
+  io->on_this_completion_cb([this](Io const& io) { this->complete(); });
+  current_activity_ = io;
 }
 
-} // namespace simgrid::plugins
+} // namespace simgrid::s4u
index 5fa39d6..9b9aaa8 100644 (file)
@@ -25,7 +25,7 @@ set(EXTRA_DIST
   src/kernel/resource/models/network_ns3.hpp
   src/kernel/resource/models/ns3/ns3_simulator.hpp
   src/kernel/resource/models/ptask_L07.hpp
-  
+
   src/mc/datatypes.h
   src/mc/mc.h
   src/mc/mc_mmu.hpp
@@ -56,7 +56,7 @@ set(EXTRA_DIST
   src/xbt/log_private.hpp
   src/xbt/mallocator_private.h
   src/xbt/parmap.hpp
-  
+
   src/xbt/mmalloc/mmalloc.h
   src/xbt/mmalloc/mfree.c
   src/xbt/mmalloc/mm_legacy.c
@@ -342,7 +342,7 @@ set(KERNEL_SRC
   src/kernel/actor/SimcallObserver.hpp
   src/kernel/actor/SynchroObserver.cpp
   src/kernel/actor/SynchroObserver.hpp
-  
+
   src/kernel/context/Context.cpp
   src/kernel/context/Context.hpp
   src/kernel/context/ContextRaw.cpp
@@ -454,7 +454,6 @@ set(PLUGINS_SRC
   src/plugins/vm/VmLiveMigration.hpp
   src/plugins/vm/dirty_page_tracking.cpp
   src/plugins/battery.cpp
-  src/plugins/task.cpp
   src/plugins/photovoltaic.cpp
   )
 
@@ -475,6 +474,7 @@ set(S4U_SRC
   src/s4u/s4u_Mutex.cpp
   src/s4u/s4u_Netzone.cpp
   src/s4u/s4u_Semaphore.cpp
+  src/s4u/s4u_Task.cpp
   src/s4u/s4u_VirtualMachine.cpp
 )
 
@@ -521,7 +521,7 @@ set(MC_SRC_BASE
   src/mc/mc_replay.hpp
   src/mc/transition/Transition.cpp
   )
-  
+
 set(MC_SRC_STATELESS
   src/mc/api/ActorState.hpp
   src/mc/api/ClockVector.cpp
@@ -530,7 +530,7 @@ set(MC_SRC_STATELESS
   src/mc/api/State.hpp
   src/mc/api/RemoteApp.cpp
   src/mc/api/RemoteApp.hpp
-  
+
   src/mc/explo/DFSExplorer.cpp
   src/mc/explo/DFSExplorer.hpp
   src/mc/explo/Exploration.cpp
@@ -577,7 +577,7 @@ set(MC_SRC_STATEFUL
   src/mc/explo/LivenessChecker.hpp
   src/mc/explo/UdporChecker.cpp
   src/mc/explo/UdporChecker.hpp
-  
+
   src/mc/explo/udpor/Comb.hpp
   src/mc/explo/udpor/Configuration.hpp
   src/mc/explo/udpor/Configuration.cpp
@@ -595,7 +595,7 @@ set(MC_SRC_STATEFUL
   src/mc/explo/udpor/Unfolding.hpp
   src/mc/explo/udpor/udpor_forward.hpp
   src/mc/explo/udpor/udpor_tests_private.hpp
-  
+
   src/mc/inspect/DwarfExpression.cpp
   src/mc/inspect/DwarfExpression.hpp
   src/mc/inspect/Frame.cpp
@@ -614,7 +614,7 @@ set(MC_SRC_STATEFUL
   src/mc/inspect/mc_unw.cpp
   src/mc/inspect/mc_unw.hpp
   src/mc/inspect/mc_unw_vmread.cpp
-  
+
   src/mc/sosp/ChunkedData.cpp
   src/mc/sosp/ChunkedData.hpp
   src/mc/sosp/PageStore.cpp
@@ -641,7 +641,7 @@ set(MC_SRC_STATEFUL
   src/mc/api/strategy/MinMatchComm.hpp
   src/mc/api/strategy/Strategy.hpp
   src/mc/api/strategy/UniformStrategy.hpp
-  
+
   src/xbt/mmalloc/mm_interface.c
   )
 
@@ -661,7 +661,6 @@ set(headers_to_install
   include/simgrid/plugins/file_system.h
   include/simgrid/plugins/live_migration.h
   include/simgrid/plugins/load.h
-  include/simgrid/plugins/task.hpp
   include/simgrid/plugins/photovoltaic.hpp
   include/simgrid/plugins/ProducerConsumer.hpp
   include/simgrid/instr.h
@@ -695,6 +694,7 @@ set(headers_to_install
   include/simgrid/s4u/Mutex.hpp
   include/simgrid/s4u/NetZone.hpp
   include/simgrid/s4u/Semaphore.hpp
+  include/simgrid/s4u/Task.hpp
   include/simgrid/s4u/VirtualMachine.hpp
   include/simgrid/s4u.hpp