From 1fd664b43fb86c61c7f394c6d23de727cee5bc46 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Thu, 10 Mar 2016 21:56:07 +0100 Subject: [PATCH] move a function to the right (xml) file --- src/surf/sg_platf.cpp | 75 ++++++++++++++++++++++++++++++++++++--- src/surf/surf_routing.cpp | 69 ----------------------------------- 2 files changed, 71 insertions(+), 73 deletions(-) diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 55010c7bba..3adc2e1aeb 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -425,6 +425,75 @@ void routing_cluster_add_backbone(simgrid::surf::Link* bb) { XBT_DEBUG("Add a backbone to AS '%s'", current_routing->name()); } +void sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet) +{ + int start, end, i; + char *groups , *host_id , *link_id = NULL; + unsigned int iter; + xbt_dynar_t radical_elements; + xbt_dynar_t radical_ends; + + //Make all hosts + radical_elements = xbt_str_split(cabinet->radical, ","); + xbt_dynar_foreach(radical_elements, iter, groups) { + + radical_ends = xbt_str_split(groups, "-"); + start = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 0, char *)); + + switch (xbt_dynar_length(radical_ends)) { + case 1: + end = start; + break; + case 2: + end = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 1, char *)); + break; + default: + surf_parse_error("Malformed radical"); + break; + } + s_sg_platf_host_cbarg_t host = SG_PLATF_HOST_INITIALIZER; + memset(&host, 0, sizeof(host)); + host.pstate = 0; + host.core_amount = 1; + + s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER; + memset(&link, 0, sizeof(link)); + link.policy = SURF_LINK_FULLDUPLEX; + link.latency = cabinet->lat; + link.bandwidth = cabinet->bw; + + s_sg_platf_host_link_cbarg_t host_link = SG_PLATF_HOST_LINK_INITIALIZER; + 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.speed_peak = xbt_dynar_new(sizeof(double), NULL); + xbt_dynar_push(host.speed_peak,&cabinet->speed); + sg_platf_new_host(&host); + xbt_dynar_free(&host.speed_peak); + 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; + sg_platf_new_hostlink(&host_link); + + free(host_id); + free(link_id); + free(link_up); + free(link_down); + } + + xbt_dynar_free(&radical_ends); + } + xbt_dynar_free(&radical_elements); +} + void sg_platf_new_storage(sg_platf_storage_cbarg_t storage) { xbt_assert(!xbt_lib_get_or_null(storage_lib, storage->id,ROUTING_STORAGE_LEVEL), @@ -667,15 +736,13 @@ void sg_platf_new_peer(sg_platf_peer_cbarg_t peer) link.latency = peer->lat; char* link_up = bprintf("%s_UP",link_id); - XBT_DEBUG("", link_up, - peer->bw_out, peer->lat); + XBT_DEBUG("", link_up, peer->bw_out, peer->lat); link.id = link_up; link.bandwidth = peer->bw_out; sg_platf_new_link(&link); char* link_down = bprintf("%s_DOWN",link_id); - XBT_DEBUG("", link_down, - peer->bw_in, peer->lat); + XBT_DEBUG("", link_down, peer->bw_in, peer->lat); link.id = link_down; link.bandwidth = peer->bw_in; sg_platf_new_link(&link); diff --git a/src/surf/surf_routing.cpp b/src/surf/surf_routing.cpp index 4dba6f1a63..69ab7ead30 100644 --- a/src/surf/surf_routing.cpp +++ b/src/surf/surf_routing.cpp @@ -136,75 +136,6 @@ void routing_model_create(Link *loopback) /* ************************************************************************** */ /* ************************* GENERIC PARSE FUNCTIONS ************************ */ -void sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet) -{ - int start, end, i; - char *groups , *host_id , *link_id = NULL; - unsigned int iter; - xbt_dynar_t radical_elements; - xbt_dynar_t radical_ends; - - //Make all hosts - radical_elements = xbt_str_split(cabinet->radical, ","); - xbt_dynar_foreach(radical_elements, iter, groups) { - - radical_ends = xbt_str_split(groups, "-"); - start = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 0, char *)); - - switch (xbt_dynar_length(radical_ends)) { - case 1: - end = start; - break; - case 2: - end = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 1, char *)); - break; - default: - surf_parse_error("Malformed radical"); - break; - } - s_sg_platf_host_cbarg_t host = SG_PLATF_HOST_INITIALIZER; - memset(&host, 0, sizeof(host)); - host.pstate = 0; - host.core_amount = 1; - - s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER; - memset(&link, 0, sizeof(link)); - link.policy = SURF_LINK_FULLDUPLEX; - link.latency = cabinet->lat; - link.bandwidth = cabinet->bw; - - s_sg_platf_host_link_cbarg_t host_link = SG_PLATF_HOST_LINK_INITIALIZER; - 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.speed_peak = xbt_dynar_new(sizeof(double), NULL); - xbt_dynar_push(host.speed_peak,&cabinet->speed); - sg_platf_new_host(&host); - xbt_dynar_free(&host.speed_peak); - 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; - sg_platf_new_hostlink(&host_link); - - free(host_id); - free(link_id); - free(link_up); - free(link_down); - } - - xbt_dynar_free(&radical_ends); - } - xbt_dynar_free(&radical_elements); -} - static void check_disk_attachment() { xbt_lib_cursor_t cursor; -- 2.20.1