From dbb61188c41cbcc3cbb6eca59452abf3d65e7c41 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Mon, 1 Feb 2021 20:35:14 +0100 Subject: [PATCH] Introduce Exec::init(). One step towards SimDag++ --- include/simgrid/s4u/Exec.hpp | 3 ++- src/s4u/s4u_Actor.cpp | 11 +++-------- src/s4u/s4u_Exec.cpp | 5 +++++ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/simgrid/s4u/Exec.hpp b/include/simgrid/s4u/Exec.hpp index 20cb8e48dd..19fa207624 100644 --- a/include/simgrid/s4u/Exec.hpp +++ b/include/simgrid/s4u/Exec.hpp @@ -37,9 +37,9 @@ class XBT_PUBLIC Exec : public Activity_T { std::vector bytes_amounts_; std::vector hosts_; bool parallel_ = false; + Exec(); public: - Exec(); ~Exec() override = default; #ifndef DOXYGEN Exec(Exec const&) = delete; @@ -49,6 +49,7 @@ public: static xbt::signal on_start; static xbt::signal on_completion; + static ExecPtr init(); Exec* start() override; /** @brief On sequential executions, returns the amount of flops that remain to be done; This cannot be used on * parallel executions. */ diff --git a/src/s4u/s4u_Actor.cpp b/src/s4u/s4u_Actor.cpp index 858f69e54a..3c4b899c84 100644 --- a/src/s4u/s4u_Actor.cpp +++ b/src/s4u/s4u_Actor.cpp @@ -372,9 +372,7 @@ void parallel_execute(const std::vector& hosts, const std::vectorset_flops_amount(flops_amount)->set_host(get_host()); - return exec; + return Exec::init()->set_flops_amount(flops_amount)->set_host(get_host()); } ExecPtr exec_init(const std::vector& hosts, const std::vector& flops_amounts, @@ -400,9 +398,7 @@ ExecPtr exec_init(const std::vector& hosts, const std::vectorset_flops_amounts(flops_amounts)->set_bytes_amounts(bytes_amounts)->set_hosts(hosts); - return exec; + return Exec::init()->set_flops_amounts(flops_amounts)->set_bytes_amounts(bytes_amounts)->set_hosts(hosts); } ExecPtr exec_async(double flops) @@ -875,8 +871,7 @@ sg_exec_t sg_actor_parallel_exec_init(int host_nb, const sg_host_t* host_list, d if (bytes_amount != nullptr) bytes = std::vector(bytes_amount, bytes_amount + host_nb * host_nb); - simgrid::s4u::ExecPtr exec(new simgrid::s4u::Exec()); - exec->set_flops_amounts(flops)->set_bytes_amounts(bytes)->set_hosts(hosts); + simgrid::s4u::ExecPtr exec = simgrid::s4u::this_actor::exec_init(hosts, flops, bytes); exec->add_ref(); return exec.get(); } diff --git a/src/s4u/s4u_Exec.cpp b/src/s4u/s4u_Exec.cpp index edea68571a..31f69d287e 100644 --- a/src/s4u/s4u_Exec.cpp +++ b/src/s4u/s4u_Exec.cpp @@ -22,6 +22,11 @@ Exec::Exec() pimpl_ = kernel::activity::ExecImplPtr(new kernel::activity::ExecImpl()); } +ExecPtr Exec::init() +{ + return ExecPtr(new Exec()); +} + Exec* Exec::wait() { return this->wait_for(-1); -- 2.20.1