Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix surf_usage
authorPaul Bédaride <paul.bedaride@gmail.com>
Tue, 8 Oct 2013 13:26:11 +0000 (15:26 +0200)
committerPaul Bédaride <paul.bedaride@gmail.com>
Tue, 8 Oct 2013 13:53:02 +0000 (15:53 +0200)
25 files changed:
src/include/surf/surf.h
src/simgrid/sg_config.c
src/surf/cpu_cas01.cpp
src/surf/cpu_cas01.hpp
src/surf/cpu_ti.cpp
src/surf/network.cpp
src/surf/network.hpp
src/surf/network_constant.cpp
src/surf/network_constant.hpp
src/surf/storage.cpp
src/surf/storage.hpp
src/surf/surf.cpp
src/surf/surf.hpp
src/surf/surf_interface.cpp
src/surf/surf_routing.cpp
src/surf/surf_routing.hpp
src/surf/surf_routing_full.cpp
src/surf/surf_routing_full.hpp [new file with mode: 0644]
src/surf/surf_routing_generic.cpp
src/surf/surf_routing_generic.hpp
src/surf/surf_routing_none.hpp
src/surf/workstation.cpp
src/surf/workstation.hpp
src/surf/workstation_ptask_L07.cpp
testsuite/surf/surf_usage.c

index 7d783ce..784df53 100644 (file)
@@ -305,6 +305,7 @@ static inline void *surf_storage_resource_by_name(const char *name){
 #ifdef __cplusplus
 extern "C" {
 #endif
 #ifdef __cplusplus
 extern "C" {
 #endif
+char *surf_routing_edge_name(sg_routing_edge_t edge);
 
 const char *surf_model_name(surf_model_t model);
 xbt_swag_t surf_model_done_action_set(surf_model_t model);
 
 const char *surf_model_name(surf_model_t model);
 xbt_swag_t surf_model_done_action_set(surf_model_t model);
@@ -331,6 +332,7 @@ surf_action_t surf_workstation_sleep(surf_workstation_t resource, double duratio
 surf_action_t surf_workstation_communicate(surf_workstation_t workstation_src, surf_workstation_t workstation_dst, double size, double rate);
 surf_action_t surf_workstation_open(surf_workstation_t workstation, const char* mount, const char* path);
 surf_action_t surf_workstation_close(surf_workstation_t workstation, surf_file_t fd);
 surf_action_t surf_workstation_communicate(surf_workstation_t workstation_src, surf_workstation_t workstation_dst, double size, double rate);
 surf_action_t surf_workstation_open(surf_workstation_t workstation, const char* mount, const char* path);
 surf_action_t surf_workstation_close(surf_workstation_t workstation, surf_file_t fd);
+const char *surf_cpu_name(surf_cpu_t resource);
 surf_action_t surf_cpu_execute(surf_cpu_t cpu, double size);
 surf_action_t surf_cpu_sleep(surf_cpu_t cpu, double duration);
 int surf_workstation_unlink(surf_workstation_t workstation, surf_file_t fd);
 surf_action_t surf_cpu_execute(surf_cpu_t cpu, double size);
 surf_action_t surf_cpu_sleep(surf_cpu_t cpu, double duration);
 int surf_workstation_unlink(surf_workstation_t workstation, surf_file_t fd);
index 3022b61..1726748 100644 (file)
@@ -922,12 +922,12 @@ void surf_config_models_setup()
 
   /* ********************************************************************* */
   /* TUTORIAL: New model                                                   */
 
   /* ********************************************************************* */
   /* TUTORIAL: New model                                                   */
-  int new_model_id = -1;
+  /*FIXME:UPDATE: int new_model_id = -1;
   char *new_model_name = NULL;
   new_model_name = xbt_cfg_get_string(_sg_cfg_set, "new_model/model");
   XBT_DEBUG("Call new model_init");
   new_model_id = find_model_description(surf_new_model_description, new_model_name);
   char *new_model_name = NULL;
   new_model_name = xbt_cfg_get_string(_sg_cfg_set, "new_model/model");
   XBT_DEBUG("Call new model_init");
   new_model_id = find_model_description(surf_new_model_description, new_model_name);
-  surf_new_model_description[new_model_id].model_init_preparse();
+  surf_new_model_description[new_model_id].model_init_preparse();*/
   /* ********************************************************************* */
 }
 
   /* ********************************************************************* */
 }
 
index 68fba77..c1eedce 100644 (file)
@@ -18,6 +18,24 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu_cas, surf,
 static xbt_swag_t
     cpu_running_action_set_that_does_not_need_being_checked = NULL;
 
 static xbt_swag_t
     cpu_running_action_set_that_does_not_need_being_checked = NULL;
 
+/*************
+ * CallBacks *
+ *************/
+
+static void parse_cpu_init(sg_platf_host_cbarg_t host){
+  ((CpuCas01ModelPtr)surf_cpu_model)->parseInit(host);
+}
+
+static void cpu_add_traces_cpu(){
+  surf_cpu_model->addTraces();
+}
+
+static void cpu_define_callbacks()
+{
+  sg_platf_host_add_cb(parse_cpu_init);
+  sg_platf_postparse_add_cb(cpu_add_traces_cpu);
+}
+
 /*********
  * Model *
  *********/
 /*********
  * Model *
  *********/
@@ -34,7 +52,9 @@ void surf_cpu_model_init_Cas01()
   }
 
   surf_cpu_model = new CpuCas01Model();
   }
 
   surf_cpu_model = new CpuCas01Model();
-  xbt_dynar_push(model_list, &surf_cpu_model);
+  cpu_define_callbacks();
+  ModelPtr model = static_cast<ModelPtr>(surf_cpu_model);
+  xbt_dynar_push(model_list, &model);
 }
 
 CpuCas01Model::CpuCas01Model() : CpuModel("cpu")
 }
 
 CpuCas01Model::CpuCas01Model() : CpuModel("cpu")
@@ -79,12 +99,23 @@ CpuCas01Model::CpuCas01Model() : CpuModel("cpu")
   if (p_updateMechanism == UM_LAZY) {
     p_actionHeap = xbt_heap_new(8, NULL);
     xbt_heap_set_update_callback(p_actionHeap,  surf_action_lmm_update_index_heap);
   if (p_updateMechanism == UM_LAZY) {
     p_actionHeap = xbt_heap_new(8, NULL);
     xbt_heap_set_update_callback(p_actionHeap,  surf_action_lmm_update_index_heap);
-    p_modifiedSet = xbt_swag_new(xbt_swag_offset(action, p_actionListHookup));
-    //TOREPAIR: cpu_model->model_private->maxmin_system->m_keepTrack = cpu_model->model_private->modified_set;
+    ActionLmmPtr _actionlmm;
+    CpuCas01ActionLmmPtr _actioncpu;
+    int j = xbt_swag_offset(*_actionlmm, p_actionListHookup);
+    int k = xbt_swag_offset(*_actioncpu, p_actionListHookup);
+    j = ((char *)&( (*_actionlmm).p_actionListHookup ) - (char *)(_actionlmm));
+    k = ((char *)&( (*_actioncpu).p_actionListHookup ) - (char *)(_actioncpu));
+    void *toto = &(*_actionlmm).p_actionListHookup;
+    void *tata = _actionlmm;
+    ActionLmm aieu;
+    ActionLmmPtr actionBase = &aieu;
+    void *actionBaseVoid = actionBase;
+    void *actionBaseCVoid = static_cast<void*>(actionBase);
+    ActionLmmPtr actionBaseVoidBase = (ActionLmmPtr)actionBaseVoid;
+    ActionLmmPtr actionBaseCVoidCBase = static_cast<ActionLmmPtr>(actionBaseCVoid);
+    p_modifiedSet = xbt_swag_new(xbt_swag_offset(*_actionlmm, p_actionListHookup));
+    p_maxminSystem->keep_track = p_modifiedSet;
   }
   }
-  /* Define callbacks */
-  //TODO sg_platf_host_add_cb(parse_cpu_init);
-  //TODO sg_platf_postparse_add_cb(cpu_add_traces_cpu);
 }
 
 CpuCas01Model::~CpuCas01Model()
 }
 
 CpuCas01Model::~CpuCas01Model()
@@ -119,8 +150,7 @@ CpuCas01LmmPtr CpuCas01Model::createResource(const char *name, double power_peak
                           tmgr_trace_t state_trace,
                           xbt_dict_t cpu_properties)
 {
                           tmgr_trace_t state_trace,
                           xbt_dict_t cpu_properties)
 {
-  CpuCas01LmmPtr cpu = NULL;
-
+  CpuPtr cpu = NULL;
   xbt_assert(!surf_cpu_resource_priv(surf_cpu_resource_by_name(name)),
              "Host '%s' declared several times in the platform file",
              name);
   xbt_assert(!surf_cpu_resource_priv(surf_cpu_resource_by_name(name)),
              "Host '%s' declared several times in the platform file",
              name);
@@ -128,8 +158,7 @@ CpuCas01LmmPtr CpuCas01Model::createResource(const char *name, double power_peak
   xbt_assert(core > 0, "Invalid number of cores %d", core);
 
   cpu = new CpuCas01Lmm(this, name, power_peak, power_scale, power_trace, core, state_initial, state_trace, cpu_properties);
   xbt_assert(core > 0, "Invalid number of cores %d", core);
 
   cpu = new CpuCas01Lmm(this, name, power_peak, power_scale, power_trace, core, state_initial, state_trace, cpu_properties);
-
-  xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, this);
+  xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu);
 
   return (CpuCas01LmmPtr) xbt_lib_get_elm_or_null(host_lib, name);;
 }
 
   return (CpuCas01LmmPtr) xbt_lib_get_elm_or_null(host_lib, name);;
 }
@@ -155,24 +184,24 @@ 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);
-    CpuCas01LmmPtr host = (CpuCas01LmmPtr) surf_cpu_resource_by_name(elm);
+    CpuCas01LmmPtr host = (CpuCas01LmmPtr) surf_cpu_resource_priv(surf_cpu_resource_by_name(elm));
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
     host->p_stateEvent =
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
     host->p_stateEvent =
-        tmgr_history_add_trace(history, trace, 0.0, 0, host);
+        tmgr_history_add_trace(history, trace, 0.0, 0, (ResourcePtr) host);
   }
 
   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);
-    CpuCas01LmmPtr host = (CpuCas01LmmPtr) surf_cpu_resource_by_name(elm);
+    CpuCas01LmmPtr host = (CpuCas01LmmPtr) surf_cpu_resource_priv(surf_cpu_resource_by_name(elm));
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
     host->p_powerEvent =
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
     host->p_powerEvent =
-        tmgr_history_add_trace(history, trace, 0.0, 0, host);
+        tmgr_history_add_trace(history, trace, 0.0, 0, (ResourcePtr) host);
   }
 }
 
   }
 }
 
@@ -182,17 +211,17 @@ void CpuCas01Model::addTraces()
 CpuCas01Lmm::CpuCas01Lmm(CpuCas01ModelPtr model, const char *name, double powerPeak,
         double powerScale, tmgr_trace_t powerTrace, int core,
         e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace,
 CpuCas01Lmm::CpuCas01Lmm(CpuCas01ModelPtr model, const char *name, double powerPeak,
         double powerScale, tmgr_trace_t powerTrace, int core,
         e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace,
-       xbt_dict_t properties) :  
-       CpuLmm(model, name, properties) {
+       xbt_dict_t properties) :
+       CpuLmm(model, name, properties), Resource(model, name, properties) {
   m_powerPeak = powerPeak;
   m_powerScale = powerScale;
   m_core = core;
   p_stateCurrent = stateInitial;
   if (powerTrace)
   m_powerPeak = powerPeak;
   m_powerScale = powerScale;
   m_core = core;
   p_stateCurrent = stateInitial;
   if (powerTrace)
-    p_powerEvent = tmgr_history_add_trace(history, powerTrace, 0.0, 0, this);
+    p_powerEvent = tmgr_history_add_trace(history, powerTrace, 0.0, 0, static_cast<ResourcePtr>(this));
 
   if (stateTrace)
 
   if (stateTrace)
-    p_stateEvent = tmgr_history_add_trace(history, stateTrace, 0.0, 0, this);
+    p_stateEvent = tmgr_history_add_trace(history, stateTrace, 0.0, 0, static_cast<ResourcePtr>(this));
 
   p_constraint = lmm_constraint_new(p_model->p_maxminSystem, this, m_core * m_powerScale * m_powerPeak);
 }
 
   p_constraint = lmm_constraint_new(p_model->p_maxminSystem, this, m_core * m_powerScale * m_powerPeak);
 }
