From: Martin Quinson Date: Sat, 26 Mar 2016 10:09:16 +0000 (+0100) Subject: sort out the Link::onCommunicate signal X-Git-Tag: v3_13~282 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/353856867665015bd39041aacba13ad22035287c sort out the Link::onCommunicate signal --- diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index a32ccb8033..37d0970afe 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -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; } diff --git a/src/surf/network_constant.cpp b/src/surf/network_constant.cpp index e68c91d532..fe3356da4f 100644 --- a/src/surf/network_constant.cpp +++ b/src/surf/network_constant.cpp @@ -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; } diff --git a/src/surf/network_ib.cpp b/src/surf/network_ib.cpp index de2c180fa3..eed2ba8f1a 100644 --- a/src/surf/network_ib.cpp +++ b/src/surf/network_ib.cpp @@ -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); diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index a4b3e23078..e2ae780e63 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -96,7 +96,7 @@ namespace simgrid { simgrid::xbt::signal Link::onStateChange; simgrid::xbt::signal networkActionStateChangedCallbacks; - simgrid::xbt::signal networkCommunicateCallbacks; + simgrid::xbt::signal Link::onCommunicate; } } diff --git a/src/surf/network_interface.hpp b/src/surf/network_interface.hpp index 4b4c2567b7..b5330ad715 100644 --- a/src/surf/network_interface.hpp +++ b/src/surf/network_interface.hpp @@ -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) 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) networkCommunicateCallbacks; - - } + } } /********* @@ -197,6 +193,11 @@ namespace simgrid { * Signature: `void(Link*)` */ static simgrid::xbt::signal onStateChange; + /** @brief Callback signal fired when a communication starts + * Signature: `void(NetworkAction *action, RoutingEdge *src, RoutingEdge *dst)` */ + static simgrid::xbt::signal onCommunicate; + + /** @brief Get the bandwidth in bytes per second of current Link */ virtual double getBandwidth(); diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index 606da4ff13..ceb4afc415 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -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() {