Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Introduce Exec::init(). One step towards SimDag++
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 1 Feb 2021 19:35:14 +0000 (20:35 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 1 Feb 2021 19:35:14 +0000 (20:35 +0100)
include/simgrid/s4u/Exec.hpp
src/s4u/s4u_Actor.cpp
src/s4u/s4u_Exec.cpp

index 20cb8e4..19fa207 100644 (file)
@@ -37,9 +37,9 @@ class XBT_PUBLIC Exec : public Activity_T<Exec> {
   std::vector<double> bytes_amounts_;
   std::vector<Host*> hosts_;
   bool parallel_ = false;
+  Exec();
 
 public:
-  Exec();
   ~Exec() override = default;
 #ifndef DOXYGEN
   Exec(Exec const&) = delete;
@@ -49,6 +49,7 @@ public:
   static xbt::signal<void(Exec const&)> on_start;
   static xbt::signal<void(Exec const&)> 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. */
index 858f69e..3c4b899 100644 (file)
@@ -372,9 +372,7 @@ void parallel_execute(const std::vector<s4u::Host*>& hosts, const std::vector<do
 
 ExecPtr exec_init(double flops_amount)
 {
-  ExecPtr exec(new Exec());
-  exec->set_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<s4u::Host*>& hosts, const std::vector<double>& flops_amounts,
@@ -400,9 +398,7 @@ ExecPtr exec_init(const std::vector<s4u::Host*>& hosts, const std::vector<double
   xbt_assert(std::all_of(bytes_amounts.begin(), bytes_amounts.end(), [](double elm) { return std::isfinite(elm); }),
              "flops_amounts comprises infinite values!");
 
-  ExecPtr exec(new Exec());
-  exec->set_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<double>(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();
 }
index edea685..31f69d2 100644 (file)
@@ -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);