@@ -221,7 +250,8 @@ void CpuCas01Lmm::updateState(tmgr_trace_event_t event_type, double value, doubl
 #endif
     while ((var = lmm_get_var_from_cnst
             (surf_cpu_model->p_maxminSystem, p_constraint, &elem))) {
 #endif
     while ((var = lmm_get_var_from_cnst
             (surf_cpu_model->p_maxminSystem, p_constraint, &elem))) {
-      CpuCas01ActionLmmPtr action = (CpuCas01ActionLmmPtr) lmm_variable_id(var);
+      CpuCas01ActionLmmPtr action = static_cast<CpuCas01ActionLmmPtr>(static_cast<ActionLmmPtr>(lmm_variable_id(var)));
+
       lmm_update_variable_bound(surf_cpu_model->p_maxminSystem,
                                 action->p_variable,
                                 m_powerScale * m_powerPeak);
       lmm_update_variable_bound(surf_cpu_model->p_maxminSystem,
                                 action->p_variable,
                                 m_powerScale * m_powerPeak);
@@ -237,7 +267,7 @@ void CpuCas01Lmm::updateState(tmgr_trace_event_t event_type, double value, doubl
       p_stateCurrent = SURF_RESOURCE_OFF;
 
       while ((var = lmm_get_var_from_cnst(surf_cpu_model->p_maxminSystem, cnst, &elem))) {
       p_stateCurrent = SURF_RESOURCE_OFF;
 
       while ((var = lmm_get_var_from_cnst(surf_cpu_model->p_maxminSystem, cnst, &elem))) {
-        ActionPtr action = (ActionPtr) lmm_variable_id(var);
+        ActionLmmPtr action = static_cast<ActionLmmPtr>(lmm_variable_id(var));
 
         if (action->getState() == SURF_ACTION_RUNNING ||
             action->getState() == SURF_ACTION_READY ||
 
         if (action->getState() == SURF_ACTION_RUNNING ||
             action->getState() == SURF_ACTION_READY ||
@@ -267,7 +297,7 @@ CpuActionPtr CpuCas01Lmm::execute(double size)
                                                    calloc but it seems to help valgrind... */
 
   action->p_variable =
                                                    calloc but it seems to help valgrind... */
 
   action->p_variable =
-      lmm_variable_new(surf_cpu_model->p_maxminSystem, action,
+      lmm_variable_new(surf_cpu_model->p_maxminSystem, static_cast<ActionLmmPtr>(action),
                        action->m_priority,
                        m_powerScale * m_powerPeak, 1);
   if (surf_cpu_model->p_updateMechanism == UM_LAZY) {
                        action->m_priority,
                        m_powerScale * m_powerPeak, 1);
   if (surf_cpu_model->p_updateMechanism == UM_LAZY) {
@@ -295,9 +325,9 @@ CpuActionPtr CpuCas01Lmm::sleep(double duration)
   if (duration == NO_MAX_DURATION) {
     /* Move to the *end* of the corresponding action set. This convention
        is used to speed up update_resource_state  */
   if (duration == NO_MAX_DURATION) {
     /* Move to the *end* of the corresponding action set. This convention
        is used to speed up update_resource_state  */
-    xbt_swag_remove(action, action->p_stateSet);
+    xbt_swag_remove(static_cast<ActionPtr>(action), action->p_stateSet);
     action->p_stateSet = cpu_running_action_set_that_does_not_need_being_checked;
     action->p_stateSet = cpu_running_action_set_that_does_not_need_being_checked;
-    xbt_swag_insert(action, action->p_stateSet);
+    xbt_swag_insert(static_cast<ActionPtr>(action), action->p_stateSet);
   }
 
   lmm_update_variable_weight(surf_cpu_model->p_maxminSystem,
   }
 
   lmm_update_variable_weight(surf_cpu_model->p_maxminSystem,
index 7b2a76e..17895d5 100644 (file)
@@ -57,8 +57,5 @@ public:
 class CpuCas01ActionLmm: public CpuActionLmm {
 public:
   CpuCas01ActionLmm() {};
 class CpuCas01ActionLmm: public CpuActionLmm {
 public:
   CpuCas01ActionLmm() {};
-  CpuCas01ActionLmm(ModelPtr model, double cost, bool failed): CpuActionLmm(model, cost, failed) {};
-  int unref() {return 0;};//TODO
-  void cancel() {};//TODO
-  void recycle() {};//TODO
+  CpuCas01ActionLmm(ModelPtr model, double cost, bool failed): Action(model, cost, failed), CpuActionLmm(model, cost, failed) {};
 };
 };
index 3b5020a..e4b500a 100644 (file)
@@ -840,9 +840,9 @@ CpuActionPtr CpuTi::sleep(double duration)
   if (duration == NO_MAX_DURATION) {
     /* Move to the *end* of the corresponding action set. This convention
        is used to speed up update_resource_state  */
   if (duration == NO_MAX_DURATION) {
     /* Move to the *end* of the corresponding action set. This convention
        is used to speed up update_resource_state  */
-    xbt_swag_remove(action, action->p_stateSet);
+    xbt_swag_remove(static_cast<ActionPtr>(action), action->p_stateSet);
     action->p_stateSet = cpu_ti_running_action_set_that_does_not_need_being_checked;
     action->p_stateSet = cpu_ti_running_action_set_that_does_not_need_being_checked;
-    xbt_swag_insert(action, action->p_stateSet);
+    xbt_swag_insert(static_cast<ActionPtr>(action), action->p_stateSet);
   }
   XBT_OUT();
   return action;
   }
   XBT_OUT();
   return action;
@@ -875,7 +875,7 @@ int CpuTiAction::unref()
 {
   m_refcount--;
   if (!m_refcount) {
 {
   m_refcount--;
   if (!m_refcount) {
-    xbt_swag_remove(this, p_stateSet);
+    xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
     /* remove from action_set */
     xbt_swag_remove(this, ((CpuTiPtr)surf_cpu_resource_priv(p_cpu))->p_actionSet);
     /* remove from heap */
     /* remove from action_set */
     xbt_swag_remove(this, ((CpuTiPtr)surf_cpu_resource_priv(p_cpu))->p_actionSet);
     /* remove from heap */
index ab8d902..e01213e 100644 (file)
@@ -17,6 +17,105 @@ double sg_weight_S_parameter = 0.0;     /* default value; can be set by model or
 double sg_tcp_gamma = 0.0;
 int sg_network_crosstraffic = 0;
 
 double sg_tcp_gamma = 0.0;
 int sg_network_crosstraffic = 0;
 
+/*************
+ * CallBacks *
+ *************/
+
+static void net_parse_link_init(sg_platf_link_cbarg_t link){
+  if (link->policy == SURF_LINK_FULLDUPLEX) {
+    char *link_id;
+    link_id = bprintf("%s_UP", link->id);
+    surf_network_model->createResource(link_id,
+                      link->bandwidth,
+                      link->bandwidth_trace,
+                      link->latency,
+                      link->latency_trace,
+                      link->state,
+                      link->state_trace, link->policy, link->properties);
+    xbt_free(link_id);
+    link_id = bprintf("%s_DOWN", link->id);
+    surf_network_model->createResource(link_id,
+                      link->bandwidth,
+                      link->bandwidth_trace,
+                      link->latency,
+                      link->latency_trace,
+                      link->state,
+                      link->state_trace, link->policy, link->properties);
+    xbt_free(link_id);
+  } else {
+       surf_network_model->createResource(link->id,
+                      link->bandwidth,
+                      link->bandwidth_trace,
+                      link->latency,
+                      link->latency_trace,
+                      link->state,
+                      link->state_trace, link->policy, link->properties);
+  }
+}
+
+static void net_add_traces(void){
+  xbt_dict_cursor_t cursor = NULL;
+  char *trace_name, *elm;
+
+  static int called = 0;
+  if (called)
+    return;
+  called = 1;
+
+  /* connect all traces relative to network */
+  xbt_dict_foreach(trace_connect_list_link_avail, cursor, trace_name, elm) {
+    tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
+    NetworkCm02LinkLmmPtr link = static_cast<NetworkCm02LinkLmmPtr>(
+                                    static_cast<NetworkCm02LinkPtr>(
+                                                 xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL)));
+
+    xbt_assert(link, "Cannot connect trace %s to link %s: link undefined",
+               trace_name, elm);
+    xbt_assert(trace,
+               "Cannot connect trace %s to link %s: trace undefined",
+               trace_name, elm);
+
+    link->p_stateEvent = tmgr_history_add_trace(history, trace, 0.0, 0, link);
+  }
+
+  xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) {
+    tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
+    NetworkCm02LinkLmmPtr link = static_cast<NetworkCm02LinkLmmPtr>(
+                                 static_cast<NetworkCm02LinkPtr>(
+                                             xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL)));
+
+    xbt_assert(link, "Cannot connect trace %s to link %s: link undefined",
+               trace_name, elm);
+    xbt_assert(trace,
+               "Cannot connect trace %s to link %s: trace undefined",
+               trace_name, elm);
+
+    link->p_power.event = tmgr_history_add_trace(history, trace, 0.0, 0, link);
+  }
+
+  xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) {
+    tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
+    NetworkCm02LinkLmmPtr link = static_cast<NetworkCm02LinkLmmPtr>(
+                                 static_cast<NetworkCm02LinkPtr>(
+                                             xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL)));
+
+    xbt_assert(link, "Cannot connect trace %s to link %s: link undefined",
+               trace_name, elm);
+    xbt_assert(trace,
+               "Cannot connect trace %s to link %s: trace undefined",
+               trace_name, elm);
+
+    link->p_latEvent = tmgr_history_add_trace(history, trace, 0.0, 0, link);
+  }
+}
+
+static void net_define_callbacks(void)
+{
+  /* Figuring out the network links */
+  sg_platf_link_add_cb(net_parse_link_init);
+  sg_platf_postparse_add_cb(net_add_traces);
+}
+
 /*********
  * Model *
  *********/
 /*********
  * Model *
  *********/
@@ -41,7 +140,9 @@ void surf_network_model_init_LegrandVelho(void)
     return;
 
   surf_network_model = new NetworkCm02Model();
     return;
 
   surf_network_model = new NetworkCm02Model();
-  xbt_dynar_push(model_list, &surf_network_model);
+  net_define_callbacks();
+  ModelPtr model = static_cast<ModelPtr>(surf_network_model);
+  xbt_dynar_push(model_list, &model);
 
   xbt_cfg_setdefault_double(_sg_cfg_set, "network/latency_factor",
                             13.01);
 
   xbt_cfg_setdefault_double(_sg_cfg_set, "network/latency_factor",
                             13.01);
@@ -68,7 +169,9 @@ void surf_network_model_init_CM02(void)
     return;
 
   surf_network_model = new NetworkCm02Model();
     return;
 
   surf_network_model = new NetworkCm02Model();
-  xbt_dynar_push(model_list, &surf_network_model);
+  net_define_callbacks();
+  ModelPtr model = static_cast<ModelPtr>(surf_network_model);
+  xbt_dynar_push(model_list, &model);
 
   xbt_cfg_setdefault_double(_sg_cfg_set, "network/latency_factor", 1.0);
   xbt_cfg_setdefault_double(_sg_cfg_set, "network/bandwidth_factor",
 
   xbt_cfg_setdefault_double(_sg_cfg_set, "network/latency_factor", 1.0);
   xbt_cfg_setdefault_double(_sg_cfg_set, "network/bandwidth_factor",
@@ -92,7 +195,9 @@ void surf_network_model_init_Reno(void)
     return;
 
   surf_network_model = new NetworkCm02Model();
     return;
 
   surf_network_model = new NetworkCm02Model();
-  xbt_dynar_push(model_list, &surf_network_model);
+  net_define_callbacks();
+  ModelPtr model = static_cast<ModelPtr>(surf_network_model);
+  xbt_dynar_push(model_list, &model);
   lmm_set_default_protocol_function(func_reno_f, func_reno_fp,
                                     func_reno_fpi);
   surf_network_model->f_networkSolve = lagrange_solve;
   lmm_set_default_protocol_function(func_reno_f, func_reno_fp,
                                     func_reno_fpi);
   surf_network_model->f_networkSolve = lagrange_solve;
@@ -110,7 +215,9 @@ void surf_network_model_init_Reno2(void)
     return;
 
   surf_network_model = new NetworkCm02Model();
     return;
 
   surf_network_model = new NetworkCm02Model();
-  xbt_dynar_push(model_list, &surf_network_model);
+  net_define_callbacks();
+  ModelPtr model = static_cast<ModelPtr>(surf_network_model);
+  xbt_dynar_push(model_list, &model);
   lmm_set_default_protocol_function(func_reno2_f, func_reno2_fp,
                                     func_reno2_fpi);
   surf_network_model->f_networkSolve = lagrange_solve;
   lmm_set_default_protocol_function(func_reno2_f, func_reno2_fp,
                                     func_reno2_fpi);
   surf_network_model->f_networkSolve = lagrange_solve;
@@ -128,7 +235,9 @@ void surf_network_model_init_Vegas(void)
     return;
 
   surf_network_model = new NetworkCm02Model();
     return;
 
   surf_network_model = new NetworkCm02Model();
-  xbt_dynar_push(model_list, &surf_network_model);
+  net_define_callbacks();
+  ModelPtr model = static_cast<ModelPtr>(surf_network_model);
+  xbt_dynar_push(model_list, &model);
   lmm_set_default_protocol_function(func_vegas_f, func_vegas_fp,
                                     func_vegas_fpi);
   surf_network_model->f_networkSolve = lagrange_solve;
   lmm_set_default_protocol_function(func_vegas_f, func_vegas_fp,
                                     func_vegas_fpi);
   surf_network_model->f_networkSolve = lagrange_solve;
@@ -199,7 +308,7 @@ NetworkCm02LinkLmmPtr NetworkCm02Model::createResource(const char *name,
                                                 state_initial, state_trace, bw_initial, bw_trace, lat_initial, lat_trace, policy);
 
 
                                                 state_initial, state_trace, bw_initial, bw_trace, lat_initial, lat_trace, policy);
 
 
-  xbt_lib_set(link_lib, name, SURF_LINK_LEVEL, nw_link);
+  xbt_lib_set(link_lib, name, SURF_LINK_LEVEL, static_cast<NetworkCm02LinkPtr>(nw_link));
   XBT_DEBUG("Create link '%s'",name);
 
   return nw_link;
   XBT_DEBUG("Create link '%s'",name);
 
   return nw_link;
@@ -269,6 +378,7 @@ NetworkCm02ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEd
                                                 double size, double rate)
 {
   unsigned int i;
                                                 double size, double rate)
 {
   unsigned int i;
+  void *_link;
   NetworkCm02LinkLmmPtr link;
   int failed = 0;
   NetworkCm02ActionLmmPtr action = NULL;
   NetworkCm02LinkLmmPtr link;
   int failed = 0;
   NetworkCm02ActionLmmPtr action = NULL;
@@ -286,7 +396,8 @@ NetworkCm02ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEd
              "You're trying to send data from %s to %s but there is no connection at all between these two hosts.",
              src->p_name, dst->p_name);
 
              "You're trying to send data from %s to %s but there is no connection at all between these two hosts.",
              src->p_name, dst->p_name);
 
-  xbt_dynar_foreach(route, i, link) {
+  xbt_dynar_foreach(route, i, _link) {
+       link = static_cast<NetworkCm02LinkLmmPtr>(static_cast<NetworkCm02LinkPtr>(_link));
     if (link->p_stateCurrent == SURF_RESOURCE_OFF) {
       failed = 1;
       break;
     if (link->p_stateCurrent == SURF_RESOURCE_OFF) {
       failed = 1;
       break;
@@ -294,7 +405,8 @@ NetworkCm02ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEd
   }
   if (sg_network_crosstraffic == 1) {
          routing_platf->getRouteAndLatency(dst, src, &back_route, NULL);
   }
   if (sg_network_crosstraffic == 1) {
          routing_platf->getRouteAndLatency(dst, src, &back_route, NULL);
-    xbt_dynar_foreach(back_route, i, link) {
+    xbt_dynar_foreach(back_route, i, _link) {
+      link = static_cast<NetworkCm02LinkLmmPtr>(static_cast<NetworkCm02LinkPtr>(_link));
       if (link->p_stateCurrent == SURF_RESOURCE_OFF) {
         failed = 1;
         break;
       if (link->p_stateCurrent == SURF_RESOURCE_OFF) {
         failed = 1;
         break;
@@ -309,7 +421,7 @@ NetworkCm02ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEd
 #endif
   action->m_weight = action->m_latency = latency;
 
 #endif
   action->m_weight = action->m_latency = latency;
 
-  xbt_swag_insert(action, action->p_stateSet);
+  //FIXME:REMOVxbt_swag_insert(action, action->p_stateSet);
   action->m_rate = rate;
   if (p_updateMechanism == UM_LAZY) {
     action->m_indexHeap = -1;
   action->m_rate = rate;
   if (p_updateMechanism == UM_LAZY) {
     action->m_indexHeap = -1;
@@ -324,9 +436,9 @@ NetworkCm02ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEd
          (link->p_power.peak * link->p_power.scale);
     }
   }
          (link->p_power.peak * link->p_power.scale);
     }
   }
-  xbt_dynar_foreach(route, i, link) {
-    double bb = bandwidthFactor(size) *
-        (link->p_power.peak * link->p_power.scale);
+  xbt_dynar_foreach(route, i, _link) {
+       link = static_cast<NetworkCm02LinkLmmPtr>(static_cast<NetworkCm02LinkPtr>(_link));
+    double bb = bandwidthFactor(size) * (link->p_power.peak * link->p_power.scale);
     bandwidth_bound =
         (bandwidth_bound < 0.0) ? bb : min(bandwidth_bound, bb);
   }
     bandwidth_bound =
         (bandwidth_bound < 0.0) ? bb : min(bandwidth_bound, bb);
   }
@@ -338,7 +450,8 @@ NetworkCm02ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEd
     xbt_assert(!xbt_dynar_is_empty(route),
                "Using a model with a gap (e.g., SMPI) with a platform without links (e.g. vivaldi)!!!");
 
     xbt_assert(!xbt_dynar_is_empty(route),
                "Using a model with a gap (e.g., SMPI) with a platform without links (e.g. vivaldi)!!!");
 
-    link = *(NetworkCm02LinkLmmPtr *) xbt_dynar_get_ptr(route, 0);
+    //link = *(NetworkCm02LinkLmmPtr *) xbt_dynar_get_ptr(route, 0);
+    link = static_cast<NetworkCm02LinkLmmPtr>(*static_cast<NetworkCm02LinkPtr *>(xbt_dynar_get_ptr(route, 0)));
     gapAppend(size, link, action);
     XBT_DEBUG("Comm %p: %s -> %s gap=%f (lat=%f)",
               action, src->p_name, dst->p_name, action->m_senderGap,
     gapAppend(size, link, action);
     XBT_DEBUG("Comm %p: %s -> %s gap=%f (lat=%f)",
               action, src->p_name, dst->p_name, action->m_senderGap,
@@ -367,13 +480,15 @@ NetworkCm02ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEd
     lmm_update_variable_bound(p_maxminSystem, action->p_variable, (action->m_latCurrent > 0) ? min(action->m_rate, sg_tcp_gamma / (2.0 * action->m_latCurrent)) : action->m_rate);
   }
 
     lmm_update_variable_bound(p_maxminSystem, action->p_variable, (action->m_latCurrent > 0) ? min(action->m_rate, sg_tcp_gamma / (2.0 * action->m_latCurrent)) : action->m_rate);
   }
 
-  xbt_dynar_foreach(route, i, link) {
+  xbt_dynar_foreach(route, i, _link) {
+       link = static_cast<NetworkCm02LinkLmmPtr>(static_cast<NetworkCm02LinkPtr>(_link));
     lmm_expand(p_maxminSystem, link->p_constraint, action->p_variable, 1.0);
   }
 
   if (sg_network_crosstraffic == 1) {
     XBT_DEBUG("Fullduplex active adding backward flow using 5%%");
     lmm_expand(p_maxminSystem, link->p_constraint, action->p_variable, 1.0);
   }
 
   if (sg_network_crosstraffic == 1) {
     XBT_DEBUG("Fullduplex active adding backward flow using 5%%");
-    xbt_dynar_foreach(back_route, i, link) {
+    xbt_dynar_foreach(back_route, i, _link) {
+      link = static_cast<NetworkCm02LinkLmmPtr>(static_cast<NetworkCm02LinkPtr>(_link));
       lmm_expand(p_maxminSystem, link->p_constraint, action->p_variable, .05);
     }
   }
       lmm_expand(p_maxminSystem, link->p_constraint, action->p_variable, .05);
     }
   }
@@ -410,7 +525,9 @@ NetworkCm02LinkLmm::NetworkCm02LinkLmm(NetworkCm02ModelPtr model, const char *na
                                   double lat_initial,
                                   tmgr_trace_t lat_trace,
                                   e_surf_link_sharing_policy_t policy)
                                   double lat_initial,
                                   tmgr_trace_t lat_trace,
                                   e_surf_link_sharing_policy_t policy)
-: ResourceLmm(model, name, props, system, constraint_value, history, state_init, state_trace, metric_peak, metric_trace)
+: Resource(model, name, props),
+  ResourceLmm(model, name, props, system, constraint_value, history, state_init, state_trace, metric_peak, metric_trace),
+  NetworkCm02Link(model, name, props)
 {
   m_latCurrent = lat_initial;
   if (lat_trace)
 {
   m_latCurrent = lat_initial;
   if (lat_trace)
index 32fbdaa..f5e196d 100644 (file)
@@ -49,7 +49,6 @@ public:
                                    e_surf_link_sharing_policy_t policy,
                                    xbt_dict_t properties);
   void updateActionsStateLazy(double now, double delta);
                                    e_surf_link_sharing_policy_t policy,
                                    xbt_dict_t properties);
   void updateActionsStateLazy(double now, double delta);
-  void updateActionsStateFull(double now, double delta);
   virtual void gapAppend(double size, const NetworkCm02LinkLmmPtr link, NetworkCm02ActionLmmPtr action) {};
   NetworkCm02ActionPtr communicate(RoutingEdgePtr src, RoutingEdgePtr dst,
                                           double size, double rate);
   virtual void gapAppend(double size, const NetworkCm02LinkLmmPtr link, NetworkCm02ActionLmmPtr action) {};
   NetworkCm02ActionPtr communicate(RoutingEdgePtr src, RoutingEdgePtr dst,
                                           double size, double rate);
@@ -104,7 +103,8 @@ public:
  **********/
 class NetworkCm02Action : virtual public Action {
 public:
  **********/
 class NetworkCm02Action : virtual public Action {
 public:
-  NetworkCm02Action(ModelPtr model, double cost, bool failed): Action(model, cost, failed) {};
+  NetworkCm02Action(ModelPtr model, double cost, bool failed)
+ : Action(model, cost, failed) {};
   double m_latency;
   double m_latCurrent;
   double m_weight;
   double m_latency;
   double m_latCurrent;
   double m_weight;
@@ -121,7 +121,10 @@ public:
 
 class NetworkCm02ActionLmm : public ActionLmm, public NetworkCm02Action {
 public:
 
 class NetworkCm02ActionLmm : public ActionLmm, public NetworkCm02Action {
 public:
-  NetworkCm02ActionLmm(ModelPtr model, double cost, bool failed): ActionLmm(model, cost, failed), NetworkCm02Action(model, cost, failed) {};
+  NetworkCm02ActionLmm(ModelPtr model, double cost, bool failed)
+ : Action(model, cost, failed),
+   ActionLmm(model, cost, failed),
+   NetworkCm02Action(model, cost, failed) {};
   void updateRemainingLazy(double now);
   void recycle();
 };
   void updateRemainingLazy(double now);
   void recycle();
 };
index fc4babc..4509a74 100644 (file)
@@ -22,7 +22,8 @@ void surf_network_model_init_Constant()
 
   //FIXME:sg_platf_host_add_cb(netcste_count_hosts);
 
 
   //FIXME:sg_platf_host_add_cb(netcste_count_hosts);
 
-  xbt_dynar_push(model_list, &surf_network_model);
+  ModelPtr model = static_cast<ModelPtr>(surf_network_model);
+  xbt_dynar_push(model_list, &model);
 
   //FIXME:routing_model_create(NULL);
 }
 
   //FIXME:routing_model_create(NULL);
 }
@@ -129,7 +130,7 @@ int NetworkConstantActionLmm::unref()
 {
   m_refcount--;
   if (!m_refcount) {
 {
   m_refcount--;
   if (!m_refcount) {
-    xbt_swag_remove(this, p_stateSet);
+    xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
     delete this;
   return 1;
   }
     delete this;
   return 1;
   }
index 38736be..ef9344b 100644 (file)
@@ -53,7 +53,7 @@ public:
        m_latency = latency;
        if (m_latency <= 0.0) {
          p_stateSet = p_model->p_doneActionSet;
        m_latency = latency;
        if (m_latency <= 0.0) {
          p_stateSet = p_model->p_doneActionSet;
-         xbt_swag_insert(this, p_stateSet);
+         xbt_swag_insert(static_cast<ActionPtr>(this), p_stateSet);
        }
   };
   int unref();
        }
   };
   int unref();
index 771091b..1824c92 100644 (file)
@@ -22,22 +22,35 @@ lmm_system_t storage_maxmin_system = NULL;
 static int storage_selective_update = 0;
 static xbt_swag_t storage_running_action_set_that_does_not_need_being_checked = NULL;
 
 static int storage_selective_update = 0;
 static xbt_swag_t storage_running_action_set_that_does_not_need_being_checked = NULL;
 
-void storage_register_callbacks() {
+/*************
+ * CallBacks *
+ *************/
 
 
-  /*FIXME:ROUTING_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,xbt_free);
-  ROUTING_STORAGE_HOST_LEVEL = xbt_lib_add_level(storage_lib,routing_storage_host_free);
-  ROUTING_STORAGE_TYPE_LEVEL = xbt_lib_add_level(storage_type_lib,routing_storage_type_free);
-  SURF_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,surf_storage_resource_free);
+static XBT_INLINE void routing_storage_type_free(void *r)
+{
+  storage_type_t stype = (storage_type_t) r;
+  free(stype->model);
+  free(stype->type_id);
+  free(stype->content);
+  xbt_dict_free(&(stype->properties));
+  free(stype);
+}
 
 
-  sg_platf_storage_add_cb(storage_parse_storage);
-  sg_platf_mstorage_add_cb(storage_parse_mstorage);
-  sg_platf_storage_type_add_cb(storage_parse_storage_type);
-  sg_platf_mount_add_cb(storage_parse_mount);*/
+static XBT_INLINE void surf_storage_resource_free(void *r)
+{
+  // specific to storage
+  StoragePtr storage = (StoragePtr) r;
+  xbt_dict_free(&storage->p_content);
+  xbt_dynar_free(&storage->p_writeActions);
+  // generic resource
+  delete storage;
 }
 
 }
 
-/***********
- * PARSING *
- ***********/
+static XBT_INLINE void routing_storage_host_free(void *r)
+{
+  xbt_dynar_t dyn = (xbt_dynar_t) r;
+  xbt_dynar_free(&dyn);
+}
 
 static void parse_storage_init(sg_platf_storage_cbarg_t storage)
 {
 
 static void parse_storage_init(sg_platf_storage_cbarg_t storage)
 {
@@ -203,30 +216,25 @@ static void storage_parse_mount(sg_platf_mount_cbarg_t mount)
   xbt_dynar_push(mount_list,&mnt);
 }
 
   xbt_dynar_push(mount_list,&mnt);
 }
 
-static XBT_INLINE void routing_storage_type_free(void *r)
+static void storage_define_callbacks()
 {
 {
-  storage_type_t stype = (storage_type_t) r;
-  free(stype->model);
-  free(stype->type_id);
-  free(stype->content);
-  xbt_dict_free(&(stype->properties));
-  free(stype);
+  sg_platf_storage_add_cb(parse_storage_init);
+  sg_platf_storage_type_add_cb(parse_storage_type_init);
+  sg_platf_mstorage_add_cb(parse_mstorage_init);
+  sg_platf_mount_add_cb(parse_mount_init);
 }
 
 }
 
-static XBT_INLINE void surf_storage_resource_free(void *r)
-{
-  // specific to storage
-  StoragePtr storage = (StoragePtr) r;
-  xbt_dict_free(&storage->p_content);
-  xbt_dynar_free(&storage->p_writeActions);
-  // generic resource
-  delete storage;
-}
+void storage_register_callbacks() {
 
 
-static XBT_INLINE void routing_storage_host_free(void *r)
-{
-  xbt_dynar_t dyn = (xbt_dynar_t) r;
-  xbt_dynar_free(&dyn);
+  ROUTING_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,xbt_free);
+  ROUTING_STORAGE_HOST_LEVEL = xbt_lib_add_level(storage_lib, routing_storage_host_free);
+  ROUTING_STORAGE_TYPE_LEVEL = xbt_lib_add_level(storage_type_lib, routing_storage_type_free);
+  SURF_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, surf_storage_resource_free);
+
+  sg_platf_storage_add_cb(storage_parse_storage);
+  sg_platf_mstorage_add_cb(storage_parse_mstorage);
+  sg_platf_storage_type_add_cb(storage_parse_storage_type);
+  sg_platf_mount_add_cb(storage_parse_mount);
 }
 
 /*********
 }
 
 /*********
@@ -235,33 +243,22 @@ static XBT_INLINE void routing_storage_host_free(void *r)
 
 void surf_storage_model_init_default(void)
 {
 
 void surf_storage_model_init_default(void)
 {
-  new StorageModel();
+  surf_storage_model = new StorageModel();
+  storage_define_callbacks();
+  xbt_dynar_push(model_list, &surf_storage_model);
 }
 
 StorageModel::StorageModel() : Model("Storage"){
   StorageActionLmm action;
 }
 
 StorageModel::StorageModel() : Model("Storage"){
   StorageActionLmm action;
+
+  XBT_DEBUG("surf_storage_model_init_internal");
+
   storage_running_action_set_that_does_not_need_being_checked =
       xbt_swag_new(xbt_swag_offset(action, p_stateHookup));
 
   if (!storage_maxmin_system) {
     storage_maxmin_system = lmm_system_new(storage_selective_update);
   }
   storage_running_action_set_that_does_not_need_being_checked =
       xbt_swag_new(xbt_swag_offset(action, p_stateHookup));
 
   if (!storage_maxmin_system) {
     storage_maxmin_system = lmm_system_new(storage_selective_update);
   }
-  xbt_dynar_push(model_list, this);
-
-  sg_platf_storage_add_cb(parse_storage_init);
-  sg_platf_storage_type_add_cb(parse_storage_type_init);
-  sg_platf_mstorage_add_cb(parse_mstorage_init);
-  sg_platf_mount_add_cb(parse_mount_init);
-
-  ROUTING_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,xbt_free);
-  ROUTING_STORAGE_HOST_LEVEL = xbt_lib_add_level(storage_lib,routing_storage_host_free);
-  ROUTING_STORAGE_TYPE_LEVEL = xbt_lib_add_level(storage_type_lib,routing_storage_type_free);
-  SURF_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,surf_storage_resource_free);
-
-  sg_platf_storage_add_cb(storage_parse_storage);
-  sg_platf_mstorage_add_cb(storage_parse_mstorage);
-  sg_platf_storage_type_add_cb(storage_parse_storage_type);
-  sg_platf_mount_add_cb(storage_parse_mount);
 }
 
 
 }
 
 
@@ -284,19 +281,16 @@ StoragePtr StorageModel::createResource(const char* id, const char* model, const
               "Storage '%s' declared several times in the platform file",
               id);
 
               "Storage '%s' declared several times in the platform file",
               id);
 
-  StoragePtr storage ;//= new Storage();
-
   storage_type_t storage_type = (storage_type_t) xbt_lib_get_or_null(storage_type_lib, type_id,ROUTING_STORAGE_TYPE_LEVEL);
   storage_type_t storage_type = (storage_type_t) xbt_lib_get_or_null(storage_type_lib, type_id,ROUTING_STORAGE_TYPE_LEVEL);
+
   double Bread  = atof((char*)xbt_dict_get(storage_type->properties, "Bread"));
   double Bwrite = atof((char*)xbt_dict_get(storage_type->properties, "Bwrite"));
   double Bread  = atof((char*)xbt_dict_get(storage_type->properties, "Bread"));
   double Bwrite = atof((char*)xbt_dict_get(storage_type->properties, "Bwrite"));
-  double Bconnection = atof((char*)xbt_dict_get(storage_type->properties, "Bconnection"));
-  XBT_DEBUG("Create resource with Bconnection '%f' Bread '%f' Bwrite '%f' and Size '%lu'", Bconnection, Bread, Bwrite, (unsigned long)storage_type->size);
-  storage->p_constraint = lmm_constraint_new(storage_maxmin_system, storage, Bconnection);
-  /* TOREPAIR: storage->constraint       = lmm_constraint_new(storage_maxmin_system, storage, Bconnection);
-  storage->constraint_read  = lmm_constraint_new(storage_maxmin_system, storage, Bread);
-  storage->constraint_write = lmm_constraint_new(storage_maxmin_system, storage, Bwrite);*/
-  storage->p_content = parseContent((char*)content_name, &(storage->m_usedSize));
-  storage->m_size = storage_type->size;
+  double Bconnection   = atof((char*)xbt_dict_get(storage_type->properties, "Bconnection"));
+
+  StoragePtr storage = new StorageLmm(this, NULL, NULL, p_maxminSystem,
+                 Bread, Bwrite, Bconnection,
+                 parseContent((char*)content_name, &(storage->m_usedSize)),
+                 storage_type->size);
 
   xbt_lib_set(storage_lib, id, SURF_STORAGE_LEVEL, storage);
 
 
   xbt_lib_set(storage_lib, id, SURF_STORAGE_LEVEL, storage);
 
@@ -437,6 +431,19 @@ Storage::Storage(StorageModelPtr model, const char* name, xbt_dict_t properties)
   p_writeActions = xbt_dynar_new(sizeof(char *),NULL);
 }
 
   p_writeActions = xbt_dynar_new(sizeof(char *),NULL);
 }
 
+StorageLmm::StorageLmm(StorageModelPtr model, const char* name, xbt_dict_t properties,
+            lmm_system_t maxminSystem, double bread, double bwrite, double bconnection,
+            xbt_dict_t content, size_t size)
+ :    ResourceLmm(), Storage(model, name, properties) {
+  XBT_DEBUG("Create resource with Bconnection '%f' Bread '%f' Bwrite '%f' and Size '%lu'", bconnection, bread, bwrite, ((unsigned long)size));
+
+  p_constraint = lmm_constraint_new(maxminSystem, this, bconnection);
+  p_constraintRead  = lmm_constraint_new(maxminSystem, this, bread);
+  p_constraintWrite = lmm_constraint_new(maxminSystem, this, bwrite);
+  p_content = content;
+  m_size = size;
+}
+
 bool Storage::isUsed()
 {
   THROW_UNIMPLEMENTED;
 bool Storage::isUsed()
 {
   THROW_UNIMPLEMENTED;
@@ -448,9 +455,9 @@ void Storage::updateState(tmgr_trace_event_t event_type, double value, double da
   THROW_UNIMPLEMENTED;
 }
 
   THROW_UNIMPLEMENTED;
 }
 
-StorageActionLmmPtr Storage::ls(const char* path)
+StorageActionPtr StorageLmm::ls(const char* path)
 {
 {
-  StorageActionLmmPtr action = new StorageActionLmm(p_model, 0, m_stateCurrent != SURF_RESOURCE_ON, this, LS);
+  StorageActionLmmPtr action = new StorageActionLmm(p_model, 0, p_stateCurrent != SURF_RESOURCE_ON, this, LS);
 
   action->p_lsDict = NULL;
   xbt_dict_t ls_dict = xbt_dict_new();
 
   action->p_lsDict = NULL;
   xbt_dict_t ls_dict = xbt_dict_new();
@@ -491,7 +498,7 @@ StorageActionLmmPtr Storage::ls(const char* path)
   return action;
 }
 
   return action;
 }
 
-StorageActionLmmPtr Storage::open(const char* mount, const char* path)
+StorageActionPtr StorageLmm::open(const char* mount, const char* path)
 {
   XBT_DEBUG("\tOpen file '%s'",path);
   size_t size = (size_t) xbt_dict_get_or_null(p_content, path);
 {
   XBT_DEBUG("\tOpen file '%s'",path);
   size_t size = (size_t) xbt_dict_get_or_null(p_content, path);
@@ -505,12 +512,12 @@ StorageActionLmmPtr Storage::open(const char* mount, const char* path)
   file->size = size;
   file->storage = xbt_strdup(mount);
 
   file->size = size;
   file->storage = xbt_strdup(mount);
 
-  StorageActionLmmPtr action = new StorageActionLmm(p_model, 0, m_stateCurrent != SURF_RESOURCE_ON, this, OPEN);
+  StorageActionLmmPtr action = new StorageActionLmm(p_model, 0, p_stateCurrent != SURF_RESOURCE_ON, this, OPEN);
   action->p_file = file;
   return action;
 }
 
   action->p_file = file;
   return action;
 }
 
-StorageActionLmmPtr Storage::close(surf_file_t fd)
+StorageActionPtr StorageLmm::close(surf_file_t fd)
 {
   char *filename = fd->name;
   XBT_DEBUG("\tClose file '%s' size '%zu'", filename, fd->size);
 {
   char *filename = fd->name;
   XBT_DEBUG("\tClose file '%s' size '%zu'", filename, fd->size);
@@ -526,24 +533,24 @@ StorageActionLmmPtr Storage::close(surf_file_t fd)
   free(fd->name);
   free(fd->storage);
   xbt_free(fd);
   free(fd->name);
   free(fd->storage);
   xbt_free(fd);
-  StorageActionLmmPtr action = new StorageActionLmm(p_model, 0, m_stateCurrent != SURF_RESOURCE_ON, this, CLOSE);
+  StorageActionLmmPtr action = new StorageActionLmm(p_model, 0, p_stateCurrent != SURF_RESOURCE_ON, this, CLOSE);
   return action;
 }
 
   return action;
 }
 
-StorageActionLmmPtr Storage::read(void* ptr, size_t size, surf_file_t fd)
+StorageActionPtr StorageLmm::read(void* ptr, size_t size, surf_file_t fd)
 {
   if(size > fd->size)
     size = fd->size;
 {
   if(size > fd->size)
     size = fd->size;
-  StorageActionLmmPtr action = new StorageActionLmm(p_model, 0, m_stateCurrent != SURF_RESOURCE_ON, this, READ);
+  StorageActionLmmPtr action = new StorageActionLmm(p_model, 0, p_stateCurrent != SURF_RESOURCE_ON, this, READ);
   return action;
 }
 
   return action;
 }
 
-StorageActionLmmPtr Storage::write(const void* ptr, size_t size, surf_file_t fd)
+StorageActionPtr StorageLmm::write(const void* ptr, size_t size, surf_file_t fd)
 {
   char *filename = fd->name;
   XBT_DEBUG("\tWrite file '%s' size '%zu/%zu'",filename,size,fd->size);
 
 {
   char *filename = fd->name;
   XBT_DEBUG("\tWrite file '%s' size '%zu/%zu'",filename,size,fd->size);
 
-  StorageActionLmmPtr action = new StorageActionLmm(p_model, 0, m_stateCurrent != SURF_RESOURCE_ON, this, WRITE);
+  StorageActionLmmPtr action = new StorageActionLmm(p_model, 0, p_stateCurrent != SURF_RESOURCE_ON, this, WRITE);
   action->p_file = fd;
 
   // If the storage is full
   action->p_file = fd;
 
   // If the storage is full
@@ -557,8 +564,8 @@ StorageActionLmmPtr Storage::write(const void* ptr, size_t size, surf_file_t fd)
  * Action *
  **********/
 
  * Action *
  **********/
 
-StorageActionLmm::StorageActionLmm(ModelPtr model, double cost, bool failed, StoragePtr storage, e_surf_action_storage_type_t type)
-  : ActionLmm(model, cost, failed), p_storage(storage), m_type(type) {
+StorageActionLmm::StorageActionLmm(ModelPtr model, double cost, bool failed, StorageLmmPtr storage, e_surf_action_storage_type_t type)
+  : ActionLmm(model, cost, failed), StorageAction(model, cost, failed, storage, type) {
   XBT_IN("(%s,%zu", storage->m_name, cost);
   // Must be less than the max bandwidth for all actions
   lmm_expand(storage_maxmin_system, storage->p_constraint, p_variable, 1.0);
   XBT_IN("(%s,%zu", storage->m_name, cost);
   // Must be less than the max bandwidth for all actions
   lmm_expand(storage_maxmin_system, storage->p_constraint, p_variable, 1.0);
@@ -585,7 +592,7 @@ int StorageActionLmm::unref()
 {
   m_refcount--;
   if (!m_refcount) {
 {
   m_refcount--;
   if (!m_refcount) {
-    xbt_swag_remove(this, p_stateSet);
+    xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
     if (p_variable)
       lmm_variable_free(storage_maxmin_system, p_variable);
 #ifdef HAVE_TRACING
     if (p_variable)
       lmm_variable_free(storage_maxmin_system, p_variable);
 #ifdef HAVE_TRACING
@@ -603,8 +610,6 @@ void StorageActionLmm::cancel()
   return;
 }
 
   return;
 }
 
-
-
 void StorageActionLmm::suspend()
 {
   XBT_IN("(%p)", this);
 void StorageActionLmm::suspend()
 {
   XBT_IN("(%p)", this);
index 7e929d6..2899481 100644 (file)
@@ -13,9 +13,16 @@ typedef StorageModel *StorageModelPtr;
 class Storage;
 typedef Storage *StoragePtr;
 
 class Storage;
 typedef Storage *StoragePtr;
 
+class StorageLmm;
+typedef StorageLmm *StorageLmmPtr;
+
+class StorageAction;
+typedef StorageAction *StorageActionPtr;
+
 class StorageActionLmm;
 typedef StorageActionLmm *StorageActionLmmPtr;
 
 class StorageActionLmm;
 typedef StorageActionLmm *StorageActionLmmPtr;
 
+
 /*********
  * Model *
  *********/
 /*********
  * Model *
  *********/
@@ -34,30 +41,46 @@ public:
  * Resource *
  ************/
 
  * Resource *
  ************/
 
-class Storage : public ResourceLmm {
+class Storage : virtual public Resource {
 public:
   Storage(StorageModelPtr model, const char* name, xbt_dict_t properties);
 
   bool isUsed();
   void updateState(tmgr_trace_event_t event_type, double value, double date);
 
 public:
   Storage(StorageModelPtr model, const char* name, xbt_dict_t properties);
 
   bool isUsed();
   void updateState(tmgr_trace_event_t event_type, double value, double date);
 
-  lmm_constraint_t p_constraintWrite;    /* Constraint for maximum write bandwidth*/
-  lmm_constraint_t p_constraintRead;     /* Constraint for maximum write bandwidth*/
   xbt_dict_t p_content; /* char * -> s_surf_file_t */
 
   xbt_dict_t p_content; /* char * -> s_surf_file_t */
 
-  StorageActionLmmPtr open(const char* mount, const char* path);
-  StorageActionLmmPtr close(surf_file_t fd);
-  StorageActionLmmPtr unlink(surf_file_t fd);
-  StorageActionLmmPtr ls(const char *path);
-  size_t getSize(surf_file_t fd);
-  StorageActionLmmPtr read(void* ptr, size_t size, surf_file_t fd);//FIXME:why we have a useless param ptr ??
-  StorageActionLmmPtr write(const void* ptr, size_t size, surf_file_t fd);//FIXME:why we have a useless param ptr ??
+  virtual StorageActionPtr open(const char* mount, const char* path)=0;
+  virtual StorageActionPtr close(surf_file_t fd)=0;
+  //virtual StorageActionPtr unlink(surf_file_t fd)=0;
+  virtual StorageActionPtr ls(const char *path)=0;
+  //virtual size_t getSize(surf_file_t fd);
+  virtual StorageActionPtr read(void* ptr, size_t size, surf_file_t fd)=0;//FIXME:why we have a useless param ptr ??
+  virtual StorageActionPtr write(const void* ptr, size_t size, surf_file_t fd)=0;//FIXME:why we have a useless param ptr ??
 
   size_t m_size;
   size_t m_usedSize;
   xbt_dynar_t p_writeActions;
 };
 
 
   size_t m_size;
   size_t m_usedSize;
   xbt_dynar_t p_writeActions;
 };
 
+class StorageLmm : public ResourceLmm, public Storage {
+public:
+  StorageLmm(StorageModelPtr model, const char* name, xbt_dict_t properties,
+                    lmm_system_t maxminSystem, double bread, double bwrite, double bconnection,
+                    xbt_dict_t content, size_t size);
+
+  StorageActionPtr open(const char* mount, const char* path);
+  StorageActionPtr close(surf_file_t fd);
+  //StorageActionPtr unlink(surf_file_t fd);
+  StorageActionPtr ls(const char *path);
+  //size_t getSize(surf_file_t fd);
+  StorageActionPtr read(void* ptr, size_t size, surf_file_t fd);//FIXME:why we have a useless param ptr ??
+  StorageActionPtr write(const void* ptr, size_t size, surf_file_t fd);//FIXME:why we have a useless param ptr ??
+
+  lmm_constraint_t p_constraintWrite;    /* Constraint for maximum write bandwidth*/
+  lmm_constraint_t p_constraintRead;     /* Constraint for maximum write bandwidth*/
+};
+
 /**********
  * Action *
  **********/
 /**********
  * Action *
  **********/
@@ -66,24 +89,33 @@ typedef enum {
   READ=0, WRITE, STAT, OPEN, CLOSE, LS
 } e_surf_action_storage_type_t;
 
   READ=0, WRITE, STAT, OPEN, CLOSE, LS
 } e_surf_action_storage_type_t;
 
-class StorageActionLmm : public ActionLmm {
+
+class StorageAction : virtual public Action {
 public:
 public:
-  StorageActionLmm(){};
-  StorageActionLmm(ModelPtr model, double cost, bool failed, StoragePtr storage, e_surf_action_storage_type_t type);
+  StorageAction(){};
+  StorageAction(ModelPtr model, double cost, bool failed, StoragePtr storage, e_surf_action_storage_type_t type){};
+
+
 
 
+  e_surf_action_storage_type_t m_type;
+  StoragePtr p_storage;
+  surf_file_t p_file;
+  xbt_dict_t p_lsDict;
+};
+
+class StorageActionLmm : public ActionLmm, public StorageAction {
+public:
+  StorageActionLmm(){};
+  StorageActionLmm(ModelPtr model, double cost, bool failed, StorageLmmPtr storage, e_surf_action_storage_type_t type);
+  void suspend();
   int unref();
   void cancel();
   //FIXME:??void recycle();
   int unref();
   void cancel();
   //FIXME:??void recycle();
-  void suspend();
   void resume();
   bool isSuspended();
   void setMaxDuration(double duration);
   void setPriority(double priority);
 
   void resume();
   bool isSuspended();
   void setMaxDuration(double duration);
   void setPriority(double priority);
 
-  e_surf_action_storage_type_t m_type;
-  StoragePtr p_storage;
-  surf_file_t p_file;
-  xbt_dict_t p_lsDict;
 };
 
 
 };
 
 
index 54355f6..f0aac77 100644 (file)
@@ -1,6 +1,8 @@
 #include "surf_private.h"
 #include "surf.hpp"
 #include "surf_private.h"
 #include "surf.hpp"
+#include "network.hpp"
 #include "cpu.hpp"
 #include "cpu.hpp"
+#include "workstation.hpp"
 #include "simix/smx_host_private.h"
 #include "surf_routing.hpp"
 #include "simgrid/sg_config.h"
 #include "simix/smx_host_private.h"
 #include "surf_routing.hpp"
 #include "simgrid/sg_config.h"
@@ -324,12 +326,22 @@ static XBT_INLINE void routing_asr_prop_free(void *p)
   xbt_dict_free(&elm);
 }
 
   xbt_dict_free(&elm);
 }
 
-static XBT_INLINE void surf_resource_free(void *r)
+static XBT_INLINE void surf_cpu_free(void *r)
 {
 {
-  ResourcePtr resource = (ResourcePtr) r;
-  delete resource;
+  delete static_cast<CpuPtr>(r);
 }
 
 }
 
+static XBT_INLINE void surf_link_free(void *r)
+{
+  delete static_cast<NetworkCm02LinkPtr>(r);
+}
+
+static XBT_INLINE void surf_workstation_free(void *r)
+{
+  delete static_cast<WorkstationCLM03Ptr>(r);
+}
+
+
 void sg_version(int *ver_major,int *ver_minor,int *ver_patch) {
   *ver_major = SIMGRID_VERSION_MAJOR;
   *ver_minor = SIMGRID_VERSION_MINOR;
 void sg_version(int *ver_major,int *ver_minor,int *ver_patch) {
   *ver_major = SIMGRID_VERSION_MAJOR;
   *ver_minor = SIMGRID_VERSION_MINOR;
@@ -352,9 +364,9 @@ void surf_init(int *argc, char **argv)
   ROUTING_PROP_ASR_LEVEL = xbt_lib_add_level(as_router_lib,routing_asr_prop_free);
 
   XBT_DEBUG("Add SURF levels");
   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_resource_free);
-  SURF_WKS_LEVEL = xbt_lib_add_level(host_lib,surf_resource_free);
-  SURF_LINK_LEVEL = xbt_lib_add_level(link_lib,surf_resource_free);
+  SURF_CPU_LEVEL = xbt_lib_add_level(host_lib,surf_cpu_free);
+  SURF_WKS_LEVEL = xbt_lib_add_level(host_lib,surf_workstation_free);
+  SURF_LINK_LEVEL = xbt_lib_add_level(link_lib,surf_link_free);
 
   xbt_init(argc, argv);
   if (!model_list)
 
   xbt_init(argc, argv);
   if (!model_list)
@@ -446,7 +458,13 @@ xbt_swag_free(p_doneActionSet);
 
 double Model::shareResources(double now)
 {
 
 double Model::shareResources(double now)
 {
-  //FIXME: to implement
+  //FIXME: set the good function once and for all
+  if (p_updateMechanism == UM_LAZY)
+       shareResourcesLazy(now);
+  else if (p_updateMechanism == UM_FULL)
+       shareResourcesFull(now);
+  else
+       xbt_die("Invalid cpu update mechanism!");
 }
 
 double Model::shareResourcesLazy(double now)
 }
 
 double Model::shareResourcesLazy(double now)
@@ -521,6 +539,11 @@ double Model::shareResourcesLazy(double now)
   return min;
 }
 
   return min;
 }
 
+double Model::shareResourcesFull(double now) {
+  THROW_UNIMPLEMENTED;
+}
+
+
 double Model::shareResourcesMaxMin(xbt_swag_t running_actions,
                           size_t offset,
                           lmm_system_t sys,
 double Model::shareResourcesMaxMin(xbt_swag_t running_actions,
                           size_t offset,
                           lmm_system_t sys,
@@ -662,7 +685,7 @@ Resource::Resource(surf_model_t model, const char *name, xbt_dict_t props)
 
 Resource::Resource(){
   //FIXME:free(m_name);
 
 Resource::Resource(){
   //FIXME:free(m_name);
-  xbt_dict_free(&m_properties);
+  //FIXME:xbt_dict_free(&m_properties);
 }
 
 const char *Resource::getName()
 }
 
 const char *Resource::getName()
@@ -677,7 +700,7 @@ xbt_dict_t Resource::getProperties()
 
 e_surf_resource_state_t Resource::getState()
 {
 
 e_surf_resource_state_t Resource::getState()
 {
-  return m_stateCurrent;
+  return p_stateCurrent;
 }
 
 bool Resource::isOn()
 }
 
 bool Resource::isOn()
@@ -832,6 +855,13 @@ double Action::getFinishTime()
   return m_remains == 0 ? m_finish : -1;
 }
 
   return m_remains == 0 ? m_finish : -1;
 }
 
+double Action::getRemains()
+{
+  XBT_IN("(%p)", this);
+  XBT_OUT();
+  return m_remains;
+}
+
 void Action::setData(void* data)
 {
   p_data = data;
 void Action::setData(void* data)
 {
   p_data = data;
@@ -883,7 +913,7 @@ void ActionLmm::cancel(){
 int ActionLmm::unref(){
   m_refcount--;
   if (!m_refcount) {
 int ActionLmm::unref(){
   m_refcount--;
   if (!m_refcount) {
-       xbt_swag_remove(this, p_stateSet);
+       xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
        if (p_variable)
          lmm_variable_free(p_model->p_maxminSystem, p_variable);
        if (p_model->p_updateMechanism == UM_LAZY) {
        if (p_variable)
          lmm_variable_free(p_model->p_maxminSystem, p_variable);
        if (p_model->p_updateMechanism == UM_LAZY) {
@@ -958,17 +988,74 @@ void ActionLmm::updateIndexHeap(int i) {
   m_indexHeap = i;
 }
 
   m_indexHeap = i;
 }
 
-
 double ActionLmm::getRemains()
 {
   XBT_IN("(%p)", this);
   /* update remains before return it */
 double ActionLmm::getRemains()
 {
   XBT_IN("(%p)", this);
   /* update remains before return it */
-  if (p_updateMechanism == UM_LAZY)      /* update remains before return it */
+  if (p_model->p_updateMechanism == UM_LAZY)      /* update remains before return it */
     updateRemainingLazy(surf_get_clock());
   XBT_OUT();
   return m_remains;
 }
 
     updateRemainingLazy(surf_get_clock());
   XBT_OUT();
   return m_remains;
 }
 
+//FIXME split code in the right places
+void ActionLmm::updateRemainingLazy(double now)
+{
+  double delta = 0.0;
+
+  if(p_model == static_cast<ModelPtr>(surf_network_model))
+  {
+    if (m_suspended != 0)
+      return;
+  }
+  else
+  {
+    xbt_assert(p_stateSet == p_model->p_runningActionSet,
+        "You're updating an action that is not running.");
+
+      /* bogus priority, skip it */
+    xbt_assert(m_priority > 0,
+        "You're updating an action that seems suspended.");
+  }
+
+  delta = now - m_lastUpdate;
+
+  if (m_remains > 0) {
+    XBT_DEBUG("Updating action(%p): remains was %lf, last_update was: %lf", this, m_remains, m_lastUpdate);
+    double_update(&m_remains, m_lastValue * delta);
+
+#ifdef HAVE_TRACING
+    if (p_model == static_cast<ModelPtr>(surf_cpu_model) && TRACE_is_enabled()) {
+      ResourcePtr cpu = static_cast<ResourcePtr>(lmm_constraint_id(lmm_get_cnst_from_var(p_model->p_maxminSystem, p_variable, 0)));
+      TRACE_surf_host_set_utilization(cpu->m_name, p_category, m_lastValue, m_lastUpdate, now - m_lastUpdate);
+    }
+#endif
+    XBT_DEBUG("Updating action(%p): remains is now %lf", this, m_remains);
+  }
+
+  if(p_model == static_cast<ModelPtr>(surf_network_model))
+  {
+    if (m_maxDuration != NO_MAX_DURATION)
+      double_update(&m_maxDuration, delta);
+
+    //FIXME: duplicated code
+    if ((m_remains <= 0) &&
+        (lmm_get_variable_weight(p_variable) > 0)) {
+      m_finish = surf_get_clock();
+      setState(SURF_ACTION_DONE);
+      heapRemove(p_model->p_actionHeap);
+    } else if (((m_maxDuration != NO_MAX_DURATION)
+        && (m_maxDuration <= 0))) {
+      m_finish = surf_get_clock();
+      setState(SURF_ACTION_DONE);
+      heapRemove(p_model->p_actionHeap);
+    }
+  }
+
+  m_lastUpdate = now;
+  m_lastValue = lmm_variable_getvalue(p_variable);
+}
+
 /*void Action::cancel()
 {
   p_model->notifyActionCancel(this);
 /*void Action::cancel()
 {
   p_model->notifyActionCancel(this);
index 996aa47..ac59e13 100644 (file)
@@ -109,15 +109,15 @@ public:
   ResourcePtr createResource(string name);
   ActionPtr createAction(double _cost, bool _failed);
   virtual double shareResources(double now);
   ResourcePtr createResource(string name);
   ActionPtr createAction(double _cost, bool _failed);
   virtual double shareResources(double now);
-  double shareResourcesLazy(double now);
-  //double shareResourcesFull(double now);
+  virtual double shareResourcesLazy(double now);
+  virtual double shareResourcesFull(double now);
   double shareResourcesMaxMin(xbt_swag_t running_actions,
                                       size_t offset,
                                       lmm_system_t sys,
                                       void (*solve) (lmm_system_t));
   double shareResourcesMaxMin(xbt_swag_t running_actions,
                                       size_t offset,
                                       lmm_system_t sys,
                                       void (*solve) (lmm_system_t));
-  void updateActionsState(double now, double delta);
-  void updateActionsStateLazy(double now, double delta);
-  void updateActionsStateFull(double now, double delta);
+  virtual void updateActionsState(double now, double delta);
+  virtual void updateActionsStateLazy(double now, double delta);
+  virtual void updateActionsStateFull(double now, double delta);
 
   string getName() {return m_name;};
 
 
   string getName() {return m_name;};
 
@@ -177,9 +177,9 @@ public:
 
   //private
   virtual bool isUsed()=0;
 
   //private
   virtual bool isUsed()=0;
-  //TODOupdateActionState();
-  //TODOupdateResourceState();
-  //TODOfinilize();
+  //FIXME:updateActionState();
+  //FIXME:updateResourceState();
+  //FIXME:finilize();
 
   bool isOn();
   void turnOn();
 
   bool isOn();
   void turnOn();
@@ -192,10 +192,10 @@ public:
   e_surf_resource_state_t getState();
   void printModel() { std::cout << p_model->getName() << "<<plop"<<std::endl;};
   void *p_resource;
   e_surf_resource_state_t getState();
   void printModel() { std::cout << p_model->getName() << "<<plop"<<std::endl;};
   void *p_resource;
-  e_surf_resource_state_t m_stateCurrent;
   const char *m_name;
   xbt_dict_t m_properties;
   ModelPtr p_model;
   const char *m_name;
   xbt_dict_t m_properties;
   ModelPtr p_model;
+  e_surf_resource_state_t p_stateCurrent;
 
 protected:
 
 
 protected:
 
@@ -215,7 +215,6 @@ public:
                            double metric_peak,
                            tmgr_trace_t metric_trace);
   lmm_constraint_t p_constraint;
                            double metric_peak,
                            tmgr_trace_t metric_trace);
   lmm_constraint_t p_constraint;
-  e_surf_resource_state_t p_stateCurrent;
   tmgr_trace_event_t p_stateEvent;
   s_surf_metric_t p_power;
 };
   tmgr_trace_event_t p_stateEvent;
   s_surf_metric_t p_power;
 };
@@ -250,7 +249,7 @@ public:
 #ifdef HAVE_TRACING
   void setCategory(const char *category); /**< Set the category of an action */
 #endif
 #ifdef HAVE_TRACING
   void setCategory(const char *category); /**< Set the category of an action */
 #endif
-  double getRemains();     /**< Get the remains of an action */
+  virtual double getRemains();     /**< Get the remains of an action */
 #ifdef HAVE_LATENCY_BOUND_TRACKING
   int getLatencyLimited();     /**< Return 1 if action is limited by latency, 0 otherwise */
 #endif
 #ifdef HAVE_LATENCY_BOUND_TRACKING
   int getLatencyLimited();     /**< Return 1 if action is limited by latency, 0 otherwise */
 #endif
@@ -300,13 +299,13 @@ public:
   ActionLmm() : m_suspended(false) {};
   ActionLmm(ModelPtr model, double cost, bool failed) : m_suspended(false) {};
 
   ActionLmm() : m_suspended(false) {};
   ActionLmm(ModelPtr model, double cost, bool failed) : m_suspended(false) {};
 
-  void updateRemainingLazy(double now) {};//FIXME:
+  virtual void updateRemainingLazy(double now);
   void heapInsert(xbt_heap_t heap, double key, enum heap_action_type hat);
   void heapRemove(xbt_heap_t heap);
   double getRemains();     /**< Get the remains of an action */
   void updateIndexHeap(int i);
 
   void heapInsert(xbt_heap_t heap, double key, enum heap_action_type hat);
   void heapRemove(xbt_heap_t heap);
   double getRemains();     /**< Get the remains of an action */
   void updateIndexHeap(int i);
 
-  int unref();
+  virtual int unref();
   void cancel();
   void suspend();
   void resume();
   void cancel();
   void suspend();
   void resume();
index 6cc7d33..e4f4d0d 100644 (file)
@@ -10,6 +10,10 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_kernel);
  *********/
 extern double NOW;
 
  *********/
 extern double NOW;
 
+char *surf_routing_edge_name(sg_routing_edge_t edge){
+  return edge->p_name;
+}
+
 #ifdef CONTEXT_THREADS
 static xbt_parmap_t surf_parmap = NULL; /* parallel map on models */
 #endif
 #ifdef CONTEXT_THREADS
 static xbt_parmap_t surf_parmap = NULL; /* parallel map on models */
 #endif
@@ -87,7 +91,7 @@ double surf_solve(double max_date)
 
   /* sequential version */
   xbt_dynar_foreach(model_list, iter, model) {
 
   /* sequential version */
   xbt_dynar_foreach(model_list, iter, model) {
-    surf_share_resources(model);
+    surf_share_resources(static_cast<ModelPtr>(model));
   }
 
   unsigned i;
   }
 
   unsigned i;
@@ -305,6 +309,10 @@ double surf_network_link_get_latency(surf_network_link_t link){
   return link->getLatency();
 }
 
   return link->getLatency();
 }
 
+const char *surf_cpu_name(surf_cpu_t resource){
+  return resource->m_name;
+}
+
 surf_action_t surf_cpu_execute(surf_cpu_t cpu, double size){
   return cpu->execute(size);
 }
 surf_action_t surf_cpu_execute(surf_cpu_t cpu, double size){
   return cpu->execute(size);
 }
index 545b75f..9e09a18 100644 (file)
@@ -526,6 +526,8 @@ static void _get_route_and_latency(RoutingEdgePtr src, RoutingEdgePtr dst,
   /* Check whether a direct bypass is defined */
   sg_platf_route_cbarg_t e_route_bypass = NULL;
   //FIXME:REMOVE:if (common_father->get_bypass_route)
   /* Check whether a direct bypass is defined */
   sg_platf_route_cbarg_t e_route_bypass = NULL;
   //FIXME:REMOVE:if (common_father->get_bypass_route)
+  common_father->test();
+
   e_route_bypass = common_father->getBypassRoute(src, dst, latency);
 
   /* Common ancestor is kind enough to declare a bypass route from src to dst -- use it and bail out */
   e_route_bypass = common_father->getBypassRoute(src, dst, latency);
 
   /* Common ancestor is kind enough to declare a bypass route from src to dst -- use it and bail out */
index 960314f..60c47f2 100644 (file)
@@ -45,6 +45,7 @@ public:
 
   As(){};
   ~As(){};
 
   As(){};
   ~As(){};
+  int test(){return 3;};
   virtual void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency)=0;
   virtual xbt_dynar_t getOneLinkRoutes()=0;
   virtual void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)=0;
   virtual void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency)=0;
   virtual xbt_dynar_t getOneLinkRoutes()=0;
   virtual void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)=0;
index 0058aeb..7e5f14d 100644 (file)
 #include "surf_routing_private.h"
 #include "surf_routing_private.h"
+#include "surf_routing_full.hpp"
+#include "network.hpp"
 
 extern "C" {
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_full, surf, "Routing part of surf");
 }
 
 
 extern "C" {
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_full, surf, "Routing part of surf");
 }
 
+/* Global vars */
+extern routing_platf_t routing_platf;
+extern int surf_parse_lineno;
+
+#define TO_ROUTE_FULL(i,j) p_routingTable[(i)+(j)*table_size]
+
 AS_t model_full_create(void)
 AS_t model_full_create(void)
-{//FIXME:
+{
+  return new AsFull();
+}
+
+void model_full_end(AS_t _routing)
+{
+  unsigned int i;
+  sg_platf_route_cbarg_t e_route;
+
+  /* set utils vars */
+  AsFullPtr routing = ((AsFullPtr) _routing);
+  size_t table_size = xbt_dynar_length(routing->p_indexNetworkElm);
+
+  /* Create table if necessary */
+  if (!routing->p_routingTable)
+    routing->p_routingTable = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size);
+
+  /* Add the loopback if needed */
+  if (routing_platf->p_loopback && routing->p_hierarchy == SURF_ROUTING_BASE) {
+    for (i = 0; i < table_size; i++) {
+      e_route = routing->TO_ROUTE_FULL(i, i);
+      if (!e_route) {
+        e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
+        e_route->gw_src = NULL;
+        e_route->gw_dst = NULL;
+        e_route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL);
+        xbt_dynar_push(e_route->link_list, &routing_platf->p_loopback);
+        routing->TO_ROUTE_FULL(i, i) = e_route;
+      }
+    }
+  }
+}
+
+AsFull::AsFull(){
+}
+
+AsFull::~AsFull(){
+  size_t table_size = xbt_dynar_length(p_indexNetworkElm);
+  int i, j;
+  /* Delete routing table */
+  for (i = 0; i < table_size; i++)
+    for (j = 0; j < table_size; j++)
+      delete TO_ROUTE_FULL(i,j);
+  xbt_free(p_routingTable);
+}
+
+xbt_dynar_t AsFull::getOneLinkRoutes()
+{
+  xbt_dynar_t ret = xbt_dynar_new(sizeof(onelink_t), xbt_free);
+
+  int src, dst;
+  int table_size = xbt_dynar_length(p_indexNetworkElm);
+
+  for(src=0; src < table_size; src++) {
+    for(dst=0; dst< table_size; dst++) {
+      sg_platf_route_cbarg_t route = TO_ROUTE_FULL(src,dst);
+      if (route) {
+        if (xbt_dynar_length(route->link_list) == 1) {
+          void *link = *(void **) xbt_dynar_get_ptr(route->link_list, 0);
+          onelink_t onelink = xbt_new0(s_onelink_t, 1);
+          onelink->link_ptr = link;
+          if (p_hierarchy == SURF_ROUTING_BASE) {
+            onelink->src = xbt_dynar_get_as(p_indexNetworkElm, src, sg_routing_edge_t);
+            onelink->src->m_id = src;
+            onelink->dst = xbt_dynar_get_as(p_indexNetworkElm, dst, sg_routing_edge_t);
+            onelink->dst->m_id = dst;
+          } else if (p_hierarchy == SURF_ROUTING_RECURSIVE) {
+            onelink->src = route->gw_src;
+            onelink->dst = route->gw_dst;
+          }
+          xbt_dynar_push(ret, &onelink);
+          XBT_DEBUG("Push route from '%d' to '%d'",
+              src,
+              dst);
+        }
+      }
+    }
+  }
+  return ret;
+}
+
+void AsFull::getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t res, double *lat)
+{
+  XBT_DEBUG("full_get_route_and_latency from %s[%d] to %s[%d]",
+      src->p_name,
+      src->m_id,
+      dst->p_name,
+      dst->m_id  );
+
+  /* set utils vars */
+  size_t table_size = xbt_dynar_length(p_indexNetworkElm);
+
+  sg_platf_route_cbarg_t e_route = NULL;
+  NetworkCm02LinkPtr link;
+  unsigned int cpt = 0;
+
+  e_route = TO_ROUTE_FULL(src->m_id, dst->m_id);
+
+  if (e_route) {
+    res->gw_src = e_route->gw_src;
+    res->gw_dst = e_route->gw_dst;
+    xbt_dynar_foreach(e_route->link_list, cpt, link) {
+      xbt_dynar_push(res->link_list, &link);
+      if (lat)
+        *lat += link->getLatency();
+    }
+  }
+}
+
+void AsFull::parseASroute(sg_platf_route_cbarg_t route){
+  parseRoute(route);
+}
+
+static int full_pointer_resource_cmp(const void *a, const void *b)
+{
+  return a != b;
+}
+
+void AsFull::parseRoute(sg_platf_route_cbarg_t route)
+{
+  int as_route = 0;
+  char *src = (char*)(route->src);
+  char *dst = (char*)(route->dst);
+  RoutingEdgePtr src_net_elm, dst_net_elm;
+  src_net_elm = sg_routing_edge_by_name_or_null(src);
+  dst_net_elm = sg_routing_edge_by_name_or_null(dst);
+
+  xbt_assert(src_net_elm, "Network elements %s not found", src);
+  xbt_assert(dst_net_elm, "Network elements %s not found", dst);
+
+  size_t table_size = xbt_dynar_length(p_indexNetworkElm);
+
+  xbt_assert(!xbt_dynar_is_empty(route->link_list),
+      "Invalid count of links, must be greater than zero (%s,%s)",
+      src, dst);
+
+  if (!p_routingTable)
+    p_routingTable = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size);
+
+  if (TO_ROUTE_FULL(src_net_elm->m_id, dst_net_elm->m_id)) {
+    char *link_name;
+    unsigned int i;
+    xbt_dynar_t link_route_to_test =
+        xbt_dynar_new(sizeof(sg_routing_link_t), NULL);
+    xbt_dynar_foreach(route->link_list, i, link_name) {
+      void *link = xbt_lib_get_or_null(link_lib, link_name, SURF_LINK_LEVEL);
+      xbt_assert(link, "Link : '%s' doesn't exists.", link_name);
+      xbt_dynar_push(link_route_to_test, &link);
+    }
+    if (xbt_dynar_compare(TO_ROUTE_FULL(src_net_elm->m_id, dst_net_elm->m_id)->link_list,
+        link_route_to_test, full_pointer_resource_cmp)) {
+      surf_parse_error("A route between \"%s\" and \"%s\" already exists "
+          "with a different content. "
+          "If you are trying to define a reverse route, "
+          "you must set the symmetrical=no attribute to "
+          "your routes tags.", src, dst);
+    } else {
+      surf_parse_warn("Ignoring the identical redefinition of the route "
+          "between \"%s\" and \"%s\"", src, dst);
+    }
+  } else {
+    if (!route->gw_dst && !route->gw_dst)
+      XBT_DEBUG("Load Route from \"%s\" to \"%s\"", src, dst);
+    else {
+      // FIXME We can call a gw which is down the current AS (cf g5k.xml) but not upper.
+      //      AS_t subas = xbt_dict_get_or_null(rc->routing_sons, src);
+      //      if (subas == NULL)
+      //        surf_parse_error("The source of an ASroute must be a sub-AS "
+      //                         "declared within the current AS, "
+      //                         "but '%s' is not an AS within '%s'", src, rc->name);
+      //      if (subas->to_index
+      //          && xbt_dict_get_or_null(subas->to_index, route->src_gateway) == NULL)
+      //        surf_parse_error("In an ASroute, source gateway must be part of "
+      //                         "the source sub-AS (in particular, being in a "
+      //                         "sub-sub-AS is not allowed), "
+      //                         "but '%s' is not in '%s'.",
+      //                         route->src_gateway, subas->name);
+      //
+      //      subas = xbt_dict_get_or_null(rc->routing_sons, dst);
+      //      if (subas == NULL)
+      //        surf_parse_error("The destination of an ASroute must be a sub-AS "
+      //                         "declared within the current AS, "
+      //                         "but '%s' is not an AS within '%s'", dst, rc->name);
+      //      if (subas->to_index
+      //          && xbt_dict_get_or_null(subas->to_index, route->dst_gateway) == NULL)
+      //        surf_parse_error("In an ASroute, destination gateway must be "
+      //                         "part of the destination sub-AS (in particular, "
+      //                         "in a sub-sub-AS is not allowed), "
+      //                         "but '%s' is not in '%s'.",
+      //                         route->dst_gateway, subas->name);
+      as_route = 1;
+      XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"",
+          src, route->gw_src->p_name, dst, route->gw_dst->p_name);
+      if (route->gw_dst->p_rcType == SURF_NETWORK_ELEMENT_NULL)
+        xbt_die("The dst_gateway '%s' does not exist!", route->gw_dst->p_name);
+      if (route->gw_src->p_rcType == SURF_NETWORK_ELEMENT_NULL)
+        xbt_die("The src_gateway '%s' does not exist!", route->gw_src->p_name);
+    }
+    TO_ROUTE_FULL(src_net_elm->m_id, dst_net_elm->m_id) = newExtendedRoute(p_hierarchy, route, 1);
+    xbt_dynar_shrink(TO_ROUTE_FULL(src_net_elm->m_id, dst_net_elm->m_id)->link_list, 0);
+  }
+
+  if ( (route->symmetrical == TRUE && as_route == 0)
+      || (route->symmetrical == TRUE && as_route == 1)
+  ) {
+    if (route->gw_dst && route->gw_src) {
+      sg_routing_edge_t gw_tmp;
+      gw_tmp = route->gw_src;
+      route->gw_src = route->gw_dst;
+      route->gw_dst = gw_tmp;
+    }
+    if (TO_ROUTE_FULL(dst_net_elm->m_id, src_net_elm->m_id)) {
+      char *link_name;
+      unsigned int i;
+      xbt_dynar_t link_route_to_test =
+          xbt_dynar_new(sizeof(sg_routing_link_t), NULL);
+      for (i = xbt_dynar_length(route->link_list); i > 0; i--) {
+        link_name = xbt_dynar_get_as(route->link_list, i - 1, char *);
+        void *link = xbt_lib_get_or_null(link_lib, link_name, SURF_LINK_LEVEL);
+        xbt_assert(link, "Link : '%s' doesn't exists.", link_name);
+        xbt_dynar_push(link_route_to_test, &link);
+      }
+      xbt_assert(!xbt_dynar_compare(TO_ROUTE_FULL(dst_net_elm->m_id, src_net_elm->m_id)->link_list,
+          link_route_to_test,
+          full_pointer_resource_cmp),
+          "The route between \"%s\" and \"%s\" already exists", src,
+          dst);
+    } else {
+      if (!route->gw_dst && !route->gw_src)
+        XBT_DEBUG("Load Route from \"%s\" to \"%s\"", dst, src);
+      else
+        XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"",
+            dst, route->gw_src->p_name, src, route->gw_dst->p_name);
+      TO_ROUTE_FULL(dst_net_elm->m_id, src_net_elm->m_id) = newExtendedRoute(p_hierarchy, route, 0);
+      xbt_dynar_shrink(TO_ROUTE_FULL(dst_net_elm->m_id, src_net_elm->m_id)->link_list, 0);
+    }
+  }
+  xbt_dynar_free(&route->link_list);
 }
 
 }
 
-void model_full_end(AS_t current_routing)
-{}
+
+
+
diff --git a/src/surf/surf_routing_full.hpp b/src/surf/surf_routing_full.hpp
new file mode 100644 (file)
index 0000000..f820a32
--- /dev/null
@@ -0,0 +1,39 @@
+#include "surf_routing_generic.hpp"
+
+#ifndef SURF_ROUTING_FULL_HPP_
+#define SURF_ROUTING_FULL_HPP_
+
+/***********
+ * Classes *
+ ***********/
+class AsFull;
+typedef AsFull *AsFullPtr;
+
+class AsFull: public AsGeneric {
+public:
+  sg_platf_route_cbarg_t *p_routingTable;
+
+  AsFull();
+  ~AsFull();
+  int test(){return 1;};
+
+  void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency);
+  xbt_dynar_t getOneLinkRoutes();
+  void parseRoute(sg_platf_route_cbarg_t route);
+  void parseASroute(sg_platf_route_cbarg_t route);
+
+  //void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges);
+  //sg_platf_route_cbarg_t getBypassRoute(RoutingEdgePtr src, RoutingEdgePtr dst, double *lat);
+
+  /* The parser calls the following functions to inform the routing models
+   * that a new element is added to the AS currently built.
+   *
+   * Of course, only the routing model of this AS is informed, not every ones */
+  //virtual int parsePU(RoutingEdgePtr elm)=0; /* A host or a router, whatever */
+  //virtual int parseAS( RoutingEdgePtr elm)=0;
+
+  //virtual void parseBypassroute(sg_platf_route_cbarg_t e_route)=0;
+};
+
+
+#endif /* SURF_ROUTING_FULL_HPP_ */
index fd8e37b..42dbfc2 100644 (file)
@@ -36,10 +36,6 @@ void AsGeneric::getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_pl
   THROW_IMPOSSIBLE;
 }
 
   THROW_IMPOSSIBLE;
 }
 
-xbt_dynar_t AsGeneric::getOneLinkRoutes(){
-  THROW_IMPOSSIBLE;
-}
-
 AsGeneric::AsGeneric() {
   p_bypassRoutes = xbt_dict_new_homogeneous((void (*)(void *)) generic_free_route);
 }
 AsGeneric::AsGeneric() {
   p_bypassRoutes = xbt_dict_new_homogeneous((void (*)(void *)) generic_free_route);
 }
@@ -98,7 +94,7 @@ void AsGeneric::parseBypassroute(sg_platf_route_cbarg_t e_route)
 /* ************************************************************************** */
 /* *********************** GENERIC BUSINESS METHODS ************************* */
 
 /* ************************************************************************** */
 /* *********************** GENERIC BUSINESS METHODS ************************* */
 
-xbt_dynar_t AsGeneric::getOnelinkRoutes() { // FIXME: kill that stub
+xbt_dynar_t AsGeneric::getOneLinkRoutes() { // FIXME: kill that stub
   xbt_die("\"generic_get_onelink_routes\" not implemented yet");
   return NULL;
 }
   xbt_die("\"generic_get_onelink_routes\" not implemented yet");
   return NULL;
 }
index ecf6975..756460b 100644 (file)
@@ -10,29 +10,28 @@ class AsGeneric : public AsNone {
 public:
   AsGeneric();
   ~AsGeneric();
 public:
   AsGeneric();
   ~AsGeneric();
-  void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency);
-  xbt_dynar_t getOneLinkRoutes();
-  void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges);
-  sg_platf_route_cbarg_t getBypassRoute(RoutingEdgePtr src, RoutingEdgePtr dst, double *lat);
-  void finalize();
+  int test(){return 2;};
+
+  virtual void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency);
+  virtual xbt_dynar_t getOneLinkRoutes();
+  virtual void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges);
+  virtual sg_platf_route_cbarg_t getBypassRoute(RoutingEdgePtr src, RoutingEdgePtr dst, double *lat);
 
   /* The parser calls the following functions to inform the routing models
    * that a new element is added to the AS currently built.
    *
    * Of course, only the routing model of this AS is informed, not every ones */
 
   /* The parser calls the following functions to inform the routing models
    * that a new element is added to the AS currently built.
    *
    * Of course, only the routing model of this AS is informed, not every ones */
-  int parsePU(RoutingEdgePtr elm); /* A host or a router, whatever */
-  int parseAS( RoutingEdgePtr elm);
-  void parseRoute(sg_platf_route_cbarg_t route);
-  void parseASroute(sg_platf_route_cbarg_t route);
-  void parseBypassroute(sg_platf_route_cbarg_t e_route);
+  virtual int parsePU(RoutingEdgePtr elm); /* A host or a router, whatever */
+  virtual int parseAS( RoutingEdgePtr elm);
+  virtual void parseRoute(sg_platf_route_cbarg_t route);
+  virtual void parseASroute(sg_platf_route_cbarg_t route);
+  virtual void parseBypassroute(sg_platf_route_cbarg_t e_route);
 
 
-  xbt_dynar_t getOnelinkRoutes();
-  sg_platf_route_cbarg_t getBypassroute(RoutingEdgePtr src, RoutingEdgePtr dst, double *lat);
-  sg_platf_route_cbarg_t newExtendedRoute(e_surf_routing_hierarchy_t hierarchy, sg_platf_route_cbarg_t routearg, int change_order);
-  AsPtr asExist(AsPtr to_find);
-  AsPtr autonomousSystemExist(char *element);
-  AsPtr processingUnitsExist(char *element);
-  void srcDstCheck(RoutingEdgePtr src, RoutingEdgePtr dst);
+  virtual sg_platf_route_cbarg_t newExtendedRoute(e_surf_routing_hierarchy_t hierarchy, sg_platf_route_cbarg_t routearg, int change_order);
+  virtual AsPtr asExist(AsPtr to_find);
+  virtual AsPtr autonomousSystemExist(char *element);
+  virtual AsPtr processingUnitsExist(char *element);
+  virtual void srcDstCheck(RoutingEdgePtr src, RoutingEdgePtr dst);
 };
 
 #endif /* SURF_ROUTING_GENERIC_HPP_ */
 };
 
 #endif /* SURF_ROUTING_GENERIC_HPP_ */
index 7a56e25..2e6d24a 100644 (file)
@@ -7,21 +7,20 @@ class AsNone : public As {
 public:
   AsNone();
   ~AsNone();
 public:
   AsNone();
   ~AsNone();
-  void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency);
-  xbt_dynar_t getOneLinkRoutes();
-  void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges);
-  sg_platf_route_cbarg_t getBypassRoute(RoutingEdgePtr src, RoutingEdgePtr dst, double *lat);
-  void finalize();
+  virtual void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency);
+  virtual xbt_dynar_t getOneLinkRoutes();
+  virtual void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges);
+  virtual sg_platf_route_cbarg_t getBypassRoute(RoutingEdgePtr src, RoutingEdgePtr dst, double *lat);
 
   /* The parser calls the following functions to inform the routing models
    * that a new element is added to the AS currently built.
    *
    * Of course, only the routing model of this AS is informed, not every ones */
 
   /* The parser calls the following functions to inform the routing models
    * that a new element is added to the AS currently built.
    *
    * Of course, only the routing model of this AS is informed, not every ones */
-  int parsePU(RoutingEdgePtr elm); /* A host or a router, whatever */
-  int parseAS( RoutingEdgePtr elm);
-  void parseRoute(sg_platf_route_cbarg_t route);
-  void parseASroute(sg_platf_route_cbarg_t route);
-  void parseBypassroute(sg_platf_route_cbarg_t e_route);
+  virtual int parsePU(RoutingEdgePtr elm); /* A host or a router, whatever */
+  virtual int parseAS( RoutingEdgePtr elm);
+  virtual void parseRoute(sg_platf_route_cbarg_t route);
+  virtual void parseASroute(sg_platf_route_cbarg_t route);
+  virtual void parseBypassroute(sg_platf_route_cbarg_t e_route);
 };
 
 
 };
 
 
