Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
MASSIVE cleanup: s/workstation/host/
[simgrid.git] / src / surf / host_ptask_L07.cpp
1 /* Copyright (c) 2007-2010, 2013-2014. 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 "host_ptask_L07.hpp"
8
9 #include "cpu_interface.hpp"
10 #include "surf_routing.hpp"
11
12 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_host);
13
14 static int ptask_host_count = 0;
15 static xbt_dict_t ptask_parallel_task_link_set = NULL;
16 lmm_system_t ptask_maxmin_system = NULL;
17
18
19 /**************************************/
20 /*** Resource Creation & Destruction **/
21 /**************************************/
22
23 static void ptask_netlink_parse_init(sg_platf_link_cbarg_t link)
24 {
25   netlink_parse_init(link);
26   current_property_set = NULL;
27 }
28
29 static void ptask_define_callbacks()
30 {
31   sg_platf_host_add_cb(cpu_parse_init);
32   sg_platf_host_add_cb(host_parse_init);
33   sg_platf_link_add_cb(ptask_netlink_parse_init);
34   sg_platf_postparse_add_cb(host_add_traces);
35 }
36
37 void surf_host_model_init_ptask_L07(void)
38 {
39   XBT_INFO("surf_host_model_init_ptask_L07");
40   xbt_assert(!surf_cpu_model_pm, "CPU model type already defined");
41   xbt_assert(!surf_network_model, "network model type already defined");
42   ptask_define_callbacks();
43   surf_host_model = new HostL07Model();
44   ModelPtr model = surf_host_model;
45   xbt_dynar_push(model_list, &model);
46   xbt_dynar_push(model_list_invoke, &model);
47 }
48
49
50 HostL07Model::HostL07Model() : HostModel("Host ptask_L07") {
51   if (!ptask_maxmin_system)
52         ptask_maxmin_system = lmm_system_new(1);
53   surf_host_model = NULL;
54   surf_network_model = new NetworkL07Model();
55   surf_cpu_model_pm = new CpuL07Model();
56   routing_model_create(surf_network_model->createNetworkLink("__loopback__",
57                                                           498000000, NULL,
58                                                           0.000015, NULL,
59                                                           SURF_RESOURCE_ON, NULL,
60                                                           SURF_LINK_FATPIPE, NULL));
61   p_cpuModel = surf_cpu_model_pm;
62 }
63
64 HostL07Model::~HostL07Model() {
65   xbt_dict_free(&ptask_parallel_task_link_set);
66
67   delete surf_cpu_model_pm;
68   delete surf_network_model;
69   ptask_host_count = 0;
70
71   if (ptask_maxmin_system) {
72     lmm_system_free(ptask_maxmin_system);
73     ptask_maxmin_system = NULL;
74   }
75 }
76
77 double HostL07Model::shareResources(double /*now*/)
78 {
79   HostL07ActionPtr action;
80
81   ActionListPtr running_actions = getRunningActionSet();
82   double min = this->shareResourcesMaxMin(running_actions,
83                                               ptask_maxmin_system,
84                                               bottleneck_solve);
85
86   for(ActionList::iterator it(running_actions->begin()), itend(running_actions->end())
87          ; it != itend ; ++it) {
88         action = static_cast<HostL07ActionPtr>(&*it);
89     if (action->m_latency > 0) {
90       if (min < 0) {
91         min = action->m_latency;
92         XBT_DEBUG("Updating min (value) with %p (start %f): %f", action,
93                action->getStartTime(), min);
94       } else if (action->m_latency < min) {
95         min = action->m_latency;
96         XBT_DEBUG("Updating min (latency) with %p (start %f): %f", action,
97                action->getStartTime(), min);
98       }
99     }
100   }
101
102   XBT_DEBUG("min value : %f", min);
103
104   return min;
105 }
106
107 void HostL07Model::updateActionsState(double /*now*/, double delta)
108 {
109   double deltap = 0.0;
110   HostL07ActionPtr action;
111
112   ActionListPtr actionSet = getRunningActionSet();
113
114   for(ActionList::iterator it(actionSet->begin()), itNext = it, itend(actionSet->end())
115          ; it != itend ; it=itNext) {
116         ++itNext;
117     action = static_cast<HostL07ActionPtr>(&*it);
118     deltap = delta;
119     if (action->m_latency > 0) {
120       if (action->m_latency > deltap) {
121         double_update(&(action->m_latency), deltap, sg_surf_precision);
122         deltap = 0.0;
123       } else {
124         double_update(&(deltap), action->m_latency, sg_surf_precision);
125         action->m_latency = 0.0;
126       }
127       if ((action->m_latency == 0.0) && (action->isSuspended() == 0)) {
128         action->updateBound();
129         lmm_update_variable_weight(ptask_maxmin_system, action->getVariable(), 1.0);
130       }
131     }
132     XBT_DEBUG("Action (%p) : remains (%g) updated by %g.",
133            action, action->getRemains(), lmm_variable_getvalue(action->getVariable()) * delta);
134     action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta);
135
136     if (action->getMaxDuration() != NO_MAX_DURATION)
137       action->updateMaxDuration(delta);
138
139     XBT_DEBUG("Action (%p) : remains (%g).",
140            action, action->getRemains());
141     if ((action->getRemains() <= 0) &&
142         (lmm_get_variable_weight(action->getVariable()) > 0)) {
143       action->finish();
144       action->setState(SURF_ACTION_DONE);
145     } else if ((action->getMaxDuration() != NO_MAX_DURATION) &&
146                (action->getMaxDuration() <= 0)) {
147       action->finish();
148      action->setState(SURF_ACTION_DONE);
149     } else {
150       /* Need to check that none of the model has failed */
151       lmm_constraint_t cnst = NULL;
152       int i = 0;
153       void *constraint_id = NULL;
154
155       while ((cnst = lmm_get_cnst_from_var(ptask_maxmin_system, action->getVariable(),
156                                     i++))) {
157         constraint_id = lmm_constraint_id(cnst);
158
159         if (static_cast<HostPtr>(constraint_id)->getState() == SURF_RESOURCE_OFF) {
160           XBT_DEBUG("Action (%p) Failed!!", action);
161           action->finish();
162           action->setState(SURF_ACTION_FAILED);
163           break;
164         }
165       }
166     }
167   }
168   return;
169 }
170
171 ActionPtr HostL07Model::executeParallelTask(int host_nb,
172                                                    void **host_list,
173                                                    double *flops_amount,
174                                                                                                    double *bytes_amount,
175                                                    double rate)
176 {
177   HostL07ActionPtr action;
178   int i, j;
179   unsigned int cpt;
180   int nb_link = 0;
181   int nb_host = 0;
182   double latency = 0.0;
183
184   if (ptask_parallel_task_link_set == NULL)
185     ptask_parallel_task_link_set = xbt_dict_new_homogeneous(NULL);
186
187   xbt_dict_reset(ptask_parallel_task_link_set);
188
189   /* Compute the number of affected resources... */
190   for (i = 0; i < host_nb; i++) {
191     for (j = 0; j < host_nb; j++) {
192       xbt_dynar_t route=NULL;
193
194       if (bytes_amount[i * host_nb + j] > 0) {
195         double lat=0.0;
196         unsigned int cpt;
197         void *_link;
198         LinkL07Ptr link;
199
200         routing_platf->getRouteAndLatency(static_cast<HostL07Ptr>(host_list[i])->p_netElm,
201                                                   static_cast<HostL07Ptr>(host_list[j])->p_netElm,
202                                                   &route,
203                                                   &lat);
204         latency = MAX(latency, lat);
205
206         xbt_dynar_foreach(route, cpt, _link) {
207            link = static_cast<LinkL07Ptr>(_link);
208            xbt_dict_set(ptask_parallel_task_link_set, link->getName(), link, NULL);
209         }
210       }
211     }
212   }
213
214   nb_link = xbt_dict_length(ptask_parallel_task_link_set);
215   xbt_dict_reset(ptask_parallel_task_link_set);
216
217   for (i = 0; i < host_nb; i++)
218     if (flops_amount[i] > 0)
219       nb_host++;
220
221   action = new HostL07Action(this, 1, 0);
222   XBT_DEBUG("Creating a parallel task (%p) with %d cpus and %d links.",
223          action, host_nb, nb_link);
224   action->m_suspended = 0;        /* Should be useless because of the
225                                    calloc but it seems to help valgrind... */
226   action->m_hostNb = host_nb;
227   action->p_hostList = (HostPtr *) host_list;
228   action->p_computationAmount = flops_amount;
229   action->p_communicationAmount = bytes_amount;
230   action->m_latency = latency;
231   action->m_rate = rate;
232
233   action->p_variable = lmm_variable_new(ptask_maxmin_system, action, 1.0,
234                        (action->m_rate > 0) ? action->m_rate : -1.0,
235                        host_nb + nb_link);
236
237   if (action->m_latency > 0)
238     lmm_update_variable_weight(ptask_maxmin_system, action->getVariable(), 0.0);
239
240   for (i = 0; i < host_nb; i++)
241     lmm_expand(ptask_maxmin_system,
242                  static_cast<HostL07Ptr>(host_list[i])->p_cpu->getConstraint(),
243                action->getVariable(), flops_amount[i]);
244
245   for (i = 0; i < host_nb; i++) {
246     for (j = 0; j < host_nb; j++) {
247       void *_link;
248       LinkL07Ptr link;
249
250       xbt_dynar_t route=NULL;
251       if (bytes_amount[i * host_nb + j] == 0.0)
252         continue;
253
254       routing_platf->getRouteAndLatency(static_cast<HostL07Ptr>(host_list[i])->p_netElm,
255                                         static_cast<HostL07Ptr>(host_list[j])->p_netElm,
256                                             &route, NULL);
257
258       xbt_dynar_foreach(route, cpt, _link) {
259         link = static_cast<LinkL07Ptr>(_link);
260         lmm_expand_add(ptask_maxmin_system, link->getConstraint(),
261                        action->getVariable(),
262                        bytes_amount[i * host_nb + j]);
263       }
264     }
265   }
266
267   if (nb_link + nb_host == 0) {
268     action->setCost(1.0);
269     action->setRemains(0.0);
270   }
271
272   return action;
273 }
274
275 HostPtr HostL07Model::createHost(const char *name)
276 {
277   HostL07Ptr wk = NULL;
278   xbt_assert(!surf_host_resource_priv(surf_host_resource_by_name(name)),
279               "Host '%s' declared several times in the platform file.",
280               name);
281
282   wk = new HostL07(this, name, NULL,
283                                   static_cast<RoutingEdgePtr>(xbt_lib_get_or_null(host_lib, name, ROUTING_HOST_LEVEL)),
284                                   static_cast<CpuPtr>(xbt_lib_get_or_null(host_lib, name, SURF_CPU_LEVEL)));
285
286   xbt_lib_set(host_lib, name, SURF_HOST_LEVEL, wk);
287
288   return wk;//FIXME:xbt_lib_get_elm_or_null(host_lib, name);
289 }
290
291 ActionPtr HostL07Model::communicate(HostPtr src, HostPtr dst,
292                                        double size, double rate)
293 {
294   void **host_list = xbt_new0(void *, 2);
295   double *flops_amount = xbt_new0(double, 2);
296   double *bytes_amount = xbt_new0(double, 4);
297   ActionPtr res = NULL;
298
299   host_list[0] = src;
300   host_list[1] = dst;
301   bytes_amount[1] = size;
302
303   res = executeParallelTask(2, host_list,
304                                     flops_amount,
305                                     bytes_amount, rate);
306
307   return res;
308 }
309
310 xbt_dynar_t HostL07Model::getRoute(HostPtr src, HostPtr dst)
311 {
312   xbt_dynar_t route=NULL;
313   routing_platf->getRouteAndLatency(src->p_netElm, dst->p_netElm, &route, NULL);
314   return route;
315 }
316
317 CpuPtr CpuL07Model::createCpu(const char *name,  xbt_dynar_t powerPeak,
318                           int pstate, double power_scale,
319                           tmgr_trace_t power_trace, int core,
320                           e_surf_resource_state_t state_initial,
321                           tmgr_trace_t state_trace,
322                           xbt_dict_t cpu_properties)
323 {
324   double power_initial = xbt_dynar_get_as(powerPeak, pstate, double);
325   xbt_dynar_free(&powerPeak);   // kill memory leak
326
327   xbt_assert(!surf_host_resource_priv(surf_host_resource_by_name(name)),
328               "Host '%s' declared several times in the platform file.",
329               name);
330
331   CpuL07Ptr cpu = new CpuL07(this, name, cpu_properties,
332                                      power_initial, power_scale, power_trace,
333                          core, state_initial, state_trace);
334
335   xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu);
336
337   return cpu;
338 }
339
340 NetworkLinkPtr NetworkL07Model::createNetworkLink(const char *name,
341                                  double bw_initial,
342                                  tmgr_trace_t bw_trace,
343                                  double lat_initial,
344                                  tmgr_trace_t lat_trace,
345                                  e_surf_resource_state_t
346                                  state_initial,
347                                  tmgr_trace_t state_trace,
348                                  e_surf_link_sharing_policy_t policy,
349                                  xbt_dict_t properties)
350 {
351   xbt_assert(!xbt_lib_get_or_null(link_lib, name, SURF_LINK_LEVEL),
352                       "Link '%s' declared several times in the platform file.",
353                       name);
354
355   LinkL07Ptr nw_link = new LinkL07(this, name, properties,
356                                        bw_initial, bw_trace,
357                                        lat_initial, lat_trace,
358                                        state_initial, state_trace,
359                                        policy);
360
361   xbt_lib_set(link_lib, name, SURF_LINK_LEVEL, nw_link);
362   return nw_link;
363 }
364
365 void HostL07Model::addTraces()
366 {
367   xbt_dict_cursor_t cursor = NULL;
368   char *trace_name, *elm;
369
370   if (!trace_connect_list_host_avail)
371     return;
372
373   /* Connect traces relative to cpu */
374   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
375     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
376     CpuL07Ptr host = static_cast<CpuL07Ptr>(surf_cpu_resource_priv(surf_cpu_resource_by_name(elm)));
377
378     xbt_assert(host, "Host %s undefined", elm);
379     xbt_assert(trace, "Trace %s undefined", trace_name);
380
381     host->p_stateEvent = tmgr_history_add_trace(history, trace, 0.0, 0, host);
382   }
383
384   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
385     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
386     CpuL07Ptr host = static_cast<CpuL07Ptr>(surf_cpu_resource_priv(surf_cpu_resource_by_name(elm)));
387
388     xbt_assert(host, "Host %s undefined", elm);
389     xbt_assert(trace, "Trace %s undefined", trace_name);
390
391     host->p_powerEvent = tmgr_history_add_trace(history, trace, 0.0, 0, host);
392   }
393
394   /* Connect traces relative to network */
395   xbt_dict_foreach(trace_connect_list_link_avail, cursor, trace_name, elm) {
396     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
397     LinkL07Ptr link = static_cast<LinkL07Ptr>(xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL));
398
399     xbt_assert(link, "Link %s undefined", elm);
400     xbt_assert(trace, "Trace %s undefined", trace_name);
401
402     link->p_stateEvent = tmgr_history_add_trace(history, trace, 0.0, 0, link);
403   }
404
405   xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) {
406     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
407     LinkL07Ptr link = static_cast<LinkL07Ptr>(xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL));
408
409     xbt_assert(link, "Link %s undefined", elm);
410     xbt_assert(trace, "Trace %s undefined", trace_name);
411
412     link->p_bwEvent = tmgr_history_add_trace(history, trace, 0.0, 0, link);
413   }
414
415   xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) {
416     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
417     LinkL07Ptr link = static_cast<LinkL07Ptr>(xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL));
418
419     xbt_assert(link, "Link %s undefined", elm);
420     xbt_assert(trace, "Trace %s undefined", trace_name);
421
422     link->p_latEvent = tmgr_history_add_trace(history, trace, 0.0, 0, link);
423   }
424 }
425
426 /************
427  * Resource *
428  ************/
429
430 HostL07::HostL07(HostModelPtr model, const char* name, xbt_dict_t props, RoutingEdgePtr netElm, CpuPtr cpu)
431   : Host(model, name, props, NULL, netElm, cpu)
432 {
433 }
434
435 double HostL07::getPowerPeakAt(int /*pstate_index*/)
436 {
437         THROW_UNIMPLEMENTED;
438 }
439
440 int HostL07::getNbPstates()
441 {
442         THROW_UNIMPLEMENTED;
443 }
444
445 void HostL07::setPstate(int /*pstate_index*/)
446 {
447         THROW_UNIMPLEMENTED;
448 }
449
450 int HostL07::getPstate()
451 {
452         THROW_UNIMPLEMENTED;
453 }
454
455 double HostL07::getConsumedEnergy()
456 {
457         THROW_UNIMPLEMENTED;
458 }
459
460 CpuL07::CpuL07(CpuL07ModelPtr model, const char* name, xbt_dict_t props,
461                      double power_initial, double power_scale, tmgr_trace_t power_trace,
462                            int core, e_surf_resource_state_t state_initial, tmgr_trace_t state_trace)
463  : Cpu(model, name, props, lmm_constraint_new(ptask_maxmin_system, this, power_initial * power_scale),
464            core, power_initial, power_scale)
465 {
466   xbt_assert(m_powerScale > 0, "Power has to be >0");
467
468   if (power_trace)
469     p_powerEvent = tmgr_history_add_trace(history, power_trace, 0.0, 0, this);
470   else
471     p_powerEvent = NULL;
472
473   setState(state_initial);
474   if (state_trace)
475         p_stateEvent = tmgr_history_add_trace(history, state_trace, 0.0, 0, this);
476 }
477
478 LinkL07::LinkL07(NetworkL07ModelPtr model, const char* name, xbt_dict_t props,
479                          double bw_initial,
480                          tmgr_trace_t bw_trace,
481                          double lat_initial,
482                          tmgr_trace_t lat_trace,
483                          e_surf_resource_state_t state_initial,
484                          tmgr_trace_t state_trace,
485                          e_surf_link_sharing_policy_t policy)
486  : NetworkLink(model, name, props, lmm_constraint_new(ptask_maxmin_system, this, bw_initial), history, state_trace)
487 {
488   m_bwCurrent = bw_initial;
489   if (bw_trace)
490     p_bwEvent = tmgr_history_add_trace(history, bw_trace, 0.0, 0, this);
491
492   setState(state_initial);
493   m_latCurrent = lat_initial;
494
495   if (lat_trace)
496         p_latEvent = tmgr_history_add_trace(history, lat_trace, 0.0, 0, this);
497
498   if (policy == SURF_LINK_FATPIPE)
499         lmm_constraint_shared(getConstraint());
500 }
501
502 bool CpuL07::isUsed(){
503   return lmm_constraint_used(ptask_maxmin_system, getConstraint());
504 }
505
506 bool LinkL07::isUsed(){
507   return lmm_constraint_used(ptask_maxmin_system, getConstraint());
508 }
509
510 void CpuL07::updateState(tmgr_trace_event_t event_type, double value, double /*date*/){
511   XBT_DEBUG("Updating cpu %s (%p) with value %g", getName(), this, value);
512   if (event_type == p_powerEvent) {
513           m_powerScale = value;
514     lmm_update_constraint_bound(ptask_maxmin_system, getConstraint(), m_powerPeak * m_powerScale);
515     if (tmgr_trace_event_free(event_type))
516       p_powerEvent = NULL;
517   } else if (event_type == p_stateEvent) {
518     if (value > 0)
519       setState(SURF_RESOURCE_ON);
520     else
521       setState(SURF_RESOURCE_OFF);
522     if (tmgr_trace_event_free(event_type))
523       p_stateEvent = NULL;
524   } else {
525     XBT_CRITICAL("Unknown event ! \n");
526     xbt_abort();
527   }
528   return;
529 }
530
531 void LinkL07::updateState(tmgr_trace_event_t event_type, double value, double date){
532   XBT_DEBUG("Updating link %s (%p) with value=%f for date=%g", getName(), this, value, date);
533   if (event_type == p_bwEvent) {
534     updateBandwidth(value, date);
535     if (tmgr_trace_event_free(event_type))
536       p_bwEvent = NULL;
537   } else if (event_type == p_latEvent) {
538     updateLatency(value, date);
539     if (tmgr_trace_event_free(event_type))
540       p_latEvent = NULL;
541   } else if (event_type == p_stateEvent) {
542     if (value > 0)
543       setState(SURF_RESOURCE_ON);
544     else
545       setState(SURF_RESOURCE_OFF);
546     if (tmgr_trace_event_free(event_type))
547       p_stateEvent = NULL;
548   } else {
549     XBT_CRITICAL("Unknown event ! \n");
550     xbt_abort();
551   }
552   return;
553 }
554
555 e_surf_resource_state_t HostL07::getState()
556 {
557   return p_cpu->getState();
558 }
559
560 ActionPtr HostL07::execute(double size)
561 {
562   void **host_list = xbt_new0(void *, 1);
563   double *flops_amount = xbt_new0(double, 1);
564   double *bytes_amount = xbt_new0(double, 1);
565
566   host_list[0] = this;
567   bytes_amount[0] = 0.0;
568   flops_amount[0] = size;
569
570   return static_cast<HostL07ModelPtr>(getModel())->executeParallelTask(1, host_list,
571                                               flops_amount,
572                                      bytes_amount, -1);
573 }
574
575 ActionPtr HostL07::sleep(double duration)
576 {
577   HostL07ActionPtr action = NULL;
578
579   XBT_IN("(%s,%g)", getName(), duration);
580
581   action = static_cast<HostL07ActionPtr>(execute(1.0));
582   action->m_maxDuration = duration;
583   action->m_suspended = 2;
584   lmm_update_variable_weight(ptask_maxmin_system, action->getVariable(), 0.0);
585
586   XBT_OUT();
587   return action;
588 }
589
590 double LinkL07::getBandwidth()
591 {
592   return m_bwCurrent;
593 }
594
595 void LinkL07::updateBandwidth(double value, double date)
596 {
597   m_bwCurrent = value;
598   lmm_update_constraint_bound(ptask_maxmin_system, getConstraint(), m_bwCurrent);
599 }
600
601 double LinkL07::getLatency()
602 {
603   return m_latCurrent;
604 }
605
606 void LinkL07::updateLatency(double value, double date)
607 {
608   lmm_variable_t var = NULL;
609   HostL07ActionPtr action;
610   lmm_element_t elem = NULL;
611
612   m_latCurrent = value;
613   while ((var = lmm_get_var_from_cnst(ptask_maxmin_system, getConstraint(), &elem))) {
614     action = (HostL07ActionPtr) lmm_variable_id(var);
615     action->updateBound();
616   }
617 }
618
619
620 bool LinkL07::isShared()
621 {
622   return lmm_constraint_is_shared(getConstraint());
623 }
624
625 /**********
626  * Action *
627  **********/
628
629 HostL07Action::~HostL07Action(){
630   free(p_hostList);
631   free(p_communicationAmount);
632   free(p_computationAmount);
633 }
634
635 void HostL07Action::updateBound()
636 {
637   double lat_current = 0.0;
638   double lat_bound = -1.0;
639   int i, j;
640
641   for (i = 0; i < m_hostNb; i++) {
642     for (j = 0; j < m_hostNb; j++) {
643       xbt_dynar_t route=NULL;
644
645       if (p_communicationAmount[i * m_hostNb + j] > 0) {
646         double lat = 0.0;
647         routing_platf->getRouteAndLatency(static_cast<HostL07Ptr>(((void**)p_hostList)[i])->p_netElm,
648                                           static_cast<HostL07Ptr>(((void**)p_hostList)[j])->p_netElm,
649                                                           &route, &lat);
650
651         lat_current = MAX(lat_current, lat * p_communicationAmount[i * m_hostNb + j]);
652       }
653     }
654   }
655   lat_bound = sg_tcp_gamma / (2.0 * lat_current);
656   XBT_DEBUG("action (%p) : lat_bound = %g", this, lat_bound);
657   if ((m_latency == 0.0) && (m_suspended == 0)) {
658     if (m_rate < 0)
659       lmm_update_variable_bound(ptask_maxmin_system, getVariable(), lat_bound);
660     else
661       lmm_update_variable_bound(ptask_maxmin_system, getVariable(), min(m_rate, lat_bound));
662   }
663 }
664
665 int HostL07Action::unref()
666 {
667   m_refcount--;
668   if (!m_refcount) {
669     if (actionHook::is_linked())
670           p_stateSet->erase(p_stateSet->iterator_to(*this));
671     if (getVariable())
672       lmm_variable_free(ptask_maxmin_system, getVariable());
673     delete this;
674     return 1;
675   }
676   return 0;
677 }
678
679 void HostL07Action::cancel()
680 {
681   setState(SURF_ACTION_FAILED);
682   return;
683 }
684
685 void HostL07Action::suspend()
686 {
687   XBT_IN("(%p))", this);
688   if (m_suspended != 2) {
689     m_suspended = 1;
690     lmm_update_variable_weight(ptask_maxmin_system, getVariable(), 0.0);
691   }
692   XBT_OUT();
693 }
694
695 void HostL07Action::resume()
696 {
697   XBT_IN("(%p)", this);
698   if (m_suspended != 2) {
699     lmm_update_variable_weight(ptask_maxmin_system, getVariable(), 1.0);
700     m_suspended = 0;
701   }
702   XBT_OUT();
703 }
704
705 bool HostL07Action::isSuspended()
706 {
707   return m_suspended == 1;
708 }
709
710 void HostL07Action::setMaxDuration(double duration)
711 {                               /* FIXME: should inherit */
712   XBT_IN("(%p,%g)", this, duration);
713   m_maxDuration = duration;
714   XBT_OUT();
715 }
716
717 void HostL07Action::setPriority(double priority)
718 {                               /* FIXME: should inherit */
719   XBT_IN("(%p,%g)", this, priority);
720   m_priority = priority;
721   XBT_OUT();
722 }
723
724 double HostL07Action::getRemains()
725 {
726   XBT_IN("(%p)", this);
727   XBT_OUT();
728   return m_remains;
729 }