X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b356ce9a510410f879eb3cd1b16b33856aebfdbe..5bc3597e1513c7b94497ae0ea819e5fa2e28058a:/src/surf/network_smpi.cpp diff --git a/src/surf/network_smpi.cpp b/src/surf/network_smpi.cpp index 4531307ff6..9c6f3890da 100644 --- a/src/surf/network_smpi.cpp +++ b/src/surf/network_smpi.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2015. The SimGrid Team. +/* Copyright (c) 2013-2017. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -18,8 +18,6 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_network); std::vector smpi_bw_factor; std::vector smpi_lat_factor; -xbt_dict_t gap_lookup = nullptr; - /********* * Model * *********/ @@ -42,133 +40,65 @@ void surf_network_model_init_SMPI() surf_network_model = new simgrid::surf::NetworkSmpiModel(); all_existing_models->push_back(surf_network_model); - xbt_cfg_setdefault_double("network/sender-gap", 10e-6); xbt_cfg_setdefault_double("network/weight-S", 8775); } namespace simgrid { - namespace surf { - - NetworkSmpiModel::NetworkSmpiModel() : NetworkCm02Model() - { - haveGap_ = true; - } - - NetworkSmpiModel::~NetworkSmpiModel() - { - xbt_dict_free(&gap_lookup); - } - - void NetworkSmpiModel::gapAppend(double size, LinkImpl* link, NetworkAction* act) - { - const char* src = link->cname(); - xbt_fifo_t fifo; - NetworkCm02Action *action= static_cast(act); - - if (sg_sender_gap > 0.0) { - if (!gap_lookup) { - gap_lookup = xbt_dict_new_homogeneous(nullptr); - } - 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, nullptr); - } - 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(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.empty()) - smpi_bw_factor = parse_factor(xbt_cfg_get_string("smpi/bw-factor")); - - double current = 1.0; - for (const auto& fact : smpi_bw_factor) { - if (size <= fact.factor) { - XBT_DEBUG("%f <= %zu return %f", size, fact.factor, current); - return current; - } else - current = fact.values.front(); - } - XBT_DEBUG("%f > %zu return %f", size, smpi_bw_factor.back().factor, current); +namespace surf { - return current; - } - - double NetworkSmpiModel::latencyFactor(double size) - { - if (smpi_lat_factor.empty()) - smpi_lat_factor = parse_factor(xbt_cfg_get_string("smpi/lat-factor")); - - double current=1.0; - for (const auto& fact : smpi_lat_factor) { - if (size <= fact.factor) { - XBT_DEBUG("%f <= %zu return %f", size, fact.factor, current); - return current; - }else - current=fact.values.front(); - } - XBT_DEBUG("%f > %zu return %f", size, smpi_lat_factor.back().factor, current); +NetworkSmpiModel::NetworkSmpiModel() : NetworkCm02Model() +{ +} + +NetworkSmpiModel::~NetworkSmpiModel() = default; +double NetworkSmpiModel::bandwidthFactor(double size) +{ + if (smpi_bw_factor.empty()) + smpi_bw_factor = parse_factor(xbt_cfg_get_string("smpi/bw-factor")); + + double current = 1.0; + for (auto const& fact : smpi_bw_factor) { + if (size <= fact.factor) { + XBT_DEBUG("%f <= %zu return %f", size, fact.factor, current); return current; - } + } else + current = fact.values.front(); + } + XBT_DEBUG("%f > %zu return %f", size, smpi_bw_factor.back().factor, current); + + return current; +} - double NetworkSmpiModel::bandwidthConstraint(double rate, double bound, double size) - { - return rate < 0 ? bound : std::min(bound, rate * bandwidthFactor(size)); - } +double NetworkSmpiModel::latencyFactor(double size) +{ + if (smpi_lat_factor.empty()) + smpi_lat_factor = parse_factor(xbt_cfg_get_string("smpi/lat-factor")); - /************ - * Resource * - ************/ + double current = 1.0; + for (auto const& fact : smpi_lat_factor) { + if (size <= fact.factor) { + XBT_DEBUG("%f <= %zu return %f", size, fact.factor, current); + return current; + } else + current = fact.values.front(); + } + XBT_DEBUG("%f > %zu return %f", size, smpi_lat_factor.back().factor, current); + return current; +} +double NetworkSmpiModel::bandwidthConstraint(double rate, double bound, double size) +{ + return rate < 0 ? bound : std::min(bound, rate * bandwidthFactor(size)); +} - /********** - * Action * - **********/ +/************ + * Resource * + ************/ - } +/********** + * Action * + **********/ +} }