X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/8308c42874c76edaffd662b81eaacc6ad87b36e4..6cb691951277de5ede59b021bd50648ba9968182:/src/surf/workstation_ptask_L07.c diff --git a/src/surf/workstation_ptask_L07.c b/src/surf/workstation_ptask_L07.c index 7793af265e..8050848e99 100644 --- a/src/surf/workstation_ptask_L07.c +++ b/src/surf/workstation_ptask_L07.c @@ -19,13 +19,13 @@ typedef enum { /********* cpu object *****************/ /**************************************/ typedef struct cpu_L07 { - s_surf_resource_t generic_resource; /* Do not move this field: must match surf_resource_t */ + s_surf_resource_t generic_resource; /* Do not move this field: must match surf_resource_t */ e_surf_workstation_model_type_t type; /* Do not move this field: must match link_L07_t */ lmm_constraint_t constraint; /* Do not move this field: must match link_L07_t */ double power_scale; double power_current; tmgr_trace_event_t power_event; - e_surf_cpu_state_t state_current; + e_surf_resource_state_t state_current; tmgr_trace_event_t state_event; int id; /* cpu and network card are a single object... */ } s_cpu_L07_t, *cpu_L07_t; @@ -35,14 +35,14 @@ typedef struct cpu_L07 { /**************************************/ typedef struct link_L07 { - s_surf_resource_t generic_resource; /* Do not move this field: must match surf_resource_t */ + s_surf_resource_t generic_resource; /* Do not move this field: must match surf_resource_t */ e_surf_workstation_model_type_t type; /* Do not move this field: must match cpu_L07_t */ lmm_constraint_t constraint; /* Do not move this field: must match cpu_L07_t */ double lat_current; tmgr_trace_event_t lat_event; double bw_current; tmgr_trace_event_t bw_event; - e_surf_link_state_t state_current; + e_surf_resource_state_t state_current; tmgr_trace_event_t state_event; } s_link_L07_t, *link_L07_t; @@ -86,7 +86,7 @@ static void update_action_bound(surf_action_workstation_L07_t action) double lat = 0.0; if (action->communication_amount[i * workstation_nb + j] > 0) { - xbt_dynar_foreach(route,cpt,link) { + xbt_dynar_foreach(route, cpt, link) { lat += link->lat_current; } lat_current = @@ -182,6 +182,13 @@ static void action_set_priority(surf_action_t action, double priority) XBT_OUT; } +static double action_get_remains(surf_action_t action) +{ + XBT_IN1("(%p)", action); + return action->remains; + XBT_OUT; +} + /**************************************/ /******* Resource Private **********/ /**************************************/ @@ -298,14 +305,14 @@ static void update_actions_state(double now, double delta) if (((((link_L07_t) constraint_id)->type == SURF_WORKSTATION_RESOURCE_LINK) && (((link_L07_t) constraint_id)->state_current == - SURF_LINK_OFF)) || + SURF_RESOURCE_OFF)) || ((((cpu_L07_t) constraint_id)->type == SURF_WORKSTATION_RESOURCE_CPU) && - (((cpu_L07_t) constraint_id)->state_current == SURF_CPU_OFF))) { + (((cpu_L07_t) constraint_id)->state_current == + SURF_RESOURCE_OFF))) { DEBUG1("Action (%p) Failed!!", action); action->generic_action.finish = surf_get_clock(); - surf_action_state_set((surf_action_t) action, - SURF_ACTION_FAILED); + surf_action_state_set((surf_action_t) action, SURF_ACTION_FAILED); break; } } @@ -322,11 +329,13 @@ static void update_resource_state(void *id, link_L07_t nw_link = id; if (nw_link->type == SURF_WORKSTATION_RESOURCE_LINK) { - DEBUG2("Updating link %s (%p)", nw_link->generic_resource.name, nw_link); + DEBUG2("Updating link %s (%p)", surf_resource_name(nw_link), nw_link); if (event_type == nw_link->bw_event) { nw_link->bw_current = value; lmm_update_constraint_bound(ptask_maxmin_system, nw_link->constraint, nw_link->bw_current); + if (tmgr_trace_event_free(event_type)) + nw_link->bw_event = NULL; } else if (event_type == nw_link->lat_event) { lmm_variable_t var = NULL; surf_action_workstation_L07_t action = NULL; @@ -340,28 +349,37 @@ static void update_resource_state(void *id, action = lmm_variable_id(var); update_action_bound(action); } + if (tmgr_trace_event_free(event_type)) + nw_link->lat_event = NULL; } else if (event_type == nw_link->state_event) { if (value > 0) - nw_link->state_current = SURF_LINK_ON; + nw_link->state_current = SURF_RESOURCE_ON; else - nw_link->state_current = SURF_LINK_OFF; + nw_link->state_current = SURF_RESOURCE_OFF; + if (tmgr_trace_event_free(event_type)) + nw_link->state_event = NULL; } else { CRITICAL0("Unknown event ! \n"); xbt_abort(); } return; } else if (cpu->type == SURF_WORKSTATION_RESOURCE_CPU) { - DEBUG3("Updating cpu %s (%p) with value %g", cpu->generic_resource.name, cpu, value); + DEBUG3("Updating cpu %s (%p) with value %g", surf_resource_name(cpu), cpu, + value); if (event_type == cpu->power_event) { cpu->power_current = value; lmm_update_constraint_bound(ptask_maxmin_system, cpu->constraint, cpu->power_current * cpu->power_scale); + if (tmgr_trace_event_free(event_type)) + cpu->power_event = NULL; } else if (event_type == cpu->state_event) { if (value > 0) - cpu->state_current = SURF_CPU_ON; + cpu->state_current = SURF_RESOURCE_ON; else - cpu->state_current = SURF_CPU_OFF; + cpu->state_current = SURF_RESOURCE_OFF; + if (tmgr_trace_event_free(event_type)) + cpu->state_event = NULL; } else { CRITICAL0("Unknown event ! \n"); xbt_abort(); @@ -384,7 +402,7 @@ static void finalize(void) surf_network_model = NULL; used_routing->finalize(); - host_count = 0; // FIXME: KILLME? + host_count = 0; if (ptask_maxmin_system) { lmm_system_free(ptask_maxmin_system); @@ -396,7 +414,7 @@ static void finalize(void) /******* Resource Private **********/ /**************************************/ -static e_surf_cpu_state_t resource_get_state(void *cpu) +static e_surf_resource_state_t resource_get_state(void *cpu) { return ((cpu_L07_t) cpu)->state_current; } @@ -439,10 +457,10 @@ static surf_action_t execute_parallel_task(int workstation_nb, double lat = 0.0; if (communication_amount[i * workstation_nb + j] > 0) - xbt_dynar_foreach(route,cpt,link) { - lat += link->lat_current; - xbt_dict_set(parallel_task_link_set, link->generic_resource.name, - link, NULL); + xbt_dynar_foreach(route, cpt, link) { + lat += link->lat_current; + xbt_dict_set(parallel_task_link_set, link->generic_resource.name, + link, NULL); } latency = MAX(latency, lat); } @@ -455,16 +473,11 @@ static surf_action_t execute_parallel_task(int workstation_nb, if (computation_amount[i] > 0) nb_host++; - action = xbt_new0(s_surf_action_workstation_L07_t, 1); - DEBUG3("Creating a parallel task (%p) with %d cpus and %d links.", - action, workstation_nb, nb_link); - action->generic_action.refcount = 1; - action->generic_action.cost = amount; - action->generic_action.remains = amount; - action->generic_action.max_duration = NO_MAX_DURATION; - action->generic_action.start = surf_get_clock(); - action->generic_action.finish = -1.0; - action->generic_action.model_type = surf_workstation_model; + action = + surf_action_new(sizeof(s_surf_action_workstation_L07_t), amount, + surf_workstation_model, 0); + DEBUG3("Creating a parallel task (%p) with %d cpus and %d links.", action, + workstation_nb, nb_link); action->suspended = 0; /* Should be useless because of the calloc but it seems to help valgrind... */ action->workstation_nb = workstation_nb; @@ -472,10 +485,6 @@ static surf_action_t execute_parallel_task(int workstation_nb, action->computation_amount = computation_amount; action->communication_amount = communication_amount; action->latency = latency; - action->generic_action.state_set = - surf_workstation_model->states.running_action_set; - - xbt_swag_insert(action, action->generic_action.state_set); action->rate = rate; action->variable = @@ -500,7 +509,7 @@ static surf_action_t execute_parallel_task(int workstation_nb, if (communication_amount[i * workstation_nb + j] == 0.0) continue; - xbt_dynar_foreach(route,cpt,link) { + xbt_dynar_foreach(route, cpt, link) { lmm_expand_add(ptask_maxmin_system, link->constraint, action->variable, communication_amount[i * workstation_nb + j]); @@ -553,7 +562,7 @@ static surf_action_t action_sleep(void *cpu, double duration) { surf_action_workstation_L07_t action = NULL; - XBT_IN2("(%s,%g)", ((cpu_L07_t) cpu)->generic_resource.name, duration); + XBT_IN2("(%s,%g)", surf_resource_name(cpu), duration); action = (surf_action_workstation_L07_t) execute(cpu, 1.0); action->generic_action.max_duration = duration; @@ -594,7 +603,7 @@ static int link_shared(const void *link) static cpu_L07_t cpu_new(const char *name, double power_scale, double power_initial, tmgr_trace_t power_trace, - e_surf_cpu_state_t state_initial, + e_surf_resource_state_t state_initial, tmgr_trace_t state_trace, xbt_dict_t cpu_properties) { cpu_L07_t cpu = xbt_new0(s_cpu_L07_t, 1); @@ -635,21 +644,21 @@ static void parse_cpu_init(void) double power_scale = 0.0; double power_initial = 0.0; tmgr_trace_t power_trace = NULL; - e_surf_cpu_state_t state_initial = SURF_CPU_OFF; + e_surf_resource_state_t state_initial = SURF_RESOURCE_OFF; tmgr_trace_t state_trace = NULL; power_scale = get_cpu_power(A_surfxml_host_power); surf_parse_get_double(&power_initial, A_surfxml_host_availability); - surf_parse_get_trace(&power_trace, A_surfxml_host_availability_file); + power_trace = tmgr_trace_new(A_surfxml_host_availability_file); xbt_assert0((A_surfxml_host_state == A_surfxml_host_state_ON) || (A_surfxml_host_state == A_surfxml_host_state_OFF), "Invalid state"); if (A_surfxml_host_state == A_surfxml_host_state_ON) - state_initial = SURF_CPU_ON; + state_initial = SURF_RESOURCE_ON; if (A_surfxml_host_state == A_surfxml_host_state_OFF) - state_initial = SURF_CPU_OFF; - surf_parse_get_trace(&state_trace, A_surfxml_host_state_file); + state_initial = SURF_RESOURCE_OFF; + state_trace = tmgr_trace_new(A_surfxml_host_state_file); current_property_set = xbt_dict_new(); cpu_new(A_surfxml_host_id, power_scale, power_initial, power_trace, @@ -661,7 +670,7 @@ static link_L07_t link_new(char *name, tmgr_trace_t bw_trace, double lat_initial, tmgr_trace_t lat_trace, - e_surf_link_state_t + e_surf_resource_state_t state_initial, tmgr_trace_t state_trace, e_surf_link_sharing_policy_t @@ -695,7 +704,8 @@ static link_L07_t link_new(char *name, lmm_constraint_shared(nw_link->constraint); - xbt_dict_set(surf_network_model->resource_set, name, nw_link, surf_resource_free); + xbt_dict_set(surf_network_model->resource_set, name, nw_link, + surf_resource_free); return nw_link; } @@ -707,23 +717,23 @@ static void parse_link_init(void) tmgr_trace_t bw_trace; double lat_initial; tmgr_trace_t lat_trace; - e_surf_link_state_t state_initial_link = SURF_LINK_ON; + e_surf_resource_state_t state_initial_link = SURF_RESOURCE_ON; e_surf_link_sharing_policy_t policy_initial_link = SURF_LINK_SHARED; tmgr_trace_t state_trace; name_link = xbt_strdup(A_surfxml_link_id); surf_parse_get_double(&bw_initial, A_surfxml_link_bandwidth); - surf_parse_get_trace(&bw_trace, A_surfxml_link_bandwidth_file); + bw_trace = tmgr_trace_new(A_surfxml_link_bandwidth_file); surf_parse_get_double(&lat_initial, A_surfxml_link_latency); - surf_parse_get_trace(&lat_trace, A_surfxml_link_latency_file); + lat_trace = tmgr_trace_new(A_surfxml_link_latency_file); xbt_assert0((A_surfxml_link_state == A_surfxml_link_state_ON) || (A_surfxml_link_state == A_surfxml_link_state_OFF), "Invalid state"); if (A_surfxml_link_state == A_surfxml_link_state_ON) - state_initial_link = SURF_LINK_ON; + state_initial_link = SURF_RESOURCE_ON; else if (A_surfxml_link_state == A_surfxml_link_state_OFF) - state_initial_link = SURF_LINK_OFF; + state_initial_link = SURF_RESOURCE_OFF; if (A_surfxml_link_sharing_policy == A_surfxml_link_sharing_policy_SHARED) policy_initial_link = SURF_LINK_SHARED; @@ -731,7 +741,7 @@ static void parse_link_init(void) A_surfxml_link_sharing_policy_FATPIPE) policy_initial_link = SURF_LINK_FATPIPE; - surf_parse_get_trace(&state_trace, A_surfxml_link_state_file); + state_trace = tmgr_trace_new(A_surfxml_link_state_file); current_property_set = xbt_dict_new(); link_new(name_link, bw_initial, bw_trace, lat_initial, lat_trace, @@ -771,7 +781,8 @@ static void add_traces(void) /* 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(surf_network_model->resource_set, elm); + link_L07_t link = + xbt_dict_get_or_null(surf_network_model->resource_set, elm); xbt_assert1(link, "Link %s undefined", elm); xbt_assert1(trace, "Trace %s undefined", trace_name); @@ -781,7 +792,8 @@ static void add_traces(void) 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(surf_network_model->resource_set, elm); + link_L07_t link = + xbt_dict_get_or_null(surf_network_model->resource_set, elm); xbt_assert1(link, "Link %s undefined", elm); xbt_assert1(trace, "Trace %s undefined", trace_name); @@ -791,7 +803,8 @@ static void add_traces(void) 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(surf_network_model->resource_set, elm); + link_L07_t link = + xbt_dict_get_or_null(surf_network_model->resource_set, elm); xbt_assert1(link, "Link %s undefined", elm); xbt_assert1(trace, "Trace %s undefined", trace_name); @@ -826,6 +839,7 @@ static void model_init_internal(void) surf_workstation_model->is_suspended = action_is_suspended; surf_workstation_model->set_max_duration = action_set_max_duration; surf_workstation_model->set_priority = action_set_priority; + surf_workstation_model->get_remains = action_get_remains; surf_workstation_model->name = "Workstation ptask_L07"; surf_workstation_model->model_private->resource_used = resource_used; @@ -852,14 +866,18 @@ static void model_init_internal(void) surf_workstation_model->extension.workstation.get_link_latency = get_link_latency; surf_workstation_model->extension.workstation.link_shared = link_shared; + surf_workstation_model->extension.workstation.get_properties = + surf_resource_properties; + if (!ptask_maxmin_system) ptask_maxmin_system = lmm_system_new(); - routing_model_full_create(sizeof(link_L07_t), - link_new(xbt_strdup("__MSG_loopback__"), - 498000000, NULL, 0.000015, NULL, - SURF_LINK_ON, NULL, SURF_LINK_FATPIPE, NULL)); + routing_model_create(sizeof(link_L07_t), + link_new(xbt_strdup("__loopback__"), + 498000000, NULL, 0.000015, NULL, + SURF_RESOURCE_ON, NULL, SURF_LINK_FATPIPE, + NULL)); }