X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/931e26e928ecd6de21bd1450de7ac17a9780cbd4..0012af2fe54e316c010990ddf269246ef022d139:/src/surf/surf_routing_floyd.cpp diff --git a/src/surf/surf_routing_floyd.cpp b/src/surf/surf_routing_floyd.cpp index 2ece750ad6..49022bb0e8 100644 --- a/src/surf/surf_routing_floyd.cpp +++ b/src/surf/surf_routing_floyd.cpp @@ -14,20 +14,12 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_floyd, surf, "Routing part of surf"); #define TO_FLOYD_PRED(i,j) (p_predecessorTable)[(i)+(j)*table_size] #define TO_FLOYD_LINK(i,j) (p_linkTable)[(i)+(j)*table_size] -AS_t model_floyd_create(void) -{ - return new simgrid::surf::AsFloyd(); -} - -void model_floyd_end(AS_t current_routing) -{ - static_cast(current_routing)->end(); -} - namespace simgrid { namespace surf { -AsFloyd::AsFloyd(): AsGeneric() { +AsFloyd::AsFloyd(const char*name) + : AsGeneric(name) +{ p_predecessorTable = NULL; p_costTable = NULL; p_linkTable = NULL; @@ -36,17 +28,17 @@ AsFloyd::AsFloyd(): AsGeneric() { AsFloyd::~AsFloyd(){ int i, j; int table_size; - table_size = (int)xbt_dynar_length(p_indexNetworkElm); + table_size = (int)xbt_dynar_length(vertices_); if (p_linkTable == NULL) // Dealing with a parse error in the file? - return; + return; /* Delete link_table */ for (i = 0; i < table_size; i++) - for (j = 0; j < table_size; j++) { - generic_free_route(TO_FLOYD_LINK(i, j)); - } + for (j = 0; j < table_size; j++) { + routing_route_free(TO_FLOYD_LINK(i, j)); + } xbt_free(p_linkTable); /* Delete bypass dict */ - xbt_dict_free(&p_bypassRoutes); + xbt_dict_free(&bypassRoutes_); /* Delete predecessor and cost table */ xbt_free(p_predecessorTable); xbt_free(p_costTable); @@ -61,20 +53,20 @@ xbt_dynar_t AsFloyd::getOneLinkRoutes() int src,dst; sg_netcard_t src_elm, dst_elm; - int table_size = xbt_dynar_length(p_indexNetworkElm); + int table_size = xbt_dynar_length(vertices_); for(src=0; src < table_size; src++) { for(dst=0; dst< table_size; dst++) { xbt_dynar_reset(route->link_list); - src_elm = xbt_dynar_get_as(p_indexNetworkElm, src, NetCard*); - dst_elm = xbt_dynar_get_as(p_indexNetworkElm, dst, NetCard*); + src_elm = xbt_dynar_get_as(vertices_, src, NetCard*); + dst_elm = xbt_dynar_get_as(vertices_, dst, NetCard*); this->getRouteAndLatency(src_elm, dst_elm, route, NULL); if (xbt_dynar_length(route->link_list) == 1) { void *link = *(void **) xbt_dynar_get_ptr(route->link_list, 0); Onelink *onelink; - if (p_hierarchy == SURF_ROUTING_BASE) + if (hierarchy_ == SURF_ROUTING_BASE) onelink = new Onelink(link, src_elm, dst_elm); - else if (p_hierarchy == SURF_ROUTING_RECURSIVE) + else if (hierarchy_ == SURF_ROUTING_RECURSIVE) onelink = new Onelink(link, route->gw_src, route->gw_dst); else onelink = new Onelink(link, NULL, NULL); @@ -90,7 +82,7 @@ void AsFloyd::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbar { /* set utils vars */ - size_t table_size = xbt_dynar_length(p_indexNetworkElm); + size_t table_size = xbt_dynar_length(vertices_); this->srcDstCheck(src, dst); @@ -106,7 +98,7 @@ void AsFloyd::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbar cur = pred; } while (cur != src->getId()); - if (p_hierarchy == SURF_ROUTING_RECURSIVE) { + if (hierarchy_ == SURF_ROUTING_RECURSIVE) { res->gw_src = xbt_dynar_getlast_as(route_stack, sg_platf_route_cbarg_t)->gw_src; res->gw_dst = xbt_dynar_getfirst_as(route_stack, sg_platf_route_cbarg_t)->gw_dst; } @@ -118,7 +110,7 @@ void AsFloyd::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbar void *link; unsigned int cpt; - if (p_hierarchy == SURF_ROUTING_RECURSIVE && prev_dst_gw != NULL + if (hierarchy_ == SURF_ROUTING_RECURSIVE && prev_dst_gw != NULL && strcmp(prev_dst_gw->getName(), e_route->gw_src->getName())) { routing_platf->getRouteAndLatency(prev_dst_gw, e_route->gw_src, &res->link_list, lat); @@ -152,7 +144,7 @@ void AsFloyd::parseRoute(sg_platf_route_cbarg_t route) int as_route = 0; /* set the size of table routing */ - int table_size = (int)xbt_dynar_length(p_indexNetworkElm); + int table_size = (int)xbt_dynar_length(vertices_); NetCard *src_net_elm, *dst_net_elm; src_net_elm = sg_netcard_by_name_or_null(src); @@ -210,7 +202,7 @@ void AsFloyd::parseRoute(sg_platf_route_cbarg_t route) else { TO_FLOYD_LINK(src_net_elm->getId(), dst_net_elm->getId()) = - newExtendedRoute(p_hierarchy, route, 1); + newExtendedRoute(hierarchy_, route, 1); TO_FLOYD_PRED(src_net_elm->getId(), dst_net_elm->getId()) = src_net_elm->getId(); TO_FLOYD_COST(src_net_elm->getId(), dst_net_elm->getId()) = ((TO_FLOYD_LINK(src_net_elm->getId(), dst_net_elm->getId()))->link_list)->used; /* count of links, old model assume 1 */ @@ -260,7 +252,7 @@ void AsFloyd::parseRoute(sg_platf_route_cbarg_t route) route->gw_src->getName(), src, route->gw_dst->getName()); TO_FLOYD_LINK(dst_net_elm->getId(), src_net_elm->getId()) = - newExtendedRoute(p_hierarchy, route, 0); + newExtendedRoute(hierarchy_, route, 0); TO_FLOYD_PRED(dst_net_elm->getId(), src_net_elm->getId()) = dst_net_elm->getId(); TO_FLOYD_COST(dst_net_elm->getId(), src_net_elm->getId()) = ((TO_FLOYD_LINK(dst_net_elm->getId(), src_net_elm->getId()))->link_list)->used; /* count of links, old model assume 1 */ @@ -269,11 +261,11 @@ void AsFloyd::parseRoute(sg_platf_route_cbarg_t route) xbt_dynar_free(&route->link_list); } -void AsFloyd::end(){ +void AsFloyd::Seal(){ unsigned int i, j, a, b, c; /* set the size of table routing */ - size_t table_size = xbt_dynar_length(p_indexNetworkElm); + size_t table_size = xbt_dynar_length(vertices_); if(!p_linkTable) { /* Create Cost, Predecessor and Link tables */ @@ -291,7 +283,7 @@ void AsFloyd::end(){ } /* Add the loopback if needed */ - if (routing_platf->p_loopback && p_hierarchy == SURF_ROUTING_BASE) { + if (routing_platf->p_loopback && hierarchy_ == SURF_ROUTING_BASE) { for (i = 0; i < table_size; i++) { sg_platf_route_cbarg_t e_route = TO_FLOYD_LINK(i, i); if (!e_route) {