Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
further rework the config handling. Still much to do
[simgrid.git] / src / surf / network_ib.cpp
index 7b743d5..b39302c 100644 (file)
@@ -33,10 +33,10 @@ static void IB_create_host_callback(simgrid::s4u::Host& host){
 
 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::Action::State statein, simgrid::surf::Action::State stateout)
 {
   using namespace simgrid::surf;
-  if(statein!=SURF_ACTION_RUNNING|| stateout!=SURF_ACTION_DONE)
+  if(statein!=simgrid::surf::Action::State::running || stateout!=simgrid::surf::Action::State::done)
     return;
   std::pair<IBNode*,IBNode*> pair = ((NetworkIBModel*)surf_network_model)->active_comms[action];
   XBT_DEBUG("IB callback - action %p finished", action);
@@ -49,29 +49,19 @@ static void IB_action_state_changed_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)
 {
-  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;
+  simgrid::surf::NetworkIBModel* ibModel = (simgrid::surf::NetworkIBModel*)surf_network_model;
 
-  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;
+  simgrid::surf::IBNode* act_src= (simgrid::surf::IBNode*) xbt_dict_get_or_null(ibModel->active_nodes, src->name());
+  xbt_assert(act_src, "could not find src node active comms !");
 
-  ((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);
+  simgrid::surf::IBNode* act_dst= (simgrid::surf::IBNode*) xbt_dict_get_or_null(ibModel->active_nodes, dst->name());
+  xbt_assert(act_dst, "could not find dst node active comms !");
 
-  ((NetworkIBModel*)surf_network_model)->updateIBfactors(action, act_src, act_dst, 0);
+  ibModel->active_comms[action]=std::make_pair(act_src, act_dst);
 
+  ibModel->updateIBfactors(action, act_src, act_dst, 0);
 }
 
 /*********
@@ -91,18 +81,16 @@ static void IB_action_init_callback(
 void surf_network_model_init_IB(void)
 {
   using simgrid::surf::networkActionStateChangedCallbacks;
-  using simgrid::surf::networkCommunicateCallbacks;
 
   if (surf_network_model)
     return;
 
-  simgrid::surf::on_link.connect(netlink_parse_init);
   surf_network_model = new simgrid::surf::NetworkIBModel();
   xbt_dynar_push(all_existing_models, &surf_network_model);
   networkActionStateChangedCallbacks.connect(IB_action_state_changed_callback);
-  networkCommunicateCallbacks.connect(IB_action_init_callback);
+  Link::onCommunicate.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);
+  xbt_cfg_setdefault_double("network/weight_S", 8775);
 
 }
 
@@ -113,7 +101,7 @@ namespace simgrid {
 
     NetworkIBModel::NetworkIBModel()
     : NetworkSmpiModel() {
-      m_haveGap=false;
+      haveGap_=false;
       active_nodes=NULL;
 
       const char* IB_factors_string=sg_cfg_get_string("smpi/IB_penalty_factors");
@@ -178,7 +166,7 @@ namespace simgrid {
 
         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);
+          lmm_update_variable_bound(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 );
         }