Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics
[simgrid.git] / src / surf / network.c
1
2 /*
3  * Network with improved management of tasks, IM (Improved Management).
4  * Uses a heap to store actions so that the share_resources is faster.
5  * This model automatically sets the selective update flag to 1 and is
6  * highly dependent on the maxmin lmm module.
7  */
8
9 /* Copyright (c) 2009, 2010, 2011. The SimGrid Team.
10  * All rights reserved.                                                     */
11
12 /* This program is free software; you can redistribute it and/or modify it
13  * under the terms of the license (GNU LGPL) which comes with this package. */
14
15 #include "network_private.h"
16 #include "xbt/log.h"
17 #include "xbt/str.h"
18
19 #include "surf_private.h"
20 #include "xbt/dict.h"
21 #include "maxmin_private.h"
22 #include "surf/surfxml_parse_values.h"
23 #include "surf/surf_resource.h"
24 #include "surf/surf_resource_lmm.h"
25
26 #undef GENERIC_ACTION
27 #define GENERIC_ACTION(action) action->generic_action
28
29 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network, surf,
30                                 "Logging specific to the SURF network module");
31
32 surf_model_t surf_network_model = NULL;
33 static lmm_system_t network_maxmin_system = NULL;
34 static void (*network_solve) (lmm_system_t) = NULL;
35
36 xbt_dynar_t smpi_bw_factor = NULL;
37 xbt_dynar_t smpi_lat_factor = NULL;
38
39 typedef struct s_smpi_factor *smpi_factor_t;
40 typedef struct s_smpi_factor {
41   long factor;
42   double value;
43 } s_smpi_factor_t;
44
45 double sg_sender_gap = 0.0;
46 double sg_latency_factor = 1.0; /* default value; can be set by model or from command line */
47 double sg_bandwidth_factor = 1.0;       /* default value; can be set by model or from command line */
48 double sg_weight_S_parameter = 0.0;     /* default value; can be set by model or from command line */
49
50 double sg_tcp_gamma = 0.0;
51 int sg_network_crosstraffic = 0;
52
53 xbt_dict_t gap_lookup = NULL;
54
55 e_UM_t network_update_mechanism = UM_UNDEFINED;
56 static int net_selective_update = 0;
57
58 static int net_action_is_suspended(surf_action_t action);
59 static void update_action_remaining_lazy(double now);
60
61 static xbt_swag_t net_modified_set = NULL;
62 static xbt_heap_t net_action_heap = NULL;
63
64 /* added to manage the communication action's heap */
65 static void net_action_update_index_heap(void *action, int i)
66 {
67   ((surf_action_network_CM02_t) action)->index_heap = i;
68 }
69
70 /* insert action on heap using a given key and a hat (heap_action_type)
71  * a hat can be of three types for communications:
72  *
73  * NORMAL = this is a normal heap entry stating the date to finish transmitting
74  * LATENCY = this is a heap entry to warn us when the latency is payed
75  * MAX_DURATION =this is a heap entry to warn us when the max_duration limit is reached
76  */
77 static void heap_insert(surf_action_network_CM02_t action, double key,
78                         enum heap_action_type hat)
79 {
80   action->hat = hat;
81   xbt_heap_push(net_action_heap, action, key);
82 }
83
84 static void heap_remove(surf_action_network_CM02_t action)
85 {
86   action->hat = NOTSET;
87   if (((surf_action_network_CM02_t) action)->index_heap >= 0) {
88     xbt_heap_remove(net_action_heap, action->index_heap);
89   }
90 }
91
92 /******************************************************************************/
93 /*                           Factors callbacks                                */
94 /******************************************************************************/
95 static double constant_latency_factor(double size)
96 {
97   return sg_latency_factor;
98 }
99
100 static double constant_bandwidth_factor(double size)
101 {
102   return sg_bandwidth_factor;
103 }
104
105 static double constant_bandwidth_constraint(double rate, double bound,
106                                             double size)
107 {
108   return rate;
109 }
110
111 /**********************/
112 /*   SMPI callbacks   */
113 /**********************/
114 static xbt_dynar_t parse_factor(const char *smpi_coef_string)
115 {
116   char *value = NULL;
117   unsigned int iter = 0;
118   s_smpi_factor_t fact;
119   xbt_dynar_t smpi_factor, radical_elements, radical_elements2 = NULL;
120
121   smpi_factor = xbt_dynar_new(sizeof(s_smpi_factor_t), NULL);
122   radical_elements = xbt_str_split(smpi_coef_string, ";");
123   xbt_dynar_foreach(radical_elements, iter, value) {
124
125     radical_elements2 = xbt_str_split(value, ":");
126     if (xbt_dynar_length(radical_elements2) != 2)
127       xbt_die("Malformed radical for smpi factor!");
128     fact.factor = atol(xbt_dynar_get_as(radical_elements2, 0, char *));
129     fact.value = atof(xbt_dynar_get_as(radical_elements2, 1, char *));
130     xbt_dynar_push_as(smpi_factor, s_smpi_factor_t, fact);
131     XBT_DEBUG("smpi_factor:\t%ld : %f", fact.factor, fact.value);
132     xbt_dynar_free(&radical_elements2);
133   }
134   xbt_dynar_free(&radical_elements);
135   return smpi_factor;
136 }
137
138 static double smpi_bandwidth_factor(double size)
139 {
140   if (!smpi_bw_factor)
141     smpi_bw_factor =
142         parse_factor(xbt_cfg_get_string(_surf_cfg_set, "smpi/bw_factor"));
143
144   unsigned int iter = 0;
145   s_smpi_factor_t fact;
146   xbt_dynar_foreach(smpi_bw_factor, iter, fact) {
147     if (size >= fact.factor) {
148       XBT_DEBUG("%lf >= %ld return %f", size, fact.factor, fact.value);
149       return fact.value;
150     }
151   }
152
153   return 1.0;
154 }
155
156 static double smpi_latency_factor(double size)
157 {
158   if (!smpi_lat_factor)
159     smpi_lat_factor =
160         parse_factor(xbt_cfg_get_string(_surf_cfg_set, "smpi/lat_factor"));
161
162   unsigned int iter = 0;
163   s_smpi_factor_t fact;
164   xbt_dynar_foreach(smpi_lat_factor, iter, fact) {
165     if (size >= fact.factor) {
166       XBT_DEBUG("%lf >= %ld return %f", size, fact.factor, fact.value);
167       return fact.value;
168     }
169   }
170
171   return 1.0;
172 }
173
174 /**--------- <copy/paste C code snippet in surf/network.c> -----------*/
175
176 static double smpi_bandwidth_constraint(double rate, double bound,
177                                         double size)
178 {
179   return rate < 0 ? bound : min(bound, rate * smpi_bandwidth_factor(size));
180 }
181
182 static double (*latency_factor_callback) (double) =
183     &constant_latency_factor;
184 static double (*bandwidth_factor_callback) (double) =
185     &constant_bandwidth_factor;
186 static double (*bandwidth_constraint_callback) (double, double, double) =
187     &constant_bandwidth_constraint;
188
189 static void (*gap_append) (double, const link_CM02_t,
190                            surf_action_network_CM02_t) = NULL;
191 static void (*gap_remove) (surf_action_network_CM02_t) = NULL;
192
193 static void *net_create_resource(const char *name,
194                                  double bw_initial,
195                                  tmgr_trace_t bw_trace,
196                                  double lat_initial,
197                                  tmgr_trace_t lat_trace,
198                                  e_surf_resource_state_t
199                                  state_initial,
200                                  tmgr_trace_t state_trace,
201                                  e_surf_link_sharing_policy_t
202                                  policy, xbt_dict_t properties)
203 {
204   link_CM02_t nw_link = (link_CM02_t)
205       surf_resource_lmm_new(sizeof(s_link_CM02_t),
206                             surf_network_model, name, properties,
207                             network_maxmin_system,
208                             sg_bandwidth_factor * bw_initial,
209                             history,
210                             state_initial, state_trace,
211                             bw_initial, bw_trace);
212
213   xbt_assert(!xbt_lib_get_or_null(link_lib, name, SURF_LINK_LEVEL),
214              "Link '%s' declared several times in the platform file.",
215              name);
216
217   nw_link->lat_current = lat_initial;
218   if (lat_trace)
219     nw_link->lat_event =
220         tmgr_history_add_trace(history, lat_trace, 0.0, 0, nw_link);
221
222   if (policy == SURF_LINK_FATPIPE)
223     lmm_constraint_shared(nw_link->lmm_resource.constraint);
224
225   xbt_lib_set(link_lib, name, SURF_LINK_LEVEL, nw_link);
226
227   return nw_link;
228 }
229
230 static void net_parse_link_init(sg_platf_link_cbarg_t link)
231 {
232   if (link->policy == SURF_LINK_FULLDUPLEX) {
233     char *link_id;
234     link_id = bprintf("%s_UP", link->id);
235     net_create_resource(link_id,
236                         link->bandwidth,
237                         link->bandwidth_trace,
238                         link->latency,
239                         link->latency_trace,
240                         link->state,
241                         link->state_trace, link->policy, link->properties);
242     xbt_free(link_id);
243     link_id = bprintf("%s_DOWN", link->id);
244     net_create_resource(link_id,
245                         link->bandwidth,
246                         link->bandwidth_trace,
247                         link->latency,
248                         link->latency_trace,
249                         link->state,
250                         link->state_trace, link->policy, link->properties);
251     xbt_free(link_id);
252   } else {
253     net_create_resource(link->id,
254                         link->bandwidth,
255                         link->bandwidth_trace,
256                         link->latency,
257                         link->latency_trace,
258                         link->state,
259                         link->state_trace, link->policy, link->properties);
260   }
261 }
262
263 static void net_add_traces(void)
264 {
265   xbt_dict_cursor_t cursor = NULL;
266   char *trace_name, *elm;
267
268   static int called = 0;
269   if (called)
270     return;
271   called = 1;
272
273   /* connect all traces relative to network */
274   xbt_dict_foreach(trace_connect_list_link_avail, cursor, trace_name, elm) {
275     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
276     link_CM02_t link = xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL);
277
278     xbt_assert(link, "Cannot connect trace %s to link %s: link undefined",
279                trace_name, elm);
280     xbt_assert(trace,
281                "Cannot connect trace %s to link %s: trace undefined",
282                trace_name, elm);
283
284     link->lmm_resource.state_event =
285         tmgr_history_add_trace(history, trace, 0.0, 0, link);
286   }
287
288   xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) {
289     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
290     link_CM02_t link = xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL);
291
292     xbt_assert(link, "Cannot connect trace %s to link %s: link undefined",
293                trace_name, elm);
294     xbt_assert(trace,
295                "Cannot connect trace %s to link %s: trace undefined",
296                trace_name, elm);
297
298     link->lmm_resource.power.event =
299         tmgr_history_add_trace(history, trace, 0.0, 0, link);
300   }
301
302   xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) {
303     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
304     link_CM02_t link = xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL);
305
306     xbt_assert(link, "Cannot connect trace %s to link %s: link undefined",
307                trace_name, elm);
308     xbt_assert(trace,
309                "Cannot connect trace %s to link %s: trace undefined",
310                trace_name, elm);
311
312     link->lat_event = tmgr_history_add_trace(history, trace, 0.0, 0, link);
313   }
314 }
315
316 static void net_define_callbacks(void)
317 {
318   /* Figuring out the network links */
319   sg_platf_link_add_cb(net_parse_link_init);
320   sg_platf_postparse_add_cb(net_add_traces);
321 }
322
323 static int net_resource_used(void *resource_id)
324 {
325   return lmm_constraint_used(network_maxmin_system, ((surf_resource_lmm_t)
326                                                      resource_id)->
327                              constraint);
328 }
329
330 static int net_action_unref(surf_action_t action)
331 {
332   action->refcount--;
333   if (!action->refcount) {
334     xbt_swag_remove(action, action->state_set);
335     if (((surf_action_network_CM02_t) action)->variable) {
336       lmm_variable_free(network_maxmin_system,
337                         ((surf_action_network_CM02_t) action)->variable);
338     }
339     if (network_update_mechanism == UM_LAZY) {  // remove action from the heap
340       heap_remove((surf_action_network_CM02_t) action);
341       xbt_swag_remove(action, net_modified_set);
342     }
343 #ifdef HAVE_TRACING
344     xbt_free(((surf_action_network_CM02_t) action)->src_name);
345     xbt_free(((surf_action_network_CM02_t) action)->dst_name);
346     xbt_free(action->category);
347 #endif
348     surf_action_free(&action);
349     return 1;
350   }
351   return 0;
352 }
353
354
355
356 static void net_action_cancel(surf_action_t action)
357 {
358   XBT_DEBUG("cancel action %p", action);
359   surf_network_model->action_state_set(action, SURF_ACTION_FAILED);
360   if (network_update_mechanism == UM_LAZY) {    // remove action from the heap
361     xbt_swag_remove(action, net_modified_set);
362     heap_remove((surf_action_network_CM02_t) action);
363   }
364 }
365
366 void net_action_recycle(surf_action_t action)
367 {
368   return;
369 }
370
371 #ifdef HAVE_LATENCY_BOUND_TRACKING
372 int net_get_link_latency_limited(surf_action_t action)
373 {
374   return action->latency_limited;
375 }
376 #endif
377
378 double net_action_get_remains(surf_action_t action)
379 {
380   if (network_update_mechanism == UM_LAZY)      /* update remains before return it */
381     update_action_remaining_lazy(surf_get_clock());
382   return action->remains;
383 }
384
385 static void update_action_remaining_lazy(double now)
386 {
387   surf_action_network_CM02_t action = NULL;
388   double delta = 0.0;
389
390   xbt_swag_foreach(action, net_modified_set) {
391
392     if (action->suspended != 0) {
393       continue;
394     }
395
396     delta = now - action->last_update;
397
398     double_update(&(action->generic_action.remains),
399                   lmm_variable_getvalue(action->variable) * delta);
400
401     if (action->generic_action.max_duration != NO_MAX_DURATION)
402       double_update(&(action->generic_action.max_duration), delta);
403
404     if ((action->generic_action.remains <= 0) &&
405         (lmm_get_variable_weight(action->variable) > 0)) {
406       action->generic_action.finish = surf_get_clock();
407       surf_network_model->action_state_set((surf_action_t) action,
408                                            SURF_ACTION_DONE);
409       heap_remove(action);
410     } else if ((action->generic_action.max_duration != NO_MAX_DURATION)
411                && (action->generic_action.max_duration <= 0)) {
412       action->generic_action.finish = surf_get_clock();
413       surf_network_model->action_state_set((surf_action_t) action,
414                                            SURF_ACTION_DONE);
415       heap_remove(action);
416     }
417
418     action->last_update = now;
419   }
420 }
421
422 static double net_share_resources_full(double now)
423 {
424   s_surf_action_network_CM02_t s_action;
425   surf_action_network_CM02_t action = NULL;
426   xbt_swag_t running_actions =
427       surf_network_model->states.running_action_set;
428   double min;
429
430   min = generic_maxmin_share_resources(running_actions,
431                                        xbt_swag_offset(s_action,
432                                                        variable),
433                                        network_maxmin_system,
434                                        network_solve);
435
436 #define VARIABLE(action) (*((lmm_variable_t*)(((char *) (action)) + xbt_swag_offset(s_action, variable)  )))
437
438   xbt_swag_foreach(action, running_actions) {
439 #ifdef HAVE_LATENCY_BOUND_TRACKING
440     if (lmm_is_variable_limited_by_latency(action->variable)) {
441       (action->generic_action).latency_limited = 1;
442     } else {
443       (action->generic_action).latency_limited = 0;
444     }
445 #endif
446     if (action->latency > 0) {
447       min = (min < 0) ? action->latency : min(min, action->latency);
448     }
449   }
450
451   XBT_DEBUG("Min of share resources %f", min);
452
453   return min;
454 }
455
456 static double net_share_resources_lazy(double now)
457 {
458   surf_action_network_CM02_t action = NULL;
459   double min = -1.0;
460   double value;
461
462   XBT_DEBUG
463       ("Before share resources, the size of modified actions set is %d",
464        xbt_swag_size(net_modified_set));
465   update_action_remaining_lazy(now);
466
467   lmm_solve(network_maxmin_system);
468
469   XBT_DEBUG
470       ("After share resources, The size of modified actions set is %d",
471        xbt_swag_size(net_modified_set));
472
473   xbt_swag_foreach(action, net_modified_set) {
474     int max_dur_flag = 0;
475
476     if (GENERIC_ACTION(action).state_set !=
477         surf_network_model->states.running_action_set) {
478       continue;
479     }
480
481     /* bogus priority, skip it */
482     if (GENERIC_ACTION(action).priority <= 0) {
483       continue;
484     }
485
486     min = -1;
487     value = lmm_variable_getvalue(action->variable);
488     if (value > 0) {
489       if (GENERIC_ACTION(action).remains > 0) {
490         value = GENERIC_ACTION(action).remains / value;
491         min = now + value;
492       } else {
493         value = 0.0;
494         min = now;
495       }
496     }
497
498     if ((GENERIC_ACTION(action).max_duration != NO_MAX_DURATION)
499         && (min == -1
500             || GENERIC_ACTION(action).start +
501             GENERIC_ACTION(action).max_duration < min)) {
502       min = GENERIC_ACTION(action).start +
503           GENERIC_ACTION(action).max_duration;
504       max_dur_flag = 1;
505     }
506
507     XBT_DEBUG("Action(%p) Start %lf Finish %lf Max_duration %lf", action,
508               GENERIC_ACTION(action).start, now + value,
509               GENERIC_ACTION(action).max_duration);
510
511     if (action->index_heap >= 0) {
512       heap_remove((surf_action_network_CM02_t) action);
513     }
514
515     if (min != -1) {
516       heap_insert((surf_action_network_CM02_t) action, min,
517                   max_dur_flag ? MAX_DURATION : NORMAL);
518       XBT_DEBUG("Insert at heap action(%p) min %lf now %lf", action, min,
519                 now);
520     }
521   }
522
523   //hereafter must have already the min value for this resource model
524   if (xbt_heap_size(net_action_heap) > 0) {
525     min = xbt_heap_maxkey(net_action_heap) - now;
526   } else {
527     min = -1;
528   }
529
530   XBT_DEBUG("The minimum with the HEAP %lf", min);
531
532   return min;
533 }
534
535 static void net_update_actions_state_full(double now, double delta)
536 {
537   double deltap = 0.0;
538   surf_action_network_CM02_t action = NULL;
539   surf_action_network_CM02_t next_action = NULL;
540   xbt_swag_t running_actions =
541       surf_network_model->states.running_action_set;
542   /*
543      xbt_swag_t failed_actions =
544      surf_network_model->states.failed_action_set;
545    */
546
547   xbt_swag_foreach_safe(action, next_action, running_actions) {
548     deltap = delta;
549     if (action->latency > 0) {
550       if (action->latency > deltap) {
551         double_update(&(action->latency), deltap);
552         deltap = 0.0;
553       } else {
554         double_update(&(deltap), action->latency);
555         action->latency = 0.0;
556       }
557       if ((action->latency == 0.0) && !(action->suspended))
558         lmm_update_variable_weight(network_maxmin_system, action->variable,
559                                    action->weight);
560     }
561 #ifdef HAVE_TRACING
562     if (TRACE_is_enabled()) {
563       xbt_dynar_t route = NULL;
564       routing_get_route_and_latency(action->src_name, action->dst_name,
565                                     &route, NULL);
566       link_CM02_t link;
567       unsigned int i;
568       xbt_dynar_foreach(route, i, link) {
569         TRACE_surf_link_set_utilization(link->lmm_resource.
570                                         generic_resource.name,
571                                         action->generic_action.data,
572                                         (surf_action_t) action,
573                                         lmm_variable_getvalue(action->
574                                                               variable),
575                                         now - delta, delta);
576       }
577     }
578 #endif
579     if (!lmm_get_number_of_cnst_from_var
580         (network_maxmin_system, action->variable)) {
581       /* There is actually no link used, hence an infinite bandwidth.
582        * This happens often when using models like vivaldi.
583        * In such case, just make sure that the action completes immediately.
584        */
585       double_update(&(action->generic_action.remains),
586                     action->generic_action.remains);
587     }
588     double_update(&(action->generic_action.remains),
589                   lmm_variable_getvalue(action->variable) * deltap);
590     if (action->generic_action.max_duration != NO_MAX_DURATION)
591       double_update(&(action->generic_action.max_duration), delta);
592
593     if ((action->generic_action.remains <= 0) &&
594         (lmm_get_variable_weight(action->variable) > 0)) {
595       action->generic_action.finish = surf_get_clock();
596       surf_network_model->action_state_set((surf_action_t) action,
597                                            SURF_ACTION_DONE);
598
599       if (gap_remove)
600         gap_remove(action);
601     } else if ((action->generic_action.max_duration != NO_MAX_DURATION)
602                && (action->generic_action.max_duration <= 0)) {
603       action->generic_action.finish = surf_get_clock();
604       surf_network_model->action_state_set((surf_action_t) action,
605                                            SURF_ACTION_DONE);
606       if (gap_remove)
607         gap_remove(action);
608     }
609   }
610
611   return;
612 }
613
614 static void net_update_actions_state_lazy(double now, double delta)
615 {
616   surf_action_network_CM02_t action = NULL;
617
618   while ((xbt_heap_size(net_action_heap) > 0)
619          && (double_equals(xbt_heap_maxkey(net_action_heap), now))) {
620     action = xbt_heap_pop(net_action_heap);
621     XBT_DEBUG("Action %p: finish", action);
622     GENERIC_ACTION(action).finish = surf_get_clock();
623
624     // if I am wearing a latency hat
625     if (action->hat == LATENCY) {
626       lmm_update_variable_weight(network_maxmin_system, action->variable,
627                                  action->weight);
628       heap_remove(action);
629       action->last_update = surf_get_clock();
630
631       // if I am wearing a max_duration or normal hat
632     } else if (action->hat == MAX_DURATION || action->hat == NORMAL) {
633       // no need to communicate anymore
634       // assume that flows that reached max_duration have remaining of 0
635       GENERIC_ACTION(action).remains = 0;
636       action->generic_action.finish = surf_get_clock();
637       surf_network_model->action_state_set((surf_action_t) action,
638                                            SURF_ACTION_DONE);
639       heap_remove(action);
640     }
641   }
642   return;
643 }
644
645 static void net_update_resource_state(void *id,
646                                       tmgr_trace_event_t event_type,
647                                       double value, double date)
648 {
649   link_CM02_t nw_link = id;
650   /*   printf("[" "%lg" "] Asking to update network card \"%s\" with value " */
651   /*     "%lg" " for event %p\n", surf_get_clock(), nw_link->name, */
652   /*     value, event_type); */
653
654   if (event_type == nw_link->lmm_resource.power.event) {
655     double delta =
656         sg_weight_S_parameter / value - sg_weight_S_parameter /
657         (nw_link->lmm_resource.power.peak *
658          nw_link->lmm_resource.power.scale);
659     lmm_variable_t var = NULL;
660     lmm_element_t elem = NULL;
661     surf_action_network_CM02_t action = NULL;
662
663     nw_link->lmm_resource.power.peak = value;
664     lmm_update_constraint_bound(network_maxmin_system,
665                                 nw_link->lmm_resource.constraint,
666                                 sg_bandwidth_factor *
667                                 (nw_link->lmm_resource.power.peak *
668                                  nw_link->lmm_resource.power.scale));
669 #ifdef HAVE_TRACING
670     TRACE_surf_link_set_bandwidth(date,
671                                   (char
672                                    *) (((nw_link->lmm_resource).
673                                         generic_resource).name),
674                                   sg_bandwidth_factor *
675                                   (nw_link->lmm_resource.power.peak *
676                                    nw_link->lmm_resource.power.scale));
677 #endif
678     if (sg_weight_S_parameter > 0) {
679       while ((var = lmm_get_var_from_cnst
680               (network_maxmin_system, nw_link->lmm_resource.constraint,
681                &elem))) {
682         action = lmm_variable_id(var);
683         action->weight += delta;
684         if (!(action->suspended))
685           lmm_update_variable_weight(network_maxmin_system,
686                                      action->variable, action->weight);
687       }
688     }
689     if (tmgr_trace_event_free(event_type))
690       nw_link->lmm_resource.power.event = NULL;
691   } else if (event_type == nw_link->lat_event) {
692     double delta = value - nw_link->lat_current;
693     lmm_variable_t var = NULL;
694     lmm_element_t elem = NULL;
695     surf_action_network_CM02_t action = NULL;
696
697     nw_link->lat_current = value;
698     while ((var = lmm_get_var_from_cnst
699             (network_maxmin_system, nw_link->lmm_resource.constraint,
700              &elem))) {
701       action = lmm_variable_id(var);
702       action->lat_current += delta;
703       action->weight += delta;
704       if (action->rate < 0)
705         lmm_update_variable_bound(network_maxmin_system, action->variable,
706                                   sg_tcp_gamma / (2.0 *
707                                                   action->lat_current));
708       else {
709         lmm_update_variable_bound(network_maxmin_system, action->variable,
710                                   min(action->rate,
711                                       sg_tcp_gamma / (2.0 *
712                                                       action->
713                                                       lat_current)));
714
715         if (action->rate < sg_tcp_gamma / (2.0 * action->lat_current)) {
716           XBT_INFO("Flow is limited BYBANDWIDTH");
717         } else {
718           XBT_INFO("Flow is limited BYLATENCY, latency of flow is %f",
719                    action->lat_current);
720         }
721       }
722       if (!(action->suspended))
723         lmm_update_variable_weight(network_maxmin_system, action->variable,
724                                    action->weight);
725
726     }
727     if (tmgr_trace_event_free(event_type))
728       nw_link->lat_event = NULL;
729   } else if (event_type == nw_link->lmm_resource.state_event) {
730     if (value > 0)
731       nw_link->lmm_resource.state_current = SURF_RESOURCE_ON;
732     else {
733       lmm_constraint_t cnst = nw_link->lmm_resource.constraint;
734       lmm_variable_t var = NULL;
735       lmm_element_t elem = NULL;
736
737       nw_link->lmm_resource.state_current = SURF_RESOURCE_OFF;
738       while ((var = lmm_get_var_from_cnst
739               (network_maxmin_system, cnst, &elem))) {
740         surf_action_t action = lmm_variable_id(var);
741
742         if (surf_action_state_get(action) == SURF_ACTION_RUNNING ||
743             surf_action_state_get(action) == SURF_ACTION_READY) {
744           action->finish = date;
745           surf_network_model->action_state_set(action, SURF_ACTION_FAILED);
746         }
747       }
748     }
749     if (tmgr_trace_event_free(event_type))
750       nw_link->lmm_resource.state_event = NULL;
751   } else {
752     XBT_CRITICAL("Unknown event ! \n");
753     xbt_abort();
754   }
755
756   XBT_DEBUG
757       ("There were a resource state event, need to update actions related to the constraint (%p)",
758        nw_link->lmm_resource.constraint);
759   return;
760 }
761
762
763 static surf_action_t net_communicate(const char *src_name,
764                                      const char *dst_name, double size,
765                                      double rate)
766 {
767   unsigned int i;
768   link_CM02_t link;
769   int failed = 0;
770   surf_action_network_CM02_t action = NULL;
771   double bandwidth_bound;
772   double latency = 0.0;
773   xbt_dynar_t back_route = NULL;
774   int constraints_per_variable = 0;
775
776   xbt_dynar_t route = xbt_dynar_new(global_routing->size_of_link, NULL);
777
778   XBT_IN("(%s,%s,%g,%g)", src_name, dst_name, size, rate);
779
780   routing_get_route_and_latency(src_name, dst_name, &route, &latency);
781   xbt_assert(!xbt_dynar_is_empty(route) || latency,
782              "You're trying to send data from %s to %s but there is no connection at all between these two hosts.",
783              src_name, dst_name);
784
785   xbt_dynar_foreach(route, i, link) {
786     if (link->lmm_resource.state_current == SURF_RESOURCE_OFF) {
787       failed = 1;
788       break;
789     }
790   }
791   if (sg_network_crosstraffic == 1) {
792     routing_get_route_and_latency(dst_name, src_name, &back_route, NULL);
793     xbt_dynar_foreach(back_route, i, link) {
794       if (link->lmm_resource.state_current == SURF_RESOURCE_OFF) {
795         failed = 1;
796         break;
797       }
798     }
799   }
800
801   action =
802       surf_action_new(sizeof(s_surf_action_network_CM02_t), size,
803                       surf_network_model, failed);
804 #ifdef HAVE_LATENCY_BOUND_TRACKING
805   (action->generic_action).latency_limited = 0;
806 #endif
807   action->weight = action->latency = latency;
808
809   xbt_swag_insert(action, action->generic_action.state_set);
810   action->rate = rate;
811   if (network_update_mechanism == UM_LAZY) {
812     action->index_heap = -1;
813     action->last_update = surf_get_clock();
814   }
815
816   bandwidth_bound = -1.0;
817   if (sg_weight_S_parameter > 0) {
818     xbt_dynar_foreach(route, i, link) {
819       action->weight +=
820           sg_weight_S_parameter /
821           (link->lmm_resource.power.peak * link->lmm_resource.power.scale);
822     }
823   }
824   xbt_dynar_foreach(route, i, link) {
825     double bb = bandwidth_factor_callback(size) *
826         (link->lmm_resource.power.peak * link->lmm_resource.power.scale);
827     bandwidth_bound =
828         (bandwidth_bound < 0.0) ? bb : min(bandwidth_bound, bb);
829   }
830
831   action->lat_current = action->latency;
832   action->latency *= latency_factor_callback(size);
833   action->rate =
834       bandwidth_constraint_callback(action->rate, bandwidth_bound, size);
835   if (gap_append) {
836     xbt_assert(!xbt_dynar_is_empty(route),
837                "Using a model with a gap (e.g., SMPI) with a platform without links (e.g. vivaldi)!!!");
838
839     link = *(link_CM02_t *) xbt_dynar_get_ptr(route, 0);
840     gap_append(size, link, action);
841     XBT_DEBUG("Comm %p: %s -> %s gap=%f (lat=%f)",
842               action, src_name, dst_name, action->sender.gap,
843               action->latency);
844   }
845
846   constraints_per_variable = xbt_dynar_length(route);
847   if (back_route != NULL)
848     constraints_per_variable += xbt_dynar_length(back_route);
849
850   if (action->latency > 0) {
851     action->variable =
852         lmm_variable_new(network_maxmin_system, action, 0.0, -1.0,
853                          constraints_per_variable);
854     if (network_update_mechanism == UM_LAZY) {
855       // add to the heap the event when the latency is payed
856       XBT_DEBUG("Added action (%p) one latency event at date %f", action,
857                 action->latency + action->last_update);
858       heap_insert(action, action->latency + action->last_update,
859                   xbt_dynar_is_empty(route) ? NORMAL : LATENCY);
860     }
861   } else
862     action->variable =
863         lmm_variable_new(network_maxmin_system, action, 1.0, -1.0,
864                          constraints_per_variable);
865
866   if (action->rate < 0) {
867     lmm_update_variable_bound(network_maxmin_system, action->variable,
868                               (action->lat_current > 0) ?
869                               sg_tcp_gamma / (2.0 *
870                                               action->lat_current) : -1.0);
871   } else {
872     lmm_update_variable_bound(network_maxmin_system, action->variable,
873                               (action->lat_current > 0) ?
874                               min(action->rate,
875                                   sg_tcp_gamma / (2.0 *
876                                                   action->lat_current))
877                               : action->rate);
878   }
879
880   xbt_dynar_foreach(route, i, link) {
881     lmm_expand(network_maxmin_system, link->lmm_resource.constraint,
882                action->variable, 1.0);
883   }
884
885   if (sg_network_crosstraffic == 1) {
886     XBT_DEBUG("Fullduplex active adding backward flow using 5%%");
887     xbt_dynar_foreach(back_route, i, link) {
888       lmm_expand(network_maxmin_system, link->lmm_resource.constraint,
889                  action->variable, .05);
890     }
891   }
892 #ifdef HAVE_TRACING
893   if (TRACE_is_enabled()) {
894     action->src_name = xbt_strdup(src_name);
895     action->dst_name = xbt_strdup(dst_name);
896   } else {
897     action->src_name = action->dst_name = NULL;
898   }
899 #endif
900
901   xbt_dynar_free(&route);
902   XBT_OUT();
903
904   return (surf_action_t) action;
905 }
906
907 static xbt_dynar_t net_get_route(const char *src, const char *dst)
908 {
909   xbt_dynar_t route = NULL;
910   routing_get_route_and_latency(src, dst, &route, NULL);
911   return route;
912 }
913
914 static double net_get_link_bandwidth(const void *link)
915 {
916   surf_resource_lmm_t lmm = (surf_resource_lmm_t) link;
917   return lmm->power.peak * lmm->power.scale;
918 }
919
920 static double net_get_link_latency(const void *link)
921 {
922   return ((link_CM02_t) link)->lat_current;
923 }
924
925 static int net_link_shared(const void *link)
926 {
927   return
928       lmm_constraint_is_shared(((surf_resource_lmm_t) link)->constraint);
929 }
930
931 static void net_action_suspend(surf_action_t action)
932 {
933   ((surf_action_network_CM02_t) action)->suspended = 1;
934   lmm_update_variable_weight(network_maxmin_system,
935                              ((surf_action_network_CM02_t)
936                               action)->variable, 0.0);
937
938   if (network_update_mechanism == UM_LAZY)      // remove action from the heap
939     heap_remove((surf_action_network_CM02_t) action);
940 }
941
942 static void net_action_resume(surf_action_t action)
943 {
944   if (((surf_action_network_CM02_t) action)->suspended) {
945     lmm_update_variable_weight(network_maxmin_system,
946                                ((surf_action_network_CM02_t)
947                                 action)->variable,
948                                ((surf_action_network_CM02_t)
949                                 action)->weight);
950     ((surf_action_network_CM02_t) action)->suspended = 0;
951     if (network_update_mechanism == UM_LAZY)    // remove action from the heap
952       heap_remove((surf_action_network_CM02_t) action);
953   }
954 }
955
956 static int net_action_is_suspended(surf_action_t action)
957 {
958   return ((surf_action_network_CM02_t) action)->suspended;
959 }
960
961 void net_action_set_max_duration(surf_action_t action, double duration)
962 {
963   action->max_duration = duration;
964   if (network_update_mechanism == UM_LAZY)      // remove action from the heap
965     heap_remove((surf_action_network_CM02_t) action);
966 }
967
968 #ifdef HAVE_TRACING
969 static void net_action_set_category(surf_action_t action,
970                                     const char *category)
971 {
972   action->category = xbt_strdup(category);
973 }
974 #endif
975
976 static void net_finalize(void)
977 {
978   surf_model_exit(surf_network_model);
979   surf_network_model = NULL;
980
981   lmm_system_free(network_maxmin_system);
982   network_maxmin_system = NULL;
983
984   if (network_update_mechanism == UM_LAZY) {
985     xbt_heap_free(net_action_heap);
986     xbt_swag_free(net_modified_set);
987   }
988
989   if (smpi_bw_factor)
990     xbt_dynar_free(&smpi_bw_factor);
991   if (smpi_lat_factor)
992     xbt_dynar_free(&smpi_lat_factor);
993 }
994
995 static void smpi_gap_append(double size, const link_CM02_t link,
996                             surf_action_network_CM02_t action)
997 {
998   const char *src = link->lmm_resource.generic_resource.name;
999   xbt_fifo_t fifo;
1000   surf_action_network_CM02_t last_action;
1001   double bw;
1002
1003   if (sg_sender_gap > 0.0) {
1004     if (!gap_lookup) {
1005       gap_lookup = xbt_dict_new();
1006     }
1007     fifo = (xbt_fifo_t) xbt_dict_get_or_null(gap_lookup, src);
1008     action->sender.gap = 0.0;
1009     if (fifo && xbt_fifo_size(fifo) > 0) {
1010       /* Compute gap from last send */
1011       last_action =
1012           (surf_action_network_CM02_t)
1013           xbt_fifo_get_item_content(xbt_fifo_get_last_item(fifo));
1014       bw = net_get_link_bandwidth(link);
1015       action->sender.gap =
1016           last_action->sender.gap + max(sg_sender_gap,
1017                                         last_action->sender.size / bw);
1018       action->latency += action->sender.gap;
1019     }
1020     /* Append action as last send */
1021     action->sender.link_name = link->lmm_resource.generic_resource.name;
1022     fifo =
1023         (xbt_fifo_t) xbt_dict_get_or_null(gap_lookup,
1024                                           action->sender.link_name);
1025     if (!fifo) {
1026       fifo = xbt_fifo_new();
1027       xbt_dict_set(gap_lookup, action->sender.link_name, fifo, NULL);
1028     }
1029     action->sender.fifo_item = xbt_fifo_push(fifo, action);
1030     action->sender.size = size;
1031   }
1032 }
1033
1034 static void smpi_gap_remove(surf_action_network_CM02_t action)
1035 {
1036   xbt_fifo_t fifo;
1037   size_t size;
1038
1039   if (sg_sender_gap > 0.0 && action->sender.link_name
1040       && action->sender.fifo_item) {
1041     fifo =
1042         (xbt_fifo_t) xbt_dict_get_or_null(gap_lookup,
1043                                           action->sender.link_name);
1044     xbt_fifo_remove_item(fifo, action->sender.fifo_item);
1045     size = xbt_fifo_size(fifo);
1046     if (size == 0) {
1047       xbt_fifo_free(fifo);
1048       xbt_dict_remove(gap_lookup, action->sender.link_name);
1049       size = xbt_dict_length(gap_lookup);
1050       if (size == 0) {
1051         xbt_dict_free(&gap_lookup);
1052       }
1053     }
1054   }
1055 }
1056
1057 static void surf_network_model_init_internal(void)
1058 {
1059   s_surf_action_network_CM02_t comm;
1060   surf_network_model = surf_model_init();
1061
1062   surf_network_model->name = "network";
1063   surf_network_model->action_unref = net_action_unref;
1064   surf_network_model->action_cancel = net_action_cancel;
1065   surf_network_model->action_recycle = net_action_recycle;
1066   surf_network_model->get_remains = net_action_get_remains;
1067 #ifdef HAVE_LATENCY_BOUND_TRACKING
1068   surf_network_model->get_latency_limited = net_get_link_latency_limited;
1069 #endif
1070 #ifdef HAVE_TRACING
1071   surf_network_model->set_category = net_action_set_category;
1072 #endif
1073
1074   surf_network_model->model_private->resource_used = net_resource_used;
1075   if (network_update_mechanism == UM_LAZY) {
1076     surf_network_model->model_private->share_resources =
1077         net_share_resources_lazy;
1078     surf_network_model->model_private->update_actions_state =
1079         net_update_actions_state_lazy;
1080   } else if (network_update_mechanism == UM_FULL) {
1081     surf_network_model->model_private->share_resources =
1082         net_share_resources_full;
1083     surf_network_model->model_private->update_actions_state =
1084         net_update_actions_state_full;
1085   }
1086
1087   surf_network_model->model_private->update_resource_state =
1088       net_update_resource_state;
1089   surf_network_model->model_private->finalize = net_finalize;
1090
1091   surf_network_model->suspend = net_action_suspend;
1092   surf_network_model->resume = net_action_resume;
1093   surf_network_model->is_suspended = net_action_is_suspended;
1094   surf_cpu_model->set_max_duration = net_action_set_max_duration;
1095
1096   surf_network_model->extension.network.communicate = net_communicate;
1097   surf_network_model->extension.network.get_route = net_get_route;
1098   surf_network_model->extension.network.get_link_bandwidth =
1099       net_get_link_bandwidth;
1100   surf_network_model->extension.network.get_link_latency =
1101       net_get_link_latency;
1102   surf_network_model->extension.network.link_shared = net_link_shared;
1103   surf_network_model->extension.network.add_traces = net_add_traces;
1104   surf_network_model->extension.network.create_resource =
1105       net_create_resource;
1106
1107   if (!network_maxmin_system)
1108     network_maxmin_system = lmm_system_new(net_selective_update);
1109
1110   routing_model_create(sizeof(link_CM02_t),
1111                        net_create_resource("__loopback__",
1112                                            498000000, NULL, 0.000015, NULL,
1113                                            SURF_RESOURCE_ON, NULL,
1114                                            SURF_LINK_FATPIPE, NULL));
1115
1116   if (network_update_mechanism == UM_LAZY) {
1117     net_action_heap = xbt_heap_new(8, NULL);
1118     xbt_heap_set_update_callback(net_action_heap,
1119                                  net_action_update_index_heap);
1120     net_modified_set =
1121         xbt_swag_new(xbt_swag_offset(comm, action_list_hookup));
1122     network_maxmin_system->keep_track = net_modified_set;
1123   }
1124 }
1125
1126 static void set_update_mechanism(void)
1127 {
1128 #ifdef HAVE_TRACING
1129   TRACE_set_network_update_mechanism();
1130 #endif
1131
1132   char *optim = xbt_cfg_get_string(_surf_cfg_set, "network/optim");
1133   int select =
1134       xbt_cfg_get_int(_surf_cfg_set, "network/maxmin_selective_update");
1135
1136   if (!strcmp(optim, "Full")) {
1137     network_update_mechanism = UM_FULL;
1138     net_selective_update = select;
1139   } else if (!strcmp(optim, "Lazy")) {
1140     network_update_mechanism = UM_LAZY;
1141     net_selective_update = 1;
1142     xbt_assert((select == 1)
1143                ||
1144                (xbt_cfg_is_default_value
1145                 (_surf_cfg_set, "network/maxmin_selective_update")),
1146                "Disabling selective update while using the lazy update mechanism is dumb!");
1147   } else {
1148     xbt_die("Unsupported optimization (%s) for this model", optim);
1149   }
1150 }
1151
1152 /************************************************************************/
1153 /* New model based on LV08 and experimental results of MPI ping-pongs   */
1154 /************************************************************************/
1155 /* @Inproceedings{smpi_ipdps, */
1156 /*  author={Pierre-Nicolas Clauss and Mark Stillwell and Stéphane Genaud and Frédéric Suter and Henri Casanova and Martin Quinson}, */
1157 /*  title={Single Node On-Line Simulation of {MPI} Applications with SMPI}, */
1158 /*  booktitle={25th IEEE International Parallel and Distributed Processing Symposium (IPDPS'11)}, */
1159 /*  address={Anchorage (Alaska) USA}, */
1160 /*  month=may, */
1161 /*  year={2011} */
1162 /*  } */
1163 void surf_network_model_init_SMPI(void)
1164 {
1165
1166   if (surf_network_model)
1167     return;
1168   set_update_mechanism();
1169
1170   surf_network_model_init_internal();
1171   latency_factor_callback = &smpi_latency_factor;
1172   bandwidth_factor_callback = &smpi_bandwidth_factor;
1173   bandwidth_constraint_callback = &smpi_bandwidth_constraint;
1174   gap_append = &smpi_gap_append;
1175   gap_remove = &smpi_gap_remove;
1176   net_define_callbacks();
1177   xbt_dynar_push(model_list, &surf_network_model);
1178   network_solve = lmm_solve;
1179
1180   xbt_cfg_setdefault_double(_surf_cfg_set, "network/sender_gap", 10e-6);
1181   xbt_cfg_setdefault_double(_surf_cfg_set, "network/weight_S", 8775);
1182 }
1183
1184 /************************************************************************/
1185 /* New model based on optimizations discussed during Pedro Velho's thesis*/
1186 /************************************************************************/
1187 /* @techreport{VELHO:2011:HAL-00646896:1, */
1188 /*      url = {http://hal.inria.fr/hal-00646896/en/}, */
1189 /*      title = {{Flow-level network models: have we reached the limits?}}, */
1190 /*      author = {Velho, Pedro and Schnorr, Lucas and Casanova, Henri and Legrand, Arnaud}, */
1191 /*      type = {Rapport de recherche}, */
1192 /*      institution = {INRIA}, */
1193 /*      number = {RR-7821}, */
1194 /*      year = {2011}, */
1195 /*      month = Nov, */
1196 /*      pdf = {http://hal.inria.fr/hal-00646896/PDF/rr-validity.pdf}, */
1197 /*  } */
1198 void surf_network_model_init_LegrandVelho(void)
1199 {
1200   if (surf_network_model)
1201     return;
1202
1203   set_update_mechanism();
1204
1205   surf_network_model_init_internal();
1206   net_define_callbacks();
1207   xbt_dynar_push(model_list, &surf_network_model);
1208   network_solve = lmm_solve;
1209
1210   xbt_cfg_setdefault_double(_surf_cfg_set, "network/latency_factor",
1211                             13.01);
1212   xbt_cfg_setdefault_double(_surf_cfg_set, "network/bandwidth_factor",
1213                             0.97);
1214   xbt_cfg_setdefault_double(_surf_cfg_set, "network/weight_S", 20537);
1215 }
1216
1217 /***************************************************************************/
1218 /* The nice TCP sharing model designed by Loris Marchal and Henri Casanova */
1219 /***************************************************************************/
1220 /* @TechReport{      rr-lip2002-40, */
1221 /*   author        = {Henri Casanova and Loris Marchal}, */
1222 /*   institution   = {LIP}, */
1223 /*   title         = {A Network Model for Simulation of Grid Application}, */
1224 /*   number        = {2002-40}, */
1225 /*   month         = {oct}, */
1226 /*   year          = {2002} */
1227 /* } */
1228 void surf_network_model_init_CM02(void)
1229 {
1230
1231   if (surf_network_model)
1232     return;
1233
1234   set_update_mechanism();
1235   surf_network_model_init_internal();
1236   net_define_callbacks();
1237   xbt_dynar_push(model_list, &surf_network_model);
1238   network_solve = lmm_solve;
1239
1240   xbt_cfg_setdefault_double(_surf_cfg_set, "network/latency_factor", 1.0);
1241   xbt_cfg_setdefault_double(_surf_cfg_set, "network/bandwidth_factor",
1242                             1.0);
1243   xbt_cfg_setdefault_double(_surf_cfg_set, "network/weight_S", 0.0);
1244 }
1245
1246 /***************************************************************************/
1247 /* The models from Steven H. Low                                           */
1248 /***************************************************************************/
1249 /* @article{Low03,                                                         */
1250 /*   author={Steven H. Low},                                               */
1251 /*   title={A Duality Model of {TCP} and Queue Management Algorithms},     */
1252 /*   year={2003},                                                          */
1253 /*   journal={{IEEE/ACM} Transactions on Networking},                      */
1254 /*    volume={11}, number={4},                                             */
1255 /*  }                                                                      */
1256 void surf_network_model_init_Reno(void)
1257 {
1258   if (surf_network_model)
1259     return;
1260
1261   set_update_mechanism();
1262   surf_network_model_init_internal();
1263   net_define_callbacks();
1264
1265   xbt_dynar_push(model_list, &surf_network_model);
1266   lmm_set_default_protocol_function(func_reno_f, func_reno_fp,
1267                                     func_reno_fpi);
1268   network_solve = lagrange_solve;
1269
1270   xbt_cfg_setdefault_double(_surf_cfg_set, "network/latency_factor", 10.4);
1271   xbt_cfg_setdefault_double(_surf_cfg_set, "network/bandwidth_factor",
1272                             0.92);
1273   xbt_cfg_setdefault_double(_surf_cfg_set, "network/weight_S", 8775);
1274 }
1275
1276
1277 void surf_network_model_init_Reno2(void)
1278 {
1279   if (surf_network_model)
1280     return;
1281
1282   set_update_mechanism();
1283   surf_network_model_init_internal();
1284   net_define_callbacks();
1285
1286   xbt_dynar_push(model_list, &surf_network_model);
1287   lmm_set_default_protocol_function(func_reno2_f, func_reno2_fp,
1288                                     func_reno2_fpi);
1289   network_solve = lagrange_solve;
1290
1291   xbt_cfg_setdefault_double(_surf_cfg_set, "network/latency_factor", 10.4);
1292   xbt_cfg_setdefault_double(_surf_cfg_set, "network/bandwidth_factor",
1293                             0.92);
1294   xbt_cfg_setdefault_double(_surf_cfg_set, "network/weight_S_parameter",
1295                             8775);
1296 }
1297
1298 void surf_network_model_init_Vegas(void)
1299 {
1300   if (surf_network_model)
1301     return;
1302
1303   set_update_mechanism();
1304   surf_network_model_init_internal();
1305   net_define_callbacks();
1306
1307   xbt_dynar_push(model_list, &surf_network_model);
1308   lmm_set_default_protocol_function(func_vegas_f, func_vegas_fp,
1309                                     func_vegas_fpi);
1310   network_solve = lagrange_solve;
1311
1312   xbt_cfg_setdefault_double(_surf_cfg_set, "network/latency_factor", 10.4);
1313   xbt_cfg_setdefault_double(_surf_cfg_set, "network/bandwidth_factor",
1314                             0.92);
1315   xbt_cfg_setdefault_double(_surf_cfg_set, "network/weight_S", 8775);
1316 }