From e049fe573b321fbf974191c9f084873dc306009c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20B=C3=A9daride?= Date: Tue, 22 Oct 2013 16:01:33 +0200 Subject: [PATCH 1/1] Fix unset variables issues --- src/include/surf/surf.h | 4 +- src/simdag/sd_task.c | 2 +- src/simix/smx_host.c | 2 +- src/simix/smx_io.c | 4 +- src/surf/network.cpp | 2 +- src/surf/storage.cpp | 60 ++++++++++++++++-------------- src/surf/storage.hpp | 9 +++-- src/surf/surf.hpp | 1 - src/surf/surf_interface.cpp | 8 ++-- src/surf/surf_routing.cpp | 14 +++---- src/surf/surf_routing_cluster.cpp | 3 ++ src/surf/surf_routing_dijkstra.cpp | 56 +++++++++++++++++++++------- src/surf/surf_routing_dijkstra.hpp | 7 ++++ src/surf/surf_routing_floyd.cpp | 4 ++ src/surf/surf_routing_floyd.hpp | 1 + src/surf/surf_routing_full.cpp | 1 + src/surf/workstation_ptask_L07.cpp | 47 +++++++++++++++-------- src/surf/workstation_ptask_L07.hpp | 11 ++++-- 18 files changed, 154 insertions(+), 82 deletions(-) diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 102f5853b3..5c253a53b1 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -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 } diff --git a/src/simdag/sd_task.c b/src/simdag/sd_task.c index c17bb71ca6..6465616156 100644 --- a/src/simdag/sd_task.c +++ b/src/simdag/sd_task.c @@ -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); diff --git a/src/simix/smx_host.c b/src/simix/smx_host.c index 5e130a4d54..436bc8aec9 100644 --- a/src/simix/smx_host.c +++ b/src/simix/smx_host.c @@ -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()) { diff --git a/src/simix/smx_io.c b/src/simix/smx_io.c index 9793490a17..971ccf61d2 100644 --- a/src/simix/smx_io.c +++ b/src/simix/smx_io.c @@ -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; diff --git a/src/surf/network.cpp b/src/surf/network.cpp index b1c8981e07..5b1896c700 100644 --- a/src/surf/network.cpp +++ b/src/surf/network.cpp @@ -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(createResource("__loopback__", + routing_model_create(static_cast(createResource("__loopback__", 498000000, NULL, 0.000015, NULL, SURF_RESOURCE_ON, NULL, SURF_LINK_FATPIPE, NULL))); diff --git a/src/surf/storage.cpp b/src/surf/storage.cpp index d4f35412fa..7a288588ae 100644 --- a/src/surf/storage.cpp +++ b/src/surf/storage.cpp @@ -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(static_cast(_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(static_cast(_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(this)); break; } XBT_OUT(); @@ -592,7 +596,7 @@ int StorageActionLmm::unref() if (!m_refcount) { xbt_swag_remove(static_cast(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; diff --git a/src/surf/storage.hpp b/src/surf/storage.hpp index 28994812d0..94ac7fd699 100644 --- a/src/surf/storage.hpp +++ b/src/surf/storage.hpp @@ -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) {}; diff --git a/src/surf/surf.hpp b/src/surf/surf.hpp index 358546a870..862173d4cf 100644 --- a/src/surf/surf.hpp +++ b/src/surf/surf.hpp @@ -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; diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index 2bccb88547..81163e8514 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -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(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(action)->p_lsDict; } diff --git a/src/surf/surf_routing.cpp b/src/surf/surf_routing.cpp index 8600c449e8..a3a53c4f81 100644 --- a/src/surf/surf_routing.cpp +++ b/src/surf/surf_routing.cpp @@ -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; diff --git a/src/surf/surf_routing_cluster.cpp b/src/surf/surf_routing_cluster.cpp index 6bc1553d72..d9cab06320 100644 --- a/src/surf/surf_routing_cluster.cpp +++ b/src/surf/surf_routing_cluster.cpp @@ -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 */ diff --git a/src/surf/surf_routing_dijkstra.cpp b/src/surf/surf_routing_dijkstra.cpp index da697be599..d748a0f96d 100644 --- a/src/surf/surf_routing_dijkstra.cpp +++ b/src/surf/surf_routing_dijkstra.cpp @@ -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(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); diff --git a/src/surf/surf_routing_dijkstra.hpp b/src/surf/surf_routing_dijkstra.hpp index 621d248cef..ef683860d8 100644 --- a/src/surf/surf_routing_dijkstra.hpp +++ b/src/surf/surf_routing_dijkstra.hpp @@ -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(); diff --git a/src/surf/surf_routing_floyd.cpp b/src/surf/surf_routing_floyd.cpp index 499a2102f4..1cfc5c0c89 100644 --- a/src/surf/surf_routing_floyd.cpp +++ b/src/surf/surf_routing_floyd.cpp @@ -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); diff --git a/src/surf/surf_routing_floyd.hpp b/src/surf/surf_routing_floyd.hpp index 72ada10070..56b6805cdd 100644 --- a/src/surf/surf_routing_floyd.hpp +++ b/src/surf/surf_routing_floyd.hpp @@ -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); diff --git a/src/surf/surf_routing_full.cpp b/src/surf/surf_routing_full.cpp index a2435b5a54..21338ffc70 100644 --- a/src/surf/surf_routing_full.cpp +++ b/src/surf/surf_routing_full.cpp @@ -47,6 +47,7 @@ void model_full_end(AS_t _routing) } AsFull::AsFull(){ + p_routingTable = 0; } AsFull::~AsFull(){ diff --git a/src/surf/workstation_ptask_L07.cpp b/src/surf/workstation_ptask_L07.cpp index d62afc9c95..8f11693496 100644 --- a/src/surf/workstation_ptask_L07.cpp +++ b/src/surf/workstation_ptask_L07.cpp @@ -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( static_cast( - surf_workstation_resource_priv(workstation_list[i])))->p_netElm, + workstation_list[i]))->p_netElm, dynamic_cast( static_cast( - 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(dynamic_cast( - static_cast( - surf_workstation_resource_priv(workstation_list[i])))->p_cpu)->p_constraint, + static_cast(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( - static_cast( - surf_workstation_resource_priv(workstation_list[i])))->p_netElm, + static_cast(workstation_list[i]))->p_netElm, dynamic_cast( - static_cast( - surf_workstation_resource_priv(workstation_list[j])))->p_netElm, + static_cast(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( + static_cast( + 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( + static_cast( + 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( - static_cast( - surf_workstation_resource_priv(p_workstationList[i])))->p_netElm, + static_cast(((void**)p_workstationList)[i]))->p_netElm, dynamic_cast( - static_cast( - surf_workstation_resource_priv(p_workstationList[j])))->p_netElm, + static_cast(((void**)p_workstationList)[j]))->p_netElm, &route, &lat); lat_current = MAX(lat_current, lat * p_communicationAmount[i * m_workstationNb + j]); diff --git a/src/surf/workstation_ptask_L07.hpp b/src/surf/workstation_ptask_L07.hpp index c195fdf787..ded3df2b38 100644 --- a/src/surf/workstation_ptask_L07.hpp +++ b/src/surf/workstation_ptask_L07.hpp @@ -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(); -- 2.20.1