1 /* Copyright (c) 2007-2021. The SimGrid Team. All rights reserved. */
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. */
6 #ifndef SIMGRID_KERNEL_ACTIVITY_EXEC_HPP
7 #define SIMGRID_KERNEL_ACTIVITY_EXEC_HPP
9 #include <simgrid/s4u/Exec.hpp>
11 #include "src/kernel/activity/ActivityImpl.hpp"
12 #include "src/kernel/context/Context.hpp"
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 double sharing_penalty_ = 1.0;
23 double start_time_ = -1.0;
24 double finish_time_ = -1.0;
25 std::vector<s4u::Host*> hosts_;
26 std::vector<double> flops_amounts_;
27 std::vector<double> bytes_amounts_;
28 int cb_id_ = -1; // callback id from Host::on_state_change.connect()
33 ExecImpl& set_timeout(double timeout) override;
34 ExecImpl& set_bound(double bound);
35 ExecImpl& set_sharing_penalty(double sharing_penalty);
36 ExecImpl& update_sharing_penalty(double sharing_penalty);
38 void set_cb_id(unsigned int cb_id) { cb_id_ = cb_id; }
40 double get_start_time() const { return start_time_; }
41 void set_finish_time(double finish_time) { finish_time_ = finish_time; }
42 double get_finish_time() const { return finish_time_; }
44 ExecImpl& set_flops_amount(double flop_amount);
45 ExecImpl& set_host(s4u::Host* host);
46 s4u::Host* get_host() const { return hosts_.front(); }
47 const std::vector<s4u::Host*>& get_hosts() const { return hosts_; }
49 ExecImpl& set_flops_amounts(const std::vector<double>& flops_amounts);
50 ExecImpl& set_bytes_amounts(const std::vector<double>& bytes_amounts);
51 ExecImpl& set_hosts(const std::vector<s4u::Host*>& hosts);
53 unsigned int get_host_number() const { return hosts_.size(); }
54 double get_seq_remaining_ratio();
55 double get_par_remaining_ratio();
56 double get_remaining() const override;
57 virtual ActivityImpl* migrate(s4u::Host* to);
61 void set_exception(actor::ActorImpl* issuer) override;
62 void finish() override;
65 static void wait_any_for(actor::ActorImpl* issuer, const std::vector<ExecImpl*>& execs, double timeout);
67 static xbt::signal<void(ExecImpl const&, s4u::Host*)> on_migration;
69 } // namespace activity
71 } // namespace simgrid