Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Kill unused function TRACE_surf_action().
[simgrid.git] / src / surf / network_ib.cpp
index eea85e8..1dc1b1e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2015. The SimGrid Team.
+/* Copyright (c) 2014-2017. The SimGrid Team.
 *All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -7,8 +7,8 @@
 #include <utility>
 
 #include "simgrid/sg_config.h"
+#include "src/kernel/lmm/maxmin.hpp"
 #include "src/surf/HostImpl.hpp"
-#include "src/surf/maxmin_private.hpp"
 #include "src/surf/network_ib.hpp"
 #include "src/surf/xml/platf.hpp"
 #include <boost/algorithm/string/classification.hpp>
@@ -52,16 +52,18 @@ static void IB_action_init_callback(simgrid::surf::NetworkAction* action, simgri
   simgrid::surf::IBNode* act_src;
   simgrid::surf::IBNode* act_dst;
 
-  try {
-    act_src = ibModel->active_nodes.at(src->getName());
-  } catch (std::out_of_range& unfound) {
-    throw std::out_of_range(std::string("Could not find '") + src->getName() + "' active comms !");
+  auto asrc = ibModel->active_nodes.find(src->getName());
+  if (asrc != ibModel->active_nodes.end()) {
+    act_src = asrc->second;
+  } else {
+    throw std::out_of_range(std::string("Could not find '") + src->getCname() + "' active comms !");
   }
 
-  try {
-    act_dst = ibModel->active_nodes.at(dst->getName());
-  } catch (std::out_of_range& unfound) {
-    throw std::out_of_range(std::string("Could not find '") + dst->getName() + "' active comms !");
+  auto adst = ibModel->active_nodes.find(dst->getName());
+  if (adst != ibModel->active_nodes.end()) {
+    act_dst = adst->second;
+  } else {
+    throw std::out_of_range(std::string("Could not find '") + dst->getCname() + "' active comms !");
   }
 
   ibModel->active_comms[action]=std::make_pair(act_src, act_dst);
@@ -102,8 +104,7 @@ namespace surf {
 
 NetworkIBModel::NetworkIBModel() : NetworkSmpiModel()
 {
-  haveGap_                      = false;
-  const char* IB_factors_string = xbt_cfg_get_string("smpi/IB-penalty-factors");
+  std::string IB_factors_string = xbt_cfg_get_string("smpi/IB-penalty-factors");
   std::vector<std::string> radical_elements;
   boost::split(radical_elements, IB_factors_string, boost::is_any_of(";"));
 
@@ -131,7 +132,7 @@ NetworkIBModel::NetworkIBModel() : NetworkSmpiModel()
 
 NetworkIBModel::~NetworkIBModel()
 {
-  for (auto instance : active_nodes)
+  for (auto const& instance : active_nodes)
     delete instance.second;
 }
 
@@ -173,7 +174,7 @@ void NetworkIBModel::computeIBfactors(IBNode* root)
     if (not double_equals(penalized_bw, rate_before_update, sg_surf_precision)) {
       XBT_DEBUG("%d->%d action %p penalty updated : bw now %f, before %f , initial rate %f", root->id,
                 (*it)->destination->id, (*it)->action, penalized_bw, (*it)->action->getBound(), (*it)->init_rate);
-      lmm_update_variable_bound(maxminSystem_, (*it)->action->getVariable(), penalized_bw);
+      maxminSystem_->update_variable_bound((*it)->action->getVariable(), penalized_bw);
     } else {
       XBT_DEBUG("%d->%d action %p penalty not updated : bw %f, initial rate %f", root->id, (*it)->destination->id,
                 (*it)->action, penalized_bw, (*it)->init_rate);
@@ -182,18 +183,18 @@ void NetworkIBModel::computeIBfactors(IBNode* root)
   XBT_DEBUG("Finished computing IB penalties");
 }
 
-void NetworkIBModel::updateIBfactors_rec(IBNode* root, bool* updatedlist)
+void NetworkIBModel::updateIBfactors_rec(IBNode* root, std::vector<bool>& updatedlist)
 {
-  if (updatedlist[root->id] == 0) {
+  if (not updatedlist[root->id]) {
     XBT_DEBUG("IB - Updating rec %d", root->id);
     computeIBfactors(root);
-    updatedlist[root->id] = 1;
+    updatedlist[root->id] = true;
     for (std::vector<ActiveComm*>::iterator it = root->ActiveCommsUp.begin(); it != root->ActiveCommsUp.end(); ++it) {
-      if (updatedlist[(*it)->destination->id] != 1)
+      if (not updatedlist[(*it)->destination->id])
         updateIBfactors_rec((*it)->destination, updatedlist);
     }
     for (std::map<IBNode*, int>::iterator it = root->ActiveCommsDown.begin(); it != root->ActiveCommsDown.end(); ++it) {
-      if (updatedlist[it->first->id] != 1)
+      if (not updatedlist[it->first->id])
         updateIBfactors_rec(it->first, updatedlist);
     }
   }
@@ -204,7 +205,6 @@ void NetworkIBModel::updateIBfactors(NetworkAction* action, IBNode* from, IBNode
   if (from == to) // disregard local comms (should use loopback)
     return;
 
-  bool* updated    = (bool*)xbt_malloc0(active_nodes.size() * sizeof(bool));
   ActiveComm* comm = nullptr;
   if (remove) {
     if (to->ActiveCommsDown[from] == 1)
@@ -232,11 +232,10 @@ void NetworkIBModel::updateIBfactors(NetworkAction* action, IBNode* from, IBNode
     to->nbActiveCommsDown++;
   }
   XBT_DEBUG("IB - Updating %d", from->id);
+  std::vector<bool> updated(active_nodes.size(), false);
   updateIBfactors_rec(from, updated);
   XBT_DEBUG("IB - Finished updating %d", from->id);
-  if (comm)
-    delete comm;
-  xbt_free(updated);
+  delete comm;
 }
 }
 }