-
- if(xbt_dynar_length(dimensions) == 0 ) {
- /**
- * If torus is not specified, generate one link by node
- */
-
- memset(&link, 0, sizeof(link));
- 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);
-
- if (link.policy == SURF_LINK_FULLDUPLEX) {
- char *tmp_link = bprintf("%s_UP", link_id);
- info.link_up =
- xbt_lib_get_or_null(link_lib, tmp_link, SURF_LINK_LEVEL);
- free(tmp_link);
- tmp_link = bprintf("%s_DOWN", link_id);
- info.link_down =
- xbt_lib_get_or_null(link_lib, tmp_link, SURF_LINK_LEVEL);
- free(tmp_link);
- } else {
- info.link_up = xbt_lib_get_or_null(link_lib, link_id, SURF_LINK_LEVEL);
- info.link_down = info.link_up;
- }
- xbt_dynar_set(current_routing->p_linkUpDownList, rankId*nb_links_per_node
- + ((AsClusterPtr)current_routing)->p_has_loopback
- + ((AsClusterPtr)current_routing)->p_has_limiter,
- &info);
- }else{
-
- unsigned int j = 0;
- /**
- * Create all links that exist in the torus.
- * Each rank creates #dimensions-1 links
- */
- int neighbour_rank_id = 0; // The other node the link connects
- int current_dimension = 0, // which dimension are we currently in?
- // we need to iterate over all dimensions
- // and create all links there
- dim_product = 1; // Needed to calculate the next neighbour_id
- for (j = 0; j < xbt_dynar_length(dimensions); j++) {
-
- memset(&link, 0, sizeof(link));
- current_dimension = xbt_dynar_get_as(dimensions, j, int);
- neighbour_rank_id = ( ((int) i / dim_product) % current_dimension == current_dimension-1) ? i - (current_dimension-1)*dim_product : i + dim_product;
- link_id = bprintf("link_from_%i_to_%i", i, neighbour_rank_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);
- s_surf_parsing_link_up_down_t info;
- if (link.policy == SURF_LINK_FULLDUPLEX) {
- char *tmp_link = bprintf("%s_UP", link_id);
- info.link_up =
- xbt_lib_get_or_null(link_lib, tmp_link, SURF_LINK_LEVEL);
- free(tmp_link);
- tmp_link = bprintf("%s_DOWN", link_id);
- info.link_down =
- xbt_lib_get_or_null(link_lib, tmp_link, SURF_LINK_LEVEL);
- free(tmp_link);
- } else {
- info.link_up = xbt_lib_get_or_null(link_lib, link_id, SURF_LINK_LEVEL);
- info.link_down = info.link_up;
- }
- /**
- * Add the link to its appropriate position;
- * note that position rankId*(xbt_dynar_length(dimensions)+has_loopack?+has_limiter?)
- * holds the link "rankId->rankId"
- */
- xbt_dynar_set(current_routing->p_linkUpDownList, rankId*nb_links_per_node
- + ((AsClusterPtr)current_routing)->p_has_loopback
- + ((AsClusterPtr)current_routing)->p_has_limiter
- + j,
- &info);
- dim_product *= current_dimension;
- xbt_free(link_id);
-
- }