1 /* Copyright (c) 2007-2023. 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"
14 namespace simgrid::kernel::activity {
16 class XBT_PUBLIC ExecImpl : public ActivityImpl_T<ExecImpl> {
17 double sharing_penalty_ = 1.0;
19 std::vector<double> flops_amounts_;
20 std::vector<double> bytes_amounts_;
21 int thread_count_ = 1;
22 int cb_id_ = -1; // callback id from Host::on_state_change.connect()
27 ExecImpl& set_bound(double bound);
28 ExecImpl& set_sharing_penalty(double sharing_penalty);
29 ExecImpl& update_sharing_penalty(double sharing_penalty);
31 void set_cb_id(unsigned int cb_id) { cb_id_ = cb_id; }
33 ExecImpl& set_flops_amount(double flop_amount);
34 ExecImpl& set_host(s4u::Host* host);
36 ExecImpl& set_flops_amounts(const std::vector<double>& flops_amounts);
37 ExecImpl& set_bytes_amounts(const std::vector<double>& bytes_amounts);
38 ExecImpl& set_thread_count(int thread_count);
39 ExecImpl& set_hosts(const std::vector<s4u::Host*>& hosts);
41 unsigned int get_host_number() const { return static_cast<unsigned>(get_hosts().size()); }
42 int get_thread_count() const { return thread_count_; }
43 double get_seq_remaining_ratio();
44 double get_par_remaining_ratio();
45 double get_remaining() const override;
46 virtual ActivityImpl* migrate(s4u::Host* to);
49 void set_exception(actor::ActorImpl* issuer) override;
50 void finish() override;
54 static xbt::signal<void(ExecImpl const&, s4u::Host*)> on_migration;
56 } // namespace simgrid::kernel::activity