/** Block the calling actor on an execution located on the called host (with explicit priority) */
void execute(double flops, double priority);
- /** @brief Returns the current computation load (in flops per second) */
+ /** @brief Returns the current computation load (in flops per second)
+ * The external load (coming from an availability trace) is not taken in account.
+ *
+ * @return The number of activities currently running on a host (an activity at priority 2 is counted twice).
+ */
double getLoad();
private:
simgrid::xbt::string name_{"noname"};
- std::unordered_map<std::string, Storage*>* mounts = nullptr; // caching
+ std::unordered_map<std::string, Storage*>* mounts_ = nullptr; // caching
public:
// TODO, this could be a unique_ptr
kernel::routing::NetPoint* pimpl_netpoint = nullptr;
/*** Called on each newly created host */
- static simgrid::xbt::signal<void(Host&)> onCreation;
+ static simgrid::xbt::signal<void(Host&)> on_creation;
/*** Called just before destructing an host */
- static simgrid::xbt::signal<void(Host&)> onDestruction;
+ static simgrid::xbt::signal<void(Host&)> on_destruction;
/*** Called when the machine is turned on or off (called AFTER the change) */
- static simgrid::xbt::signal<void(Host&)> onStateChange;
+ static simgrid::xbt::signal<void(Host&)> on_state_change;
/*** Called when the speed of the machine is changed (called AFTER the change)
* (either because of a pstate switch or because of an external load event coming from the profile) */
- static simgrid::xbt::signal<void(Host&)> onSpeedChange;
+ static simgrid::xbt::signal<void(Host&)> on_speed_change;
};
}
} // namespace simgrid::s4u
extern int USER_HOST_LEVEL;
#endif /* SIMGRID_S4U_HOST_HPP */
-
-#if 0
-
-public class Host {
-
- /**
- * This method returns the number of tasks currently running on a host.
- * The external load (coming from an availability trace) is not taken in account.
- *
- * @return The number of tasks currently running on a host.
- */
- public native int getLoad();
-
-}
-#endif
// properly
if (TRACE_needs_platform()) {
simgrid::s4u::on_platform_created.connect(instr_on_platform_created);
- simgrid::s4u::Host::onCreation.connect(instr_host_on_creation);
+ simgrid::s4u::Host::on_creation.connect(instr_host_on_creation);
simgrid::s4u::Link::on_creation.connect(instr_link_on_creation);
}
simgrid::s4u::NetZone::onCreation.connect(instr_netzone_on_creation);
}
if (TRACE_vm_is_enabled()) {
- simgrid::s4u::Host::onCreation.connect(instr_vm_on_creation);
+ simgrid::s4u::Host::on_creation.connect(instr_vm_on_creation);
simgrid::s4u::VirtualMachine::on_start.connect(instr_vm_on_start);
simgrid::s4u::VirtualMachine::on_started.connect(instr_vm_on_started);
simgrid::s4u::VirtualMachine::on_suspend.connect(instr_vm_on_suspend);
simgrid::s4u::VirtualMachine::on_resume.connect(instr_vm_on_resume);
- simgrid::s4u::Host::onDestruction.connect(instr_vm_on_destruction);
+ simgrid::s4u::Host::on_destruction.connect(instr_vm_on_destruction);
}
}
/*
for (auto const& kv : *props)
res->setProperty(kv.first, kv.second);
- simgrid::s4u::Host::onCreation(*res); // notify the signal
+ simgrid::s4u::Host::on_creation(*res); // notify the signal
return res;
}
if (not FileDescriptorHostExt::EXTENSION_ID.valid()) {
FileDescriptorHostExt::EXTENSION_ID = simgrid::s4u::Host::extension_create<FileDescriptorHostExt>();
- simgrid::s4u::Host::onCreation.connect(&on_host_creation);
+ simgrid::s4u::Host::on_creation.connect(&on_host_creation);
}
}
}
VMModel::VMModel()
{
- s4u::Host::onStateChange.connect(hostStateChange);
+ s4u::Host::on_state_change.connect(hostStateChange);
}
double VMModel::next_occuring_event(double now)
VirtualMachine::~VirtualMachine()
{
- onDestruction(*this);
+ on_destruction(*this);
XBT_DEBUG("destroy %s", get_cname());
namespace s4u {
-simgrid::xbt::signal<void(Host&)> Host::onCreation;
-simgrid::xbt::signal<void(Host&)> Host::onDestruction;
-simgrid::xbt::signal<void(Host&)> Host::onStateChange;
-simgrid::xbt::signal<void(Host&)> Host::onSpeedChange;
+simgrid::xbt::signal<void(Host&)> Host::on_creation;
+simgrid::xbt::signal<void(Host&)> Host::on_destruction;
+simgrid::xbt::signal<void(Host&)> Host::on_state_change;
+simgrid::xbt::signal<void(Host&)> Host::on_speed_change;
Host::Host(const char* name) : name_(name)
{
if (pimpl_netpoint != nullptr) // not removed yet by a children class
simgrid::s4u::Engine::get_instance()->netpoint_unregister(pimpl_netpoint);
delete pimpl_cpu;
- delete mounts;
+ delete mounts_;
}
/** @brief Fire the required callbacks and destroy the object
{
if (not currentlyDestroying_) {
currentlyDestroying_ = true;
- onDestruction(*this);
+ on_destruction(*this);
Engine::get_instance()->host_unregister(std::string(name_));
delete this;
}
simgrid::simix::simcall([this] {
this->extension<simgrid::simix::Host>()->turnOn();
this->pimpl_cpu->turn_on();
- onStateChange(*this);
+ on_state_change(*this);
});
}
}
smx_actor_t self = SIMIX_process_self();
simgrid::simix::simcall([this, self] {
SIMIX_host_off(this, self);
- onStateChange(*this);
+ on_state_change(*this);
});
}
}
std::unordered_map<std::string, Storage*> const& Host::getMountedStorages()
{
- if (mounts == nullptr) {
- mounts = new std::unordered_map<std::string, Storage*>();
+ if (mounts_ == nullptr) {
+ mounts_ = new std::unordered_map<std::string, Storage*>();
for (auto const& m : this->pimpl_->storage_) {
- mounts->insert({m.first, &m.second->piface_});
+ mounts_->insert({m.first, &m.second->piface_});
}
}
- return *mounts;
+ return *mounts_;
}
void Host::execute(double flops)
/* register a function to be called by SURF after the environment creation */
sg_platf_init();
simgrid::s4u::on_platform_created.connect(SIMIX_post_create_environment);
- simgrid::s4u::Host::onCreation.connect([](simgrid::s4u::Host& host) {
+ simgrid::s4u::Host::on_creation.connect([](simgrid::s4u::Host& host) {
if (host.extension<simgrid::simix::Host>() == nullptr) // another callback to the same signal may have created it
host.extension_set<simgrid::simix::Host>(new simgrid::simix::Host());
});
// TODO This will not be executed in the case where smpi_main is not called,
// e.g., not for smpi_msg_masterslave. This should be moved to another location
// that is always called -- maybe close to Actor::onCreation?
- simgrid::s4u::Host::onCreation.connect([](simgrid::s4u::Host& host) {
- host.extension_set(new simgrid::smpi::Host(&host));
- });
+ simgrid::s4u::Host::on_creation.connect(
+ [](simgrid::s4u::Host& host) { host.extension_set(new simgrid::smpi::Host(&host)); });
// parse the platform file: get the host list
SIMIX_create_environment(argv[1]);
instr::Container::by_name(get_cname())
->get_variable("power")
->set_event(surf_get_clock(), coresAmount_ * speed_.scale * speed_.peak);
- s4u::Host::onSpeedChange(*host_);
+ s4u::Host::on_speed_change(*host_);
}
int Cpu::coreCount()
all_existing_models->push_back(surf_network_model);
simgrid::s4u::Link::on_communication_state_change.connect(IB_action_state_changed_callback);
simgrid::s4u::Link::on_communicate.connect(IB_action_init_callback);
- simgrid::s4u::Host::onCreation.connect(IB_create_host_callback);
+ simgrid::s4u::Host::on_creation.connect(IB_create_host_callback);
simgrid::config::set_default<double>("network/weight-S", 8775);
}
sg_host_load_plugin_init();
- simgrid::s4u::Host::onCreation.connect(&on_host_added);
+ simgrid::s4u::Host::on_creation.connect(&on_host_added);
simgrid::config::declare_flag<double>(
property_sampling_rate, "How often should the dvfs plugin check whether the frequency needs to be changed?", 0.1);
simgrid::config::declare_flag<std::string>(
HostEnergy::EXTENSION_ID = simgrid::s4u::Host::extension_create<HostEnergy>();
- simgrid::s4u::Host::onCreation.connect(&onCreation);
- simgrid::s4u::Host::onStateChange.connect(&onHostChange);
- simgrid::s4u::Host::onSpeedChange.connect(&onHostChange);
- simgrid::s4u::Host::onDestruction.connect(&onHostDestruction);
+ simgrid::s4u::Host::on_creation.connect(&onCreation);
+ simgrid::s4u::Host::on_state_change.connect(&onHostChange);
+ simgrid::s4u::Host::on_speed_change.connect(&onHostChange);
+ simgrid::s4u::Host::on_destruction.connect(&onHostDestruction);
simgrid::s4u::on_simulation_end.connect(&onSimulationEnd);
simgrid::surf::CpuAction::onStateChange.connect(&onActionStateChange);
}
/* When attaching a callback into a signal, you can use a lambda as follows, or a regular function as done below */
- simgrid::s4u::Host::onCreation.connect([](simgrid::s4u::Host& host) {
+ simgrid::s4u::Host::on_creation.connect([](simgrid::s4u::Host& host) {
if (dynamic_cast<simgrid::s4u::VirtualMachine*>(&host)) // Ignore virtual machines
return;
host.extension_set(new HostLoad(&host));
});
simgrid::surf::CpuAction::onStateChange.connect(&onActionStateChange);
- simgrid::s4u::Host::onStateChange.connect(&onHostChange);
- simgrid::s4u::Host::onSpeedChange.connect(&onHostChange);
+ simgrid::s4u::Host::on_state_change.connect(&onHostChange);
+ simgrid::s4u::Host::on_speed_change.connect(&onHostChange);
}
/** @brief Returns the current load of the host passed as argument
-/* Copyright (c) 2016-2018. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2016-2018. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */