Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[SGpp] make SURF_CPU_LEVEL private
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 15 Jul 2015 07:59:34 +0000 (09:59 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 18 Jul 2015 18:07:02 +0000 (20:07 +0200)
25 files changed:
include/simgrid/host.h
include/simgrid/simix.h
include/surf/surf_routing.h
src/bindings/java/surf_swig.cpp
src/include/surf/surf.h
src/simgrid/host.cpp
src/simix/popping_bodies.c
src/simix/popping_generated.c
src/simix/smx_deployment.c
src/simix/smx_global.c
src/simix/smx_host.c
src/simix/smx_process.c
src/simix/smx_vm.c
src/surf/cpu_cas01.cpp
src/surf/cpu_interface.hpp
src/surf/cpu_ti.cpp
src/surf/host_clm03.cpp
src/surf/host_ptask_L07.cpp
src/surf/surf_c_bindings.cpp
src/surf/surf_interface.cpp
src/surf/surf_interface.hpp
src/surf/surf_routing.cpp
src/surf/vm_hl13.cpp
teshsuite/surf/surf_usage/surf_usage.c
teshsuite/surf/surf_usage/surf_usage2.c

index fcee52c..15c66f5 100644 (file)
@@ -8,11 +8,20 @@
 #define SIMGRID_HOST_H_
 
 #include <xbt/dict.h>
 #define SIMGRID_HOST_H_
 
 #include <xbt/dict.h>
-
 SG_BEGIN_DECL()
 
 typedef xbt_dictelm_t sg_host_t;
 SG_BEGIN_DECL()
 
 typedef xbt_dictelm_t sg_host_t;
-
+XBT_PUBLIC(sg_host_t) sg_host_by_name(const char *name);
+static XBT_INLINE char *sg_host_get_name(sg_host_t host){
+       return host->key;
+}
+
+#ifdef __cplusplus
+#define DEFINE_EXTERNAL_CLASS(klass) class klass;
+class Cpu;
+#else
+#define DEFINE_EXTERNAL_CLASS(klass) typedef struct klass klass;
+#endif
 
 // ========== MSG Layer ==============
 typedef struct s_msg_host_priv *msg_host_priv_t;
 
 // ========== MSG Layer ==============
 typedef struct s_msg_host_priv *msg_host_priv_t;
@@ -26,7 +35,16 @@ XBT_PUBLIC(smx_host_priv_t) sg_host_simix(sg_host_t host);
 XBT_PUBLIC(void) sg_host_simix_set(sg_host_t host, smx_host_priv_t priv);
 XBT_PUBLIC(void) sg_host_simix_destroy(sg_host_t host);
 
 XBT_PUBLIC(void) sg_host_simix_set(sg_host_t host, smx_host_priv_t priv);
 XBT_PUBLIC(void) sg_host_simix_destroy(sg_host_t host);
 
-// Module initializer. Won't survive the conversion to C++
+// ========== SURF CPU ============
+DEFINE_EXTERNAL_CLASS(Cpu);
+typedef Cpu *surf_cpu_t;
+typedef Cpu *CpuPtr;
+XBT_PUBLIC(surf_cpu_t) sg_host_surfcpu(sg_host_t host);
+XBT_PUBLIC(void) sg_host_surfcpu_set(sg_host_t host, surf_cpu_t cpu);
+XBT_PUBLIC(void) sg_host_surfcpu_destroy(sg_host_t host);
+
+
+// Module initializer. Won't survive the conversion to C++. Hopefully.
 XBT_PUBLIC(void) sg_host_init(void);
 
 SG_END_DECL()
 XBT_PUBLIC(void) sg_host_init(void);
 
 SG_END_DECL()
index b85a67d..7047cb7 100644 (file)
@@ -259,8 +259,6 @@ XBT_PUBLIC(void) SIMIX_process_set_function(const char* process_host,
                                             double process_kill_time);
 
 /*********************************** Host *************************************/
                                             double process_kill_time);
 
 /*********************************** Host *************************************/
-//XBT_PUBLIC(xbt_dict_t) SIMIX_host_get_dict(u_smx_scalar_t *args);
-XBT_PUBLIC(sg_host_t) SIMIX_host_get_by_name(const char *name);
 XBT_PUBLIC(sg_host_t) SIMIX_host_self(void);
 XBT_PUBLIC(const char*) SIMIX_host_self_get_name(void);
 #define SIMIX_host_get_name(h) sg_host_name(h)  /* DEPRECATED: SIMIX_host_get_name */
 XBT_PUBLIC(sg_host_t) SIMIX_host_self(void);
 XBT_PUBLIC(const char*) SIMIX_host_self_get_name(void);
 #define SIMIX_host_get_name(h) sg_host_name(h)  /* DEPRECATED: SIMIX_host_get_name */
index f44d94c..836a5d3 100644 (file)
@@ -14,7 +14,6 @@ SG_BEGIN_DECL()
 
 XBT_PUBLIC_DATA(xbt_lib_t) host_lib;
 XBT_PUBLIC_DATA(int) ROUTING_HOST_LEVEL; //Routing level
 
 XBT_PUBLIC_DATA(xbt_lib_t) host_lib;
 XBT_PUBLIC_DATA(int) ROUTING_HOST_LEVEL; //Routing level
