Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
reindent, no real change
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 28 Feb 2016 11:25:37 +0000 (12:25 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 28 Feb 2016 11:25:37 +0000 (12:25 +0100)
src/surf/network_constant.cpp
src/surf/network_constant.hpp
src/surf/network_ib.cpp
src/surf/network_ib.hpp
src/surf/network_interface.cpp
src/surf/network_interface.hpp
src/surf/network_smpi.hpp

index 533be80..ce90e8a 100644 (file)
@@ -20,94 +20,94 @@ void surf_network_model_init_Constant()
   routing_model_create(NULL);
 
   simgrid::surf::on_link.connect([](sg_platf_link_cbarg_t link){
   routing_model_create(NULL);
 
   simgrid::surf::on_link.connect([](sg_platf_link_cbarg_t link){
-      xbt_die("There is no link in the Constant network model. "
-          "Please remove any link from your platform (and switch to routing='None')");
+    xbt_die("There is no link in the Constant network model. "
+        "Please remove any link from your platform (and switch to routing='None')");
   });
 }
 
 namespace simgrid {
   });
 }
 
 namespace simgrid {
-namespace surf {
-
-double NetworkConstantModel::next_occuring_event(double /*now*/)
-{
-  NetworkConstantAction *action = NULL;
-  double min = -1.0;
-
-  ActionList *actionSet = getRunningActionSet();
-  for(ActionList::iterator it(actionSet->begin()), itend(actionSet->end())
-      ; it != itend ; ++it) {
-    action = static_cast<NetworkConstantAction*>(&*it);
-    if (action->m_latency > 0 && (min < 0 || action->m_latency < min))
-      min = action->m_latency;
-  }
+  namespace surf {
+
+    double NetworkConstantModel::next_occuring_event(double /*now*/)
+    {
+      NetworkConstantAction *action = NULL;
+      double min = -1.0;
+
+      ActionList *actionSet = getRunningActionSet();
+      for(ActionList::iterator it(actionSet->begin()), itend(actionSet->end())
+          ; it != itend ; ++it) {
+        action = static_cast<NetworkConstantAction*>(&*it);
+        if (action->m_latency > 0 && (min < 0 || action->m_latency < min))
+          min = action->m_latency;
+      }
 
 
-  return min;
-}
+      return min;
+    }
 
 
-void NetworkConstantModel::updateActionsState(double /*now*/, double delta)
-{
-  NetworkConstantAction *action = NULL;
-  ActionList *actionSet = getRunningActionSet();
-  for(ActionList::iterator it(actionSet->begin()), itNext=it, itend(actionSet->end())
-      ; it != itend ; it=itNext) {
-    ++itNext;
-    action = static_cast<NetworkConstantAction*>(&*it);
-    if (action->m_latency > 0) {
-      if (action->m_latency > delta) {
-        double_update(&(action->m_latency), delta, sg_surf_precision);
-      } else {
-        action->m_latency = 0.0;
+    void NetworkConstantModel::updateActionsState(double /*now*/, double delta)
+    {
+      NetworkConstantAction *action = NULL;
+      ActionList *actionSet = getRunningActionSet();
+      for(ActionList::iterator it(actionSet->begin()), itNext=it, itend(actionSet->end())
+          ; it != itend ; it=itNext) {
+        ++itNext;
+        action = static_cast<NetworkConstantAction*>(&*it);
+        if (action->m_latency > 0) {
+          if (action->m_latency > delta) {
+            double_update(&(action->m_latency), delta, sg_surf_precision);
+          } else {
+            action->m_latency = 0.0;
+          }
+        }
+        action->updateRemains(action->getCost() * delta / action->m_latInit);
+        if (action->getMaxDuration() != NO_MAX_DURATION)
+          action->updateMaxDuration(delta);
+
+        if (action->getRemainsNoUpdate() <= 0) {
+          action->finish();
+          action->setState(SURF_ACTION_DONE);
+        } else if ((action->getMaxDuration() != NO_MAX_DURATION)
+            && (action->getMaxDuration() <= 0)) {
+          action->finish();
+          action->setState(SURF_ACTION_DONE);
+        }
       }
     }
       }
     }
-    action->updateRemains(action->getCost() * delta / action->m_latInit);
-    if (action->getMaxDuration() != NO_MAX_DURATION)
-      action->updateMaxDuration(delta);
-
-    if (action->getRemainsNoUpdate() <= 0) {
-      action->finish();
-      action->setState(SURF_ACTION_DONE);
-    } else if ((action->getMaxDuration() != NO_MAX_DURATION)
-        && (action->getMaxDuration() <= 0)) {
-      action->finish();
-      action->setState(SURF_ACTION_DONE);
-    }
-  }
-}
-
-Action *NetworkConstantModel::communicate(NetCard *src, NetCard *dst,
-    double size, double rate)
-{
-  char *src_name = src->name();
-  char *dst_name = dst->name();
 
 
-  XBT_IN("(%s,%s,%g,%g)", src_name, dst_name, size, rate);
-  NetworkConstantAction *action = new NetworkConstantAction(this, size, sg_latency_factor);
-  XBT_OUT();
+    Action *NetworkConstantModel::communicate(NetCard *src, NetCard *dst,
+        double size, double rate)
+    {
+      char *src_name = src->name();
+      char *dst_name = dst->name();
 
 
-  networkCommunicateCallbacks(action, src, dst, size, rate);
-  return action;
-}
+      XBT_IN("(%s,%s,%g,%g)", src_name, dst_name, size, rate);
+      NetworkConstantAction *action = new NetworkConstantAction(this, size, sg_latency_factor);
+      XBT_OUT();
 
 
-/**********
- * Action *
- **********/
+      networkCommunicateCallbacks(action, src, dst, size, rate);
+      return action;
+    }
 
 
-int NetworkConstantAction::unref()
-{
-  m_refcount--;
-  if (!m_refcount) {
-    if (action_hook.is_linked())
-      p_stateSet->erase(p_stateSet->iterator_to(*this));
-    delete this;
-    return 1;
-  }
-  return 0;
-}
+    /**********
+     * Action *
+     **********/
+
+    int NetworkConstantAction::unref()
+    {
+      m_refcount--;
+      if (!m_refcount) {
+        if (action_hook.is_linked())
+          p_stateSet->erase(p_stateSet->iterator_to(*this));
+        delete this;
+        return 1;
+      }
+      return 0;
+    }
 
 
-void NetworkConstantAction::cancel()
-{
-  return;
-}
+    void NetworkConstantAction::cancel()
+    {
+      return;
+    }
 
 
-}
+  }
 }
 }
index fea074d..60f166e 100644 (file)
 #include "network_interface.hpp"
 
 namespace simgrid {
 #include "network_interface.hpp"
 
 namespace simgrid {
-namespace surf {
+  namespace surf {
 
 
-/***********
- * Classes *
- ***********/
-class XBT_PRIVATE NetworkConstantModel;
-class XBT_PRIVATE NetworkConstantAction;
+    /***********
+     * Classes *
+     ***********/
 
 
-/*********
- * Model *
- *********/
-class NetworkConstantModel : public NetworkModel {
-public:
-  NetworkConstantModel()  : NetworkModel() { };
-  ~NetworkConstantModel() { }
+    class XBT_PRIVATE NetworkConstantModel;
+    class XBT_PRIVATE NetworkConstantAction;
 
 
-  Action *communicate(NetCard *src, NetCard *dst, double size, double rate) override;
-  double next_occuring_event(double now) override;
-  bool next_occuring_event_isIdempotent() override {return true;}
-  void updateActionsState(double now, double delta) override;
+    /*********
+     * Model *
+     *********/
+    class NetworkConstantModel : public NetworkModel {
+    public:
+      NetworkConstantModel()  : NetworkModel() { };
+      ~NetworkConstantModel() { }
 
 
-  Link*
-  createLink(const char *name,
-      double bw_initial, tmgr_trace_t bw_trace,
-      double lat_initial, tmgr_trace_t lat_trace,
-      tmgr_trace_t state_trace,
-      e_surf_link_sharing_policy_t policy,
-      xbt_dict_t properties)          override { DIE_IMPOSSIBLE; }
-};
+      Action *communicate(NetCard *src, NetCard *dst, double size, double rate) override;
+      double next_occuring_event(double now) override;
+      bool next_occuring_event_isIdempotent() override {return true;}
+      void updateActionsState(double now, double delta) override;
 
 
-/**********
- * Action *
- **********/
-class NetworkConstantAction : public NetworkAction {
-public:
-  NetworkConstantAction(NetworkConstantModel *model_, double size, double latency)
-  : NetworkAction(model_, size, false)
-  , m_latInit(latency)
-  {
-  m_latency = latency;
-  if (m_latency <= 0.0) {
-    p_stateSet = getModel()->getDoneActionSet();
-    p_stateSet->push_back(*this);
-  }
-  p_variable = NULL;
-  };
-  int unref() override;
-  void cancel() override;
-  double m_latInit;
-};
+      Link*
+      createLink(const char *name,
+          double bw_initial, tmgr_trace_t bw_trace,
+          double lat_initial, tmgr_trace_t lat_trace,
+          tmgr_trace_t state_trace,
+          e_surf_link_sharing_policy_t policy,
+          xbt_dict_t properties)          override { DIE_IMPOSSIBLE; }
+    };
 
 
-}
+    /**********
+     * Action *
+     **********/
+    class NetworkConstantAction : public NetworkAction {
+    public:
+      NetworkConstantAction(NetworkConstantModel *model_, double size, double latency)
+    : NetworkAction(model_, size, false)
+    , m_latInit(latency)
+    {
+        m_latency = latency;
+        if (m_latency <= 0.0) {
+          p_stateSet = getModel()->getDoneActionSet();
+          p_stateSet->push_back(*this);
+        }
+        p_variable = NULL;
+    };
+      int unref() override;
+      void cancel() override;
+      double m_latInit;
+    };
+
+  }
 }
 
 #endif /* NETWORK_CONSTANT_HPP_ */
 }
 
 #endif /* NETWORK_CONSTANT_HPP_ */
