X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/fa222c38f9b796be07ab4351ffc810a61a8fd705..d4dde3e21757601ea3e603e38a84b265067179db:/src/surf/surf_routing_cluster.cpp diff --git a/src/surf/surf_routing_cluster.cpp b/src/surf/surf_routing_cluster.cpp index 8ee2f556e7..81848c2ebb 100644 --- a/src/surf/surf_routing_cluster.cpp +++ b/src/surf/surf_routing_cluster.cpp @@ -12,33 +12,22 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_cluster, surf, "Routing part of surf" * Note that a router is created, easing the interconnexion with the rest of the world. */ -AS_t model_cluster_create(void) -{ - return new AsCluster(); -} +namespace simgrid { +namespace surf { + AsCluster::AsCluster(const char*name) + : As(name) + {} -/* Creation routing model functions */ -AsCluster::AsCluster() : AsNone() -{ - p_backbone = 0; - p_loopback = 0; - p_router = 0; - p_has_limiter = 0; - p_has_loopback = 0; - p_nb_links_per_node = 1; -} - -/* Business methods */ -void AsCluster::getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_route_cbarg_t route, double *lat) +void AsCluster::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t route, double *lat) { s_surf_parsing_link_up_down_t info; XBT_VERB("cluster_get_route_and_latency from '%s'[%d] to '%s'[%d]", - src->getName(), src->getId(), dst->getName(), dst->getId()); + src->name(), src->id(), dst->name(), dst->id()); - if (src->getRcType() != SURF_NETWORK_ELEMENT_ROUTER) { // No specific link for router + if (! src->isRouter()) { // No specific link for router - if((src->getId() == dst->getId()) && p_has_loopback ){ - info = xbt_dynar_get_as(p_linkUpDownList, src->getId() * p_nb_links_per_node, s_surf_parsing_link_up_down_t); + if((src->id() == dst->id()) && has_loopback_ ){ + info = xbt_dynar_get_as(upDownLinks, src->id() * nb_links_per_node_, s_surf_parsing_link_up_down_t); xbt_dynar_push_as(route->link_list, void *, info.link_up); if (lat) *lat += static_cast(info.link_up)->getLatency(); @@ -46,12 +35,12 @@ void AsCluster::getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_ } - if (p_has_limiter){ // limiter for sender - info = xbt_dynar_get_as(p_linkUpDownList, src->getId() * p_nb_links_per_node + p_has_loopback, s_surf_parsing_link_up_down_t); + if (has_limiter_){ // limiter for sender + info = xbt_dynar_get_as(upDownLinks, src->id() * nb_links_per_node_ + has_loopback_, s_surf_parsing_link_up_down_t); xbt_dynar_push_as(route->link_list, void *, info.link_up); } - info = xbt_dynar_get_as(p_linkUpDownList, src->getId() * p_nb_links_per_node + p_has_loopback + p_has_limiter, s_surf_parsing_link_up_down_t); + info = xbt_dynar_get_as(upDownLinks, src->id() * nb_links_per_node_ + has_loopback_ + has_limiter_, s_surf_parsing_link_up_down_t); if (info.link_up) { // link up xbt_dynar_push_as(route->link_list, void *, info.link_up); if (lat) @@ -60,22 +49,23 @@ void AsCluster::getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_ } - if (p_backbone) { - xbt_dynar_push_as(route->link_list, void *, static_cast(p_backbone)); + if (backbone_) { + xbt_dynar_push_as(route->link_list, void *, + static_cast(backbone_)); if (lat) - *lat += p_backbone->getLatency(); + *lat += backbone_->getLatency(); } - if (dst->getRcType() != SURF_NETWORK_ELEMENT_ROUTER) { // No specific link for router - info = xbt_dynar_get_as(p_linkUpDownList, dst->getId() * p_nb_links_per_node + p_has_loopback + p_has_limiter, s_surf_parsing_link_up_down_t); + if (! dst->isRouter()) { // No specific link for router + info = xbt_dynar_get_as(upDownLinks, dst->id() * nb_links_per_node_ + has_loopback_ + has_limiter_, s_surf_parsing_link_up_down_t); if (info.link_down) { // link down xbt_dynar_push_as(route->link_list, void *, info.link_down); if (lat) *lat += static_cast(info.link_down)->getLatency(); } - if (p_has_limiter){ // limiter for receiver - info = xbt_dynar_get_as(p_linkUpDownList, dst->getId() * p_nb_links_per_node + p_has_loopback, s_surf_parsing_link_up_down_t); + if (has_limiter_){ // limiter for receiver + info = xbt_dynar_get_as(upDownLinks, dst->id() * nb_links_per_node_ + has_loopback_, s_surf_parsing_link_up_down_t); xbt_dynar_push_as(route->link_list, void *, info.link_up); } } @@ -84,40 +74,41 @@ void AsCluster::getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_ void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) { int isrc; - int table_size = xbt_dynar_length(p_indexNetworkElm); + int table_size = xbt_dynar_length(vertices_); - RoutingEdge *src; + NetCard *src; xbt_node_t current, previous, backboneNode = NULL, routerNode; s_surf_parsing_link_up_down_t info; - xbt_assert(p_router,"Malformed cluster. This may be because your platform file is a hypergraph while it must be a graph."); + xbt_assert(router_,"Malformed cluster. This may be because your platform file is a hypergraph while it must be a graph."); /* create the router */ - char *link_name = p_router->getName(); + char *link_name = router_->name(); routerNode = new_xbt_graph_node(graph, link_name, nodes); - if(p_backbone) { - const char *link_nameR = p_backbone->getName(); + if(backbone_) { + const char *link_nameR = backbone_->getName(); backboneNode = new_xbt_graph_node(graph, link_nameR, nodes); new_xbt_graph_edge(graph, routerNode, backboneNode, edges); } for (isrc = 0; isrc < table_size; isrc++) { - src = xbt_dynar_get_as(p_indexNetworkElm, isrc, RoutingEdge*); + src = xbt_dynar_get_as(vertices_, isrc, NetCard*); - if (src->getRcType() != SURF_NETWORK_ELEMENT_ROUTER) { - previous = new_xbt_graph_node(graph, src->getName(), nodes); + if (! src->isRouter()) { + previous = new_xbt_graph_node(graph, src->name(), nodes); - info = xbt_dynar_get_as(p_linkUpDownList, src->getId(), s_surf_parsing_link_up_down_t); + info = xbt_dynar_get_as(upDownLinks, src->id(), s_surf_parsing_link_up_down_t); if (info.link_up) { // link up - const char *link_name = static_cast(info.link_up)->getName(); + const char *link_name = static_cast( + info.link_up)->getName(); current = new_xbt_graph_node(graph, link_name, nodes); new_xbt_graph_edge(graph, previous, current, edges); - if (p_backbone) { + if (backbone_) { new_xbt_graph_edge(graph, current, backboneNode, edges); } else { new_xbt_graph_edge(graph, current, routerNode, edges); @@ -126,11 +117,12 @@ void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) } if (info.link_down) { // link down - const char *link_name = static_cast(info.link_down)->getName(); + const char *link_name = static_cast( + info.link_down)->getName(); current = new_xbt_graph_node(graph, link_name, nodes); new_xbt_graph_edge(graph, previous, current, edges); - if (p_backbone) { + if (backbone_) { new_xbt_graph_edge(graph, current, backboneNode, edges); } else { new_xbt_graph_edge(graph, current, routerNode, edges); @@ -150,7 +142,6 @@ void AsCluster::create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, link.id = link_id; link.bandwidth = cluster->bw; link.latency = cluster->lat; - link.state = SURF_RESOURCE_ON; link.policy = cluster->sharing_policy; sg_platf_new_link(&link); @@ -165,19 +156,9 @@ void AsCluster::create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, info.link_up = sg_link_by_name(link_id); info.link_down = info.link_up; } - xbt_dynar_set(p_linkUpDownList, position, &info); + xbt_dynar_set(upDownLinks, position, &info); xbt_free(link_id); } -int AsCluster::parsePU(RoutingEdge *elm) { - XBT_DEBUG("Load process unit \"%s\"", elm->getName()); - xbt_dynar_push_as(p_indexNetworkElm, RoutingEdge*, elm); - return xbt_dynar_length(p_indexNetworkElm)-1; } - -int AsCluster::parseAS(RoutingEdge *elm) { - XBT_DEBUG("Load Autonomous system \"%s\"", elm->getName()); - xbt_dynar_push_as(p_indexNetworkElm, RoutingEdge*, elm); - return xbt_dynar_length(p_indexNetworkElm)-1; } -