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.
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
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
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
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
.. doxygengroup:: plugin_battery
-.. _plugin_operation:
+.. _plugin_task:
-Operation
+Task
===========
-.. doxygengroup:: plugin_operation
+.. doxygengroup:: plugin_task
.. _plugin_photovoltaic:
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
+++ /dev/null
-/* 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/file_system.h>
-#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;
-}
+++ /dev/null
-#!/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)
+++ /dev/null
-/* 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;
-}
+++ /dev/null
-#!/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)
+++ /dev/null
-#!/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
+++ /dev/null
-#!/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)
--- /dev/null
+/* 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 <simgrid/plugins/file_system.h>
+
+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;
+}
--- /dev/null
+#!/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)
--- /dev/null
+/* 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;
+}
--- /dev/null
+#!/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)
/* 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.
* 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<simgrid::plugins::CommOp*>(op);
+ comm0->on_this_start([exec1, exec2, jupiter, fafard](simgrid::plugins::Task* t) {
+ auto* comm0 = dynamic_cast<simgrid::plugins::CommTask*>(t);
static int count = 0;
if (count % 2 == 0) {
comm0->set_destination(jupiter);
count++;
});
- // Enqueue four executions for operation comm0
+ // Enqueue four executions for task comm0
comm0->enqueue_execs(4);
// Start the simulation
--- /dev/null
+#!/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
/* 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);
}
}
{
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
--- /dev/null
+#!/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)
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)
+++ /dev/null
-#!/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)
-
+++ /dev/null
-#!/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)
+++ /dev/null
-#!/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)
+++ /dev/null
-#!/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)
-
-
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()
)
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
--- /dev/null
+#!/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)
+
# 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()
)
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
--- /dev/null
+#!/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)
# 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.
from argparse import ArgumentParser
import sys
-from simgrid import Engine, Operation, CommOp, ExecOp
+from simgrid import Engine, Task, CommTask, ExecTask
def parse():
parser = ArgumentParser()
)
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
--- /dev/null
+#!/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)
# 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()
)
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)
--- /dev/null
+#!/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)
+
+
+++ /dev/null
-#ifndef SIMGRID_PLUGINS_OPERATION_H_
-#define SIMGRID_PLUGINS_OPERATION_H_
-
-#include <simgrid/s4u/Activity.hpp>
-#include <simgrid/s4u/Io.hpp>
-#include <xbt/Extendable.hpp>
-
-#include <atomic>
-#include <map>
-#include <memory>
-#include <set>
-
-namespace simgrid::plugins {
-
-class Operation;
-using OperationPtr = boost::intrusive_ptr<Operation>;
-XBT_PUBLIC void intrusive_ptr_release(Operation* o);
-XBT_PUBLIC void intrusive_ptr_add_ref(Operation* o);
-class ExecOp;
-using ExecOpPtr = boost::intrusive_ptr<ExecOp>;
-XBT_PUBLIC void intrusive_ptr_release(ExecOp* e);
-XBT_PUBLIC void intrusive_ptr_add_ref(ExecOp* e);
-class CommOp;
-using CommOpPtr = boost::intrusive_ptr<CommOp>;
-XBT_PUBLIC void intrusive_ptr_release(CommOp* c);
-XBT_PUBLIC void intrusive_ptr_add_ref(CommOp* c);
-class IoOp;
-using IoOpPtr = boost::intrusive_ptr<IoOp>;
-XBT_PUBLIC void intrusive_ptr_release(IoOp* i);
-XBT_PUBLIC void intrusive_ptr_add_ref(IoOp* i);
-
-struct ExtendedAttributeActivity {
- static simgrid::xbt::Extension<simgrid::s4u::Activity, ExtendedAttributeActivity> EXTENSION_ID;
- Operation* operation_;
-};
-
-class Operation {
- static bool inited_;
- std::set<Operation*> successors_ = {};
- std::map<Operation*, unsigned int> 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<std::function<void(Operation*)>> end_func_handlers_;
- std::vector<std::function<void(Operation*)>> start_func_handlers_;
- explicit Operation(const std::string& name);
- virtual ~Operation() = default;
- virtual void execute() = 0;
-
- static xbt::signal<void(Operation*)> on_start;
- static xbt::signal<void(Operation*)> 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<Operation*>& get_successors() const { return successors_ ;}
- void on_this_start(const std::function<void(Operation*)>& func);
- void on_this_end(const std::function<void(Operation*)>& 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<void(Operation*)>& 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<void(Operation*)>& 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<Operation*>(e)); }
- friend void inline intrusive_ptr_add_ref(ExecOp* e) { intrusive_ptr_add_ref(static_cast<Operation*>(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<Operation*>(c)); }
- friend void inline intrusive_ptr_add_ref(CommOp* c) { intrusive_ptr_add_ref(static_cast<Operation*>(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<Operation*>(i)); }
- friend void inline intrusive_ptr_add_ref(IoOp* i) { intrusive_ptr_add_ref(static_cast<Operation*>(i)); }
-};
-} // namespace simgrid::plugins
-#endif
--- /dev/null
+#ifndef SIMGRID_PLUGINS_TASK_H_
+#define SIMGRID_PLUGINS_TASK_H_
+
+#include <simgrid/s4u/Activity.hpp>
+#include <simgrid/s4u/Io.hpp>
+#include <xbt/Extendable.hpp>
+
+#include <atomic>
+#include <map>
+#include <memory>
+#include <set>
+
+namespace simgrid::plugins {
+
+class Task;
+using TaskPtr = boost::intrusive_ptr<Task>;
+XBT_PUBLIC void intrusive_ptr_release(Task* o);
+XBT_PUBLIC void intrusive_ptr_add_ref(Task* o);
+class ExecTask;
+using ExecTaskPtr = boost::intrusive_ptr<ExecTask>;
+XBT_PUBLIC void intrusive_ptr_release(ExecTask* e);
+XBT_PUBLIC void intrusive_ptr_add_ref(ExecTask* e);
+class CommTask;
+using CommTaskPtr = boost::intrusive_ptr<CommTask>;
+XBT_PUBLIC void intrusive_ptr_release(CommTask* c);
+XBT_PUBLIC void intrusive_ptr_add_ref(CommTask* c);
+class IoTask;
+using IoTaskPtr = boost::intrusive_ptr<IoTask>;
+XBT_PUBLIC void intrusive_ptr_release(IoTask* i);
+XBT_PUBLIC void intrusive_ptr_add_ref(IoTask* i);
+
+struct ExtendedAttributeActivity {
+ static simgrid::xbt::Extension<simgrid::s4u::Activity, ExtendedAttributeActivity> EXTENSION_ID;
+ Task* task_;
+};
+
+class Task {
+ static bool inited_;
+ std::set<Task*> successors_ = {};
+ std::map<Task*, unsigned int> 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<std::function<void(Task*)>> end_func_handlers_;
+ std::vector<std::function<void(Task*)>> start_func_handlers_;
+ explicit Task(const std::string& name);
+ virtual ~Task() = default;
+ virtual void fire() = 0;
+
+ 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);
+ 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<Task*>& get_successors() const { return successors_; }
+ void on_this_start(const std::function<void(Task*)>& func);
+ void on_this_end(const std::function<void(Task*)>& 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<void(Task*)>& 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<void(Task*)>& 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<Task*>(e)); }
+ friend void inline intrusive_ptr_add_ref(ExecTask* e) { intrusive_ptr_add_ref(static_cast<Task*>(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<Task*>(c)); }
+ friend void inline intrusive_ptr_add_ref(CommTask* c) { intrusive_ptr_add_ref(static_cast<Task*>(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<Task*>(i)); }
+ friend void inline intrusive_ptr_add_ref(IoTask* i) { intrusive_ptr_add_ref(static_cast<Task*>(i)); }
+};
+} // namespace simgrid::plugins
+#endif
#include "simgrid/kernel/ProfileBuilder.hpp"
#include "simgrid/kernel/routing/NetPoint.hpp"
#include <simgrid/Exception.hpp>
-#include <simgrid/plugins/operation.hpp>
+#include <simgrid/plugins/task.hpp>
#include <simgrid/s4u/Actor.hpp>
#include <simgrid/s4u/Barrier.hpp>
#include <simgrid/s4u/Comm.hpp>
#include <vector>
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;
.value("READ", simgrid::s4u::Io::OpType::READ)
.value("WRITE", simgrid::s4u::Io::OpType::WRITE);
- /* Class Operation */
- py::class_<Operation, OperationPtr>(m, "Operation", "Operation. See the C++ documentation for details.")
- .def_static("init", &Operation::init)
+ /* 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) {
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<py::function>(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<py::function>(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<int>(&Operation::enqueue_execs), py::call_guard<py::gil_scoped_release>(),
- py::arg("n"), "Enqueue executions for this operation.")
- .def("add_successor", py::overload_cast<OperationPtr>(&Operation::add_successor),
- py::call_guard<py::gil_scoped_release>(), py::arg("op"), "Add a successor to this operation.")
- .def("remove_successor", py::overload_cast<OperationPtr>(&Operation::remove_successor),
- py::call_guard<py::gil_scoped_release>(), py::arg("op"), "Remove a successor of this operation.")
- .def("remove_all_successors", &Operation::remove_all_successors, py::call_guard<py::gil_scoped_release>(),
- "Remove all successors of this operation.")
- .def("on_this_start", py::overload_cast<const std::function<void(Operation*)>&>(&Operation::on_this_start),
- py::arg("func"), "Add a callback called when this operation starts.")
- .def("on_this_end", py::overload_cast<const std::function<void(Operation*)>&>(&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<int>(&Task::enqueue_execs), py::call_guard<py::gil_scoped_release>(),
+ py::arg("n"), "Enqueue executions for this task.")
+ .def("add_successor", py::overload_cast<TaskPtr>(&Task::add_successor), py::call_guard<py::gil_scoped_release>(),
+ py::arg("op"), "Add a successor to this task.")
+ .def("remove_successor", py::overload_cast<TaskPtr>(&Task::remove_successor),
+ py::call_guard<py::gil_scoped_release>(), py::arg("op"), "Remove a successor of this task.")
+ .def("remove_all_successors", &Task::remove_all_successors, py::call_guard<py::gil_scoped_release>(),
+ "Remove all successors of this task.")
+ .def("on_this_start", py::overload_cast<const std::function<void(Task*)>&>(&Task::on_this_start), py::arg("func"),
+ "Add a callback called when this task starts.")
+ .def("on_this_end", py::overload_cast<const std::function<void(Task*)>&>(&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_<CommOp, CommOpPtr, Operation>(m, "CommOp",
- "Communication Operation. See the C++ documentation for details.")
- .def_static("init", py::overload_cast<const std::string&>(&CommOp::init),
- py::call_guard<py::gil_scoped_release>(), py::arg("name"), "CommOp constructor")
- .def_static("init", py::overload_cast<const std::string&, double, Host*, Host*>(&CommOp::init),
+ "__repr__", [](const TaskPtr op) { return "Task(" + op->get_name() + ")"; },
+ "Textual representation of the Task");
+
+ /* Class CommTask */
+ py::class_<CommTask, CommTaskPtr, Task>(m, "CommTask", "Communication Task. See the C++ documentation for details.")
+ .def_static("init", py::overload_cast<const std::string&>(&CommTask::init),
+ py::call_guard<py::gil_scoped_release>(), py::arg("name"), "CommTask constructor")
+ .def_static("init", py::overload_cast<const std::string&, double, Host*, Host*>(&CommTask::init),
py::call_guard<py::gil_scoped_release>(), 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_<ExecOp, ExecOpPtr, Operation>(m, "ExecOp", "Execution Operation. See the C++ documentation for details.")
- .def_static("init", py::overload_cast<const std::string&>(&ExecOp::init),
- py::call_guard<py::gil_scoped_release>(), py::arg("name"), "ExecOp constructor")
- .def_static("init", py::overload_cast<const std::string&, double, Host*>(&ExecOp::init),
+ "__repr__", [](const CommTaskPtr c) { return "CommTask(" + c->get_name() + ")"; },
+ "Textual representation of the CommTask");
+
+ /* Class ExecTask */
+ py::class_<ExecTask, ExecTaskPtr, Task>(m, "ExecTask", "Execution Task. See the C++ documentation for details.")
+ .def_static("init", py::overload_cast<const std::string&>(&ExecTask::init),
+ py::call_guard<py::gil_scoped_release>(), py::arg("name"), "ExecTask constructor")
+ .def_static("init", py::overload_cast<const std::string&, double, Host*>(&ExecTask::init),
py::call_guard<py::gil_scoped_release>(), 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_<IoOp, IoOpPtr, Operation>(m, "IoOp", "IO Operation. See the C++ documentation for details.")
- .def_static("init", py::overload_cast<const std::string&>(&IoOp::init), py::call_guard<py::gil_scoped_release>(),
- py::arg("name"), "IoOp constructor")
- .def_static("init", py::overload_cast<const std::string&, double, Disk*, Io::OpType>(&IoOp::init),
+ "__repr__", [](const ExecTaskPtr e) { return "ExecTask(" + e->get_name() + ")"; },
+ "Textual representation of the ExecTask");
+
+ /* Class IoTask */
+ py::class_<IoTask, IoTaskPtr, Task>(m, "IoTask", "IO Task. See the C++ documentation for details.")
+ .def_static("init", py::overload_cast<const std::string&>(&IoTask::init),
+ py::call_guard<py::gil_scoped_release>(), py::arg("name"), "IoTask constructor")
+ .def_static("init", py::overload_cast<const std::string&, double, Disk*, Io::OpType>(&IoTask::init),
py::call_guard<py::gil_scoped_release>(), 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");
}
#include <simgrid/Exception.hpp>
-#include <simgrid/plugins/operation.hpp>
+#include <simgrid/plugins/task.hpp>
#include <simgrid/s4u/Comm.hpp>
#include <simgrid/s4u/Exec.hpp>
#include <simgrid/s4u/Io.hpp>
#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 <API_s4u_Exec>`.
-A CommOp is a Communication Operation. Its underlying Activity is a :ref:`Comm <API_s4u_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 <API_s4u_Exec>`.
+A CommTask is a Communication Task. Its underlying Activity is a :ref:`Comm <API_s4u_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<void(Operation*)> Operation::on_start;
-xbt::signal<void(Operation*)> Operation::on_end;
+xbt::signal<void(Task*)> Task::on_start;
+xbt::signal<void(Task*)> 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++;
}
/**
- * @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.
* 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;
});
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<ExtendedAttributeActivity>();
- simgrid::s4u::Exec::on_completion_cb([](simgrid::s4u::Exec const& exec) {
- exec.extension<ExtendedAttributeActivity>()->operation_->complete();
- });
- simgrid::s4u::Comm::on_completion_cb([](simgrid::s4u::Comm const& comm) {
- comm.extension<ExtendedAttributeActivity>()->operation_->complete();
- });
- simgrid::s4u::Io::on_completion_cb([](simgrid::s4u::Io const& io) {
- io.extension<ExtendedAttributeActivity>()->operation_->complete();
- });
+ 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_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()) {
});
}
-/** @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<void(Operation*)>& func)
+void Task::on_this_start(const std::function<void(Task*)>& 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<void(Operation*)>& func)
+void Task::on_this_end(const std::function<void(Task*)>& 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_;
}
/**
* @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);
exec->set_host(host_);
exec->start();
exec->extension_set(new ExtendedAttributeActivity());
- exec->extension<ExtendedAttributeActivity>()->operation_ = this;
+ exec->extension<ExtendedAttributeActivity>()->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;
/**
* @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);
comm->set_payload_size(amount_);
comm->start();
comm->extension_set(new ExtendedAttributeActivity());
- comm->extension<ExtendedAttributeActivity>()->operation_ = this;
+ comm->extension<ExtendedAttributeActivity>()->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;
/**
* @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);
io->set_op_type(type_);
io->start();
io->extension_set(new ExtendedAttributeActivity());
- io->extension<ExtendedAttributeActivity>()->operation_ = this;
+ io->extension<ExtendedAttributeActivity>()->task_ = this;
kernel::actor::simcall_answered([this, io] { current_activity_ = io; });
}
-
} // namespace simgrid::plugins
simgrid::xbt::Extension<simgrid::s4u::Activity, simgrid::plugins::ExtendedAttributeActivity>
simgrid::plugins::ExtendedAttributeActivity::EXTENSION_ID;
-bool simgrid::plugins::Operation::inited_ = false;
+bool simgrid::plugins::Task::inited_ = false;
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
)
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