Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix unset variables issues
authorPaul Bédaride <paul.bedaride@gmail.com>
Tue, 22 Oct 2013 14:01:33 +0000 (16:01 +0200)
committerPaul Bédaride <paul.bedaride@gmail.com>
Tue, 22 Oct 2013 14:01:33 +0000 (16:01 +0200)
18 files changed:
src/include/surf/surf.h
src/simdag/sd_task.c
src/simix/smx_host.c
src/simix/smx_io.c
src/surf/network.cpp
src/surf/storage.cpp
src/surf/storage.hpp
src/surf/surf.hpp
src/surf/surf_interface.cpp
src/surf/surf_routing.cpp
src/surf/surf_routing_cluster.cpp
src/surf/surf_routing_dijkstra.cpp
src/surf/surf_routing_dijkstra.hpp
src/surf/surf_routing_floyd.cpp
src/surf/surf_routing_floyd.hpp
src/surf/surf_routing_full.cpp
src/surf/workstation_ptask_L07.cpp
src/surf/workstation_ptask_L07.hpp

index 102f585..5c253a5 100644 (file)
@@ -354,8 +354,8 @@ void surf_action_set_priority(surf_action_t action, double priority);
 void surf_action_set_category(surf_action_t action, const char *category);
 e_surf_action_state_t surf_action_get_state(surf_action_t action);
 int surf_action_get_cost(surf_action_t action);
-surf_file_t surf_storage_action_get_file(surf_storage_action_lmm_t action);
-xbt_dict_t surf_storage_action_get_ls_dict(surf_storage_action_lmm_t action);
+surf_file_t surf_storage_action_get_file(surf_action_t action);
+xbt_dict_t surf_storage_action_get_ls_dict(surf_action_t action);
 
 #ifdef __cplusplus
 }
index c17bb71..6465616 100644 (file)
@@ -1112,7 +1112,7 @@ void __SD_task_really_run(SD_task_t task)
   surf_workstations = xbt_new(void *, workstation_nb);
 
   for (i = 0; i < workstation_nb; i++)
-    surf_workstations[i] = task->workstation_list[i];
+    surf_workstations[i] =  surf_workstation_resource_priv(task->workstation_list[i]);
 
   double *computation_amount = xbt_new0(double, workstation_nb);
   double *communication_amount = xbt_new0(double, workstation_nb * workstation_nb);
