Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
give simgrid::Host a getState() method, and use it
authorMartin Quinson <martin.quinson@loria.fr>
Thu, 7 Jan 2016 13:52:21 +0000 (14:52 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Thu, 7 Jan 2016 13:52:21 +0000 (14:52 +0100)
include/simgrid/Host.hpp
src/include/surf/surf.h
src/simgrid/host.cpp
src/simix/smx_host.cpp
src/simix/smx_io.cpp
src/simix/smx_network.cpp
src/simix/smx_process.cpp
src/simix/smx_vm.cpp
src/surf/virtual_machine.hpp
src/surf/vm_hl13.hpp

index 0460df6..fb2a509 100644 (file)
@@ -40,6 +40,7 @@ public:
   simgrid::xbt::string const& getName() const { return name_; }
   void on();
   void off();
+  e_surf_resource_state_t getState();
   xbt_dict_t getProperties();
   xbt_swag_t getProcessList();
   double getCurrentPowerPeak();
index cf58fce..6d3265f 100644 (file)
@@ -305,11 +305,6 @@ XBT_PUBLIC(xbt_dict_t) sg_host_get_properties(sg_host_t host);
 /** @brief Get the state of a surf resource (cpu, host, network, …) */
 XBT_PUBLIC(e_surf_resource_state_t) surf_resource_get_state(surf_cpp_resource_t resource);
 
-static XBT_INLINE e_surf_resource_state_t surf_host_get_state(surf_host_t host) {
-       return surf_resource_get_state((surf_cpp_resource_t)host);
-}
-
-
 /** @brief Set the state of a surf resource (cpu, host, network, …) */
 XBT_PUBLIC(void) surf_resource_set_state(surf_cpp_resource_t resource, e_surf_resource_state_t state);
 static inline void surf_host_set_state(surf_host_t host, e_surf_resource_state_t state) {
index df6a15b..7f8881b 100644 (file)
@@ -138,7 +138,7 @@ double sg_host_get_available_speed(sg_host_t host){
  *  @return 1 if the host is active or 0 if it has crashed.
  */
 int sg_host_get_state(sg_host_t host) {
-       return surf_host_get_state(surf_host_resource_priv(host));
+       return host->p_cpu->getState();
 }
 
 /** @brief Returns the total energy consumed by the host (in Joules).
@@ -190,6 +190,11 @@ void Host::off()
   simgrid::simix::simcall<void>(SIMCALL_HOST_OFF, this);
 }
 
+e_surf_resource_state_t Host::getState() {
+  return p_cpu->getState();
+}
+
+
 /** Get the properties assigned to a host */
 xbt_dict_t Host::getProperties()
 {
index 5139c62..71bf7a5 100644 (file)
@@ -43,7 +43,7 @@ void SIMIX_host_on(sg_host_t h)
 
   xbt_assert((host != NULL), "Invalid parameters");
 
-  if (surf_host_get_state(surf_host_resource_priv(h))==SURF_RESOURCE_OFF) {
+  if (h->getState()==SURF_RESOURCE_OFF) {
     surf_host_set_state(surf_host_resource_priv(h), SURF_RESOURCE_ON);
 
     unsigned int cpt;
@@ -96,7 +96,7 @@ void SIMIX_host_off(sg_host_t h, smx_process_t issuer)
 
   xbt_assert((host != NULL), "Invalid parameters");
 
-  if (surf_host_get_state(surf_host_resource_priv(h))==SURF_RESOURCE_ON) {
+  if (h->getState()==SURF_RESOURCE_ON) {
        surf_host_set_state(surf_host_resource_priv(h), SURF_RESOURCE_OFF);
 
     /* Clean Simulator data */
@@ -499,7 +499,7 @@ void SIMIX_execution_finish(smx_synchro_t synchro)
             (int)synchro->state);
     }
     /* check if the host is down */
-    if (surf_host_get_state(surf_host_resource_priv(simcall->issuer->host)) != SURF_RESOURCE_ON) {
+    if (simcall->issuer->host->getState() != SURF_RESOURCE_ON) {
       simcall->issuer->context->iwannadie = 1;
     }
 
@@ -517,7 +517,7 @@ void SIMIX_post_host_execute(smx_synchro_t synchro)
 {
   if (synchro->type == SIMIX_SYNC_EXECUTE && /* FIMXE: handle resource failure
                                                * for parallel tasks too */
-      surf_host_get_state(surf_host_resource_priv(synchro->execution.host)) == SURF_RESOURCE_OFF) {
+      synchro->execution.host->getState() == SURF_RESOURCE_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;
index 146a80a..9bac80e 100644 (file)
@@ -61,7 +61,7 @@ smx_synchro_t SIMIX_file_read(smx_file_t fd, sg_size_t size, sg_host_t host)
   smx_synchro_t synchro;
 
   /* check if the host is active */
-  if (surf_host_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
+  if (host->getState() != SURF_RESOURCE_ON) {
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
            sg_host_get_name(host));
   }
@@ -93,7 +93,7 @@ smx_synchro_t SIMIX_file_write(smx_file_t fd, sg_size_t size, sg_host_t host)
   smx_synchro_t synchro;
 
   /* check if the host is active */
-  if (surf_host_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
+  if (host->getState() != SURF_RESOURCE_ON) {
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
            sg_host_get_name(host));
   }
@@ -125,7 +125,7 @@ smx_synchro_t SIMIX_file_open(const char* fullpath, sg_host_t host)
   smx_synchro_t synchro;
 
   /* check if the host is active */
-  if (surf_host_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
+  if (host->getState() != SURF_RESOURCE_ON) {
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
            sg_host_get_name(host));
   }
@@ -157,7 +157,7 @@ smx_synchro_t SIMIX_file_close(smx_file_t fd, sg_host_t host)
   smx_synchro_t synchro;
 
   /* check if the host is active */
-  if (surf_host_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
+  if (host->getState() != SURF_RESOURCE_ON) {
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
            sg_host_get_name(host));
   }
@@ -181,7 +181,7 @@ smx_synchro_t SIMIX_file_close(smx_file_t fd, sg_host_t host)
 int SIMIX_file_unlink(smx_file_t fd, sg_host_t host)
 {
   /* check if the host is active */
-  if (surf_host_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
+  if (host->getState() != SURF_RESOURCE_ON) {
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
            sg_host_get_name(host));
   }
@@ -373,7 +373,7 @@ void SIMIX_io_finish(smx_synchro_t synchro)
             (int)synchro->state);
     }
 
-    if (surf_host_get_state(surf_host_resource_priv(simcall->issuer->host)) != SURF_RESOURCE_ON) {
+    if (simcall->issuer->host->getState() != SURF_RESOURCE_ON) {
       simcall->issuer->context->iwannadie = 1;
     }
 
index d808503..21d5890 100644 (file)
@@ -792,8 +792,7 @@ void SIMIX_comm_finish(smx_synchro_t synchro)
 
     /* Check out for errors */
 
-    if (surf_host_get_state(surf_host_resource_priv(
-          simcall->issuer->host)) != SURF_RESOURCE_ON) {
+    if (simcall->issuer->host->getState() != SURF_RESOURCE_ON) {
       simcall->issuer->context->iwannadie = 1;
       SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed");
     } else
@@ -871,7 +870,7 @@ void SIMIX_comm_finish(smx_synchro_t synchro)
       }
     }
 
-    if (surf_host_get_state(surf_host_resource_priv(simcall->issuer->host)) != SURF_RESOURCE_ON) {
+    if (simcall->issuer->host->getState() != SURF_RESOURCE_ON) {
       simcall->issuer->context->iwannadie = 1;
     }
 
index 3f74714..891f989 100644 (file)
@@ -770,7 +770,7 @@ smx_synchro_t SIMIX_process_sleep(smx_process_t process, double duration)
   sg_host_t host = process->host;
 
   /* check if the host is active */
-  if (surf_host_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
+  if (host->getState() != SURF_RESOURCE_ON) {
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
            sg_host_get_name(host));
   }
@@ -812,7 +812,7 @@ void SIMIX_post_process_sleep(smx_synchro_t synchro)
         THROW_IMPOSSIBLE;
         break;
     }
-    if (surf_host_get_state(surf_host_resource_priv(simcall->issuer->host)) != SURF_RESOURCE_ON) {
+    if (simcall->issuer->host->getState() != SURF_RESOURCE_ON) {
       simcall->issuer->context->iwannadie = 1;
     }
     simcall_process_sleep__set__result(simcall, state);
index 6751a1b..ae74934 100644 (file)
@@ -9,6 +9,7 @@
 #include "xbt/log.h"
 #include "xbt/dict.h"
 #include "mc/mc.h"
+#include "src/surf/host_interface.hpp"
 
 //If you need to log some stuffs, just uncomment these two lines and uses XBT_DEBUG for instance
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_vm, simix, "Logging specific to SIMIX (vms)");
@@ -100,7 +101,7 @@ void SIMIX_vm_start(sg_host_t ind_vm)
 
 int SIMIX_vm_get_state(sg_host_t ind_vm)
 {
-  return surf_host_get_state(surf_host_resource_priv(ind_vm));
+  return surf_host_resource_priv(ind_vm)->getState();
 }
 
 /**
index fff482a..c943946 100644 (file)
@@ -68,7 +68,7 @@ public:
   /** @brief Destructor */
   ~VirtualMachine();
 
-  void setState(e_surf_resource_state_t state);
+  void setState(e_surf_resource_state_t state) override;
 
   /** @brief Suspend the VM */
   virtual void suspend()=0;
index aba2143..df67e4f 100644 (file)
@@ -61,8 +61,8 @@ public:
 
   void migrate(sg_host_t ind_dst_pm) override;
 
-  e_surf_resource_state_t getState();
-  void setState(e_surf_resource_state_t state);
+  e_surf_resource_state_t getState() override;
+  void setState(e_surf_resource_state_t state) override;
 
   void setBound(double bound);
   void setAffinity(Cpu *cpu, unsigned long mask);