Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Enable access to Exec from ExecImpl and fix get_finish_time()
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 9 Feb 2021 07:15:28 +0000 (08:15 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 9 Feb 2021 08:16:59 +0000 (09:16 +0100)
include/simgrid/s4u/Exec.hpp
src/kernel/activity/ExecImpl.cpp
src/kernel/activity/ExecImpl.hpp
src/s4u/s4u_Exec.cpp

index afc242f..72d0e2e 100644 (file)
@@ -30,6 +30,7 @@ namespace s4u {
  * @endrst
  */
 class XBT_PUBLIC Exec : public Activity_T<Exec> {
+  friend kernel::activity::ExecImpl;
   double priority_              = 1.0;
   double bound_                 = 0.0;
   double timeout_               = 0.0;
@@ -39,7 +40,9 @@ class XBT_PUBLIC Exec : public Activity_T<Exec> {
   bool parallel_ = false;
   double start_time_ = -1.0;
   double finish_time_ = -1.0;
-  Exec();
+
+protected:
+  explicit Exec(kernel::activity::ExecImplPtr pimpl);
 
 public:
   ~Exec() override = default;
@@ -80,7 +83,8 @@ public:
   Host* get_host() const;
   unsigned int get_host_number() const;
   double get_start_time() const { return start_time_; }
-  double get_finish_time() const;
+  double get_finish_time() const { return finish_time_; }
+  void set_finish_time(double finish_time) { finish_time_ = finish_time; }
   double get_cost() const;
   bool is_parallel() const { return parallel_; }
   bool is_assigned() const override { return not hosts_.empty(); }
index 3e27a03..166d78f 100644 (file)
@@ -3,6 +3,7 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "simgrid/s4u/Exec.hpp"
 #include "src/kernel/activity/ExecImpl.hpp"
 #include "simgrid/Exception.hpp"
 #include "simgrid/modelchecker.h"
@@ -57,6 +58,7 @@ namespace activity {
 
 ExecImpl::ExecImpl()
 {
+  piface_ = new s4u::Exec(this);
   actor::ActorImpl* self = actor::ActorImpl::self();
   if (self) {
     actor_ = self;
@@ -163,6 +165,8 @@ void ExecImpl::post()
     state_ = State::DONE;
   }
 
+  get_iface()->set_finish_time(surf_action_->get_finish_time());
+
   clean_action();
   timeout_detector_.reset();
   if (actor_) {
@@ -208,7 +212,6 @@ void ExecImpl::finish()
         simcall_execution_waitany_for__set__result(simcall, rank);
       }
     }
-
     switch (state_) {
       case State::DONE:
         /* do nothing, synchro done */
index 0f92c84..3782b7a 100644 (file)
@@ -6,6 +6,7 @@
 #ifndef SIMGRID_KERNEL_ACTIVITY_EXEC_HPP
 #define SIMGRID_KERNEL_ACTIVITY_EXEC_HPP
 
+#include "simgrid/s4u/Exec.hpp"
 #include "src/kernel/activity/ActivityImpl.hpp"
 #include "src/kernel/context/Context.hpp"
 #include "surf/surf.hpp"
@@ -23,9 +24,10 @@ class XBT_PUBLIC ExecImpl : public ActivityImpl_T<ExecImpl> {
   std::vector<s4u::Host*> hosts_;
   std::vector<double> flops_amounts_;
   std::vector<double> bytes_amounts_;
-
+  s4u::Exec* piface_;
 public:
   ExecImpl();
+  s4u::Exec* get_iface() { return piface_; }
 
   ExecImpl& set_timeout(double timeout) override;
   ExecImpl& set_bound(double bound);
index 731631f..81a0578 100644 (file)
@@ -17,14 +17,15 @@ namespace s4u {
 xbt::signal<void(Exec const&)> Exec::on_start;
 xbt::signal<void(Exec const&)> Exec::on_completion;
 
-Exec::Exec()
+Exec::Exec(kernel::activity::ExecImplPtr pimpl)
 {
-  pimpl_ = kernel::activity::ExecImplPtr(new kernel::activity::ExecImpl());
+  pimpl_ = pimpl;
 }
 
 ExecPtr Exec::init()
 {
-  return ExecPtr(new Exec());
+  auto pimpl = kernel::activity::ExecImplPtr(new kernel::activity::ExecImpl());
+  return ExecPtr(pimpl->get_iface());
 }
 
 Exec* Exec::wait()
@@ -116,10 +117,6 @@ unsigned int Exec::get_host_number() const
 {
   return static_cast<kernel::activity::ExecImpl*>(pimpl_.get())->get_host_number();
 }
-double Exec::get_finish_time() const
-{
-  return (pimpl_->surf_action_ == nullptr) ? -1 : pimpl_->surf_action_->get_finish_time();
-}
 double Exec::get_cost() const
 {
   return (pimpl_->surf_action_ == nullptr) ? -1 : pimpl_->surf_action_->get_cost();