From 12ef73b3c1b6ef7bb9f2cf8031edf5e99e6c27a1 Mon Sep 17 00:00:00 2001 From: Fred Suter Date: Wed, 21 Jun 2023 14:54:17 -0400 Subject: [PATCH] rename enqueue_execs into enqueue_firings --- examples/cpp/task-io/s4u-task-io.cpp | 4 ++-- examples/cpp/task-simple/s4u-task-simple.cpp | 4 ++-- examples/cpp/task-storm/s4u-task-storm.cpp | 6 +++--- .../task-switch-host/s4u-task-switch-host.cpp | 6 +++--- .../s4u-task-variable-load.cpp | 4 ++-- examples/python/task-io/task-io.py | 4 ++-- examples/python/task-simple/task-simple.py | 4 ++-- .../task-switch-host/task-switch-host.py | 6 +++--- .../task-variable-load/task-variable-load.py | 4 ++-- include/simgrid/s4u/Task.hpp | 4 ++-- src/bindings/python/simgrid_python.cpp | 4 ++-- src/s4u/s4u_Task.cpp | 20 +++++++++---------- 12 files changed, 35 insertions(+), 35 deletions(-) diff --git a/examples/cpp/task-io/s4u-task-io.cpp b/examples/cpp/task-io/s4u-task-io.cpp index 52dcca1202..f5d3c1560c 100644 --- a/examples/cpp/task-io/s4u-task-io.cpp +++ b/examples/cpp/task-io/s4u-task-io.cpp @@ -45,8 +45,8 @@ int main(int argc, char* argv[]) XBT_INFO("Task %s finished (%d)", t->get_name().c_str(), t->get_count()); }); - // Enqueue two executions for task exec1 - exec1->enqueue_execs(2); + // Enqueue two firings for task exec1 + exec1->enqueue_firings(2); // Start the simulation e.run(); diff --git a/examples/cpp/task-simple/s4u-task-simple.cpp b/examples/cpp/task-simple/s4u-task-simple.cpp index 0ec6aaa4c2..72ddf4c0d9 100644 --- a/examples/cpp/task-simple/s4u-task-simple.cpp +++ b/examples/cpp/task-simple/s4u-task-simple.cpp @@ -42,8 +42,8 @@ int main(int argc, char* argv[]) XBT_INFO("Task %s finished (%d)", t->get_name().c_str(), t->get_count()); }); - // Enqueue two executions for task exec1 - exec1->enqueue_execs(2); + // Enqueue two firings for task exec1 + exec1->enqueue_firings(2); // Start the simulation e.run(); diff --git a/examples/cpp/task-storm/s4u-task-storm.cpp b/examples/cpp/task-storm/s4u-task-storm.cpp index 63c3d64542..2c4edb1cb4 100644 --- a/examples/cpp/task-storm/s4u-task-storm.cpp +++ b/examples/cpp/task-storm/s4u-task-storm.cpp @@ -114,9 +114,9 @@ int main(int argc, char* argv[]) t->set_amount(*data * 10); }); - // Enqueue executions for tasks without predecessors - SA->enqueue_execs(5); - SB->enqueue_execs(5); + // Enqueue firings for tasks without predecessors + SA->enqueue_firings(5); + SB->enqueue_firings(5); // Add a function to be called when tasks end for log purpose sg4::Task::on_completion_cb([] diff --git a/examples/cpp/task-switch-host/s4u-task-switch-host.cpp b/examples/cpp/task-switch-host/s4u-task-switch-host.cpp index 2a22323f45..7023f68b48 100644 --- a/examples/cpp/task-switch-host/s4u-task-switch-host.cpp +++ b/examples/cpp/task-switch-host/s4u-task-switch-host.cpp @@ -50,7 +50,7 @@ int main(int argc, char* argv[]) 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 + // Add a function to be called before each firing of comm0 // This function modifies the graph of tasks by adding or removing // successors to comm0 comm0->on_this_start_cb([comm0, exec1, exec2, jupiter, fafard](sg4::Task*) { @@ -67,8 +67,8 @@ int main(int argc, char* argv[]) count++; }); - // Enqueue four executions for task comm0 - comm0->enqueue_execs(4); + // Enqueue four firings for task comm0 + comm0->enqueue_firings(4); // Start the simulation e.run(); diff --git a/examples/cpp/task-variable-load/s4u-task-variable-load.cpp b/examples/cpp/task-variable-load/s4u-task-variable-load.cpp index df41c95a82..0955c2e2a4 100644 --- a/examples/cpp/task-variable-load/s4u-task-variable-load.cpp +++ b/examples/cpp/task-variable-load/s4u-task-variable-load.cpp @@ -22,13 +22,13 @@ static void variable_load(sg4::TaskPtr t) { XBT_INFO("--- Small load ---"); for (int i = 0; i < 3; i++) { - t->enqueue_execs(1); + t->enqueue_firings(1); sg4::this_actor::sleep_for(100); } sg4::this_actor::sleep_until(1000); XBT_INFO("--- Heavy load ---"); for (int i = 0; i < 3; i++) { - t->enqueue_execs(1); + t->enqueue_firings(1); sg4::this_actor::sleep_for(1); } } diff --git a/examples/python/task-io/task-io.py b/examples/python/task-io/task-io.py index 4db1456ded..e75215a0f7 100644 --- a/examples/python/task-io/task-io.py +++ b/examples/python/task-io/task-io.py @@ -43,8 +43,8 @@ if __name__ == '__main__': # Add a function to be called when tasks end for log purpose Task.on_completion_cb(callback) - # Enqueue two executions for task exec1 - exec1.enqueue_execs(2) + # Enqueue two firings for task exec1 + exec1.enqueue_firings(2) # runs the simulation e.run() diff --git a/examples/python/task-simple/task-simple.py b/examples/python/task-simple/task-simple.py index ce57577dea..23e9fc0c8a 100644 --- a/examples/python/task-simple/task-simple.py +++ b/examples/python/task-simple/task-simple.py @@ -51,8 +51,8 @@ if __name__ == '__main__': # Add a function to be called when tasks end for log purpose Task.on_completion_cb(callback) - # Enqueue two executions for task exec1 - exec1.enqueue_execs(2) + # Enqueue two firings for task exec1 + exec1.enqueue_firings(2) # runs the simulation e.run() diff --git a/examples/python/task-switch-host/task-switch-host.py b/examples/python/task-switch-host/task-switch-host.py index 53ba3f2374..b2904c3f56 100644 --- a/examples/python/task-switch-host/task-switch-host.py +++ b/examples/python/task-switch-host/task-switch-host.py @@ -77,13 +77,13 @@ if __name__ == '__main__': # Add a function to be called when tasks end for log purpose Task.on_completion_cb(callback) - # Add a function to be called before each executions of comm0 + # Add a function to be called before each firing of comm0 # This function modifies the graph of tasks by adding or removing # successors to comm0 comm0.on_this_start_cb(lambda t: switch(t, [jupiter, fafard], [exec1,exec2])) - # Enqueue two executions for task exec1 - comm0.enqueue_execs(4) + # Enqueue two firings for task exec1 + comm0.enqueue_firings(4) # runs the simulation e.run() diff --git a/examples/python/task-variable-load/task-variable-load.py b/examples/python/task-variable-load/task-variable-load.py index 719bf56da5..51dbc1a6c6 100644 --- a/examples/python/task-variable-load/task-variable-load.py +++ b/examples/python/task-variable-load/task-variable-load.py @@ -33,12 +33,12 @@ def callback(t): def variable_load(t): print('--- Small load ---') for _ in range(3): - t.enqueue_execs(1) + t.enqueue_firings(1) this_actor.sleep_for(100) this_actor.sleep_for(1000) print('--- Heavy load ---') for _ in range(3): - t.enqueue_execs(1) + t.enqueue_firings(1) this_actor.sleep_for(1) if __name__ == '__main__': diff --git a/include/simgrid/s4u/Task.hpp b/include/simgrid/s4u/Task.hpp index d6f41f5074..c0677da108 100644 --- a/include/simgrid/s4u/Task.hpp +++ b/include/simgrid/s4u/Task.hpp @@ -29,7 +29,7 @@ class XBT_PUBLIC Token : public xbt::Extendable {}; class Task { std::string name_; double amount_; - int queued_execs_ = 0; + int queued_firings_ = 0; int count_ = 0; bool working_ = false; @@ -74,7 +74,7 @@ public: void remove_all_successors(); const std::set& get_successors() const { return successors_; } - void enqueue_execs(int n); + void enqueue_firings(int n); /** Add a callback fired before this task activity starts */ void on_this_start_cb(const std::function& func){ on_this_start.connect(func); } diff --git a/src/bindings/python/simgrid_python.cpp b/src/bindings/python/simgrid_python.cpp index f7f06b73cf..f71d652224 100644 --- a/src/bindings/python/simgrid_python.cpp +++ b/src/bindings/python/simgrid_python.cpp @@ -947,8 +947,8 @@ PYBIND11_MODULE(simgrid, m) .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("enqueue_firings", py::overload_cast(&Task::enqueue_firings), py::call_guard(), + py::arg("n"), "Enqueue firings 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), diff --git a/src/s4u/s4u_Task.cpp b/src/s4u/s4u_Task.cpp index 9c9fbe9487..bda7ec170e 100644 --- a/src/s4u/s4u_Task.cpp +++ b/src/s4u/s4u_Task.cpp @@ -33,7 +33,7 @@ Task::Task(const std::string& name) : name_(name) {} */ bool Task::ready_to_run() const { - return not working_ && queued_execs_ > 0; + return not working_ && queued_firings_ > 0; } /** @@ -46,9 +46,9 @@ void Task::receive(Task* source) { XBT_DEBUG("Task %s received a token from %s", name_.c_str(), source->name_.c_str()); auto source_count = predecessors_[source]++; - if (tokens_received_.size() <= queued_execs_ + source_count) + if (tokens_received_.size() <= queued_firings_ + source_count) tokens_received_.push_back({}); - tokens_received_[queued_execs_ + source_count][source] = source->token_; + tokens_received_[queued_firings_ + source_count][source] = source->token_; bool enough_tokens = true; for (auto const& [key, val] : predecessors_) if (val < 1) { @@ -58,7 +58,7 @@ void Task::receive(Task* source) if (enough_tokens) { for (auto& [key, val] : predecessors_) val--; - enqueue_execs(1); + enqueue_firings(1); } } @@ -86,14 +86,14 @@ void Task::complete() fire(); } -/** @param n The number of executions to enqueue. - * @brief Enqueue executions. - * @note Immediatly starts an execution if possible. +/** @param n The number of firings to enqueue. + * @brief Enqueue firing. + * @note Immediatly fire an activity if possible. */ -void Task::enqueue_execs(int n) +void Task::enqueue_firings(int n) { simgrid::kernel::actor::simcall_answered([this, n] { - queued_execs_ += n; + queued_firings_ += n; if (ready_to_run()) fire(); }); @@ -129,7 +129,7 @@ void Task::fire() { on_this_start(this); on_start(this); working_ = true; - queued_execs_ = std::max(queued_execs_ - 1, 0); + queued_firings_ = std::max(queued_firings_ - 1, 0); if (tokens_received_.size() > 0) tokens_received_.pop_front(); } -- 2.20.1