From 5a00c16b5ea7fd8c37f39544914acfcb0f6e07b2 Mon Sep 17 00:00:00 2001 From: alegrand Date: Mon, 30 Jul 2007 19:48:10 +0000 Subject: [PATCH] * Moving things around (private->public) * Adding a workstation_compound model * Getting rid of useless and GTNets-specific dead code git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@3917 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/include/surf/surf.h | 25 ++- src/surf/network_gtnets_private.h | 4 - src/surf/workstation.c | 285 +++--------------------------- 3 files changed, 46 insertions(+), 268 deletions(-) diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 6dfd902889..840cd70383 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -266,12 +266,25 @@ XBT_PUBLIC_DATA(surf_network_resource_t) surf_network_resource; * \param filename XML platform file name * * This function is called by surf_workstation_resource_init_CLM03 - * so you shouldn't call it by yourself. + * or by yourself only if you plan using surf_workstation_resource_init_compound * * \see surf_workstation_resource_init_CLM03() */ XBT_PUBLIC(void) surf_network_resource_init_CM02(const char *filename); +#ifdef USE_GTNETS +/** \brief Initializes the platform with the network model GTNETS + * \ingroup SURF_resources + * \param filename XML platform file name + * + * This function is called by surf_workstation_resource_init_GTNETS + * or by yourself only if you plan using surf_workstation_resource_init_compound + * + * \see surf_workstation_resource_init_GTNETS() + */ +XBT_PUBLIC(void) surf_network_resource_init_GTNETS(const char *filename); +#endif + /** \brief Workstation resource extension public * \ingroup SURF_resources * @@ -321,6 +334,16 @@ typedef struct surf_workstation_resource { */ XBT_PUBLIC_DATA(surf_workstation_resource_t) surf_workstation_resource; +/** \brief Initializes the platform with a compound workstation model + * \ingroup SURF_resources + * \param filename XML platform file name + * + * This function should be called after a cpu_resource and a + * network_resource have been set up. + * + */ +XBT_PUBLIC(void) surf_workstation_resource_init_compound(const char *filename); + /** \brief Initializes the platform with the workstation model CLM03 * \ingroup SURF_resources * \param filename XML platform file name diff --git a/src/surf/network_gtnets_private.h b/src/surf/network_gtnets_private.h index 0a20d4c624..fa6bdce867 100644 --- a/src/surf/network_gtnets_private.h +++ b/src/surf/network_gtnets_private.h @@ -41,10 +41,6 @@ typedef struct surf_action_network_GTNETS { extern xbt_dict_t network_card_set; -/* HC: I put this prototype here for now but it will have to go in - src/include/surf.h when it is functionnal. */ -void surf_network_resource_init_GTNETS(const char *filename); - #endif /* _SURF_NETWORK_PRIVATE_H */ diff --git a/src/surf/workstation.c b/src/surf/workstation.c index d16860c062..a552aa13fb 100644 --- a/src/surf/workstation.c +++ b/src/surf/workstation.c @@ -12,10 +12,6 @@ #include "cpu_private.h" #include "network_private.h" -#ifdef USE_GTNETS -#include "network_gtnets_private.h" -#endif - surf_workstation_resource_t surf_workstation_resource = NULL; xbt_dict_t workstation_set = NULL; static xbt_dict_t parallel_task_network_link_set = NULL; @@ -210,69 +206,6 @@ static void update_actions_state(double now, double delta) return; } -#ifdef USE_GTNETS -/* KF. For GTNetS. This is the same as surf_actions_state_gtnets except for - the network resource update. -*/ -static void update_actions_state_gtnets(double now, double delta) -{ - surf_action_parallel_task_CSL05_t action = NULL; - surf_action_parallel_task_CSL05_t next_action = NULL; - xbt_swag_t running_actions = - surf_workstation_resource->common_public->states.running_action_set; - /* FIXME: unused - xbt_swag_t failed_actions = - surf_workstation_resource->common_public->states.failed_action_set; - */ - - xbt_swag_foreach_safe(action, next_action, running_actions) { - double_update(&(action->generic_action.remains), - lmm_variable_getvalue(action->variable) * delta); - if (action->generic_action.max_duration != NO_MAX_DURATION) - double_update(&(action->generic_action.max_duration), delta); - if ((action->generic_action.remains <= 0) && - (lmm_get_variable_weight(action->variable)>0)) { - action->generic_action.finish = surf_get_clock(); - action_change_state((surf_action_t) action, SURF_ACTION_DONE); - } else if ((action->generic_action.max_duration != NO_MAX_DURATION) && - (action->generic_action.max_duration <= 0)) { - action->generic_action.finish = surf_get_clock(); - action_change_state((surf_action_t) action, SURF_ACTION_DONE); - } else { /* Need to check that none of the resource has failed */ - lmm_constraint_t cnst = NULL; - int i = 0; - surf_resource_t resource = NULL; - - while ((cnst = - lmm_get_cnst_from_var(maxmin_system, action->variable, - i++))) { - resource = (surf_resource_t) lmm_constraint_id(cnst); - if(resource== (surf_resource_t) surf_cpu_resource) { - cpu_Cas01_t cpu = lmm_constraint_id(cnst); - if (cpu->state_current == SURF_CPU_OFF) { - action->generic_action.finish = surf_get_clock(); - action_change_state((surf_action_t) action, SURF_ACTION_FAILED); - break; - } - } else if (resource== (surf_resource_t) surf_network_resource) { - /** - network_link_GTNETS_t nw_link = lmm_constraint_id(cnst); - - if (nw_link->state_current == SURF_NETWORK_LINK_OFF) { - action->generic_action.finish = surf_get_clock(); - action_change_state((surf_action_t) action, SURF_ACTION_FAILED); - break; - } - **/ - } - } - } - } - - return; -} -#endif - static void update_resource_state(void *id, tmgr_trace_event_t event_type, double value) @@ -364,107 +297,23 @@ static double get_available_speed(void *workstation) get_available_speed(((workstation_CLM03_t) workstation)->cpu); } -static surf_action_t execute_parallel_task (int workstation_nb, +static surf_action_t execute_parallel_task_bogus (int workstation_nb, void **workstation_list, double *computation_amount, double *communication_amount, double amount, double rate) { - surf_action_parallel_task_CSL05_t action = NULL; - int i, j, k; - int nb_link = 0; - int nb_host = 0; - - if (parallel_task_network_link_set == NULL) { - parallel_task_network_link_set = xbt_dict_new_ext(workstation_nb * workstation_nb * 10); - } - - /* Compute the number of affected resources... */ - for(i=0; i< workstation_nb; i++) { - for(j=0; j< workstation_nb; j++) { - network_card_CM02_t card_src = ((workstation_CLM03_t*)workstation_list)[i]->network_card; - network_card_CM02_t card_dst = ((workstation_CLM03_t*)workstation_list)[j]->network_card; - int route_size = ROUTE_SIZE(card_src->id, card_dst->id); - network_link_CM02_t *route = ROUTE(card_src->id, card_dst->id); - - if(communication_amount[i*workstation_nb+j]>0) - for(k=0; k< route_size; k++) { - xbt_dict_set(parallel_task_network_link_set, route[k]->name, route[k], NULL); - } - } - } - - nb_link = xbt_dict_length(parallel_task_network_link_set); - xbt_dict_reset(parallel_task_network_link_set); - - for (i = 0; i0) nb_host++; - - if(nb_link + workstation_nb == 0) - return NULL; - - action = xbt_new0(s_surf_action_parallel_task_CSL05_t, 1); - action->generic_action.using = 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.resource_type = - (surf_resource_t) surf_workstation_resource; - action->suspended = 0; /* Should be useless because of the - calloc but it seems to help valgrind... */ - action->generic_action.state_set = - surf_workstation_resource->common_public->states.running_action_set; - - xbt_swag_insert(action, action->generic_action.state_set); - action->rate = rate; - - if(action->rate>0) - action->variable = lmm_variable_new(maxmin_system, action, 1.0, -1.0, - nb_host + nb_link); - else - action->variable = lmm_variable_new(maxmin_system, action, 1.0, action->rate, - nb_host + nb_link); - - for (i = 0; i0) - lmm_expand(maxmin_system, ((cpu_Cas01_t) ((workstation_CLM03_t) workstation_list[i])->cpu)->constraint, - action->variable, computation_amount[i]); - - for (i=0; inetwork_card; - network_card_CM02_t card_dst = ((workstation_CLM03_t*)workstation_list)[j]->network_card; - int route_size = ROUTE_SIZE(card_src->id, card_dst->id); - network_link_CM02_t *route = ROUTE(card_src->id, card_dst->id); - - for(k=0; k< route_size; k++) { - if(communication_amount[i*workstation_nb+j]>0) { - lmm_expand_add(maxmin_system, route[k]->constraint, - action->variable, communication_amount[i*workstation_nb+j]); - } - } - } - } - - return (surf_action_t) action; + DIE_IMPOSSIBLE; } -#ifdef USE_GTNETS -/* KF. We don't support this for GTNetS. -*/ -static surf_action_t execute_parallel_task_gtnets (int workstation_nb, +static surf_action_t execute_parallel_task (int workstation_nb, void **workstation_list, double *computation_amount, double *communication_amount, double amount, double rate) { - xbt_assert0(0,"Cannot execute parallel task"); - return 0; -#if 0 surf_action_parallel_task_CSL05_t action = NULL; int i, j, k; int nb_link = 0; @@ -474,12 +323,13 @@ static surf_action_t execute_parallel_task_gtnets (int workstation_nb, parallel_task_network_link_set = xbt_dict_new_ext(workstation_nb * workstation_nb * 10); } + /* Compute the number of affected resources... */ for(i=0; i< workstation_nb; i++) { for(j=0; j< workstation_nb; j++) { - network_card_GTNETS_t card_src = ((workstation_CLM03_t*)workstation_list)[i]->network_card; - network_card_GTNETS_t card_dst = ((workstation_CLM03_t*)workstation_list)[j]->network_card; + network_card_CM02_t card_src = ((workstation_CLM03_t*)workstation_list)[i]->network_card; + network_card_CM02_t card_dst = ((workstation_CLM03_t*)workstation_list)[j]->network_card; int route_size = ROUTE_SIZE(card_src->id, card_dst->id); - network_link_GTNETS_t *route = ROUTE(card_src->id, card_dst->id); + network_link_CM02_t *route = ROUTE(card_src->id, card_dst->id); if(communication_amount[i*workstation_nb+j]>0) for(k=0; k< route_size; k++) { @@ -528,10 +378,10 @@ static surf_action_t execute_parallel_task_gtnets (int workstation_nb, for (i=0; inetwork_card; - network_card_GTNETS_t card_dst = ((workstation_CLM03_t*)workstation_list)[j]->network_card; + network_card_CM02_t card_src = ((workstation_CLM03_t*)workstation_list)[i]->network_card; + network_card_CM02_t card_dst = ((workstation_CLM03_t*)workstation_list)[j]->network_card; int route_size = ROUTE_SIZE(card_src->id, card_dst->id); - network_link_GTNETS_t *route = ROUTE(card_src->id, card_dst->id); + network_link_CM02_t *route = ROUTE(card_src->id, card_dst->id); for(k=0; k< route_size; k++) { if(communication_amount[i*workstation_nb+j]>0) { @@ -543,9 +393,7 @@ static surf_action_t execute_parallel_task_gtnets (int workstation_nb, } return (surf_action_t) action; -#endif } -#endif /* returns an array of network_link_CM02_t */ static const void** get_route(void *src, void *dst) { @@ -654,7 +502,7 @@ static void surf_workstation_resource_init_internal(void) surf_workstation_resource->extension_public->get_available_speed = get_available_speed; surf_workstation_resource->extension_public->communicate = communicate; surf_workstation_resource->extension_public->execute_parallel_task = - execute_parallel_task; + execute_parallel_task_bogus; surf_workstation_resource->extension_public->get_route = get_route; surf_workstation_resource->extension_public->get_route_size = get_route_size; surf_workstation_resource->extension_public->get_link_name = get_link_name; @@ -665,90 +513,6 @@ static void surf_workstation_resource_init_internal(void) xbt_assert0(maxmin_system, "surf_init has to be called first!"); } -#ifdef USE_GTNETS -/* KF. For GTNetS. This is the same as surf_workstation_resource_init_internal - except for - - surf_workstation_resource->common_private->update_actions_state = - update_actions_state_gtnets; - - surf_workstation_resource->extension_public->execute_parallel_task = - execute_parallel_task_gtnets; -*/ -static void surf_workstation_resource_init_internal_gtnets(void) -{ - s_surf_action_t action; - - surf_workstation_resource = xbt_new0(s_surf_workstation_resource_t, 1); - - surf_workstation_resource->common_private = - xbt_new0(s_surf_resource_private_t, 1); - surf_workstation_resource->common_public = - xbt_new0(s_surf_resource_public_t, 1); -/* surf_workstation_resource->extension_private = xbt_new0(s_surf_workstation_resource_extension_private_t,1); */ - surf_workstation_resource->extension_public = - xbt_new0(s_surf_workstation_resource_extension_public_t, 1); - - surf_workstation_resource->common_public->states.ready_action_set = - xbt_swag_new(xbt_swag_offset(action, state_hookup)); - surf_workstation_resource->common_public->states.running_action_set = - xbt_swag_new(xbt_swag_offset(action, state_hookup)); - surf_workstation_resource->common_public->states.failed_action_set = - xbt_swag_new(xbt_swag_offset(action, state_hookup)); - surf_workstation_resource->common_public->states.done_action_set = - xbt_swag_new(xbt_swag_offset(action, state_hookup)); - - surf_workstation_resource->common_public->name_service = name_service; - surf_workstation_resource->common_public->get_resource_name = - get_resource_name; - surf_workstation_resource->common_public->action_get_state = - surf_action_get_state; - surf_workstation_resource->common_public->action_get_start_time = - surf_action_get_start_time; - surf_workstation_resource->common_public->action_get_finish_time = - surf_action_get_finish_time; - surf_workstation_resource->common_public->action_free = action_free; - surf_workstation_resource->common_public->action_use = action_use; - surf_workstation_resource->common_public->action_cancel = action_cancel; - surf_workstation_resource->common_public->action_recycle = - action_recycle; - surf_workstation_resource->common_public->action_change_state = - action_change_state; - surf_workstation_resource->common_public->action_set_data = surf_action_set_data; - surf_workstation_resource->common_public->name = "Workstation"; - - surf_workstation_resource->common_private->resource_used = resource_used; - surf_workstation_resource->common_private->share_resources = - share_resources; - surf_workstation_resource->common_private->update_actions_state = - update_actions_state_gtnets; - surf_workstation_resource->common_private->update_resource_state = - update_resource_state; - surf_workstation_resource->common_private->finalize = finalize; - - surf_workstation_resource->common_public->suspend = action_suspend; - surf_workstation_resource->common_public->resume = action_resume; - surf_workstation_resource->common_public->is_suspended = action_is_suspended; - surf_workstation_resource->common_public->set_max_duration = action_set_max_duration; - surf_workstation_resource->common_public->set_priority = action_set_priority; - - surf_workstation_resource->extension_public->execute = execute; - surf_workstation_resource->extension_public->sleep = action_sleep; - surf_workstation_resource->extension_public->get_state = get_state; - surf_workstation_resource->extension_public->get_speed = get_speed; - surf_workstation_resource->extension_public->get_available_speed = get_available_speed; - surf_workstation_resource->extension_public->communicate = communicate; - surf_workstation_resource->extension_public->execute_parallel_task = - execute_parallel_task_gtnets; - surf_workstation_resource->extension_public->get_route = get_route; - surf_workstation_resource->extension_public->get_route_size = get_route_size; - surf_workstation_resource->extension_public->get_link_name = get_link_name; - surf_workstation_resource->extension_public->get_link_bandwidth = get_link_bandwidth; - surf_workstation_resource->extension_public->get_link_latency = get_link_latency; - workstation_set = xbt_dict_new(); - - xbt_assert0(maxmin_system, "surf_init has to be called first!"); -} -#endif - /********************************************************************/ /* The model used in MSG and presented at CCGrid03 */ /********************************************************************/ @@ -762,36 +526,31 @@ static void surf_workstation_resource_init_internal_gtnets(void) /* } */ void surf_workstation_resource_init_CLM03(const char *filename) { -/* int i ; */ -/* surf_resource_t resource = NULL; */ - surf_workstation_resource_init_internal(); surf_cpu_resource_init_Cas01(filename); surf_network_resource_init_CM02(filename); create_workstations(); xbt_dynar_push(resource_list, &surf_workstation_resource); -/* xbt_dynar_foreach(resource_list, i, resource) { */ -/* if(resource==surf_cpu_resource) { */ -/* xbt_dynar_remove_at(resource_list, i, NULL); */ -/* i--; */ -/* continue; */ -/* } */ -/* if(resource==surf_network_resource) { */ -/* xbt_dynar_remove_at(resource_list, i, NULL); */ -/* i--; */ -/* continue; */ -/* } */ -/* } */ } #ifdef USE_GTNETS /* KF. Use GTNetS for the network. */ void surf_workstation_resource_init_GTNETS(const char *filename) { - surf_workstation_resource_init_internal_gtnets(); + surf_workstation_resource_init_internal(); surf_cpu_resource_init_Cas01(filename); surf_network_resource_init_GTNETS(filename); create_workstations(); xbt_dynar_push(resource_list, &surf_workstation_resource); } #endif + +void surf_workstation_resource_init_compound(const char *filename) +{ + + xbt_assert0(surf_cpu_resource,"No CPU resource defined yet!"); + xbt_assert0(surf_network_resource,"No network resource defined yet!"); + surf_workstation_resource_init_internal(); + create_workstations(); + xbt_dynar_push(resource_list, &surf_workstation_resource); +} -- 2.20.1