Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[simix] Move other simcall to the Host class
authorGabriel Corona <gabriel.corona@loria.fr>
Tue, 5 Jan 2016 13:21:18 +0000 (14:21 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Tue, 5 Jan 2016 14:41:23 +0000 (15:41 +0100)
include/simgrid/Host.hpp
include/simgrid/simix.h
src/msg/msg_host.cpp
src/msg/msg_io.cpp
src/msg/msg_vm.cpp
src/s4u/s4u_host.cpp
src/simgrid/host.cpp
src/simix/libsmx.cpp

index d8d68c8..0460df6 100644 (file)
 #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 {
 
@@ -37,6 +40,18 @@ public:
   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);
 };
index b94dec0..2a38a26 100644 (file)
@@ -255,7 +255,6 @@ XBT_PUBLIC(void) simcall_call(smx_process_t process);
 /* 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);
index 06716bb..4182933 100644 (file)
@@ -238,8 +238,7 @@ int MSG_host_get_core_number(msg_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();
 }
 
 
@@ -264,8 +263,7 @@ const char *MSG_host_get_property_value(msg_host_t host, const char *name)
 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
@@ -316,7 +314,7 @@ int MSG_host_is_off(msg_host_t host)
  */
 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
@@ -327,7 +325,7 @@ void MSG_host_set_params(msg_host_t host, vm_params_t params)
  */
 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
@@ -339,7 +337,7 @@ void MSG_host_get_params(msg_host_t host, vm_params_t params)
  */
 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
@@ -350,7 +348,7 @@ double MSG_host_get_power_peak_at(msg_host_t host, int pstate_index) {
  */
 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
@@ -370,8 +368,7 @@ int MSG_host_get_nb_pstates(msg_host_t host) {
  */
 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.
@@ -397,14 +394,14 @@ double MSG_host_get_consumed_energy(msg_host_t host) {
  *
  */
 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
@@ -415,7 +412,7 @@ double MSG_host_get_wattmax_at(msg_host_t host, int pstate){
 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
@@ -426,7 +423,7 @@ xbt_dict_t MSG_host_get_mounted_storage_list(msg_host_t host)
 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
@@ -443,7 +440,7 @@ xbt_dict_t MSG_host_get_storage_content(msg_host_t host)
   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);
index 77f06e8..6ac73c6 100644 (file)
@@ -343,7 +343,7 @@ msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpa
   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);
index 836b25d..34abb09 100644 (file)
@@ -46,8 +46,7 @@ const char *MSG_vm_get_property_value(msg_vm_t vm, const char *name)
 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
@@ -195,7 +194,7 @@ msg_vm_t MSG_vm_create(msg_host_t pm, const char *name,
   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, &params);
+  vm->setParams(&params);
 
   return vm;
 }
@@ -360,7 +359,7 @@ static int migration_rx_fun(int argc, char *argv[])
   struct migration_session *ms = (migration_session *) MSG_process_get_data(MSG_process_self());
 
   s_vm_params_t params;
-  simcall_host_get_params(ms->vm, &params);
+  ms->vm->getParams(&params);
 
   int need_exit = 0;
 
@@ -689,7 +688,7 @@ static int migration_tx_fun(int argc, char *argv[])
     (migration_session *) MSG_process_get_data(MSG_process_self());
 
   s_vm_params_t params;
-  simcall_host_get_params(ms->vm, &params);
+  ms->vm->getParams(&params);
   const sg_size_t ramsize   = params.ramsize;
   const sg_size_t devsize   = params.devsize;
   const int skip_stage1     = params.skip_stage1;
index f075483..527dc29 100644 (file)
@@ -66,7 +66,7 @@ boost::unordered_map<std::string, Storage&> &Host::mountedStorages() {
        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;
index 2f70c60..5e1656f 100644 (file)
@@ -190,6 +190,32 @@ void Host::off()
   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);
@@ -214,4 +240,59 @@ Host* Host::by_name_or_create(const char* name)
   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
+  ));
+}
+
 }
index f6d5d73..18ff330 100644 (file)
@@ -39,101 +39,97 @@ void simcall_call(smx_process_t process)
   }
 }
 
-/**
- * \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
@@ -365,16 +361,6 @@ void simcall_vm_set_affinity(sg_host_t vm, sg_host_t pm, unsigned long mask)
   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
@@ -1335,32 +1321,6 @@ sg_size_t simcall_storage_get_used_size (smx_storage_t storage){
   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.