index ecc9e63..7b743d5 100644 (file)
@@ -17,61 +17,61 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_network);
 
 static void IB_create_host_callback(simgrid::s4u::Host& host){
   using namespace simgrid::surf;
 
 static void IB_create_host_callback(simgrid::s4u::Host& host){
   using namespace simgrid::surf;
-  
+
   static int id=0;
   static int id=0;
-// pour t->id -> rajouter une nouvelle struct dans le dict, pour stocker les comms actives
+  // pour t->id -> rajouter une nouvelle struct dans le dict, pour stocker les comms actives
   if(((NetworkIBModel*)surf_network_model)->active_nodes==NULL)
     ((NetworkIBModel*)surf_network_model)->active_nodes=xbt_dict_new();
   if(((NetworkIBModel*)surf_network_model)->active_nodes==NULL)
     ((NetworkIBModel*)surf_network_model)->active_nodes=xbt_dict_new();
-  
+
   IBNode* act = new IBNode(id);
 
   id++;
   xbt_dict_set(((NetworkIBModel*)surf_network_model)->active_nodes,
   IBNode* act = new IBNode(id);
 
   id++;
   xbt_dict_set(((NetworkIBModel*)surf_network_model)->active_nodes,
-    host.name().c_str(), act, NULL);
+      host.name().c_str(), act, NULL);
 
 }
 
 static void IB_action_state_changed_callback(
 
 }
 
 static void IB_action_state_changed_callback(
-  simgrid::surf::NetworkAction *action,
-  e_surf_action_state_t statein, e_surf_action_state_t stateout)
+    simgrid::surf::NetworkAction *action,
+    e_surf_action_state_t statein, e_surf_action_state_t stateout)
 {
 {
- using namespace simgrid::surf;
- if(statein!=SURF_ACTION_RUNNING|| stateout!=SURF_ACTION_DONE)
 using namespace simgrid::surf;
 if(statein!=SURF_ACTION_RUNNING|| stateout!=SURF_ACTION_DONE)
     return;
   std::pair<IBNode*,IBNode*> pair = ((NetworkIBModel*)surf_network_model)->active_comms[action];
   XBT_DEBUG("IB callback - action %p finished", action);
     return;
   std::pair<IBNode*,IBNode*> pair = ((NetworkIBModel*)surf_network_model)->active_comms[action];
   XBT_DEBUG("IB callback - action %p finished", action);
- ((NetworkIBModel*)surf_network_model)->updateIBfactors(action, pair.first, pair.second, 1);
+
 ((NetworkIBModel*)surf_network_model)->updateIBfactors(action, pair.first, pair.second, 1);
 
   ((NetworkIBModel*)surf_network_model)->active_comms.erase(action);
 
   ((NetworkIBModel*)surf_network_model)->active_comms.erase(action);
-  
+
 }
 
 
 static void IB_action_init_callback(
 }
 
 
 static void IB_action_init_callback(
-  simgrid::surf::NetworkAction *action, simgrid::surf::NetCard *src, simgrid::surf::NetCard *dst,
-  double size, double rate)
+    simgrid::surf::NetworkAction *action, simgrid::surf::NetCard *src, simgrid::surf::NetCard *dst,
+    double size, double rate)
 {
   using namespace simgrid::surf;
   if(((NetworkIBModel*)surf_network_model)->active_nodes==NULL)
     xbt_die("IB comm added, without any node connected !");
 {
   using namespace simgrid::surf;
   if(((NetworkIBModel*)surf_network_model)->active_nodes==NULL)
     xbt_die("IB comm added, without any node connected !");
-  
+
   IBNode* act_src= (IBNode*) xbt_dict_get_or_null(((NetworkIBModel*)surf_network_model)->active_nodes, src->name());
   if(act_src==NULL)
     xbt_die("could not find src node active comms !");
   //act_src->rate=rate;
   IBNode* act_src= (IBNode*) xbt_dict_get_or_null(((NetworkIBModel*)surf_network_model)->active_nodes, src->name());
   if(act_src==NULL)
     xbt_die("could not find src node active comms !");
   //act_src->rate=rate;
-  
+
   IBNode* act_dst= (IBNode*) xbt_dict_get_or_null(((NetworkIBModel*)surf_network_model)->active_nodes, dst->name());
   if(act_dst==NULL)
     xbt_die("could not find dst node active comms !");  
   IBNode* act_dst= (IBNode*) xbt_dict_get_or_null(((NetworkIBModel*)surf_network_model)->active_nodes, dst->name());
   if(act_dst==NULL)
     xbt_die("could not find dst node active comms !");  
- // act_dst->rate=rate;
-  
 // act_dst->rate=rate;
+
   ((NetworkIBModel*)surf_network_model)->active_comms[action]=std::make_pair(act_src, act_dst);
   //post the action in the second dist, to retrieve in the other callback
   XBT_DEBUG("IB callback - action %p init", action);
 
   ((NetworkIBModel*)surf_network_model)->updateIBfactors(action, act_src, act_dst, 0);
   ((NetworkIBModel*)surf_network_model)->active_comms[action]=std::make_pair(act_src, act_dst);
   //post the action in the second dist, to retrieve in the other callback
   XBT_DEBUG("IB callback - action %p init", action);
 
   ((NetworkIBModel*)surf_network_model)->updateIBfactors(action, act_src, act_dst, 0);
-  
+
 }
 
 /*********
 }
 
 /*********
@@ -103,147 +103,147 @@ void surf_network_model_init_IB(void)
   networkCommunicateCallbacks.connect(IB_action_init_callback);
   simgrid::s4u::Host::onCreation.connect(IB_create_host_callback);
   xbt_cfg_setdefault_double(_sg_cfg_set, "network/weight_S", 8775);
   networkCommunicateCallbacks.connect(IB_action_init_callback);
   simgrid::s4u::Host::onCreation.connect(IB_create_host_callback);
   xbt_cfg_setdefault_double(_sg_cfg_set, "network/weight_S", 8775);
-  
+
 }
 
 #include "src/surf/xml/platf.hpp" // FIXME: move that back to the parsing area
 
 namespace simgrid {
 }
 
 #include "src/surf/xml/platf.hpp" // FIXME: move that back to the parsing area
 
 namespace simgrid {
-namespace surf {
-
-NetworkIBModel::NetworkIBModel()
- : NetworkSmpiModel() {
-  m_haveGap=false;
-  active_nodes=NULL;
-    
-  const char* IB_factors_string=sg_cfg_get_string("smpi/IB_penalty_factors");
-  xbt_dynar_t radical_elements = xbt_str_split(IB_factors_string, ";");
-  
-  surf_parse_assert(xbt_dynar_length(radical_elements)==3,
-    "smpi/IB_penalty_factors should be provided and contain 3 elements, semi-colon separated : for example 0.965;0.925;1.35");
-  
-  Be = xbt_str_parse_double(xbt_dynar_get_as(radical_elements, 0, char *), "First part of smpi/IB_penalty_factors is not numerical: %s");
-  Bs = xbt_str_parse_double(xbt_dynar_get_as(radical_elements, 1, char *), "Second part of smpi/IB_penalty_factors is not numerical: %s");
-  ys = xbt_str_parse_double(xbt_dynar_get_as(radical_elements, 2, char *), "Third part of smpi/IB_penalty_factors is not numerical: %s");
-
-  xbt_dynar_free(&radical_elements);
-}
+  namespace surf {
 
 
-NetworkIBModel::~NetworkIBModel()
-{
-  xbt_dict_cursor_t cursor = NULL;
-  IBNode* instance = NULL;
-  char *name = NULL;
-  xbt_dict_foreach(active_nodes, cursor, name, instance)
-    delete instance;
-  xbt_dict_free(&active_nodes);
-}
+    NetworkIBModel::NetworkIBModel()
+    : NetworkSmpiModel() {
+      m_haveGap=false;
+      active_nodes=NULL;
 
 
-void NetworkIBModel::computeIBfactors(IBNode *root) {
-  double penalized_bw=0.0;
-  double num_comm_out = (double) root->ActiveCommsUp.size();
-  double max_penalty_out=0.0;
-  //first, compute all outbound penalties to get their max
-  for (std::vector<ActiveComm*>::iterator it= root->ActiveCommsUp.begin(); it != root->ActiveCommsUp.end(); ++it) {
-    double my_penalty_out = 1.0;
-
-    if(num_comm_out!=1){
-      if((*it)->destination->nbActiveCommsDown > 2)//number of comms sent to the receiving node
-  my_penalty_out = num_comm_out * Bs * ys;
-      else
-  my_penalty_out = num_comm_out * Bs;
-    }
+      const char* IB_factors_string=sg_cfg_get_string("smpi/IB_penalty_factors");
+      xbt_dynar_t radical_elements = xbt_str_split(IB_factors_string, ";");
 
 
-    max_penalty_out = std::max(max_penalty_out,my_penalty_out);
-  }
+      surf_parse_assert(xbt_dynar_length(radical_elements)==3,
+          "smpi/IB_penalty_factors should be provided and contain 3 elements, semi-colon separated : for example 0.965;0.925;1.35");
 
 
-  for (std::vector<ActiveComm*>::iterator it= root->ActiveCommsUp.begin(); it != root->ActiveCommsUp.end(); ++it) {
-
-    //compute inbound penalty
-    double my_penalty_in = 1.0;
-    int nb_comms = (*it)->destination->nbActiveCommsDown;//total number of incoming comms
-    if(nb_comms!=1)
-      my_penalty_in = ((*it)->destination->ActiveCommsDown)[root] //number of comm sent to dest by root node
-          * Be 
-          * (*it)->destination->ActiveCommsDown.size();//number of different nodes sending to dest
-    
-    double penalty = std::max(my_penalty_in,max_penalty_out);
-    
-    double rate_before_update = (*it)->action->getBound();
-    //save initial rate of the action
-    if((*it)->init_rate==-1) 
-      (*it)->init_rate= rate_before_update;
-    
-    penalized_bw= ! num_comm_out ? (*it)->init_rate : (*it)->init_rate /penalty;
-    
-    if (!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(p_maxminSystem, (*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 );
+      Be = xbt_str_parse_double(xbt_dynar_get_as(radical_elements, 0, char *), "First part of smpi/IB_penalty_factors is not numerical: %s");
+      Bs = xbt_str_parse_double(xbt_dynar_get_as(radical_elements, 1, char *), "Second part of smpi/IB_penalty_factors is not numerical: %s");
+      ys = xbt_str_parse_double(xbt_dynar_get_as(radical_elements, 2, char *), "Third part of smpi/IB_penalty_factors is not numerical: %s");
+
+      xbt_dynar_free(&radical_elements);
     }
 
     }
 
-  }
-  XBT_DEBUG("Finished computing IB penalties");
-}
+    NetworkIBModel::~NetworkIBModel()
+    {
+      xbt_dict_cursor_t cursor = NULL;
+      IBNode* instance = NULL;
+      char *name = NULL;
+      xbt_dict_foreach(active_nodes, cursor, name, instance)
+      delete instance;
+      xbt_dict_free(&active_nodes);
+    }
 
 
-void NetworkIBModel::updateIBfactors_rec(IBNode *root, bool* updatedlist) {
-  if(updatedlist[root->id]==0){
-    XBT_DEBUG("IB - Updating rec %d", root->id);
-    computeIBfactors(root);
-    updatedlist[root->id]=1;
-    for (std::vector<ActiveComm*>::iterator it= root->ActiveCommsUp.begin(); it != root->ActiveCommsUp.end(); ++it) {
-        if(updatedlist[(*it)->destination->id]!=1)
-          updateIBfactors_rec((*it)->destination, updatedlist);
+    void NetworkIBModel::computeIBfactors(IBNode *root) {
+      double penalized_bw=0.0;
+      double num_comm_out = (double) root->ActiveCommsUp.size();
+      double max_penalty_out=0.0;
+      //first, compute all outbound penalties to get their max
+      for (std::vector<ActiveComm*>::iterator it= root->ActiveCommsUp.begin(); it != root->ActiveCommsUp.end(); ++it) {
+        double my_penalty_out = 1.0;
+
+        if(num_comm_out!=1){
+          if((*it)->destination->nbActiveCommsDown > 2)//number of comms sent to the receiving node
+            my_penalty_out = num_comm_out * Bs * ys;
+          else
+            my_penalty_out = num_comm_out * Bs;
+        }
+
+        max_penalty_out = std::max(max_penalty_out,my_penalty_out);
+      }
+
+      for (std::vector<ActiveComm*>::iterator it= root->ActiveCommsUp.begin(); it != root->ActiveCommsUp.end(); ++it) {
+
+        //compute inbound penalty
+        double my_penalty_in = 1.0;
+        int nb_comms = (*it)->destination->nbActiveCommsDown;//total number of incoming comms
+        if(nb_comms!=1)
+          my_penalty_in = ((*it)->destination->ActiveCommsDown)[root] //number of comm sent to dest by root node
+                                                                * Be
+                                                                * (*it)->destination->ActiveCommsDown.size();//number of different nodes sending to dest
+
+        double penalty = std::max(my_penalty_in,max_penalty_out);
+
+        double rate_before_update = (*it)->action->getBound();
+        //save initial rate of the action
+        if((*it)->init_rate==-1)
+          (*it)->init_rate= rate_before_update;
+
+        penalized_bw= ! num_comm_out ? (*it)->init_rate : (*it)->init_rate /penalty;
+
+        if (!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(p_maxminSystem, (*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 );
+        }
+
+      }
+      XBT_DEBUG("Finished computing IB penalties");
     }
     }
-    for (std::map<IBNode*, int>::iterator it= root->ActiveCommsDown.begin(); it != root->ActiveCommsDown.end(); ++it) {
-        if(updatedlist[it->first->id]!=1)
-          updateIBfactors_rec(it->first, updatedlist);
+
+    void NetworkIBModel::updateIBfactors_rec(IBNode *root, bool* updatedlist) {
+      if(updatedlist[root->id]==0){
+        XBT_DEBUG("IB - Updating rec %d", root->id);
+        computeIBfactors(root);
+        updatedlist[root->id]=1;
+        for (std::vector<ActiveComm*>::iterator it= root->ActiveCommsUp.begin(); it != root->ActiveCommsUp.end(); ++it) {
+          if(updatedlist[(*it)->destination->id]!=1)
+            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)
+            updateIBfactors_rec(it->first, updatedlist);
+        }
+      }
     }
     }
-  }
-}
 
 
 
 
-void NetworkIBModel::updateIBfactors(NetworkAction *action, IBNode *from, IBNode * to, int remove) {
-  if (from == to)//disregard local comms (should use loopback)
-    return;
-  
-  bool* updated=(bool*)xbt_malloc0(xbt_dict_size(active_nodes)*sizeof(bool));
-  ActiveComm* comm=NULL;
-  if(remove){
-    if(to->ActiveCommsDown[from]==1)
-      to->ActiveCommsDown.erase(from);
-    else
-      to->ActiveCommsDown[from]-=1;
-
-    to->nbActiveCommsDown--;
-    for (std::vector<ActiveComm*>::iterator it= from->ActiveCommsUp.begin(); 
-   it != from->ActiveCommsUp.end(); ++it) {
-      if((*it)->action==action){
-  comm=(*it);
-  from->ActiveCommsUp.erase(it);
-  break;
+    void NetworkIBModel::updateIBfactors(NetworkAction *action, IBNode *from, IBNode * to, int remove) {
+      if (from == to)//disregard local comms (should use loopback)
+        return;
+
+      bool* updated=(bool*)xbt_malloc0(xbt_dict_size(active_nodes)*sizeof(bool));
+      ActiveComm* comm=NULL;
+      if(remove){
+        if(to->ActiveCommsDown[from]==1)
+          to->ActiveCommsDown.erase(from);
+        else
+          to->ActiveCommsDown[from]-=1;
+
+        to->nbActiveCommsDown--;
+        for (std::vector<ActiveComm*>::iterator it= from->ActiveCommsUp.begin();
+            it != from->ActiveCommsUp.end(); ++it) {
+          if((*it)->action==action){
+            comm=(*it);
+            from->ActiveCommsUp.erase(it);
+            break;
+          }
+        }
+        action->unref();
+
+      }else{
+        action->ref();
+        ActiveComm* comm=new ActiveComm();
+        comm->action=action;
+        comm->destination=to;
+        from->ActiveCommsUp.push_back(comm);
+
+        to->ActiveCommsDown[from]+=1;
+        to->nbActiveCommsDown++;
       }
       }
+      XBT_DEBUG("IB - Updating %d", from->id);
+      updateIBfactors_rec(from, updated);
+      XBT_DEBUG("IB - Finished updating %d", from->id);
+      if(comm)
+        delete comm;
+      xbt_free(updated);
     }
     }
-    action->unref();
 
 
-  }else{
-    action->ref();
-    ActiveComm* comm=new ActiveComm();
-    comm->action=action;
-    comm->destination=to;
-    from->ActiveCommsUp.push_back(comm);
-
-    to->ActiveCommsDown[from]+=1;
-    to->nbActiveCommsDown++;
   }
   }
-  XBT_DEBUG("IB - Updating %d", from->id);
-  updateIBfactors_rec(from, updated);
-  XBT_DEBUG("IB - Finished updating %d", from->id);
-  if(comm)
-    delete comm;
-  xbt_free(updated);
-}
-
-}
 }
 }
index 553f941..b8357fb 100644 (file)
 #include "network_smpi.hpp"
 
 namespace simgrid {
 #include "network_smpi.hpp"
 
 namespace simgrid {
-namespace surf {
+  namespace surf {
 
 
-class XBT_PRIVATE IBNode;
+    class XBT_PRIVATE IBNode;
 
 
-class XBT_PRIVATE ActiveComm{
-public :
-  //IBNode* origin;
-  IBNode* destination;
-  NetworkAction *action;
-  double init_rate;
-  ActiveComm() : destination(NULL),action(NULL),init_rate(-1){};
-  ~ActiveComm(){};
-};
+    class XBT_PRIVATE ActiveComm{
+    public :
+      //IBNode* origin;
+      IBNode* destination;
+      NetworkAction *action;
+      double init_rate;
+      ActiveComm() : destination(NULL),action(NULL),init_rate(-1){};
+      ~ActiveComm(){};
+    };
 
 
-class IBNode{
-public :
-  int id;
-    //store related links, to ease computation of the penalties
-  std::vector<ActiveComm*> ActiveCommsUp;
-  //store the number of comms received from each node
-  std::map<IBNode*, int> ActiveCommsDown;
-  //number of comms the node is receiving
-  int nbActiveCommsDown;
-  IBNode(int id) : id(id),nbActiveCommsDown(0){};
-  ~IBNode(){};
-};
+    class IBNode{
+    public :
+      int id;
+      //store related links, to ease computation of the penalties
+      std::vector<ActiveComm*> ActiveCommsUp;
+      //store the number of comms received from each node
+      std::map<IBNode*, int> ActiveCommsDown;
+      //number of comms the node is receiving
+      int nbActiveCommsDown;
+      IBNode(int id) : id(id),nbActiveCommsDown(0){};
+      ~IBNode(){};
+    };
 
 
-class XBT_PRIVATE NetworkIBModel : public NetworkSmpiModel {
-private:
-  void updateIBfactors_rec(IBNode *root, bool* updatedlist);
-  void computeIBfactors(IBNode *root);
-public:
-  NetworkIBModel();
-  NetworkIBModel(const char *name);
-  ~NetworkIBModel();
-  void updateIBfactors(NetworkAction *action, IBNode *from, IBNode * to, int remove);
-  
-  xbt_dict_t active_nodes;
-  std::map<NetworkAction *, std::pair<IBNode*,IBNode*> > active_comms;
-  
-  double Bs;
-  double Be;
-  double ys;
+    class XBT_PRIVATE NetworkIBModel : public NetworkSmpiModel {
+    private:
+      void updateIBfactors_rec(IBNode *root, bool* updatedlist);
+      void computeIBfactors(IBNode *root);
+    public:
+      NetworkIBModel();
+      NetworkIBModel(const char *name);
+      ~NetworkIBModel();
+      void updateIBfactors(NetworkAction *action, IBNode *from, IBNode * to, int remove);
 
 
-};
+      xbt_dict_t active_nodes;
+      std::map<NetworkAction *, std::pair<IBNode*,IBNode*> > active_comms;
 
 
-}
+      double Bs;
+      double Be;
+      double ys;
+
+    };
+
+  }
 }
 
 #endif
 }
 
 #endif
index a1cb5d3..4629706 100644 (file)
@@ -13,7 +13,7 @@
 #define NETWORK_INTERFACE_CPP_
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network, surf,
 #define NETWORK_INTERFACE_CPP_
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network, surf,
-                                "Logging specific to the SURF network module");
+    "Logging specific to the SURF network module");
 
 /*********
  * C API *
 
 /*********
  * C API *
@@ -21,37 +21,37 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network, surf,
 
 extern "C" {
 
 
 extern "C" {
 
-const char* sg_link_name(Link *link) {
-  return link->getName();
-}
-Link * sg_link_by_name(const char* name) {
-  return Link::byName(name);
-}
+  const char* sg_link_name(Link *link) {
+    return link->getName();
+  }
+  Link * sg_link_by_name(const char* name) {
+    return Link::byName(name);
+  }
 
 
-int sg_link_is_shared(Link *link){
-  return link->sharingPolicy();
-}
-double sg_link_bandwidth(Link *link){
-  return link->getBandwidth();
-}
-double sg_link_latency(Link *link){
-  return link->getLatency();
-}
-void* sg_link_data(Link *link) {
-  return link->getData();
-}
-void sg_link_data_set(Link *link,void *data) {
-  link->setData(data);
-}
-int sg_link_count(void) {
-  return Link::linksCount();
-}
-Link** sg_link_list(void) {
-  return Link::linksList();
-}
-void sg_link_exit(void) {
-  Link::linksExit();
-}
+  int sg_link_is_shared(Link *link){
+    return link->sharingPolicy();
+  }
+  double sg_link_bandwidth(Link *link){
+    return link->getBandwidth();
+  }
+  double sg_link_latency(Link *link){
+    return link->getLatency();
+  }
+  void* sg_link_data(Link *link) {
+    return link->getData();
+  }
+  void sg_link_data_set(Link *link,void *data) {
+    link->setData(data);
+  }
+  int sg_link_count(void) {
+    return Link::linksCount();
+  }
+  Link** sg_link_list(void) {
+    return Link::linksList();
+  }
+  void sg_link_exit(void) {
+    Link::linksExit();
+  }
 
 }
 
 
 }
 
@@ -60,49 +60,49 @@ void sg_link_exit(void) {
  *****************/
 
 namespace simgrid {
  *****************/
 
 namespace simgrid {
-namespace surf {
+  namespace surf {
 
 
-boost::unordered_map<std::string,Link *> *Link::links = new boost::unordered_map<std::string,Link *>();
-Link *Link::byName(const char* name) {
-    Link * res = NULL;
-    try {
-      res = links->at(name);
-    } catch (std::out_of_range& e) {}
+    boost::unordered_map<std::string,Link *> *Link::links = new boost::unordered_map<std::string,Link *>();
+    Link *Link::byName(const char* name) {
+      Link * res = NULL;
+      try {
+        res = links->at(name);
+      } catch (std::out_of_range& e) {}
 
 
-    return res;
-}
-/** @brief Returns the amount of links in the platform */
-int Link::linksCount() {
-    return links->size();
-}
-/** @brief Returns a list of all existing links */
-Link **Link::linksList() {
-    Link **res = xbt_new(Link*, (int)links->size());
-    int i=0;
-    for (auto kv : *links) {
-      res[i++] = kv.second;
+      return res;
+    }
+    /** @brief Returns the amount of links in the platform */
+    int Link::linksCount() {
+      return links->size();
+    }
+    /** @brief Returns a list of all existing links */
+    Link **Link::linksList() {
+      Link **res = xbt_new(Link*, (int)links->size());
+      int i=0;
+      for (auto kv : *links) {
+        res[i++] = kv.second;
+      }
+      return res;
+    }
+    /** @brief destructor of the static data */
+    void Link::linksExit() {
+      for (auto kv : *links)
+        (kv.second)->destroy();
+      delete links;
     }
     }
-    return res;
-}
-/** @brief destructor of the static data */
-void Link::linksExit() {
-  for (auto kv : *links)
-    (kv.second)->destroy();
-  delete links;
-}
 
 
-/*************
- * Callbacks *
- *************/
+    /*************
    * Callbacks *
    *************/
 
 
-simgrid::xbt::signal<void(simgrid::surf::Link*)> Link::onCreation;
-simgrid::xbt::signal<void(simgrid::surf::Link*)> Link::onDestruction;
-simgrid::xbt::signal<void(simgrid::surf::Link*)> Link::onStateChange;
+    simgrid::xbt::signal<void(simgrid::surf::Link*)> Link::onCreation;
+    simgrid::xbt::signal<void(simgrid::surf::Link*)> Link::onDestruction;
+    simgrid::xbt::signal<void(simgrid::surf::Link*)> Link::onStateChange;
 
 
-simgrid::xbt::signal<void(simgrid::surf::NetworkAction*, e_surf_action_state_t, e_surf_action_state_t)> networkActionStateChangedCallbacks;
-simgrid::xbt::signal<void(simgrid::surf::NetworkAction*, simgrid::surf::NetCard *src, simgrid::surf::NetCard *dst, double size, double rate)> networkCommunicateCallbacks;
+    simgrid::xbt::signal<void(simgrid::surf::NetworkAction*, e_surf_action_state_t, e_surf_action_state_t)> networkActionStateChangedCallbacks;
+    simgrid::xbt::signal<void(simgrid::surf::NetworkAction*, simgrid::surf::NetCard *src, simgrid::surf::NetCard *dst, double size, double rate)> networkCommunicateCallbacks;
 
 
-}
+  }
 }
 
 void netlink_parse_init(sg_platf_link_cbarg_t link){
 }
 
 void netlink_parse_init(sg_platf_link_cbarg_t link){
@@ -110,19 +110,19 @@ void netlink_parse_init(sg_platf_link_cbarg_t link){
     char *link_id;
     link_id = bprintf("%s_UP", link->id);
     surf_network_model->createLink(link_id,
     char *link_id;
     link_id = bprintf("%s_UP", link->id);
     surf_network_model->createLink(link_id,
-                      link->bandwidth,
-                      link->bandwidth_trace,
-                      link->latency,
-                      link->latency_trace,
-                      link->state_trace, link->policy, link->properties);
+        link->bandwidth,
+        link->bandwidth_trace,
+        link->latency,
+        link->latency_trace,
+        link->state_trace, link->policy, link->properties);
     xbt_free(link_id);
     link_id = bprintf("%s_DOWN", link->id);
     surf_network_model->createLink(link_id,
     xbt_free(link_id);
     link_id = bprintf("%s_DOWN", link->id);
     surf_network_model->createLink(link_id,
-                      link->bandwidth,
-                      link->bandwidth_trace,
-                      link->latency,
-                      link->latency_trace,
-                      link->state_trace, link->policy, link->properties);
+        link->bandwidth,
+        link->bandwidth_trace,
+        link->latency,
+        link->latency_trace,
+        link->state_trace, link->policy, link->properties);
     xbt_free(link_id);
   } else {
     surf_network_model->createLink(link->id,
     xbt_free(link_id);
   } else {
     surf_network_model->createLink(link->id,
@@ -141,159 +141,159 @@ void netlink_parse_init(sg_platf_link_cbarg_t link){
 simgrid::surf::NetworkModel *surf_network_model = NULL;
 
 namespace simgrid {
 simgrid::surf::NetworkModel *surf_network_model = NULL;
 
 namespace simgrid {
-namespace surf {
+  namespace surf {
 
 
-double NetworkModel::latencyFactor(double /*size*/) {
-  return sg_latency_factor;
-}
+    double NetworkModel::latencyFactor(double /*size*/) {
+      return sg_latency_factor;
+    }
 
 
-double NetworkModel::bandwidthFactor(double /*size*/) {
-  return sg_bandwidth_factor;
-}
+    double NetworkModel::bandwidthFactor(double /*size*/) {
+      return sg_bandwidth_factor;
+    }
 
 
-double NetworkModel::bandwidthConstraint(double rate, double /*bound*/, double /*size*/) {
-  return rate;
-}
+    double NetworkModel::bandwidthConstraint(double rate, double /*bound*/, double /*size*/) {
+      return rate;
+    }
 
 
-double NetworkModel::next_occuring_event_full(double now)
-{
-  NetworkAction *action = NULL;
-  ActionList *runningActions = surf_network_model->getRunningActionSet();
-  double minRes;
+    double NetworkModel::next_occuring_event_full(double now)
+    {
+      NetworkAction *action = NULL;
+      ActionList *runningActions = surf_network_model->getRunningActionSet();
+      double minRes;
 
 
-  minRes = shareResourcesMaxMin(runningActions, surf_network_model->p_maxminSystem, surf_network_model->f_networkSolve);
+      minRes = shareResourcesMaxMin(runningActions, surf_network_model->p_maxminSystem, surf_network_model->f_networkSolve);
 
 
-  for(ActionList::iterator it(runningActions->begin()), itend(runningActions->end())
-       ; it != itend ; ++it) {
-      action = static_cast<NetworkAction*>(&*it);
+      for(ActionList::iterator it(runningActions->begin()), itend(runningActions->end())
+          ; it != itend ; ++it) {
+        action = static_cast<NetworkAction*>(&*it);
 #ifdef HAVE_LATENCY_BOUND_TRACKING
 #ifdef HAVE_LATENCY_BOUND_TRACKING
-    if (lmm_is_variable_limited_by_latency(action->getVariable())) {
-      action->m_latencyLimited = 1;
-    } else {
-      action->m_latencyLimited = 0;
-    }
+        if (lmm_is_variable_limited_by_latency(action->getVariable())) {
+          action->m_latencyLimited = 1;
+        } else {
+          action->m_latencyLimited = 0;
+        }
 #endif
 #endif
-    if (action->m_latency > 0) {
-      minRes = (minRes < 0) ? action->m_latency : std::min(minRes, action->m_latency);
-    }
-  }
+        if (action->m_latency > 0) {
+          minRes = (minRes < 0) ? action->m_latency : std::min(minRes, action->m_latency);
+        }
+      }
 
 
-  XBT_DEBUG("Min of share resources %f", minRes);
+      XBT_DEBUG("Min of share resources %f", minRes);
 
 
-  return minRes;
-}
+      return minRes;
+    }
 
 
-/************
- * Resource *
- ************/
+    /************
    * Resource *
    ************/
 
 
-Link::Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props)
-: Resource(model, name),
-  PropertyHolder(props)
-{
-  links->insert({name, this});
+    Link::Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props)
+    : Resource(model, name),
+      PropertyHolder(props)
+    {
+      links->insert({name, this});
 
 
-  m_latency.scale = 1;
-  m_bandwidth.scale = 1;
-  XBT_DEBUG("Create link '%s'",name);
-}
+      m_latency.scale = 1;
+      m_bandwidth.scale = 1;
+      XBT_DEBUG("Create link '%s'",name);
+    }
 
 
-Link::Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props,
-                     lmm_constraint_t constraint,
-                       tmgr_trace_t state_trace)
-: Resource(model, name, constraint),
-  PropertyHolder(props)
-{
-  m_latency.scale = 1;
-  m_bandwidth.scale = 1;
-  if (state_trace)
-    m_stateEvent = future_evt_set->add_trace(state_trace, 0.0, this);
+    Link::Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props,
+        lmm_constraint_t constraint,
+        tmgr_trace_t state_trace)
+    : Resource(model, name, constraint),
+      PropertyHolder(props)
+    {
+      m_latency.scale = 1;
+      m_bandwidth.scale = 1;
+      if (state_trace)
+        m_stateEvent = future_evt_set->add_trace(state_trace, 0.0, this);
 
 
-  links->insert({name, this});
-  XBT_DEBUG("Create link '%s'",name);
+      links->insert({name, this});
+      XBT_DEBUG("Create link '%s'",name);
 
 
-}
+    }
 
 
-/** @brief use destroy() instead of this destructor */
-Link::~Link() {
-  xbt_assert(currentlyDestroying_, "Don't delete Links directly. Call destroy() instead.");
-}
-/** @brief Fire the require callbacks and destroy the object
- *
- * Don't delete directly an Link, call l->destroy() instead.
- */
-void Link::destroy()
-{
-  if (!currentlyDestroying_) {
-    currentlyDestroying_ = true;
-    onDestruction(this);
-    delete this;
-  }
-}
+    /** @brief use destroy() instead of this destructor */
+    Link::~Link() {
+      xbt_assert(currentlyDestroying_, "Don't delete Links directly. Call destroy() instead.");
+    }
+    /** @brief Fire the require callbacks and destroy the object
    *
    * Don't delete directly an Link, call l->destroy() instead.
    */
+    void Link::destroy()
+    {
+      if (!currentlyDestroying_) {
+        currentlyDestroying_ = true;
+        onDestruction(this);
+        delete this;
+      }
+    }
 
 
-bool Link::isUsed()
-{
-  return lmm_constraint_used(getModel()->getMaxminSystem(), getConstraint());
-}
+    bool Link::isUsed()
+    {
+      return lmm_constraint_used(getModel()->getMaxminSystem(), getConstraint());
+    }
 
 
-double Link::getLatency()
-{
-  return m_latency.peak * m_latency.scale;
-}
+    double Link::getLatency()
+    {
+      return m_latency.peak * m_latency.scale;
+    }
 
 
-double Link::getBandwidth()
-{
-  return m_bandwidth.peak * m_bandwidth.scale;
-}
+    double Link::getBandwidth()
+    {
+      return m_bandwidth.peak * m_bandwidth.scale;
+    }
 
 
-int Link::sharingPolicy()
-{
-  return lmm_constraint_sharing_policy(getConstraint());
-}
+    int Link::sharingPolicy()
+    {
+      return lmm_constraint_sharing_policy(getConstraint());
+    }
 
 
-void Link::turnOn(){
-  if (isOff()) {
-    Resource::turnOn();
-    onStateChange(this);
-  }
-}
-void Link::turnOff(){
-  if (isOn()) {
-    Resource::turnOff();
-    onStateChange(this);
-  }
-}
-void Link::set_state_trace(tmgr_trace_t trace)
-{
-  xbt_assert(m_stateEvent==NULL,"Cannot set a second state trace to Link %s", getName());
+    void Link::turnOn(){
+      if (isOff()) {
+        Resource::turnOn();
+        onStateChange(this);
+      }
+    }
+    void Link::turnOff(){
+      if (isOn()) {
+        Resource::turnOff();
+        onStateChange(this);
+      }
+    }
+    void Link::set_state_trace(tmgr_trace_t trace)
+    {
+      xbt_assert(m_stateEvent==NULL,"Cannot set a second state trace to Link %s", getName());
 
 
-  m_stateEvent = future_evt_set->add_trace(trace, 0.0, this);
-}
-void Link::set_bandwidth_trace(tmgr_trace_t trace)
-{
-  xbt_assert(m_bandwidth.event==NULL,"Cannot set a second bandwidth trace to Link %s", getName());
+      m_stateEvent = future_evt_set->add_trace(trace, 0.0, this);
+    }
+    void Link::set_bandwidth_trace(tmgr_trace_t trace)
+    {
+      xbt_assert(m_bandwidth.event==NULL,"Cannot set a second bandwidth trace to Link %s", getName());
 
 
-  m_bandwidth.event = future_evt_set->add_trace(trace, 0.0, this);
-}
-void Link::set_latency_trace(tmgr_trace_t trace)
-{
-  xbt_assert(m_latency.event==NULL,"Cannot set a second latency trace to Link %s", getName());
+      m_bandwidth.event = future_evt_set->add_trace(trace, 0.0, this);
+    }
+    void Link::set_latency_trace(tmgr_trace_t trace)
+    {
+      xbt_assert(m_latency.event==NULL,"Cannot set a second latency trace to Link %s", getName());
 
 
-  m_latency.event = future_evt_set->add_trace(trace, 0.0, this);
-}
+      m_latency.event = future_evt_set->add_trace(trace, 0.0, this);
+    }
 
 
 
 
-/**********
- * Action *
- **********/
+    /**********
    * Action *
    **********/
 
 
-void NetworkAction::setState(e_surf_action_state_t state){
-  e_surf_action_state_t old = getState();
-  Action::setState(state);
-  networkActionStateChangedCallbacks(this, old, state);
-}
+    void NetworkAction::setState(e_surf_action_state_t state){
+      e_surf_action_state_t old = getState();
+      Action::setState(state);
+      networkActionStateChangedCallbacks(this, old, state);
+    }
 
 
-}
+  }
 }
 
 #endif /* NETWORK_INTERFACE_CPP_ */
 }
 
 #endif /* NETWORK_INTERFACE_CPP_ */
index 1977d96..1b69f74 100644 (file)
  ***********/
 
 namespace simgrid {
  ***********/
 
 namespace simgrid {
-namespace surf {
+  namespace surf {
 
 
-class NetworkModel;
-class NetworkAction;
+    class NetworkModel;
+    class NetworkAction;
 
 
-/*************
- * Callbacks *
- *************/
+    /*************
    * Callbacks *
    *************/
 
 
 
 
-/** @brief Callback signal fired when the state of a NetworkAction changes
- *  Signature: `void(NetworkAction *action, e_surf_action_state_t old, e_surf_action_state_t current)` */
-XBT_PUBLIC_DATA(simgrid::xbt::signal<void(simgrid::surf::NetworkAction*, e_surf_action_state_t, e_surf_action_state_t)>) networkActionStateChangedCallbacks;
+    /** @brief Callback signal fired when the state of a NetworkAction changes
    *  Signature: `void(NetworkAction *action, e_surf_action_state_t old, e_surf_action_state_t current)` */
+    XBT_PUBLIC_DATA(simgrid::xbt::signal<void(simgrid::surf::NetworkAction*, e_surf_action_state_t, e_surf_action_state_t)>) networkActionStateChangedCallbacks;
 
 
-/** @brief Callback signal fired when a NetworkAction is created (when a communication starts)
- *  Signature: `void(NetworkAction *action, RoutingEdge *src, RoutingEdge *dst, double size, double rate)` */
-XBT_PUBLIC_DATA(simgrid::xbt::signal<void(simgrid::surf::NetworkAction*, simgrid::surf::NetCard *src, simgrid::surf::NetCard *dst, double size, double rate)>) networkCommunicateCallbacks;
+    /** @brief Callback signal fired when a NetworkAction is created (when a communication starts)
    *  Signature: `void(NetworkAction *action, RoutingEdge *src, RoutingEdge *dst, double size, double rate)` */
+    XBT_PUBLIC_DATA(simgrid::xbt::signal<void(simgrid::surf::NetworkAction*, simgrid::surf::NetCard *src, simgrid::surf::NetCard *dst, double size, double rate)>) networkCommunicateCallbacks;
 
 
-}
+  }
 }
 
 /*********
 }
 
 /*********
@@ -55,264 +55,264 @@ XBT_PUBLIC(void) netlink_parse_init(sg_platf_link_cbarg_t link);
  *********/
 
 namespace simgrid {
  *********/
 
 namespace simgrid {
-namespace surf {
-
-/** @ingroup SURF_network_interface
- * @brief SURF network model interface class
- * @details A model is an object which handles the interactions between its Resources and its Actions
- */
-class NetworkModel : public Model {
-public:
-  /** @brief Constructor */
-  NetworkModel() : Model() { }
-
-  /** @brief Destructor */
-  ~NetworkModel() {
-  if (p_maxminSystem)
-    lmm_system_free(p_maxminSystem);
-  if (p_actionHeap)
-    xbt_heap_free(p_actionHeap);
-  if (p_modifiedSet)
-    delete p_modifiedSet;
-  }
-
-  /**
-   * @brief Create a Link
-   *
-   * @param name The name of the Link
-   * @param bw_initial The initial bandwidth of the Link in bytes per second
-   * @param bw_trace The trace associated to the Link bandwidth
-   * @param lat_initial The initial latency of the Link in seconds
-   * @param lat_trace The trace associated to the Link latency
-   * @param state_trace The trace associated to the Link (state)[e_surf_resource_state_t]
-   * @param policy The sharing policy of the Link
-   * @param properties Dictionary of properties associated to this Resource
-   * @return The created Link
-   */
-  virtual Link* createLink(const char *name,
-                                   double bw_initial,
-                                   tmgr_trace_t bw_trace,
-                                   double lat_initial,
-                                   tmgr_trace_t lat_trace,
-                                   tmgr_trace_t state_trace,
-                                   e_surf_link_sharing_policy_t policy,
-                                   xbt_dict_t properties)=0;
-
-  /**
-   * @brief Create a communication between two hosts.
-   * @details It makes calls to the routing part, and execute the communication
-   * between the two end points.
-   *
-   * @param src The source of the communication
-   * @param dst The destination of the communication
-   * @param size The size of the communication in bytes
-   * @param rate Allows to limit the transfer rate. Negative value means
-   * unlimited.
-   * @return The action representing the communication
-   */
-  virtual Action *communicate(NetCard *src, NetCard *dst,
-                               double size, double rate)=0;
-
-  /** @brief Function pointer to the function to use to solve the lmm_system_t
-   *
-   * @param system The lmm_system_t to solve
-   */
-  void (*f_networkSolve)(lmm_system_t) = lmm_solve;
-
-  /**
-   * @brief Get the right multiplicative factor for the latency.
-   * @details Depending on the model, the effective latency when sending
-   * a message might be different from the theoretical latency of the link,
-   * in function of the message size. In order to account for this, this
-   * function gets this factor.
-   *
-   * @param size The size of the message.
-   * @return The latency factor.
-   */
-  virtual double latencyFactor(double size);
-
-  /**
-   * @brief Get the right multiplicative factor for the bandwidth.
-   * @details Depending on the model, the effective bandwidth when sending
-   * a message might be different from the theoretical bandwidth of the link,
-   * in function of the message size. In order to account for this, this
-   * function gets this factor.
-   *
-   * @param size The size of the message.
-   * @return The bandwidth factor.
-   */
-  virtual double bandwidthFactor(double size);
-
-  /**
-   * @brief Get definitive bandwidth.
-   * @details It gives the minimum bandwidth between the one that would
-   * occur if no limitation was enforced, and the one arbitrary limited.
-   * @param rate The desired maximum bandwidth.
-   * @param bound The bandwidth with only the network taken into account.
-   * @param size The size of the message.
-   * @return The new bandwidth.
-   */
-  virtual double bandwidthConstraint(double rate, double bound, double size);
-  double next_occuring_event_full(double now) override;
-};
-
-/************
- * Resource *
- ************/
- /** @ingroup SURF_network_interface
-  * @brief SURF network link interface class
-  * @details A Link represents the link between two [hosts](\ref Host)
-  */
-class Link :
-    public simgrid::surf::Resource,
-    public simgrid::surf::PropertyHolder {
-public:
-  /**
-   * @brief Link constructor
-   *
-   * @param model The NetworkModel associated to this Link
-   * @param name The name of the Link
-   * @param props Dictionary of properties associated to this Link
-   */
-  Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props);
-
-  /**
-   * @brief Link constructor
-   *
-   * @param model The NetworkModel associated to this Link
-   * @param name The name of the Link
-   * @param props Dictionary of properties associated to this Link
-   * @param constraint The lmm constraint associated to this Cpu if it is part of a LMM component
-   * @param state_trace [TODO]
-   */
-  Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props,
-              lmm_constraint_t constraint,
-              tmgr_trace_t state_trace);
-
-  /* Link destruction logic */
-  /**************************/
-protected:
-  ~Link();
-public:
-  void destroy(); // Must be called instead of the destructor
-private:
-  bool currentlyDestroying_ = false;
-
-public:
-  /** @brief Callback signal fired when a new Link is created.
-   *  Signature: void(Link*) */
-  static simgrid::xbt::signal<void(simgrid::surf::Link*)> onCreation;
-
-  /** @brief Callback signal fired when a Link is destroyed.
-   *  Signature: void(Link*) */
-  static simgrid::xbt::signal<void(simgrid::surf::Link*)> onDestruction;
-
-  /** @brief Callback signal fired when the state of a Link changes (when it is turned on or off)
-   *  Signature: `void(Link*)` */
-  static simgrid::xbt::signal<void(simgrid::surf::Link*)> onStateChange;
-
-
-  /** @brief Get the bandwidth in bytes per second of current Link */
-  virtual double getBandwidth();
-
-  /** @brief Update the bandwidth in bytes per second of current Link */
-  virtual void updateBandwidth(double value)=0;
-
-  /** @brief Get the latency in seconds of current Link */
-  virtual double getLatency();
-
-  /** @brief Update the latency in seconds of current Link */
-  virtual void updateLatency(double value)=0;
-
-  /** @brief The sharing policy is a @{link e_surf_link_sharing_policy_t::EType} (0: FATPIPE, 1: SHARED, 2: FULLDUPLEX) */
-  virtual int sharingPolicy();
-
-  /** @brief Check if the Link is used */
-  bool isUsed() override;
-
-  void turnOn() override;
-  void turnOff() override;
-
-  virtual void set_state_trace(tmgr_trace_t trace); /*< setup the trace file with states events (ON or OFF). Trace must contain boolean values. */
-  virtual void set_bandwidth_trace(tmgr_trace_t trace); /*< setup the trace file with bandwidth events (peak speed changes due to external load). Trace must contain percentages (value between 0 and 1). */
-  virtual void set_latency_trace(tmgr_trace_t trace); /*< setup the trace file with latency events (peak latency changes due to external load). Trace must contain absolute values */
-
-  tmgr_trace_iterator_t m_stateEvent = NULL;
-  s_surf_metric_t m_latency = {1.0,0,NULL};
-  s_surf_metric_t m_bandwidth = {1.0,0,NULL};
-
-  /* User data */
-public:
-  void *getData()        { return userData;}
-  void  setData(void *d) { userData=d;}
-private:
-  void *userData = NULL;
-
-  /* List of all links */
-private:
-  static boost::unordered_map<std::string, Link *> *links;
-public:
-  static Link *byName(const char* name);
-  static int linksCount();
-  static Link **linksList();
-  static void linksExit();
-};
-
-/**********
- * Action *
- **********/
-/** @ingroup SURF_network_interface
- * @brief SURF network action interface class
- * @details A NetworkAction represents a communication between two [hosts](\ref Host)
- */
-class NetworkAction : public simgrid::surf::Action {
-public:
-  /** @brief Constructor
-   *
-   * @param model The NetworkModel associated to this NetworkAction
-   * @param cost The cost of this  NetworkAction in [TODO]
-   * @param failed [description]
-   */
-  NetworkAction(simgrid::surf::Model *model, double cost, bool failed)
-  : simgrid::surf::Action(model, cost, failed) {}
-
-  /**
-   * @brief NetworkAction constructor
-   *
-   * @param model The NetworkModel associated to this NetworkAction
-   * @param cost The cost of this  NetworkAction in [TODO]
-   * @param failed [description]
-   * @param var The lmm variable associated to this Action if it is part of a
-   * LMM component
-   */
-  NetworkAction(simgrid::surf::Model *model, double cost, bool failed, lmm_variable_t var)
-  : simgrid::surf::Action(model, cost, failed, var) {};
-
-  void setState(e_surf_action_state_t state);
+  namespace surf {
+
+    /** @ingroup SURF_network_interface
    * @brief SURF network model interface class
    * @details A model is an object which handles the interactions between its Resources and its Actions
    */
+    class NetworkModel : public Model {
+    public:
+      /** @brief Constructor */
+      NetworkModel() : Model() { }
+
+      /** @brief Destructor */
+      ~NetworkModel() {
+        if (p_maxminSystem)
+          lmm_system_free(p_maxminSystem);
+        if (p_actionHeap)
+          xbt_heap_free(p_actionHeap);
+        if (p_modifiedSet)
+          delete p_modifiedSet;
+      }
+
+      /**
+       * @brief Create a Link
+       *
+       * @param name The name of the Link
+       * @param bw_initial The initial bandwidth of the Link in bytes per second
+       * @param bw_trace The trace associated to the Link bandwidth
+       * @param lat_initial The initial latency of the Link in seconds
+       * @param lat_trace The trace associated to the Link latency
+       * @param state_trace The trace associated to the Link (state)[e_surf_resource_state_t]
+       * @param policy The sharing policy of the Link
+       * @param properties Dictionary of properties associated to this Resource
+       * @return The created Link
+       */
+      virtual Link* createLink(const char *name,
+          double bw_initial,
+          tmgr_trace_t bw_trace,
+          double lat_initial,
+          tmgr_trace_t lat_trace,
+          tmgr_trace_t state_trace,
+          e_surf_link_sharing_policy_t policy,
+          xbt_dict_t properties)=0;
+
+      /**
+       * @brief Create a communication between two hosts.
+       * @details It makes calls to the routing part, and execute the communication
+       * between the two end points.
+       *
+       * @param src The source of the communication
+       * @param dst The destination of the communication
+       * @param size The size of the communication in bytes
+       * @param rate Allows to limit the transfer rate. Negative value means
+       * unlimited.
+       * @return The action representing the communication
+       */
+      virtual Action *communicate(NetCard *src, NetCard *dst,
+          double size, double rate)=0;
+
+      /** @brief Function pointer to the function to use to solve the lmm_system_t
+       *
+       * @param system The lmm_system_t to solve
+       */
+      void (*f_networkSolve)(lmm_system_t) = lmm_solve;
+
+      /**
+       * @brief Get the right multiplicative factor for the latency.
+       * @details Depending on the model, the effective latency when sending
+       * a message might be different from the theoretical latency of the link,
+       * in function of the message size. In order to account for this, this
+       * function gets this factor.
+       *
+       * @param size The size of the message.
+       * @return The latency factor.
+       */
+      virtual double latencyFactor(double size);
+
+      /**
+       * @brief Get the right multiplicative factor for the bandwidth.
+       * @details Depending on the model, the effective bandwidth when sending
+       * a message might be different from the theoretical bandwidth of the link,
+       * in function of the message size. In order to account for this, this
+       * function gets this factor.
+       *
+       * @param size The size of the message.
+       * @return The bandwidth factor.
+       */
+      virtual double bandwidthFactor(double size);
+
+      /**
+       * @brief Get definitive bandwidth.
+       * @details It gives the minimum bandwidth between the one that would
+       * occur if no limitation was enforced, and the one arbitrary limited.
+       * @param rate The desired maximum bandwidth.
+       * @param bound The bandwidth with only the network taken into account.
+       * @param size The size of the message.
+       * @return The new bandwidth.
+       */
+      virtual double bandwidthConstraint(double rate, double bound, double size);
+      double next_occuring_event_full(double now) override;
+    };
+
+    /************
    * Resource *
    ************/
   /** @ingroup SURF_network_interface
+     * @brief SURF network link interface class
+     * @details A Link represents the link between two [hosts](\ref Host)
+     */
+    class Link :
+        public simgrid::surf::Resource,
+        public simgrid::surf::PropertyHolder {
+        public:
+      /**
+       * @brief Link constructor
+       *
+       * @param model The NetworkModel associated to this Link
+       * @param name The name of the Link
+       * @param props Dictionary of properties associated to this Link
+       */
+      Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props);
+
+      /**
+       * @brief Link constructor
+       *
+       * @param model The NetworkModel associated to this Link
+       * @param name The name of the Link
+       * @param props Dictionary of properties associated to this Link
+       * @param constraint The lmm constraint associated to this Cpu if it is part of a LMM component
+       * @param state_trace [TODO]
+       */
+      Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props,
+          lmm_constraint_t constraint,
+          tmgr_trace_t state_trace);
+
+      /* Link destruction logic */
+      /**************************/
+        protected:
+      ~Link();
+        public:
+      void destroy(); // Must be called instead of the destructor
+        private:
+      bool currentlyDestroying_ = false;
+
+        public:
+      /** @brief Callback signal fired when a new Link is created.
+       *  Signature: void(Link*) */
+      static simgrid::xbt::signal<void(simgrid::surf::Link*)> onCreation;
+
+      /** @brief Callback signal fired when a Link is destroyed.
+       *  Signature: void(Link*) */
+      static simgrid::xbt::signal<void(simgrid::surf::Link*)> onDestruction;
+
+      /** @brief Callback signal fired when the state of a Link changes (when it is turned on or off)
+       *  Signature: `void(Link*)` */
+      static simgrid::xbt::signal<void(simgrid::surf::Link*)> onStateChange;
+
+
+      /** @brief Get the bandwidth in bytes per second of current Link */
+      virtual double getBandwidth();
+
+      /** @brief Update the bandwidth in bytes per second of current Link */
+      virtual void updateBandwidth(double value)=0;
+
+      /** @brief Get the latency in seconds of current Link */
+      virtual double getLatency();
+
+      /** @brief Update the latency in seconds of current Link */
+      virtual void updateLatency(double value)=0;
+
+      /** @brief The sharing policy is a @{link e_surf_link_sharing_policy_t::EType} (0: FATPIPE, 1: SHARED, 2: FULLDUPLEX) */
+      virtual int sharingPolicy();
+
+      /** @brief Check if the Link is used */
+      bool isUsed() override;
+
+      void turnOn() override;
+      void turnOff() override;
+
+      virtual void set_state_trace(tmgr_trace_t trace); /*< setup the trace file with states events (ON or OFF). Trace must contain boolean values. */
+      virtual void set_bandwidth_trace(tmgr_trace_t trace); /*< setup the trace file with bandwidth events (peak speed changes due to external load). Trace must contain percentages (value between 0 and 1). */
+      virtual void set_latency_trace(tmgr_trace_t trace); /*< setup the trace file with latency events (peak latency changes due to external load). Trace must contain absolute values */
+
+      tmgr_trace_iterator_t m_stateEvent = NULL;
+      s_surf_metric_t m_latency = {1.0,0,NULL};
+      s_surf_metric_t m_bandwidth = {1.0,0,NULL};
+
+      /* User data */
+        public:
+      void *getData()        { return userData;}
+      void  setData(void *d) { userData=d;}
+        private:
+      void *userData = NULL;
+
+      /* List of all links */
+        private:
+      static boost::unordered_map<std::string, Link *> *links;
+        public:
+      static Link *byName(const char* name);
+      static int linksCount();
+      static Link **linksList();
+      static void linksExit();
+    };
+
+    /**********
    * Action *
    **********/
+    /** @ingroup SURF_network_interface
    * @brief SURF network action interface class
    * @details A NetworkAction represents a communication between two [hosts](\ref Host)
    */
+    class NetworkAction : public simgrid::surf::Action {
+    public:
+      /** @brief Constructor
+       *
+       * @param model The NetworkModel associated to this NetworkAction
+       * @param cost The cost of this  NetworkAction in [TODO]
+       * @param failed [description]
+       */
+      NetworkAction(simgrid::surf::Model *model, double cost, bool failed)
+    : simgrid::surf::Action(model, cost, failed) {}
+
+      /**
+       * @brief NetworkAction constructor
+       *
+       * @param model The NetworkModel associated to this NetworkAction
+       * @param cost The cost of this  NetworkAction in [TODO]
+       * @param failed [description]
+       * @param var The lmm variable associated to this Action if it is part of a
+       * LMM component
+       */
+      NetworkAction(simgrid::surf::Model *model, double cost, bool failed, lmm_variable_t var)
+      : simgrid::surf::Action(model, cost, failed, var) {};
+
+      void setState(e_surf_action_state_t state);
 
 #ifdef HAVE_LATENCY_BOUND_TRACKING
 
 #ifdef HAVE_LATENCY_BOUND_TRACKING
-  /**
-   * @brief Check if the action is limited by latency.
-   *
-   * @return 1 if action is limited by latency, 0 otherwise
-   */
-  virtual int getLatencyLimited() {return m_latencyLimited;}
+      /**
+       * @brief Check if the action is limited by latency.
+       *
+       * @return 1 if action is limited by latency, 0 otherwise
+       */
+      virtual int getLatencyLimited() {return m_latencyLimited;}
 #endif
 
 #endif
 
-  double m_latency;
-  double m_latCurrent;
-  double m_weight;
-  double m_rate;
-  const char* p_senderLinkName;
-  double m_senderSize;
-  xbt_fifo_item_t p_senderFifoItem;
+      double m_latency;
+      double m_latCurrent;
+      double m_weight;
+      double m_rate;
+      const char* p_senderLinkName;
+      double m_senderSize;
+      xbt_fifo_item_t p_senderFifoItem;
 #ifdef HAVE_LATENCY_BOUND_TRACKING
 #ifdef HAVE_LATENCY_BOUND_TRACKING
-  int m_latencyLimited;
+      int m_latencyLimited;
 #endif
 
 #endif
 
-};
+    };
 
 
-}
+  }
 }
 
 #endif /* SURF_NETWORK_INTERFACE_HPP_ */
 }
 
 #endif /* SURF_NETWORK_INTERFACE_HPP_ */
