#undef GENERIC_ACTION
#define GENERIC_ACTION(action) action->generic_action
-
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network, surf,
"Logging specific to the SURF network module");
static lmm_system_t network_maxmin_system = NULL;
static void (*network_solve) (lmm_system_t) = NULL;
+xbt_dynar_t smpi_bw_factor = NULL;
+xbt_dynar_t smpi_lat_factor = NULL;
+
+typedef struct s_smpi_factor *smpi_factor_t;
+typedef struct s_smpi_factor {
+ long factor;
+ double value;
+} s_smpi_factor_t;
+
double sg_sender_gap = 0.0;
double sg_latency_factor = 1.0; /* default value; can be set by model or from command line */
double sg_bandwidth_factor = 1.0; /* default value; can be set by model or from command line */
xbt_dict_t gap_lookup = NULL;
e_UM_t network_update_mechanism = UM_UNDEFINED;
-static int selective_update = 0;
+static int net_selective_update = 0;
static int net_action_is_suspended(surf_action_t action);
-static void net_update_actions_state(double now, double delta);
static void update_action_remaining(double now);
static xbt_swag_t net_modified_set = NULL;
static xbt_heap_t net_action_heap = NULL;
-xbt_swag_t keep_track = NULL;
-extern int sg_maxmin_selective_update;
-
-#ifdef HAVE_SMPI
-static void gap_append(double size, const link_CM02_t link, surf_action_network_CM02_t action);
-static void gap_unknown(surf_action_network_CM02_t action);
-static void gap_remove(surf_action_network_CM02_t action);
-#endif
/* added to manage the communication action's heap */
static void net_action_update_index_heap(void *action, int i)
}
static void heap_remove(surf_action_network_CM02_t action){
- action->hat = NONE;
+ action->hat = NOTSET;
if(((surf_action_network_CM02_t) action)->index_heap >= 0){
xbt_heap_remove(net_action_heap,action->index_heap);
}
return rate;
}
-
/**********************/
/* SMPI callbacks */
/**********************/
-static double smpi_latency_factor(double size)
+static xbt_dynar_t parse_factor(const char *smpi_coef_string)
{
- /* 1 B <= size <= 1 KiB */
- if (size <= 1024.0) {
- return 1.0056;
- }
-
- /* 2 KiB <= size <= 32 KiB */
- if (size <= 32768.0) {
- return 1.8805;
- }
-
- /* 64 KiB <= size <= 4 MiB */
- return 22.7111;
+ char *value = NULL;
+ unsigned int iter = 0;
+ s_smpi_factor_t fact;
+ xbt_dynar_t smpi_factor, radical_elements, radical_elements2 = NULL;
+
+ smpi_factor = xbt_dynar_new(sizeof(s_smpi_factor_t), NULL);
+ radical_elements = xbt_str_split(smpi_coef_string, ";");
+ xbt_dynar_foreach(radical_elements, iter, value) {
+
+ radical_elements2 = xbt_str_split(value, ":");
+ if(xbt_dynar_length(radical_elements2) != 2)
+ xbt_die("Malformed radical for smpi factor!");
+ fact.factor = atol(xbt_dynar_get_as(radical_elements2,0,char*));
+ fact.value = atof(xbt_dynar_get_as(radical_elements2,1,char*));
+ xbt_dynar_push_as(smpi_factor,s_smpi_factor_t,fact);
+ XBT_DEBUG("smpi_factor:\t%ld : %f",fact.factor,fact.value);
+ xbt_dynar_free(&radical_elements2);
+ }
+ xbt_dynar_free(&radical_elements);
+ return smpi_factor;
}
static double smpi_bandwidth_factor(double size)
{
- /* 1 B <= size <= 1 KiB */
- if (size <= 1024.0) {
- return 0.2758;
- }
-
- /* 2 KiB <= size <= 32 KiB */
- if (size <= 32768.0) {
- return 0.5477;
- }
+ if(!smpi_bw_factor)
+ smpi_bw_factor = parse_factor( xbt_cfg_get_string(_surf_cfg_set,"smpi/bw_factor") );
+
+ unsigned int iter = 0;
+ s_smpi_factor_t fact;
+ xbt_dynar_foreach(smpi_bw_factor, iter, fact) {
+ if(size >= fact.factor){
+ XBT_DEBUG("%lf >= %ld return %f",size,fact.factor,fact.value);
+ return fact.value;
+ }
+ }
+
+ return 1.0;
+}
- /* 64 KiB <= size <= 4 MiB */
- return 0.9359;
+static double smpi_latency_factor(double size)
+{
+ if(!smpi_lat_factor)
+ smpi_lat_factor = parse_factor( xbt_cfg_get_string(_surf_cfg_set,"smpi/lat_factor") );
+
+ unsigned int iter = 0;
+ s_smpi_factor_t fact;
+ xbt_dynar_foreach(smpi_lat_factor, iter, fact) {
+ if(size >= fact.factor){
+ XBT_DEBUG("%lf >= %ld return %f",size,fact.factor,fact.value);
+ return fact.value;
+ }
+ }
+
+ return 1.0;
}
+/**--------- <copy/paste C code snippet in surf/network.c> -----------*/
static double smpi_bandwidth_constraint(double rate, double bound,
double size)
static double (*bandwidth_constraint_callback) (double, double, double) =
&constant_bandwidth_constraint;
+static void (*gap_append) (double, const link_CM02_t, surf_action_network_CM02_t) = NULL;
+static void (*gap_remove) (surf_action_network_CM02_t) = NULL;
static void* net_create_resource(const char *name,
double bw_initial,
static void net_action_cancel(surf_action_t action)
{
+ XBT_DEBUG("cancel action %p",action);
surf_network_model->action_state_set(action, SURF_ACTION_FAILED);
if(network_update_mechanism == UM_LAZY){// remove action from the heap
xbt_swag_remove(action, net_modified_set);
}
#ifdef HAVE_LATENCY_BOUND_TRACKING
-static int net_get_link_latency_limited(surf_action_t action)
+int net_get_link_latency_limited(surf_action_t action)
{
return action->latency_limited;
}
}
#endif
if (action->latency > 0) {
- if (min < 0)
- min = action->latency;
- else if (action->latency < min)
- min = action->latency;
+ min = (min<0)?action->latency:min(min,action->latency);
}
}
XBT_DEBUG("Before share resources, the size of modified actions set is %d", xbt_swag_size(net_modified_set));
update_action_remaining(now);
- keep_track = net_modified_set;
lmm_solve(network_maxmin_system);
- keep_track = NULL;
XBT_DEBUG("After share resources, The size of modified actions set is %d", xbt_swag_size(net_modified_set));
- xbt_swag_foreach(action, net_modified_set) {
- if (GENERIC_ACTION(action).state_set != surf_network_model->states.running_action_set){
- continue;
- }
-
- /* bogus priority, skip it */
- if (GENERIC_ACTION(action).priority <= 0){
- continue;
- }
-
- min = -1;
- value = lmm_variable_getvalue(action->variable);
- if (value > 0) {
- if (GENERIC_ACTION(action).remains > 0) {
- value = GENERIC_ACTION(action).remains / value;
- min = now + value;
- } else {
- value = 0.0;
- min = now;
- }
- }
+ xbt_swag_foreach(action, net_modified_set) {
+ int max_dur_flag = 0;
- if ((GENERIC_ACTION(action).max_duration != NO_MAX_DURATION)
- && (min == -1
- || GENERIC_ACTION(action).start +
- GENERIC_ACTION(action).max_duration < min)){
- min = GENERIC_ACTION(action).start +
- GENERIC_ACTION(action).max_duration;
- }
+ if (GENERIC_ACTION(action).state_set != surf_network_model->states.running_action_set){
+ continue;
+ }
- XBT_DEBUG("Action(%p) Start %lf Finish %lf Max_duration %lf", action,
- GENERIC_ACTION(action).start, now + value,
- GENERIC_ACTION(action).max_duration);
+ /* bogus priority, skip it */
+ if (GENERIC_ACTION(action).priority <= 0){
+ continue;
+ }
+ min = -1;
+ value = lmm_variable_getvalue(action->variable);
+ if (value > 0) {
+ if (GENERIC_ACTION(action).remains > 0) {
+ value = GENERIC_ACTION(action).remains / value;
+ min = now + value;
+ } else {
+ value = 0.0;
+ min = now;
+ }
+ }
+ if ((GENERIC_ACTION(action).max_duration != NO_MAX_DURATION)
+ && (min == -1
+ || GENERIC_ACTION(action).start +
+ GENERIC_ACTION(action).max_duration < min)){
+ min = GENERIC_ACTION(action).start +
+ GENERIC_ACTION(action).max_duration;
+ max_dur_flag = 1;
+ }
- if (action->index_heap >= 0) {
- heap_remove((surf_action_network_CM02_t) action);
- }
+ XBT_DEBUG("Action(%p) Start %lf Finish %lf Max_duration %lf", action,
+ GENERIC_ACTION(action).start, now + value,
+ GENERIC_ACTION(action).max_duration);
- if (min != -1) {
- heap_insert((surf_action_network_CM02_t) action, min, NORMAL);
- XBT_DEBUG("Insert at heap action(%p) min %lf now %lf", action, min, now);
- }
- }
+ if (action->index_heap >= 0) {
+ heap_remove((surf_action_network_CM02_t) action);
+ }
- //hereafter must have already the min value for this resource model
- if(xbt_heap_size(net_action_heap) > 0 ){
- min = xbt_heap_maxkey(net_action_heap) - now ;
- }else{
- min = -1;
- }
+ if (min != -1) {
+ heap_insert((surf_action_network_CM02_t) action, min, max_dur_flag?MAX_DURATION:NORMAL);
+ XBT_DEBUG("Insert at heap action(%p) min %lf now %lf", action, min, now);
+ }
+ }
- XBT_DEBUG("The minimum with the HEAP %lf", min);
+ //hereafter must have already the min value for this resource model
+ if(xbt_heap_size(net_action_heap) > 0 ){
+ min = xbt_heap_maxkey(net_action_heap) - now ;
+ }else{
+ min = -1;
+ }
+ XBT_DEBUG("The minimum with the HEAP %lf", min);
return min;
}
action->generic_action.finish = surf_get_clock();
surf_network_model->action_state_set((surf_action_t) action,
SURF_ACTION_DONE);
-#ifdef HAVE_SMPI
- gap_remove(action);
-#endif
+
+ if(gap_remove) gap_remove(action);
} else if ((action->generic_action.max_duration != NO_MAX_DURATION)
&& (action->generic_action.max_duration <= 0)) {
action->generic_action.finish = surf_get_clock();
surf_network_model->action_state_set((surf_action_t) action,
SURF_ACTION_DONE);
-#ifdef HAVE_SMPI
- gap_remove(action);
-#endif
+ if(gap_remove) gap_remove(action);
}
}
XBT_DEBUG("Action %p: finish", action);
GENERIC_ACTION(action).finish = surf_get_clock();
- // if I am wearing a latency heat
+ // if I am wearing a latency hat
if( action->hat == LATENCY){
lmm_update_variable_weight(network_maxmin_system, action->variable,
action->weight);
heap_remove(action);
action->last_update = surf_get_clock();
- XBT_DEBUG("Action (%p) is not limited by latency anymore", action);
-#ifdef HAVE_LATENCY_BOUND_TRACKING
- GENERIC_ACTION(action).latency_limited = 0;
-#endif
-
// if I am wearing a max_duration or normal hat
}else if( action->hat == MAX_DURATION || action->hat == NORMAL ){
// no need to communicate anymore
surf_action_network_CM02_t action = NULL;
double bandwidth_bound;
double latency=0.0;
- /* 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 */
-
xbt_dynar_t back_route = NULL;
int constraints_per_variable = 0;
- // I need to have the forward and backward routes at the same time, so allocate "route". That way, the routing wont clean it up
- xbt_dynar_t route=xbt_dynar_new(global_routing->size_of_link,NULL);
- routing_get_route_and_latency(src_name, dst_name, &route, &latency);
- if (sg_network_crosstraffic == 1) {
- // FIXME: fill route directly (unclear: check with blame who put the FIXME)
- routing_get_route_and_latency(dst_name, src_name, &back_route,NULL);
- }
-
- /* LARGE PLATFORMS HACK:
- total_route_size = route_size + src->link_nb + dst->nb */
+ xbt_dynar_t route=xbt_dynar_new(global_routing->size_of_link,NULL);
XBT_IN("(%s,%s,%g,%g)", src_name, dst_name, size, rate);
- /* LARGE PLATFORMS HACK:
- assert on total_route_size */
+
+ routing_get_route_and_latency(src_name, dst_name, &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.",
src_name, dst_name);
}
}
if (sg_network_crosstraffic == 1) {
+ routing_get_route_and_latency(dst_name, src_name, &back_route,NULL);
xbt_dynar_foreach(back_route, i, link) {
if (link->lmm_resource.state_current == SURF_RESOURCE_OFF) {
failed = 1;
action->rate = rate;
if(network_update_mechanism == UM_LAZY){
action->index_heap = -1;
- action->latency = 0.0;
- action->weight = 0.0;
action->last_update = surf_get_clock();
}
bandwidth_bound = -1.0;
+ if(sg_weight_S_parameter>0) {
+ xbt_dynar_foreach(route, i, link) {
+ action->weight +=
+ sg_weight_S_parameter /
+ (link->lmm_resource.power.peak * link->lmm_resource.power.scale);
+ }
+ }
xbt_dynar_foreach(route, i, link) {
- action->weight +=
- sg_weight_S_parameter /
+ double bb = bandwidth_factor_callback(size) *
(link->lmm_resource.power.peak * link->lmm_resource.power.scale);
- if (bandwidth_bound < 0.0)
- bandwidth_bound =
- bandwidth_factor_callback(size) *
- (link->lmm_resource.power.peak * link->lmm_resource.power.scale);
- else
- bandwidth_bound =
- min(bandwidth_bound,
- bandwidth_factor_callback(size) *
- (link->lmm_resource.power.peak *
- link->lmm_resource.power.scale));
+ bandwidth_bound = (bandwidth_bound < 0.0)?bb:min(bandwidth_bound,bb);
}
- /* LARGE PLATFORMS HACK:
- Add src->link and dst->link latencies */
+
action->lat_current = action->latency;
action->latency *= latency_factor_callback(size);
action->rate =
bandwidth_constraint_callback(action->rate, bandwidth_bound,
size);
-#ifdef HAVE_SMPI
- if(!xbt_dynar_is_empty(route)) {
+ if(gap_append) {
+ xbt_assert(!xbt_dynar_is_empty(route),"Using a model with a gap (e.g., SMPI) with a platform without links (e.g. vivaldi)!!!");
+
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, src_name, dst_name, action->sender.gap, action->latency);
- } else {
- gap_unknown(action);
}
-#endif
- /* LARGE PLATFORMS HACK:
- lmm_variable_new(..., total_route_size) */
- if (back_route != NULL) {
- constraints_per_variable =
- xbt_dynar_length(route) + xbt_dynar_length(back_route);
- } else {
- constraints_per_variable = xbt_dynar_length(route);
- }
+ constraints_per_variable = xbt_dynar_length(route);
+ if (back_route != NULL)
+ constraints_per_variable += xbt_dynar_length(back_route);
if (action->latency > 0){
action->variable =
if(network_update_mechanism == UM_LAZY){
// add to the heap the event when the latency is payed
XBT_DEBUG("Added action (%p) one latency event at date %f", action, action->latency + action->last_update);
- heap_insert(action, action->latency + action->last_update, LATENCY);
+ heap_insert(action, action->latency + action->last_update, xbt_dynar_is_empty(route)?NORMAL:LATENCY);
}
-#ifdef HAVE_LATENCY_BOUND_TRACKING
- (action->generic_action).latency_limited = 1;
-#endif
- }
- else
+ } else
action->variable =
lmm_variable_new(network_maxmin_system, action, 1.0, -1.0,
constraints_per_variable);
if (action->rate < 0) {
- if (action->lat_current > 0)
- lmm_update_variable_bound(network_maxmin_system, action->variable,
- sg_tcp_gamma / (2.0 *
- action->lat_current));
- else
- lmm_update_variable_bound(network_maxmin_system, action->variable,
- -1.0);
+ lmm_update_variable_bound(network_maxmin_system, action->variable,
+ (action->lat_current > 0)?
+ sg_tcp_gamma / (2.0 * action->lat_current) :-1.0);
} else {
- if (action->lat_current > 0)
- lmm_update_variable_bound(network_maxmin_system, action->variable,
- min(action->rate,
- sg_tcp_gamma / (2.0 *
- action->lat_current)));
- else
- lmm_update_variable_bound(network_maxmin_system, action->variable,
- action->rate);
+ lmm_update_variable_bound(network_maxmin_system, action->variable,
+ (action->lat_current > 0)?
+ min(action->rate, sg_tcp_gamma / (2.0 * action->lat_current))
+ :action->rate);
}
xbt_dynar_foreach(route, i, link) {
}
if (sg_network_crosstraffic == 1) {
- XBT_DEBUG("Fullduplex active adding backward flow using 5%c", '%');
+ XBT_DEBUG("Fullduplex active adding backward flow using 5%%");
xbt_dynar_foreach(back_route, i, link) {
lmm_expand(network_maxmin_system, link->lmm_resource.constraint,
action->variable, .05);
}
}
- /* LARGE PLATFORMS HACK:
- expand also with src->link and dst->link */
#ifdef HAVE_TRACING
if (TRACE_is_enabled()) {
action->src_name = xbt_strdup(src_name);
xbt_heap_free(net_action_heap);
xbt_swag_free(net_modified_set);
}
+
+ if(smpi_bw_factor)
+ xbt_dynar_free(&smpi_bw_factor);
+ if(smpi_lat_factor)
+ xbt_dynar_free(&smpi_lat_factor);
}
-#ifdef HAVE_SMPI
-static void gap_append(double size, const link_CM02_t link, surf_action_network_CM02_t action) {
+static void smpi_gap_append(double size, const link_CM02_t link, surf_action_network_CM02_t action) {
const char* src = link->lmm_resource.generic_resource.name;
xbt_fifo_t fifo;
surf_action_network_CM02_t last_action;
}
}
-static void gap_unknown(surf_action_network_CM02_t action) {
- action->sender.gap = 0.0;
- action->sender.link_name = NULL;
- action->sender.fifo_item = NULL;
- action->sender.size = 0.0;
-}
-
-static void gap_remove(surf_action_network_CM02_t action) {
+static void smpi_gap_remove(surf_action_network_CM02_t action) {
xbt_fifo_t fifo;
size_t size;
}
}
}
-#endif
static void surf_network_model_init_internal(void)
{
#ifdef HAVE_LATENCY_BOUND_TRACKING
surf_network_model->get_latency_limited = net_get_link_latency_limited;
#endif
+#ifdef HAVE_TRACING
+ surf_network_model->set_category = net_action_set_category;
+#endif
surf_network_model->model_private->resource_used = net_resource_used;
if(network_update_mechanism == UM_LAZY) {
net_create_resource;
if (!network_maxmin_system)
- network_maxmin_system = lmm_system_new(selective_update);
+ network_maxmin_system = lmm_system_new(net_selective_update);
routing_model_create(sizeof(link_CM02_t),
net_create_resource("__loopback__",
if(network_update_mechanism == UM_LAZY){
net_action_heap = xbt_heap_new(8,NULL);
xbt_heap_set_update_callback(net_action_heap, net_action_update_index_heap);
- net_modified_set =
- xbt_swag_new(xbt_swag_offset(comm, action_list_hookup));
+ net_modified_set = xbt_swag_new(xbt_swag_offset(comm, action_list_hookup));
+ network_maxmin_system->keep_track = net_modified_set;
}
}
static void set_update_mechanism(void) {
+#ifdef HAVE_TRACING
+ TRACE_set_network_update_mechanism ();
+#endif
+
char *optim = xbt_cfg_get_string(_surf_cfg_set, "network/optim");
int select = xbt_cfg_get_int(_surf_cfg_set, "network/maxmin_selective_update");
if(!strcmp(optim,"Full")) {
network_update_mechanism = UM_FULL;
- selective_update = select;
+ net_selective_update = select;
} else if (!strcmp(optim,"Lazy")) {
network_update_mechanism = UM_LAZY;
- selective_update = 1;
+ net_selective_update = 1;
xbt_assert((select==1) || (xbt_cfg_is_default_value(_surf_cfg_set,"network/maxmin_selective_update")),
"Disabling selective update while using the lazy update mechanism is dumb!");
} else {
latency_factor_callback = &smpi_latency_factor;
bandwidth_factor_callback = &smpi_bandwidth_factor;
bandwidth_constraint_callback = &smpi_bandwidth_constraint;
+ gap_append = &smpi_gap_append;
+ gap_remove = &smpi_gap_remove;
net_define_callbacks();
xbt_dynar_push(model_list, &surf_network_model);
network_solve = lmm_solve;
/* } */
void surf_network_model_init_LegrandVelho(void)
{
- char *model = xbt_cfg_get_string(_surf_cfg_set, "network/model");
-
if (surf_network_model)
return;
- if(!strcmp(model,"LV08_fullupdate")) {
- XBT_WARN("[*Deprecated*. Use --cfg=network/model:LV08 with option --cfg=network/optim:Full instead.]");
- }
set_update_mechanism();
surf_network_model_init_internal();
xbt_dynar_push(model_list, &surf_network_model);
network_solve = lmm_solve;
- xbt_cfg_setdefault_double(_surf_cfg_set, "network/latency_factor", 10.4); // 13.01 when callibration is done without phase effects
- xbt_cfg_setdefault_double(_surf_cfg_set, "network/bandwidth_factor",0.92);// 0.97 when callibration is done without phase effects
- xbt_cfg_setdefault_double(_surf_cfg_set, "network/weight_S", 8775); // 20537 when callibration is done without phase effects
+ xbt_cfg_setdefault_double(_surf_cfg_set, "network/latency_factor", 13.01);
+ xbt_cfg_setdefault_double(_surf_cfg_set, "network/bandwidth_factor",0.97);
+ xbt_cfg_setdefault_double(_surf_cfg_set, "network/weight_S", 20537);
}
/***************************************************************************/