Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
[simgrid.git] / src / surf / cpu_ti.cpp
index bbc2ffa..40c0490 100644 (file)
@@ -61,19 +61,18 @@ CpuTiTmgr::~CpuTiTmgr()
 */
 double CpuTiTmgr::integrate(double a, double b)
 {
-  int a_index;
-
   if ((a < 0.0) || (a > b)) {
     xbt_die("Error, invalid integration interval [%.2f,%.2f]. "
         "You probably have a task executing with negative computation amount. Check your code.", a, b);
   }
-  if (fabs(a -b) < EPSILON)
+  if (fabs(a - b) < EPSILON)
     return 0.0;
 
   if (type_ == Type::FIXED) {
-    return ((b - a) * value_);
+    return (b - a) * value_;
   }
 
+  int a_index;
   if (fabs(ceil(a / last_time_) - a / last_time_) < EPSILON)
     a_index = 1 + static_cast<int>(ceil(a / last_time_));
   else
@@ -384,22 +383,17 @@ void CpuTi::set_speed_trace(tmgr_trace_t trace)
 void CpuTi::apply_event(tmgr_trace_event_t event, double value)
 {
   if (event == speed_.event) {
-    XBT_DEBUG("Finish trace date: value %f", value);
+    XBT_DEBUG("Speed changed in trace! New fixed value: %f", value);
+
     /* update remaining of actions and put in modified cpu list */
     update_remaining_amount(surf_get_clock());
 
     set_modified(true);
 
-    tmgr_trace_t speedTrace   = speed_integrated_trace_->speed_trace_;
-    trace_mgr::DatedValue val = speedTrace->event_list.back();
     delete speed_integrated_trace_;
-    speed_.scale = val.value_;
-
-    CpuTiTmgr* trace = new CpuTiTmgr(CpuTiTmgr::Type::FIXED, val.value_);
-    XBT_DEBUG("value %f", val.value_);
-
-    speed_integrated_trace_ = trace;
+    speed_integrated_trace_ = new CpuTiTmgr(value);
 
+    speed_.scale = value;
     tmgr_trace_event_unref(&speed_.event);
 
   } else if (event == state_event_) {
@@ -503,8 +497,7 @@ double CpuTi::get_speed_ratio()
 /** @brief Update the remaining amount of actions */
 void CpuTi::update_remaining_amount(double now)
 {
-
-  /* already updated */
+  /* already up to date */
   if (last_update_ >= now)
     return;