X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f3ae712a1b95294052b6e8136d0f0f2d4b30e6eb..5677df9af6d2d3f0530b8213b964594247b61769:/src/surf/surf_routing.cpp diff --git a/src/surf/surf_routing.cpp b/src/surf/surf_routing.cpp index a4bbe30144..4a381dcb89 100644 --- a/src/surf/surf_routing.cpp +++ b/src/surf/surf_routing.cpp @@ -8,7 +8,7 @@ #include "surf_routing_private.hpp" #include "surf_routing_cluster.hpp" #include "surf_routing_cluster_torus.hpp" - +#include "surf_routing_cluster_fat_tree.hpp" #include "simgrid/platf_interface.h" // platform creation API internal interface #include "simgrid/sg_config.h" @@ -19,13 +19,13 @@ /** * @ingroup SURF_build_api - * @brief A library containing all known workstations + * @brief A library containing all known hosts */ xbt_lib_t host_lib; int ROUTING_HOST_LEVEL; //Routing level int SURF_CPU_LEVEL; //Surf cpu level -int SURF_WKS_LEVEL; //Surf workstation level +int SURF_HOST_LEVEL; //Surf host level int SIMIX_HOST_LEVEL; //Simix host level int SIMIX_STORAGE_LEVEL; //Simix storage level int MSG_HOST_LEVEL; //Msg host level @@ -43,7 +43,6 @@ int NS3_HOST_LEVEL; //host node for ns3 xbt_lib_t link_lib; int SD_LINK_LEVEL; //Simdag level int SURF_LINK_LEVEL; //Surf level -int NS3_LINK_LEVEL; //link for ns3 xbt_lib_t as_router_lib; int ROUTING_ASR_LEVEL; //Routing level @@ -56,7 +55,7 @@ static xbt_dict_t random_value = NULL; /** @brief Retrieve a routing edge from its name * - * Routing edges are either CPU/workstation and routers, whatever + * Routing edges are either host and routers, whatever */ RoutingEdgePtr sg_routing_edge_by_name_or_null(const char *name) { RoutingEdgePtr net_elm = (RoutingEdgePtr) xbt_lib_get_or_null(host_lib, name, ROUTING_HOST_LEVEL); @@ -89,7 +88,7 @@ typedef enum { SURF_MODEL_VIVALDI, SURF_MODEL_CLUSTER, SURF_MODEL_TORUS_CLUSTER, - + SURF_MODEL_FAT_TREE_CLUSTER, } e_routing_types; struct s_model_type routing_models[] = { @@ -111,8 +110,10 @@ struct s_model_type routing_models[] = { model_vivaldi_create, NULL}, {"Cluster", "Cluster routing", model_cluster_create, NULL}, - {"Torus_Cluster", "Torus Cluster routing", - model_torus_cluster_create, NULL}, + {"Torus_Cluster", "Torus Cluster routing", + model_torus_cluster_create, NULL}, + {"Fat_Tree_Cluster", "Fat Tree Cluster routing", + model_fat_tree_cluster_create, NULL}, {NULL, NULL, NULL, NULL} }; @@ -356,14 +357,15 @@ void routing_AS_begin(sg_platf_AS_cbarg_t AS) /* search the routing model */ switch(AS->routing){ - case A_surfxml_AS_routing_Cluster: model = &routing_models[SURF_MODEL_CLUSTER];break; - case A_surfxml_AS_routing_Cluster___torus: model = &routing_models[SURF_MODEL_TORUS_CLUSTER];break; - case A_surfxml_AS_routing_Dijkstra: model = &routing_models[SURF_MODEL_DIJKSTRA];break; - case A_surfxml_AS_routing_DijkstraCache: model = &routing_models[SURF_MODEL_DIJKSTRACACHE];break; - case A_surfxml_AS_routing_Floyd: model = &routing_models[SURF_MODEL_FLOYD];break; - case A_surfxml_AS_routing_Full: model = &routing_models[SURF_MODEL_FULL];break; - case A_surfxml_AS_routing_None: model = &routing_models[SURF_MODEL_NONE];break; - case A_surfxml_AS_routing_Vivaldi: model = &routing_models[SURF_MODEL_VIVALDI];break; + case A_surfxml_AS_routing_Cluster: model = &routing_models[SURF_MODEL_CLUSTER];break; + case A_surfxml_AS_routing_Cluster___torus: model = &routing_models[SURF_MODEL_TORUS_CLUSTER];break; + case A_surfxml_AS_routing_Cluster___fat___tree: model = &routing_models[SURF_MODEL_FAT_TREE_CLUSTER];break; + case A_surfxml_AS_routing_Dijkstra: model = &routing_models[SURF_MODEL_DIJKSTRA];break; + case A_surfxml_AS_routing_DijkstraCache: model = &routing_models[SURF_MODEL_DIJKSTRACACHE];break; + case A_surfxml_AS_routing_Floyd: model = &routing_models[SURF_MODEL_FLOYD];break; + case A_surfxml_AS_routing_Full: model = &routing_models[SURF_MODEL_FULL];break; + case A_surfxml_AS_routing_None: model = &routing_models[SURF_MODEL_NONE];break; + case A_surfxml_AS_routing_Vivaldi: model = &routing_models[SURF_MODEL_VIVALDI];break; default: xbt_die("Not a valid model!!!"); break; } @@ -401,7 +403,7 @@ void routing_AS_begin(sg_platf_AS_cbarg_t AS) /* add to the father element list */ info->setId(current_routing->parseAS(info)); } else { - THROWF(arg_error, 0, "All defined components must be belong to a AS"); + THROWF(arg_error, 0, "All defined components must belong to a AS"); } xbt_lib_set(as_router_lib, info->getName(), ROUTING_ASR_LEVEL, @@ -631,7 +633,7 @@ xbt_dynar_t RoutingPlatf::getOneLinkRoutes(){ xbt_dynar_t RoutingPlatf::recursiveGetOneLinkRoutes(AsPtr rc) { - xbt_dynar_t ret = xbt_dynar_new(sizeof(OnelinkPtr), xbt_free); + xbt_dynar_t ret = xbt_dynar_new(sizeof(OnelinkPtr), xbt_free_f); //adding my one link routes xbt_dynar_t onelink_mine = rc->getOneLinkRoutes(); @@ -759,36 +761,36 @@ static void routing_parse_cabinet(sg_platf_cabinet_cbarg_t cabinet) s_sg_platf_host_cbarg_t host; memset(&host, 0, sizeof(host)); host.initial_state = SURF_RESOURCE_ON; - host.pstate = 0; - host.power_scale = 1.0; - host.core_amount = 1; + host.pstate = 0; + host.power_scale = 1.0; + host.core_amount = 1; s_sg_platf_link_cbarg_t link; memset(&link, 0, sizeof(link)); - link.state = SURF_RESOURCE_ON; - link.policy = SURF_LINK_FULLDUPLEX; - link.latency = cabinet->lat; + link.state = SURF_RESOURCE_ON; + link.policy = SURF_LINK_FULLDUPLEX; + link.latency = cabinet->lat; link.bandwidth = cabinet->bw; s_sg_platf_host_link_cbarg_t host_link; memset(&host_link, 0, sizeof(host_link)); for (i = start; i <= end; i++) { - host_id = bprintf("%s%d%s",cabinet->prefix,i,cabinet->suffix); - link_id = bprintf("link_%s%d%s",cabinet->prefix,i,cabinet->suffix); - host.id = host_id; - link.id = link_id; + host_id = bprintf("%s%d%s",cabinet->prefix,i,cabinet->suffix); + link_id = bprintf("link_%s%d%s",cabinet->prefix,i,cabinet->suffix); + host.id = host_id; + link.id = link_id; xbt_dynar_t power_state_list = xbt_dynar_new(sizeof(double), NULL); xbt_dynar_push(power_state_list,&cabinet->power); host.power_peak = power_state_list; sg_platf_new_host(&host); sg_platf_new_link(&link); - char* link_up = bprintf("%s_UP",link_id); - char* link_down = bprintf("%s_DOWN",link_id); - host_link.id = host_id; - host_link.link_up = link_up; - host_link.link_down= link_down; + char* link_up = bprintf("%s_UP",link_id); + char* link_down = bprintf("%s_DOWN",link_id); + host_link.id = host_id; + host_link.link_up = link_up; + host_link.link_down = link_down; sg_platf_new_host_link(&host_link); free(host_id); @@ -836,7 +838,15 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster) AS.routing = A_surfxml_AS_routing_Cluster___torus; sg_platf_new_AS_begin(&AS); ((AsClusterTorusPtr)current_routing)->parse_specific_arguments(cluster); - }else{ + } + else if (cluster->topology == SURF_CLUSTER_FAT_TREE) { + XBT_DEBUG("", cluster->id); + AS.routing = A_surfxml_AS_routing_Cluster___fat___tree; + sg_platf_new_AS_begin(&AS); + ((AsClusterFatTree*)current_routing)->parse_specific_arguments(cluster); + } + + else{ XBT_DEBUG("", cluster->id); AS.routing = A_surfxml_AS_routing_Cluster; sg_platf_new_AS_begin(&AS); @@ -884,6 +894,15 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster) memset(&host, 0, sizeof(host)); host.id = host_id; + if ((cluster->properties != NULL) && (!xbt_dict_is_empty(cluster->properties))) { + xbt_dict_cursor_t cursor=NULL; + char *key,*data; + host.properties = xbt_dict_new(); + + xbt_dict_foreach(cluster->properties,cursor,key,data) { + xbt_dict_set(host.properties, key, xbt_strdup(data),free); + } + } if (cluster->availability_trace && strcmp(cluster->availability_trace, "")) { xbt_dict_set(patterns, "radical", bprintf("%d", i), NULL); char *avail_file = xbt_str_varsubst(cluster->availability_trace, patterns); @@ -936,13 +955,13 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster) memset(&link, 0, sizeof(link)); - link.id = tmp_link; + link.id = tmp_link; link.bandwidth = cluster->loopback_bw; - link.latency = cluster->loopback_lat; - link.state = SURF_RESOURCE_ON; - link.policy = SURF_LINK_FATPIPE; + link.latency = cluster->loopback_lat; + link.state = SURF_RESOURCE_ON; + link.policy = SURF_LINK_FATPIPE; sg_platf_new_link(&link); - info_loop.link_up = + info_loop.link_up = xbt_lib_get_or_null(link_lib, tmp_link, SURF_LINK_LEVEL); info_loop.link_down = info_loop.link_up; free(tmp_link); @@ -975,12 +994,15 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster) //call the cluster function that adds the others links - + if (cluster->topology == SURF_CLUSTER_FAT_TREE) { + ((AsClusterFatTree*) current_routing)->addProcessingNode(i); + } + else { ((AsClusterPtr)current_routing)->create_links_for_node(cluster, i, rankId, rankId* ((AsClusterPtr)current_routing)->p_nb_links_per_node + ((AsClusterPtr)current_routing)->p_has_loopback + ((AsClusterPtr)current_routing)->p_has_limiter ); - + } xbt_free(link_id); xbt_free(host_id); rankId++; @@ -990,6 +1012,10 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster) } xbt_dynar_free(&radical_elements); + // For fat trees, the links must be created once all nodes have been added + if(cluster->topology == SURF_CLUSTER_FAT_TREE) { + ((AsClusterFatTree*)current_routing)->create_links(); + } // Add a router. It is magically used thanks to the way in which surf_routing_cluster is written, // and it's very useful to connect clusters together XBT_DEBUG(" "); @@ -1014,11 +1040,11 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster) cluster->bb_bw, cluster->bb_lat); memset(&link, 0, sizeof(link)); - link.id = link_backbone; + link.id = link_backbone; link.bandwidth = cluster->bb_bw; - link.latency = cluster->bb_lat; - link.state = SURF_RESOURCE_ON; - link.policy = cluster->bb_sharing_policy; + link.latency = cluster->bb_lat; + link.state = SURF_RESOURCE_ON; + link.policy = cluster->bb_sharing_policy; sg_platf_new_link(&link); @@ -1050,8 +1076,8 @@ static void routing_parse_peer(sg_platf_peer_cbarg_t peer) XBT_DEBUG("", peer->id); s_sg_platf_AS_cbarg_t AS = SG_PLATF_AS_INITIALIZER; - AS.id = peer->id; - AS.routing = A_surfxml_AS_routing_Cluster; + AS.id = peer->id; + AS.routing = A_surfxml_AS_routing_Cluster; sg_platf_new_AS_begin(&AS); current_routing->p_linkUpDownList = xbt_dynar_new(sizeof(s_surf_parsing_link_up_down_t),NULL); @@ -1075,8 +1101,8 @@ static void routing_parse_peer(sg_platf_peer_cbarg_t peer) s_sg_platf_link_cbarg_t link; memset(&link, 0, sizeof(link)); - link.state = SURF_RESOURCE_ON; - link.policy = SURF_LINK_SHARED; + link.state = SURF_RESOURCE_ON; + link.policy = SURF_LINK_SHARED; link.latency = peer->lat; char* link_up = bprintf("%s_UP",link_id); @@ -1096,9 +1122,9 @@ static void routing_parse_peer(sg_platf_peer_cbarg_t peer) XBT_DEBUG("", host_id,link_up,link_down); s_sg_platf_host_link_cbarg_t host_link; memset(&host_link, 0, sizeof(host_link)); - host_link.id = host_id; - host_link.link_up = link_up; - host_link.link_down= link_down; + host_link.id = host_id; + host_link.link_up = link_up; + host_link.link_down = link_down; sg_platf_new_host_link(&host_link); XBT_DEBUG("", router_id); @@ -1281,9 +1307,7 @@ void routing_register_callbacks() sg_platf_trace_add_cb(routing_parse_trace); sg_platf_trace_connect_add_cb(routing_parse_trace_connect); -#ifdef HAVE_TRACING instr_routing_define_callbacks(); -#endif } /** @@ -1325,6 +1349,32 @@ const char *surf_AS_get_name(AsPtr as) { return as->p_name; } +static AsPtr surf_AS_recursive_get_by_name(AsPtr current, const char * name) { + xbt_dict_cursor_t cursor = NULL; + char *key; + AS_t elem; + AsPtr tmp = NULL; + + if(!strcmp(current->p_name, name)) + return current; + + xbt_dict_foreach(current->p_routingSons, cursor, key, elem) { + tmp = surf_AS_recursive_get_by_name(elem, name); + if(tmp != NULL ) { + break; + } + } + return tmp; +} + + +AsPtr surf_AS_get_by_name(const char * name) { + AsPtr as = surf_AS_recursive_get_by_name(routing_platf->p_root, name); + if(as == NULL) + XBT_WARN("Impossible to find an AS with name %s, please check your input", name); + return as; +} + xbt_dict_t surf_AS_get_routing_sons(AsPtr as) { return as->p_routingSons; } @@ -1353,4 +1403,3 @@ xbt_dynar_t surf_AS_get_hosts(AsPtr as) { void surf_AS_get_graph(AS_t as, xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) { as->getGraph(graph, nodes, edges); } -