Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
sort out the Link::onCommunicate signal
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 26 Mar 2016 10:09:16 +0000 (11:09 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 26 Mar 2016 10:09:16 +0000 (11:09 +0100)
src/surf/network_cm02.cpp
src/surf/network_constant.cpp
src/surf/network_ib.cpp
src/surf/network_interface.cpp
src/surf/network_interface.hpp
src/surf/network_ns3.cpp

index a32ccb8..37d0970 100644 (file)
@@ -386,7 +386,7 @@ Action *NetworkCm02Model::communicate(NetCard *src, NetCard *dst, double size, d
   delete route;
   XBT_OUT();
 
-  networkCommunicateCallbacks(action, src, dst, size, rate);
+  Link::onCommunicate(action, src, dst);
   return action;
 }
 
index e68c91d..fe3356d 100644 (file)
@@ -78,17 +78,11 @@ namespace simgrid {
       }
     }
 
-    Action *NetworkConstantModel::communicate(NetCard *src, NetCard *dst,
-        double size, double rate)
+    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();
 
-      networkCommunicateCallbacks(action, src, dst, size, rate);
+      Link::onCommunicate(action, src, dst);
       return action;
     }
 
index de2c180..eed2ba8 100644 (file)
@@ -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,7 +81,6 @@ 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;
@@ -100,7 +89,7 @@ void surf_network_model_init_IB(void)
   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);
 
index a4b3e23..e2ae780 100644 (file)
@@ -96,7 +96,7 @@ namespace simgrid {
     simgrid::xbt::signal<void(simgrid::surf::Link*)> Link::onStateChange;
 
     simgrid::xbt::signal<void(simgrid::surf::NetworkAction*, simgrid::surf::Action::State, simgrid::surf::Action::State)> 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*, simgrid::surf::NetCard *src, simgrid::surf::NetCard *dst)> Link::onCommunicate;
 
   }
 }
index 4b4c256..b5330ad 100644 (file)
@@ -38,11 +38,7 @@ namespace simgrid {
      *  Signature: `void(NetworkAction *action, simgrid::surf::Action::State old, simgrid::surf::Action::State current)` */
     XBT_PUBLIC_DATA(simgrid::xbt::signal<void(simgrid::surf::NetworkAction*, simgrid::surf::Action::State, simgrid::surf::Action::State)>) 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;
-
-  }
+      }
 }
 
 /*********
@@ -197,6 +193,11 @@ namespace simgrid {
        *  Signature: `void(Link*)` */
       static simgrid::xbt::signal<void(simgrid::surf::Link*)> onStateChange;
 
+      /** @brief Callback signal fired when a communication starts
+       *  Signature: `void(NetworkAction *action, RoutingEdge *src, RoutingEdge *dst)` */
+      static simgrid::xbt::signal<void(simgrid::surf::NetworkAction*, simgrid::surf::NetCard *src, simgrid::surf::NetCard *dst)> onCommunicate;
+
+
 
       /** @brief Get the bandwidth in bytes per second of current Link */
       virtual double getBandwidth();
index 606da4f..ceb4afc 100644 (file)
@@ -368,7 +368,7 @@ NetworkNS3Action::NetworkNS3Action(Model *model, double size, NetCard *src, NetC
   dstElm_ = dst;
   ns3_create_flow(src->name(), dst->name(), surf_get_clock(), size, this);
 
-  networkCommunicateCallbacks(this, src, dst, size, 0);
+  Link::onCommunicate(this, src, dst);
 }
 
 void NetworkNS3Action::suspend() {