From: Adrien Gougeon Date: Fri, 2 Jun 2023 07:50:56 +0000 (+0200) Subject: rename operation to task. rename execute to fire. X-Git-Tag: v3.34~67^2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/1b211507e0c2abe5f2b7fbe56988af46d3189b51 rename operation to task. rename execute to fire. --- diff --git a/ChangeLog b/ChangeLog index ba67d904ef..8e1ae4ded1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -34,8 +34,8 @@ S4U: That is, callbacks registered in Exec::on_suspend_cb will not be fired for Comms nor Ios. New S4U plugins: - - Operation: They are designed to represent workflows, i.e, graphs of repeatable Activities. - See the examples under examples/cpp/operation-* and the documentation in the Plugins page. + - 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. diff --git a/MANIFEST.in b/MANIFEST.in index f4fe53ad60..470fb419a3 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -350,14 +350,14 @@ include examples/cpp/network-ns3/s4u-network-ns3-timed.tesh include examples/cpp/network-ns3/s4u-network-ns3.cpp include examples/cpp/network-wifi/s4u-network-wifi.cpp include examples/cpp/network-wifi/s4u-network-wifi.tesh -include examples/cpp/operation-io/s4u-operation-io.cpp -include examples/cpp/operation-io/s4u-operation-io.tesh -include examples/cpp/operation-simple/s4u-operation-simple.cpp -include examples/cpp/operation-simple/s4u-operation-simple.tesh -include examples/cpp/operation-switch-host/s4u-operation-switch-host.cpp -include examples/cpp/operation-switch-host/s4u-operation-switch-host.tesh -include examples/cpp/operation-variable-load/s4u-operation-variable-load.cpp -include examples/cpp/operation-variable-load/s4u-operation-variable-load.tesh +include examples/cpp/task-io/s4u-task-io.cpp +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-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 +include examples/cpp/task-variable-load/s4u-task-variable-load.tesh include examples/cpp/photovoltaic-simple/s4u-photovoltaic-simple.cpp include examples/cpp/photovoltaic-simple/s4u-photovoltaic-simple.tesh include examples/cpp/platform-comm-serialize/s4u-platform-comm-serialize.cpp @@ -476,14 +476,14 @@ include examples/python/io-degradation/io-degradation.py include examples/python/io-degradation/io-degradation.tesh include examples/python/network-nonlinear/network-nonlinear.py include examples/python/network-nonlinear/network-nonlinear.tesh -include examples/python/operation-io/operation-io.py -include examples/python/operation-io/operation-io.tesh -include examples/python/operation-simple/operation-simple.py -include examples/python/operation-simple/operation-simple.tesh -include examples/python/operation-switch-host/operation-switch-host.py -include examples/python/operation-switch-host/operation-switch-host.tesh -include examples/python/operation-variable-load/operation-variable-load.py -include examples/python/operation-variable-load/operation-variable-load.tesh +include examples/python/task-io/task-io.py +include examples/python/task-io/task-io.tesh +include examples/python/task-simple/task-simple.py +include examples/python/task-simple/task-simple.tesh +include examples/python/task-switch-host/task-switch-host.py +include examples/python/task-switch-host/task-switch-host.tesh +include examples/python/task-variable-load/task-variable-load.py +include examples/python/task-variable-load/task-variable-load.tesh include examples/python/platform-comm-serialize/platform-comm-serialize.py include examples/python/platform-comm-serialize/platform-comm-serialize.tesh include examples/python/platform-failures/platform-failures.py @@ -1944,7 +1944,7 @@ include include/simgrid/plugins/file_system.h include include/simgrid/plugins/live_migration.h include include/simgrid/plugins/load.h include include/simgrid/plugins/ns3.hpp -include include/simgrid/plugins/operation.hpp +include include/simgrid/plugins/task.hpp include include/simgrid/plugins/photovoltaic.hpp include include/simgrid/s4u.hpp include include/simgrid/s4u/Activity.hpp @@ -2303,7 +2303,7 @@ include src/plugins/host_load.cpp include src/plugins/link_energy.cpp include src/plugins/link_energy_wifi.cpp include src/plugins/link_load.cpp -include src/plugins/operation.cpp +include src/plugins/task.cpp include src/plugins/photovoltaic.cpp include src/plugins/vm/VmLiveMigration.cpp include src/plugins/vm/VmLiveMigration.hpp diff --git a/docs/source/Plugins.rst b/docs/source/Plugins.rst index 70502462e0..aeac133ece 100644 --- a/docs/source/Plugins.rst +++ b/docs/source/Plugins.rst @@ -219,12 +219,12 @@ Battery .. doxygengroup:: plugin_battery -.. _plugin_operation: +.. _plugin_task: -Operation +Task =========== -.. doxygengroup:: plugin_operation +.. doxygengroup:: plugin_task .. _plugin_photovoltaic: diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt index 10f6d58fe0..709bebe0f2 100644 --- a/examples/cpp/CMakeLists.txt +++ b/examples/cpp/CMakeLists.txt @@ -168,7 +168,7 @@ foreach (example activity-testany activity-waitany mc-bugged1 mc-bugged1-liveness mc-bugged2 mc-bugged2-liveness mc-centralized-mutex mc-electric-fence mc-failing-assert network-ns3 network-ns3-wifi network-wifi io-async io-priority io-degradation io-file-system io-file-remote io-disk-raw io-dependent - operation-io operation-simple operation-variable-load operation-switch-host + task-io task-simple task-variable-load task-switch-host photovoltaic-simple platform-comm-serialize platform-failures platform-profile platform-properties plugin-host-load plugin-link-load plugin-prodcons diff --git a/examples/cpp/operation-io/s4u-operation-io.cpp b/examples/cpp/operation-io/s4u-operation-io.cpp deleted file mode 100644 index f12687402c..0000000000 --- a/examples/cpp/operation-io/s4u-operation-io.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (c) 2017-2023. 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. */ - -/* This example demonstrate basic use of the operation plugin. - * - * We model the following graph: - * - * exec1 -> comm -> exec2 - * - * exec1 and exec2 are execution operations. - * comm is a communication operation. - */ - -#include -#include "simgrid/plugins/operation.hpp" -#include "simgrid/s4u.hpp" - -XBT_LOG_NEW_DEFAULT_CATEGORY(operation_simple, "Messages specific for this operation example"); - -int main(int argc, char* argv[]) -{ - simgrid::s4u::Engine e(&argc, argv); - e.load_platform(argv[1]); - simgrid::plugins::Operation::init(); - - // Retrieve hosts - auto bob = e.host_by_name("bob"); - auto carl = e.host_by_name("carl"); - - // Create operations - auto exec1 = simgrid::plugins::ExecOp::init("exec1", 1e9, bob); - auto exec2 = simgrid::plugins::ExecOp::init("exec2", 1e9, carl); - auto write = simgrid::plugins::IoOp::init("write", 1e7, bob->get_disks().front(), simgrid::s4u::Io::OpType::WRITE); - auto read = simgrid::plugins::IoOp::init("read", 1e7, carl->get_disks().front(), simgrid::s4u::Io::OpType::READ); - - // Create the graph by defining dependencies between operations - exec1->add_successor(write); - write->add_successor(read); - read->add_successor(exec2); - - // Add a function to be called when operations end for log purpose - simgrid::plugins::Operation::on_end_cb([](const simgrid::plugins::Operation* op) { - XBT_INFO("Operation %s finished (%d)", op->get_name().c_str(), op->get_count()); - }); - - // Enqueue two executions for operation exec1 - exec1->enqueue_execs(2); - - // Start the simulation - e.run(); - return 0; -} diff --git a/examples/cpp/operation-io/s4u-operation-io.tesh b/examples/cpp/operation-io/s4u-operation-io.tesh deleted file mode 100644 index 89adedd735..0000000000 --- a/examples/cpp/operation-io/s4u-operation-io.tesh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env tesh - -$ ${bindir:=.}/s4u-operation-io ${platfdir}/hosts_with_disks.xml -> [1.000000] [operation_simple/INFO] Operation exec1 finished (1) -> [1.250000] [operation_simple/INFO] Operation write finished (1) -> [1.350000] [operation_simple/INFO] Operation read finished (1) -> [2.000000] [operation_simple/INFO] Operation exec1 finished (2) -> [2.250000] [operation_simple/INFO] Operation write finished (2) -> [2.350000] [operation_simple/INFO] Operation exec2 finished (1) -> [2.350000] [operation_simple/INFO] Operation read finished (2) -> [3.350000] [operation_simple/INFO] Operation exec2 finished (2) diff --git a/examples/cpp/operation-simple/s4u-operation-simple.cpp b/examples/cpp/operation-simple/s4u-operation-simple.cpp deleted file mode 100644 index 40a32b2212..0000000000 --- a/examples/cpp/operation-simple/s4u-operation-simple.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright (c) 2017-2023. 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. */ - -/* This example demonstrate basic use of the operation plugin. - * - * We model the following graph: - * - * exec1 -> comm -> exec2 - * - * exec1 and exec2 are execution operations. - * comm is a communication operation. - */ - -#include "simgrid/plugins/operation.hpp" -#include "simgrid/s4u.hpp" - -XBT_LOG_NEW_DEFAULT_CATEGORY(operation_simple, "Messages specific for this operation example"); - -int main(int argc, char* argv[]) -{ - simgrid::s4u::Engine e(&argc, argv); - e.load_platform(argv[1]); - simgrid::plugins::Operation::init(); - - // Retrieve hosts - auto tremblay = e.host_by_name("Tremblay"); - auto jupiter = e.host_by_name("Jupiter"); - - // Create operations - auto exec1 = simgrid::plugins::ExecOp::init("exec1", 1e9, tremblay); - auto exec2 = simgrid::plugins::ExecOp::init("exec2", 1e9, jupiter); - auto comm = simgrid::plugins::CommOp::init("comm", 1e7, tremblay, jupiter); - - // Create the graph by defining dependencies between operations - exec1->add_successor(comm); - comm->add_successor(exec2); - - // Add a function to be called when operations end for log purpose - simgrid::plugins::Operation::on_end_cb([](const simgrid::plugins::Operation* op) { - XBT_INFO("Operation %s finished (%d)", op->get_name().c_str(), op->get_count()); - }); - - // Enqueue two executions for operation exec1 - exec1->enqueue_execs(2); - - // Start the simulation - e.run(); - return 0; -} diff --git a/examples/cpp/operation-simple/s4u-operation-simple.tesh b/examples/cpp/operation-simple/s4u-operation-simple.tesh deleted file mode 100644 index c9eee76355..0000000000 --- a/examples/cpp/operation-simple/s4u-operation-simple.tesh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env tesh - -$ ${bindir:=.}/s4u-operation-simple ${platfdir}/small_platform.xml -> [10.194200] [operation_simple/INFO] Operation exec1 finished (1) -> [11.714617] [operation_simple/INFO] Operation comm finished (1) -> [20.388399] [operation_simple/INFO] Operation exec1 finished (2) -> [21.908817] [operation_simple/INFO] Operation comm finished (2) -> [24.821464] [operation_simple/INFO] Operation exec2 finished (1) -> [37.928311] [operation_simple/INFO] Operation exec2 finished (2) diff --git a/examples/cpp/operation-switch-host/s4u-operation-switch-host.tesh b/examples/cpp/operation-switch-host/s4u-operation-switch-host.tesh deleted file mode 100644 index 20bff408af..0000000000 --- a/examples/cpp/operation-switch-host/s4u-operation-switch-host.tesh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env tesh - -$ ${bindir:=.}/s4u-operation-switch-host ${platfdir}/small_platform.xml -> [1.520418] [operation_switch_host/INFO] Operation comm0 finished (1) -> [2.873012] [operation_switch_host/INFO] Operation comm0 finished (2) -> [4.393430] [operation_switch_host/INFO] Operation comm0 finished (3) -> [5.746025] [operation_switch_host/INFO] Operation comm0 finished (4) -> [14.627265] [operation_switch_host/INFO] Operation exec1 finished (1) -> [15.979859] [operation_switch_host/INFO] Operation exec2 finished (1) -> [16.147682] [operation_switch_host/INFO] Operation comm1 finished (1) -> [17.332454] [operation_switch_host/INFO] Operation comm2 finished (1) -> [27.734112] [operation_switch_host/INFO] Operation exec1 finished (2) -> [29.086707] [operation_switch_host/INFO] Operation exec2 finished (2) -> [29.254529] [operation_switch_host/INFO] Operation comm1 finished (2) -> [30.439301] [operation_switch_host/INFO] Operation comm2 finished (2) \ No newline at end of file diff --git a/examples/cpp/operation-variable-load/s4u-operation-variable-load.tesh b/examples/cpp/operation-variable-load/s4u-operation-variable-load.tesh deleted file mode 100644 index b0d5cecce5..0000000000 --- a/examples/cpp/operation-variable-load/s4u-operation-variable-load.tesh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env tesh - -$ ${bindir:=.}/s4u-operation-variable-load ${platfdir}/small_platform.xml -> [Tremblay:input:(1) 0.000000] [operation_variable_load/INFO] --- Small load --- -> [1.520418] [operation_variable_load/INFO] Operation comm finished (1) -> [14.627265] [operation_variable_load/INFO] Operation exec finished (1) -> [101.520418] [operation_variable_load/INFO] Operation comm finished (2) -> [114.627265] [operation_variable_load/INFO] Operation exec finished (2) -> [201.520418] [operation_variable_load/INFO] Operation comm finished (3) -> [214.627265] [operation_variable_load/INFO] Operation exec finished (3) -> [Tremblay:input:(1) 1000.000000] [operation_variable_load/INFO] --- Heavy load --- -> [1001.520418] [operation_variable_load/INFO] Operation comm finished (4) -> [1003.040835] [operation_variable_load/INFO] Operation comm finished (5) -> [1004.561253] [operation_variable_load/INFO] Operation comm finished (6) -> [1014.627265] [operation_variable_load/INFO] Operation exec finished (4) -> [1027.734112] [operation_variable_load/INFO] Operation exec finished (5) -> [1040.840959] [operation_variable_load/INFO] Operation exec finished (6) diff --git a/examples/cpp/task-io/s4u-task-io.cpp b/examples/cpp/task-io/s4u-task-io.cpp new file mode 100644 index 0000000000..4150f442c3 --- /dev/null +++ b/examples/cpp/task-io/s4u-task-io.cpp @@ -0,0 +1,54 @@ +/* Copyright (c) 2017-2023. 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. */ + +/* This example demonstrate basic use of the task plugin. + * + * We model the following graph: + * + * exec1 -> comm -> exec2 + * + * exec1 and exec2 are execution tasks. + * comm is a communication task. + */ + +#include "simgrid/plugins/task.hpp" +#include "simgrid/s4u.hpp" +#include + +XBT_LOG_NEW_DEFAULT_CATEGORY(task_simple, "Messages specific for this task example"); + +int main(int argc, char* argv[]) +{ + simgrid::s4u::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); + + // Create the graph by defining dependencies between tasks + exec1->add_successor(write); + write->add_successor(read); + 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) { + XBT_INFO("Task %s finished (%d)", t->get_name().c_str(), t->get_count()); + }); + + // Enqueue two executions for task exec1 + exec1->enqueue_execs(2); + + // Start the simulation + e.run(); + return 0; +} diff --git a/examples/cpp/task-io/s4u-task-io.tesh b/examples/cpp/task-io/s4u-task-io.tesh new file mode 100644 index 0000000000..b1b5cdb1be --- /dev/null +++ b/examples/cpp/task-io/s4u-task-io.tesh @@ -0,0 +1,11 @@ +#!/usr/bin/env tesh + +$ ${bindir:=.}/s4u-task-io ${platfdir}/hosts_with_disks.xml +> [1.000000] [task_simple/INFO] Task exec1 finished (1) +> [1.250000] [task_simple/INFO] Task write finished (1) +> [1.350000] [task_simple/INFO] Task read finished (1) +> [2.000000] [task_simple/INFO] Task exec1 finished (2) +> [2.250000] [task_simple/INFO] Task write finished (2) +> [2.350000] [task_simple/INFO] Task exec2 finished (1) +> [2.350000] [task_simple/INFO] Task read finished (2) +> [3.350000] [task_simple/INFO] Task exec2 finished (2) diff --git a/examples/cpp/task-simple/s4u-task-simple.cpp b/examples/cpp/task-simple/s4u-task-simple.cpp new file mode 100644 index 0000000000..0eddb5a1ef --- /dev/null +++ b/examples/cpp/task-simple/s4u-task-simple.cpp @@ -0,0 +1,51 @@ +/* Copyright (c) 2017-2023. 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. */ + +/* This example demonstrate basic use of the task plugin. + * + * We model the following graph: + * + * exec1 -> comm -> exec2 + * + * exec1 and exec2 are execution tasks. + * 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"); + +int main(int argc, char* argv[]) +{ + simgrid::s4u::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); + + // 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) { + XBT_INFO("Task %s finished (%d)", t->get_name().c_str(), t->get_count()); + }); + + // Enqueue two executions for task exec1 + exec1->enqueue_execs(2); + + // Start the simulation + e.run(); + return 0; +} diff --git a/examples/cpp/task-simple/s4u-task-simple.tesh b/examples/cpp/task-simple/s4u-task-simple.tesh new file mode 100644 index 0000000000..b07d406d4d --- /dev/null +++ b/examples/cpp/task-simple/s4u-task-simple.tesh @@ -0,0 +1,9 @@ +#!/usr/bin/env tesh + +$ ${bindir:=.}/s4u-task-simple ${platfdir}/small_platform.xml +> [10.194200] [task_simple/INFO] Task exec1 finished (1) +> [11.714617] [task_simple/INFO] Task comm finished (1) +> [20.388399] [task_simple/INFO] Task exec1 finished (2) +> [21.908817] [task_simple/INFO] Task comm finished (2) +> [24.821464] [task_simple/INFO] Task exec2 finished (1) +> [37.928311] [task_simple/INFO] Task exec2 finished (2) diff --git a/examples/cpp/operation-switch-host/s4u-operation-switch-host.cpp b/examples/cpp/task-switch-host/s4u-task-switch-host.cpp similarity index 58% rename from examples/cpp/operation-switch-host/s4u-operation-switch-host.cpp rename to examples/cpp/task-switch-host/s4u-task-switch-host.cpp index 10b0b4cd31..27038a38fa 100644 --- a/examples/cpp/operation-switch-host/s4u-operation-switch-host.cpp +++ b/examples/cpp/task-switch-host/s4u-task-switch-host.cpp @@ -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 demonstrates how to dynamically modify a graph of operations. +/* This example demonstrates how to dynamically modify a graph of tasks. * * Assuming we have two instances of a service placed on different hosts, * we want to send data alternatively to thoses instances. @@ -16,46 +16,46 @@ * With exec1 and exec2 on different hosts. */ -#include "simgrid/plugins/operation.hpp" +#include "simgrid/plugins/task.hpp" #include "simgrid/s4u.hpp" -XBT_LOG_NEW_DEFAULT_CATEGORY(operation_switch_host, "Messages specific for this operation example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(task_switch_host, "Messages specific for this task example"); int main(int argc, char* argv[]) { simgrid::s4u::Engine e(&argc, argv); e.load_platform(argv[1]); - simgrid::plugins::Operation::init(); + simgrid::plugins::Task::init(); // Retrieve hosts auto* tremblay = e.host_by_name("Tremblay"); auto* jupiter = e.host_by_name("Jupiter"); auto* fafard = e.host_by_name("Fafard"); - // Create operations - auto comm0 = simgrid::plugins::CommOp::init("comm0"); + // Create tasks + auto comm0 = simgrid::plugins::CommTask::init("comm0"); comm0->set_bytes(1e7); comm0->set_source(tremblay); - auto exec1 = simgrid::plugins::ExecOp::init("exec1", 1e9, jupiter); - auto exec2 = simgrid::plugins::ExecOp::init("exec2", 1e9, fafard); - auto comm1 = simgrid::plugins::CommOp::init("comm1", 1e7, jupiter, tremblay); - auto comm2 = simgrid::plugins::CommOp::init("comm2", 1e7, fafard, 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); - // Create the initial graph by defining dependencies between operations + // Create the initial graph by defining dependencies between tasks comm0->add_successor(exec2); exec1->add_successor(comm1); exec2->add_successor(comm2); - // Add a function to be called when operations end for log purpose - simgrid::plugins::Operation::on_end_cb([](const simgrid::plugins::Operation* op) { - XBT_INFO("Operation %s finished (%d)", op->get_name().c_str(), op->get_count()); + // Add a function to be called when tasks end for log purpose + simgrid::plugins::Task::on_end_cb([](const simgrid::plugins::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 operations by adding or removing + // This function modifies the graph of tasks by adding or removing // successors to comm0 - comm0->on_this_start([exec1, exec2, jupiter, fafard](simgrid::plugins::Operation* op) { - auto* comm0 = dynamic_cast(op); + comm0->on_this_start([exec1, exec2, jupiter, fafard](simgrid::plugins::Task* t) { + auto* comm0 = dynamic_cast(t); static int count = 0; if (count % 2 == 0) { comm0->set_destination(jupiter); @@ -69,7 +69,7 @@ int main(int argc, char* argv[]) count++; }); - // Enqueue four executions for operation comm0 + // Enqueue four executions for task comm0 comm0->enqueue_execs(4); // Start the simulation diff --git a/examples/cpp/task-switch-host/s4u-task-switch-host.tesh b/examples/cpp/task-switch-host/s4u-task-switch-host.tesh new file mode 100644 index 0000000000..b3146ff29c --- /dev/null +++ b/examples/cpp/task-switch-host/s4u-task-switch-host.tesh @@ -0,0 +1,15 @@ +#!/usr/bin/env tesh + +$ ${bindir:=.}/s4u-task-switch-host ${platfdir}/small_platform.xml +> [1.520418] [task_switch_host/INFO] Task comm0 finished (1) +> [2.873012] [task_switch_host/INFO] Task comm0 finished (2) +> [4.393430] [task_switch_host/INFO] Task comm0 finished (3) +> [5.746025] [task_switch_host/INFO] Task comm0 finished (4) +> [14.627265] [task_switch_host/INFO] Task exec1 finished (1) +> [15.979859] [task_switch_host/INFO] Task exec2 finished (1) +> [16.147682] [task_switch_host/INFO] Task comm1 finished (1) +> [17.332454] [task_switch_host/INFO] Task comm2 finished (1) +> [27.734112] [task_switch_host/INFO] Task exec1 finished (2) +> [29.086707] [task_switch_host/INFO] Task exec2 finished (2) +> [29.254529] [task_switch_host/INFO] Task comm1 finished (2) +> [30.439301] [task_switch_host/INFO] Task comm2 finished (2) \ No newline at end of file diff --git a/examples/cpp/operation-variable-load/s4u-operation-variable-load.cpp b/examples/cpp/task-variable-load/s4u-task-variable-load.cpp similarity index 51% rename from examples/cpp/operation-variable-load/s4u-operation-variable-load.cpp rename to examples/cpp/task-variable-load/s4u-task-variable-load.cpp index 02938b5a8d..ddcea76bd5 100644 --- a/examples/cpp/operation-variable-load/s4u-operation-variable-load.cpp +++ b/examples/cpp/task-variable-load/s4u-task-variable-load.cpp @@ -3,32 +3,32 @@ /* 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 demonstrates how to create a variable load for operations. +/* This example demonstrates how to create a variable load for tasks. * * We consider the following graph: * * comm -> exec * - * With a small load each comm operation is followed by an exec operation. - * With a heavy load there is a burst of comm before the exec operation can even finish once. + * With a small load each comm task is followed by an exec task. + * With a heavy load there is a burst of comm before the exec task can even finish once. */ -#include "simgrid/plugins/operation.hpp" +#include "simgrid/plugins/task.hpp" #include "simgrid/s4u.hpp" -XBT_LOG_NEW_DEFAULT_CATEGORY(operation_variable_load, "Messages specific for this s4u example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(task_variable_load, "Messages specific for this s4u example"); -static void variable_load(simgrid::plugins::OperationPtr op) +static void variable_load(simgrid::plugins::TaskPtr t) { XBT_INFO("--- Small load ---"); for (int i = 0; i < 3; i++) { - op->enqueue_execs(1); + t->enqueue_execs(1); simgrid::s4u::this_actor::sleep_for(100); } simgrid::s4u::this_actor::sleep_until(1000); XBT_INFO("--- Heavy load ---"); for (int i = 0; i < 3; i++) { - op->enqueue_execs(1); + t->enqueue_execs(1); simgrid::s4u::this_actor::sleep_for(1); } } @@ -37,22 +37,22 @@ int main(int argc, char* argv[]) { simgrid::s4u::Engine e(&argc, argv); e.load_platform(argv[1]); - simgrid::plugins::Operation::init(); + simgrid::plugins::Task::init(); // Retreive hosts auto tremblay = e.host_by_name("Tremblay"); auto jupiter = e.host_by_name("Jupiter"); - // Create operations - auto comm = simgrid::plugins::CommOp::init("comm", 1e7, tremblay, jupiter); - auto exec = simgrid::plugins::ExecOp::init("exec", 1e9, jupiter); + // Create tasks + auto comm = simgrid::plugins::CommTask::init("comm", 1e7, tremblay, jupiter); + auto exec = simgrid::plugins::ExecTask::init("exec", 1e9, jupiter); - // Create the graph by defining dependencies between operations + // Create the graph by defining dependencies between tasks comm->add_successor(exec); - // Add a function to be called when operations end for log purpose - simgrid::plugins::Operation::on_end_cb([](const simgrid::plugins::Operation* op) { - XBT_INFO("Operation %s finished (%d)", op->get_name().c_str(), op->get_count()); + // Add a function to be called when tasks end for log purpose + simgrid::plugins::Task::on_end_cb([](const simgrid::plugins::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 diff --git a/examples/cpp/task-variable-load/s4u-task-variable-load.tesh b/examples/cpp/task-variable-load/s4u-task-variable-load.tesh new file mode 100644 index 0000000000..2f2ab9bd1b --- /dev/null +++ b/examples/cpp/task-variable-load/s4u-task-variable-load.tesh @@ -0,0 +1,17 @@ +#!/usr/bin/env tesh + +$ ${bindir:=.}/s4u-task-variable-load ${platfdir}/small_platform.xml +> [Tremblay:input:(1) 0.000000] [task_variable_load/INFO] --- Small load --- +> [1.520418] [task_variable_load/INFO] Task comm finished (1) +> [14.627265] [task_variable_load/INFO] Task exec finished (1) +> [101.520418] [task_variable_load/INFO] Task comm finished (2) +> [114.627265] [task_variable_load/INFO] Task exec finished (2) +> [201.520418] [task_variable_load/INFO] Task comm finished (3) +> [214.627265] [task_variable_load/INFO] Task exec finished (3) +> [Tremblay:input:(1) 1000.000000] [task_variable_load/INFO] --- Heavy load --- +> [1001.520418] [task_variable_load/INFO] Task comm finished (4) +> [1003.040835] [task_variable_load/INFO] Task comm finished (5) +> [1004.561253] [task_variable_load/INFO] Task comm finished (6) +> [1014.627265] [task_variable_load/INFO] Task exec finished (4) +> [1027.734112] [task_variable_load/INFO] Task exec finished (5) +> [1040.840959] [task_variable_load/INFO] Task exec finished (6) diff --git a/examples/python/CMakeLists.txt b/examples/python/CMakeLists.txt index 7d6b742d22..f4afe5bbd7 100644 --- a/examples/python/CMakeLists.txt +++ b/examples/python/CMakeLists.txt @@ -3,7 +3,7 @@ foreach(example actor-create actor-daemon actor-join actor-kill actor-migrate ac comm-wait comm-waitall comm-waitallfor comm-waitany comm-failure comm-host2host comm-pingpong comm-ready comm-suspend comm-testany comm-throttling comm-waitallfor comm-waituntil exec-async exec-basic exec-dvfs exec-remote exec-ptask - operation-io operation-simple operation-switch-host operation-variable-load + task-io task-simple task-switch-host task-variable-load platform-comm-serialize platform-profile platform-failures network-nonlinear clusters-multicpu io-degradation exec-cpu-nonlinear synchro-barrier synchro-mutex synchro-semaphore) diff --git a/examples/python/operation-io/operation-io.tesh b/examples/python/operation-io/operation-io.tesh deleted file mode 100644 index b217012f6a..0000000000 --- a/examples/python/operation-io/operation-io.tesh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env tesh - -$ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${srcdir:=.}/operation-io.py --platform ${platfdir}/hosts_with_disks.xml -> [1.0] Operation ExecOp(exec1) finished (1) -> [1.25] Operation IoOp(write) finished (1) -> [1.35] Operation IoOp(read) finished (1) -> [2.0] Operation ExecOp(exec1) finished (2) -> [2.25] Operation IoOp(write) finished (2) -> [2.35] Operation ExecOp(exec2) finished (1) -> [2.35] Operation IoOp(read) finished (2) -> [3.35] Operation ExecOp(exec2) finished (2) - diff --git a/examples/python/operation-simple/operation-simple.tesh b/examples/python/operation-simple/operation-simple.tesh deleted file mode 100644 index fcea020620..0000000000 --- a/examples/python/operation-simple/operation-simple.tesh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env tesh - -$ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${srcdir:=.}/operation-simple.py --platform ${platfdir}/small_platform.xml -> [10.194199500484224] Operation ExecOp(exec1) finished (1) -> [11.714617112501687] Operation CommOp(comm) finished (1) -> [20.388399000968448] Operation ExecOp(exec1) finished (2) -> [21.90881661298591] Operation CommOp(comm) finished (2) -> [24.82146412938331] Operation ExecOp(exec2) finished (1) -> [37.92831114626493] Operation ExecOp(exec2) finished (2) diff --git a/examples/python/operation-switch-host/operation-switch-host.tesh b/examples/python/operation-switch-host/operation-switch-host.tesh deleted file mode 100644 index ced340b115..0000000000 --- a/examples/python/operation-switch-host/operation-switch-host.tesh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env tesh - -$ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${srcdir:=.}/operation-switch-host.py --platform ${platfdir}/small_platform.xml -> [1.5204176120174615] Operation CommOp(comm0) finished (1) -> [2.873012467069035] Operation CommOp(comm0) finished (2) -> [4.393430079086497] Operation CommOp(comm0) finished (3) -> [5.74602493413807] Operation CommOp(comm0) finished (4) -> [14.62726462889908] Operation ExecOp(exec1) finished (1) -> [15.979859483950655] Operation ExecOp(exec2) finished (1) -> [16.14768224091654] Operation CommOp(comm1) finished (1) -> [17.33245433900223] Operation CommOp(comm2) finished (1) -> [27.7341116457807] Operation ExecOp(exec1) finished (2) -> [29.086706500832275] Operation ExecOp(exec2) finished (2) -> [29.25452925779816] Operation CommOp(comm1) finished (2) -> [30.43930135588385] Operation CommOp(comm2) finished (2) diff --git a/examples/python/operation-variable-load/operation-variable-load.tesh b/examples/python/operation-variable-load/operation-variable-load.tesh deleted file mode 100644 index 70ecefe202..0000000000 --- a/examples/python/operation-variable-load/operation-variable-load.tesh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env tesh - -$ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${srcdir:=.}/operation-variable-load.py --platform ${platfdir}/small_platform.xml -> --- Small load --- -> [1.5204176120174615] Operation CommOp(comm) finished (1) -> [14.62726462889908] Operation ExecOp(exec) finished (1) -> [101.52041761201747] Operation CommOp(comm) finished (2) -> [114.62726462889908] Operation ExecOp(exec) finished (2) -> [201.52041761201744] Operation CommOp(comm) finished (3) -> [214.62726462889907] Operation ExecOp(exec) finished (3) -> --- Heavy load --- -> [1301.5204176120174] Operation CommOp(comm) finished (4) -> [1303.0408352240347] Operation CommOp(comm) finished (5) -> [1304.561252836052] Operation CommOp(comm) finished (6) -> [1314.627264628899] Operation ExecOp(exec) finished (4) -> [1327.7341116457806] Operation ExecOp(exec) finished (5) -> [1340.8409586626622] Operation ExecOp(exec) finished (6) - - diff --git a/examples/python/operation-io/operation-io.py b/examples/python/task-io/task-io.py similarity index 56% rename from examples/python/operation-io/operation-io.py rename to examples/python/task-io/task-io.py index 59a07afaad..18a4cb2aac 100644 --- a/examples/python/operation-io/operation-io.py +++ b/examples/python/task-io/task-io.py @@ -5,7 +5,7 @@ from argparse import ArgumentParser import sys -from simgrid import Engine, Operation, ExecOp, IoOp, IoOpType +from simgrid import Engine, Task, ExecTask, IoTask, IoOpType def parse(): parser = ArgumentParser() @@ -17,34 +17,34 @@ def parse(): ) return parser.parse_args() -def callback(op): - print(f'[{Engine.clock}] Operation {op} finished ({op.count})') +def callback( t): + print(f'[{Engine.clock}] { t} finished ({ t.count})') if __name__ == '__main__': args = parse() e = Engine(sys.argv) e.load_platform(args.platform) - Operation.init() + Task.init() # Retrieve hosts bob = e.host_by_name('bob') carl = e.host_by_name('carl') - # Create operations - exec1 = ExecOp.init("exec1", 1e9, bob) - exec2 = ExecOp.init("exec2", 1e9, carl) - write = IoOp.init("write", 1e7, bob.disks[0], IoOpType.WRITE) - read = IoOp.init("read", 1e7, carl.disks[0], IoOpType.READ) + # Create tasks + exec1 = ExecTask.init("exec1", 1e9, bob) + exec2 = ExecTask.init("exec2", 1e9, carl) + write = IoTask.init("write", 1e7, bob.disks[0], IoOpType.WRITE) + read = IoTask.init("read", 1e7, carl.disks[0], IoOpType.READ) - # Create the graph by defining dependencies between operations + # Create the graph by defining dependencies between tasks exec1.add_successor(write) write.add_successor(read) read.add_successor(exec2) - # Add a function to be called when operations end for log purpose - Operation.on_end_cb(callback) + # Add a function to be called when tasks end for log purpose + Task.on_end_cb(callback) - # Enqueue two executions for operation exec1 + # Enqueue two executions for task exec1 exec1.enqueue_execs(2) # runs the simulation diff --git a/examples/python/task-io/task-io.tesh b/examples/python/task-io/task-io.tesh new file mode 100644 index 0000000000..c6e5691f3f --- /dev/null +++ b/examples/python/task-io/task-io.tesh @@ -0,0 +1,12 @@ +#!/usr/bin/env tesh + +$ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${srcdir:=.}/task-io.py --platform ${platfdir}/hosts_with_disks.xml +> [1.0] ExecTask(exec1) finished (1) +> [1.25] IoTask(write) finished (1) +> [1.35] IoTask(read) finished (1) +> [2.0] ExecTask(exec1) finished (2) +> [2.25] IoTask(write) finished (2) +> [2.35] ExecTask(exec2) finished (1) +> [2.35] IoTask(read) finished (2) +> [3.35] ExecTask(exec2) finished (2) + diff --git a/examples/python/operation-simple/operation-simple.py b/examples/python/task-simple/task-simple.py similarity index 56% rename from examples/python/operation-simple/operation-simple.py rename to examples/python/task-simple/task-simple.py index fcd36ecc9b..29a24b7f66 100644 --- a/examples/python/operation-simple/operation-simple.py +++ b/examples/python/task-simple/task-simple.py @@ -4,18 +4,18 @@ # under the terms of the license (GNU LGPL) which comes with this package. """ -This example demonstrates basic use of the operation plugin. +This example demonstrates basic use of the task plugin. We model the following graph: exec1 -> comm -> exec2 -exec1 and exec2 are execution operations. -comm is a communication operation. +exec1 and exec2 are execution tasks. +comm is a communication task. """ from argparse import ArgumentParser import sys -from simgrid import Engine, Operation, CommOp, ExecOp +from simgrid import Engine, Task, CommTask, ExecTask def parse(): parser = ArgumentParser() @@ -27,32 +27,32 @@ def parse(): ) return parser.parse_args() -def callback(op): - print(f'[{Engine.clock}] Operation {op} finished ({op.count})') +def callback( t): + print(f'[{Engine.clock}] { t} finished ({ t.count})') if __name__ == '__main__': args = parse() e = Engine(sys.argv) e.load_platform(args.platform) - Operation.init() + Task.init() # Retrieve hosts tremblay = e.host_by_name('Tremblay') jupiter = e.host_by_name('Jupiter') - # Create operations - exec1 = ExecOp.init("exec1", 1e9, tremblay) - exec2 = ExecOp.init("exec2", 1e9, jupiter) - comm = CommOp.init("comm", 1e7, tremblay, jupiter) + # Create tasks + exec1 = ExecTask.init("exec1", 1e9, tremblay) + exec2 = ExecTask.init("exec2", 1e9, jupiter) + comm = CommTask.init("comm", 1e7, tremblay, jupiter) - # Create the graph by defining dependencies between operations + # Create the graph by defining dependencies between tasks exec1.add_successor(comm) comm.add_successor(exec2) - # Add a function to be called when operations end for log purpose - Operation.on_end_cb(callback) + # Add a function to be called when tasks end for log purpose + Task.on_end_cb(callback) - # Enqueue two executions for operation exec1 + # Enqueue two executions for task exec1 exec1.enqueue_execs(2) # runs the simulation diff --git a/examples/python/task-simple/task-simple.tesh b/examples/python/task-simple/task-simple.tesh new file mode 100644 index 0000000000..5a27a53ad4 --- /dev/null +++ b/examples/python/task-simple/task-simple.tesh @@ -0,0 +1,9 @@ +#!/usr/bin/env tesh + +$ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${srcdir:=.}/task-simple.py --platform ${platfdir}/small_platform.xml +> [10.194199500484224] ExecTask(exec1) finished (1) +> [11.714617112501687] CommTask(comm) finished (1) +> [20.388399000968448] ExecTask(exec1) finished (2) +> [21.90881661298591] CommTask(comm) finished (2) +> [24.82146412938331] ExecTask(exec2) finished (1) +> [37.92831114626493] ExecTask(exec2) finished (2) diff --git a/examples/python/operation-switch-host/operation-switch-host.py b/examples/python/task-switch-host/task-switch-host.py similarity index 69% rename from examples/python/operation-switch-host/operation-switch-host.py rename to examples/python/task-switch-host/task-switch-host.py index 90a1fae78b..f8d8dfa942 100644 --- a/examples/python/operation-switch-host/operation-switch-host.py +++ b/examples/python/task-switch-host/task-switch-host.py @@ -4,7 +4,7 @@ # under the terms of the license (GNU LGPL) which comes with this package. """ -/* This example demonstrates how to dynamically modify a graph of operations. +/* This example demonstrates how to dynamically modify a graph of tasks. * * Assuming we have two instances of a service placed on different hosts, * we want to send data alternatively to thoses instances. @@ -31,7 +31,7 @@ from argparse import ArgumentParser import sys -from simgrid import Engine, Operation, CommOp, ExecOp +from simgrid import Engine, Task, CommTask, ExecTask def parse(): parser = ArgumentParser() @@ -43,47 +43,47 @@ def parse(): ) return parser.parse_args() -def callback(op): - print(f'[{Engine.clock}] Operation {op} finished ({op.count})') +def callback( t): + print(f'[{Engine.clock}] { t} finished ({ t.count})') -def switch(op, hosts, execs): - comm0.destination = hosts[op.count % 2] - comm0.remove_successor(execs[op.count % 2 - 1]) - comm0.add_successor(execs[op.count % 2]) +def switch( t, hosts, execs): + comm0.destination = hosts[ t.count % 2] + comm0.remove_successor(execs[ t.count % 2 - 1]) + comm0.add_successor(execs[ t.count % 2]) if __name__ == '__main__': args = parse() e = Engine(sys.argv) e.load_platform(args.platform) - Operation.init() + Task.init() # Retrieve hosts tremblay = e.host_by_name('Tremblay') jupiter = e.host_by_name('Jupiter') fafard = e.host_by_name('Fafard') - # Create operations - comm0 = CommOp.init("comm0") + # Create tasks + comm0 = CommTask.init("comm0") comm0.bytes = 1e7 comm0.source = tremblay - exec1 = ExecOp.init("exec1", 1e9, jupiter) - exec2 = ExecOp.init("exec2", 1e9, fafard) - comm1 = CommOp.init("comm1", 1e7, jupiter, tremblay) - comm2 = CommOp.init("comm2", 1e7, fafard, tremblay) + exec1 = ExecTask.init("exec1", 1e9, jupiter) + exec2 = ExecTask.init("exec2", 1e9, fafard) + comm1 = CommTask.init("comm1", 1e7, jupiter, tremblay) + comm2 = CommTask.init("comm2", 1e7, fafard, tremblay) - # Create the initial graph by defining dependencies between operations + # Create the initial graph by defining dependencies between tasks exec1.add_successor(comm1) exec2.add_successor(comm2) - # Add a function to be called when operations end for log purpose - Operation.on_end_cb(callback) + # Add a function to be called when tasks end for log purpose + Task.on_end_cb(callback) # Add a function to be called before each executions of comm0 - # This function modifies the graph of operations by adding or removing + # This function modifies the graph of tasks by adding or removing # successors to comm0 - comm0.on_this_start(lambda op: switch(op, [jupiter, fafard], [exec1,exec2])) + comm0.on_this_start(lambda t: switch( t, [jupiter, fafard], [exec1,exec2])) - # Enqueue two executions for operation exec1 + # Enqueue two executions for task exec1 comm0.enqueue_execs(4) # runs the simulation diff --git a/examples/python/task-switch-host/task-switch-host.tesh b/examples/python/task-switch-host/task-switch-host.tesh new file mode 100644 index 0000000000..e506de708b --- /dev/null +++ b/examples/python/task-switch-host/task-switch-host.tesh @@ -0,0 +1,15 @@ +#!/usr/bin/env tesh + +$ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${srcdir:=.}/task-switch-host.py --platform ${platfdir}/small_platform.xml +> [1.5204176120174615] CommTask(comm0) finished (1) +> [2.873012467069035] CommTask(comm0) finished (2) +> [4.393430079086497] CommTask(comm0) finished (3) +> [5.74602493413807] CommTask(comm0) finished (4) +> [14.62726462889908] ExecTask(exec1) finished (1) +> [15.979859483950655] ExecTask(exec2) finished (1) +> [16.14768224091654] CommTask(comm1) finished (1) +> [17.33245433900223] CommTask(comm2) finished (1) +> [27.7341116457807] ExecTask(exec1) finished (2) +> [29.086706500832275] ExecTask(exec2) finished (2) +> [29.25452925779816] CommTask(comm1) finished (2) +> [30.43930135588385] CommTask(comm2) finished (2) diff --git a/examples/python/operation-variable-load/operation-variable-load.py b/examples/python/task-variable-load/task-variable-load.py similarity index 59% rename from examples/python/operation-variable-load/operation-variable-load.py rename to examples/python/task-variable-load/task-variable-load.py index 800da204bc..5e437e36b5 100644 --- a/examples/python/operation-variable-load/operation-variable-load.py +++ b/examples/python/task-variable-load/task-variable-load.py @@ -4,18 +4,18 @@ # under the terms of the license (GNU LGPL) which comes with this package. """ -This example demonstrates how to create a variable load for operations. +This example demonstrates how to create a variable load for tasks. We consider the following graph: comm -> exec -With a small load each comm operation is followed by an exec operation. -With a heavy load there is a burst of comm before the exec operation can even finish once. +With a small load each comm task is followed by an exec task. +With a heavy load there is a burst of comm before the exec task can even finish once. """ from argparse import ArgumentParser import sys -from simgrid import Engine, Operation, CommOp, ExecOp, Actor, this_actor +from simgrid import Engine, Task, CommTask, ExecTask, Actor, this_actor def parse(): parser = ArgumentParser() @@ -27,39 +27,39 @@ def parse(): ) return parser.parse_args() -def callback(op): - print(f'[{Engine.clock}] Operation {op} finished ({op.count})') +def callback( t): + print(f'[{Engine.clock}] { t} finished ({ t.count})') -def variable_load(op): +def variable_load( t): print('--- Small load ---') for i in range(3): - op.enqueue_execs(1) + t.enqueue_execs(1) this_actor.sleep_for(100) this_actor.sleep_for(1000) print('--- Heavy load ---') for i in range(3): - op.enqueue_execs(1) + t.enqueue_execs(1) this_actor.sleep_for(1) if __name__ == '__main__': args = parse() e = Engine(sys.argv) e.load_platform(args.platform) - Operation.init() + Task.init() # Retrieve hosts tremblay = e.host_by_name('Tremblay') jupiter = e.host_by_name('Jupiter') - # Create operations - comm = CommOp.init("comm", 1e7, tremblay, jupiter) - exec = ExecOp.init("exec", 1e9, jupiter) + # Create tasks + comm = CommTask.init("comm", 1e7, tremblay, jupiter) + exec = ExecTask.init("exec", 1e9, jupiter) - # Create the graph by defining dependencies between operations + # Create the graph by defining dependencies between tasks comm.add_successor(exec) - # Add a function to be called when operations end for log purpose - Operation.on_end_cb(callback) + # Add a function to be called when tasks end for log purpose + Task.on_end_cb(callback) # Create the actor that will inject load during the simulation Actor.create("input", tremblay, variable_load, comm) diff --git a/examples/python/task-variable-load/task-variable-load.tesh b/examples/python/task-variable-load/task-variable-load.tesh new file mode 100644 index 0000000000..0aa185a3a7 --- /dev/null +++ b/examples/python/task-variable-load/task-variable-load.tesh @@ -0,0 +1,19 @@ +#!/usr/bin/env tesh + +$ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${srcdir:=.}/task-variable-load.py --platform ${platfdir}/small_platform.xml +> --- Small load --- +> [1.5204176120174615] CommTask(comm) finished (1) +> [14.62726462889908] ExecTask(exec) finished (1) +> [101.52041761201747] CommTask(comm) finished (2) +> [114.62726462889908] ExecTask(exec) finished (2) +> [201.52041761201744] CommTask(comm) finished (3) +> [214.62726462889907] ExecTask(exec) finished (3) +> --- Heavy load --- +> [1301.5204176120174] CommTask(comm) finished (4) +> [1303.0408352240347] CommTask(comm) finished (5) +> [1304.561252836052] CommTask(comm) finished (6) +> [1314.627264628899] ExecTask(exec) finished (4) +> [1327.7341116457806] ExecTask(exec) finished (5) +> [1340.8409586626622] ExecTask(exec) finished (6) + + diff --git a/include/simgrid/plugins/operation.hpp b/include/simgrid/plugins/operation.hpp deleted file mode 100644 index 537d95db6c..0000000000 --- a/include/simgrid/plugins/operation.hpp +++ /dev/null @@ -1,158 +0,0 @@ -#ifndef SIMGRID_PLUGINS_OPERATION_H_ -#define SIMGRID_PLUGINS_OPERATION_H_ - -#include -#include -#include - -#include -#include -#include -#include - -namespace simgrid::plugins { - -class Operation; -using OperationPtr = boost::intrusive_ptr; -XBT_PUBLIC void intrusive_ptr_release(Operation* o); -XBT_PUBLIC void intrusive_ptr_add_ref(Operation* o); -class ExecOp; -using ExecOpPtr = boost::intrusive_ptr; -XBT_PUBLIC void intrusive_ptr_release(ExecOp* e); -XBT_PUBLIC void intrusive_ptr_add_ref(ExecOp* e); -class CommOp; -using CommOpPtr = boost::intrusive_ptr; -XBT_PUBLIC void intrusive_ptr_release(CommOp* c); -XBT_PUBLIC void intrusive_ptr_add_ref(CommOp* c); -class IoOp; -using IoOpPtr = boost::intrusive_ptr; -XBT_PUBLIC void intrusive_ptr_release(IoOp* i); -XBT_PUBLIC void intrusive_ptr_add_ref(IoOp* i); - -struct ExtendedAttributeActivity { - static simgrid::xbt::Extension EXTENSION_ID; - Operation* operation_; -}; - -class Operation { - static bool inited_; - std::set successors_ = {}; - std::map predecessors_ = {}; - - void add_predecessor(Operation* predecessor); - void remove_predecessor(Operation* predecessor); - bool ready_to_run() const; - void receive(Operation* source); - void complete(); - -protected: - std::string name_; - double amount_; - int queued_execs_ = 0; - int count_ = 0; - bool working_ = false; - s4u::ActivityPtr current_activity_; - std::vector> end_func_handlers_; - std::vector> start_func_handlers_; - explicit Operation(const std::string& name); - virtual ~Operation() = default; - virtual void execute() = 0; - - static xbt::signal on_start; - static xbt::signal 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); - void set_amount(double amount); - double get_amount() const { return amount_; } - void add_successor(OperationPtr op); - void remove_successor(OperationPtr op); - void remove_all_successors(); - const std::set& get_successors() const { return successors_ ;} - void on_this_start(const std::function& func); - void on_this_end(const std::function& func); - int get_count() const; - - /** Add a callback fired before an operation activity start. - * Triggered after the on_this_start function**/ - static void on_start_cb(const std::function& cb) { on_start.connect(cb); } - /** Add a callback fired after an operation activity end. - * Triggered after the on_this_end function, but before - * sending tokens to successors.**/ - static void on_end_cb(const std::function& cb) { on_end.connect(cb); } - -#ifndef DOXYGEN - friend void intrusive_ptr_release(Operation* o) - { - if (o->refcount_.fetch_sub(1, std::memory_order_release) == 1) { - std::atomic_thread_fence(std::memory_order_acquire); - delete o; - } - } - friend void intrusive_ptr_add_ref(Operation* o) { o->refcount_.fetch_add(1, std::memory_order_relaxed); } -#endif -}; - -class ExecOp : public Operation { - s4u::Host* host_; - - explicit ExecOp(const std::string& name); - void execute() override; - -public: - static ExecOpPtr init(const std::string& name); - static ExecOpPtr init(const std::string& name, double flops, s4u::Host* host); - ExecOpPtr set_host(s4u::Host* host); - s4u::Host* get_host() const { return host_; } - ExecOpPtr set_flops(double flops); - double get_flops() const { return get_amount(); } - friend void inline intrusive_ptr_release(ExecOp* e) { intrusive_ptr_release(static_cast(e)); } - friend void inline intrusive_ptr_add_ref(ExecOp* e) { intrusive_ptr_add_ref(static_cast(e)); } -}; - -class CommOp : public Operation { - s4u::Host* source_; - s4u::Host* destination_; - - explicit CommOp(const std::string& name); - void execute() override; - -public: - static CommOpPtr init(const std::string& name); - static CommOpPtr init(const std::string& name, double bytes, s4u::Host* source, - s4u::Host* destination); - CommOpPtr set_source(s4u::Host* source); - s4u::Host* get_source() const { return source_; } - CommOpPtr set_destination(s4u::Host* destination); - s4u::Host* get_destination() const { return destination_; } - CommOpPtr set_bytes(double bytes); - double get_bytes() const { return get_amount(); } - friend void inline intrusive_ptr_release(CommOp* c) { intrusive_ptr_release(static_cast(c)); } - friend void inline intrusive_ptr_add_ref(CommOp* c) { intrusive_ptr_add_ref(static_cast(c)); } -}; - -class IoOp : public Operation { - s4u::Disk* disk_; - s4u::Io::OpType type_; - explicit IoOp(const std::string& name); - void execute() override; - -public: - static IoOpPtr init(const std::string& name); - static IoOpPtr init(const std::string& name, double bytes, s4u::Disk* disk, s4u::Io::OpType type); - IoOpPtr set_disk(s4u::Disk* disk); - s4u::Disk* get_disk() const { return disk_; } - IoOpPtr set_bytes(double bytes); - double get_bytes() { return get_amount(); } - IoOpPtr set_op_type(s4u::Io::OpType type); - s4u::Io::OpType get_op_type() { return type_; } - - friend void inline intrusive_ptr_release(IoOp* i) { intrusive_ptr_release(static_cast(i)); } - friend void inline intrusive_ptr_add_ref(IoOp* i) { intrusive_ptr_add_ref(static_cast(i)); } -}; -} // namespace simgrid::plugins -#endif diff --git a/include/simgrid/plugins/task.hpp b/include/simgrid/plugins/task.hpp new file mode 100644 index 0000000000..e9fa1afffd --- /dev/null +++ b/include/simgrid/plugins/task.hpp @@ -0,0 +1,157 @@ +#ifndef SIMGRID_PLUGINS_TASK_H_ +#define SIMGRID_PLUGINS_TASK_H_ + +#include +#include +#include + +#include +#include +#include +#include + +namespace simgrid::plugins { + +class Task; +using TaskPtr = boost::intrusive_ptr; +XBT_PUBLIC void intrusive_ptr_release(Task* o); +XBT_PUBLIC void intrusive_ptr_add_ref(Task* o); +class ExecTask; +using ExecTaskPtr = boost::intrusive_ptr; +XBT_PUBLIC void intrusive_ptr_release(ExecTask* e); +XBT_PUBLIC void intrusive_ptr_add_ref(ExecTask* e); +class CommTask; +using CommTaskPtr = boost::intrusive_ptr; +XBT_PUBLIC void intrusive_ptr_release(CommTask* c); +XBT_PUBLIC void intrusive_ptr_add_ref(CommTask* c); +class IoTask; +using IoTaskPtr = boost::intrusive_ptr; +XBT_PUBLIC void intrusive_ptr_release(IoTask* i); +XBT_PUBLIC void intrusive_ptr_add_ref(IoTask* i); + +struct ExtendedAttributeActivity { + static simgrid::xbt::Extension EXTENSION_ID; + Task* task_; +}; + +class Task { + static bool inited_; + std::set successors_ = {}; + std::map predecessors_ = {}; + + void add_predecessor(Task* predecessor); + void remove_predecessor(Task* predecessor); + bool ready_to_run() const; + void receive(Task* source); + void complete(); + +protected: + std::string name_; + double amount_; + int queued_execs_ = 0; + int count_ = 0; + bool working_ = false; + s4u::ActivityPtr current_activity_; + std::vector> end_func_handlers_; + std::vector> start_func_handlers_; + explicit Task(const std::string& name); + virtual ~Task() = default; + virtual void fire() = 0; + + static xbt::signal on_start; + static xbt::signal 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); + void set_amount(double amount); + double get_amount() const { return amount_; } + void add_successor(TaskPtr t); + void remove_successor(TaskPtr t); + void remove_all_successors(); + const std::set& get_successors() const { return successors_; } + void on_this_start(const std::function& func); + void on_this_end(const std::function& func); + int get_count() const; + + /** Add a callback fired before a task activity start. + * Triggered after the on_this_start function**/ + static void on_start_cb(const std::function& cb) { on_start.connect(cb); } + /** Add a callback fired after a task activity end. + * Triggered after the on_this_end function, but before + * sending tokens to successors.**/ + static void on_end_cb(const std::function& cb) { on_end.connect(cb); } + +#ifndef DOXYGEN + friend void intrusive_ptr_release(Task* o) + { + if (o->refcount_.fetch_sub(1, std::memory_order_release) == 1) { + std::atomic_thread_fence(std::memory_order_acquire); + delete o; + } + } + friend void intrusive_ptr_add_ref(Task* o) { o->refcount_.fetch_add(1, std::memory_order_relaxed); } +#endif +}; + +class ExecTask : public Task { + s4u::Host* host_; + + explicit ExecTask(const std::string& name); + void fire() override; + +public: + static ExecTaskPtr init(const std::string& name); + static ExecTaskPtr init(const std::string& name, double flops, s4u::Host* host); + ExecTaskPtr set_host(s4u::Host* host); + s4u::Host* get_host() const { return host_; } + ExecTaskPtr set_flops(double flops); + double get_flops() const { return get_amount(); } + friend void inline intrusive_ptr_release(ExecTask* e) { intrusive_ptr_release(static_cast(e)); } + friend void inline intrusive_ptr_add_ref(ExecTask* e) { intrusive_ptr_add_ref(static_cast(e)); } +}; + +class CommTask : public Task { + s4u::Host* source_; + s4u::Host* destination_; + + explicit CommTask(const std::string& name); + void fire() override; + +public: + static CommTaskPtr init(const std::string& name); + static CommTaskPtr init(const std::string& name, double bytes, s4u::Host* source, s4u::Host* destination); + CommTaskPtr set_source(s4u::Host* source); + s4u::Host* get_source() const { return source_; } + CommTaskPtr set_destination(s4u::Host* destination); + s4u::Host* get_destination() const { return destination_; } + CommTaskPtr set_bytes(double bytes); + double get_bytes() const { return get_amount(); } + friend void inline intrusive_ptr_release(CommTask* c) { intrusive_ptr_release(static_cast(c)); } + friend void inline intrusive_ptr_add_ref(CommTask* c) { intrusive_ptr_add_ref(static_cast(c)); } +}; + +class IoTask : public Task { + s4u::Disk* disk_; + s4u::Io::OpType type_; + explicit IoTask(const std::string& name); + void fire() override; + +public: + static IoTaskPtr init(const std::string& name); + static IoTaskPtr init(const std::string& name, double bytes, s4u::Disk* disk, s4u::Io::OpType type); + IoTaskPtr set_disk(s4u::Disk* disk); + s4u::Disk* get_disk() const { return disk_; } + IoTaskPtr set_bytes(double bytes); + double get_bytes() { return get_amount(); } + IoTaskPtr set_op_type(s4u::Io::OpType type); + s4u::Io::OpType get_op_type() { return type_; } + + friend void inline intrusive_ptr_release(IoTask* i) { intrusive_ptr_release(static_cast(i)); } + friend void inline intrusive_ptr_add_ref(IoTask* i) { intrusive_ptr_add_ref(static_cast(i)); } +}; +} // namespace simgrid::plugins +#endif diff --git a/src/bindings/python/simgrid_python.cpp b/src/bindings/python/simgrid_python.cpp index 0b7fd840bb..a89056d97a 100644 --- a/src/bindings/python/simgrid_python.cpp +++ b/src/bindings/python/simgrid_python.cpp @@ -11,7 +11,7 @@ #include "simgrid/kernel/ProfileBuilder.hpp" #include "simgrid/kernel/routing/NetPoint.hpp" #include -#include +#include #include #include #include @@ -33,14 +33,14 @@ #include namespace py = pybind11; -using simgrid::plugins::CommOp; -using simgrid::plugins::CommOpPtr; -using simgrid::plugins::ExecOp; -using simgrid::plugins::ExecOpPtr; -using simgrid::plugins::IoOp; -using simgrid::plugins::IoOpPtr; -using simgrid::plugins::Operation; -using simgrid::plugins::OperationPtr; +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::Actor; using simgrid::s4u::ActorPtr; using simgrid::s4u::Barrier; @@ -919,92 +919,90 @@ PYBIND11_MODULE(simgrid, m) .value("READ", simgrid::s4u::Io::OpType::READ) .value("WRITE", simgrid::s4u::Io::OpType::WRITE); - /* Class Operation */ - py::class_(m, "Operation", "Operation. See the C++ documentation for details.") - .def_static("init", &Operation::init) + /* Class Task */ + py::class_(m, "Task", "Task. See the C++ documentation for details.") + .def_static("init", &Task::init) .def_static( "on_start_cb", [](py::object cb) { cb.inc_ref(); // keep alive after return const py::gil_scoped_release gil_release; - Operation::on_start_cb([cb](Operation* op) { + Task::on_start_cb([cb](Task* op) { const py::gil_scoped_acquire py_context; // need a new context for callback py::reinterpret_borrow(cb.ptr())(op); }); }, - "Add a callback called when each operation starts.") + "Add a callback called when each task starts.") .def_static( "on_end_cb", [](py::object cb) { cb.inc_ref(); // keep alive after return const py::gil_scoped_release gil_release; - Operation::on_end_cb([cb](Operation* op) { + Task::on_end_cb([cb](Task* op) { const py::gil_scoped_acquire py_context; // need a new context for callback py::reinterpret_borrow(cb.ptr())(op); }); }, - "Add a callback called when each operation ends.") - .def_property_readonly("name", &Operation::get_name, "The name of this operation (read-only).") - .def_property_readonly("count", &Operation::get_count, "The execution count of this operation (read-only).") - .def_property_readonly("successors", &Operation::get_successors, "The successors of this operation (read-only).") - .def_property("amount", &Operation::get_amount, &Operation::set_amount, - "The amount of work to do for this operation.") - .def("enqueue_execs", py::overload_cast(&Operation::enqueue_execs), py::call_guard(), - py::arg("n"), "Enqueue executions for this operation.") - .def("add_successor", py::overload_cast(&Operation::add_successor), - py::call_guard(), py::arg("op"), "Add a successor to this operation.") - .def("remove_successor", py::overload_cast(&Operation::remove_successor), - py::call_guard(), py::arg("op"), "Remove a successor of this operation.") - .def("remove_all_successors", &Operation::remove_all_successors, py::call_guard(), - "Remove all successors of this operation.") - .def("on_this_start", py::overload_cast&>(&Operation::on_this_start), - py::arg("func"), "Add a callback called when this operation starts.") - .def("on_this_end", py::overload_cast&>(&Operation::on_this_end), - py::arg("func"), "Add a callback called when this operation ends.") + "Add a callback called when each task ends.") + .def_property_readonly("name", &Task::get_name, "The name of this task (read-only).") + .def_property_readonly("count", &Task::get_count, "The execution count of this task (read-only).") + .def_property_readonly("successors", &Task::get_successors, "The successors of this task (read-only).") + .def_property("amount", &Task::get_amount, &Task::set_amount, "The amount of work to do for this task.") + .def("enqueue_execs", py::overload_cast(&Task::enqueue_execs), py::call_guard(), + py::arg("n"), "Enqueue executions for this task.") + .def("add_successor", py::overload_cast(&Task::add_successor), py::call_guard(), + py::arg("op"), "Add a successor to this task.") + .def("remove_successor", py::overload_cast(&Task::remove_successor), + py::call_guard(), py::arg("op"), "Remove a successor of this task.") + .def("remove_all_successors", &Task::remove_all_successors, py::call_guard(), + "Remove all successors of this task.") + .def("on_this_start", py::overload_cast&>(&Task::on_this_start), py::arg("func"), + "Add a callback called when this task starts.") + .def("on_this_end", py::overload_cast&>(&Task::on_this_end), py::arg("func"), + "Add a callback called when this task ends.") .def( - "__repr__", [](const OperationPtr op) { return "Operation(" + op->get_name() + ")"; }, - "Textual representation of the Operation"); - - /* Class CommOp */ - py::class_(m, "CommOp", - "Communication Operation. See the C++ documentation for details.") - .def_static("init", py::overload_cast(&CommOp::init), - py::call_guard(), py::arg("name"), "CommOp constructor") - .def_static("init", py::overload_cast(&CommOp::init), + "__repr__", [](const TaskPtr op) { return "Task(" + op->get_name() + ")"; }, + "Textual representation of the Task"); + + /* Class CommTask */ + py::class_(m, "CommTask", "Communication Task. See the C++ documentation for details.") + .def_static("init", py::overload_cast(&CommTask::init), + py::call_guard(), py::arg("name"), "CommTask constructor") + .def_static("init", py::overload_cast(&CommTask::init), py::call_guard(), py::arg("name"), py::arg("bytes"), py::arg("source"), - py::arg("destination"), "CommOp constructor") - .def_property("source", &CommOp::get_source, &CommOp::set_source, "The source of the communication.") - .def_property("destination", &CommOp::get_destination, &CommOp::set_destination, + py::arg("destination"), "CommTask constructor") + .def_property("source", &CommTask::get_source, &CommTask::set_source, "The source of the communication.") + .def_property("destination", &CommTask::get_destination, &CommTask::set_destination, "The destination of the communication.") - .def_property("bytes", &CommOp::get_bytes, &CommOp::set_bytes, "The amount of bytes to send.") + .def_property("bytes", &CommTask::get_bytes, &CommTask::set_bytes, "The amount of bytes to send.") .def( - "__repr__", [](const CommOpPtr c) { return "CommOp(" + c->get_name() + ")"; }, - "Textual representation of the CommOp"); - - /* Class ExecOp */ - py::class_(m, "ExecOp", "Execution Operation. See the C++ documentation for details.") - .def_static("init", py::overload_cast(&ExecOp::init), - py::call_guard(), py::arg("name"), "ExecOp constructor") - .def_static("init", py::overload_cast(&ExecOp::init), + "__repr__", [](const CommTaskPtr c) { return "CommTask(" + c->get_name() + ")"; }, + "Textual representation of the CommTask"); + + /* Class ExecTask */ + py::class_(m, "ExecTask", "Execution Task. See the C++ documentation for details.") + .def_static("init", py::overload_cast(&ExecTask::init), + py::call_guard(), py::arg("name"), "ExecTask constructor") + .def_static("init", py::overload_cast(&ExecTask::init), py::call_guard(), py::arg("name"), py::arg("flops"), py::arg("host"), - "CommOp constructor.") - .def_property("host", &ExecOp::get_host, &ExecOp::set_host, "The host of the execution.") - .def_property("flops", &ExecOp::get_flops, &ExecOp::set_flops, "The amount of flops to execute.") + "CommTask constructor.") + .def_property("host", &ExecTask::get_host, &ExecTask::set_host, "The host of the execution.") + .def_property("flops", &ExecTask::get_flops, &ExecTask::set_flops, "The amount of flops to execute.") .def( - "__repr__", [](const ExecOpPtr e) { return "ExecOp(" + e->get_name() + ")"; }, - "Textual representation of the ExecOp"); - - /* Class IoOp */ - py::class_(m, "IoOp", "IO Operation. See the C++ documentation for details.") - .def_static("init", py::overload_cast(&IoOp::init), py::call_guard(), - py::arg("name"), "IoOp constructor") - .def_static("init", py::overload_cast(&IoOp::init), + "__repr__", [](const ExecTaskPtr e) { return "ExecTask(" + e->get_name() + ")"; }, + "Textual representation of the ExecTask"); + + /* Class IoTask */ + py::class_(m, "IoTask", "IO Task. See the C++ documentation for details.") + .def_static("init", py::overload_cast(&IoTask::init), + py::call_guard(), py::arg("name"), "IoTask constructor") + .def_static("init", py::overload_cast(&IoTask::init), py::call_guard(), py::arg("name"), py::arg("bytes"), py::arg("disk"), - py::arg("type"), "IoOp constructor.") - .def_property("disk", &IoOp::get_disk, &IoOp::set_disk, "The disk of the IO.") - .def_property("bytes", &IoOp::get_bytes, &IoOp::set_bytes, "The amount of bytes to process.") - .def_property("type", &IoOp::get_bytes, &IoOp::set_bytes, "The type of IO.") + py::arg("type"), "IoTask constructor.") + .def_property("disk", &IoTask::get_disk, &IoTask::set_disk, "The disk of the IO.") + .def_property("bytes", &IoTask::get_bytes, &IoTask::set_bytes, "The amount of bytes to process.") + .def_property("type", &IoTask::get_bytes, &IoTask::set_bytes, "The type of IO.") .def( - "__repr__", [](const IoOpPtr io) { return "IoOp(" + io->get_name() + ")"; }, - "Textual representation of the IoOp"); + "__repr__", [](const IoTaskPtr io) { return "IoTask(" + io->get_name() + ")"; }, + "Textual representation of the IoTask"); } diff --git a/src/plugins/operation.cpp b/src/plugins/task.cpp similarity index 55% rename from src/plugins/operation.cpp rename to src/plugins/task.cpp index 689bd0ce4c..f0bf5b161d 100644 --- a/src/plugins/operation.cpp +++ b/src/plugins/task.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -7,68 +7,68 @@ #include "src/simgrid/module.hpp" -SIMGRID_REGISTER_PLUGIN(operation, "Battery management", nullptr) -/** @defgroup plugin_operation plugin_operation Plugin Operation +SIMGRID_REGISTER_PLUGIN(task, "Battery management", nullptr) +/** @defgroup plugin_task plugin_task Plugin Task @beginrst -This is the operation plugin, enabling management of Operations. -To activate this plugin, first call :cpp:func:`Operation::init`. +This is the task plugin, enabling management of Tasks. +To activate this plugin, first call :cpp:func:`Task::init`. -Operations are designed to represent workflows, i.e, graphs of Operations. -Operations can only be instancied using either -:cpp:func:`simgrid::plugins::ExecOp::init` or :cpp:func:`simgrid::plugins::CommOp::init` -An ExecOp is an Execution Operation. Its underlying Activity is an :ref:`Exec `. -A CommOp is a Communication Operation. Its underlying Activity is a :ref:`Comm `. +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` +An ExecTask is an Execution Task. Its underlying Activity is an :ref:`Exec `. +A CommTask is a Communication Task. Its underlying Activity is a :ref:`Comm `. @endrst */ -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(Operation, kernel, "Logging specific to the operation plugin"); +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(Task, kernel, "Logging specific to the task plugin"); namespace simgrid::plugins { -xbt::signal Operation::on_start; -xbt::signal Operation::on_end; +xbt::signal Task::on_start; +xbt::signal Task::on_end; -Operation::Operation(const std::string& name) : name_(name) {} +Task::Task(const std::string& name) : name_(name) {} /** - * @param predecessor The Operation to add. - * @brief Add a predecessor to this Operation. + * @param predecessor The Task to add. + * @brief Add a predecessor to this Task. */ -void Operation::add_predecessor(Operation* predecessor) +void Task::add_predecessor(Task* predecessor) { if (predecessors_.find(predecessor) == predecessors_.end()) simgrid::kernel::actor::simcall_answered([this, predecessor] { predecessors_[predecessor] = 0; }); } /** - * @param predecessor The Operation to remove. - * @brief Remove a predecessor from this Operation. + * @param predecessor The Task to remove. + * @brief Remove a predecessor from this Task. */ -void Operation::remove_predecessor(Operation* predecessor) +void Task::remove_predecessor(Task* predecessor) { simgrid::kernel::actor::simcall_answered([this, predecessor] { predecessors_.erase(predecessor); }); } /** - * @brief Return True if the Operation can start a new Activity. - * @note The Operation is ready if not already doing something and there is at least one execution waiting in queue. + * @brief Return True if the Task can start a new Activity. + * @note The Task is ready if not already doing something and there is at least one execution waiting in queue. */ -bool Operation::ready_to_run() const +bool Task::ready_to_run() const { return not working_ && queued_execs_ > 0; } /** * @param source The sender. - * @brief Receive a token from another Operation. - * @note Check upon reception if the Operation has received a token from each of its predecessors, + * @brief Receive a token from another Task. + * @note Check upon reception if the Task has received a token from each of its predecessors, * and in this case consumes those tokens and enqueue an execution. */ -void Operation::receive(Operation* source) +void Task::receive(Task* source) { - XBT_DEBUG("Operation %s received a token from %s", name_.c_str(), source->name_.c_str()); + XBT_DEBUG("Task %s received a token from %s", name_.c_str(), source->name_.c_str()); auto it = predecessors_.find(source); simgrid::kernel::actor::simcall_answered([this, it] { it->second++; @@ -87,7 +87,7 @@ void Operation::receive(Operation* source) } /** - * @brief Operation routine when finishing an execution. + * @brief Task routine when finishing an execution. * @note Set its working status as false. * Add 1 to its count of finished executions. * Call the on_this_end func. @@ -95,7 +95,7 @@ void Operation::receive(Operation* source) * Send a token to each of its successors. * Start a new execution if possible. */ -void Operation::complete() +void Task::complete() { simgrid::kernel::actor::simcall_answered([this] { working_ = false; @@ -103,81 +103,78 @@ void Operation::complete() }); for (auto end_func : end_func_handlers_) end_func(this); - Operation::on_end(this); - for (auto const& op : successors_) - op->receive(this); + Task::on_end(this); + for (auto const& t : successors_) + t->receive(this); if (ready_to_run()) - execute(); + fire(); } -/** @ingroup plugin_operation - * @brief Init the Operation plugin. - * @note Add a completion callback to all Activities to call Operation::complete(). +/** @ingroup plugin_task + * @brief Init the Task plugin. + * @note Add a completion callback to all Activities to call Task::complete(). */ -void Operation::init() +void Task::init() { - if (Operation::inited_) + if (Task::inited_) return; - Operation::inited_ = true; + Task::inited_ = true; ExtendedAttributeActivity::EXTENSION_ID = simgrid::s4u::Activity::extension_create(); - simgrid::s4u::Exec::on_completion_cb([](simgrid::s4u::Exec const& exec) { - exec.extension()->operation_->complete(); - }); - simgrid::s4u::Comm::on_completion_cb([](simgrid::s4u::Comm const& comm) { - comm.extension()->operation_->complete(); - }); - simgrid::s4u::Io::on_completion_cb([](simgrid::s4u::Io const& io) { - io.extension()->operation_->complete(); - }); + simgrid::s4u::Exec::on_completion_cb( + [](simgrid::s4u::Exec const& exec) { exec.extension()->task_->complete(); }); + simgrid::s4u::Comm::on_completion_cb( + [](simgrid::s4u::Comm const& comm) { comm.extension()->task_->complete(); }); + simgrid::s4u::Io::on_completion_cb( + [](simgrid::s4u::Io const& io) { io.extension()->task_->complete(); }); } -/** @ingroup plugin_operation +/** @ingroup plugin_task * @param n The number of executions to enqueue. * @brief Enqueue executions. * @note Immediatly starts an execution if possible. */ -void Operation::enqueue_execs(int n) +void Task::enqueue_execs(int n) { simgrid::kernel::actor::simcall_answered([this, n] { queued_execs_ += n; if (ready_to_run()) - execute(); + fire(); }); } -/** @ingroup plugin_operation +/** @ingroup plugin_task * @param amount The amount to set. * @brief Set the amout of work to do. - * @note Amount in flop for ExecOp and in bytes for CommOp. + * @note Amount in flop for ExecTask and in bytes for CommTask. */ -void Operation::set_amount(double amount) +void Task::set_amount(double amount) { simgrid::kernel::actor::simcall_answered([this, amount] { amount_ = amount; }); } -/** @ingroup plugin_operation - * @param successor The Operation to add. - * @brief Add a successor to this Operation. +/** @ingroup plugin_task + * @param successor The Task to add. + * @brief Add a successor to this Task. * @note It also adds this as a predecessor of successor. */ -void Operation::add_successor(OperationPtr successor) +void Task::add_successor(TaskPtr successor) { simgrid::kernel::actor::simcall_answered([this, successor] { successors_.insert(successor.get()); }); successor->add_predecessor(this); } -/** @ingroup plugin_operation - * @param successor The Operation to remove. - * @brief Remove a successor from this Operation. +/** @ingroup plugin_task + * @param successor The Task to remove. + * @brief Remove a successor from this Task. * @note It also remove this from the predecessors of successor. */ -void Operation::remove_successor(OperationPtr successor) +void Task::remove_successor(TaskPtr successor) { simgrid::kernel::actor::simcall_answered([this, successor] { successors_.erase(successor.get()); }); successor->remove_predecessor(this); } -void Operation::remove_all_successors() +void Task::remove_all_successors() { simgrid::kernel::actor::simcall_answered([this] { while (not successors_.empty()) { @@ -188,30 +185,30 @@ void Operation::remove_all_successors() }); } -/** @ingroup plugin_operation +/** @ingroup plugin_task * @param func The function to set. * @brief Set a function to be called before each execution. * @note The function is called before the underlying Activity starts. */ -void Operation::on_this_start(const std::function& func) +void Task::on_this_start(const std::function& func) { simgrid::kernel::actor::simcall_answered([this, &func] { start_func_handlers_.push_back(func); }); } -/** @ingroup plugin_operation +/** @ingroup plugin_task * @param func The function to set. * @brief Set a function to be called after each execution. * @note The function is called after the underlying Activity ends, but before sending tokens to successors. */ -void Operation::on_this_end(const std::function& func) +void Task::on_this_end(const std::function& func) { simgrid::kernel::actor::simcall_answered([this, &func] { end_func_handlers_.push_back(func); }); } -/** @ingroup plugin_operation +/** @ingroup plugin_task * @brief Return the number of completed executions. */ -int Operation::get_count() const +int Task::get_count() const { return count_; } @@ -219,34 +216,34 @@ int Operation::get_count() const /** * @brief Default constructor. */ -ExecOp::ExecOp(const std::string& name) : Operation(name) {} +ExecTask::ExecTask(const std::string& name) : Task(name) {} -/** @ingroup plugin_operation +/** @ingroup plugin_task * @brief Smart Constructor. */ -ExecOpPtr ExecOp::init(const std::string& name) +ExecTaskPtr ExecTask::init(const std::string& name) { - return ExecOpPtr(new ExecOp(name)); + return ExecTaskPtr(new ExecTask(name)); } -/** @ingroup plugin_operation +/** @ingroup plugin_task * @brief Smart Constructor. */ -ExecOpPtr ExecOp::init(const std::string& name, double flops, s4u::Host* host) +ExecTaskPtr ExecTask::init(const std::string& name, double flops, s4u::Host* host) { return init(name)->set_flops(flops)->set_host(host); } /** - * @brief Do one execution of the Operation. + * @brief Do one execution of the Task. * @note Call the on_this_start() func. Set its working status as true. * Init and start the underlying Activity. */ -void ExecOp::execute() +void ExecTask::fire() { for (auto start_func : start_func_handlers_) start_func(this); - Operation::on_start(this); + Task::on_start(this); kernel::actor::simcall_answered([this] { working_ = true; queued_execs_ = std::max(queued_execs_ - 1, 0); @@ -257,24 +254,24 @@ void ExecOp::execute() exec->set_host(host_); exec->start(); exec->extension_set(new ExtendedAttributeActivity()); - exec->extension()->operation_ = this; + exec->extension()->task_ = this; kernel::actor::simcall_answered([this, exec] { current_activity_ = exec; }); } -/** @ingroup plugin_operation +/** @ingroup plugin_task * @param host The host to set. * @brief Set a new host. */ -ExecOpPtr ExecOp::set_host(s4u::Host* host) +ExecTaskPtr ExecTask::set_host(s4u::Host* host) { kernel::actor::simcall_answered([this, host] { host_ = host; }); return this; } -/** @ingroup plugin_operation +/** @ingroup plugin_task * @param flops The amount of flops to set. */ -ExecOpPtr ExecOp::set_flops(double flops) +ExecTaskPtr ExecTask::set_flops(double flops) { kernel::actor::simcall_answered([this, flops] { amount_ = flops; }); return this; @@ -283,35 +280,34 @@ ExecOpPtr ExecOp::set_flops(double flops) /** * @brief Default constructor. */ -CommOp::CommOp(const std::string& name) : Operation(name) {} +CommTask::CommTask(const std::string& name) : Task(name) {} -/** @ingroup plugin_operation +/** @ingroup plugin_task * @brief Smart constructor. */ -CommOpPtr CommOp::init(const std::string& name) +CommTaskPtr CommTask::init(const std::string& name) { - return CommOpPtr(new CommOp(name)); + return CommTaskPtr(new CommTask(name)); } -/** @ingroup plugin_operation +/** @ingroup plugin_task * @brief Smart constructor. */ -CommOpPtr CommOp::init(const std::string& name, double bytes, s4u::Host* source, - s4u::Host* destination) +CommTaskPtr CommTask::init(const std::string& name, double bytes, s4u::Host* source, s4u::Host* destination) { return init(name)->set_bytes(bytes)->set_source(source)->set_destination(destination); } /** - * @brief Do one execution of the Operation. + * @brief Do one execution of the Task. * @note Call the on_this_start() func. Set its working status as true. * Init and start the underlying Activity. */ -void CommOp::execute() +void CommTask::fire() { for (auto start_func : start_func_handlers_) start_func(this); - Operation::on_start(this); + Task::on_start(this); kernel::actor::simcall_answered([this] { working_ = true; queued_execs_ = std::max(queued_execs_ - 1, 0); @@ -321,34 +317,34 @@ void CommOp::execute() comm->set_payload_size(amount_); comm->start(); comm->extension_set(new ExtendedAttributeActivity()); - comm->extension()->operation_ = this; + comm->extension()->task_ = this; kernel::actor::simcall_answered([this, comm] { current_activity_ = comm; }); } -/** @ingroup plugin_operation +/** @ingroup plugin_task * @param source The host to set. * @brief Set a new source host. */ -CommOpPtr CommOp::set_source(s4u::Host* source) +CommTaskPtr CommTask::set_source(s4u::Host* source) { kernel::actor::simcall_answered([this, source] { source_ = source; }); return this; } -/** @ingroup plugin_operation +/** @ingroup plugin_task * @param destination The host to set. * @brief Set a new destination host. */ -CommOpPtr CommOp::set_destination(s4u::Host* destination) +CommTaskPtr CommTask::set_destination(s4u::Host* destination) { kernel::actor::simcall_answered([this, destination] { destination_ = destination; }); return this; } -/** @ingroup plugin_operation +/** @ingroup plugin_task * @param bytes The amount of bytes to set. */ -CommOpPtr CommOp::set_bytes(double bytes) +CommTaskPtr CommTask::set_bytes(double bytes) { kernel::actor::simcall_answered([this, bytes] { amount_ = bytes; }); return this; @@ -357,55 +353,55 @@ CommOpPtr CommOp::set_bytes(double bytes) /** * @brief Default constructor. */ -IoOp::IoOp(const std::string& name) : Operation(name) {} +IoTask::IoTask(const std::string& name) : Task(name) {} -/** @ingroup plugin_operation +/** @ingroup plugin_task * @brief Smart Constructor. */ -IoOpPtr IoOp::init(const std::string& name) +IoTaskPtr IoTask::init(const std::string& name) { - return IoOpPtr(new IoOp(name)); + return IoTaskPtr(new IoTask(name)); } -/** @ingroup plugin_operation +/** @ingroup plugin_task * @brief Smart Constructor. */ -IoOpPtr IoOp::init(const std::string& name, double bytes, s4u::Disk* disk, s4u::Io::OpType type) +IoTaskPtr IoTask::init(const std::string& name, double bytes, s4u::Disk* disk, s4u::Io::OpType type) { return init(name)->set_bytes(bytes)->set_disk(disk)->set_op_type(type); } -/** @ingroup plugin_operation +/** @ingroup plugin_task * @param disk The disk to set. * @brief Set a new disk. */ -IoOpPtr IoOp::set_disk(s4u::Disk* disk) +IoTaskPtr IoTask::set_disk(s4u::Disk* disk) { kernel::actor::simcall_answered([this, disk] { disk_ = disk; }); return this; } -/** @ingroup plugin_operation +/** @ingroup plugin_task * @param bytes The amount of bytes to set. */ -IoOpPtr IoOp::set_bytes(double bytes) +IoTaskPtr IoTask::set_bytes(double bytes) { kernel::actor::simcall_answered([this, bytes] { amount_ = bytes; }); return this; } -/** @ingroup plugin_operation */ -IoOpPtr IoOp::set_op_type(s4u::Io::OpType type) +/** @ingroup plugin_task */ +IoTaskPtr IoTask::set_op_type(s4u::Io::OpType type) { kernel::actor::simcall_answered([this, type] { type_ = type; }); return this; } -void IoOp::execute() +void IoTask::fire() { for (auto start_func : start_func_handlers_) start_func(this); - Operation::on_start(this); + Task::on_start(this); kernel::actor::simcall_answered([this] { working_ = true; queued_execs_ = std::max(queued_execs_ - 1, 0); @@ -417,13 +413,12 @@ void IoOp::execute() io->set_op_type(type_); io->start(); io->extension_set(new ExtendedAttributeActivity()); - io->extension()->operation_ = this; + io->extension()->task_ = this; kernel::actor::simcall_answered([this, io] { current_activity_ = io; }); } - } // namespace simgrid::plugins simgrid::xbt::Extension simgrid::plugins::ExtendedAttributeActivity::EXTENSION_ID; -bool simgrid::plugins::Operation::inited_ = false; +bool simgrid::plugins::Task::inited_ = false; diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index d6d2a5b7bd..f2b1bb00f1 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -454,7 +454,7 @@ set(PLUGINS_SRC src/plugins/vm/VmLiveMigration.hpp src/plugins/vm/dirty_page_tracking.cpp src/plugins/battery.cpp - src/plugins/operation.cpp + src/plugins/task.cpp src/plugins/photovoltaic.cpp ) @@ -646,7 +646,7 @@ set(headers_to_install include/simgrid/plugins/file_system.h include/simgrid/plugins/live_migration.h include/simgrid/plugins/load.h - include/simgrid/plugins/operation.hpp + include/simgrid/plugins/task.hpp include/simgrid/plugins/photovoltaic.hpp include/simgrid/plugins/ProducerConsumer.hpp include/simgrid/instr.h