Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
less void*, new type: surf_host_t
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 12 Jul 2015 21:30:05 +0000 (23:30 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 12 Jul 2015 21:53:14 +0000 (23:53 +0200)
Plus some small cosmetics

src/include/surf/surf.h
src/simdag/sd_workstation.c
src/simix/smx_host.c
src/simix/smx_io.c
src/simix/smx_network.c
src/simix/smx_process.c
src/simix/smx_vm.c
src/surf/storage_interface.hpp
teshsuite/surf/surf_usage/surf_usage.c
teshsuite/surf/surf_usage/surf_usage2.c

index 98b848f..32dc7ad 100644 (file)
@@ -53,6 +53,7 @@ class NetworkModel;
 class StorageModel;
 class Resource;
 class ResourceLmm;
+class Host;
 class HostCLM03;
 class NetworkCm02Link;
 class Cpu;
@@ -72,6 +73,7 @@ typedef struct StorageModel StorageModel;
 typedef struct Resource Resource;
 typedef struct ResourceLmm ResourceLmm;
 typedef struct HostCLM03 HostCLM03;
+typedef struct Host Host;
 typedef struct NetworkCm02Link NetworkCm02Link;
 typedef struct Cpu Cpu;
 typedef struct Action Action;
@@ -98,6 +100,7 @@ typedef StorageModel *surf_storage_model_t;
 
 typedef xbt_dictelm_t surf_resource_t;
 typedef Resource *surf_cpp_resource_t;
+typedef Host *surf_host_t;
 typedef HostCLM03 *surf_host_CLM03_t;
 typedef NetworkCm02Link *surf_network_link_t;
 typedef Cpu *surf_cpu_t;
@@ -183,14 +186,13 @@ typedef enum {
 /* Generic model object */
 /***************************/
 
-//FIXME:REMOVE typedef struct s_routing_platf s_routing_platf_t, *routing_platf_t;
 XBT_PUBLIC_DATA(routing_platf_t) routing_platf;
 
-static inline void *surf_cpu_resource_priv(const void *host) {
-  return xbt_lib_get_level((xbt_dictelm_t)host, SURF_CPU_LEVEL);
+static inline surf_cpu_t surf_cpu_resource_priv(const void *host) {
+  return (surf_cpu_t)xbt_lib_get_level((xbt_dictelm_t)host, SURF_CPU_LEVEL);
 }
-static inline void *surf_host_resource_priv(const void *host){
-  return (void*)xbt_lib_get_level((xbt_dictelm_t)host, SURF_HOST_LEVEL);
+static inline surf_host_t surf_host_resource_priv(const void *host){
+  return (surf_host_t) xbt_lib_get_level((xbt_dictelm_t)host, SURF_HOST_LEVEL);
 }
 static inline void *surf_routing_resource_priv(const void *host){
   return (void*)xbt_lib_get_level((xbt_dictelm_t)host, ROUTING_HOST_LEVEL);
@@ -334,6 +336,9 @@ XBT_PUBLIC(surf_action_t) surf_network_model_communicate(surf_network_model_t mo
  * @return The name of the surf resource
  */
 XBT_PUBLIC(const char * ) surf_resource_name(surf_cpp_resource_t resource);
+static inline const char * surf_cpu_name(surf_cpu_t cpu) {
+       return surf_resource_name((surf_cpp_resource_t)cpu);
+}
 
 /**
  * @brief Get the properties of a surf resource (cpu, host, network, …)
@@ -342,6 +347,10 @@ XBT_PUBLIC(const char * ) surf_resource_name(surf_cpp_resource_t resource);
  * @return The properties of the surf resource
  */
 XBT_PUBLIC(xbt_dict_t) surf_resource_get_properties(surf_cpp_resource_t resource);
+static XBT_INLINE xbt_dict_t surf_host_get_properties(surf_host_t host) {
+       return surf_resource_get_properties((surf_cpp_resource_t)host);
+}
+
 
 /**
  * @brief Get the state of a surf resource (cpu, host, network, …)
@@ -351,6 +360,11 @@ XBT_PUBLIC(xbt_dict_t) surf_resource_get_properties(surf_cpp_resource_t resource
  */
 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, …)
  *
@@ -358,6 +372,9 @@ XBT_PUBLIC(e_surf_resource_state_t) surf_resource_get_state(surf_cpp_resource_t
  * @param state The new state of the surf resource
  */
 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) {
+       surf_resource_set_state((surf_cpp_resource_t)host, state);
+}
 
 /**
  * @brief Get the speed of the cpu associated to a host
index bcd3285..ac506cc 100644 (file)
@@ -178,7 +178,7 @@ const char *SD_workstation_get_property_value(SD_workstation_t ws,
  */
 xbt_dict_t SD_workstation_get_properties(SD_workstation_t workstation)
 {
-  return surf_resource_get_properties(surf_host_resource_priv(workstation));
+  return surf_host_get_properties(surf_host_resource_priv(workstation));
 }
 
 
index 819b819..628ea05 100644 (file)
@@ -46,8 +46,8 @@ void SIMIX_host_on(smx_host_t h)
 
   xbt_assert((host != NULL), "Invalid parameters");
 
-  if (surf_resource_get_state(surf_host_resource_priv(h))==SURF_RESOURCE_OFF) {
-    surf_resource_set_state(surf_host_resource_priv(h), SURF_RESOURCE_ON);
+  if (surf_host_get_state(surf_host_resource_priv(h))==SURF_RESOURCE_OFF) {
+    surf_host_set_state(surf_host_resource_priv(h), SURF_RESOURCE_ON);
 
     unsigned int cpt;
     smx_process_arg_t arg;
@@ -102,8 +102,8 @@ void SIMIX_host_off(smx_host_t h, smx_process_t issuer)
 
   xbt_assert((host != NULL), "Invalid parameters");
 
-  if (surf_resource_get_state(surf_host_resource_priv(h))==SURF_RESOURCE_ON) {
-       surf_resource_set_state(surf_host_resource_priv(h), SURF_RESOURCE_OFF);
+  if (surf_host_get_state(surf_host_resource_priv(h))==SURF_RESOURCE_ON) {
+       surf_host_set_state(surf_host_resource_priv(h), SURF_RESOURCE_OFF);
 
     /* Clean Simulator data */
     if (xbt_swag_size(host->process_list) != 0) {
@@ -176,7 +176,7 @@ const char* SIMIX_host_self_get_name(void)
 }
 
 xbt_dict_t SIMIX_host_get_properties(smx_host_t host){
-  return surf_resource_get_properties(surf_host_resource_priv(host));
+  return surf_host_get_properties(surf_host_resource_priv(host));
 }
 
 double SIMIX_host_get_speed(smx_host_t host){
@@ -229,7 +229,7 @@ double SIMIX_host_get_wattmax_at(smx_host_t host,int pstate) {
 }
 
 int SIMIX_host_get_state(smx_host_t host){
-  return surf_resource_get_state(surf_host_resource_priv(host));
+  return surf_host_get_state(surf_host_resource_priv(host));
 }
 
 void _SIMIX_host_free_process_arg(void *data)
@@ -546,7 +546,7 @@ void SIMIX_execution_finish(smx_synchro_t synchro)
             (int)synchro->state);
     }
     /* check if the host is down */
-    if (surf_resource_get_state(surf_host_resource_priv(simcall->issuer->smx_host)) != SURF_RESOURCE_ON) {
+    if (surf_host_get_state(surf_host_resource_priv(simcall->issuer->smx_host)) != SURF_RESOURCE_ON) {
       simcall->issuer->context->iwannadie = 1;
     }
 
@@ -564,7 +564,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_resource_get_state(surf_host_resource_priv(synchro->execution.host)) == SURF_RESOURCE_OFF) {
+      surf_host_get_state(surf_host_resource_priv(synchro->execution.host)) == 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 0dce9cb..5800ceb 100644 (file)
@@ -62,7 +62,7 @@ smx_synchro_t SIMIX_file_read(smx_file_t fd, sg_size_t size, smx_host_t host)
   smx_synchro_t synchro;
 
   /* check if the host is active */
-  if (surf_resource_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
+  if (surf_host_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
            sg_host_name(host));
   }
@@ -94,7 +94,7 @@ smx_synchro_t SIMIX_file_write(smx_file_t fd, sg_size_t size, smx_host_t host)
   smx_synchro_t synchro;
 
   /* check if the host is active */
-  if (surf_resource_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
+  if (surf_host_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
            sg_host_name(host));
   }
@@ -126,7 +126,7 @@ smx_synchro_t SIMIX_file_open(const char* fullpath, smx_host_t host)
   smx_synchro_t synchro;
 
   /* check if the host is active */
-  if (surf_resource_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
+  if (surf_host_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
            sg_host_name(host));
   }
@@ -158,7 +158,7 @@ smx_synchro_t SIMIX_file_close(smx_file_t fd, smx_host_t host)
   smx_synchro_t synchro;
 
   /* check if the host is active */
-  if (surf_resource_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
+  if (surf_host_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
            sg_host_name(host));
   }
@@ -182,7 +182,7 @@ smx_synchro_t SIMIX_file_close(smx_file_t fd, smx_host_t host)
 int SIMIX_file_unlink(smx_file_t fd, smx_host_t host)
 {
   /* check if the host is active */
-  if (surf_resource_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
+  if (surf_host_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
            sg_host_name(host));
   }
@@ -375,7 +375,7 @@ void SIMIX_io_finish(smx_synchro_t synchro)
             (int)synchro->state);
     }
 
-    if (surf_resource_get_state(surf_host_resource_priv(simcall->issuer->smx_host)) != SURF_RESOURCE_ON) {
+    if (surf_host_get_state(surf_host_resource_priv(simcall->issuer->smx_host)) != SURF_RESOURCE_ON) {
       simcall->issuer->context->iwannadie = 1;
     }
 
index 6cc1114..a671d9f 100644 (file)
@@ -800,7 +800,7 @@ void SIMIX_comm_finish(smx_synchro_t synchro)
 
     /* Check out for errors */
 
-    if (surf_resource_get_state(surf_host_resource_priv(
+    if (surf_host_get_state(surf_host_resource_priv(
           simcall->issuer->smx_host)) != SURF_RESOURCE_ON) {
       simcall->issuer->context->iwannadie = 1;
       SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed");
@@ -879,7 +879,7 @@ void SIMIX_comm_finish(smx_synchro_t synchro)
       }
     }
 
-    if (surf_resource_get_state(surf_host_resource_priv(simcall->issuer->smx_host)) != SURF_RESOURCE_ON) {
+    if (surf_host_get_state(surf_host_resource_priv(simcall->issuer->smx_host)) != SURF_RESOURCE_ON) {
       simcall->issuer->context->iwannadie = 1;
     }
 
index 2fcb6d6..f91a7a2 100644 (file)
@@ -746,7 +746,7 @@ smx_synchro_t SIMIX_process_sleep(smx_process_t process, double duration)
   smx_host_t host = process->smx_host;
 
   /* check if the host is active */
-  if (surf_resource_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
+  if (surf_host_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
            sg_host_name(host));
   }
@@ -788,7 +788,7 @@ void SIMIX_post_process_sleep(smx_synchro_t synchro)
         THROW_IMPOSSIBLE;
         break;
     }
-    if (surf_resource_get_state(surf_host_resource_priv(simcall->issuer->smx_host)) != SURF_RESOURCE_ON) {
+    if (surf_host_get_state(surf_host_resource_priv(simcall->issuer->smx_host)) != SURF_RESOURCE_ON) {
       simcall->issuer->context->iwannadie = 1;
     }
     simcall_process_sleep__set__result(simcall, state);
index 5dd21c4..0ee280f 100644 (file)
@@ -90,7 +90,7 @@ static int __can_be_started(smx_host_t vm)
 void SIMIX_vm_start(smx_host_t ind_vm)
 {
   if (__can_be_started(ind_vm))
-    surf_resource_set_state(surf_host_resource_priv(ind_vm),
+    surf_host_set_state(surf_host_resource_priv(ind_vm),
                             (int)SURF_VM_STATE_RUNNING);
   else
     THROWF(vm_error, 0, "The VM %s cannot be started", SIMIX_host_get_name(ind_vm));
@@ -99,7 +99,7 @@ void SIMIX_vm_start(smx_host_t ind_vm)
 
 int SIMIX_vm_get_state(smx_host_t ind_vm)
 {
-  return surf_resource_get_state(surf_host_resource_priv(ind_vm));
+  return surf_host_get_state(surf_host_resource_priv(ind_vm));
 }
 
 /**
@@ -342,7 +342,7 @@ void SIMIX_vm_shutdown(smx_host_t ind_vm, smx_process_t issuer)
   }
 
   /* FIXME: we may have to do something at the surf layer, e.g., vcpu action */
-  surf_resource_set_state(surf_host_resource_priv(ind_vm),
+  surf_host_set_state(surf_host_resource_priv(ind_vm),
                           (int)SURF_VM_STATE_CREATED);
 }
 
index c578bff..56cd226 100644 (file)
@@ -21,12 +21,6 @@ typedef StorageModel *StorageModelPtr;
 class Storage;
 typedef Storage *StoragePtr;
 
-class Storage;
-typedef Storage *StoragePtr;
-
-class StorageAction;
-typedef StorageAction *StorageActionPtr;
-
 class StorageAction;
 typedef StorageAction *StorageActionPtr;
 
index 45cb3ef..f6e335e 100644 (file)
@@ -13,7 +13,6 @@
 #include <stdio.h>
 #include "simgrid/sg_config.h"
 #include "surf/surf.h"
-#include "surf/surf_resource.h"
 #include "surf/surfxml_parse.h" // for reset callback
 
 #include "xbt/log.h"
@@ -63,8 +62,8 @@ void test(char *platform)
   cpuB = surf_cpu_resource_by_name("Cpu B");
 
   /* Let's check that those two processors exist */
-  XBT_DEBUG("%s : %p", surf_resource_name(surf_cpu_resource_priv(cpuA)), cpuA);
-  XBT_DEBUG("%s : %p", surf_resource_name(surf_cpu_resource_priv(cpuB)), cpuB);
+  XBT_DEBUG("%s : %p", surf_cpu_name(surf_cpu_resource_priv(cpuA)), cpuA);
+  XBT_DEBUG("%s : %p", surf_cpu_name(surf_cpu_resource_priv(cpuB)), cpuB);
 
   /* Let's do something on it */
   actionA = surf_cpu_execute(cpuA, 1000.0);
index 9f83171..dbb1c6a 100644 (file)
@@ -13,7 +13,6 @@
 #include <stdio.h>
 #include "simgrid/sg_config.h"
 #include "surf/surf.h"
-#include "surf/surf_resource.h"
 #include "surf/surfxml_parse.h" // for reset callback
 
 #include "xbt/log.h"