index a8a4ec1..763323b 100644 (file)
@@ -10,6 +10,14 @@ WorkstationModelPtr surf_workstation_model = NULL;
 
 //FIXME:Faire hériter ou composer de cup et network
 
 
 //FIXME:Faire hériter ou composer de cup et network
 
+/*************
+ * CallBacks *
+ *************/
+
+static void workstation_new(sg_platf_host_cbarg_t host){
+  surf_workstation_model->createResource(host->id);
+}
+
 /*********
  * Model *
  *********/
 /*********
  * Model *
  *********/
@@ -21,8 +29,9 @@ void surf_workstation_model_init_current_default(void)
   surf_cpu_model_init_Cas01();
   surf_network_model_init_LegrandVelho();
 
   surf_cpu_model_init_Cas01();
   surf_network_model_init_LegrandVelho();
 
-  xbt_dynar_push(model_list, &surf_workstation_model);
-  //FIXME:sg_platf_host_add_cb(workstation_new);
+  ModelPtr model = static_cast<ModelPtr>(surf_workstation_model);
+  xbt_dynar_push(model_list, &model);
+  sg_platf_host_add_cb(workstation_new);
 }
 
 void surf_workstation_model_init_compound()
 }
 
 void surf_workstation_model_init_compound()
@@ -31,19 +40,17 @@ void surf_workstation_model_init_compound()
   xbt_assert(surf_cpu_model, "No CPU model defined yet!");
   xbt_assert(surf_network_model, "No network model defined yet!");
   surf_workstation_model = new WorkstationModel();
   xbt_assert(surf_cpu_model, "No CPU model defined yet!");
   xbt_assert(surf_network_model, "No network model defined yet!");
   surf_workstation_model = new WorkstationModel();
