X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7e049faf8cdd41c59c2e97f8c46fd6052b23b8a3..c54b74368b97bb0d0b42aea6857681d7ff9df910:/src/surf/workstation_ptask_L07.c diff --git a/src/surf/workstation_ptask_L07.c b/src/surf/workstation_ptask_L07.c index 730476ecd3..b66945fb43 100644 --- a/src/surf/workstation_ptask_L07.c +++ b/src/surf/workstation_ptask_L07.c @@ -6,6 +6,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "xbt/ex.h" +#include "xbt/str.h" #include "xbt/dict.h" #include "surf_private.h" /* extern lmm_system_t maxmin_system; */ @@ -360,7 +361,7 @@ static void update_actions_state(double now, double delta) static void update_resource_state(void *id, tmgr_trace_event_t event_type, - double value) + double value, double date) { cpu_L07_t cpu = id; link_L07_t nw_link = id; @@ -374,10 +375,11 @@ static void update_resource_state(void *id, } else if (event_type == nw_link->lat_event) { lmm_variable_t var = NULL; surf_action_workstation_L07_t action = NULL; + lmm_element_t elem = NULL; nw_link->lat_current = value; - while (lmm_get_var_from_cnst - (ptask_maxmin_system, nw_link->constraint, &var)) { + while ((var = lmm_get_var_from_cnst + (ptask_maxmin_system, nw_link->constraint, &elem))) { action = lmm_variable_id(var); @@ -399,7 +401,7 @@ static void update_resource_state(void *id, if (event_type == cpu->power_event) { cpu->power_current = value; lmm_update_constraint_bound(ptask_maxmin_system, cpu->constraint, - cpu->power_current); + cpu->power_current * cpu->power_scale); } else if (event_type == cpu->state_event) { if (value > 0) cpu->state_current = SURF_CPU_ON; @@ -485,10 +487,8 @@ static surf_action_t execute_parallel_task(int workstation_nb, int nb_host = 0; double latency = 0.0; - if (parallel_task_link_set == NULL) { - parallel_task_link_set = - xbt_dict_new_ext(workstation_nb * workstation_nb * 10); - } + if (parallel_task_link_set == NULL) + parallel_task_link_set = xbt_dict_new(); xbt_dict_reset(parallel_task_link_set); @@ -877,7 +877,6 @@ static void parse_route_set_route(void) char* name; if (src_id != -1 && dst_id != -1) { name = bprintf("%x#%x",src_id, dst_id); - manage_route(route_table, name, route_action, 0); free(name); } @@ -913,6 +912,7 @@ static void add_route(void) char *key,*data, *end; const char *sep = "#"; xbt_dynar_t links, keys; + char* link = NULL; if (routing_table == NULL) create_routing_table(); @@ -927,7 +927,7 @@ static void add_route(void) link_list_capacity = xbt_dynar_length(links); link_list = xbt_new(link_L07_t, link_list_capacity); - char* link = NULL; + xbt_dynar_foreach (links, cpt, link) { TRY { link_list[nb_link++] = xbt_dict_get(link_set, link); @@ -937,25 +937,70 @@ static void add_route(void) } } route_new(src_id, dst_id, link_list, nb_link); - xbt_dynar_free(&links); } xbt_dict_free(&route_table); } -static void add_traces(void) -{ - xbt_dynar_t trace_connect = NULL; - unsigned int cpt; - int connect_element, connect_kind; - char *value, *trace_id, *connector_id; - link_L07_t link; - cpu_L07_t host = NULL; - tmgr_trace_t trace; +static void add_traces(void) { + xbt_dict_cursor_t cursor=NULL; + char *trace_name,*elm; - if (!traces_connect_list) return; + if (!trace_connect_list_host_avail) return; - /*for all trace connects parse them and update traces for hosts or links */ + /* Connect traces relative to cpu */ + xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) { + tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name); + cpu_L07_t host = xbt_dict_get_or_null(workstation_set, elm); + + xbt_assert1(host, "Host %s undefined", elm); + xbt_assert1(trace, "Trace %s undefined", trace_name); + + host->state_event = tmgr_history_add_trace(history, trace, 0.0, 0, host); + } + + xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) { + tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name); + cpu_L07_t host = xbt_dict_get_or_null(workstation_set, elm); + + xbt_assert1(host, "Host %s undefined", elm); + xbt_assert1(trace, "Trace %s undefined", trace_name); + + host->power_event = tmgr_history_add_trace(history, trace, 0.0, 0, host); + } + + /* Connect traces relative to network */ + xbt_dict_foreach(trace_connect_list_link_avail, cursor, trace_name, elm) { + tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name); + link_L07_t link = xbt_dict_get_or_null(link_set, elm); + + xbt_assert1(link, "Link %s undefined", elm); + xbt_assert1(trace, "Trace %s undefined", trace_name); + + link->state_event = tmgr_history_add_trace(history, trace, 0.0, 0, link); + } + + xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) { + tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name); + link_L07_t link = xbt_dict_get_or_null(link_set, elm); + + xbt_assert1(link, "Link %s undefined", elm); + xbt_assert1(trace, "Trace %s undefined", trace_name); + + link->bw_event = tmgr_history_add_trace(history, trace, 0.0, 0, link); + } + + xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) { + tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name); + link_L07_t link = xbt_dict_get_or_null(link_set, elm); + + xbt_assert1(link, "Link %s undefined", elm); + xbt_assert1(trace, "Trace %s undefined", trace_name); + + link->lat_event = tmgr_history_add_trace(history, trace, 0.0, 0, link); + } +/* + xbt_dynar_foreach (traces_connect_list, cpt, value) { trace_connect = xbt_str_split_str(value, "#"); trace_id = xbt_dynar_get_as(trace_connect, 0, char*); @@ -981,9 +1026,13 @@ static void add_traces(void) } } } - - xbt_dynar_free(&trace_connect); - xbt_dynar_free(&traces_connect_list); +*/ + xbt_dict_free(&trace_connect_list_host_avail); + xbt_dict_free(&trace_connect_list_power); + xbt_dict_free(&trace_connect_list_link_avail); + xbt_dict_free(&trace_connect_list_bandwidth); + xbt_dict_free(&trace_connect_list_latency); + xbt_dict_free(&traces_set_list); } @@ -1099,8 +1148,8 @@ static void model_init_internal(void) surf_workstation_model->common_public->get_properties = get_properties; - workstation_set = xbt_dict_new_ext(1024); - link_set = xbt_dict_new_ext(1024); + workstation_set = xbt_dict_new(); + link_set = xbt_dict_new(); if (!ptask_maxmin_system) ptask_maxmin_system = lmm_system_new();