int ret = sscanf(string, "%lg", &res);
if (ret != 1)
surf_parse_error("%s is not a double", string);
+ //printf("Parsed double [%lg] %s\n", res, string);
return res;
}
return res;
}
+double surf_parse_get_time(const char *string) {
+ char* ptr;
+ double res = strtod(string, &ptr);
+ if (ptr == string)
+ surf_parse_error("This is not a time: %s", string);
+ else if (strcmp(ptr, "ps") == 0)
+ res *= 1E-12;
+ else if (strcmp(ptr, "ns") == 0)
+ res *= 1E-9;
+ else if (strcmp(ptr, "us") == 0)
+ res *= 1E-6;
+ else if (strcmp(ptr, "ms") == 0)
+ res *= 1E-3;
+ else if (strcmp(ptr, "s") == 0)
+ res *= 1;
+ else if (strcmp(ptr, "m") == 0)
+ res *= 60;
+ else if (strcmp(ptr, "h") == 0)
+ res *= 3600;
+ else if (strcmp(ptr, "d") == 0)
+ res *= 86400;
+ else if (strcmp(ptr, "w") == 0)
+ res *= 604800;
+ return res;
+}
+
+double surf_parse_get_bandwidth(const char *string) {
+ char* ptr;
+ double res = strtod(string, &ptr);
+ if (ptr == string)
+ surf_parse_error("This is not a bandwidth: %s", string);
+ else if (strcmp(ptr, "KBps") == 0)
+ res *= 1E3;
+ else if (strcmp(ptr, "MBps") == 0)
+ res *= 1E6;
+ else if (strcmp(ptr, "GBps") == 0)
+ res *= 1E9;
+ else if (strcmp(ptr, "TBps") == 0)
+ res *= 1E12;
+ else if (strcmp(ptr, "Bps") == 0)
+ res *= 1;
+ else if (strcmp(ptr, "kbps") == 0)
+ res *= 0.125 * 1E3;
+ else if (strcmp(ptr, "mbps") == 0)
+ res *= 0.125 * 1E6;
+ else if (strcmp(ptr, "gbps") == 0)
+ res *= 0.125 * 1E9;
+ else if (strcmp(ptr, "tbps") == 0)
+ res *= 0.125 * 1E12;
+ else if (strcmp(ptr, "bps") == 0)
+ res *= 0.125;
+ return res;
+}
+
+double surf_parse_get_power(const char *string) {
+ char* ptr;
+ double res = strtod(string, &ptr);
+ if (ptr == string)
+ surf_parse_error("This is not a power: %s", string);
+ else if (strcmp(ptr, "kiloflops") == 0)
+ res *= 1E3;
+ else if (strcmp(ptr, "megaflops") == 0)
+ res *= 1E6;
+ else if (strcmp(ptr, "gigaflops") == 0)
+ res *= 1E9;
+ else if (strcmp(ptr, "teraflops") == 0)
+ res *= 1E12;
+ else if (strcmp(ptr, "petaflops") == 0)
+ res *= 1E15;
+ else if (strcmp(ptr, "exaflops") == 0)
+ res *= 1E18;
+ else if (strcmp(ptr, "zettaflops") == 0)
+ res *= 1E21;
+ else if (strcmp(ptr, "yottaflops") == 0)
+ res *= 1E24;
+ else if (strcmp(ptr, "flops") == 0)
+ res *= 1;
+ else if (strcmp(ptr, "kf") == 0)
+ res *= 1E3;
+ else if (strcmp(ptr, "mf") == 0)
+ res *= 1E6;
+ else if (strcmp(ptr, "gf") == 0)
+ res *= 1E9;
+ else if (strcmp(ptr, "tf") == 0)
+ res *= 1E12;
+ else if (strcmp(ptr, "pf") == 0)
+ res *= 1E15;
+ else if (strcmp(ptr, "ef") == 0)
+ res *= 1E18;
+ else if (strcmp(ptr, "zf") == 0)
+ res *= 1E21;
+ else if (strcmp(ptr, "yf") == 0)
+ res *= 1E24;
+ else if (strcmp(ptr, "f") == 0)
+ res *= 1;
+ return res;
+}
/*
* All the callback lists that can be overridden anywhere.
cluster.prefix = A_surfxml_cluster_prefix;
cluster.suffix = A_surfxml_cluster_suffix;
cluster.radical = A_surfxml_cluster_radical;
- cluster.power= surf_parse_get_double(A_surfxml_cluster_power);
+ cluster.power = surf_parse_get_power(A_surfxml_cluster_power);
cluster.core_amount = surf_parse_get_int(A_surfxml_cluster_core);
- cluster.bw = surf_parse_get_double(A_surfxml_cluster_bw);
- cluster.lat = surf_parse_get_double(A_surfxml_cluster_lat);
+ cluster.bw = surf_parse_get_bandwidth(A_surfxml_cluster_bw);
+ cluster.lat = surf_parse_get_time(A_surfxml_cluster_lat);
if(strcmp(A_surfxml_cluster_bb___bw,""))
- cluster.bb_bw = surf_parse_get_double(A_surfxml_cluster_bb___bw);
+ cluster.bb_bw = surf_parse_get_bandwidth(A_surfxml_cluster_bb___bw);
if(strcmp(A_surfxml_cluster_bb___lat,""))
- cluster.bb_lat = surf_parse_get_double(A_surfxml_cluster_bb___lat);
+ cluster.bb_lat = surf_parse_get_time(A_surfxml_cluster_bb___lat);
+ if(strcmp(A_surfxml_cluster_limiter___link,""))
+ cluster.limiter_link = surf_parse_get_double(A_surfxml_cluster_limiter___link);
+ if(strcmp(A_surfxml_cluster_loopback___bw,""))
+ cluster.loopback_bw = surf_parse_get_bandwidth(A_surfxml_cluster_loopback___bw);
+ if(strcmp(A_surfxml_cluster_loopback___lat,""))
+ cluster.loopback_lat = surf_parse_get_time(A_surfxml_cluster_loopback___lat);
cluster.router_id = A_surfxml_cluster_router___id;
switch (AX_surfxml_cluster_sharing___policy) {
cabinet.id = A_surfxml_cabinet_id;
cabinet.prefix = A_surfxml_cabinet_prefix;
cabinet.suffix = A_surfxml_cabinet_suffix;
- cabinet.power = surf_parse_get_double(A_surfxml_cabinet_power);
- cabinet.bw = surf_parse_get_double(A_surfxml_cabinet_bw);
- cabinet.lat = surf_parse_get_double(A_surfxml_cabinet_lat);
+ cabinet.power = surf_parse_get_power(A_surfxml_cabinet_power);
+ cabinet.bw = surf_parse_get_bandwidth(A_surfxml_cabinet_bw);
+ cabinet.lat = surf_parse_get_time(A_surfxml_cabinet_lat);
cabinet.radical = A_surfxml_cabinet_radical;
sg_platf_new_cabinet(&cabinet);
s_sg_platf_peer_cbarg_t peer;
memset(&peer,0,sizeof(peer));
peer.id = A_surfxml_peer_id;
- peer.power = surf_parse_get_double(A_surfxml_peer_power);
- peer.bw_in = surf_parse_get_double(A_surfxml_peer_bw___in);
- peer.bw_out = surf_parse_get_double(A_surfxml_peer_bw___out);
- peer.lat = surf_parse_get_double(A_surfxml_peer_lat);
+ peer.power = surf_parse_get_power(A_surfxml_peer_power);
+ peer.bw_in = surf_parse_get_bandwidth(A_surfxml_peer_bw___in);
+ peer.bw_out = surf_parse_get_bandwidth(A_surfxml_peer_bw___out);
+ peer.lat = surf_parse_get_time(A_surfxml_peer_lat);
peer.coord = A_surfxml_peer_coordinates;
peer.availability_trace = tmgr_trace_new_from_file(A_surfxml_peer_availability___file);
peer.state_trace = tmgr_trace_new_from_file(A_surfxml_peer_state___file);
link.properties = current_property_set;
link.id = A_surfxml_link_id;
- link.bandwidth = surf_parse_get_double(A_surfxml_link_bandwidth);
+ link.bandwidth = surf_parse_get_bandwidth(A_surfxml_link_bandwidth);
+ //printf("Link bandwidth [%lg]\n", link.bandwidth);
link.bandwidth_trace = tmgr_trace_new_from_file(A_surfxml_link_bandwidth___file);
- link.latency = surf_parse_get_double(A_surfxml_link_latency);
+ link.latency = surf_parse_get_time(A_surfxml_link_latency);
+ //printf("Link latency [%lg]\n", link.latency);
link.latency_trace = tmgr_trace_new_from_file(A_surfxml_link_latency___file);
switch (A_surfxml_link_state) {
link.properties = NULL;
link.id = A_surfxml_backbone_id;
- link.bandwidth = surf_parse_get_double(A_surfxml_backbone_bandwidth);
- link.latency = surf_parse_get_double(A_surfxml_backbone_latency);
+ link.bandwidth = surf_parse_get_bandwidth(A_surfxml_backbone_bandwidth);
+ link.latency = surf_parse_get_time(A_surfxml_backbone_latency);
link.state = SURF_RESOURCE_ON;
link.policy = SURF_LINK_SHARED;
trace_connect.kind = SURF_TRACE_CONNECT_KIND_LINK_AVAIL;
break;
}
- sg_platf_new_trace_connect(&trace_connect);
+ sg_platf_trace_connect(&trace_connect);
}
void STag_surfxml_AS(void){
xbt_dynar_free(&surf_parsed_filename_stack);
free(surf_parsed_filename);
+ surf_parsed_filename = NULL;
if (surf_file_to_parse) {
surf_parse__delete_buffer(surf_input_buffer);
power_scale = random_generate(random);
}
} else {
- power_scale = surf_parse_get_double(power);
+ power_scale = surf_parse_get_power(power);
}
return power_scale;
}