int main(int argc, char **argv) {
boost::unordered_map <std::string, simgrid::s4u::Storage *>& mounts =
- simgrid::s4u::Host::current()->mountedStorages();
+ simgrid::s4u::Host::current()->mounted_storages();
show_info(mounts);
* All actors on that host which were marked autorestart will be restarted automatically.
* This call does nothing if the host is already on.
*/
- void turnOn();
+ void turn_on();
/** Turns that host off. All actors are forcefully stopped. */
- void turnOff();
+ void turn_off();
/** Returns if that host is currently up and running */
- bool isOn();
- bool isOff() { return !isOn(); }
-
- double getSpeed();
- int getCoreAmount();
- xbt_dict_t getProperties();
- xbt_swag_t getProcessList();
- double getCurrentPowerPeak();
- double getPowerPeakAt(int pstate_index);
- void setPState(int pstate_index);
- int getNbPStates() const;
- int getPState();
- void getParams(vm_params_t params);
- void setParams(vm_params_t params);
- xbt_dict_t getMountedStorageList();
- xbt_dynar_t getAttachedStorageList();
+ bool is_on();
+ bool is_off() { return !is_on(); }
+
+ double speed();
+ int core_count();
+ xbt_dict_t properties();
+ xbt_swag_t processes();
+ double current_power_peak();
+ double power_peak_at(int pstate_index);
+ void set_pstate(int pstate_index);
+ int pstates_count() const;
+ int pstate();
+ void get_parameters(vm_params_t params);
+ void set_parameters(vm_params_t params);
+ xbt_dict_t mounted_storages_as_dict(); // HACK
+ xbt_dynar_t attached_storages();
/** Get an associative list [mount point]->[Storage] off all local mount points.
*
*
* Do not change the returned value in any way.
*/
- boost::unordered_map<std::string, Storage*> &mountedStorages();
+ boost::unordered_map<std::string, Storage*> &mounted_storages();
private:
simgrid::xbt::string name_ = "noname";
*/
void MSG_host_on(msg_host_t host)
{
- host->turnOn();
+ host->turn_on();
}
/** \ingroup m_host_management
*/
void MSG_host_off(msg_host_t host)
{
- host->turnOff();
+ host->turn_off();
}
/*
the current load on the machine.
*/
double MSG_get_host_speed(msg_host_t host) {
- return host->getSpeed();
+ return host->speed();
}
* \return the number of cores
*/
int MSG_host_get_core_number(msg_host_t host) {
- return host->getCoreAmount();
+ return host->core_count();
}
/** \ingroup m_host_management
xbt_swag_t MSG_host_get_process_list(msg_host_t host)
{
xbt_assert((host != NULL), "Invalid parameters");
- return host->getProcessList();
+ return host->processes();
}
xbt_dict_t MSG_host_get_properties(msg_host_t host)
{
xbt_assert((host != NULL), "Invalid parameters (host is NULL)");
- return host->getProperties();
+ return host->properties();
}
/** \ingroup m_host_management
*/
void MSG_host_set_params(msg_host_t host, vm_params_t params)
{
- host->setParams(params);
+ host->set_parameters(params);
}
/** \ingroup m_host_management
*/
void MSG_host_get_params(msg_host_t host, vm_params_t params)
{
- host->getParams(params);
+ host->get_parameters(params);
}
/** \ingroup m_host_management
*/
double MSG_host_get_power_peak_at(msg_host_t host, int pstate_index) {
xbt_assert((host != NULL), "Invalid parameters (host is NULL)");
- return host->getPowerPeakAt(pstate_index);
+ return host->power_peak_at(pstate_index);
}
/** \ingroup m_host_management
*/
double MSG_host_get_current_power_peak(msg_host_t host) {
xbt_assert((host != NULL), "Invalid parameters (host is NULL)");
- return host->getCurrentPowerPeak();
+ return host->current_power_peak();
}
/** \ingroup m_host_management
xbt_dict_t MSG_host_get_mounted_storage_list(msg_host_t host)
{
xbt_assert((host != NULL), "Invalid parameters");
- return host->getMountedStorageList();
+ return host->mounted_storages_as_dict();
}
/** \ingroup m_host_management
xbt_dynar_t MSG_host_get_attached_storage_list(msg_host_t host)
{
xbt_assert((host != NULL), "Invalid parameters");
- return host->getAttachedStorageList();
+ return host->attached_storages();
}
/** \ingroup m_host_management
char* mount_name;
xbt_dict_cursor_t cursor = NULL;
- xbt_dict_t storage_list = host->getMountedStorageList();
+ xbt_dict_t storage_list = host->mounted_storages_as_dict();
xbt_dict_foreach(storage_list,cursor,mount_name,storage_name){
storage = (msg_storage_t)xbt_lib_get_elm_or_null(storage_lib,storage_name);
msg_host_t host_dest;
size_t longest_prefix_length = 0;
- xbt_dict_t storage_list = host->getMountedStorageList();
+ xbt_dict_t storage_list = host->mounted_storages_as_dict();
xbt_dict_foreach(storage_list,cursor,mount_name,storage_name){
file_mount_name = (char *) xbt_malloc ((strlen(mount_name)+1));
strncpy(file_mount_name,fullpath,strlen(mount_name)+1);
xbt_dict_t MSG_vm_get_properties(msg_vm_t vm)
{
xbt_assert((vm != NULL), "Invalid parameters (vm is NULL)");
- return vm->getProperties();
+ return vm->properties();
}
/** \ingroup m_host_management
params.mig_speed = (double)mig_netspeed * 1024 * 1024; // mig_speed
//XBT_INFO("dp rate %f migspeed : %f intensity mem : %d, updatespeed %f, hostspeed %f",params.dp_rate, params.mig_speed, dp_intensity, update_speed, host_speed);
- vm->setParams(¶ms);
+ vm->set_parameters(¶ms);
return vm;
}
struct migration_session *ms = (migration_session *) MSG_process_get_data(MSG_process_self());
s_vm_params_t params;
- ms->vm->getParams(¶ms);
+ ms->vm->get_parameters(¶ms);
int need_exit = 0;
(migration_session *) MSG_process_get_data(MSG_process_self());
s_vm_params_t params;
- ms->vm->getParams(¶ms);
+ ms->vm->get_parameters(¶ms);
const sg_size_t ramsize = params.ramsize;
const sg_size_t devsize = params.devsize;
const int skip_stage1 = params.skip_stage1;
return SIMIX_process_get_host(smx_proc);
}
-void Host::turnOn() {
+void Host::turn_on() {
simgrid::simix::kernel(std::bind(SIMIX_host_on, this));
}
-void Host::turnOff() {
+void Host::turn_off() {
simgrid::simix::simcall<void>(SIMCALL_HOST_OFF, this);
}
-bool Host::isOn() {
+bool Host::is_on() {
return this->pimpl_cpu->isOn();
}
-int Host::getNbPStates() const {
+int Host::pstates_count() const {
return this->pimpl_cpu->getNbPStates();
}
-boost::unordered_map<std::string, Storage*> &Host::mountedStorages() {
+boost::unordered_map<std::string, Storage*> &Host::mounted_storages() {
if (mounts == NULL) {
mounts = new boost::unordered_map<std::string, Storage*> ();
- xbt_dict_t dict = this->getMountedStorageList();
+ xbt_dict_t dict = this->mounted_storages_as_dict();
xbt_dict_cursor_t cursor;
char *mountname;
}
/** Get the properties assigned to a host */
-xbt_dict_t Host::getProperties() {
+xbt_dict_t Host::properties() {
return simgrid::simix::kernel([&] {
simgrid::surf::Host* surf_host = this->extension<simgrid::surf::Host>();
return surf_host->getProperties();
}
/** Get the processes attached to the host */
-xbt_swag_t Host::getProcessList()
+xbt_swag_t Host::processes()
{
return simgrid::simix::kernel([&]() {
return ((smx_host_priv_t)this->extension(SIMIX_HOST_LEVEL))->process_list;
}
/** Get the peak power of a host */
-double Host::getCurrentPowerPeak()
+double Host::current_power_peak()
{
return simgrid::simix::kernel([&] {
return this->pimpl_cpu->getCurrentPowerPeak();
}
/** Get one power peak (in flops/s) of a host at a given pstate */
-double Host::getPowerPeakAt(int pstate_index)
+double Host::power_peak_at(int pstate_index)
{
return simgrid::simix::kernel([&] {
return this->pimpl_cpu->getPowerPeakAt(pstate_index);
}
/** @brief Get the speed of the cpu associated to a host */
-double Host::getSpeed() {
+double Host::speed() {
return pimpl_cpu->getSpeed(1.0);
}
/** @brief Returns the number of core of the processor. */
-int Host::getCoreAmount() {
+int Host::core_count() {
return pimpl_cpu->getCore();
}
}
/** @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::kernel(std::bind(
&simgrid::surf::Cpu::setPState, pimpl_cpu, pstate_index
));
}
/** @brief Retrieve the pstate at which the host is currently running */
-int Host::getPState()
+int Host::pstate()
{
return pimpl_cpu->getPState();
}
-void Host::getParams(vm_params_t params)
+void Host::get_parameters(vm_params_t params)
{
simgrid::simix::kernel([&]() {
this->extension<simgrid::surf::Host>()->getParams(params);
});
}
-void Host::setParams(vm_params_t params)
+void Host::set_parameters(vm_params_t params)
{
simgrid::simix::kernel([&]() {
this->extension<simgrid::surf::Host>()->setParams(params);
* \brief Returns the list of storages mounted on an host.
* \return a dict containing all storages mounted on the host
*/
-xbt_dict_t Host::getMountedStorageList()
+xbt_dict_t Host::mounted_storages_as_dict()
{
return simgrid::simix::kernel([&] {
return this->extension<simgrid::surf::Host>()->getMountedStorageList();
* \brief Returns the list of storages attached to an host.
* \return a dict containing all storages attached to the host
*/
-xbt_dynar_t Host::getAttachedStorageList()
+xbt_dynar_t Host::attached_storages()
{
return simgrid::simix::kernel([&] {
return this->extension<simgrid::surf::Host>()->getAttachedStorageList();
*/
double SD_workstation_get_power(SD_workstation_t workstation)
{
- return workstation->getSpeed();
+ return workstation->speed();
}
/**
* \brief Returns the amount of cores of a workstation
* \return the amount of cores of this workstation
*/
int SD_workstation_get_cores(SD_workstation_t workstation) {
- return workstation->getCoreAmount();
+ return workstation->core_count();
}
/**
* @return 1 if the host is active or 0 if it has crashed.
*/
int sg_host_is_on(sg_host_t host) {
- return host->isOn();
+ return host->is_on();
}
/** @brief Returns the number of power states for a host.
* See also @ref SURF_plugin_energy.
*/
int sg_host_get_nb_pstates(sg_host_t host) {
- return host->getNbPStates();
+ return host->pstates_count();
}
/** @brief Gets the pstate at which that host currently runs.
* See also @ref SURF_plugin_energy.
*/
int sg_host_get_pstate(sg_host_t host) {
- return host->getPState();
+ return host->pstate();
}
/** @brief Sets the pstate at which that host should run.
*
* See also @ref SURF_plugin_energy.
*/
void sg_host_set_pstate(sg_host_t host,int pstate) {
- host->setPState(pstate);
+ host->set_pstate(pstate);
}
/** @brief Get the properties of an host */
xbt_dict_t sg_host_get_properties(sg_host_t host) {
- return host->getProperties();
+ return host->properties();
}
* \deprecated */
xbt_swag_t simcall_host_get_process_list(sg_host_t host)
{
- return host->getProcessList();
+ return host->processes();
}
/** \ingroup simix_host_management
* \deprecated */
double simcall_host_get_current_power_peak(sg_host_t host)
{
- return host->getCurrentPowerPeak();
+ return host->current_power_peak();
}
/** \ingroup simix_host_management
* \deprecated */
double simcall_host_get_power_peak_at(sg_host_t host, int pstate_index)
{
- return host->getPowerPeakAt(pstate_index);
+ return host->power_peak_at(pstate_index);
}
/** \deprecated */
void simcall_host_get_params(sg_host_t vm, vm_params_t params)
{
- vm->getParams(params);
+ vm->get_parameters(params);
}
/** \deprecated */
void simcall_host_set_params(sg_host_t vm, vm_params_t params)
{
- vm->setParams(params);
+ vm->set_parameters(params);
}
/** \ingroup simix_storage_management
* \deprecated */
xbt_dict_t simcall_host_get_mounted_storage_list(sg_host_t host)
{
- return host->getMountedStorageList();
+ return host->mounted_storages_as_dict();
}
/** \ingroup simix_storage_management
* \deprecated */
xbt_dynar_t simcall_host_get_attached_storage_list(sg_host_t host)
{
- return host->getAttachedStorageList();
+ return host->attached_storages();
}
// ***** Other simcalls
xbt_assert((host != NULL), "Invalid parameters");
- if (h->isOff()) {
+ if (h->is_off()) {
simgrid::surf::Host* surf_host = h->extension<simgrid::surf::Host>();
surf_host->turnOn();
xbt_assert((host != NULL), "Invalid parameters");
- if (h->isOn()) {
+ if (h->is_on()) {
simgrid::surf::Host* surf_host = h->extension<simgrid::surf::Host>();
surf_host->turnOff();
(int)synchro->state);
}
/* check if the host is down */
- if (simcall->issuer->host->isOff()) {
+ if (simcall->issuer->host->is_off()) {
simcall->issuer->context->iwannadie = 1;
}
{
if (synchro->type == SIMIX_SYNC_EXECUTE && /* FIMXE: handle resource failure
* for parallel tasks too */
- synchro->execution.host->isOff()) {
+ synchro->execution.host->is_off()) {
/* If the host running the synchro failed, notice it so that the asking
* process can be killed if it runs on that host itself */
synchro->state = SIMIX_FAILED;
smx_synchro_t synchro;
/* check if the host is active */
- if (host->isOff()) {
+ if (host->is_off()) {
THROWF(host_error, 0, "Host %s failed, you cannot call this function",
sg_host_get_name(host));
}
smx_synchro_t synchro;
/* check if the host is active */
- if (host->isOff()) {
+ if (host->is_off()) {
THROWF(host_error, 0, "Host %s failed, you cannot call this function",
sg_host_get_name(host));
}
smx_synchro_t synchro;
/* check if the host is active */
- if (host->isOff()) {
+ if (host->is_off()) {
THROWF(host_error, 0, "Host %s failed, you cannot call this function",
sg_host_get_name(host));
}
smx_synchro_t synchro;
/* check if the host is active */
- if (host->isOff()) {
+ if (host->is_off()) {
THROWF(host_error, 0, "Host %s failed, you cannot call this function",
sg_host_get_name(host));
}
int SIMIX_file_unlink(smx_file_t fd, sg_host_t host)
{
/* check if the host is active */
- if (host->isOff()) {
+ if (host->is_off()) {
THROWF(host_error, 0, "Host %s failed, you cannot call this function",
sg_host_get_name(host));
}
(int)synchro->state);
}
- if (simcall->issuer->host->isOff()) {
+ if (simcall->issuer->host->is_off()) {
simcall->issuer->context->iwannadie = 1;
}
/* Check out for errors */
- if (simcall->issuer->host->isOff()) {
+ if (simcall->issuer->host->is_off()) {
simcall->issuer->context->iwannadie = 1;
SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed");
} else
}
}
- if (simcall->issuer->host->isOff()) {
+ if (simcall->issuer->host->is_off()) {
simcall->issuer->context->iwannadie = 1;
}
/* execute the on_exit functions */
SIMIX_process_on_exit_runall(arg);
/* Add the process to the list of process to restart, only if the host is down */
- if (arg->auto_restart && arg->host->isOff()) {
+ if (arg->auto_restart && arg->host->is_off()) {
SIMIX_host_add_auto_restart_process(arg->host,arg->name,arg->code, arg->data,
sg_host_get_name(arg->host),
SIMIX_timer_get_date(arg->kill_timer),
XBT_DEBUG("Start process %s on host '%s'", name, hostname);
- if (host->isOff()) {
+ if (host->is_off()) {
int i;
XBT_WARN("Cannot launch process '%s' on failed host '%s'", name,
hostname);
sg_host_t host = process->host;
/* check if the host is active */
- if (host->isOff()) {
+ if (host->is_off()) {
THROWF(host_error, 0, "Host %s failed, you cannot call this function",
sg_host_get_name(host));
}
THROW_IMPOSSIBLE;
break;
}
- if (simcall->issuer->host->isOff()) {
+ if (simcall->issuer->host->is_off()) {
simcall->issuer->context->iwannadie = 1;
}
simcall_process_sleep__set__result(simcall, state);
double previous_energy = this->total_energy;
double instantaneous_consumption;
- if (host->isOff())
+ if (host->is_off())
instantaneous_consumption = this->watts_off;
else
instantaneous_consumption = this->getCurrentWattsValue(cpu_load);
{
initWattsRangeList();
- if (host->getProperties() != NULL) {
- char* off_power_str = (char*)xbt_dict_get_or_null(host->getProperties(), "watt_off");
+ if (host->properties() != NULL) {
+ char* off_power_str = (char*)xbt_dict_get_or_null(
+ host->properties(), "watt_off");
if (off_power_str != NULL)
watts_off = atof(off_power_str);
else
/* min_power corresponds to the idle power (cpu load = 0) */
/* max_power is the power consumed at 100% cpu load */
- auto range = power_range_watts_list.at(host->getPState());
+ auto range = power_range_watts_list.at(host->pstate());
double min_power = range.first;
double max_power = range.second;
double power_slope = max_power - min_power;
void HostEnergy::initWattsRangeList()
{
- if (host->getProperties() == NULL)
+ if (host->properties() == NULL)
return;
char* all_power_values_str =
- (char*)xbt_dict_get_or_null(host->getProperties(), "watt_per_state");
+ (char*)xbt_dict_get_or_null(host->properties(), "watt_per_state");
if (all_power_values_str == NULL)
return;