delete route;
XBT_OUT();
- networkCommunicateCallbacks(action, src, dst, size, rate);
+ Link::onCommunicate(action, src, dst);
return action;
}
}
}
- 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;
}
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);
}
/*********
void surf_network_model_init_IB(void)
{
using simgrid::surf::networkActionStateChangedCallbacks;
- using simgrid::surf::networkCommunicateCallbacks;
if (surf_network_model)
return;
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);
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;
}
}
* 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;
-
- }
+ }
}
/*********
* 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();
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() {