Logo AND Algorithmique Numérique Distribuée

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