Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
link_energy: make sure that the watts ranges are always inited correctly
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Thu, 29 Nov 2018 15:15:17 +0000 (16:15 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Thu, 29 Nov 2018 15:17:50 +0000 (16:17 +0100)
Thanks to Loic for the report and debug of this issue.

src/plugins/link_energy.cpp

index 8bf1697..08e0a73 100644 (file)
@@ -72,6 +72,9 @@ simgrid::xbt::Extension<simgrid::s4u::Link, LinkEnergy> LinkEnergy::EXTENSION_ID
 
 void LinkEnergy::update()
 {
 
 void LinkEnergy::update()
 {
+  if (!inited_)
+    init_watts_range_list();
+
   double power = get_power();
   double now   = surf_get_clock();
   total_energy_ += power * (now - last_updated_);
   double power = get_power();
   double now   = surf_get_clock();
   total_energy_ += power * (now - last_updated_);
@@ -80,7 +83,6 @@ void LinkEnergy::update()
 
 void LinkEnergy::init_watts_range_list()
 {
 
 void LinkEnergy::init_watts_range_list()
 {
-
   if (inited_)
     return;
   inited_ = true;
   if (inited_)
     return;
   inited_ = true;
@@ -114,8 +116,6 @@ void LinkEnergy::init_watts_range_list()
     } catch (std::invalid_argument& ia) {
       throw std::invalid_argument(std::string("Invalid busy power value for link ") + this->link_->get_cname());
     }
     } catch (std::invalid_argument& ia) {
       throw std::invalid_argument(std::string("Invalid busy power value for link ") + this->link_->get_cname());
     }
-
-    update();
   }
 }
 
   }
 }