#include <vector>
#include <xbt/base.h>
+#include <xbt/dict.h>
+#include <xbt/swag.h>
#include <xbt/string.hpp>
#include <xbt/Extendable.hpp>
+#include <simgrid/datatypes.h>
namespace simgrid {
simgrid::xbt::string const& getName() const { return name_; }
void on();
void off();
+ xbt_dict_t getProperties();
+ xbt_swag_t getProcessList();
+ double getCurrentPowerPeak();
+ double getPowerPeakAt(int pstate_index);
+ void setPstate(int pstate_index);
+ double getWattMinAt(int pstate);
+ double getWattMaxAt(int pstate);
+ void getParams(vm_params_t params);
+ void setParams(vm_params_t params);
+ xbt_dict_t getMountedStorageList();
+ xbt_dynar_t getAttachedStorageList();
+
static Host* by_name_or_null(const char* name);
static Host* by_name_or_create(const char* name);
};
/* TODO use handlers and keep sg_host_t hidden from higher levels */
XBT_PUBLIC(xbt_dict_t) simcall_host_get_properties(sg_host_t host);
XBT_PUBLIC(xbt_swag_t) simcall_host_get_process_list(sg_host_t host);
-
XBT_PUBLIC(void) simcall_host_set_data(sg_host_t host, void *data);
XBT_PUBLIC(double) simcall_host_get_current_power_peak(sg_host_t host);
xbt_swag_t MSG_host_get_process_list(msg_host_t host)
{
xbt_assert((host != NULL), "Invalid parameters");
-
- return (simcall_host_get_process_list(host));
+ return host->getProcessList();
}
xbt_dict_t MSG_host_get_properties(msg_host_t host)
{
xbt_assert((host != NULL), "Invalid parameters (host is NULL)");
-
- return (simcall_host_get_properties(host));
+ return host->getProperties();
}
/** \ingroup m_host_management
*/
void MSG_host_set_params(msg_host_t host, vm_params_t params)
{
- simcall_host_set_params(host, params);
+ host->setParams(params);
}
/** \ingroup m_host_management
*/
void MSG_host_get_params(msg_host_t host, vm_params_t params)
{
- simcall_host_get_params(host, params);
+ host->getParams(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 (simcall_host_get_power_peak_at(host, pstate_index));
+ return host->getPowerPeakAt(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 simcall_host_get_current_power_peak(host);
+ return host->getCurrentPowerPeak();
}
/** \ingroup m_host_management
*/
void MSG_host_set_pstate(msg_host_t host, int pstate_index) {
xbt_assert((host != NULL), "Invalid parameters (host is NULL)");
-
- simcall_host_set_pstate(host, pstate_index);
+ host->setPstate(pstate_index);
}
/** \ingroup m_host_management
* \brief Gets the pstate at which the given host is currently running. See also @ref SURF_plugin_energy.
*
*/
double MSG_host_get_wattmin_at(msg_host_t host, int pstate){
- return simcall_host_get_wattmin_at(host, pstate);
+ return host->getWattMinAt(pstate);
}
/** \ingroup m_host_management
* \brief Returns the amount of watt dissipated at the given pstate when the host burns CPU at 100%
*
*/
double MSG_host_get_wattmax_at(msg_host_t host, int pstate){
- return simcall_host_get_wattmax_at(host, pstate);
+ return host->getWattMaxAt(pstate);
}
/** \ingroup m_host_management
xbt_dict_t MSG_host_get_mounted_storage_list(msg_host_t host)
{
xbt_assert((host != NULL), "Invalid parameters");
- return (simcall_host_get_mounted_storage_list(host));
+ return host->getMountedStorageList();
}
/** \ingroup m_host_management
xbt_dynar_t MSG_host_get_attached_storage_list(msg_host_t host)
{
xbt_assert((host != NULL), "Invalid parameters");
- return (simcall_host_get_attached_storage_list(host));
+ return host->getAttachedStorageList();
}
/** \ingroup m_host_management
char* mount_name;
xbt_dict_cursor_t cursor = NULL;
- xbt_dict_t storage_list = simcall_host_get_mounted_storage_list(host);
+ xbt_dict_t storage_list = host->getMountedStorageList();
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 = simcall_host_get_mounted_storage_list(host);
+ xbt_dict_t storage_list = host->getMountedStorageList();
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 (simcall_host_get_properties(vm));
+ return vm->getProperties();
}
/** \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);
- simcall_host_set_params(vm, ¶ms);
+ vm->setParams(¶ms);
return vm;
}
struct migration_session *ms = (migration_session *) MSG_process_get_data(MSG_process_self());
s_vm_params_t params;
- simcall_host_get_params(ms->vm, ¶ms);
+ ms->vm->getParams(¶ms);
int need_exit = 0;
(migration_session *) MSG_process_get_data(MSG_process_self());
s_vm_params_t params;
- simcall_host_get_params(ms->vm, ¶ms);
+ ms->vm->getParams(¶ms);
const sg_size_t ramsize = params.ramsize;
const sg_size_t devsize = params.devsize;
const int skip_stage1 = params.skip_stage1;
if (mounts == NULL) {
mounts = new boost::unordered_map<std::string, Storage&> ();
- xbt_dict_t dict = simcall_host_get_mounted_storage_list(p_inferior);
+ xbt_dict_t dict = p_inferior->getMountedStorageList();
xbt_dict_cursor_t cursor;
char *mountname;
simgrid::simix::simcall<void>(SIMCALL_HOST_OFF, this);
}
+/** Get the properties assigned to a host */
+xbt_dict_t Host::getProperties()
+{
+ return simgrid::simix::kernel(std::bind(SIMIX_host_get_properties, this));
+}
+
+/** Get the processes attached to the host */
+xbt_swag_t Host::getProcessList()
+{
+ return simgrid::simix::kernel(std::bind(SIMIX_host_get_process_list, this));
+}
+
+/** Get the peak power of a host */
+double Host::getCurrentPowerPeak()
+{
+ return simgrid::simix::kernel(
+ std::bind(SIMIX_host_get_current_power_peak, this));
+}
+
+/** Get one power peak (in flops/s) of a host at a given pstate */
+double Host::getPowerPeakAt(int pstate_index)
+{
+ return simgrid::simix::kernel(
+ std::bind(SIMIX_host_get_power_peak_at, this, pstate_index));
+}
+
/** @brief Get the speed of the cpu associated to a host */
double Host::getSpeed() {
return p_cpu->getSpeed(1.0);
return host;
}
+/** Set the pstate at which the host should run */
+void Host::setPstate(int pstate_index)
+{
+ simgrid::simix::kernel(
+ std::bind(SIMIX_host_set_pstate, this, pstate_index));
+}
+
+/** Get the amount of watt dissipated at the given pstate when the host is idling */
+double Host::getWattMinAt(int pstate)
+{
+ return simgrid::simix::kernel(
+ std::bind(SIMIX_host_get_wattmin_at, this, pstate));
+}
+
+/** Get the amount of watt dissipated at the given pstate when the host burns CPU at 100% */
+double Host::getWattMaxAt(int pstate)
+{
+ return simgrid::simix::kernel(
+ std::bind(SIMIX_host_get_wattmax_at, this, pstate));
+}
+
+void Host::getParams(vm_params_t params)
+{
+ simgrid::simix::kernel(std::bind(SIMIX_host_get_params, this, params));
+}
+
+void Host::setParams(vm_params_t params)
+{
+ simgrid::simix::kernel(std::bind(SIMIX_host_set_params, this, params));
+}
+
+/**
+ * \ingroup simix_storage_management
+ * \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()
+{
+ return simgrid::simix::kernel(std::bind(
+ SIMIX_host_get_mounted_storage_list, this
+ ));
+}
+
+/**
+ * \ingroup simix_storage_management
+ * \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()
+{
+ return simgrid::simix::kernel(std::bind(
+ SIMIX_host_get_attached_storage_list, this
+ ));
+}
+
}
}
}
-/**
- * \ingroup simix_host_management
- * \brief Returns a dict of the properties assigned to a host.
- *
- * \param host A host
- * \return The properties of this host
- */
-xbt_dict_t simcall_host_get_properties(sg_host_t host)
-{
- return simgrid::simix::kernel(std::bind(SIMIX_host_get_properties, host));
-}
+// ***** Host simcalls
+// Those functions are replaced by methods on the Host object.
-/**
- * \ingroup simix_host_management
- * \brief Returns a dict of the properties assigned to a router or AS.
- *
- * \param name The name of the router or AS
- * \return The properties
- */
-xbt_dict_t simcall_asr_get_properties(const char *name)
+/** \ingroup simix_host_management
+ * \deprecated */
+xbt_dict_t simcall_host_get_properties(sg_host_t host)
{
- return simcall_BODY_asr_get_properties(name);
+ return host->getProperties();
}
-/**
- * \ingroup simix_host_management
- * \brief Returns the list of processes attached to the host.
- *
- * \param host A SIMIX host
- * \return the swag of attached processes
- */
+/** \ingroup simix_host_management
+ * \deprecated */
xbt_swag_t simcall_host_get_process_list(sg_host_t host)
{
- return simgrid::simix::kernel(std::bind(SIMIX_host_get_process_list, host));
+ return host->getProcessList();
}
-/**
- * \ingroup simix_host_management
- * \brief Returns the power peak of a host.
- *
- * \param host A SIMIX host
- * \return the current power peak value (double)
- */
+/** \ingroup simix_host_management
+ * \deprecated */
double simcall_host_get_current_power_peak(sg_host_t host)
{
- return simgrid::simix::kernel(
- std::bind(SIMIX_host_get_current_power_peak, host));
+ return host->getCurrentPowerPeak();
}
-/**
- * \ingroup simix_host_management
- * \brief Returns one power peak (in flops/s) of a host at a given pstate
- *
- * \param host A SIMIX host
- * \param pstate_index pstate to test
- * \return the current power peak value (double) for pstate_index
- */
+/** \ingroup simix_host_management
+ * \deprecated */
double simcall_host_get_power_peak_at(sg_host_t host, int pstate_index)
{
- return simgrid::simix::kernel(
- std::bind(SIMIX_host_get_power_peak_at, host, pstate_index));
+ return host->getPowerPeakAt(pstate_index);
}
-/**
- * \ingroup simix_host_management
- * \brief Sets the pstate at which the host should run
- *
- * \param host A SIMIX host
- * \param pstate_index The pstate to which the CPU power will be set
- */
+/** \ingroup simix_host_management
+ * \deprecated */
void simcall_host_set_pstate(sg_host_t host, int pstate_index)
{
- simgrid::simix::kernel(
- std::bind(SIMIX_host_set_pstate, host, pstate_index));
+ host->setPstate(pstate_index);
}
/** \ingroup simix_host_management
- * \brief Returns the amount of watt dissipated at the given pstate when the host is idling
- */
+ * \deprecated */
double simcall_host_get_wattmin_at(msg_host_t host, int pstate)
{
- return simgrid::simix::kernel(
- std::bind(SIMIX_host_get_wattmin_at, host, pstate));
+ return host->getWattMinAt(pstate);
}
/** \ingroup simix_host_management
- * \brief Returns the amount of watt dissipated at the given pstate when the host burns CPU at 100%
- */
+ * \deprecated */
double simcall_host_get_wattmax_at(msg_host_t host, int pstate)
{
- return simgrid::simix::kernel(
- std::bind(SIMIX_host_get_wattmax_at, host, pstate));
+ return host->getWattMaxAt(pstate);
}
+/** \deprecated */
+void simcall_host_get_params(sg_host_t vm, vm_params_t params)
+{
+ vm->getParams(params);
+}
+/** \deprecated */
+void simcall_host_set_params(sg_host_t vm, vm_params_t params)
+{
+ vm->setParams(params);
+}
+
+/** \ingroup simix_storage_management
+ * \deprecated */
+xbt_dict_t simcall_host_get_mounted_storage_list(sg_host_t host)
+{
+ return host->getMountedStorageList();
+}
+
+/** \ingroup simix_storage_management
+ * \deprecated */
+xbt_dynar_t simcall_host_get_attached_storage_list(sg_host_t host)
+{
+ return host->getAttachedStorageList();
+}
+
+// ***** Other simcalls
+
+/**
+ * \ingroup simix_host_management
+ * \brief Returns a dict of the properties assigned to a router or AS.
+ *
+ * \param name The name of the router or AS
+ * \return The properties
+ */
+xbt_dict_t simcall_asr_get_properties(const char *name)
+{
+ return simcall_BODY_asr_get_properties(name);
+}
/**
* \ingroup simix_process_management
simgrid::simix::kernel(std::bind(SIMIX_vm_set_affinity, vm, pm, mask));
}
-void simcall_host_get_params(sg_host_t vm, vm_params_t params)
-{
- simgrid::simix::kernel(std::bind(SIMIX_host_get_params, vm, params));
-}
-
-void simcall_host_set_params(sg_host_t vm, vm_params_t params)
-{
- simgrid::simix::kernel(std::bind(SIMIX_host_set_params, vm, params));
-}
-
/**
* \ingroup simix_vm_management
* \brief Migrate the given VM to the given physical host
return simcall_BODY_storage_get_used_size(storage);
}
-/**
- * \ingroup simix_storage_management
- * \brief Returns the list of storages mounted on an host.
- * \param host A SIMIX host
- * \return a dict containing all storages mounted on the host
- */
-xbt_dict_t simcall_host_get_mounted_storage_list(sg_host_t host)
-{
- return simgrid::simix::kernel(std::bind(
- SIMIX_host_get_mounted_storage_list, host
- ));
-}
-
-/**
- * \ingroup simix_storage_management
- * \brief Returns the list of storages attached to an host.
- * \param host A SIMIX host
- * \return a dict containing all storages attached to the host
- */
-xbt_dynar_t simcall_host_get_attached_storage_list(sg_host_t host)
-{
- return simgrid::simix::kernel(std::bind(
- SIMIX_host_get_attached_storage_list, host
- ));
-}
-
/**
* \ingroup simix_storage_management
* \brief Returns a dict of the properties assigned to a storage element.