- namespace surf {
-
- NetworkSmpiModel::NetworkSmpiModel()
- : NetworkCm02Model() {
- haveGap_=true;
- }
-
- NetworkSmpiModel::~NetworkSmpiModel(){
- xbt_dict_free(&gap_lookup);
- xbt_dynar_free(&smpi_bw_factor);
- xbt_dynar_free(&smpi_lat_factor);
- }
-
- void NetworkSmpiModel::gapAppend(double size, Link* link, NetworkAction *act)
- {
- const char *src = link->getName();
- xbt_fifo_t fifo;
- NetworkCm02Action *action= static_cast<NetworkCm02Action*>(act);
-
- if (sg_sender_gap > 0.0) {
- if (!gap_lookup) {
- gap_lookup = xbt_dict_new_homogeneous(NULL);
- }
- fifo = (xbt_fifo_t) xbt_dict_get_or_null(gap_lookup, src);
- action->senderGap_ = 0.0;
- if (fifo && xbt_fifo_size(fifo) > 0) {
- /* Compute gap from last send */
- /*last_action =
- (surf_action_network_CM02_t)
- xbt_fifo_get_item_content(xbt_fifo_get_last_item(fifo));*/
- // bw = net_get_link_bandwidth(link);
- action->senderGap_ = sg_sender_gap;
- /* max(sg_sender_gap,last_action->sender.size / bw);*/
- action->latency_ += action->senderGap_;
- }
- /* Append action as last send */
- /*action->sender.link_name = link->lmm_resource.generic_resource.name;
- fifo =
- (xbt_fifo_t) xbt_dict_get_or_null(gap_lookup,
- action->sender.link_name);
- if (!fifo) {
- fifo = xbt_fifo_new();
- xbt_dict_set(gap_lookup, action->sender.link_name, fifo, NULL);
- }
- action->sender.fifo_item = xbt_fifo_push(fifo, action);*/
- action->senderSize_ = size;
- }
- }
-
- void NetworkSmpiModel::gapRemove(Action *lmm_action)
- {
- xbt_fifo_t fifo;
- size_t size;
- NetworkCm02Action *action = static_cast<NetworkCm02Action*>(lmm_action);
-
- if (sg_sender_gap > 0.0 && action->senderLinkName_
- && action->senderFifoItem_) {
- fifo =
- (xbt_fifo_t) xbt_dict_get_or_null(gap_lookup,
- action->senderLinkName_);
- xbt_fifo_remove_item(fifo, action->senderFifoItem_);
- size = xbt_fifo_size(fifo);
- if (size == 0) {
- xbt_fifo_free(fifo);
- xbt_dict_remove(gap_lookup, action->senderLinkName_);
- size = xbt_dict_length(gap_lookup);
- if (size == 0) {
- xbt_dict_free(&gap_lookup);
- }
- }
- }
- }
-
- double NetworkSmpiModel::bandwidthFactor(double size)
- {
- if (!smpi_bw_factor)
- smpi_bw_factor =
- parse_factor(sg_cfg_get_string("smpi/bw_factor"));
-
- unsigned int iter = 0;
- s_smpi_factor_t fact;
- double current=1.0;
- xbt_dynar_foreach(smpi_bw_factor, iter, fact) {
- if (size <= fact.factor) {
- XBT_DEBUG("%f <= %ld return %f", size, fact.factor, current);
- return current;
- }else
- current=fact.value;
- }
- XBT_DEBUG("%f > %ld return %f", size, fact.factor, current);