-  xbt_dynar_push(model_list, &surf_workstation_model);
-  //FIXME:sg_platf_host_add_cb(workstation_new);
+
+  ModelPtr model = static_cast<ModelPtr>(surf_workstation_model);
+  xbt_dynar_push(model_list, &model);
+  sg_platf_host_add_cb(workstation_new);
 }
 
 WorkstationModel::WorkstationModel() : Model("Workstation") {
 }
 
 WorkstationModel::WorkstationModel() : Model("Workstation") {
-  //FIXME:xbt_cfg_setdefault_boolean(_sg_cfg_set, "network/crosstraffic", xbt_strdup("yes"));
-  //FIXME:surf_cpu_model_init_Cas01();
-  //FIXME:surf_network_model_init_LegrandVelho();
-
-  xbt_dynar_push(model_list, this);
-  //FIXME:sg_platf_host_add_cb(workstation_new);
 }
 
 }
 
+WorkstationModel::~WorkstationModel() {
+}
 
 void WorkstationModel::parseInit(sg_platf_host_cbarg_t host){
   createResource(host->id);
 
 void WorkstationModel::parseInit(sg_platf_host_cbarg_t host){
   createResource(host->id);
@@ -239,6 +246,9 @@ size_t WorkstationCLM03::getSize(surf_file_t fd){
   return fd->size;
 }
 
   return fd->size;
 }
 
+e_surf_resource_state_t WorkstationCLM03Lmm::getState() {
+  return WorkstationCLM03::getState();
+}
 /**********
  * Action *
  **********/
 /**********
  * Action *
  **********/
index db068ed..3926fba 100644 (file)
@@ -16,6 +16,9 @@ typedef WorkstationModel *WorkstationModelPtr;
 class WorkstationCLM03;
 typedef WorkstationCLM03 *WorkstationCLM03Ptr;
 
 class WorkstationCLM03;
 typedef WorkstationCLM03 *WorkstationCLM03Ptr;
 
+class WorkstationCLM03Lmm;
+typedef WorkstationCLM03Lmm *WorkstationCLM03LmmPtr;
+
 class WorkstationAction;
 typedef WorkstationAction *WorkstationActionPtr;
 
 class WorkstationAction;
 typedef WorkstationAction *WorkstationActionPtr;
 
@@ -34,6 +37,7 @@ class WorkstationModel : public Model {
 public:
   WorkstationModel(string name): Model(name) {};
   WorkstationModel();
 public:
   WorkstationModel(string name): Model(name) {};
   WorkstationModel();
+  ~WorkstationModel();
   void parseInit(sg_platf_host_cbarg_t host);
   WorkstationCLM03Ptr createResource(string name);
   double shareResources(double now);
   void parseInit(sg_platf_host_cbarg_t host);
   WorkstationCLM03Ptr createResource(string name);
   double shareResources(double now);
@@ -87,6 +91,7 @@ public:
 class WorkstationCLM03Lmm : public WorkstationCLM03, public ResourceLmm {
 public:
   WorkstationCLM03Lmm(WorkstationModelPtr model, const char* name, xbt_dict_t props): WorkstationCLM03(model, name, props, NULL, NULL, NULL){};
 class WorkstationCLM03Lmm : public WorkstationCLM03, public ResourceLmm {
 public:
   WorkstationCLM03Lmm(WorkstationModelPtr model, const char* name, xbt_dict_t props): WorkstationCLM03(model, name, props, NULL, NULL, NULL){};
+  e_surf_resource_state_t getState();
 };
 
 /**********
 };
 
 /**********
index cf8134f..8b2688c 100644 (file)
@@ -109,7 +109,7 @@ void WorkstationL07Model::updateActionsState(double now, double delta)
                                     i++))) {
         constraint_id = lmm_constraint_id(cnst);
 
                                     i++))) {
         constraint_id = lmm_constraint_id(cnst);
 
-        if (((WorkstationCLM03Ptr)constraint_id)->m_stateCurrent == SURF_RESOURCE_OFF) {
+        if (((WorkstationCLM03LmmPtr)constraint_id)->p_stateCurrent == SURF_RESOURCE_OFF) {
           XBT_DEBUG("Action (%p) Failed!!", action);
           action->m_finish = surf_get_clock();
           action->setState(SURF_ACTION_FAILED);
           XBT_DEBUG("Action (%p) Failed!!", action);
           action->m_finish = surf_get_clock();
           action->setState(SURF_ACTION_FAILED);
@@ -266,7 +266,7 @@ WorkstationCLM03Ptr WorkstationL07Model::createCpuResource(const char *name, dou
     cpu->p_power.event =
         tmgr_history_add_trace(history, power_trace, 0.0, 0, cpu);
 
     cpu->p_power.event =
         tmgr_history_add_trace(history, power_trace, 0.0, 0, cpu);
 
-  cpu->m_stateCurrent = state_initial;
+  cpu->p_stateCurrent = state_initial;
   if (state_trace)
     cpu->p_stateEvent =
         tmgr_history_add_trace(history, state_trace, 0.0, 0, cpu);
   if (state_trace)
     cpu->p_stateEvent =
         tmgr_history_add_trace(history, state_trace, 0.0, 0, cpu);
@@ -561,7 +561,7 @@ int WorkstationL07ActionLmm::unref()
 {
   m_refcount--;
   if (!m_refcount) {
 {
   m_refcount--;
   if (!m_refcount) {
-    xbt_swag_remove(this, p_stateSet);
+    xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
     if (p_variable)
       lmm_variable_free(ptask_maxmin_system, p_variable);
     delete this;
     if (p_variable)
       lmm_variable_free(ptask_maxmin_system, p_variable);
     delete this;
index a57a399..fd40b25 100644 (file)
@@ -63,13 +63,13 @@ void test(char *platform)
   cpuB = surf_cpu_resource_by_name("Cpu B");
 
   /* Let's check that those two processors exist */
   cpuB = surf_cpu_resource_by_name("Cpu B");
 
   /* Let's check that those two processors exist */
-  XBT_DEBUG("%s : %p", surf_resource_name(cpuA), cpuA);
-  XBT_DEBUG("%s : %p", surf_resource_name(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);
+  surf_cpu_resource_priv(cpuA);
   /* Let's do something on it */
   /* Let's do something on it */
-  actionA = surf_cpu_execute(cpuA, 1000.0);
-  actionB = surf_cpu_execute(cpuB, 1000.0);
-  actionC = surf_cpu_sleep(cpuB, 7.32);
+  actionA = surf_cpu_execute(surf_cpu_resource_priv(cpuA), 1000.0);
+  actionB = surf_cpu_execute(surf_cpu_resource_priv(cpuB), 1000.0);
+  actionC = surf_cpu_sleep(surf_cpu_resource_priv(cpuB), 7.32);
 
   /* Use whatever calling style you want... */
   stateActionA = surf_action_get_state(actionA);     /* When you know actionA model type */
 
   /* Use whatever calling style you want... */
   stateActionA = surf_action_get_state(actionA);     /* When you know actionA model type */
@@ -87,8 +87,8 @@ void test(char *platform)
   cardB = sg_routing_edge_by_name_or_null("Cpu B");
 
   /* Let's check that those two processors exist */
   cardB = sg_routing_edge_by_name_or_null("Cpu B");
 
   /* Let's check that those two processors exist */
-  XBT_DEBUG("%s : %p", surf_resource_name(cardA), cardA);
-  XBT_DEBUG("%s : %p", surf_resource_name(cardB), cardB);
+  XBT_DEBUG("%s : %p", surf_routing_edge_name(cardA), cardA);
+  XBT_DEBUG("%s : %p", surf_routing_edge_name(cardB), cardB);
 
   /* Let's do something on it */
   surf_network_model_communicate(surf_network_model, cardA, cardB, 150.0, -1.0);
 
   /* Let's do something on it */
   surf_network_model_communicate(surf_network_model, cardA, cardB, 150.0, -1.0);