Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use std::vector for s_lmm_element_t::cnsts.
[simgrid.git] / src / surf / cpu_ti.cpp
1 /* Copyright (c) 2013-2017. 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 "cpu_ti.hpp"
8 #include "src/surf/trace_mgr.hpp"
9
10 #ifndef SURF_MODEL_CPUTI_H_
11 #define SURF_MODEL_CPUTI_H_
12
13 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu_ti, surf_cpu, "Logging specific to the SURF CPU TRACE INTEGRATION module");
14
15 namespace simgrid {
16 namespace surf {
17
18 /*********
19  * Trace *
20  *********/
21
22 CpuTiTrace::CpuTiTrace(tmgr_trace_t speedTrace)
23 {
24   double integral = 0;
25   double time = 0;
26   int i = 0;
27   nbPoints_ = speedTrace->event_list.size() + 1;
28   timePoints_ = new double[nbPoints_];
29   integral_ =  new double[nbPoints_];
30   for (auto const& val : speedTrace->event_list) {
31     timePoints_[i] = time;
32     integral_[i] = integral;
33     integral += val.date_ * val.value_;
34     time += val.date_;
35     i++;
36   }
37   timePoints_[i] = time;
38   integral_[i] = integral;
39 }
40
41 CpuTiTrace::~CpuTiTrace()
42 {
43   delete [] timePoints_;
44   delete [] integral_;
45 }
46
47 CpuTiTgmr::~CpuTiTgmr()
48 {
49   if (trace_)
50     delete trace_;
51 }
52
53 /**
54 * \brief Integrate trace
55 *
56 * Wrapper around surf_cpu_integrate_trace_simple() to get
57 * the cyclic effect.
58 *
59 * \param a      Begin of interval
60 * \param b      End of interval
61 * \return the integrate value. -1 if an error occurs.
62 */
63 double CpuTiTgmr::integrate(double a, double b)
64 {
65   int a_index;
66
67   if ((a < 0.0) || (a > b)) {
68     xbt_die("Error, invalid integration interval [%.2f,%.2f]. "
69         "You probably have a task executing with negative computation amount. Check your code.", a, b);
70   }
71   if (fabs(a -b) < EPSILON)
72     return 0.0;
73
74   if (type_ == TRACE_FIXED) {
75     return ((b - a) * value_);
76   }
77
78   if (fabs(ceil(a / lastTime_) - a / lastTime_) < EPSILON)
79     a_index = 1 + static_cast<int>(ceil(a / lastTime_));
80   else
81     a_index = static_cast<int> (ceil(a / lastTime_));
82
83   int b_index = static_cast<int> (floor(b / lastTime_));
84
85   if (a_index > b_index) {      /* Same chunk */
86     return trace_->integrateSimple(a - (a_index - 1) * lastTime_, b - (b_index) * lastTime_);
87   }
88
89   double first_chunk = trace_->integrateSimple(a - (a_index - 1) * lastTime_, lastTime_);
90   double middle_chunk = (b_index - a_index) * total_;
91   double last_chunk = trace_->integrateSimple(0.0, b - (b_index) * lastTime_);
92
93   XBT_DEBUG("first_chunk=%.2f  middle_chunk=%.2f  last_chunk=%.2f\n", first_chunk, middle_chunk, last_chunk);
94
95   return (first_chunk + middle_chunk + last_chunk);
96 }
97
98 /**
99  * \brief Auxiliary function to compute the integral between a and b.
100  *     It simply computes the integrals at point a and b and returns the difference between them.
101  * \param a  Initial point
102  * \param b  Final point
103 */
104 double CpuTiTrace::integrateSimple(double a, double b)
105 {
106   return integrateSimplePoint(b) - integrateSimplePoint(a);
107 }
108
109 /**
110  * \brief Auxiliary function to compute the integral at point a.
111  * \param a        point
112  */
113 double CpuTiTrace::integrateSimplePoint(double a)
114 {
115   double integral = 0;
116   double a_aux = a;
117   int ind = binarySearch(timePoints_, a, 0, nbPoints_ - 1);
118   integral += integral_[ind];
119
120   XBT_DEBUG("a %f ind %d integral %f ind + 1 %f ind %f time +1 %f time %f",
121        a, ind, integral, integral_[ind + 1], integral_[ind], timePoints_[ind + 1], timePoints_[ind]);
122   double_update(&a_aux, timePoints_[ind], sg_maxmin_precision*sg_surf_precision);
123   if (a_aux > 0)
124     integral += ((integral_[ind + 1] - integral_[ind]) / (timePoints_[ind + 1] - timePoints_[ind])) *
125                 (a - timePoints_[ind]);
126   XBT_DEBUG("Integral a %f = %f", a, integral);
127
128   return integral;
129 }
130
131 /**
132 * \brief Computes the time needed to execute "amount" on cpu.
133 *
134 * Here, amount can span multiple trace periods
135 *
136 * \param a        Initial time
137 * \param amount  Amount to be executed
138 * \return  End time
139 */
140 double CpuTiTgmr::solve(double a, double amount)
141 {
142   /* Fix very small negative numbers */
143   if ((a < 0.0) && (a > -EPSILON)) {
144     a = 0.0;
145   }
146   if ((amount < 0.0) && (amount > -EPSILON)) {
147     amount = 0.0;
148   }
149
150   /* Sanity checks */
151   if ((a < 0.0) || (amount < 0.0)) {
152     XBT_CRITICAL ("Error, invalid parameters [a = %.2f, amount = %.2f]. "
153         "You probably have a task executing with negative computation amount. Check your code.", a, amount);
154     xbt_abort();
155   }
156
157   /* At this point, a and amount are positive */
158   if (amount < EPSILON)
159     return a;
160
161   /* Is the trace fixed ? */
162   if (type_ == TRACE_FIXED) {
163     return (a + (amount / value_));
164   }
165
166   XBT_DEBUG("amount %f total %f", amount, total_);
167   /* Reduce the problem to one where amount <= trace_total */
168   int quotient = static_cast<int>(floor(amount / total_));
169   double reduced_amount = (total_) * ((amount / total_) - floor(amount / total_));
170   double reduced_a = a - (lastTime_) * static_cast<int>(floor(a / lastTime_));
171
172   XBT_DEBUG("Quotient: %d reduced_amount: %f reduced_a: %f", quotient, reduced_amount, reduced_a);
173
174   /* Now solve for new_amount which is <= trace_total */
175   double reduced_b = solveSomewhatSimple(reduced_a, reduced_amount);
176
177 /* Re-map to the original b and amount */
178   double b = (lastTime_) * static_cast<int>(floor(a / lastTime_)) + (quotient * lastTime_) + reduced_b;
179   return b;
180 }
181
182 /**
183 * \brief Auxiliary function to solve integral
184 *
185 * Here, amount is <= trace->total
186 * and a <=trace->last_time
187 *
188 */
189 double CpuTiTgmr::solveSomewhatSimple(double a, double amount)
190 {
191   double b;
192
193   XBT_DEBUG("Solve integral: [%.2f, amount=%.2f]", a, amount);
194   double amount_till_end = integrate(a, lastTime_);
195
196   if (amount_till_end > amount) {
197     b = trace_->solveSimple(a, amount);
198   } else {
199     b = lastTime_ + trace_->solveSimple(0.0, amount - amount_till_end);
200   }
201   return b;
202 }
203
204 /**
205  * \brief Auxiliary function to solve integral.
206  *  It returns the date when the requested amount of flops is available
207  * \param a        Initial point
208  * \param amount  Amount of flops
209  * \return The date when amount is available.
210 */
211 double CpuTiTrace::solveSimple(double a, double amount)
212 {
213   double integral_a = integrateSimplePoint(a);
214   int ind = binarySearch(integral_, integral_a + amount, 0, nbPoints_ - 1);
215   double time = timePoints_[ind];
216   time += (integral_a + amount - integral_[ind]) /
217            ((integral_[ind + 1] - integral_[ind]) / (timePoints_[ind + 1] - timePoints_[ind]));
218
219   return time;
220 }
221
222 /**
223 * \brief Auxiliary function to update the CPU speed scale.
224 *
225 *  This function uses the trace structure to return the speed scale at the determined time a.
226 * \param a        Time
227 * \return CPU speed scale
228 */
229 double CpuTiTgmr::getPowerScale(double a)
230 {
231   double reduced_a = a - floor(a / lastTime_) * lastTime_;
232   int point = trace_->binarySearch(trace_->timePoints_, reduced_a, 0, trace_->nbPoints_ - 1);
233   trace_mgr::DatedValue val = speedTrace_->event_list.at(point);
234   return val.value_;
235 }
236
237 /**
238 * \brief Creates a new integration trace from a tmgr_trace_t
239 *
240 * \param  speedTrace    CPU availability trace
241 * \param  value          Percentage of CPU speed available (useful to fixed tracing)
242 * \return  Integration trace structure
243 */
244 CpuTiTgmr::CpuTiTgmr(tmgr_trace_t speedTrace, double value) :
245     speedTrace_(speedTrace)
246 {
247   double total_time = 0.0;
248   trace_ = 0;
249
250 /* no availability file, fixed trace */
251   if (not speedTrace) {
252     type_ = TRACE_FIXED;
253     value_ = value;
254     XBT_DEBUG("No availability trace. Constant value = %f", value);
255     return;
256   }
257
258   /* only one point available, fixed trace */
259   if (speedTrace->event_list.size() == 1) {
260     trace_mgr::DatedValue val = speedTrace->event_list.front();
261     type_ = TRACE_FIXED;
262     value_                    = val.value_;
263     return;
264   }
265
266   type_ = TRACE_DYNAMIC;
267
268   /* count the total time of trace file */
269   for (auto const& val : speedTrace->event_list)
270     total_time += val.date_;
271
272   trace_ = new CpuTiTrace(speedTrace);
273   lastTime_ = total_time;
274   total_ = trace_->integrateSimple(0, total_time);
275
276   XBT_DEBUG("Total integral %f, last_time %f ", total_, lastTime_);
277 }
278
279 /**
280  * \brief Binary search in array.
281  *  It returns the first point of the interval in which "a" is.
282  * \param array    Array
283  * \param a        Value to search
284  * \param low     Low bound to search in array
285  * \param high    Upper bound to search in array
286  * \return Index of point
287 */
288 int CpuTiTrace::binarySearch(double *array, double a, int low, int high)
289 {
290   xbt_assert(low < high, "Wrong parameters: low (%d) should be smaller than high (%d)", low, high);
291
292   do {
293     int mid = low + (high - low) / 2;
294     XBT_DEBUG("a %f low %d high %d mid %d value %f", a, low, high, mid, array[mid]);
295
296     if (array[mid] > a)
297       high = mid;
298     else
299       low = mid;
300   }
301   while (low < high - 1);
302
303   return low;
304 }
305
306 }
307 }
308
309 /*********
310  * Model *
311  *********/
312
313 void surf_cpu_model_init_ti()
314 {
315   xbt_assert(not surf_cpu_model_pm, "CPU model already initialized. This should not happen.");
316   xbt_assert(not surf_cpu_model_vm, "CPU model already initialized. This should not happen.");
317
318   surf_cpu_model_pm = new simgrid::surf::CpuTiModel();
319   all_existing_models->push_back(surf_cpu_model_pm);
320
321   surf_cpu_model_vm = new simgrid::surf::CpuTiModel();
322   all_existing_models->push_back(surf_cpu_model_vm);
323 }
324
325 namespace simgrid {
326 namespace surf {
327
328 CpuTiModel::CpuTiModel() : CpuModel()
329 {
330   runningActionSetThatDoesNotNeedBeingChecked_ = new ActionList();
331
332   modifiedCpu_ = new CpuTiList();
333 }
334
335 CpuTiModel::~CpuTiModel()
336 {
337   surf_cpu_model_pm = nullptr;
338   delete runningActionSetThatDoesNotNeedBeingChecked_;
339   delete modifiedCpu_;
340 }
341
342 Cpu *CpuTiModel::createCpu(simgrid::s4u::Host *host, std::vector<double>* speedPerPstate, int core)
343 {
344   return new CpuTi(this, host, speedPerPstate, core);
345 }
346
347 double CpuTiModel::nextOccuringEvent(double now)
348 {
349   double min_action_duration = -1;
350
351 /* iterates over modified cpus to update share resources */
352   CpuTiList::iterator itend(modifiedCpu_->end());
353   CpuTiList::iterator it(modifiedCpu_->begin());
354   while (it != itend) {
355     CpuTi *ti = &*it;
356     ++it;
357     ti->updateActionsFinishTime(now);
358   }
359
360 /* get the min next event if heap not empty */
361   if (not actionHeapIsEmpty())
362     min_action_duration = actionHeapTopDate() - now;
363
364   XBT_DEBUG("Share resources, min next event date: %f", min_action_duration);
365
366   return min_action_duration;
367 }
368
369 void CpuTiModel::updateActionsState(double now, double /*delta*/)
370 {
371   while (not actionHeapIsEmpty() && actionHeapTopDate() <= now) {
372     CpuTiAction* action = static_cast<CpuTiAction*>(actionHeapPop());
373     XBT_DEBUG("Action %p: finish", action);
374     action->finish(Action::State::done);
375     /* set the remains to 0 due to precision problems when updating the remaining amount */
376     action->setRemains(0);
377     /* update remaining amount of all actions */
378     action->cpu_->updateRemainingAmount(surf_get_clock());
379   }
380 }
381
382 /************
383  * Resource *
384  ************/
385 CpuTi::CpuTi(CpuTiModel *model, simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core)
386   : Cpu(model, host, speedPerPstate, core)
387 {
388   xbt_assert(core==1,"Multi-core not handled by this model yet");
389   coresAmount_ = core;
390
391   actionSet_ = new ActionTiList();
392
393   speed_.peak = speedPerPstate->front();
394   XBT_DEBUG("CPU create: peak=%f", speed_.peak);
395
396   speedIntegratedTrace_ = new CpuTiTgmr(nullptr, 1/*scale*/);
397 }
398
399 CpuTi::~CpuTi()
400 {
401   modified(false);
402   delete speedIntegratedTrace_;
403   delete actionSet_;
404 }
405 void CpuTi::setSpeedTrace(tmgr_trace_t trace)
406 {
407   if (speedIntegratedTrace_)
408     delete speedIntegratedTrace_;
409
410   speedIntegratedTrace_ = new CpuTiTgmr(trace, speed_.scale);
411
412   /* add a fake trace event if periodicity == 0 */
413   if (trace && trace->event_list.size() > 1) {
414     trace_mgr::DatedValue val = trace->event_list.back();
415     if (val.date_ < 1e-12)
416       speed_.event = future_evt_set->add_trace(new simgrid::trace_mgr::trace(), this);
417   }
418 }
419
420 void CpuTi::apply_event(tmgr_trace_event_t event, double value)
421 {
422   if (event == speed_.event) {
423     tmgr_trace_t speedTrace;
424     CpuTiTgmr *trace;
425
426     XBT_DEBUG("Finish trace date: value %f", value);
427     /* update remaining of actions and put in modified cpu swag */
428     updateRemainingAmount(surf_get_clock());
429
430     modified(true);
431
432     speedTrace = speedIntegratedTrace_->speedTrace_;
433     trace_mgr::DatedValue val = speedTrace->event_list.back();
434     delete speedIntegratedTrace_;
435     speed_.scale = val.value_;
436
437     trace = new CpuTiTgmr(TRACE_FIXED, val.value_);
438     XBT_DEBUG("value %f", val.value_);
439
440     speedIntegratedTrace_ = trace;
441
442     tmgr_trace_event_unref(&speed_.event);
443
444   } else if (event == stateEvent_) {
445     if (value > 0) {
446       if(isOff())
447         host_that_restart.push_back(getHost());
448       turnOn();
449     } else {
450       turnOff();
451       double date = surf_get_clock();
452
453       /* put all action running on cpu to failed */
454       ActionTiList::iterator itend(actionSet_->end());
455       for (ActionTiList::iterator it(actionSet_->begin()); it != itend; ++it) {
456         CpuTiAction *action = &*it;
457         if (action->getState() == Action::State::running
458          || action->getState() == Action::State::ready
459          || action->getState() == Action::State::not_in_the_system) {
460           action->setFinishTime(date);
461           action->setState(Action::State::failed);
462           action->heapRemove(model()->getActionHeap());
463         }
464       }
465     }
466     tmgr_trace_event_unref(&stateEvent_);
467
468   } else {
469     xbt_die("Unknown event!\n");
470   }
471 }
472
473 void CpuTi::updateActionsFinishTime(double now)
474 {
475   CpuTiAction *action;
476   double sum_priority = 0.0;
477   double total_area;
478
479   /* update remaining amount of actions */
480   updateRemainingAmount(now);
481
482   ActionTiList::iterator itend(actionSet_->end());
483   for (ActionTiList::iterator it(actionSet_->begin()); it != itend; ++it) {
484     action = &*it;
485     /* action not running, skip it */
486     if (action->getStateSet() != surf_cpu_model_pm->getRunningActionSet())
487       continue;
488
489     /* bogus priority, skip it */
490     if (action->getPriority() <= 0)
491       continue;
492
493     /* action suspended, skip it */
494     if (action->suspended_ != 0)
495       continue;
496
497     sum_priority += 1.0 / action->getPriority();
498   }
499   sumPriority_ = sum_priority;
500
501   for (ActionTiList::iterator it(actionSet_->begin()); it != itend; ++it) {
502     action = &*it;
503     double min_finish = -1;
504     /* action not running, skip it */
505     if (action->getStateSet() !=  surf_cpu_model_pm->getRunningActionSet())
506       continue;
507
508     /* verify if the action is really running on cpu */
509     if (action->suspended_ == 0 && action->getPriority() > 0) {
510       /* total area needed to finish the action. Used in trace integration */
511       total_area = (action->getRemains()) * sum_priority * action->getPriority();
512
513       total_area /= speed_.peak;
514
515       action->setFinishTime(speedIntegratedTrace_->solve(now, total_area));
516       /* verify which event will happen before (max_duration or finish time) */
517       if (action->getMaxDuration() > NO_MAX_DURATION &&
518           action->getStartTime() + action->getMaxDuration() < action->getFinishTime())
519         min_finish = action->getStartTime() + action->getMaxDuration();
520       else
521         min_finish = action->getFinishTime();
522     } else {
523       /* put the max duration time on heap */
524       if (action->getMaxDuration() > NO_MAX_DURATION)
525         min_finish = action->getStartTime() + action->getMaxDuration();
526     }
527     /* add in action heap */
528     if (min_finish > NO_MAX_DURATION)
529       action->heapUpdate(model()->getActionHeap(), min_finish, NOTSET);
530     else
531       action->heapRemove(model()->getActionHeap());
532
533     XBT_DEBUG("Update finish time: Cpu(%s) Action: %p, Start Time: %f Finish Time: %f Max duration %f", getCname(),
534               action, action->getStartTime(), action->getFinishTime(), action->getMaxDuration());
535   }
536   /* remove from modified cpu */
537   modified(false);
538 }
539
540 bool CpuTi::isUsed()
541 {
542   return not actionSet_->empty();
543 }
544
545 double CpuTi::getAvailableSpeed()
546 {
547   speed_.scale = speedIntegratedTrace_->getPowerScale(surf_get_clock());
548   return Cpu::getAvailableSpeed();
549 }
550
551 /** @brief Update the remaining amount of actions */
552 void CpuTi::updateRemainingAmount(double now)
553 {
554
555   /* already updated */
556   if (lastUpdate_ >= now)
557     return;
558
559   /* compute the integration area */
560   double area_total = speedIntegratedTrace_->integrate(lastUpdate_, now) * speed_.peak;
561   XBT_DEBUG("Flops total: %f, Last update %f", area_total, lastUpdate_);
562   ActionTiList::iterator itend(actionSet_->end());
563   for (ActionTiList::iterator it(actionSet_->begin()); it != itend; ++it) {
564     CpuTiAction *action = &*it;
565     /* action not running, skip it */
566     if (action->getStateSet() != model()->getRunningActionSet())
567       continue;
568
569     /* bogus priority, skip it */
570     if (action->getPriority() <= 0)
571       continue;
572
573     /* action suspended, skip it */
574     if (action->suspended_ != 0)
575       continue;
576
577     /* action don't need update */
578     if (action->getStartTime() >= now)
579       continue;
580
581     /* skip action that are finishing now */
582     if (action->getFinishTime() >= 0 && action->getFinishTime() <= now)
583       continue;
584
585     /* update remaining */
586     action->updateRemains(area_total / (sumPriority_ * action->getPriority()));
587     XBT_DEBUG("Update remaining action(%p) remaining %f", action, action->getRemainsNoUpdate());
588   }
589   lastUpdate_ = now;
590 }
591
592 CpuAction *CpuTi::execution_start(double size)
593 {
594   XBT_IN("(%s,%g)", getCname(), size);
595   CpuTiAction* action = new CpuTiAction(static_cast<CpuTiModel*>(model()), size, isOff(), this);
596
597   actionSet_->push_back(*action);
598
599   XBT_OUT();
600   return action;
601 }
602
603
604 CpuAction *CpuTi::sleep(double duration)
605 {
606   if (duration > 0)
607     duration = MAX(duration, sg_surf_precision);
608
609   XBT_IN("(%s,%g)", getCname(), duration);
610   CpuTiAction* action = new CpuTiAction(static_cast<CpuTiModel*>(model()), 1.0, isOff(), this);
611
612   action->setMaxDuration(duration);
613   action->suspended_ = 2;
614   if (duration == NO_MAX_DURATION) {
615    /* Move to the *end* of the corresponding action set. This convention
616       is used to speed up update_resource_state  */
617   action->getStateSet()->erase(action->getStateSet()->iterator_to(*action));
618   action->stateSet_ = static_cast<CpuTiModel*>(model())->runningActionSetThatDoesNotNeedBeingChecked_;
619   action->getStateSet()->push_back(*action);
620   }
621
622   actionSet_->push_back(*action);
623
624   XBT_OUT();
625   return action;
626 }
627
628 void CpuTi::modified(bool modified){
629   CpuTiList* modifiedCpu = static_cast<CpuTiModel*>(model())->modifiedCpu_;
630   if (modified) {
631     if (not cpu_ti_hook.is_linked()) {
632       modifiedCpu->push_back(*this);
633     }
634   } else {
635     if (cpu_ti_hook.is_linked()) {
636       modifiedCpu->erase(modifiedCpu->iterator_to(*this));
637     }
638   }
639 }
640
641 /**********
642  * Action *
643  **********/
644
645 CpuTiAction::CpuTiAction(CpuTiModel *model_, double cost, bool failed, CpuTi *cpu)
646  : CpuAction(model_, cost, failed)
647  , cpu_(cpu)
648 {
649   cpu_->modified(true);
650 }
651
652 void CpuTiAction::setState(Action::State state)
653 {
654   CpuAction::setState(state);
655   cpu_->modified(true);
656 }
657
658 int CpuTiAction::unref()
659 {
660   refcount_--;
661   if (not refcount_) {
662     if (action_hook.is_linked())
663       getStateSet()->erase(getStateSet()->iterator_to(*this));
664     /* remove from action_set */
665     if (action_ti_hook.is_linked())
666       cpu_->actionSet_->erase(cpu_->actionSet_->iterator_to(*this));
667     /* remove from heap */
668     heapRemove(getModel()->getActionHeap());
669     cpu_->modified(true);
670     delete this;
671     return 1;
672   }
673   return 0;
674 }
675
676 void CpuTiAction::cancel()
677 {
678   this->setState(Action::State::failed);
679   heapRemove(getModel()->getActionHeap());
680   cpu_->modified(true);
681 }
682
683 void CpuTiAction::suspend()
684 {
685   XBT_IN("(%p)", this);
686   if (suspended_ != 2) {
687     suspended_ = 1;
688     heapRemove(getModel()->getActionHeap());
689     cpu_->modified(true);
690   }
691   XBT_OUT();
692 }
693
694 void CpuTiAction::resume()
695 {
696   XBT_IN("(%p)", this);
697   if (suspended_ != 2) {
698     suspended_ = 0;
699     cpu_->modified(true);
700   }
701   XBT_OUT();
702 }
703
704 void CpuTiAction::setMaxDuration(double duration)
705 {
706   double min_finish;
707
708   XBT_IN("(%p,%g)", this, duration);
709
710   Action::setMaxDuration(duration);
711
712   if (duration >= 0)
713     min_finish = (getStartTime() + getMaxDuration()) < getFinishTime() ?
714                  (getStartTime() + getMaxDuration()) : getFinishTime();
715   else
716     min_finish = getFinishTime();
717
718   /* add in action heap */
719   heapUpdate(getModel()->getActionHeap(), min_finish, NOTSET);
720
721   XBT_OUT();
722 }
723
724 void CpuTiAction::setSharingWeight(double priority)
725 {
726   XBT_IN("(%p,%g)", this, priority);
727   setSharingWeightNoUpdate(priority);
728   cpu_->modified(true);
729   XBT_OUT();
730 }
731
732 double CpuTiAction::getRemains()
733 {
734   XBT_IN("(%p)", this);
735   cpu_->updateRemainingAmount(surf_get_clock());
736   XBT_OUT();
737   return getRemainsNoUpdate();
738 }
739
740 }
741 }
742
743 #endif /* SURF_MODEL_CPUTI_H_ */