#include "network_private.h"
#include "xbt/log.h"
+#include "xbt/str.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network, surf,
"Logging specific to the SURF network module");
-surf_network_resource_t surf_network_resource = NULL;
-
-xbt_dict_t network_link_set = NULL;
+surf_network_model_t surf_network_model = NULL;
+static lmm_system_t network_maxmin_system = NULL;
+static void (*network_solve) (lmm_system_t) = NULL;
+xbt_dict_t link_set = NULL;
xbt_dict_t network_card_set = NULL;
+double latency_factor = 1.0; /* default value */
+double bandwidth_factor = 1.0; /* default value */
+
int card_number = 0;
-network_link_CM02_t **routing_table = NULL;
+int host_number = 0;
+link_CM02_t **routing_table = NULL;
int *routing_table_size = NULL;
-static network_link_CM02_t loopback = NULL;
+static link_CM02_t loopback = NULL;
static void create_routing_table(void)
{
- routing_table = xbt_new0(network_link_CM02_t *, card_number * card_number);
- routing_table_size = xbt_new0(int, card_number * card_number);
+ routing_table =
+ xbt_new0(link_CM02_t *, /*card_number * card_number */ host_number * host_number);
+ routing_table_size = xbt_new0(int, /*card_number * card_number*/ host_number * host_number);
}
-static void network_link_free(void *nw_link)
+static void link_free(void *nw_link)
{
- free(((network_link_CM02_t)nw_link)->name);
+ free(((link_CM02_t) nw_link)->name);
+ xbt_dict_free(&(((link_CM02_t)nw_link)->properties));
free(nw_link);
}
-static network_link_CM02_t network_link_new(char *name,
- double bw_initial,
- tmgr_trace_t bw_trace,
- double lat_initial,
- tmgr_trace_t lat_trace,
- e_surf_network_link_state_t
- state_initial,
- tmgr_trace_t state_trace,
- e_surf_network_link_sharing_policy_t policy)
+static link_CM02_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
+ state_initial,
+ tmgr_trace_t state_trace,
+ e_surf_link_sharing_policy_t
+ policy, xbt_dict_t properties)
{
- network_link_CM02_t nw_link = xbt_new0(s_network_link_CM02_t, 1);
+ link_CM02_t nw_link = xbt_new0(s_link_CM02_t, 1);
+ xbt_assert1(!xbt_dict_get_or_null(link_set, name),
+ "Link '%s' declared several times in the platform file.", name);
-
- nw_link->resource = (surf_resource_t) surf_network_resource;
+ nw_link->model = (surf_model_t) surf_network_model;
nw_link->name = name;
nw_link->bw_current = bw_initial;
if (bw_trace)
tmgr_history_add_trace(history, state_trace, 0.0, 0, nw_link);
nw_link->constraint =
- lmm_constraint_new(maxmin_system, nw_link, nw_link->bw_current);
+ lmm_constraint_new(network_maxmin_system, nw_link,
+ bandwidth_factor*nw_link->bw_current);
- if(policy == SURF_NETWORK_LINK_FATPIPE)
+ if (policy == SURF_LINK_FATPIPE)
lmm_constraint_shared(nw_link->constraint);
- xbt_dict_set(network_link_set, name, nw_link, network_link_free);
+ nw_link->properties = properties;
+
+ current_property_set = properties;
+
+ xbt_dict_set(link_set, name, nw_link, link_free);
return nw_link;
}
static void network_card_free(void *nw_card)
{
- free(((network_card_CM02_t)nw_card)->name);
+ free(((network_card_CM02_t) nw_card)->name);
free(nw_card);
}
static int network_card_new(const char *card_name)
{
- network_card_CM02_t card = xbt_dict_get_or_null(network_card_set, card_name);
+ network_card_CM02_t card =
+ xbt_dict_get_or_null(network_card_set, card_name);
if (!card) {
card = xbt_new0(s_network_card_CM02_t, 1);
card->name = xbt_strdup(card_name);
- card->id = card_number++;
+ card->id = host_number++;
xbt_dict_set(network_card_set, card_name, card, network_card_free);
}
return card->id;
}
-static void route_new(int src_id, int dst_id, char **links, int nb_link)
+static void route_new(int src_id, int dst_id,
+ link_CM02_t * link_list, int nb_link)
{
- network_link_CM02_t *link_list = NULL;
- int i;
-
ROUTE_SIZE(src_id, dst_id) = nb_link;
- link_list = (ROUTE(src_id, dst_id) = xbt_new0(network_link_CM02_t, nb_link));
- for (i = 0; i < nb_link; i++) {
- link_list[i] = xbt_dict_get_or_null(network_link_set, links[i]);
- xbt_assert1(link_list[i],"Invalid link name \"%s\"",links[i]);
- free(links[i]);
- }
- free(links);
+ ROUTE(src_id, dst_id) = link_list =
+ xbt_realloc(link_list, sizeof(link_CM02_t) * nb_link);
}
-static void parse_network_link(void)
+static void parse_link_init(void)
{
- char *name;
+ char *name_link;
double bw_initial;
tmgr_trace_t bw_trace;
double lat_initial;
tmgr_trace_t lat_trace;
- e_surf_network_link_state_t state_initial = SURF_NETWORK_LINK_ON;
- e_surf_network_link_sharing_policy_t policy_initial = SURF_NETWORK_LINK_SHARED;
+ e_surf_link_state_t state_initial_link = SURF_LINK_ON;
+ e_surf_link_sharing_policy_t policy_initial_link = SURF_LINK_SHARED;
tmgr_trace_t state_trace;
- name = xbt_strdup(A_surfxml_network_link_name);
- surf_parse_get_double(&bw_initial,A_surfxml_network_link_bandwidth);
- surf_parse_get_trace(&bw_trace, A_surfxml_network_link_bandwidth_file);
- surf_parse_get_double(&lat_initial,A_surfxml_network_link_latency);
- surf_parse_get_trace(&lat_trace, A_surfxml_network_link_latency_file);
-
- xbt_assert0((A_surfxml_network_link_state==A_surfxml_network_link_state_ON)||
- (A_surfxml_network_link_state==A_surfxml_network_link_state_OFF),
- "Invalid state");
- if (A_surfxml_network_link_state==A_surfxml_network_link_state_ON)
- state_initial = SURF_NETWORK_LINK_ON;
- else if (A_surfxml_network_link_state==A_surfxml_network_link_state_OFF)
- state_initial = SURF_NETWORK_LINK_OFF;
+ 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);
+ surf_parse_get_double(&lat_initial, A_surfxml_link_latency);
+ surf_parse_get_trace(&lat_trace, 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;
+ else if (A_surfxml_link_state ==
+ A_surfxml_link_state_OFF)
+ state_initial_link = SURF_LINK_OFF;
+
+ if (A_surfxml_link_sharing_policy ==
+ A_surfxml_link_sharing_policy_SHARED)
+ policy_initial_link = SURF_LINK_SHARED;
+ else if (A_surfxml_link_sharing_policy ==
+ A_surfxml_link_sharing_policy_FATPIPE)
+ policy_initial_link = SURF_LINK_FATPIPE;
+
+ surf_parse_get_trace(&state_trace, A_surfxml_link_state_file);
+
+ link_new(name_link, bw_initial, bw_trace,
+ lat_initial, lat_trace, state_initial_link, state_trace,
+ policy_initial_link, xbt_dict_new());
- if (A_surfxml_network_link_sharing_policy==A_surfxml_network_link_sharing_policy_SHARED)
- policy_initial = SURF_NETWORK_LINK_SHARED;
- else if (A_surfxml_network_link_sharing_policy==A_surfxml_network_link_sharing_policy_FATPIPE)
- policy_initial = SURF_NETWORK_LINK_FATPIPE;
-
- surf_parse_get_trace(&state_trace,A_surfxml_network_link_state_file);
-
- network_link_new(name, bw_initial, bw_trace,
- lat_initial, lat_trace, state_initial, state_trace,
- policy_initial);
}
-static int nb_link = 0;
-static char **link_name = NULL;
static int src_id = -1;
static int dst_id = -1;
{
src_id = network_card_new(A_surfxml_route_src);
dst_id = network_card_new(A_surfxml_route_dst);
- nb_link = 0;
- link_name = NULL;
+ route_action = A_surfxml_route_action;
}
-static void parse_route_elem(void)
+static void parse_route_set_route(void)
{
- nb_link++;
- link_name = xbt_realloc(link_name, (nb_link) * sizeof(char *));
- link_name[(nb_link) - 1] = xbt_strdup(A_surfxml_route_element_name);
+ 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);
+ }
}
-static void parse_route_set_route(void)
+static void add_loopback(void)
{
- route_new(src_id, dst_id, link_name, nb_link);
+ int i;
+ /* Adding loopback if needed */
+ for (i = 0; i < host_number; i++)
+ if (!ROUTE_SIZE(i, i)) {
+ if (!loopback)
+ loopback = link_new(xbt_strdup("__MSG_loopback__"),
+ 498000000, NULL, 0.000015, NULL,
+ SURF_LINK_ON, NULL,
+ SURF_LINK_FATPIPE,NULL);
+ ROUTE_SIZE(i, i) = 1;
+ ROUTE(i, i) = xbt_new0(link_CM02_t, 1);
+ ROUTE(i, i)[0] = loopback;
+ }
}
-static void parse_file(const char *file)
+static void add_route(void)
{
- int i;
+ xbt_ex_t e;
+ int nb_link = 0;
+ unsigned int cpt = 0;
+ int link_list_capacity = 0;
+ link_CM02_t *link_list = NULL;
+ xbt_dict_cursor_t cursor = NULL;
+ char *key,*data, *end;
+ const char *sep = "#";
+ xbt_dynar_t links, keys;
+
+ if (routing_table == NULL) create_routing_table();
+
+ xbt_dict_foreach(route_table, cursor, key, data) {
+ char* link = NULL;
+ nb_link = 0;
+ links = (xbt_dynar_t)data;
+ keys = xbt_str_split_str(key, sep);
+
+ link_list_capacity = xbt_dynar_length(links);
+ link_list = xbt_new(link_CM02_t, link_list_capacity);
+
+ src_id = strtol(xbt_dynar_get_as(keys, 0, char*), &end, 16);
+ dst_id = strtol(xbt_dynar_get_as(keys, 1, char*), &end, 16);
+ xbt_dynar_free(&keys);
+
+ xbt_dynar_foreach (links, cpt, link) {
+ TRY {
+ link_list[nb_link++] = xbt_dict_get(link_set, link);
+ }
+ CATCH(e) {
+ RETHROW1("Link %s not found (dict raised this exception: %s)", link);
+ }
+ }
+ route_new(src_id, dst_id, link_list, nb_link);
+ }
+}
- /* Figuring out the network links */
- surf_parse_reset_parser();
- ETag_surfxml_network_link_fun=parse_network_link;
- surf_parse_open(file);
- xbt_assert1((!surf_parse()),"Parse error in %s",file);
- surf_parse_close();
-
- /* Figuring out the network cards used */
- surf_parse_reset_parser();
- STag_surfxml_route_fun=parse_route_set_endpoints;
- surf_parse_open(file);
- xbt_assert1((!surf_parse()),"Parse error in %s",file);
- surf_parse_close();
-
- create_routing_table();
-
- /* Building the routes */
- surf_parse_reset_parser();
- STag_surfxml_route_fun=parse_route_set_endpoints;
- ETag_surfxml_route_element_fun=parse_route_elem;
- ETag_surfxml_route_fun=parse_route_set_route;
- surf_parse_open(file);
- xbt_assert1((!surf_parse()),"Parse error in %s",file);
- surf_parse_close();
+static void count_hosts(void)
+{
+ host_number++;
+}
- /* Adding loopback if needed */
-
- for (i = 0; i < card_number; i++)
- if(!ROUTE_SIZE(i,i)) {
- if(!loopback)
- loopback = network_link_new(xbt_strdup("__MSG_loopback__"),
- 498.00, NULL, 0.000015, NULL,
- SURF_NETWORK_LINK_ON, NULL,
- SURF_NETWORK_LINK_FATPIPE);
- ROUTE_SIZE(i,i)=1;
- ROUTE(i,i) = xbt_new0(network_link_CM02_t, 1);
- ROUTE(i,i)[0] = loopback;
- }
+
+static void add_traces(void) {
+ xbt_dict_cursor_t cursor=NULL;
+ char *trace_name,*elm;
+
+ static int called = 0;
+ if (called) return;
+ called = 1;
+
+ /* connect all 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_CM02_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_CM02_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_CM02_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);
+ }
+}
+
+static void define_callbacks(const char *file)
+{
+ /* Figuring out the network links */
+ surfxml_add_callback(STag_surfxml_host_cb_list, &count_hosts);
+ surfxml_add_callback(STag_surfxml_link_cb_list, &parse_link_init);
+ surfxml_add_callback(STag_surfxml_route_cb_list, &parse_route_set_endpoints);
+ surfxml_add_callback(ETag_surfxml_route_cb_list, &parse_route_set_route);
+ surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_traces);
+ surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_route);
+ surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_loopback);
}
static void *name_service(const char *name)
static int resource_used(void *resource_id)
{
- return lmm_constraint_used(maxmin_system,
- ((network_link_CM02_t) resource_id)->constraint);
+ return lmm_constraint_used(network_maxmin_system,
+ ((link_CM02_t) resource_id)->
+ constraint);
}
static int action_free(surf_action_t action)
{
- action->using--;
- if(!action->using) {
+ action->refcount --;
+ if (!action->refcount ) {
xbt_swag_remove(action, action->state_set);
- if(((surf_action_network_CM02_t)action)->variable)
- lmm_variable_free(maxmin_system, ((surf_action_network_CM02_t)action)->variable);
+ if (((surf_action_network_CM02_t) action)->variable)
+ lmm_variable_free(network_maxmin_system,
+ ((surf_action_network_CM02_t) action)->variable);
free(action);
return 1;
}
static void action_use(surf_action_t action)
{
- action->using++;
+ action->refcount ++;
}
static void action_cancel(surf_action_t action)
{
/* if((state==SURF_ACTION_DONE) || (state==SURF_ACTION_FAILED)) */
/* if(((surf_action_network_CM02_t)action)->variable) { */
-/* lmm_variable_disable(maxmin_system, ((surf_action_network_CM02_t)action)->variable); */
+/* lmm_variable_disable(network_maxmin_system, ((surf_action_network_CM02_t)action)->variable); */
/* ((surf_action_network_CM02_t)action)->variable = NULL; */
/* } */
{
s_surf_action_network_CM02_t s_action;
surf_action_network_CM02_t action = NULL;
- xbt_swag_t running_actions = surf_network_resource->common_public->states.running_action_set;
- double min = generic_maxmin_share_resources(running_actions,
- xbt_swag_offset(s_action, variable));
+ xbt_swag_t running_actions =
+ surf_network_model->common_public->states.running_action_set;
+ double min;
+
+ min = generic_maxmin_share_resources(running_actions,
+ xbt_swag_offset(s_action,
+ variable),
+ network_maxmin_system,
+ network_solve);
+#define VARIABLE(action) (*((lmm_variable_t*)(((char *) (action)) + xbt_swag_offset(s_action, variable) )))
+
xbt_swag_foreach(action, running_actions) {
- if(action->latency>0) {
- if(min<0) min = action->latency;
- else if (action->latency<min) min = action->latency;
+ if (action->latency > 0) {
+ if (min < 0)
+ min = action->latency;
+ else if (action->latency < min)
+ min = action->latency;
}
}
surf_action_network_CM02_t action = NULL;
surf_action_network_CM02_t next_action = NULL;
xbt_swag_t running_actions =
- surf_network_resource->common_public->states.running_action_set;
+ surf_network_model->common_public->states.running_action_set;
/*
- xbt_swag_t failed_actions =
- surf_network_resource->common_public->states.failed_action_set;
- */
+ xbt_swag_t failed_actions =
+ surf_network_model->common_public->states.failed_action_set;
+ */
xbt_swag_foreach_safe(action, next_action, running_actions) {
deltap = delta;
if (action->latency > 0) {
if (action->latency > deltap) {
- surf_double_update(&(action->latency),deltap);
+ double_update(&(action->latency), deltap);
deltap = 0.0;
} else {
- surf_double_update(&(deltap), action->latency);
+ double_update(&(deltap), action->latency);
action->latency = 0.0;
}
- if ((action->latency == 0.0) && !(action->suspended))
- lmm_update_variable_weight(maxmin_system, action->variable,
- action->lat_current);
+ if ((action->latency == 0.0) && !(action->suspended))
+ lmm_update_variable_weight(network_maxmin_system, action->variable,
+ action->weight);
}
- surf_double_update(&(action->generic_action.remains),
- lmm_variable_getvalue(action->variable) * deltap);
+ double_update(&(action->generic_action.remains),
+ lmm_variable_getvalue(action->variable) * deltap);
if (action->generic_action.max_duration != NO_MAX_DURATION)
- surf_double_update(&(action->generic_action.max_duration), delta);
+ double_update(&(action->generic_action.max_duration), delta);
- /* if(action->generic_action.remains<.00001) action->generic_action.remains=0; */
-
- if ((action->generic_action.remains <= 0) &&
- (lmm_get_variable_weight(action->variable)>0)) {
+ 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;
- network_link_CM02_t nw_link = NULL;
-
- while ((cnst =
- lmm_get_cnst_from_var(maxmin_system, action->variable,
- i++))) {
- 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;
- }
- }
}
}
static void update_resource_state(void *id,
tmgr_trace_event_t event_type,
- double value)
+ double value, double date)
{
- network_link_CM02_t nw_link = id;
+ link_CM02_t nw_link = id;
/* printf("[" "%lg" "] Asking to update network card \"%s\" with value " */
- /* "%lg" " for event %p\n", surf_get_clock(), nw_link->name, */
- /* value, event_type); */
+ /* "%lg" " for event %p\n", surf_get_clock(), nw_link->name, */
+ /* value, event_type); */
if (event_type == nw_link->bw_event) {
nw_link->bw_current = value;
- lmm_update_constraint_bound(maxmin_system, nw_link->constraint,
- nw_link->bw_current);
+ lmm_update_constraint_bound(network_maxmin_system, nw_link->constraint,
+ bandwidth_factor*nw_link->bw_current);
} else if (event_type == nw_link->lat_event) {
double delta = value - nw_link->lat_current;
lmm_variable_t var = NULL;
+ lmm_element_t elem = NULL;
surf_action_network_CM02_t action = NULL;
nw_link->lat_current = value;
- while (lmm_get_var_from_cnst(maxmin_system, nw_link->constraint, &var)) {
+ while ((var= lmm_get_var_from_cnst
+ (network_maxmin_system, nw_link->constraint, &elem))) {
action = lmm_variable_id(var);
action->lat_current += delta;
- if(action->rate<0)
- lmm_update_variable_bound(maxmin_system, action->variable,
- SG_TCP_CTE_GAMMA / (2.0 * action->lat_current));
- else
- lmm_update_variable_bound(maxmin_system, action->variable,
- min(action->rate,SG_TCP_CTE_GAMMA / (2.0 * action->lat_current)));
- if(!(action->suspended))
- lmm_update_variable_weight(maxmin_system, action->variable,
- action->lat_current);
+ action->weight += delta;
+ if (action->rate < 0)
+ lmm_update_variable_bound(network_maxmin_system, action->variable,
+ SG_TCP_CTE_GAMMA / (2.0 *
+ action->
+ lat_current));
+ else
+ lmm_update_variable_bound(network_maxmin_system, action->variable,
+ min(action->rate,
+ SG_TCP_CTE_GAMMA / (2.0 *
+ action->
+ lat_current)));
+ if (!(action->suspended))
+ lmm_update_variable_weight(network_maxmin_system, action->variable,
+ action->weight);
+
}
} else if (event_type == nw_link->state_event) {
if (value > 0)
- nw_link->state_current = SURF_NETWORK_LINK_ON;
- else
- nw_link->state_current = SURF_NETWORK_LINK_OFF;
+ nw_link->state_current = SURF_LINK_ON;
+ else {
+ lmm_constraint_t cnst = nw_link->constraint;
+ lmm_variable_t var = NULL;
+ lmm_element_t elem = NULL;
+
+ nw_link->state_current = SURF_LINK_OFF;
+ while ((var= lmm_get_var_from_cnst
+ (network_maxmin_system, cnst, &elem))) {
+ surf_action_t action = lmm_variable_id(var) ;
+
+ if(surf_action_get_state(action)==SURF_ACTION_RUNNING ||
+ surf_action_get_state(action)==SURF_ACTION_READY) {
+ action->finish = date;
+ action_change_state( action, SURF_ACTION_FAILED);
+ }
+ }
+ }
} else {
CRITICAL0("Unknown event ! \n");
xbt_abort();
return;
}
-static surf_action_t communicate(void *src, void *dst, double size, double rate)
+static surf_action_t communicate(void *src, void *dst, double size,
+ double rate)
{
surf_action_network_CM02_t action = NULL;
+ /* LARGE PLATFORMS HACK:
+ Add a link_CM02_t *link and a int link_nb to network_card_CM02_t. It will represent local links for this node
+ Use the cluster_id for ->id */
network_card_CM02_t card_src = src;
network_card_CM02_t card_dst = dst;
int route_size = ROUTE_SIZE(card_src->id, card_dst->id);
- network_link_CM02_t *route = ROUTE(card_src->id, card_dst->id);
+ link_CM02_t *route = ROUTE(card_src->id, card_dst->id);
+ /* LARGE PLATFORMS HACK:
+ total_route_size = route_size + src->link_nb + dst->nb */
int i;
- XBT_IN4("(%s,%s,%g,%g)",card_src->name,card_dst->name,size,rate);
- xbt_assert2(route_size,"You're trying to send data from %s to %s but there is no connexion between these two cards.", card_src->name, card_dst->name);
+ XBT_IN4("(%s,%s,%g,%g)", card_src->name, card_dst->name, size, rate);
+ /* LARGE PLATFORMS HACK:
+ assert on total_route_size */
+ xbt_assert2(route_size,
+ "You're trying to send data from %s to %s but there is no connexion between these two cards.",
+ card_src->name, card_dst->name);
action = xbt_new0(s_surf_action_network_CM02_t, 1);
- action->generic_action.using = 1;
+ action->generic_action.refcount = 1;
action->generic_action.cost = size;
action->generic_action.remains = size;
action->generic_action.max_duration = NO_MAX_DURATION;
- action->generic_action.start = -1.0;
+ action->generic_action.start = surf_get_clock();
action->generic_action.finish = -1.0;
- action->generic_action.resource_type =
- (surf_resource_t) surf_network_resource;
- action->suspended = 0; /* Should be useless because of the
- calloc but it seems to help valgrind... */
+ action->generic_action.model_type =
+ (surf_model_t) surf_network_model;
+ action->suspended = 0; /* Should be useless because of the
+ calloc but it seems to help valgrind... */
action->generic_action.state_set =
- surf_network_resource->common_public->states.running_action_set;
-
+ surf_network_model->common_public->states.running_action_set;
+ for (i = 0; i < route_size; i++)
+ if(route[i]->state_current == SURF_LINK_OFF) {
+ action->generic_action.state_set =
+ surf_network_model->common_public->states.failed_action_set;
+ break;
+ }
+
xbt_swag_insert(action, action->generic_action.state_set);
action->rate = rate;
action->latency = 0.0;
for (i = 0; i < route_size; i++)
action->latency += route[i]->lat_current;
+ /* LARGE PLATFORMS HACK:
+ Add src->link and dst->link latencies */
action->lat_current = action->latency;
-
- if(action->latency>0)
- action->variable = lmm_variable_new(maxmin_system, action, 0.0, -1.0,
- route_size);
- else
- action->variable = lmm_variable_new(maxmin_system, action, 1.0, -1.0,
- route_size);
-
- if(action->rate<0) {
- if(action->lat_current>0)
- lmm_update_variable_bound(maxmin_system, action->variable,
- SG_TCP_CTE_GAMMA / (2.0 * action->lat_current));
+ action->weight = action->latency;
+ action->latency *= latency_factor;
+
+
+ /* LARGE PLATFORMS HACK:
+ lmm_variable_new(..., total_route_size)*/
+ if (action->latency > 0)
+ action->variable =
+ lmm_variable_new(network_maxmin_system, action, 0.0, -1.0,
+ route_size);
+ else
+ action->variable =
+ lmm_variable_new(network_maxmin_system, action, 1.0, -1.0,
+ route_size);
+
+ if (action->rate < 0) {
+ if (action->lat_current > 0)
+ lmm_update_variable_bound(network_maxmin_system, action->variable,
+ SG_TCP_CTE_GAMMA / (2.0 *
+ action->lat_current));
else
- lmm_update_variable_bound(maxmin_system, action->variable, -1.0);
+ lmm_update_variable_bound(network_maxmin_system, action->variable,
+ -1.0);
} else {
- if(action->lat_current>0)
- lmm_update_variable_bound(maxmin_system, action->variable,
- min(action->rate,SG_TCP_CTE_GAMMA / (2.0 * action->lat_current)));
+ if (action->lat_current > 0)
+ lmm_update_variable_bound(network_maxmin_system, action->variable,
+ min(action->rate,
+ SG_TCP_CTE_GAMMA / (2.0 *
+ action->
+ lat_current)));
else
- lmm_update_variable_bound(maxmin_system, action->variable, action->rate);
+ lmm_update_variable_bound(network_maxmin_system, action->variable,
+ action->rate);
}
for (i = 0; i < route_size; i++)
- lmm_expand(maxmin_system, route[i]->constraint, action->variable, 1.0);
+ lmm_expand(network_maxmin_system, route[i]->constraint,
+ action->variable, 1.0);
+ /* LARGE PLATFORMS HACK:
+ expand also with src->link and dst->link */
+
XBT_OUT;
return (surf_action_t) action;
}
-static const void** get_route(void *src, void *dst) {
- /* TODO */
+/* returns an array of link_CM02_t */
+static const void **get_route(void *src, void *dst)
+{
+ network_card_CM02_t card_src = src;
+ network_card_CM02_t card_dst = dst;
+ return (const void **) ROUTE(card_src->id, card_dst->id);
+}
- return NULL;
+static int get_route_size(void *src, void *dst)
+{
+ network_card_CM02_t card_src = src;
+ network_card_CM02_t card_dst = dst;
+ return ROUTE_SIZE(card_src->id, card_dst->id);
+}
+
+static const char *get_link_name(const void *link)
+{
+ return ((link_CM02_t) link)->name;
+}
+
+static double get_link_bandwidth(const void *link)
+{
+ return ((link_CM02_t) link)->bw_current;
+}
+
+static double get_link_latency(const void *link)
+{
+ return ((link_CM02_t) link)->lat_current;
+}
+
+static int link_shared(const void *link)
+{
+ return lmm_constraint_is_shared(((link_CM02_t) link)->constraint);
+}
+
+static xbt_dict_t get_properties(void *link)
+{
+ return ((link_CM02_t) link)->properties;
}
static void action_suspend(surf_action_t action)
{
((surf_action_network_CM02_t) action)->suspended = 1;
- lmm_update_variable_weight(maxmin_system,
- ((surf_action_network_CM02_t) action)->variable, 0.0);
+ lmm_update_variable_weight(network_maxmin_system,
+ ((surf_action_network_CM02_t) action)->
+ variable, 0.0);
}
static void action_resume(surf_action_t action)
{
- lmm_update_variable_weight(maxmin_system,
- ((surf_action_network_CM02_t) action)->variable,
- ((surf_action_network_CM02_t) action)->lat_current);
- ((surf_action_network_CM02_t) action)->suspended = 0;
+ if (((surf_action_network_CM02_t) action)->suspended) {
+ lmm_update_variable_weight(network_maxmin_system,
+ ((surf_action_network_CM02_t) action)->
+ variable,
+ ((surf_action_network_CM02_t) action)->
+ weight);
+ ((surf_action_network_CM02_t) action)->suspended = 0;
+ }
}
static int action_is_suspended(surf_action_t action)
static void finalize(void)
{
- int i,j;
+ int i, j;
xbt_dict_free(&network_card_set);
- xbt_dict_free(&network_link_set);
- xbt_swag_free(surf_network_resource->common_public->states.
+ xbt_dict_free(&link_set);
+ xbt_swag_free(surf_network_model->common_public->states.
ready_action_set);
- xbt_swag_free(surf_network_resource->common_public->states.
+ xbt_swag_free(surf_network_model->common_public->states.
running_action_set);
- xbt_swag_free(surf_network_resource->common_public->states.
+ xbt_swag_free(surf_network_model->common_public->states.
failed_action_set);
- xbt_swag_free(surf_network_resource->common_public->states.
+ xbt_swag_free(surf_network_model->common_public->states.
done_action_set);
- free(surf_network_resource->common_public);
- free(surf_network_resource->common_private);
- free(surf_network_resource->extension_public);
+ free(surf_network_model->common_public);
+ free(surf_network_model->common_private);
+ free(surf_network_model->extension_public);
- free(surf_network_resource);
- surf_network_resource = NULL;
+ free(surf_network_model);
+ surf_network_model = NULL;
loopback = NULL;
- for (i = 0; i < card_number; i++)
- for (j = 0; j < card_number; j++)
- free(ROUTE(i,j));
+ for (i = 0; i < host_number; i++)
+ for (j = 0; j < host_number; j++)
+ free(ROUTE(i, j));
free(routing_table);
routing_table = NULL;
free(routing_table_size);
routing_table_size = NULL;
- card_number = 0;
+ host_number = 0;
+ lmm_system_free(network_maxmin_system);
+ network_maxmin_system = NULL;
}
-static void surf_network_resource_init_internal(void)
+static void surf_network_model_init_internal(void)
{
s_surf_action_t action;
- surf_network_resource = xbt_new0(s_surf_network_resource_t, 1);
+ surf_network_model = xbt_new0(s_surf_network_model_t, 1);
- surf_network_resource->common_private =
- xbt_new0(s_surf_resource_private_t, 1);
- surf_network_resource->common_public =
- xbt_new0(s_surf_resource_public_t, 1);
- surf_network_resource->extension_public =
- xbt_new0(s_surf_network_resource_extension_public_t, 1);
+ surf_network_model->common_private =
+ xbt_new0(s_surf_model_private_t, 1);
+ surf_network_model->common_public =
+ xbt_new0(s_surf_model_public_t, 1);
+ surf_network_model->extension_public =
+ xbt_new0(s_surf_network_model_extension_public_t, 1);
- surf_network_resource->common_public->states.ready_action_set =
+ surf_network_model->common_public->states.ready_action_set =
xbt_swag_new(xbt_swag_offset(action, state_hookup));
- surf_network_resource->common_public->states.running_action_set =
+ surf_network_model->common_public->states.running_action_set =
xbt_swag_new(xbt_swag_offset(action, state_hookup));
- surf_network_resource->common_public->states.failed_action_set =
+ surf_network_model->common_public->states.failed_action_set =
xbt_swag_new(xbt_swag_offset(action, state_hookup));
- surf_network_resource->common_public->states.done_action_set =
+ surf_network_model->common_public->states.done_action_set =
xbt_swag_new(xbt_swag_offset(action, state_hookup));
- surf_network_resource->common_public->name_service = name_service;
- surf_network_resource->common_public->get_resource_name =
+ surf_network_model->common_public->name_service = name_service;
+ surf_network_model->common_public->get_resource_name =
get_resource_name;
- surf_network_resource->common_public->action_get_state =
+ surf_network_model->common_public->action_get_state =
surf_action_get_state;
- surf_network_resource->common_public->action_free = action_free;
- surf_network_resource->common_public->action_use = action_use;
- surf_network_resource->common_public->action_cancel = action_cancel;
- surf_network_resource->common_public->action_recycle = action_recycle;
- surf_network_resource->common_public->action_change_state =
+ surf_network_model->common_public->action_get_start_time =
+ surf_action_get_start_time;
+ surf_network_model->common_public->action_get_finish_time =
+ surf_action_get_finish_time;
+ surf_network_model->common_public->action_free = action_free;
+ surf_network_model->common_public->action_use = action_use;
+ surf_network_model->common_public->action_cancel = action_cancel;
+ surf_network_model->common_public->action_recycle = action_recycle;
+ surf_network_model->common_public->action_change_state =
action_change_state;
- surf_network_resource->common_public->action_set_data = surf_action_set_data;
- surf_network_resource->common_public->name = "network";
+ surf_network_model->common_public->action_set_data =
+ surf_action_set_data;
+ surf_network_model->common_public->name = "network";
- surf_network_resource->common_private->resource_used = resource_used;
- surf_network_resource->common_private->share_resources = share_resources;
- surf_network_resource->common_private->update_actions_state =
+ surf_network_model->common_private->resource_used = resource_used;
+ surf_network_model->common_private->share_resources = share_resources;
+ surf_network_model->common_private->update_actions_state =
update_actions_state;
- surf_network_resource->common_private->update_resource_state =
+ surf_network_model->common_private->update_resource_state =
update_resource_state;
- surf_network_resource->common_private->finalize = finalize;
+ surf_network_model->common_private->finalize = finalize;
+
+ surf_network_model->common_public->suspend = action_suspend;
+ surf_network_model->common_public->resume = action_resume;
+ surf_network_model->common_public->is_suspended = action_is_suspended;
+ surf_cpu_model->common_public->set_max_duration =
+ action_set_max_duration;
+
+ surf_network_model->extension_public->communicate = communicate;
+ surf_network_model->extension_public->get_route = get_route;
+ surf_network_model->extension_public->get_route_size = get_route_size;
+ surf_network_model->extension_public->get_link_name = get_link_name;
+ surf_network_model->extension_public->get_link_bandwidth =
+ get_link_bandwidth;
+ surf_network_model->extension_public->get_link_latency =
+ get_link_latency;
+ surf_network_model->extension_public->link_shared =
+ link_shared;
+
+ surf_network_model->common_public->get_properties = get_properties;
+
+ link_set = xbt_dict_new();
+ network_card_set = xbt_dict_new();
- surf_network_resource->common_public->suspend = action_suspend;
- surf_network_resource->common_public->resume = action_resume;
- surf_network_resource->common_public->is_suspended = action_is_suspended;
- surf_cpu_resource->common_public->set_max_duration = action_set_max_duration;
+ if (!network_maxmin_system)
+ network_maxmin_system = lmm_system_new();
+}
- surf_network_resource->extension_public->communicate = communicate;
- surf_network_resource->extension_public->get_route = get_route;
+/************************************************************************/
+/* New model based on optimizations discussed during this thesis */
+/************************************************************************/
+void surf_network_model_init_LegrandVelho(const char *filename)
+{
- network_link_set = xbt_dict_new();
- network_card_set = xbt_dict_new();
+ if (surf_network_model)
+ return;
+ surf_network_model_init_internal();
+ define_callbacks(filename);
+ xbt_dynar_push(model_list, &surf_network_model);
+ network_solve = lmm_solve;
+
+ latency_factor = 10.4;
+ bandwidth_factor = 0.92;
- xbt_assert0(maxmin_system, "surf_init has to be called first!");
+ update_model_description(surf_network_model_description,
+ "LegrandVelho",
+ (surf_model_t) surf_network_model);
}
/***************************************************************************/
/* month = {oct}, */
/* year = {2002} */
/* } */
-void surf_network_resource_init_CM02(const char *filename)
+void surf_network_model_init_CM02(const char *filename)
{
- if (surf_network_resource)
+
+ if (surf_network_model)
return;
- surf_network_resource_init_internal();
- parse_file(filename);
- xbt_dynar_push(resource_list, &surf_network_resource);
+ surf_network_model_init_internal();
+ define_callbacks(filename);
+ xbt_dynar_push(model_list, &surf_network_model);
+ network_solve = lmm_solve;
+
+ update_model_description(surf_network_model_description,
+ "CM02",
+ (surf_model_t) surf_network_model);
+}
+
+void surf_network_model_init_Reno(const char *filename)
+{
+ if (surf_network_model)
+ return;
+ surf_network_model_init_internal();
+ define_callbacks(filename);
+
+ xbt_dynar_push(model_list, &surf_network_model);
+ lmm_set_default_protocol_function(func_reno_f, func_reno_fp,
+ func_reno_fpi);
+ network_solve = lagrange_solve;
+
+ update_model_description(surf_network_model_description,
+ "Reno",
+ (surf_model_t) surf_network_model);
+}
+
+
+void surf_network_model_init_Reno2(const char *filename)
+{
+ if (surf_network_model)
+ return;
+ surf_network_model_init_internal();
+ define_callbacks(filename);
+
+ xbt_dynar_push(model_list, &surf_network_model);
+ lmm_set_default_protocol_function(func_reno2_f, func_reno2_fp,
+ func_reno2_fpi);
+ network_solve = lagrange_solve;
+
+ update_model_description(surf_network_model_description,
+ "Reno2",
+ (surf_model_t) surf_network_model);
+}
+
+void surf_network_model_init_Vegas(const char *filename)
+{
+ if (surf_network_model)
+ return;
+ surf_network_model_init_internal();
+ define_callbacks(filename);
+
+ xbt_dynar_push(model_list, &surf_network_model);
+ lmm_set_default_protocol_function(func_vegas_f, func_vegas_fp,
+ func_vegas_fpi);
+ network_solve = lagrange_solve;
+
+ update_model_description(surf_network_model_description,
+ "Vegas",
+ (surf_model_t) surf_network_model);
+}
+
+#ifdef HAVE_SDP
+ void surf_network_model_init_SDP(const char *filename)
+{
+ if (surf_network_model)
+ return;
+ surf_network_model_init_internal();
+ define_callbacks(filename);
+
+ xbt_dynar_push(model_list, &surf_network_model);
+ network_solve = sdp_solve;
+
+ update_model_description(surf_network_model_description,
+ "SDP",
+ (surf_model_t) surf_network_model);
}
+#endif