Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cleanups in the API and fields of NetCard
[simgrid.git] / src / surf / network_cm02.cpp
1 /* Copyright (c) 2013-2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include <algorithm>
8
9 #include "network_cm02.hpp"
10 #include "maxmin_private.hpp"
11 #include "simgrid/sg_config.h"
12 #include "src/surf/platform.hpp"
13
14 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_network);
15
16 double sg_sender_gap = 0.0;
17 double sg_latency_factor = 1.0; /* default value; can be set by model or from command line */
18 double sg_bandwidth_factor = 1.0;       /* default value; can be set by model or from command line */
19 double sg_weight_S_parameter = 0.0;     /* default value; can be set by model or from command line */
20
21 double sg_tcp_gamma = 0.0;
22 int sg_network_crosstraffic = 0;
23
24 /*************
25  * CallBacks *
26  *************/
27
28 void net_define_callbacks(void)
29 {
30   /* Figuring out the network links */
31   simgrid::surf::on_link.connect(netlink_parse_init);
32 }
33
34 /*********
35  * Model *
36  *********/
37
38 /************************************************************************/
39 /* New model based on optimizations discussed during Pedro Velho's thesis*/
40 /************************************************************************/
41 /* @techreport{VELHO:2011:HAL-00646896:1, */
42 /*      url = {http://hal.inria.fr/hal-00646896/en/}, */
43 /*      title = {{Flow-level network models: have we reached the limits?}}, */
44 /*      author = {Velho, Pedro and Schnorr, Lucas and Casanova, Henri and Legrand, Arnaud}, */
45 /*      type = {Rapport de recherche}, */
46 /*      institution = {INRIA}, */
47 /*      number = {RR-7821}, */
48 /*      year = {2011}, */
49 /*      month = Nov, */
50 /*      pdf = {http://hal.inria.fr/hal-00646896/PDF/rr-validity.pdf}, */
51 /*  } */
52 void surf_network_model_init_LegrandVelho(void)
53 {
54   if (surf_network_model)
55     return;
56
57   surf_network_model = new simgrid::surf::NetworkCm02Model();
58   net_define_callbacks();
59   simgrid::surf::Model *model = surf_network_model;
60   xbt_dynar_push(all_existing_models, &model);
61
62   xbt_cfg_setdefault_double(_sg_cfg_set, "network/latency_factor",
63                             13.01);
64   xbt_cfg_setdefault_double(_sg_cfg_set, "network/bandwidth_factor",
65                             0.97);
66   xbt_cfg_setdefault_double(_sg_cfg_set, "network/weight_S", 20537);
67 }
68
69 /***************************************************************************/
70 /* The nice TCP sharing model designed by Loris Marchal and Henri Casanova */
71 /***************************************************************************/
72 /* @TechReport{      rr-lip2002-40, */
73 /*   author        = {Henri Casanova and Loris Marchal}, */
74 /*   institution   = {LIP}, */
75 /*   title         = {A Network Model for Simulation of Grid Application}, */
76 /*   number        = {2002-40}, */
77 /*   month         = {oct}, */
78 /*   year          = {2002} */
79 /* } */
80 void surf_network_model_init_CM02(void)
81 {
82
83   if (surf_network_model)
84     return;
85
86   surf_network_model = new simgrid::surf::NetworkCm02Model();
87   xbt_dynar_push(all_existing_models, &surf_network_model);
88   net_define_callbacks();
89
90   xbt_cfg_setdefault_double(_sg_cfg_set, "network/latency_factor", 1.0);
91   xbt_cfg_setdefault_double(_sg_cfg_set, "network/bandwidth_factor", 1.0);
92   xbt_cfg_setdefault_double(_sg_cfg_set, "network/weight_S", 0.0);
93 }
94
95 /***************************************************************************/
96 /* The models from Steven H. Low                                           */
97 /***************************************************************************/
98 /* @article{Low03,                                                         */
99 /*   author={Steven H. Low},                                               */
100 /*   title={A Duality Model of {TCP} and Queue Management Algorithms},     */
101 /*   year={2003},                                                          */
102 /*   journal={{IEEE/ACM} Transactions on Networking},                      */
103 /*    volume={11}, number={4},                                             */
104 /*  }                                                                      */
105 void surf_network_model_init_Reno(void)
106 {
107   if (surf_network_model)
108     return;
109
110   surf_network_model = new simgrid::surf::NetworkCm02Model();
111   xbt_dynar_push(all_existing_models, &surf_network_model);
112   net_define_callbacks();
113   lmm_set_default_protocol_function(func_reno_f, func_reno_fp, func_reno_fpi);
114   surf_network_model->f_networkSolve = lagrange_solve;
115
116   xbt_cfg_setdefault_double(_sg_cfg_set, "network/latency_factor", 10.4);
117   xbt_cfg_setdefault_double(_sg_cfg_set, "network/bandwidth_factor", 0.92);
118   xbt_cfg_setdefault_double(_sg_cfg_set, "network/weight_S", 8775);
119 }
120
121
122 void surf_network_model_init_Reno2(void)
123 {
124   if (surf_network_model)
125     return;
126
127   surf_network_model = new simgrid::surf::NetworkCm02Model();
128   xbt_dynar_push(all_existing_models, &surf_network_model);
129   net_define_callbacks();
130   lmm_set_default_protocol_function(func_reno2_f, func_reno2_fp, func_reno2_fpi);
131   surf_network_model->f_networkSolve = lagrange_solve;
132
133   xbt_cfg_setdefault_double(_sg_cfg_set, "network/latency_factor", 10.4);
134   xbt_cfg_setdefault_double(_sg_cfg_set, "network/bandwidth_factor", 0.92);
135   xbt_cfg_setdefault_double(_sg_cfg_set, "network/weight_S", 8775);
136 }
137
138 void surf_network_model_init_Vegas(void)
139 {
140   if (surf_network_model)
141     return;
142
143   surf_network_model = new simgrid::surf::NetworkCm02Model();
144   xbt_dynar_push(all_existing_models, &surf_network_model);
145   net_define_callbacks();
146   lmm_set_default_protocol_function(func_vegas_f, func_vegas_fp, func_vegas_fpi);
147   surf_network_model->f_networkSolve = lagrange_solve;
148
149   xbt_cfg_setdefault_double(_sg_cfg_set, "network/latency_factor", 10.4);
150   xbt_cfg_setdefault_double(_sg_cfg_set, "network/bandwidth_factor", 0.92);
151   xbt_cfg_setdefault_double(_sg_cfg_set, "network/weight_S", 8775);
152 }
153
154 namespace simgrid {
155 namespace surf {
156
157 NetworkCm02Model::NetworkCm02Model()
158   :NetworkModel()
159 {
160   char *optim = xbt_cfg_get_string(_sg_cfg_set, "network/optim");
161   int select = xbt_cfg_get_boolean(_sg_cfg_set, "network/maxmin_selective_update");
162
163   if (!strcmp(optim, "Full")) {
164     p_updateMechanism = UM_FULL;
165     m_selectiveUpdate = select;
166   } else if (!strcmp(optim, "Lazy")) {
167     p_updateMechanism = UM_LAZY;
168     m_selectiveUpdate = 1;
169     xbt_assert((select == 1) || (xbt_cfg_is_default_value(_sg_cfg_set, "network/maxmin_selective_update")),
170                "Disabling selective update while using the lazy update mechanism is dumb!");
171   } else {
172     xbt_die("Unsupported optimization (%s) for this model", optim);
173   }
174
175   if (!p_maxminSystem)
176     p_maxminSystem = lmm_system_new(m_selectiveUpdate);
177
178   routing_model_create(createLink("__loopback__",
179                                 498000000, NULL, 0.000015, NULL,
180                                 1 /*SURF_RESOURCE_ON*/, NULL,
181                                 SURF_LINK_FATPIPE, NULL));
182
183   if (p_updateMechanism == UM_LAZY) {
184   p_actionHeap = xbt_heap_new(8, NULL);
185   xbt_heap_set_update_callback(p_actionHeap, surf_action_lmm_update_index_heap);
186   p_modifiedSet = new ActionLmmList();
187   p_maxminSystem->keep_track = p_modifiedSet;
188   }
189 }
190
191 Link* NetworkCm02Model::createLink(const char *name,
192                                  double bw_initial,
193                                  tmgr_trace_t bw_trace,
194                                  double lat_initial,
195                                  tmgr_trace_t lat_trace,
196                                  int initiallyOn,
197                                  tmgr_trace_t state_trace,
198                                  e_surf_link_sharing_policy_t policy,
199                                  xbt_dict_t properties)
200 {
201   xbt_assert(NULL == Link::byName(name),
202              "Link '%s' declared several times in the platform",
203              name);
204
205   Link* link = new NetworkCm02Link(this, name, properties, p_maxminSystem, sg_bandwidth_factor * bw_initial,
206                      initiallyOn, state_trace, bw_initial, bw_trace, lat_initial, lat_trace, policy);
207   Link::onCreation(link);
208   return link;
209 }
210
211 void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/)
212 {
213   NetworkCm02Action *action;
214   while ((xbt_heap_size(p_actionHeap) > 0)
215          && (double_equals(xbt_heap_maxkey(p_actionHeap), now, sg_surf_precision))) {
216     action = static_cast<NetworkCm02Action*> (xbt_heap_pop(p_actionHeap));
217     XBT_DEBUG("Something happened to action %p", action);
218     if (TRACE_is_enabled()) {
219       int n = lmm_get_number_of_cnst_from_var(p_maxminSystem, action->getVariable());
220       int i;
221       for (i = 0; i < n; i++){
222         lmm_constraint_t constraint = lmm_get_cnst_from_var(p_maxminSystem,
223                                                             action->getVariable(),
224                                                             i);
225         NetworkCm02Link *link = static_cast<NetworkCm02Link*>(lmm_constraint_id(constraint));
226         TRACE_surf_link_set_utilization(link->getName(),
227                                         action->getCategory(),
228                                         (lmm_variable_getvalue(action->getVariable())*
229                                             lmm_get_cnst_weight_from_var(p_maxminSystem,
230                                                 action->getVariable(),
231                                                 i)),
232                                         action->getLastUpdate(),
233                                         now - action->getLastUpdate());
234       }
235     }
236
237     // if I am wearing a latency hat
238     if (action->getHat() == LATENCY) {
239       XBT_DEBUG("Latency paid for action %p. Activating", action);
240       lmm_update_variable_weight(p_maxminSystem, action->getVariable(), action->m_weight);
241       action->heapRemove(p_actionHeap);
242       action->refreshLastUpdate();
243
244         // if I am wearing a max_duration or normal hat
245     } else if (action->getHat() == MAX_DURATION ||
246         action->getHat() == NORMAL) {
247         // no need to communicate anymore
248         // assume that flows that reached max_duration have remaining of 0
249       XBT_DEBUG("Action %p finished", action);
250       action->setRemains(0);
251       action->finish();
252       action->setState(SURF_ACTION_DONE);
253       action->heapRemove(p_actionHeap);
254
255       action->gapRemove();
256     }
257   }
258   return;
259 }
260
261
262 void NetworkCm02Model::updateActionsStateFull(double now, double delta)
263 {
264   NetworkCm02Action *action;
265   ActionList *running_actions = getRunningActionSet();
266
267   for(ActionList::iterator it(running_actions->begin()), itNext=it, itend(running_actions->end())
268      ; it != itend ; it=itNext) {
269   ++itNext;
270
271     action = static_cast<NetworkCm02Action*> (&*it);
272     XBT_DEBUG("Something happened to action %p", action);
273       double deltap = delta;
274       if (action->m_latency > 0) {
275         if (action->m_latency > deltap) {
276           double_update(&(action->m_latency), deltap, sg_surf_precision);
277           deltap = 0.0;
278         } else {
279           double_update(&(deltap), action->m_latency, sg_surf_precision);
280           action->m_latency = 0.0;
281         }
282         if (action->m_latency == 0.0 && !(action->isSuspended()))
283           lmm_update_variable_weight(p_maxminSystem, action->getVariable(),
284               action->m_weight);
285       }
286       if (TRACE_is_enabled()) {
287         int n = lmm_get_number_of_cnst_from_var(p_maxminSystem, action->getVariable());
288         int i;
289         for (i = 0; i < n; i++){
290           lmm_constraint_t constraint = lmm_get_cnst_from_var(p_maxminSystem,
291                                                             action->getVariable(),
292                                                             i);
293           NetworkCm02Link* link = static_cast<NetworkCm02Link*>(lmm_constraint_id(constraint));
294           TRACE_surf_link_set_utilization(link->getName(),
295                                         action->getCategory(),
296                                         (lmm_variable_getvalue(action->getVariable())*
297                                             lmm_get_cnst_weight_from_var(p_maxminSystem,
298                                                 action->getVariable(),
299                                                 i)),
300                                         action->getLastUpdate(),
301                                         now - action->getLastUpdate());
302         }
303       }
304       if (!lmm_get_number_of_cnst_from_var
305           (p_maxminSystem, action->getVariable())) {
306         /* There is actually no link used, hence an infinite bandwidth.
307          * This happens often when using models like vivaldi.
308          * In such case, just make sure that the action completes immediately.
309          */
310         action->updateRemains(action->getRemains());
311       }
312     action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta);
313                   
314     if (action->getMaxDuration() != NO_MAX_DURATION)
315       action->updateMaxDuration(delta);
316       
317     if ((action->getRemains() <= 0) &&
318         (lmm_get_variable_weight(action->getVariable()) > 0)) {
319       action->finish();
320       action->setState(SURF_ACTION_DONE);
321       action->gapRemove();
322     } else if (((action->getMaxDuration() != NO_MAX_DURATION)
323         && (action->getMaxDuration() <= 0))) {
324       action->finish();
325       action->setState(SURF_ACTION_DONE);
326       action->gapRemove();
327     }
328   }
329   return;
330 }
331
332 Action *NetworkCm02Model::communicate(NetCard *src, NetCard *dst,
333                                                 double size, double rate)
334 {
335   unsigned int i;
336   void *_link;
337   NetworkCm02Link *link;
338   int failed = 0;
339   NetworkCm02Action *action = NULL;
340   double bandwidth_bound;
341   double latency = 0.0;
342   xbt_dynar_t back_route = NULL;
343   int constraints_per_variable = 0;
344
345   xbt_dynar_t route = xbt_dynar_new(sizeof(NetCard*), NULL);
346
347   XBT_IN("(%s,%s,%g,%g)", src->name(), dst->name(), size, rate);
348
349   routing_platf->getRouteAndLatency(src, dst, &route, &latency);
350   xbt_assert(!xbt_dynar_is_empty(route) || latency,
351              "You're trying to send data from %s to %s but there is no connecting path between these two hosts.",
352              src->name(), dst->name());
353
354   xbt_dynar_foreach(route, i, _link) {
355   link = static_cast<NetworkCm02Link*>(_link);
356     if (link->isOff()) {
357       failed = 1;
358       break;
359     }
360   }
361   if (sg_network_crosstraffic == 1) {
362     routing_platf->getRouteAndLatency(dst, src, &back_route, NULL);
363     xbt_dynar_foreach(back_route, i, _link) {
364       link = static_cast<NetworkCm02Link*>(_link);
365       if (link->isOff()) {
366         failed = 1;
367         break;
368       }
369     }
370   }
371
372   action = new NetworkCm02Action(this, size, failed);
373
374 #ifdef HAVE_LATENCY_BOUND_TRACKING
375   action->m_latencyLimited = 0;
376 #endif
377   action->m_weight = action->m_latency = latency;
378
379   action->m_rate = rate;
380   if (p_updateMechanism == UM_LAZY) {
381     action->m_indexHeap = -1;
382     action->m_lastUpdate = surf_get_clock();
383   }
384
385   bandwidth_bound = -1.0;
386   if (sg_weight_S_parameter > 0) {
387     xbt_dynar_foreach(route, i, _link) {
388       link = static_cast<NetworkCm02Link*>(_link);
389       action->m_weight += sg_weight_S_parameter / link->getBandwidth();
390     }
391   }
392   xbt_dynar_foreach(route, i, _link) {
393   link = static_cast<NetworkCm02Link*>(_link);
394     double bb = bandwidthFactor(size) * link->getBandwidth();
395     bandwidth_bound =
396         (bandwidth_bound < 0.0) ? bb : std::min(bandwidth_bound, bb);
397   }
398
399   action->m_latCurrent = action->m_latency;
400   action->m_latency *= latencyFactor(size);
401   action->m_rate = bandwidthConstraint(action->m_rate, bandwidth_bound, size);
402   if (m_haveGap) {
403     xbt_assert(!xbt_dynar_is_empty(route),
404                "Using a model with a gap (e.g., SMPI) with a platform without links (e.g. vivaldi)!!!");
405
406     link = *static_cast<NetworkCm02Link **>(xbt_dynar_get_ptr(route, 0));
407     gapAppend(size, link, action);
408     XBT_DEBUG("Comm %p: %s -> %s gap=%f (lat=%f)",
409               action, src->name(), dst->name(), action->m_senderGap,
410               action->m_latency);
411   }
412
413   constraints_per_variable = xbt_dynar_length(route);
414   if (back_route != NULL)
415     constraints_per_variable += xbt_dynar_length(back_route);
416
417   if (action->m_latency > 0) {
418     action->p_variable = lmm_variable_new(p_maxminSystem, action, 0.0, -1.0,
419                          constraints_per_variable);
420     if (p_updateMechanism == UM_LAZY) {
421       // add to the heap the event when the latency is payed
422       XBT_DEBUG("Added action (%p) one latency event at date %f", action,
423                 action->m_latency + action->m_lastUpdate);
424       action->heapInsert(p_actionHeap, action->m_latency + action->m_lastUpdate, xbt_dynar_is_empty(route) ? NORMAL : LATENCY);
425     }
426   } else
427     action->p_variable = lmm_variable_new(p_maxminSystem, action, 1.0, -1.0, constraints_per_variable);
428
429   if (action->m_rate < 0) {
430     lmm_update_variable_bound(p_maxminSystem, action->getVariable(), (action->m_latCurrent > 0) ? sg_tcp_gamma / (2.0 * action->m_latCurrent) : -1.0);
431   } else {
432     lmm_update_variable_bound(p_maxminSystem, action->getVariable(), (action->m_latCurrent > 0) ? std::min(action->m_rate, sg_tcp_gamma / (2.0 * action->m_latCurrent)) : action->m_rate);
433   }
434
435   xbt_dynar_foreach(route, i, _link) {
436   link = static_cast<NetworkCm02Link*>(_link);
437     lmm_expand(p_maxminSystem, link->getConstraint(), action->getVariable(), 1.0);
438   }
439
440   if (sg_network_crosstraffic == 1) {
441     XBT_DEBUG("Fullduplex active adding backward flow using 5%%");
442     xbt_dynar_foreach(back_route, i, _link) {
443       link = static_cast<NetworkCm02Link*>(_link);
444       lmm_expand(p_maxminSystem, link->getConstraint(), action->getVariable(), .05);
445     }
446     lmm_variable_concurrency_share_set(action->getVariable(),2);
447   }
448
449   xbt_dynar_free(&route);
450   XBT_OUT();
451
452   networkCommunicateCallbacks(action, src, dst, size, rate);
453   return action;
454 }
455
456 /************
457  * Resource *
458  ************/
459 NetworkCm02Link::NetworkCm02Link(NetworkCm02Model *model, const char *name, xbt_dict_t props,
460                              lmm_system_t system,
461                              double constraint_value,
462                              int initiallyOn, tmgr_trace_t state_trace,
463                              double bw_peak, tmgr_trace_t bw_trace,
464                              double lat_initial, tmgr_trace_t lat_trace,
465                              e_surf_link_sharing_policy_t policy)
466 : Link(model, name, props, lmm_constraint_new(system, this, constraint_value), state_trace)
467 {
468   if (initiallyOn)
469     turnOn();
470   else
471     turnOff();
472
473   m_bandwidth.scale = 1.0;
474   m_bandwidth.peak = bw_peak;
475   if (bw_trace)
476     m_bandwidth.event = future_evt_set->add_trace(bw_trace, 0.0, this);
477   else
478     m_bandwidth.event = NULL;
479
480   m_latency.scale = 1.0;
481   m_latency.peak = lat_initial;
482   if (lat_trace)
483     m_latency.event = future_evt_set->add_trace(lat_trace, 0.0, this);
484
485   if (policy == SURF_LINK_FATPIPE)
486   lmm_constraint_shared(getConstraint());
487 }
488
489
490
491 void NetworkCm02Link::apply_event(tmgr_trace_iterator_t triggered, double value)
492 {
493
494   /* Find out which of my iterators was triggered, and react accordingly */
495   if (triggered == m_bandwidth.event) {
496     updateBandwidth(value);
497     tmgr_trace_event_unref(&m_bandwidth.event);
498
499   } else if (triggered == m_latency.event) {
500     updateLatency(value);
501     tmgr_trace_event_unref(&m_latency.event);
502
503   } else if (triggered == m_stateEvent) {
504     if (value > 0)
505       turnOn();
506     else {
507       lmm_variable_t var = NULL;
508       lmm_element_t elem = NULL;
509       double now = surf_get_clock();
510
511       turnOff();
512       while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), getConstraint(), &elem))) {
513         Action *action = static_cast<Action*>( lmm_variable_id(var) );
514
515         if (action->getState() == SURF_ACTION_RUNNING ||
516             action->getState() == SURF_ACTION_READY) {
517           action->setFinishTime(now);
518           action->setState(SURF_ACTION_FAILED);
519         }
520       }
521     }
522     tmgr_trace_event_unref(&m_stateEvent);
523   } else {
524     xbt_die("Unknown event!\n");
525   }
526
527   XBT_DEBUG
528       ("There was a resource state event, need to update actions related to the constraint (%p)",
529        getConstraint());
530 }
531
532 void NetworkCm02Link::updateBandwidth(double value) {
533   double delta = sg_weight_S_parameter / value - sg_weight_S_parameter /
534                  (m_bandwidth.peak * m_bandwidth.scale);
535   lmm_variable_t var = NULL;
536   lmm_element_t elem = NULL;
537   lmm_element_t nextelem = NULL;
538   int numelem = 0;
539
540   NetworkCm02Action *action = NULL;
541
542   m_bandwidth.peak = value;
543   lmm_update_constraint_bound(getModel()->getMaxminSystem(),
544                               getConstraint(),
545                               sg_bandwidth_factor *
546                               (m_bandwidth.peak * m_bandwidth.scale));
547   TRACE_surf_link_set_bandwidth(surf_get_clock(), getName(), sg_bandwidth_factor * m_bandwidth.peak * m_bandwidth.scale);
548   if (sg_weight_S_parameter > 0) {
549     while ((var = lmm_get_var_from_cnst_safe(getModel()->getMaxminSystem(), getConstraint(), &elem, &nextelem, &numelem))) {
550       action = (NetworkCm02Action*) lmm_variable_id(var);
551       action->m_weight += delta;
552       if (!action->isSuspended())
553         lmm_update_variable_weight(getModel()->getMaxminSystem(), action->getVariable(), action->m_weight);
554     }
555   }
556 }
557
558 void NetworkCm02Link::updateLatency(double value){
559   double delta = value - m_latency.peak;
560   lmm_variable_t var = NULL;
561   lmm_element_t elem = NULL;
562   lmm_element_t nextelem = NULL;
563   int numelem = 0;
564   NetworkCm02Action *action = NULL;
565
566   m_latency.peak = value;
567   while ((var = lmm_get_var_from_cnst_safe(getModel()->getMaxminSystem(), getConstraint(), &elem, &nextelem, &numelem))) {
568     action = (NetworkCm02Action*) lmm_variable_id(var);
569     action->m_latCurrent += delta;
570     action->m_weight += delta;
571     if (action->m_rate < 0)
572       lmm_update_variable_bound(getModel()->getMaxminSystem(), action->getVariable(), sg_tcp_gamma / (2.0 * action->m_latCurrent));
573     else {
574       lmm_update_variable_bound(getModel()->getMaxminSystem(), action->getVariable(),
575                                 std::min(action->m_rate, sg_tcp_gamma / (2.0 * action->m_latCurrent)));
576
577       if (action->m_rate < sg_tcp_gamma / (2.0 * action->m_latCurrent)) {
578         XBT_INFO("Flow is limited BYBANDWIDTH");
579       } else {
580         XBT_INFO("Flow is limited BYLATENCY, latency of flow is %f",
581                  action->m_latCurrent);
582       }
583     }
584     if (!action->isSuspended())
585       lmm_update_variable_weight(getModel()->getMaxminSystem(), action->getVariable(), action->m_weight);
586   }
587 }
588
589 /**********
590  * Action *
591  **********/
592 void NetworkCm02Action::updateRemainingLazy(double now)
593 {
594   double delta = 0.0;
595
596   if (m_suspended != 0)
597     return;
598
599   delta = now - m_lastUpdate;
600
601   if (m_remains > 0) {
602     XBT_DEBUG("Updating action(%p): remains was %f, last_update was: %f", this, m_remains, m_lastUpdate);
603     double_update(&(m_remains), m_lastValue * delta, sg_maxmin_precision*sg_surf_precision);
604
605     XBT_DEBUG("Updating action(%p): remains is now %f", this, m_remains);
606   }
607
608   if (m_maxDuration != NO_MAX_DURATION)
609     double_update(&m_maxDuration, delta, sg_surf_precision);
610
611   if (m_remains <= 0 &&
612       (lmm_get_variable_weight(getVariable()) > 0)) {
613     finish();
614     setState(SURF_ACTION_DONE);
615
616     heapRemove(getModel()->getActionHeap());
617   } else if (((m_maxDuration != NO_MAX_DURATION)
618       && (m_maxDuration <= 0))) {
619     finish();
620     setState(SURF_ACTION_DONE);
621     heapRemove(getModel()->getActionHeap());
622   }
623
624   m_lastUpdate = now;
625   m_lastValue = lmm_variable_getvalue(getVariable());
626 }
627
628 }
629 }