State state_ = State::WAITING; /* State of the activity */
double start_time_ = -1.0;
double finish_time_ = -1.0;
+ std::vector<s4u::Host*> hosts_;
public:
virtual ~ActivityImpl();
resource::Action* surf_action_ = nullptr;
protected:
-
- std::vector<s4u::Host*> hosts_;
-
-
void inline set_name(std::string_view name)
{
// This is to keep name_ private while allowing ActivityImpl_T<??> to set it and then return a Ptr to qualified
name_ = name;
}
void set_start_time(double start_time) { start_time_ = start_time; }
-
+ void clear_hosts() { hosts_.clear(); }
+ void add_host(s4u::Host* host) { hosts_.push_back(host); }
+ void set_hosts(const std::vector<s4u::Host*>& hosts) { hosts_=hosts; }
+
public:
+
const std::string& get_name() const { return name_; }
const char* get_cname() const { return name_.c_str(); }
virtual void finish() = 0; // Unlock all simcalls blocked on that activity, either because it was marked as done by
// the model or because it terminated without waiting for the model
- virtual const std::vector<s4u::Host*>& get_hosts() const { return hosts_;} ;
+ s4u::Host* get_host() const { return hosts_.front(); }
+ const std::vector<s4u::Host*>& get_hosts() const { return hosts_;} ;
void register_simcall(actor::Simcall* simcall);
void unregister_simcall(actor::Simcall* simcall);
ExecImpl& ExecImpl::set_host(s4u::Host* host)
{
- hosts_.assign(1, host);
+ clear_hosts();
+ add_host(host);
return *this;
}
ExecImpl& ExecImpl::set_hosts(const std::vector<s4u::Host*>& hosts)
{
- hosts_ = hosts;
+ ActivityImpl::set_hosts(hosts);
return *this;
}
ExecImpl& ExecImpl::set_timeout(double timeout)
{
if (timeout >= 0 && not MC_is_active() && not MC_record_replay_is_active()) {
- timeout_detector_.reset(hosts_.front()->get_cpu()->sleep(timeout));
+ timeout_detector_.reset(get_host()->get_cpu()->sleep(timeout));
timeout_detector_->set_activity(this);
}
return *this;
{
set_state(State::RUNNING);
if (not MC_is_active() && not MC_record_replay_is_active()) {
- if (hosts_.size() == 1) {
+ if (get_hosts().size() == 1) {
if (thread_count_ == 1) {
- surf_action_ = hosts_.front()->get_cpu()->execution_start(flops_amounts_.front(), bound_);
+ surf_action_ = get_host()->get_cpu()->execution_start(flops_amounts_.front(), bound_);
surf_action_->set_sharing_penalty(sharing_penalty_);
} else {
- auto host_model = hosts_.front()->get_netpoint()->get_englobing_zone()->get_host_model();
- surf_action_ = host_model->execute_thread(hosts_.front(), flops_amounts_.front(), thread_count_);
+ auto host_model = get_host()->get_netpoint()->get_englobing_zone()->get_host_model();
+ surf_action_ = host_model->execute_thread(get_host(), flops_amounts_.front(), thread_count_);
}
surf_action_->set_category(get_tracing_category());
} else {
// get the model from first host since we have only 1 by now
- auto host_model = hosts_.front()->get_netpoint()->get_englobing_zone()->get_host_model();
- surf_action_ = host_model->execute_parallel(hosts_, flops_amounts_.data(), bytes_amounts_.data(), -1);
+ auto host_model = get_host()->get_netpoint()->get_englobing_zone()->get_host_model();
+ surf_action_ = host_model->execute_parallel(get_hosts(), flops_amounts_.data(), bytes_amounts_.data(), -1);
}
surf_action_->set_activity(this);
set_start_time(surf_action_->get_start_time());
void ExecImpl::post()
{
xbt_assert(surf_action_ != nullptr);
- if (std::any_of(hosts_.begin(), hosts_.end(), [](const s4u::Host* host) { return not host->is_on(); })) {
+ auto hosts=get_hosts();
+ if (std::any_of(hosts.begin(), hosts.end(), [](const s4u::Host* host) { return not host->is_on(); })) {
/* If one of the hosts running the synchro failed, notice it. This way, the asking
* process can be killed if it runs on that host itself */
set_state(State::FAILED);
void ExecImpl::reset()
{
- hosts_.clear();
+ clear_hosts();
bytes_amounts_.clear();
flops_amounts_.clear();
set_start_time(-1.0);
ExecImpl& set_flops_amount(double flop_amount);
ExecImpl& set_host(s4u::Host* host);
- s4u::Host* get_host() const { return hosts_.front(); }
- const std::vector<s4u::Host*>& get_hosts() const { return hosts_; }
ExecImpl& set_flops_amounts(const std::vector<double>& flops_amounts);
ExecImpl& set_bytes_amounts(const std::vector<double>& bytes_amounts);
ExecImpl& set_thread_count(int thread_count);
ExecImpl& set_hosts(const std::vector<s4u::Host*>& hosts);
- unsigned int get_host_number() const { return static_cast<unsigned>(hosts_.size()); }
+ unsigned int get_host_number() const { return static_cast<unsigned>(get_hosts().size()); }
double get_seq_remaining_ratio();
double get_par_remaining_ratio();
double get_remaining() const override;