Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Enable access to Exec from ExecImpl and fix get_finish_time()
[simgrid.git] / src / kernel / activity / ExecImpl.hpp
1 /* Copyright (c) 2007-2021. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #ifndef SIMGRID_KERNEL_ACTIVITY_EXEC_HPP
7 #define SIMGRID_KERNEL_ACTIVITY_EXEC_HPP
8
9 #include "simgrid/s4u/Exec.hpp"
10 #include "src/kernel/activity/ActivityImpl.hpp"
11 #include "src/kernel/context/Context.hpp"
12 #include "surf/surf.hpp"
13
14 namespace simgrid {
15 namespace kernel {
16 namespace activity {
17
18 class XBT_PUBLIC ExecImpl : public ActivityImpl_T<ExecImpl> {
19   std::unique_ptr<resource::Action, std::function<void(resource::Action*)>> timeout_detector_{
20       nullptr, [](resource::Action* a) { a->unref(); }};
21   actor::ActorImpl* actor_            = nullptr;
22   double sharing_penalty_             = 1.0;
23   double bound_                       = 0.0;
24   std::vector<s4u::Host*> hosts_;
25   std::vector<double> flops_amounts_;
26   std::vector<double> bytes_amounts_;
27   s4u::Exec* piface_;
28 public:
29   ExecImpl();
30   s4u::Exec* get_iface() { return piface_; }
31
32   ExecImpl& set_timeout(double timeout) override;
33   ExecImpl& set_bound(double bound);
34   ExecImpl& set_sharing_penalty(double sharing_penalty);
35
36   ExecImpl& set_flops_amount(double flop_amount);
37   ExecImpl& set_host(s4u::Host* host);
38   s4u::Host* get_host() const { return hosts_.front(); }
39
40   ExecImpl& set_flops_amounts(const std::vector<double>& flops_amounts);
41   ExecImpl& set_bytes_amounts(const std::vector<double>& bytes_amounts);
42   ExecImpl& set_hosts(const std::vector<s4u::Host*>& hosts);
43
44   unsigned int get_host_number() const { return hosts_.size(); }
45   double get_seq_remaining_ratio();
46   double get_par_remaining_ratio();
47   virtual ActivityImpl* migrate(s4u::Host* to);
48
49   ExecImpl* start();
50   void post() override;
51   void finish() override;
52
53   static xbt::signal<void(ExecImpl const&, s4u::Host*)> on_migration;
54 };
55 } // namespace activity
56 } // namespace kernel
57 } // namespace simgrid
58 #endif