This will make the interesting parts of the commit more readable.
static void simulate_bootup(simgrid::s4u::Host* host)
{
- int previous_pstate = host->getPstate();
+ int previous_pstate = host->get_pstate();
XBT_INFO("Switch to virtual pstate 3, that encodes the 'booting up' state in that platform");
- host->setPstate(3);
+ host->set_pstate(3);
XBT_INFO("Actually start the host");
host->turn_on();
simgrid::s4u::this_actor::sleep_for(150);
XBT_INFO("The host is now up and running. Switch back to previous pstate %d", previous_pstate);
- host->setPstate(previous_pstate);
+ host->set_pstate(previous_pstate);
}
static void simulate_shutdown(simgrid::s4u::Host* host)
{
- int previous_pstate = host->getPstate();
+ int previous_pstate = host->get_pstate();
XBT_INFO("Switch to virtual pstate 4, that encodes the 'shutting down' state in that platform");
- host->setPstate(4);
+ host->set_pstate(4);
XBT_INFO("Wait 7 seconds to simulate the shutdown time.");
simgrid::s4u::this_actor::sleep_for(7);
XBT_INFO("Switch back to previous pstate %d, that will be used on reboot.", previous_pstate);
- host->setPstate(previous_pstate);
+ host->set_pstate(previous_pstate);
XBT_INFO("Actually shutdown the host");
host->turn_off();
{
simgrid::s4u::Host* host1 = simgrid::s4u::Host::by_name("MyHost1");
- XBT_INFO("Initial pstate: %d; Energy dissipated so far:%.0E J", host1->getPstate(),
+ XBT_INFO("Initial pstate: %d; Energy dissipated so far:%.0E J", host1->get_pstate(),
sg_host_get_consumed_energy(host1));
XBT_INFO("Sleep for 10 seconds");
simgrid::s4u::this_actor::sleep_for(10);
- XBT_INFO("Done sleeping. Current pstate: %d; Energy dissipated so far: %.2f J", host1->getPstate(),
+ XBT_INFO("Done sleeping. Current pstate: %d; Energy dissipated so far: %.2f J", host1->get_pstate(),
sg_host_get_consumed_energy(host1));
simulate_shutdown(host1);
- XBT_INFO("Host1 is now OFF. Current pstate: %d; Energy dissipated so far: %.2f J", host1->getPstate(),
+ XBT_INFO("Host1 is now OFF. Current pstate: %d; Energy dissipated so far: %.2f J", host1->get_pstate(),
sg_host_get_consumed_energy(host1));
XBT_INFO("Sleep for 10 seconds");
simgrid::s4u::this_actor::sleep_for(10);
- XBT_INFO("Done sleeping. Current pstate: %d; Energy dissipated so far: %.2f J", host1->getPstate(),
+ XBT_INFO("Done sleeping. Current pstate: %d; Energy dissipated so far: %.2f J", host1->get_pstate(),
sg_host_get_consumed_energy(host1));
simulate_bootup(host1);
- XBT_INFO("Host1 is now ON again. Current pstate: %d; Energy dissipated so far: %.2f J", host1->getPstate(),
+ XBT_INFO("Host1 is now ON again. Current pstate: %d; Energy dissipated so far: %.2f J", host1->get_pstate(),
sg_host_get_consumed_energy(host1));
return 0;
XBT_INFO("Task done (duration: %.2f s). Current peak speed=%.0E flop/s; Current consumption: from %.0fW to %.0fW"
" depending on load; Energy dissipated=%.0f J",
simgrid::s4u::Engine::get_clock() - start, host1->getSpeed(),
- sg_host_get_wattmin_at(host1, host1->getPstate()), sg_host_get_wattmax_at(host1, host1->getPstate()),
+ sg_host_get_wattmin_at(host1, host1->get_pstate()), sg_host_get_wattmax_at(host1, host1->get_pstate()),
sg_host_get_consumed_energy(host1));
// ========= Change power peak =========
int pstate = 2;
- host1->setPstate(pstate);
+ host1->set_pstate(pstate);
XBT_INFO("========= Requesting pstate %d (speed should be of %.0E flop/s and is of %.0E flop/s)", pstate,
host1->getPstateSpeed(pstate), host1->getSpeed());
double workload = 100E6;
simgrid::s4u::Host* host = simgrid::s4u::this_actor::get_host();
- int nb = host->getPstatesCount();
+ int nb = host->get_pstate_count();
XBT_INFO("Count of Processor states=%d", nb);
XBT_INFO("Current power peak=%f", host->getSpeed());
XBT_INFO("Changing power peak value to %f (at index %d)", host->getPstateSpeed(new_pstate), new_pstate);
- host->setPstate(new_pstate);
+ host->set_pstate(new_pstate);
XBT_INFO("Current power peak=%f", host->getSpeed());
// Verify that the default pstate is set to 0
host = simgrid::s4u::Host::by_name_or_null("MyHost2");
- XBT_INFO("Count of Processor states=%d", host->getPstatesCount());
+ XBT_INFO("Count of Processor states=%d", host->get_pstate_count());
XBT_INFO("Current power peak=%f", host->getSpeed());
return 0;
simgrid::s4u::Engine::get_clock() - start, host->getSpeed(), speed, sg_host_get_computed_flops(host),
sg_host_get_avg_load(host),
static_cast<double>(200E6) /
- (10.5 * speed * host->getCoreCount() +
- (simgrid::s4u::Engine::get_clock() - start - 0.5) * host->getSpeed() * host->getCoreCount()));
+ (10.5 * speed * host->get_core_count() +
+ (simgrid::s4u::Engine::get_clock() - start - 0.5) * host->getSpeed() * host->get_core_count()));
// ========= Change power peak =========
int pstate = 1;
- host->setPstate(pstate);
+ host->set_pstate(pstate);
XBT_INFO("========= Requesting pstate %d (speed should be of %.0E flop/s and is of %.0E flop/s, average load is %.5f)", pstate,
host->getPstateSpeed(pstate), host->getSpeed(), sg_host_get_avg_load(host));
simgrid::s4u::this_actor::sleep_for(10.5);
XBT_INFO("I slept until now, but now I'll change the speed of this host "
"while the other process is still computing! This should slow the computation down.");
- host->setPstate(2);
+ host->set_pstate(2);
}
int main(int argc, char* argv[])
XBT_INFO("Route between %s and %s:", h1->get_cname(), h2->get_cname());
std::vector<sg_link_t> route;
double latency = 0;
- h1->routeTo(h2, route, &latency);
+ h1->route_to(h2, route, &latency);
for (auto const& link : route)
XBT_INFO(" Link %s: latency = %f, bandwidth = %f", sg_link_name(link), sg_link_latency(link),
double getSpeed();
double get_available_speed();
- int getCoreCount();
+ int get_core_count();
double getPstateSpeed(int pstate_index);
- int getPstatesCount() const;
- void setPstate(int pstate_index);
- int getPstate();
+ int get_pstate_count() const;
+ void set_pstate(int pstate_index);
+ int get_pstate();
std::vector<const char*> get_attached_storages();
XBT_ATTRIB_DEPRECATED_v323("Please use Host::get_attached_storages() instead.") void getAttachedStorages(
*/
std::unordered_map<std::string, Storage*> const& getMountedStorages();
- void routeTo(Host* dest, std::vector<Link*>& links, double* latency);
- void routeTo(Host* dest, std::vector<kernel::resource::LinkImpl*>& links, double* latency);
+ void route_to(Host* dest, std::vector<Link*>& links, double* latency);
+ void route_to(Host* dest, std::vector<kernel::resource::LinkImpl*>& links, double* latency);
/** Block the calling actor on an execution located on the called host
*
{
set_property(key, value);
}
+ XBT_ATTRIB_DEPRECATED_v323("Please use Host::set_pstate()") void setPstate(int idx) { set_pstate(idx); }
+ XBT_ATTRIB_DEPRECATED_v323("Please use Host::get_pstate()") int getPstate() { return get_pstate(); }
+
+ XBT_ATTRIB_DEPRECATED_v323("Please use Host::route_to()") void routeTo(Host* dest, std::vector<Link*>& links,
+ double* latency)
+ {
+ route_to(dest, links, latency);
+ }
+ XBT_ATTRIB_DEPRECATED_v323("Please use Host::route_to()") void routeTo(
+ Host* dest, std::vector<kernel::resource::LinkImpl*>& links, double* latency)
+ {
+ route_to(dest, links, latency);
+ }
+ XBT_ATTRIB_DEPRECATED_v323("Please use Host::get_core_count()") int getCoreCount() { return get_core_count(); }
+ XBT_ATTRIB_DEPRECATED_v323("Please use Host::get_pstate_count()") int getPstatesCount() const
+ {
+ return get_pstate_count();
+ }
private:
simgrid::xbt::string name_{"noname"};
{
simgrid::instr::Container::by_name(host.get_cname())
->get_variable("power")
- ->set_event(surf_get_clock(), host.getCoreCount() * host.get_available_speed());
+ ->set_event(surf_get_clock(), host.get_core_count() * host.get_available_speed());
}
static void instr_cpu_action_on_state_change(simgrid::surf::CpuAction* action,
// Create a VCPU for this VM
std::vector<double> speeds;
- for (int i = 0; i < pm->getPstatesCount(); i++)
+ for (int i = 0; i < pm->get_pstate_count(); i++)
speeds.push_back(pm->getPstateSpeed(i));
- surf_cpu_model_vm->create_cpu(this, &speeds, pm->getCoreCount());
- if (pm->getPstate() != 0)
- setPstate(pm->getPstate());
+ surf_cpu_model_vm->create_cpu(this, &speeds, pm->get_core_count());
+ if (pm->get_pstate() != 0)
+ set_pstate(pm->get_pstate());
/* Make a process container */
extension_set<simgrid::simix::Host>(new simgrid::simix::Host());
return this->pimpl_cpu->is_on();
}
-int Host::getPstatesCount() const
+int Host::get_pstate_count() const
{
return this->pimpl_cpu->get_pstates_count();
}
* walk through the routing components tree and find a route between hosts
* by calling each "get_route" function in each routing component.
*/
-void Host::routeTo(Host* dest, std::vector<Link*>& links, double* latency)
+void Host::route_to(Host* dest, std::vector<Link*>& links, double* latency)
{
std::vector<kernel::resource::LinkImpl*> linkImpls;
- this->routeTo(dest, linkImpls, latency);
+ this->route_to(dest, linkImpls, latency);
for (kernel::resource::LinkImpl* const& l : linkImpls)
links.push_back(&l->piface_);
}
/** @brief Just like Host::routeTo, but filling an array of link implementations */
-void Host::routeTo(Host* dest, std::vector<kernel::resource::LinkImpl*>& links, double* latency)
+void Host::route_to(Host* dest, std::vector<kernel::resource::LinkImpl*>& links, double* latency)
{
simgrid::kernel::routing::NetZoneImpl::get_global_route(pimpl_netpoint, dest->pimpl_netpoint, links, latency);
if (XBT_LOG_ISENABLED(surf_route, xbt_log_priority_debug)) {
}
/** @brief Returns the number of core of the processor. */
-int Host::getCoreCount()
+int Host::get_core_count()
{
return this->pimpl_cpu->get_cores_count();
}
/** @brief Set the pstate at which the host should run */
-void Host::setPstate(int pstate_index)
+void Host::set_pstate(int pstate_index)
{
simgrid::simix::simcall([this, pstate_index] { this->pimpl_cpu->set_pstate(pstate_index); });
}
/** @brief Retrieve the pstate at which the host is currently running */
-int Host::getPstate()
+int Host::get_pstate()
{
return this->pimpl_cpu->get_pstate();
}
*/
int sg_host_core_count(sg_host_t host)
{
- return host->getCoreCount();
+ return host->get_core_count();
}
double sg_host_get_available_speed(sg_host_t host)
*/
int sg_host_get_nb_pstates(sg_host_t host)
{
- return host->getPstatesCount();
+ return host->get_pstate_count();
}
/** @brief Gets the pstate at which that host currently runs.
*/
int sg_host_get_pstate(sg_host_t host)
{
- return host->getPstate();
+ return host->get_pstate();
}
/** @brief Sets the pstate at which that host should run.
*
*/
void sg_host_set_pstate(sg_host_t host, int pstate)
{
- host->setPstate(pstate);
+ host->set_pstate(pstate);
}
/** \ingroup m_host_management
void sg_host_route(sg_host_t from, sg_host_t to, xbt_dynar_t links)
{
std::vector<simgrid::s4u::Link*> vlinks;
- from->routeTo(to, vlinks, nullptr);
+ from->route_to(to, vlinks, nullptr);
for (auto const& link : vlinks)
xbt_dynar_push(links, &link);
}
{
std::vector<simgrid::s4u::Link*> vlinks;
double res = 0;
- from->routeTo(to, vlinks, &res);
+ from->route_to(to, vlinks, &res);
return res;
}
/**
double min_bandwidth = -1.0;
std::vector<simgrid::s4u::Link*> vlinks;
- from->routeTo(to, vlinks, nullptr);
+ from->route_to(to, vlinks, nullptr);
for (auto const& link : vlinks) {
double bandwidth = link->get_bandwidth();
if (bandwidth < min_bandwidth || min_bandwidth < 0.0)
XBT_IN("(%s,%s,%g,%g)", src->get_cname(), dst->get_cname(), size, rate);
- src->routeTo(dst, route, &latency);
+ src->route_to(dst, route, &latency);
xbt_assert(not route.empty() || latency,
"You're trying to send data from %s to %s but there is no connecting path between these two hosts.",
src->get_cname(), dst->get_cname());
bool failed = std::any_of(route.begin(), route.end(), [](LinkImpl* link) { return link->is_off(); });
if (cfg_crosstraffic) {
- dst->routeTo(src, back_route, nullptr);
+ dst->route_to(src, back_route, nullptr);
if (not failed)
failed = std::any_of(back_route.begin(), back_route.end(), [](LinkImpl* const& link) { return link->is_off(); });
}
public:
explicit Performance(simgrid::s4u::Host* ptr) : Governor(ptr) {}
- void update() override { get_host()->setPstate(0); }
+ void update() override { get_host()->set_pstate(0); }
std::string getName() override { return "Performance"; }
};
public:
explicit Powersave(simgrid::s4u::Host* ptr) : Governor(ptr) {}
- void update() override { get_host()->setPstate(get_host()->getPstatesCount() - 1); }
+ void update() override { get_host()->set_pstate(get_host()->get_pstate_count() - 1); }
std::string getName() override { return "Powersave"; }
};
std::string getName() override { return "OnDemand"; }
void update() override
{
- double load = get_host()->getCoreCount() * sg_host_get_avg_load(get_host());
+ double load = get_host()->get_core_count() * sg_host_get_avg_load(get_host());
sg_host_load_reset(get_host()); // Only consider the period between two calls to this method!
if (load > freq_up_threshold) {
- get_host()->setPstate(0); /* Run at max. performance! */
+ get_host()->set_pstate(0); /* Run at max. performance! */
XBT_INFO("Load: %f > threshold: %f --> changed to pstate %i", load, freq_up_threshold, 0);
} else {
/* The actual implementation uses a formula here: (See Kernel file cpufreq_ondemand.c:158)
* So they assume that frequency increases by 100 MHz. We will just use
* lowest_pstate - load*pstatesCount()
*/
- int max_pstate = get_host()->getPstatesCount() - 1;
+ int max_pstate = get_host()->get_pstate_count() - 1;
// Load is now < freq_up_threshold; exclude pstate 0 (the fastest)
// because pstate 0 can only be selected if load > freq_up_threshold
int new_pstate = max_pstate - load * (max_pstate + 1);
- get_host()->setPstate(new_pstate);
+ get_host()->set_pstate(new_pstate);
XBT_DEBUG("Load: %f < threshold: %f --> changed to pstate %i", load, freq_up_threshold, new_pstate);
}
virtual std::string getName() override { return "Conservative"; }
virtual void update() override
{
- double load = get_host()->getCoreCount() * sg_host_get_avg_load(get_host());
- int pstate = get_host()->getPstate();
+ double load = get_host()->get_core_count() * sg_host_get_avg_load(get_host());
+ int pstate = get_host()->get_pstate();
sg_host_load_reset(get_host()); // Only consider the period between two calls to this method!
if (load > freq_up_threshold) {
if (pstate != 0) {
- get_host()->setPstate(pstate - 1);
+ get_host()->set_pstate(pstate - 1);
XBT_INFO("Load: %f > threshold: %f -> increasing performance to pstate %d", load, freq_up_threshold, pstate - 1);
}
else {
XBT_DEBUG("Load: %f > threshold: %f -> but cannot speed up even more, already in highest pstate %d", load, freq_up_threshold, pstate);
}
} else if (load < freq_down_threshold) {
- int max_pstate = get_host()->getPstatesCount() - 1;
+ int max_pstate = get_host()->get_pstate_count() - 1;
if (pstate != max_pstate) { // Are we in the slowest pstate already?
- get_host()->setPstate(pstate + 1);
+ get_host()->set_pstate(pstate + 1);
XBT_INFO("Load: %f < threshold: %f -> slowing down to pstate %d", load, freq_down_threshold, pstate + 1);
}
else {
}
/* Save data for the upcoming time interval: whether it's on/off and the pstate if it's on */
- this->pstate = host->is_on() ? host->getPstate() : pstate_off;
+ this->pstate = host->is_on() ? host->get_pstate() : pstate_off;
}
HostEnergy::HostEnergy(simgrid::s4u::Host* ptr) : host(ptr), last_updated(surf_get_clock())
* (maxCpuLoad is by definition 1)
*/
double power_slope;
- int coreCount = host->getCoreCount();
+ int coreCount = host->get_core_count();
double coreReciprocal = static_cast<double>(1) / static_cast<double>(coreCount);
if (coreCount > 1)
power_slope = (max_power - min_power) / (1 - coreReciprocal);
std::vector<std::string> all_power_values;
boost::split(all_power_values, all_power_values_str, boost::is_any_of(","));
- XBT_DEBUG("%s: profile: %s, cores: %d", host->get_cname(), all_power_values_str, host->getCoreCount());
+ XBT_DEBUG("%s: profile: %s, cores: %d", host->get_cname(), all_power_values_str, host->get_core_count());
int i = 0;
for (auto const& current_power_values_str : all_power_values) {
/* retrieve the power values associated with the current pstate */
std::vector<std::string> current_power_values;
boost::split(current_power_values, current_power_values_str, boost::is_any_of(":"));
- if (host->getCoreCount() == 1) {
+ if (host->get_core_count() == 1) {
xbt_assert(current_power_values.size() == 2 || current_power_values.size() == 3,
"Power properties incorrectly defined for host %s."
"It should be 'Idle:FullSpeed' power values because you have one core only.",
idle_time += (now - last_updated);
}
- theor_max_flops += current_speed * host->getCoreCount() * (now - last_updated);
+ theor_max_flops += current_speed * host->get_core_count() * (now - last_updated);
current_speed = host->getSpeed();
last_updated = now;
was_prev_idle = (current_flops == 0);
// We don't need to call update() here because it is called everytime an
// action terminates or starts
// FIXME: Can this happen at the same time? stop -> call to getCurrentLoad, load = 0 -> next action starts?
- return current_flops / static_cast<double>(host->getSpeed() * host->getCoreCount());
+ return current_flops / static_cast<double>(host->getSpeed() * host->get_core_count());
}
/**
double lat=0.0;
std::vector<kernel::resource::LinkImpl*> route;
- hostList_->at(i)->routeTo(hostList_->at(j), route, &lat);
+ hostList_->at(i)->route_to(hostList_->at(j), route, &lat);
latency = std::max(latency, lat);
for (auto const& link : route)
for (int j = 0; j < host_nb; j++) {
if (bytes_amount[i * host_nb + j] > 0.0) {
std::vector<kernel::resource::LinkImpl*> route;
- hostList_->at(i)->routeTo(hostList_->at(j), route, nullptr);
+ hostList_->at(i)->route_to(hostList_->at(j), route, nullptr);
for (auto const& link : route)
model->get_maxmin_system()->expand_add(link->get_constraint(), this->get_variable(),
if (communicationAmount_[i * hostNb + j] > 0) {
double lat = 0.0;
std::vector<kernel::resource::LinkImpl*> route;
- hostList_->at(i)->routeTo(hostList_->at(j), route, &lat);
+ hostList_->at(i)->route_to(hostList_->at(j), route, &lat);
lat_current = std::max(lat_current, lat * communicationAmount_[i * hostNb + j]);
}
for (unsigned int i = 0; i < totalHosts; i++) {
std::printf(" <host id=\"%s\" speed=\"%.0f\"", hosts[i]->get_cname(), sg_host_speed(hosts[i]));
props = hosts[i]->getProperties();
- if (hosts[i]->getCoreCount() > 1) {
- std::printf(" core=\"%d\"", hosts[i]->getCoreCount());
+ if (hosts[i]->get_core_count() > 1) {
+ std::printf(" core=\"%d\"", hosts[i]->get_core_count());
}
if (props && not props->empty()) {
std::printf(">\n");