Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://framagit.org/simgrid/simgrid
[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 "src/kernel/activity/ActivityImpl.hpp"
10 #include "src/kernel/context/Context.hpp"
11 #include "surf/surf.hpp"
12
13 namespace simgrid {
14 namespace kernel {
15 namespace activity {
16
17 class XBT_PUBLIC ExecImpl : public ActivityImpl_T<ExecImpl> {
18   std::unique_ptr<resource::Action, std::function<void(resource::Action*)>> timeout_detector_{
19       nullptr, [](resource::Action* a) { a->unref(); }};
20   actor::ActorImpl* actor_            = nullptr;
21   double sharing_penalty_             = 1.0;
22   double bound_                       = 0.0;
23   std::vector<s4u::Host*> hosts_;
24   std::vector<double> flops_amounts_;
25   std::vector<double> bytes_amounts_;
26
27 public:
28   ExecImpl();
29
30   ExecImpl& set_timeout(double timeout) override;
31   ExecImpl& set_bound(double bound);
32   ExecImpl& set_sharing_penalty(double sharing_penalty);
33
34   ExecImpl& set_flops_amount(double flop_amount);
35   ExecImpl& set_host(s4u::Host* host);
36   s4u::Host* get_host() const { return hosts_.front(); }
37
38   ExecImpl& set_flops_amounts(const std::vector<double>& flops_amounts);
39   ExecImpl& set_bytes_amounts(const std::vector<double>& bytes_amounts);
40   ExecImpl& set_hosts(const std::vector<s4u::Host*>& hosts);
41
42   unsigned int get_host_number() const { return hosts_.size(); }
43   double get_seq_remaining_ratio();
44   double get_par_remaining_ratio();
45   virtual ActivityImpl* migrate(s4u::Host* to);
46
47   ExecImpl* start();
48   void post() override;
49   void finish() override;
50
51   static xbt::signal<void(ExecImpl const&, s4u::Host*)> on_migration;
52 };
53 } // namespace activity
54 } // namespace kernel
55 } // namespace simgrid
56 #endif