index 5e130a4..436bc8a 100644 (file)
@@ -370,7 +370,7 @@ smx_action_t SIMIX_host_parallel_execute(const char *name,
   /* set surf's action */
   workstation_list = xbt_new0(void *, host_nb);
   for (i = 0; i < host_nb; i++)
-    workstation_list[i] = host_list[i];
+    workstation_list[i] = surf_workstation_resource_priv(host_list[i]);
 
   /* set surf's action */
   if (!MC_is_active()) {
index 9793490..971ccf6 100644 (file)
@@ -242,7 +242,7 @@ void SIMIX_post_io(smx_action_t action)
     switch (simcall->call) {
     case SIMCALL_FILE_OPEN:;
       smx_file_t tmp = xbt_new(s_smx_file_t,1);
-      tmp->surf_file = surf_storage_action_get_file((surf_storage_action_lmm_t)action->io.surf_io);
+      tmp->surf_file = surf_storage_action_get_file(action->io.surf_io);
       simcall_file_open__set__result(simcall, tmp);
       break;
 
@@ -267,7 +267,7 @@ void SIMIX_post_io(smx_action_t action)
 //          xbt_dict_set((action->io.surf_io)->ls_dict,key,dst,xbt_free);
 //        }
 //      }
-      simcall_file_ls__set__result(simcall, surf_storage_action_get_ls_dict((surf_storage_action_lmm_t)action->io.surf_io));
+      simcall_file_ls__set__result(simcall, surf_storage_action_get_ls_dict(action->io.surf_io));
       break;
     default:
       break;
index b1c8981..5b1896c 100644 (file)
@@ -276,7 +276,7 @@ NetworkCm02Model::NetworkCm02Model(string name) : Model(name){
   if (!p_maxminSystem)
        p_maxminSystem = lmm_system_new(m_selectiveUpdate);
 
-  routing_model_create(static_cast<NetworkCm02LinkPtr>(createResource("__loopback__",
+  routing_model_create(static_cast<ResourcePtr>(createResource("__loopback__",
                                                   498000000, NULL, 0.000015, NULL,
                                                   SURF_RESOURCE_ON, NULL,
                                                   SURF_LINK_FATPIPE, NULL)));
index d4f3541..7a28858 100644 (file)
@@ -18,7 +18,6 @@ static xbt_dynar_t storage_list;
 xbt_dynar_t mount_list = NULL;  /* temporary store of current mount storage */
 StorageModelPtr surf_storage_model = NULL;
 
-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;
 
@@ -248,7 +247,7 @@ void surf_storage_model_init_default(void)
   xbt_dynar_push(model_list, &surf_storage_model);
 }
 
-StorageModel::StorageModel() : Model("Storage"){
+StorageModel::StorageModel() : Model("Storage") {
   StorageActionLmm action;
 
   XBT_DEBUG("surf_storage_model_init_internal");
@@ -256,15 +255,14 @@ StorageModel::StorageModel() : Model("Storage"){
   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);
+  if (!p_maxminSystem) {
+    p_maxminSystem = lmm_system_new(storage_selective_update);
   }
 }
 
 
 StorageModel::~StorageModel(){
-  lmm_system_free(storage_maxmin_system);
-  storage_maxmin_system = NULL;
+  lmm_system_free(p_maxminSystem);
 
   surf_storage_model = NULL;
 
@@ -288,9 +286,7 @@ StoragePtr StorageModel::createResource(const char* id, const char* model, const
   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);
+                 Bread, Bwrite, Bconnection, (char *)content_name, storage_type->size);
 
   xbt_lib_set(storage_lib, id, SURF_STORAGE_LEVEL, storage);
 
@@ -315,7 +311,7 @@ double StorageModel::shareResources(double now)
   StorageActionLmmPtr write_action;
 
   double min_completion = shareResourcesMaxMin(p_runningActionSet,
-      storage_maxmin_system, lmm_solve);
+      p_maxminSystem, lmm_solve);
 
   double rate;
   // Foreach disk
@@ -343,7 +339,7 @@ void StorageModel::updateActionsState(double now, double delta)
   // Update the file size
   // For each action of type write
   xbt_swag_foreach_safe(_action, _next_action, p_runningActionSet) {
-       action = (StorageActionLmmPtr) _action;
+       action = dynamic_cast<StorageActionLmmPtr>(static_cast<ActionPtr>(_action));
     if(action->m_type == WRITE)
     {
       double rate = lmm_variable_getvalue(action->p_variable);
@@ -356,7 +352,7 @@ void StorageModel::updateActionsState(double now, double delta)
   }
 
   xbt_swag_foreach_safe(_action, _next_action, p_runningActionSet) {
-       action = (StorageActionLmmPtr) _action;
+       action = dynamic_cast<StorageActionLmmPtr>(static_cast<ActionPtr>(_action));
 
     double_update(&action->m_remains,
                   lmm_variable_getvalue(action->p_variable) * delta);
@@ -386,9 +382,9 @@ void StorageModel::updateActionsState(double now, double delta)
   return;
 }
 
-xbt_dict_t StorageModel::parseContent(char *filename, size_t *used_size)
+xbt_dict_t Storage::parseContent(char *filename)
 {
-  *used_size = 0;
+  m_usedSize = 0;
   if ((!filename) || (strcmp(filename, "") == 0))
     return NULL;
 
@@ -409,7 +405,7 @@ xbt_dict_t StorageModel::parseContent(char *filename, size_t *used_size)
   while ((read = xbt_getline(&line, &len, file)) != -1) {
     if (read){
     if(sscanf(line,"%s %zu",path, &size)==2) {
-        *used_size += size;
+        m_usedSize += size;
         xbt_dict_set(parse_content,path,(void*) size,NULL);
       } else {
         xbt_die("Be sure of passing a good format for content file.\n");
@@ -425,20 +421,26 @@ xbt_dict_t StorageModel::parseContent(char *filename, size_t *used_size)
  * Resource *
  ************/
 
-Storage::Storage(StorageModelPtr model, const char* name, xbt_dict_t properties) {
+Storage::Storage(StorageModelPtr model, const char* name, xbt_dict_t properties)
+:  Resource(model, name, properties)
+{
   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) {
+            char *content_name, size_t size)
+ :  Resource(model, name, properties), 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_stateCurrent = SURF_RESOURCE_ON;
+  m_usedSize = 0;
+  m_size = 0;
+
+  p_content = parseContent(content_name);
   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;
 }
 
@@ -539,7 +541,7 @@ StorageActionPtr StorageLmm::read(void* ptr, size_t size, surf_file_t fd)
 {
   if(size > fd->size)
     size = fd->size;
-  StorageActionLmmPtr action = new StorageActionLmm(p_model, 0, p_stateCurrent != SURF_RESOURCE_ON, this, READ);
+  StorageActionLmmPtr action = new StorageActionLmm(p_model, size, p_stateCurrent != SURF_RESOURCE_ON, this, READ);
   return action;
 }
 
@@ -548,7 +550,7 @@ 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);
 
-  StorageActionLmmPtr action = new StorageActionLmm(p_model, 0, p_stateCurrent != SURF_RESOURCE_ON, this, WRITE);
+  StorageActionLmmPtr action = new StorageActionLmm(p_model, size, p_stateCurrent != SURF_RESOURCE_ON, this, WRITE);
   action->p_file = fd;
 
   // If the storage is full
@@ -563,10 +565,12 @@ StorageActionPtr StorageLmm::write(const void* ptr, size_t size, surf_file_t fd)
  **********/
 
 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) {
+  : Action(model, cost, failed), ActionLmm(model, cost, failed), StorageAction(model, cost, failed, storage, type) {
   XBT_IN("(%s,%zu", storage->m_name, cost);
+  p_variable = lmm_variable_new(p_model->p_maxminSystem, this, 1.0, -1.0 , 3);
+
   // Must be less than the max bandwidth for all actions
-  lmm_expand(storage_maxmin_system, storage->p_constraint, p_variable, 1.0);
+  lmm_expand(p_model->p_maxminSystem, storage->p_constraint, p_variable, 1.0);
   switch(type) {
   case OPEN:
   case CLOSE:
@@ -574,13 +578,13 @@ StorageActionLmm::StorageActionLmm(ModelPtr model, double cost, bool failed, Sto
   case LS:
     break;
   case READ:
-    lmm_expand(storage_maxmin_system, storage->p_constraintRead,
+    lmm_expand(p_model->p_maxminSystem, storage->p_constraintRead,
                p_variable, 1.0);
     break;
   case WRITE:
-    lmm_expand(storage_maxmin_system, storage->p_constraintWrite,
+    lmm_expand(p_model->p_maxminSystem, storage->p_constraintWrite,
                p_variable, 1.0);
-    xbt_dynar_push(storage->p_writeActions,this);
+    xbt_dynar_push(storage->p_writeActions, static_cast<ActionPtr>(this));
     break;
   }
   XBT_OUT();
@@ -592,7 +596,7 @@ int StorageActionLmm::unref()
   if (!m_refcount) {
     xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
     if (p_variable)
-      lmm_variable_free(storage_maxmin_system, p_variable);
+      lmm_variable_free(p_model->p_maxminSystem, p_variable);
 #ifdef HAVE_TRACING
     xbt_free(p_category);
 #endif
@@ -612,7 +616,7 @@ void StorageActionLmm::suspend()
 {
   XBT_IN("(%p)", this);
   if (m_suspended != 2) {
-    lmm_update_variable_weight(storage_maxmin_system,
+    lmm_update_variable_weight(p_model->p_maxminSystem,
                                p_variable,
                                0.0);
     m_suspended = 1;
index 2899481..94ac7fd 100644 (file)
@@ -26,7 +26,7 @@ typedef StorageActionLmm *StorageActionLmmPtr;
 /*********
  * Model *
  *********/
-class StorageModel : Model {
+class StorageModel : public Model {
 public:
   StorageModel();
   ~StorageModel();
@@ -34,7 +34,6 @@ public:
   double shareResources(double now);
   void updateActionsState(double now, double delta);
 
-  xbt_dict_t parseContent(char *filename, size_t *used_size);
 };
 
 /************
@@ -57,6 +56,7 @@ public:
   //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 ??
+  xbt_dict_t parseContent(char *filename);
 
   size_t m_size;
   size_t m_usedSize;
@@ -67,7 +67,7 @@ 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);
+                    char *content_name, size_t size);
 
   StorageActionPtr open(const char* mount, const char* path);
   StorageActionPtr close(surf_file_t fd);
@@ -93,7 +93,8 @@ typedef enum {
 class StorageAction : virtual public Action {
 public:
   StorageAction(){};
-  StorageAction(ModelPtr model, double cost, bool failed, StoragePtr storage, e_surf_action_storage_type_t type){};
+  StorageAction(ModelPtr model, double cost, bool failed, StoragePtr storage, e_surf_action_storage_type_t type)
+   : p_storage(storage), m_type(type) {};
 
 
 
index 358546a..862173d 100644 (file)
@@ -285,7 +285,6 @@ private:
   void updateResourceState(void *id, tmgr_trace_event_t event_type,
                                  double value, double time);
 
-  lmm_system_t p_maxminSystem;
   xbt_swag_t p_modifiedSet;
   xbt_heap_t p_actionHeap;
   int m_selectiveUpdate;
index 2bccb88..81163e8 100644 (file)
@@ -382,10 +382,10 @@ int surf_action_get_cost(surf_action_t action){
   return action->m_cost;
 }
 
-surf_file_t surf_storage_action_get_file(surf_storage_action_lmm_t action){
-  return action->p_file;
+surf_file_t surf_storage_action_get_file(surf_action_t action){
+  return dynamic_cast<StorageActionPtr>(action)->p_file;
 }
 
-xbt_dict_t surf_storage_action_get_ls_dict(surf_storage_action_lmm_t action){
-  return action->p_lsDict;
+xbt_dict_t surf_storage_action_get_ls_dict(surf_action_t action){
+  return dynamic_cast<StorageActionPtr>(action)->p_lsDict;
 }
index 8600c44..a3a53c4 100644 (file)
@@ -440,15 +440,15 @@ static void elements_father(sg_routing_edge_t src, sg_routing_edge_t dst,
 {
   xbt_assert(src && dst, "bad parameters for \"elements_father\" method");
 #define ELEMENTS_FATHER_MAXDEPTH 16     /* increase if it is not enough */
-  AS_t src_as, dst_as;
-  AS_t path_src[ELEMENTS_FATHER_MAXDEPTH];
-  AS_t path_dst[ELEMENTS_FATHER_MAXDEPTH];
+  AsPtr src_as, dst_as;
+  AsPtr path_src[ELEMENTS_FATHER_MAXDEPTH];
+  AsPtr path_dst[ELEMENTS_FATHER_MAXDEPTH];
   int index_src = 0;
   int index_dst = 0;
-  AS_t current;
-  AS_t current_src;
-  AS_t current_dst;
-  AS_t father;
+  AsPtr current;
+  AsPtr current_src;
+  AsPtr current_dst;
+  AsPtr father;
 
   /* (1) find the as where the src and dst are located */
   sg_routing_edge_t src_data = src;
index 6bc1553..d9cab06 100644 (file)
@@ -22,6 +22,9 @@ AS_t model_cluster_create(void)
 /* Creation routing model functions */
 AsCluster::AsCluster() : AsNone()
 {
+  p_backbone = 0;
+  p_loopback = 0;
+  p_router = 0;
 }
 
 /* Business methods */
index da697be..d748a0f 100644 (file)
@@ -15,19 +15,6 @@ extern "C" {
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_dijkstra, surf, "Routing part of surf -- dijkstra routing logic");
 }
 
-AS_t model_dijkstra_create(void){
-  return new AsDijkstra(0);
-}
-
-AS_t model_dijkstracache_create(void){
-  return new AsDijkstra(1);
-}
-
-void model_dijkstra_both_end(AS_t as)
-{
-  delete as;
-}
-
 /* Free functions */
 
 static void route_cache_elem_free(void *e)
@@ -54,6 +41,43 @@ static void graph_edge_data_free(void *e) // FIXME: useless code duplication
   }
 }
 
+AS_t model_dijkstra_create(void){
+  return new AsDijkstra(0);
+}
+
+AS_t model_dijkstracache_create(void){
+  return new AsDijkstra(1);
+}
+
+void model_dijkstra_both_end(AS_t as)
+{
+  AsDijkstraPtr THIS_AS = static_cast<AsDijkstraPtr>(as);
+  xbt_node_t node = NULL;
+  unsigned int cursor2;
+  xbt_dynar_t nodes = NULL;
+
+  /* Create the topology graph */
+  if(!THIS_AS->p_routeGraph)
+    THIS_AS->p_routeGraph = xbt_graph_new_graph(1, NULL);
+  if(!THIS_AS->p_graphNodeMap)
+    THIS_AS->p_graphNodeMap = xbt_dict_new_homogeneous(&graph_node_map_elem_free);
+
+  if (THIS_AS->m_cached && !THIS_AS->p_routeCache)
+    THIS_AS->p_routeCache = xbt_dict_new_homogeneous(&route_cache_elem_free);
+
+  /* Add the loopback if needed */
+  if (routing_platf->p_loopback && as->p_hierarchy == SURF_ROUTING_BASE)
+    THIS_AS->addLoopback();
+
+  /* initialize graph indexes in nodes after graph has been built */
+  nodes = xbt_graph_get_nodes(THIS_AS->p_routeGraph);
+
+  xbt_dynar_foreach(nodes, cursor2, node) {
+    graph_node_data_t data = (graph_node_data_t) xbt_graph_node_get_data(node);
+    data->graph_id = cursor2;
+  }
+}
+
 /* Utility functions */
 
 xbt_node_t AsDijkstra::routeGraphNewNode(int id, int graph_id)
@@ -430,6 +454,12 @@ void AsDijkstra::end()
   }
 
 }
+
+void AsDijkstra::parseASroute(sg_platf_route_cbarg_t route)
+{
+  parseRoute(route);
+}
+
 void AsDijkstra::parseRoute(sg_platf_route_cbarg_t route)
 {
   char *src = (char*)(route->src);
index 621d248..ef68386 100644 (file)
@@ -17,6 +17,12 @@ typedef struct route_cache_element {
   int size;
 } s_route_cache_element_t, *route_cache_element_t;
 
+/***********
+ * Classes *
+ ***********/
+class AsDijkstra;
+typedef AsDijkstra *AsDijkstraPtr;
+
 class AsDijkstra : public AsGeneric {
 public:
   AsDijkstra();
@@ -29,6 +35,7 @@ public:
        void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t route, double *lat);
        xbt_dynar_t getOnelinkRoutes();
        void getRouteAndLatency(sg_platf_route_cbarg_t route, double *lat);
+       void parseASroute(sg_platf_route_cbarg_t route);
        void parseRoute(sg_platf_route_cbarg_t route);
        void end();
 
index 499a210..1cfc5c0 100644 (file)
@@ -129,6 +129,10 @@ static int floyd_pointer_resource_cmp(const void *a, const void *b) {
   return a != b;
 }
 
+void AsFloyd::parseASroute(sg_platf_route_cbarg_t route){
+  parseRoute(route);
+}
+
 void AsFloyd::parseRoute(sg_platf_route_cbarg_t route)
 {
   char *src = (char*)(route->src);
index 72ada10..56b6805 100644 (file)
@@ -17,6 +17,7 @@ public:
 
   void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency);
   xbt_dynar_t getOneLinkRoutes();
+  void parseASroute(sg_platf_route_cbarg_t route);
   void parseRoute(sg_platf_route_cbarg_t route);
   void end();
   //void parseASroute(sg_platf_route_cbarg_t route);
index a2435b5..21338ff 100644 (file)
@@ -47,6 +47,7 @@ void model_full_end(AS_t _routing)
 }
 
 AsFull::AsFull(){
+  p_routingTable = 0;
 }
 
 AsFull::~AsFull(){
index d62afc9..8f11693 100644 (file)
@@ -17,6 +17,7 @@ lmm_system_t ptask_maxmin_system = NULL;
 WorkstationL07Model::WorkstationL07Model() : WorkstationModel("Workstation ptask_L07") {
   if (!ptask_maxmin_system)
        ptask_maxmin_system = lmm_system_new(1);
+  surf_workstation_model = NULL;
   surf_network_model = new NetworkL07Model();
   surf_cpu_model = new CpuL07Model();
   routing_model_create(p_networkModel->createResource("__loopback__",
@@ -24,8 +25,19 @@ WorkstationL07Model::WorkstationL07Model() : WorkstationModel("Workstation ptask
                                                          0.000015, NULL,
                                                          SURF_RESOURCE_ON, NULL,
                                                          SURF_LINK_FATPIPE, NULL));
+}
 
+WorkstationL07Model::~WorkstationL07Model() {
+  xbt_dict_free(&ptask_parallel_task_link_set);
 
+  delete surf_cpu_model;
+  delete surf_network_model;
+  ptask_host_count = 0;
+
+  if (ptask_maxmin_system) {
+    lmm_system_free(ptask_maxmin_system);
+    ptask_maxmin_system = NULL;
+  }
 }
 
 double WorkstationL07Model::shareResources(double now)
@@ -152,10 +164,10 @@ ActionPtr WorkstationL07Model::executeParallelTask(int workstation_nb,
 
         routing_platf->getRouteAndLatency(dynamic_cast<WorkstationL07Ptr>(
                                                   static_cast<ResourcePtr>(
-                                                   surf_workstation_resource_priv(workstation_list[i])))->p_netElm,
+                                                   workstation_list[i]))->p_netElm,
                                                  dynamic_cast<WorkstationL07Ptr>(
                                                   static_cast<ResourcePtr>(
-                                                       surf_workstation_resource_priv(workstation_list[j])))->p_netElm,
+                                                       workstation_list[j]))->p_netElm,
                                                  &route,
                                                  &lat);
         latency = MAX(latency, lat);
@@ -197,8 +209,7 @@ ActionPtr WorkstationL07Model::executeParallelTask(int workstation_nb,
   for (i = 0; i < workstation_nb; i++)
     lmm_expand(ptask_maxmin_system,
               static_cast<CpuLmmPtr>(dynamic_cast<WorkstationL07Ptr>(
-                                          static_cast<ResourcePtr>(
-                                           surf_workstation_resource_priv(workstation_list[i])))->p_cpu)->p_constraint,
+                                          static_cast<ResourcePtr>(workstation_list[i]))->p_cpu)->p_constraint,
                action->p_variable, computation_amount[i]);
 
   for (i = 0; i < workstation_nb; i++) {
@@ -211,11 +222,9 @@ ActionPtr WorkstationL07Model::executeParallelTask(int workstation_nb,
         continue;
 
       routing_platf->getRouteAndLatency(dynamic_cast<WorkstationL07Ptr>(
-                                         static_cast<ResourcePtr>(
-                                          surf_workstation_resource_priv(workstation_list[i])))->p_netElm,
+                                         static_cast<ResourcePtr>(workstation_list[i]))->p_netElm,
                                         dynamic_cast<WorkstationL07Ptr>(
-                                         static_cast<ResourcePtr>(
-                                          surf_workstation_resource_priv(workstation_list[j])))->p_netElm,
+                                         static_cast<ResourcePtr>(workstation_list[j]))->p_netElm,
                                            &route, NULL);
 
       xbt_dynar_foreach(route, cpt, _link) {
@@ -369,7 +378,10 @@ void WorkstationL07Model::addTraces()
   /* Connect traces relative to cpu */
   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    CpuL07Ptr host = (CpuL07Ptr) surf_workstation_resource_priv(surf_workstation_resource_by_name(elm));
+    CpuL07Ptr host = dynamic_cast<CpuL07Ptr>(
+                          static_cast<ResourcePtr>(
+                            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);
@@ -379,7 +391,10 @@ void WorkstationL07Model::addTraces()
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    CpuL07Ptr host = (CpuL07Ptr) surf_workstation_resource_priv(surf_workstation_resource_by_name(elm));
+    CpuL07Ptr host = dynamic_cast<CpuL07Ptr>(
+                          static_cast<ResourcePtr>(
+                            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);
@@ -438,7 +453,11 @@ LinkL07::LinkL07(NetworkL07ModelPtr model, const char* name, xbt_dict_t props)
 
 }
 
-bool WorkstationL07::isUsed(){
+bool CpuL07::isUsed(){
+  return lmm_constraint_used(ptask_maxmin_system, p_constraint);
+}
+
+bool LinkL07::isUsed(){
   return lmm_constraint_used(ptask_maxmin_system, p_constraint);
 }
 
@@ -587,11 +606,9 @@ void WorkstationL07ActionLmm::updateBound()
       if (p_communicationAmount[i * m_workstationNb + j] > 0) {
         double lat = 0.0;
         routing_platf->getRouteAndLatency(dynamic_cast<WorkstationL07Ptr>(
-                                           static_cast<ResourcePtr>(
-                                            surf_workstation_resource_priv(p_workstationList[i])))->p_netElm,
+                                           static_cast<ResourcePtr>(((void**)p_workstationList)[i]))->p_netElm,
                                           dynamic_cast<WorkstationL07Ptr>(
-                                           static_cast<ResourcePtr>(
-                                                           surf_workstation_resource_priv(p_workstationList[j])))->p_netElm,
+                                           static_cast<ResourcePtr>(((void**)p_workstationList)[j]))->p_netElm,
                                                          &route, &lat);
 
         lat_current = MAX(lat_current, lat * p_communicationAmount[i * m_workstationNb + j]);
index c195fdf..ded3df2 100644 (file)
@@ -41,6 +41,7 @@ typedef WorkstationActionLmm *WorkstationActionLmmPtr;*/
 class WorkstationL07Model : public WorkstationModel {
 public:
   WorkstationL07Model();
+  ~WorkstationL07Model();
 
   double shareResources(double now);
   void updateActionsState(double now, double delta);
@@ -65,6 +66,7 @@ public:
 class CpuL07Model : public CpuModel {
 public:
   CpuL07Model() : CpuModel("cpuL07") {};
+  ~CpuL07Model() {surf_cpu_model = NULL;};
   ResourcePtr createResource(const char *name, double power_scale,
                                  double power_initial,
                                  tmgr_trace_t power_trace,
@@ -78,6 +80,7 @@ public:
 class NetworkL07Model : public NetworkCm02Model {
 public:
   NetworkL07Model() : NetworkCm02Model(0) {};
+  ~NetworkL07Model() {surf_network_model = NULL;};
   ResourcePtr createResource(const char *name,
                                                   double bw_initial,
                                                   tmgr_trace_t bw_trace,
@@ -102,7 +105,8 @@ public:
 class WorkstationL07 : public WorkstationCLM03Lmm {
 public:
   WorkstationL07(WorkstationModelPtr model, const char* name, xbt_dict_t props, RoutingEdgePtr netElm, CpuPtr cpu);
-  bool isUsed();
+  //bool isUsed();
+  bool isUsed() {DIE_IMPOSSIBLE;};
   void updateState(tmgr_trace_event_t event_type, double value, double date) {DIE_IMPOSSIBLE;};
   ActionPtr execute(double size);
   ActionPtr sleep(double duration);
@@ -112,7 +116,8 @@ public:
 class CpuL07 : public CpuLmm {
 public:
   CpuL07(CpuL07ModelPtr model, const char* name, xbt_dict_t properties);
-  bool isUsed() {DIE_IMPOSSIBLE;};
+  bool isUsed();
+  //bool isUsed() {DIE_IMPOSSIBLE;};
   void updateState(tmgr_trace_event_t event_type, double value, double date);
   e_surf_resource_state_t getState();
   double getSpeed(double load);
@@ -125,7 +130,7 @@ public:
 class LinkL07 : public NetworkCm02LinkLmm {
 public:
   LinkL07(NetworkL07ModelPtr model, const char* name, xbt_dict_t props);
-  bool isUsed() {DIE_IMPOSSIBLE;};
+  bool isUsed();
   void updateState(tmgr_trace_event_t event_type, double value, double date);
   double getBandwidth();
   double getLatency();