Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use std::fill instead of memset.
[simgrid.git] / src / kernel / activity / ExecImpl.hpp
1 /* Copyright (c) 2007-2022. 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
11 #include "src/kernel/activity/ActivityImpl.hpp"
12 #include "src/kernel/context/Context.hpp"
13
14 namespace simgrid::kernel::activity {
15
16 class XBT_PUBLIC ExecImpl : public ActivityImpl_T<ExecImpl> {
17   std::unique_ptr<resource::Action, std::function<void(resource::Action*)>> timeout_detector_{
18       nullptr, [](resource::Action* a) { a->unref(); }};
19   double sharing_penalty_             = 1.0;
20   double bound_                       = 0.0;
21   std::vector<double> flops_amounts_;
22   std::vector<double> bytes_amounts_;
23   int thread_count_ = 1;
24   int cb_id_ = -1; // callback id from Host::on_state_change.connect()
25
26 public:
27   ExecImpl();
28
29   ExecImpl& set_timeout(double timeout) override;
30   ExecImpl& set_bound(double bound);
31   ExecImpl& set_sharing_penalty(double sharing_penalty);
32   ExecImpl& update_sharing_penalty(double sharing_penalty);
33
34   void set_cb_id(unsigned int cb_id) { cb_id_ = cb_id; }
35
36   ExecImpl& set_flops_amount(double flop_amount);
37   ExecImpl& set_host(s4u::Host* host);
38
39   ExecImpl& set_flops_amounts(const std::vector<double>& flops_amounts);
40   ExecImpl& set_bytes_amounts(const std::vector<double>& bytes_amounts);
41   ExecImpl& set_thread_count(int thread_count);
42   ExecImpl& set_hosts(const std::vector<s4u::Host*>& hosts);
43
44   unsigned int get_host_number() const { return static_cast<unsigned>(get_hosts().size()); }
45   int get_thread_count() const { return thread_count_; }
46   double get_seq_remaining_ratio();
47   double get_par_remaining_ratio();
48   double get_remaining() const override;
49   virtual ActivityImpl* migrate(s4u::Host* to);
50
51   ExecImpl* start();
52   void post() override;
53   void set_exception(actor::ActorImpl* issuer) override;
54   void finish() override;
55
56   void reset();
57
58   static xbt::signal<void(ExecImpl const&, s4u::Host*)> on_migration;
59 };
60 } // namespace simgrid::kernel::activity
61 #endif