static int net_selective_update = 0;
static int net_action_is_suspended(surf_action_t action);
-static void net_update_action_remaining_lazy(double now);
+static void net_update_action_remaining_lazy(surf_action_network_CM02_t action, double now);
static xbt_swag_t net_modified_set = NULL;
static xbt_heap_t net_action_heap = NULL;
lmm_constraint_shared(nw_link->lmm_resource.constraint);
xbt_lib_set(link_lib, name, SURF_LINK_LEVEL, nw_link);
+ XBT_DEBUG("Create link '%s'",name);
return nw_link;
}
surf_action_lmm_heap_remove(net_action_heap,(surf_action_lmm_t) action);
xbt_swag_remove(action, net_modified_set);
}
+#ifdef HAVE_TRACING
+ if (action->category) xbt_free (action->category);
+#endif
surf_action_free(&action);
return 1;
}
double net_action_get_remains(surf_action_t action)
{
+ XBT_IN("(%p)", action);
+ /* update remains before return it */
if (network_update_mechanism == UM_LAZY) /* update remains before return it */
- net_update_action_remaining_lazy(surf_get_clock());
+ net_update_action_remaining_lazy((surf_action_network_CM02_t)action,
+ surf_get_clock());
+ XBT_OUT();
return action->remains;
}
-static void net_update_action_remaining_lazy(double now)
+static void net_update_action_remaining_lazy(surf_action_network_CM02_t action, double now)
{
- surf_action_lmm_t action = NULL;
double delta = 0.0;
- xbt_swag_foreach(action, net_modified_set) {
-
- if (action->suspended != 0) {
- continue;
- }
+ if (GENERIC_LMM_ACTION(action).suspended != 0)
+ return;
- delta = now - action->last_update;
+ delta = now - GENERIC_LMM_ACTION(action).last_update;
- double_update(&(((surf_action_t)action)->remains),
- lmm_variable_getvalue(action->variable) * delta);
+ double_update(&(((surf_action_t)action)->remains),
+ GENERIC_LMM_ACTION(action).last_value * delta);
- if (((surf_action_t)action)->max_duration != NO_MAX_DURATION)
- double_update(&(((surf_action_t)action)->max_duration), delta);
+ if (((surf_action_t)action)->max_duration != NO_MAX_DURATION)
+ double_update(&(((surf_action_t)action)->max_duration), delta);
- if ((((surf_action_t)action)->remains <= 0) &&
- (lmm_get_variable_weight(action->variable) > 0)) {
- ((surf_action_t)action)->finish = surf_get_clock();
- surf_network_model->action_state_set((surf_action_t) action,
- SURF_ACTION_DONE);
- surf_action_lmm_heap_remove(net_action_heap,action);
- } else if (((((surf_action_t)action)->max_duration != NO_MAX_DURATION)
- && (((surf_action_t)action)->max_duration <= 0))) {
- ((surf_action_t)action)->finish = surf_get_clock();
- surf_network_model->action_state_set((surf_action_t) action,
- SURF_ACTION_DONE);
- surf_action_lmm_heap_remove(net_action_heap,action);
- }
+ if ((((surf_action_t)action)->remains <= 0) &&
+ (lmm_get_variable_weight(GENERIC_LMM_ACTION(action).variable) > 0)) {
+ ((surf_action_t)action)->finish = surf_get_clock();
+ surf_network_model->action_state_set((surf_action_t) action,
+ SURF_ACTION_DONE);
- action->last_update = now;
+ surf_action_lmm_heap_remove(net_action_heap,(surf_action_lmm_t)action);
+ } else if (((((surf_action_t)action)->max_duration != NO_MAX_DURATION)
+ && (((surf_action_t)action)->max_duration <= 0))) {
+ ((surf_action_t)action)->finish = surf_get_clock();
+ surf_network_model->action_state_set((surf_action_t) action,
+ SURF_ACTION_DONE);
+ surf_action_lmm_heap_remove(net_action_heap,(surf_action_lmm_t)action);
}
+
+ GENERIC_LMM_ACTION(action).last_update = now;
+ GENERIC_LMM_ACTION(action).last_value = lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable);
}
static double net_share_resources_full(double now)
XBT_DEBUG
("Before share resources, the size of modified actions set is %d",
xbt_swag_size(net_modified_set));
- net_update_action_remaining_lazy(now);
lmm_solve(network_maxmin_system);
("After share resources, The size of modified actions set is %d",
xbt_swag_size(net_modified_set));
- xbt_swag_foreach(action, net_modified_set) {
+ while((action = xbt_swag_extract(net_modified_set))) {
int max_dur_flag = 0;
if (GENERIC_ACTION(action).state_set !=
if (GENERIC_ACTION(action).priority <= 0)
continue;
+ net_update_action_remaining_lazy(action,now);
+
min = -1;
value = lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable);
if (value > 0) {
link_CM02_t link = lmm_constraint_id(constraint);
TRACE_surf_link_set_utilization(link->lmm_resource.generic_resource.name,
((surf_action_t)action)->category,
- lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable),
+ (lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable)*
+ lmm_get_cnst_weight_from_var(network_maxmin_system,
+ GENERIC_LMM_ACTION(action).variable,
+ i)),
now - delta,
delta);
}
link_CM02_t link = lmm_constraint_id(constraint);
TRACE_surf_link_set_utilization(link->lmm_resource.generic_resource.name,
((surf_action_t)action)->category,
- lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable),
+ (lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable)*
+ lmm_get_cnst_weight_from_var(network_maxmin_system,
+ GENERIC_LMM_ACTION(action).variable,
+ i)),
GENERIC_LMM_ACTION(action).last_update,
now - GENERIC_LMM_ACTION(action).last_update);
}
}
-static surf_action_t net_communicate(void *src,
- void *dst, double size,
- double rate)
+static surf_action_t net_communicate(sg_routing_edge_t src,
+ sg_routing_edge_t dst,
+ double size, double rate)
{
unsigned int i;
link_CM02_t link;
xbt_dynar_t back_route = NULL;
int constraints_per_variable = 0;
- xbt_dynar_t route = xbt_dynar_new(global_routing->size_of_link, NULL);
+ xbt_dynar_t route = xbt_dynar_new(sizeof(sg_routing_link_t), NULL);
- XBT_IN("(%s,%s,%g,%g)", ((network_element_t)src)->name, ((network_element_t)dst)->name, size, rate);
+ XBT_IN("(%s,%s,%g,%g)", src->name, dst->name, size, rate);
- routing_get_route_and_latency((network_element_t)src, (network_element_t)dst, &route, &latency);
+ routing_get_route_and_latency(src, dst, &route, &latency);
xbt_assert(!xbt_dynar_is_empty(route) || latency,
"You're trying to send data from %s to %s but there is no connection at all between these two hosts.",
- ((network_element_t)src)->name, ((network_element_t)dst)->name);
+ src->name, dst->name);
xbt_dynar_foreach(route, i, link) {
if (link->lmm_resource.state_current == SURF_RESOURCE_OFF) {
}
}
if (sg_network_crosstraffic == 1) {
- routing_get_route_and_latency((network_element_t)dst, (network_element_t)src, &back_route, NULL);
+ routing_get_route_and_latency(dst, src, &back_route, NULL);
xbt_dynar_foreach(back_route, i, link) {
if (link->lmm_resource.state_current == SURF_RESOURCE_OFF) {
failed = 1;
link = *(link_CM02_t *) xbt_dynar_get_ptr(route, 0);
gap_append(size, link, action);
XBT_DEBUG("Comm %p: %s -> %s gap=%f (lat=%f)",
- action, ((network_element_t)src)->name, ((network_element_t)dst)->name, action->sender.gap,
+ action, src->name, dst->name, action->sender.gap,
action->latency);
}
if (!network_maxmin_system)
network_maxmin_system = lmm_system_new(net_selective_update);
- routing_model_create(sizeof(link_CM02_t),
- net_create_resource("__loopback__",
+ routing_model_create(net_create_resource("__loopback__",
498000000, NULL, 0.000015, NULL,
SURF_RESOURCE_ON, NULL,
SURF_LINK_FATPIPE, NULL));