// The private implementation, that never changes
surf::HostImpl* const pimpl_;
+ kernel::resource::CpuImpl* pimpl_cpu_ = nullptr;
+ kernel::routing::NetPoint* pimpl_netpoint_ = nullptr;
+
public:
explicit Host(surf::HostImpl* pimpl) : pimpl_(pimpl) {}
/** Retrieves the name of that host as a C string */
const char* get_cname() const;
+ Host* set_cpu(kernel::resource::CpuImpl* cpu);
+ kernel::resource::CpuImpl* get_cpu() const { return pimpl_cpu_; }
kernel::routing::NetPoint* get_netpoint() const { return pimpl_netpoint_; }
size_t get_actor_count() const;
/** Block the calling actor on an execution located on the called host (with explicit priority) */
void execute(double flops, double priority) const;
surf::HostImpl* get_impl() const { return pimpl_; }
-
-private:
- kernel::routing::NetPoint* pimpl_netpoint_ = nullptr;
-
-public:
-#ifndef DOXYGEN
- /** DO NOT USE DIRECTLY (@todo: these should be protected, once our code is clean) */
- kernel::resource::CpuImpl* pimpl_cpu = nullptr;
-#endif
};
} // namespace s4u
} // namespace simgrid
if (state_ != State::WAITING && state_ != State::RUNNING) {
finish();
} else { /* we need a sleep action (even when there is no timeout) to be notified of host failures */
- resource::Action* sleep = issuer->get_host()->pimpl_cpu->sleep(timeout);
+ resource::Action* sleep = issuer->get_host()->get_cpu()->sleep(timeout);
sleep->set_activity(this);
if (issuer == src_actor_)
ExecImpl& ExecImpl::set_timeout(double timeout)
{
if (timeout >= 0 && not MC_is_active() && not MC_record_replay_is_active()) {
- timeout_detector_.reset(hosts_.front()->pimpl_cpu->sleep(timeout));
+ timeout_detector_.reset(hosts_.front()->get_cpu()->sleep(timeout));
timeout_detector_->set_activity(this);
}
return *this;
state_ = State::RUNNING;
if (not MC_is_active() && not MC_record_replay_is_active()) {
if (hosts_.size() == 1) {
- surf_action_ = hosts_.front()->pimpl_cpu->execution_start(flops_amounts_.front());
+ surf_action_ = hosts_.front()->get_cpu()->execution_start(flops_amounts_.front());
surf_action_->set_sharing_penalty(sharing_penalty_);
surf_action_->set_category(get_tracing_category());
{
if (not MC_is_active() && not MC_record_replay_is_active()) {
resource::Action* old_action = this->surf_action_;
- resource::Action* new_action = to->pimpl_cpu->execution_start(old_action->get_cost());
+ resource::Action* new_action = to->get_cpu()->execution_start(old_action->get_cost());
new_action->set_remains(old_action->get_remains());
new_action->set_activity(this);
new_action->set_sharing_penalty(old_action->get_sharing_penalty());
IoImpl& IoImpl::set_timeout(double timeout)
{
const s4u::Host* host = get_disk()->get_host();
- timeout_detector_ = host->pimpl_cpu->sleep(timeout);
+ timeout_detector_ = host->get_cpu()->sleep(timeout);
timeout_detector_->set_activity(this);
return *this;
}
SleepImpl* SleepImpl::start()
{
- surf_action_ = host_->pimpl_cpu->sleep(duration_);
+ surf_action_ = host_->get_cpu()->sleep(duration_);
surf_action_->set_activity(this);
XBT_DEBUG("Create sleep synchronization %p", this);
return this;
RawImpl* RawImpl::start()
{
- surf_action_ = host_->pimpl_cpu->sleep(timeout_);
+ surf_action_ = host_->get_cpu()->sleep(timeout_);
surf_action_->set_activity(this);
return this;
}
if (ws_vm->get_state() == s4u::VirtualMachine::State::SUSPENDED) // Ignore suspended VMs
continue;
- const kernel::resource::CpuImpl* cpu = ws_vm->pimpl_cpu;
+ const kernel::resource::CpuImpl* cpu = ws_vm->get_cpu();
// solved_value below is X1 in comment above: what this VM got in the sharing on the PM
double solved_value = ws_vm->get_vm_impl()->get_action()->get_rate();
* The value for GUESTOS_NOISE corresponds to the cost of the global action associated to the VM. It corresponds to
* the cost of a VM running no tasks.
*/
- action_ = physical_host_->pimpl_cpu->execution_start(0, core_amount_);
+ action_ = physical_host_->get_cpu()->execution_start(0, core_amount_);
// It's empty for now, so it should not request resources in the PM
update_action_weight();
piface_->set_netpoint(destination->get_netpoint());
/* Adapt the speed, pstate and other physical characteristics to the one of our new physical CPU */
- piface_->pimpl_cpu->reset_vcpu(destination->pimpl_cpu);
+ piface_->get_cpu()->reset_vcpu(destination->get_cpu());
physical_host_ = destination;
/* Update vcpu's action for the new pm */
/* create a cpu action bound to the pm model at the destination. */
- kernel::resource::CpuAction* new_cpu_action = destination->pimpl_cpu->execution_start(0, this->core_amount_);
+ kernel::resource::CpuAction* new_cpu_action = destination->get_cpu()->execution_start(0, this->core_amount_);
if (action_->get_remains_no_update() > 0)
XBT_CRITICAL("FIXME: need copy the state(?), %f", action_->get_remains_no_update());
xbt::signal<void(Host const&)> Host::on_state_change;
xbt::signal<void(Host const&)> Host::on_speed_change;
+Host* Host::set_cpu(kernel::resource::CpuImpl* cpu)
+{
+ pimpl_cpu_ = cpu;
+ return this;
+}
+
Host* Host::set_netpoint(kernel::routing::NetPoint* netpoint)
{
pimpl_netpoint_ = netpoint;
{
if (pimpl_netpoint_ != nullptr) // not removed yet by a children class
Engine::get_instance()->netpoint_unregister(pimpl_netpoint_);
- delete pimpl_cpu;
+ delete pimpl_cpu_;
}
/** @brief Fire the required callbacks and destroy the object
{
if (not is_on()) {
kernel::actor::simcall([this] {
- this->pimpl_cpu->turn_on();
+ this->pimpl_cpu_->turn_on();
this->pimpl_->turn_on();
on_state_change(*this);
});
vm->shutdown();
vm->turn_off();
}
- this->pimpl_cpu->turn_off();
+ this->pimpl_cpu_->turn_off();
this->pimpl_->turn_off(self);
on_state_change(*this);
bool Host::is_on() const
{
- return this->pimpl_cpu->is_on();
+ return this->pimpl_cpu_->is_on();
}
int Host::get_pstate_count() const
{
- return this->pimpl_cpu->get_pstate_count();
+ return this->pimpl_cpu_->get_pstate_count();
}
/**
* The profile must contain boolean values. */
Host* Host::set_state_profile(kernel::profile::Profile* p)
{
- kernel::actor::simcall([this, p] { pimpl_cpu->set_state_profile(p); });
+ kernel::actor::simcall([this, p] { pimpl_cpu_->set_state_profile(p); });
return this;
}
/** Specify a profile modeling the external load according to an exhaustive list or a stochastic law.
*/
Host* Host::set_speed_profile(kernel::profile::Profile* p)
{
- kernel::actor::simcall([this, p] { pimpl_cpu->set_speed_profile(p); });
+ kernel::actor::simcall([this, p] { pimpl_cpu_->set_speed_profile(p); });
return this;
}
/** @brief Get the peak processor speed (in flops/s), at the specified pstate */
double Host::get_pstate_speed(int pstate_index) const
{
- return this->pimpl_cpu->get_pstate_peak_speed(pstate_index);
+ return this->pimpl_cpu_->get_pstate_peak_speed(pstate_index);
}
double Host::get_speed() const
{
- return this->pimpl_cpu->get_speed(1.0);
+ return this->pimpl_cpu_->get_speed(1.0);
}
double Host::get_load() const
{
- return this->pimpl_cpu->get_load();
+ return this->pimpl_cpu_->get_load();
}
double Host::get_available_speed() const
{
- return this->pimpl_cpu->get_speed_ratio();
+ return this->pimpl_cpu_->get_speed_ratio();
}
int Host::get_core_count() const
{
- return this->pimpl_cpu->get_core_count();
+ return this->pimpl_cpu_->get_core_count();
}
Host* Host::set_core_count(int core_count)
{
- kernel::actor::simcall([this, core_count] { this->pimpl_cpu->set_core_count(core_count); });
+ kernel::actor::simcall([this, core_count] { this->pimpl_cpu_->set_core_count(core_count); });
return this;
}
Host* Host::set_pstate_speed(const std::vector<double>& speed_per_state)
{
- kernel::actor::simcall([this, &speed_per_state] { pimpl_cpu->set_pstate_speed(speed_per_state); });
+ kernel::actor::simcall([this, &speed_per_state] { pimpl_cpu_->set_pstate_speed(speed_per_state); });
return this;
}
/** @brief Set the pstate at which the host should run */
Host* Host::set_pstate(int pstate_index)
{
- kernel::actor::simcall([this, pstate_index] { this->pimpl_cpu->set_pstate(pstate_index); });
+ kernel::actor::simcall([this, pstate_index] { this->pimpl_cpu_->set_pstate(pstate_index); });
return this;
}
/** @brief Retrieve the pstate at which the host is currently running */
int Host::get_pstate() const
{
- return this->pimpl_cpu->get_pstate();
+ return this->pimpl_cpu_->get_pstate();
}
Host* Host::set_coordinates(const std::string& coords)
return;
}
// seals host's CPU
- get_iface()->pimpl_cpu->seal();
+ get_iface()->get_cpu()->seal();
sealed_ = true;
/* seal its disks */
{
speed_.scale = 1;
speed_.peak = speed_per_pstate_.front();
- host->pimpl_cpu = this;
+ host->set_cpu(this);
}
void CpuImpl::reset_vcpu(CpuImpl* that)
* create the respective surf actions */
auto net_model = host_list[0]->get_netpoint()->get_englobing_zone()->get_network_model();
if ((host_list.size() == 1) && (has_cost(bytes_amount, 0) <= 0) && (has_cost(flops_amount, 0) > 0)) {
- action = host_list[0]->pimpl_cpu->execution_start(flops_amount[0]);
+ action = host_list[0]->get_cpu()->execution_start(flops_amount[0]);
} else if ((host_list.size() == 1) && (has_cost(flops_amount, 0) <= 0)) {
action = net_model->communicate(host_list[0], host_list[0], bytes_amount[0], rate);
} else if ((host_list.size() == 2) && (has_cost(flops_amount, 0) <= 0) && (has_cost(flops_amount, 1) <= 0)) {
* communication either */
double bound = std::numeric_limits<double>::max();
for (size_t i = 0; i < host_list.size(); i++) {
- model->get_maxmin_system()->expand(host_list[i]->pimpl_cpu->get_constraint(), get_variable(),
+ model->get_maxmin_system()->expand(host_list[i]->get_cpu()->get_constraint(), get_variable(),
(flops_amount == nullptr ? 0.0 : flops_amount[i]));
if (flops_amount && flops_amount[i] > 0)
- bound = std::min(bound, host_list[i]->pimpl_cpu->get_speed(1.0) * host_list[i]->pimpl_cpu->get_speed_ratio() /
+ bound = std::min(bound, host_list[i]->get_cpu()->get_speed(1.0) * host_list[i]->get_cpu()->get_speed_ratio() /
flops_amount[i]);
}
if (bound < std::numeric_limits<double>::max())
simgrid::s4u::Host* hostB = sg_host_by_name("Cpu B");
/* Let's do something on it */
- const simgrid::kernel::resource::Action* actionA = hostA->pimpl_cpu->execution_start(1000.0);
- const simgrid::kernel::resource::Action* actionB = hostB->pimpl_cpu->execution_start(1000.0);
- const simgrid::kernel::resource::Action* actionC = hostB->pimpl_cpu->sleep(7.32);
+ const simgrid::kernel::resource::Action* actionA = hostA->get_cpu()->execution_start(1000.0);
+ const simgrid::kernel::resource::Action* actionB = hostB->get_cpu()->execution_start(1000.0);
+ const simgrid::kernel::resource::Action* actionC = hostB->get_cpu()->sleep(7.32);
simgrid::kernel::resource::Action::State stateActionA = actionA->get_state();
simgrid::kernel::resource::Action::State stateActionB = actionB->get_state();
simgrid::s4u::Host* hostB = sg_host_by_name("Cpu B");
/* Let's do something on it */
- hostA->pimpl_cpu->execution_start(1000.0);
- hostB->pimpl_cpu->execution_start(1000.0);
- hostB->pimpl_cpu->sleep(7.32);
+ hostA->get_cpu()->execution_start(1000.0);
+ hostB->get_cpu()->execution_start(1000.0);
+ hostB->get_cpu()->sleep(7.32);
const_sg_netzone_t as_zone = sg_zone_get_by_name("AS0");
auto net_model = as_zone->get_impl()->get_network_model();