Logo AND Algorithmique Numérique Distribuée

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