X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f7f7d40b071a8c28f2582c39bf599e32802580eb..2b02a57e5d484b2be62c0d4b88e83fed748127f3:/src/surf/workstation_ptask_L07.c diff --git a/src/surf/workstation_ptask_L07.c b/src/surf/workstation_ptask_L07.c index 214f0333d6..425a720c78 100644 --- a/src/surf/workstation_ptask_L07.c +++ b/src/surf/workstation_ptask_L07.c @@ -20,13 +20,12 @@ typedef enum { /**************************************/ typedef struct cpu_L07 { s_surf_resource_t generic_resource; /* Do not move this field: must match surf_resource_t */ - xbt_dict_t properties; /* Do not move this field: must match link_L07_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; @@ -37,14 +36,13 @@ typedef struct cpu_L07 { typedef struct link_L07 { s_surf_resource_t generic_resource; /* Do not move this field: must match surf_resource_t */ - xbt_dict_t properties; /* Do not move this field: must match link_L07_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; @@ -113,12 +111,6 @@ static void update_action_bound(surf_action_workstation_L07_t action) /******* Resource Public **********/ /**************************************/ -static xbt_dict_t get_properties(void *r) -{ - /* We can freely cast as a cpu_L07_t since it has the same prefix than link_L07_t */ - return ((cpu_L07_t) r)->properties; -} - static int action_unref(surf_action_t action) { action->refcount--; @@ -306,10 +298,10 @@ 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, @@ -330,7 +322,7 @@ 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, @@ -351,25 +343,25 @@ static void update_resource_state(void *id, } 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; } 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); } 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; } else { CRITICAL0("Unknown event ! \n"); xbt_abort(); @@ -383,16 +375,16 @@ static void update_resource_state(void *id, static void finalize(void) { - xbt_dict_free(&link_set); - if (parallel_task_link_set != NULL) { + if (parallel_task_link_set != NULL) xbt_dict_free(¶llel_task_link_set); - } surf_model_exit(surf_workstation_model); surf_workstation_model = NULL; + surf_model_exit(surf_network_model); + 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); @@ -404,7 +396,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; } @@ -463,16 +455,9 @@ 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); + 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->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->suspended = 0; /* Should be useless because of the calloc but it seems to help valgrind... */ action->workstation_nb = workstation_nb; @@ -480,10 +465,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 = @@ -561,7 +542,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; @@ -599,16 +580,10 @@ static int link_shared(const void *link) /*** Resource Creation & Destruction **/ /**************************************/ -static void cpu_free(void *cpu) -{ - xbt_dict_free(&(((cpu_L07_t) cpu)->properties)); - surf_resource_free(cpu); -} - 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); @@ -618,6 +593,7 @@ static cpu_L07_t cpu_new(const char *name, double power_scale, cpu->generic_resource.model = surf_workstation_model; cpu->type = SURF_WORKSTATION_RESOURCE_CPU; cpu->generic_resource.name = xbt_strdup(name); + cpu->generic_resource.properties = current_property_set; cpu->id = host_count++; cpu->power_scale = power_scale; @@ -637,11 +613,8 @@ static cpu_L07_t cpu_new(const char *name, double power_scale, lmm_constraint_new(ptask_maxmin_system, cpu, cpu->power_current * cpu->power_scale); - /*add the property set */ - cpu->properties = current_property_set; - xbt_dict_set(surf_model_resource_set(surf_workstation_model), name, cpu, - cpu_free); + surf_resource_free); return cpu; } @@ -651,51 +624,46 @@ 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, state_initial, state_trace, current_property_set); } -static void link_free(void *nw_link) -{ - xbt_dict_free(&(((link_L07_t) nw_link)->properties)); - surf_resource_free(nw_link); -} - static link_L07_t link_new(char *name, double bw_initial, 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 policy, xbt_dict_t properties) { link_L07_t nw_link = xbt_new0(s_link_L07_t, 1); - xbt_assert1(!xbt_dict_get_or_null(link_set, name), + xbt_assert1(!xbt_dict_get_or_null(surf_network_model->resource_set, name), "Link '%s' declared several times in the platform file.", name); nw_link->generic_resource.model = surf_workstation_model; - nw_link->type = SURF_WORKSTATION_RESOURCE_LINK; + nw_link->generic_resource.properties = properties; nw_link->generic_resource.name = name; + nw_link->type = SURF_WORKSTATION_RESOURCE_LINK; nw_link->bw_current = bw_initial; if (bw_trace) nw_link->bw_event = @@ -715,9 +683,8 @@ static link_L07_t link_new(char *name, if (policy == SURF_LINK_FATPIPE) lmm_constraint_shared(nw_link->constraint); - nw_link->properties = properties; - xbt_dict_set(link_set, name, nw_link, link_free); + xbt_dict_set(surf_network_model->resource_set, name, nw_link, surf_resource_free); return nw_link; } @@ -729,23 +696,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; @@ -753,7 +720,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, @@ -793,7 +760,7 @@ 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(link_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); @@ -803,7 +770,7 @@ 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(link_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); @@ -813,7 +780,7 @@ 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(link_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); @@ -874,18 +841,16 @@ 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; - surf_workstation_model->get_properties = get_properties; - - link_set = xbt_dict_new(); if (!ptask_maxmin_system) ptask_maxmin_system = lmm_system_new(); - routing_model_full_create(sizeof(link_L07_t), - link_new(xbt_strdup("__MSG_loopback__"), + routing_model_create(sizeof(link_L07_t), + link_new(xbt_strdup("__loopback__"), 498000000, NULL, 0.000015, NULL, - SURF_LINK_ON, NULL, SURF_LINK_FATPIPE, NULL)); + SURF_RESOURCE_ON, NULL, SURF_LINK_FATPIPE, NULL)); } @@ -896,6 +861,7 @@ void surf_workstation_model_init_ptask_L07(const char *filename) { xbt_assert0(!surf_cpu_model, "CPU model type already defined"); xbt_assert0(!surf_network_model, "network model type already defined"); + surf_network_model = surf_model_init(); define_callbacks(filename); model_init_internal();