-XBT_PUBLIC_DATA(int)  SURF_CPU_LEVEL;    //Surf cpu level
 XBT_PUBLIC_DATA(int) SURF_HOST_LEVEL;    //Surf workstation level
 XBT_PUBLIC_DATA(int) SIMIX_STORAGE_LEVEL;  //Simix storage level
 XBT_PUBLIC_DATA(int)  SD_HOST_LEVEL;    //Simdag host level
 XBT_PUBLIC_DATA(int) SURF_HOST_LEVEL;    //Surf workstation level
 XBT_PUBLIC_DATA(int) SIMIX_STORAGE_LEVEL;  //Simix storage level
 XBT_PUBLIC_DATA(int)  SD_HOST_LEVEL;    //Simdag host level
index fef1748..c1cc3af 100644 (file)
@@ -35,16 +35,14 @@ void setCpuModel(CpuModel *cpuModel){
 }
 
 void setCpu(char *name, Cpu *cpu) {
 }
 
 void setCpu(char *name, Cpu *cpu) {
-  xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu);
+       sg_host_surfcpu_set(sg_host_by_name(name), cpu);
 }
 
 NetworkLinkDynar getRoute(char *srcName, char *dstName) {
   RoutingEdge *src = (RoutingEdge*)xbt_lib_get_or_null(host_lib, srcName, ROUTING_HOST_LEVEL);
   RoutingEdge *dst = (RoutingEdge*)xbt_lib_get_or_null(host_lib, dstName, ROUTING_HOST_LEVEL);
 }
 
 NetworkLinkDynar getRoute(char *srcName, char *dstName) {
   RoutingEdge *src = (RoutingEdge*)xbt_lib_get_or_null(host_lib, srcName, ROUTING_HOST_LEVEL);
   RoutingEdge *dst = (RoutingEdge*)xbt_lib_get_or_null(host_lib, dstName, ROUTING_HOST_LEVEL);
-  if (src==NULL)
-    xbt_die("TOTO");
-  if (dst==NULL)
-    xbt_die("TOTO");
+  xbt_assert(src,"Cannot get the route from a NULL source");
+  xbt_assert(dst,"Cannot get the route to a NULL destination");
   xbt_dynar_t route = xbt_dynar_new(sizeof(RoutingEdgePtr), NULL);
   routing_platf->getRouteAndLatency(src, dst, &route, NULL);
   return route;
   xbt_dynar_t route = xbt_dynar_new(sizeof(RoutingEdgePtr), NULL);
   routing_platf->getRouteAndLatency(src, dst, &route, NULL);
   return route;
index 32dc7ad..ed552ac 100644 (file)
@@ -56,7 +56,6 @@ class ResourceLmm;
 class Host;
 class HostCLM03;
 class NetworkCm02Link;
 class Host;
 class HostCLM03;
 class NetworkCm02Link;
-class Cpu;
 class Action;
 class ActionLmm;
 class StorageActionLmm;
 class Action;
 class ActionLmm;
 class StorageActionLmm;
@@ -75,7 +74,6 @@ typedef struct ResourceLmm ResourceLmm;
 typedef struct HostCLM03 HostCLM03;
 typedef struct Host Host;
 typedef struct NetworkCm02Link NetworkCm02Link;
 typedef struct HostCLM03 HostCLM03;
 typedef struct Host Host;
 typedef struct NetworkCm02Link NetworkCm02Link;
-typedef struct Cpu Cpu;
 typedef struct Action Action;
 typedef struct ActionLmm ActionLmm;
 typedef struct StorageActionLmm StorageActionLmm;
 typedef struct Action Action;
 typedef struct ActionLmm ActionLmm;
 typedef struct StorageActionLmm StorageActionLmm;
@@ -103,7 +101,6 @@ typedef Resource *surf_cpp_resource_t;
 typedef Host *surf_host_t;
 typedef HostCLM03 *surf_host_CLM03_t;
 typedef NetworkCm02Link *surf_network_link_t;
 typedef Host *surf_host_t;
 typedef HostCLM03 *surf_host_CLM03_t;
 typedef NetworkCm02Link *surf_network_link_t;
-typedef Cpu *surf_cpu_t;
 
 /** @ingroup SURF_c_bindings
  *  \brief Action structure
 
 /** @ingroup SURF_c_bindings
  *  \brief Action structure
@@ -188,9 +185,6 @@ typedef enum {
 
 XBT_PUBLIC_DATA(routing_platf_t) routing_platf;
 
 
 XBT_PUBLIC_DATA(routing_platf_t) routing_platf;
 
-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 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 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);
 }
@@ -201,12 +195,6 @@ static inline void *surf_storage_resource_priv(const void *storage){
   return (void*)xbt_lib_get_level((xbt_dictelm_t)storage, SURF_STORAGE_LEVEL);
 }
 
   return (void*)xbt_lib_get_level((xbt_dictelm_t)storage, SURF_STORAGE_LEVEL);
 }
 
-static inline void *surf_cpu_resource_by_name(const char *name) {
-  return xbt_lib_get_elm_or_null(host_lib, name);
-}
-static inline void *surf_host_resource_by_name(const char *name){
-  return xbt_lib_get_elm_or_null(host_lib, name);
-}
 static inline void *surf_storage_resource_by_name(const char *name){
   return xbt_lib_get_elm_or_null(storage_lib, name);
 }
 static inline void *surf_storage_resource_by_name(const char *name){
   return xbt_lib_get_elm_or_null(storage_lib, name);
 }
index 03a034f..564aea9 100644 (file)
@@ -8,14 +8,29 @@
 #include "simgrid/host.h"
 #include "surf/surf_routing.h" // SIMIX_HOST_LEVEL and friends FIXME: make private here
 
 #include "simgrid/host.h"
 #include "surf/surf_routing.h" // SIMIX_HOST_LEVEL and friends FIXME: make private here
 
+sg_host_t sg_host_by_name(const char *name){
+  return xbt_lib_get_elm_or_null(host_lib, name);
+}
+
+// ========= Layering madness ==============
+
 int SIMIX_HOST_LEVEL;
 int MSG_HOST_LEVEL;
 int SIMIX_HOST_LEVEL;
 int MSG_HOST_LEVEL;
+int SURF_CPU_LEVEL;
 
 #include "simix/smx_host_private.h" // SIMIX_host_destroy. FIXME: killme
 #include "msg/msg_private.h" // MSG_host_priv_free. FIXME: killme
 
 #include "simix/smx_host_private.h" // SIMIX_host_destroy. FIXME: killme
 #include "msg/msg_private.h" // MSG_host_priv_free. FIXME: killme
+#include "surf/cpu_interface.hpp"
+
+static XBT_INLINE void surf_cpu_free(void *r) {
+  delete static_cast<CpuPtr>(r);
+}
+
+
 void sg_host_init() {
   SIMIX_HOST_LEVEL = xbt_lib_add_level(host_lib,SIMIX_host_destroy);
   MSG_HOST_LEVEL = xbt_lib_add_level(host_lib, (void_f_pvoid_t) __MSG_host_priv_free);
 void sg_host_init() {
   SIMIX_HOST_LEVEL = xbt_lib_add_level(host_lib,SIMIX_host_destroy);
   MSG_HOST_LEVEL = xbt_lib_add_level(host_lib, (void_f_pvoid_t) __MSG_host_priv_free);
+  SURF_CPU_LEVEL = xbt_lib_add_level(host_lib,surf_cpu_free);
 }
 
 
 }
 
 
@@ -36,11 +51,23 @@ smx_host_priv_t sg_host_simix(sg_host_t host){
   return (smx_host_priv_t) xbt_lib_get_level(host, SIMIX_HOST_LEVEL);
 }
 void sg_host_simix_set(sg_host_t host, smx_host_priv_t smx_host) {
   return (smx_host_priv_t) xbt_lib_get_level(host, SIMIX_HOST_LEVEL);
 }
 void sg_host_simix_set(sg_host_t host, smx_host_priv_t smx_host) {
-         xbt_lib_set(host_lib,host->key,SIMIX_HOST_LEVEL,smx_host);
+       xbt_lib_set(host_lib,host->key,SIMIX_HOST_LEVEL,smx_host);
 }
 void sg_host_simix_destroy(sg_host_t host) {
 }
 void sg_host_simix_destroy(sg_host_t host) {
-         xbt_lib_unset(host_lib,host->key,SIMIX_HOST_LEVEL,1);
+       xbt_lib_unset(host_lib,host->key,SIMIX_HOST_LEVEL,1);
+}
+
+// ========== SURF CPU ============
+surf_cpu_t sg_host_surfcpu(sg_host_t host) {
+       return (surf_cpu_t) xbt_lib_get_level(host, SURF_CPU_LEVEL);
 }
 }
+void sg_host_surfcpu_set(sg_host_t host, surf_cpu_t cpu) {
+       xbt_lib_set(host_lib, host->key, SURF_CPU_LEVEL, cpu);
+}
+void sg_host_surfcpu_destroy(sg_host_t host) {
+       xbt_lib_unset(host_lib,host->key,SURF_CPU_LEVEL,1);
+}
+
 
 
 /*
 
 
 /*
index dd5580a..99bee4a 100644 (file)
@@ -21,7 +21,7 @@ inline static sg_host_t simcall_BODY_host_get_by_name(const char* name) {
     smx_process_t self = SIMIX_process_self();
 
     /* Go to that function to follow the code flow through the simcall barrier */
     smx_process_t self = SIMIX_process_self();
 
     /* Go to that function to follow the code flow through the simcall barrier */
-    if (0) SIMIX_host_get_by_name(name);
+    if (0) sg_host_by_name(name);
     /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */
 
     self->simcall.call = SIMCALL_HOST_GET_BY_NAME;
     /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */
 
     self->simcall.call = SIMCALL_HOST_GET_BY_NAME;
index d3f2388..66cd986 100644 (file)
@@ -169,7 +169,7 @@ void SIMIX_simcall_handle(smx_simcall_t simcall, int value) {
     return;
   switch (simcall->call) {
 case SIMCALL_HOST_GET_BY_NAME:
     return;
   switch (simcall->call) {
 case SIMCALL_HOST_GET_BY_NAME:
-      simcall->result.dp = SIMIX_host_get_by_name( simcall->args[0].cc);
+      simcall->result.dp = sg_host_by_name( simcall->args[0].cc);
       SIMIX_simcall_answer(simcall);
       break;  
 
       SIMIX_simcall_answer(simcall);
       break;  
 
index faf3c7b..7a3b025 100644 (file)
@@ -23,7 +23,7 @@ extern int surf_parse_lineno;
 
 static void parse_process(sg_platf_process_cbarg_t process)
 {
 
 static void parse_process(sg_platf_process_cbarg_t process)
 {
-  sg_host_t host = SIMIX_host_get_by_name(process->host);
+  sg_host_t host = sg_host_by_name(process->host);
   if (!host)
     THROWF(arg_error, 0, "Host '%s' unknown", process->host);
   parse_code = SIMIX_get_registered_function(process->function);
   if (!host)
     THROWF(arg_error, 0, "Host '%s' unknown", process->host);
   parse_code = SIMIX_get_registered_function(process->function);
@@ -196,7 +196,7 @@ void SIMIX_process_set_function(const char *process_host,
 {
   s_sg_platf_process_cbarg_t process = SG_PLATF_PROCESS_INITIALIZER;
 
 {
   s_sg_platf_process_cbarg_t process = SG_PLATF_PROCESS_INITIALIZER;
 
-  sg_host_t host = SIMIX_host_get_by_name(process_host);
+  sg_host_t host = sg_host_by_name(process_host);
   if (!host)
     THROWF(arg_error, 0, "Host '%s' unknown", process_host);
   process.host = sg_host_name(host);
   if (!host)
     THROWF(arg_error, 0, "Host '%s' unknown", process_host);
   process.host = sg_host_name(host);
index 9f66e79..f5ea654 100644 (file)
@@ -206,7 +206,6 @@ void SIMIX_global_init(int *argc, char **argv)
     simix_timers = xbt_heap_new(8, &free);
   }
 
     simix_timers = xbt_heap_new(8, &free);
   }
 
-  sg_host_init();
   SIMIX_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, SIMIX_storage_destroy);
 
   if (sg_cfg_get_boolean("clean_atexit"))
   SIMIX_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, SIMIX_storage_destroy);
 
   if (sg_cfg_get_boolean("clean_atexit"))
@@ -486,7 +485,7 @@ void SIMIX_run(void)
       char *hostname = NULL;
       xbt_dynar_foreach(host_that_restart,iter,hostname) {
         XBT_INFO("Restart processes on host: %s",hostname);
       char *hostname = NULL;
       xbt_dynar_foreach(host_that_restart,iter,hostname) {
         XBT_INFO("Restart processes on host: %s",hostname);
-        SIMIX_host_autorestart(SIMIX_host_get_by_name(hostname));
+        SIMIX_host_autorestart(sg_host_by_name(hostname));
       }
       xbt_dynar_reset(host_that_restart);
     }
       }
       xbt_dynar_reset(host_that_restart);
     }
index 17bc3c9..bac8423 100644 (file)
@@ -148,10 +148,6 @@ void SIMIX_host_destroy(void *h)
   return;
 }
 
   return;
 }
 
-sg_host_t SIMIX_host_get_by_name(const char *name){
-  return xbt_lib_get_elm_or_null(host_lib, name);
-}
-
 sg_host_t SIMIX_host_self(void)
 {
   smx_process_t process = SIMIX_process_self();
 sg_host_t SIMIX_host_self(void)
 {
   smx_process_t process = SIMIX_process_self();
index 8dbf276..57cc594 100644 (file)
@@ -234,7 +234,7 @@ void SIMIX_process_create(smx_process_t *process,
                           smx_process_t parent_process)
 {
   *process = NULL;
                           smx_process_t parent_process)
 {
   *process = NULL;
-  sg_host_t host = SIMIX_host_get_by_name(hostname);
+  sg_host_t host = sg_host_by_name(hostname);
 
   XBT_DEBUG("Start process %s on host '%s'", name, hostname);
 
 
   XBT_DEBUG("Start process %s on host '%s'", name, hostname);
 
index f060683..2f4ddbc 100644 (file)
@@ -30,7 +30,7 @@ sg_host_t SIMIX_vm_create(const char *name, sg_host_t ind_phys_host)
   /* We will be able to register the VM to its physical host, so that we can promptly
    * retrieve the list VMs on the physical host. */
 
   /* We will be able to register the VM to its physical host, so that we can promptly
    * retrieve the list VMs on the physical host. */
 
-  return SIMIX_host_get_by_name(name);
+  return sg_host_by_name(name);
 }
 
 
 }
 
 
index d5fb355..976b54a 100644 (file)
@@ -113,7 +113,8 @@ CpuPtr CpuCas01Model::createCpu(const char *name, xbt_dynar_t power_peak,
                           xbt_dict_t cpu_properties)
 {
   CpuPtr cpu = NULL;
                           xbt_dict_t cpu_properties)
 {
   CpuPtr cpu = NULL;
-  xbt_assert(!surf_cpu_resource_priv(surf_cpu_resource_by_name(name)),
+  sg_host_t host = sg_host_by_name(name);
+  xbt_assert(!sg_host_surfcpu(host),
              "Host '%s' declared several times in the platform file",
              name);
   xbt_assert(xbt_dynar_getfirst_as(power_peak, double) > 0.0,
              "Host '%s' declared several times in the platform file",
              name);
   xbt_assert(xbt_dynar_getfirst_as(power_peak, double) > 0.0,
@@ -121,7 +122,7 @@ CpuPtr CpuCas01Model::createCpu(const char *name, xbt_dynar_t power_peak,
   xbt_assert(core > 0, "Invalid number of cores %d. Must be larger than 0", core);
 
   cpu = new CpuCas01(this, name, power_peak, pstate, power_scale, power_trace, core, state_initial, state_trace, cpu_properties);
   xbt_assert(core > 0, "Invalid number of cores %d. Must be larger than 0", core);
 
   cpu = new CpuCas01(this, name, power_peak, pstate, power_scale, power_trace, core, state_initial, state_trace, cpu_properties);
-  xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu);
+  sg_host_surfcpu_set(host, cpu);
 
   return cpu;
 }
 
   return cpu;
 }
@@ -144,7 +145,7 @@ void CpuCas01Model::addTraces()
   /* connect all traces relative to hosts */
   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
   /* connect all traces relative to hosts */
   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    CpuCas01Ptr host = static_cast<CpuCas01Ptr>(surf_cpu_resource_priv(surf_cpu_resource_by_name(elm)));
+    CpuCas01Ptr host = static_cast<CpuCas01Ptr>(sg_host_surfcpu(sg_host_by_name(elm)));
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
@@ -154,7 +155,7 @@ void CpuCas01Model::addTraces()
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    CpuCas01Ptr host = static_cast<CpuCas01Ptr>(surf_cpu_resource_priv(surf_cpu_resource_by_name(elm)));
+    CpuCas01Ptr host = static_cast<CpuCas01Ptr>(sg_host_surfcpu(sg_host_by_name(elm)));
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
index a2dd954..045e6fe 100644 (file)
@@ -17,7 +17,6 @@ class CpuModel;
 typedef CpuModel *CpuModelPtr;
 
 class Cpu;
 typedef CpuModel *CpuModelPtr;
 
 class Cpu;
-typedef Cpu *CpuPtr;
 
 class CpuAction;
 typedef CpuAction *CpuActionPtr;
 
 class CpuAction;
 typedef CpuAction *CpuActionPtr;
index 81a156d..5d3cbf3 100644 (file)
@@ -434,14 +434,15 @@ CpuPtr CpuTiModel::createCpu(const char *name,
                            xbt_dict_t cpuProperties)
 {
   xbt_assert(core==1,"Multi-core not handled with this model yet");
                            xbt_dict_t cpuProperties)
 {
   xbt_assert(core==1,"Multi-core not handled with this model yet");
-  xbt_assert(!surf_cpu_resource_priv(surf_cpu_resource_by_name(name)),
+  sg_host_t host = sg_host_by_name(name);
+  xbt_assert(!sg_host_surfcpu(host),
               "Host '%s' declared several times in the platform file",
               name);
   xbt_assert(xbt_dynar_getfirst_as(powerPeak, double) > 0.0,
       "Power has to be >0.0. Did you forget to specify the mandatory power attribute?");
   CpuTiPtr cpu = new CpuTi(this, name, powerPeak, pstate, powerScale, powerTrace,
                           core, stateInitial, stateTrace, cpuProperties);
               "Host '%s' declared several times in the platform file",
               name);
   xbt_assert(xbt_dynar_getfirst_as(powerPeak, double) > 0.0,
       "Power has to be >0.0. Did you forget to specify the mandatory power attribute?");
   CpuTiPtr cpu = new CpuTi(this, name, powerPeak, pstate, powerScale, powerTrace,
                           core, stateInitial, stateTrace, cpuProperties);
-  xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, static_cast<ResourcePtr>(cpu));
+  sg_host_surfcpu_set(host, cpu);
   return cpu;
 }
 
   return cpu;
 }
 
@@ -495,7 +496,7 @@ void CpuTiModel::addTraces()
 /* connect all traces relative to hosts */
   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
 /* connect all traces relative to hosts */
   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    CpuTiPtr cpu = static_cast<CpuTiPtr>(surf_cpu_resource_priv(surf_cpu_resource_by_name(elm)));
+    CpuTiPtr cpu = static_cast<CpuTiPtr>(sg_host_surfcpu(sg_host_by_name(elm)));
 
     xbt_assert(cpu, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
     xbt_assert(cpu, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
@@ -511,7 +512,7 @@ void CpuTiModel::addTraces()
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    CpuTiPtr cpu = static_cast<CpuTiPtr>(surf_cpu_resource_priv(surf_cpu_resource_by_name(elm)));
+    CpuTiPtr cpu = static_cast<CpuTiPtr>(sg_host_surfcpu(sg_host_by_name(elm)));
 
     xbt_assert(cpu, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
     xbt_assert(cpu, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
index 5c1a5d6..9cac53f 100644 (file)
@@ -56,10 +56,11 @@ HostCLM03Model::~HostCLM03Model()
 {}
 
 HostPtr HostCLM03Model::createHost(const char *name){
 {}
 
 HostPtr HostCLM03Model::createHost(const char *name){
+  sg_host_t sg_host = sg_host_by_name(name);
   HostPtr host = new HostCLM03(surf_host_model, name, NULL,
                  (xbt_dynar_t)xbt_lib_get_or_null(storage_lib, name, ROUTING_STORAGE_HOST_LEVEL),
                  (RoutingEdgePtr)xbt_lib_get_or_null(host_lib, name, ROUTING_HOST_LEVEL),
   HostPtr host = new HostCLM03(surf_host_model, name, NULL,
                  (xbt_dynar_t)xbt_lib_get_or_null(storage_lib, name, ROUTING_STORAGE_HOST_LEVEL),
                  (RoutingEdgePtr)xbt_lib_get_or_null(host_lib, name, ROUTING_HOST_LEVEL),
-                 static_cast<CpuPtr>(xbt_lib_get_or_null(host_lib, name, SURF_CPU_LEVEL)));
+                 sg_host_surfcpu(sg_host));
   XBT_DEBUG("Create host %s with %ld mounted disks", name, xbt_dynar_length(host->p_storage));
   xbt_lib_set(host_lib, name, SURF_HOST_LEVEL, host);
   return host;
   XBT_DEBUG("Create host %s with %ld mounted disks", name, xbt_dynar_length(host->p_storage));
   xbt_lib_set(host_lib, name, SURF_HOST_LEVEL, host);
   return host;
index 4b7b762..053611a 100644 (file)
@@ -275,13 +275,15 @@ ActionPtr HostL07Model::executeParallelTask(int host_nb,
 HostPtr HostL07Model::createHost(const char *name)
 {
   HostL07Ptr wk = NULL;
 HostPtr HostL07Model::createHost(const char *name)
 {
   HostL07Ptr wk = NULL;
-  xbt_assert(!surf_host_resource_priv(surf_host_resource_by_name(name)),
+  sg_host_t sg_host = sg_host_by_name(name);
+
+  xbt_assert(!surf_host_resource_priv(sg_host),
               "Host '%s' declared several times in the platform file.",
               name);
 
   wk = new HostL07(this, name, NULL,
                                  static_cast<RoutingEdgePtr>(xbt_lib_get_or_null(host_lib, name, ROUTING_HOST_LEVEL)),
               "Host '%s' declared several times in the platform file.",
               name);
 
   wk = new HostL07(this, name, NULL,
                                  static_cast<RoutingEdgePtr>(xbt_lib_get_or_null(host_lib, name, ROUTING_HOST_LEVEL)),
-                                 static_cast<CpuPtr>(xbt_lib_get_or_null(host_lib, name, SURF_CPU_LEVEL)));
+                                                 sg_host_surfcpu(sg_host));
 
   xbt_lib_set(host_lib, name, SURF_HOST_LEVEL, wk);
 
 
   xbt_lib_set(host_lib, name, SURF_HOST_LEVEL, wk);
 
@@ -323,8 +325,9 @@ CpuPtr CpuL07Model::createCpu(const char *name,  xbt_dynar_t powerPeak,
 {
   double power_initial = xbt_dynar_get_as(powerPeak, pstate, double);
   xbt_dynar_free(&powerPeak);   // kill memory leak
 {
   double power_initial = xbt_dynar_get_as(powerPeak, pstate, double);
   xbt_dynar_free(&powerPeak);   // kill memory leak
+  sg_host_t sg_host = sg_host_by_name(name);
 
 
-  xbt_assert(!surf_host_resource_priv(surf_host_resource_by_name(name)),
+  xbt_assert(!surf_host_resource_priv(sg_host),
               "Host '%s' declared several times in the platform file.",
               name);
 
               "Host '%s' declared several times in the platform file.",
               name);
 
@@ -332,7 +335,7 @@ CpuPtr CpuL07Model::createCpu(const char *name,  xbt_dynar_t powerPeak,
                                     power_initial, power_scale, power_trace,
                          core, state_initial, state_trace);
 
                                     power_initial, power_scale, power_trace,
                          core, state_initial, state_trace);
 
-  xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu);
+  sg_host_surfcpu_set(sg_host, cpu);
 
   return cpu;
 }
 
   return cpu;
 }
@@ -373,7 +376,7 @@ void HostL07Model::addTraces()
   /* Connect traces relative to cpu */
   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
   /* Connect traces relative to cpu */
   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    CpuL07Ptr host = static_cast<CpuL07Ptr>(surf_cpu_resource_priv(surf_cpu_resource_by_name(elm)));
+    CpuL07Ptr host = static_cast<CpuL07Ptr>(sg_host_surfcpu(sg_host_by_name(elm)));
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
@@ -383,7 +386,7 @@ void HostL07Model::addTraces()
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    CpuL07Ptr host = static_cast<CpuL07Ptr>(surf_cpu_resource_priv(surf_cpu_resource_by_name(elm)));
+    CpuL07Ptr host = static_cast<CpuL07Ptr>(sg_host_surfcpu(sg_host_by_name(elm)));
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
index ffcf0ab..5a44b9b 100644 (file)
@@ -18,10 +18,6 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_kernel);
  * TOOLS *
  *********/
 
  * TOOLS *
  *********/
 
-static CpuPtr get_casted_cpu(surf_resource_t resource){
-  return static_cast<CpuPtr>(surf_cpu_resource_priv(resource));
-}
-
 static HostPtr get_casted_host(surf_resource_t resource){
   return static_cast<HostPtr>(surf_host_resource_priv(resource));
 }
 static HostPtr get_casted_host(surf_resource_t resource){
   return static_cast<HostPtr>(surf_host_resource_priv(resource));
 }
@@ -447,7 +443,6 @@ void surf_host_set_params(surf_resource_t host, ws_params_t params){
 
 void surf_vm_destroy(surf_resource_t resource){
   /* Before clearing the entries in host_lib, we have to pick up resources. */
 
 void surf_vm_destroy(surf_resource_t resource){
   /* Before clearing the entries in host_lib, we have to pick up resources. */
-  CpuPtr cpu = get_casted_cpu(resource);
   VMPtr vm = get_casted_vm(resource);
   RoutingEdgePtr routing = get_casted_routing(resource);
   char* name = xbt_dict_get_elm_key(resource);
   VMPtr vm = get_casted_vm(resource);
   RoutingEdgePtr routing = get_casted_routing(resource);
   char* name = xbt_dict_get_elm_key(resource);
@@ -457,14 +452,13 @@ void surf_vm_destroy(surf_resource_t resource){
    * Do not call xbt_lib_remove() here. It deletes all levels of the key,
    * including MSG_HOST_LEVEL and others. We should unregister only what we know.
    */
    * Do not call xbt_lib_remove() here. It deletes all levels of the key,
    * including MSG_HOST_LEVEL and others. We should unregister only what we know.
    */
-  xbt_lib_unset(host_lib, name, SURF_CPU_LEVEL, 0);
+  sg_host_surfcpu_destroy((sg_host_t)resource);
   xbt_lib_unset(host_lib, name, ROUTING_HOST_LEVEL, 0);
   xbt_lib_unset(host_lib, name, SURF_HOST_LEVEL, 0);
 
   /* TODO: comment out when VM storage is implemented. */
   // xbt_lib_unset(host_lib, name, SURF_STORAGE_LEVEL, 0);
 
   xbt_lib_unset(host_lib, name, ROUTING_HOST_LEVEL, 0);
   xbt_lib_unset(host_lib, name, SURF_HOST_LEVEL, 0);
 
   /* TODO: comment out when VM storage is implemented. */
   // xbt_lib_unset(host_lib, name, SURF_STORAGE_LEVEL, 0);
 
-  delete cpu;
   delete vm;
   delete routing;
 }
   delete vm;
   delete routing;
 }
@@ -498,7 +492,7 @@ void surf_vm_set_bound(surf_resource_t vm, double bound){
 }
 
 void surf_vm_set_affinity(surf_resource_t vm, surf_resource_t cpu, unsigned long mask){
 }
 
 void surf_vm_set_affinity(surf_resource_t vm, surf_resource_t cpu, unsigned long mask){
-  return get_casted_vm(vm)->setAffinity(get_casted_cpu(cpu), mask);
+  return get_casted_vm(vm)->setAffinity(sg_host_surfcpu(cpu), mask);
 }
 
 int surf_network_link_is_shared(surf_cpp_resource_t link){
 }
 
 int surf_network_link_is_shared(surf_cpp_resource_t link){
@@ -534,11 +528,11 @@ const char* surf_storage_get_host(surf_resource_t resource){
 }
 
 surf_action_t surf_cpu_execute(surf_resource_t cpu, double size){
 }
 
 surf_action_t surf_cpu_execute(surf_resource_t cpu, double size){
-  return get_casted_cpu(cpu)->execute(size);
+  return sg_host_surfcpu(cpu)->execute(size);
 }
 
 surf_action_t surf_cpu_sleep(surf_resource_t cpu, double duration){
 }
 
 surf_action_t surf_cpu_sleep(surf_resource_t cpu, double duration){
-  return get_casted_cpu(cpu)->sleep(duration);
+  return sg_host_surfcpu(cpu)->sleep(duration);
 }
 
 double surf_action_get_start_time(surf_action_t action){
 }
 
 double surf_action_get_start_time(surf_action_t action){
@@ -594,7 +588,7 @@ double surf_action_get_cost(surf_action_t action){
 }
 
 void surf_cpu_action_set_affinity(surf_action_t action, surf_resource_t cpu, unsigned long mask) {
 }
 
 void surf_cpu_action_set_affinity(surf_action_t action, surf_resource_t cpu, unsigned long mask) {
-  static_cast<CpuActionPtr>(action)->setAffinity(get_casted_cpu(cpu), mask);
+  static_cast<CpuActionPtr>(action)->setAffinity(sg_host_surfcpu(cpu), mask);
 }
 
 void surf_cpu_action_set_bound(surf_action_t action, double bound) {
 }
 
 void surf_cpu_action_set_bound(surf_action_t action, double bound) {
index 3b34cc7..cbb2f02 100644 (file)
@@ -365,11 +365,6 @@ static XBT_INLINE void routing_asr_prop_free(void *p)
   xbt_dict_free(&elm);
 }
 
   xbt_dict_free(&elm);
 }
 
-static XBT_INLINE void surf_cpu_free(void *r)
-{
-  delete static_cast<CpuPtr>(r);
-}
-
 static XBT_INLINE void surf_link_free(void *r)
 {
   delete static_cast<NetworkLinkPtr>(r);
 static XBT_INLINE void surf_link_free(void *r)
 {
   delete static_cast<NetworkLinkPtr>(r);
@@ -403,13 +398,14 @@ void surf_init(int *argc, char **argv)
   file_lib = xbt_lib_new();
   watched_hosts_lib = xbt_dict_new_homogeneous(NULL);
 
   file_lib = xbt_lib_new();
   watched_hosts_lib = xbt_dict_new_homogeneous(NULL);
 
+  sg_host_init();
+
   XBT_DEBUG("Add routing levels");
   ROUTING_HOST_LEVEL = xbt_lib_add_level(host_lib,routing_asr_host_free);
   ROUTING_ASR_LEVEL  = xbt_lib_add_level(as_router_lib,routing_asr_host_free);
   ROUTING_PROP_ASR_LEVEL = xbt_lib_add_level(as_router_lib,routing_asr_prop_free);
 
   XBT_DEBUG("Add SURF levels");
   XBT_DEBUG("Add routing levels");
   ROUTING_HOST_LEVEL = xbt_lib_add_level(host_lib,routing_asr_host_free);
   ROUTING_ASR_LEVEL  = xbt_lib_add_level(as_router_lib,routing_asr_host_free);
   ROUTING_PROP_ASR_LEVEL = xbt_lib_add_level(as_router_lib,routing_asr_prop_free);
 
   XBT_DEBUG("Add SURF levels");
-  SURF_CPU_LEVEL = xbt_lib_add_level(host_lib,surf_cpu_free);
   SURF_HOST_LEVEL = xbt_lib_add_level(host_lib,surf_host_free);
   SURF_LINK_LEVEL = xbt_lib_add_level(link_lib,surf_link_free);
   SURF_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,surf_storage_free);
   SURF_HOST_LEVEL = xbt_lib_add_level(host_lib,surf_host_free);
   SURF_LINK_LEVEL = xbt_lib_add_level(link_lib,surf_link_free);
   SURF_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,surf_storage_free);
index 8b61329..95ac8a6 100644 (file)
@@ -60,7 +60,6 @@ XBT_PUBLIC(double) surf_get_clock(void);
 }
 
 extern double sg_sender_gap;
 }
 
 extern double sg_sender_gap;
-XBT_PUBLIC_DATA(int)  SURF_CPU_LEVEL;    //Surf cpu level
 
 extern surf_callback(void, void) surfExitCallbacks;
 
 
 extern surf_callback(void, void) surfExitCallbacks;
 
index 0738974..6c723ec 100644 (file)
@@ -24,7 +24,6 @@
 xbt_lib_t host_lib;
 
 int ROUTING_HOST_LEVEL;         //Routing level
 xbt_lib_t host_lib;
 
 int ROUTING_HOST_LEVEL;         //Routing level
-int SURF_CPU_LEVEL;             //Surf cpu level
 int SURF_HOST_LEVEL;            //Surf host level
 int SIMIX_STORAGE_LEVEL;        //Simix storage level
 int MSG_STORAGE_LEVEL;          //Msg storage level
 int SURF_HOST_LEVEL;            //Surf host level
 int SIMIX_STORAGE_LEVEL;        //Simix storage level
 int MSG_STORAGE_LEVEL;          //Msg storage level
index d567fc5..b7e7b9b 100644 (file)
@@ -241,10 +241,7 @@ VMHL13::VMHL13(VMModelPtr model, const char* name, xbt_dict_t props,
 
   // //// CPU  RELATED STUFF ////
   // Roughly, create a vcpu resource by using the values of the sub_cpu one.
 
   // //// CPU  RELATED STUFF ////
   // Roughly, create a vcpu resource by using the values of the sub_cpu one.
-  CpuCas01Ptr sub_cpu = static_cast<CpuCas01Ptr>(surf_cpu_resource_priv(host_PM));
-
-  /* We can assume one core and cas01 cpu for the first step.
-   * Do xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu) if you get the resource. */
+  CpuCas01Ptr sub_cpu = static_cast<CpuCas01Ptr>(sg_host_surfcpu(host_PM));
 
   p_cpu = surf_cpu_model_vm->createCpu(name, // name
       sub_cpu->getPowerPeakList(),        // host->power_peak,
 
   p_cpu = surf_cpu_model_vm->createCpu(name, // name
       sub_cpu->getPowerPeakList(),        // host->power_peak,
@@ -367,7 +364,7 @@ void VMHL13::migrate(surf_resource_t ind_dst_pm)
 
      /* create a cpu action bound to the pm model at the destination. */
      CpuActionPtr new_cpu_action = static_cast<CpuActionPtr>(
 
      /* create a cpu action bound to the pm model at the destination. */
      CpuActionPtr new_cpu_action = static_cast<CpuActionPtr>(
-                                           static_cast<CpuPtr>(surf_cpu_resource_priv(ind_dst_pm))->execute(0));
+                                           static_cast<CpuPtr>(sg_host_surfcpu(ind_dst_pm))->execute(0));
 
      e_surf_action_state_t state = p_action->getState();
      if (state != SURF_ACTION_DONE)
 
      e_surf_action_state_t state = p_action->getState();
      if (state != SURF_ACTION_DONE)
index f6e335e..a1e779e 100644 (file)
@@ -58,12 +58,12 @@ void test(char *platform)
 
   /*********************** CPU ***********************************/
   XBT_DEBUG("%p", surf_cpu_model_pm);
 
   /*********************** CPU ***********************************/
   XBT_DEBUG("%p", surf_cpu_model_pm);
-  cpuA = surf_cpu_resource_by_name("Cpu A");
-  cpuB = surf_cpu_resource_by_name("Cpu B");
+  cpuA = sg_host_by_name("Cpu A");
+  cpuB = sg_host_by_name("Cpu B");
 
   /* Let's check that those two processors exist */
 
   /* Let's check that those two processors exist */
-  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);
+  XBT_DEBUG("%s : %p", surf_cpu_name(sg_host_surfcpu(cpuA)), cpuA);
+  XBT_DEBUG("%s : %p", surf_cpu_name(sg_host_surfcpu(cpuB)), cpuB);
 
   /* Let's do something on it */
   actionA = surf_cpu_execute(cpuA, 1000.0);
 
   /* Let's do something on it */
   actionA = surf_cpu_execute(cpuA, 1000.0);
index dbb1c6a..585415b 100644 (file)
@@ -42,8 +42,8 @@ const char *string_action(e_surf_action_state_t state)
 void test(char *platform);
 void test(char *platform)
 {
 void test(char *platform);
 void test(char *platform)
 {
-  void *hostA = NULL;
-  void *hostB = NULL;
+  sg_host_t hostA = NULL;
+  sg_host_t hostB = NULL;
   double now = -1.0;
   int running;
 
   double now = -1.0;
   int running;
 
@@ -52,12 +52,12 @@ void test(char *platform)
   parse_platform_file(platform);
 
   /*********************** HOST ***********************************/
   parse_platform_file(platform);
 
   /*********************** HOST ***********************************/
-  hostA = surf_host_resource_by_name("Cpu A");
-  hostB = surf_host_resource_by_name("Cpu B");
+  hostA = sg_host_by_name("Cpu A");
+  hostB = sg_host_by_name("Cpu B");
 
   /* Let's check that those two processors exist */
 
   /* Let's check that those two processors exist */
-  XBT_DEBUG("%s : %p", surf_resource_name(hostA), hostA);
-  XBT_DEBUG("%s : %p", surf_resource_name(hostB), hostB);
+  XBT_DEBUG("%s : %p", sg_host_get_name(hostA), hostA);
+  XBT_DEBUG("%s : %p", sg_host_get_name(hostB), hostB);
 
   /* Let's do something on it */
   surf_host_execute(hostA, 1000.0);
 
   /* Let's do something on it */
   surf_host_execute(hostA, 1000.0);