index 30cf4ee..c369fdb 100644 (file)
@@ -9,45 +9,31 @@
 #include "network_cm02.hpp"
 
 namespace simgrid {
 #include "network_cm02.hpp"
 
 namespace simgrid {
-namespace surf {
+  namespace surf {
 
 
-/***********
- * Classes *
- ***********/
+    class XBT_PRIVATE NetworkSmpiModel : public NetworkCm02Model {
+    public:
+      NetworkSmpiModel();
+      ~NetworkSmpiModel();
 
 
-class XBT_PRIVATE NetworkSmpiModel;
+      using NetworkCm02Model::gapAppend; // Explicit about overloaded method (silence Woverloaded-virtual from clang)
+      void gapAppend(double size, Link* link, NetworkAction *action);
+      void gapRemove(Action *action);
+      double latencyFactor(double size);
+      double bandwidthFactor(double size);
+      double bandwidthConstraint(double rate, double bound, double size);
+      void communicateCallBack() {};
+    };
 
 
-/*********
- * Tools *
- *********/
 
 
-/*********
* Model *
- *********/
+    /************
    * Resource *
    ************/
 
 
-class NetworkSmpiModel : public NetworkCm02Model {
-public:
-  NetworkSmpiModel();
-  ~NetworkSmpiModel();
 
 
-  using NetworkCm02Model::gapAppend; // Explicit about overloaded method (silence Woverloaded-virtual from clang)
-  void gapAppend(double size, Link* link, NetworkAction *action);
-  void gapRemove(Action *action);
-  double latencyFactor(double size);
-  double bandwidthFactor(double size);
-  double bandwidthConstraint(double rate, double bound, double size);
-  void communicateCallBack() {};
-};
+    /**********
+     * Action *
+     **********/
 
 
-
-/************
- * Resource *
- ************/
-
-
-/**********
- * Action *
- **********/
-
-}
+  }
 }
 }