X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/18bee871381a6ce670d9da211f43ab9b55fdc350..c3119f83962a5b1ef7bc8f79011698c83ce21cda:/src/surf/network_ib.cpp diff --git a/src/surf/network_ib.cpp b/src/surf/network_ib.cpp index 30d8f4ab3c..48b9c1e4da 100644 --- a/src/surf/network_ib.cpp +++ b/src/surf/network_ib.cpp @@ -1,16 +1,18 @@ /* Copyright (c) 2014-2015. The SimGrid Team. - * All rights reserved. */ +*All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ #include -#include "network_ib.hpp" - -#include "src/surf/HostImpl.hpp" #include "simgrid/sg_config.h" -#include "maxmin_private.hpp" +#include "src/surf/HostImpl.hpp" +#include "src/surf/maxmin_private.hpp" +#include "src/surf/network_ib.hpp" +#include "src/surf/xml/platf.hpp" +#include +#include XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_network); @@ -29,14 +31,12 @@ static void IB_create_host_callback(simgrid::s4u::Host& host){ xbt_dict_set(((NetworkIBModel*)surf_network_model)->active_nodes, host.cname(), act, nullptr); } -static void IB_action_state_changed_callback( - simgrid::surf::NetworkAction *action, - simgrid::surf::Action::State statein, simgrid::surf::Action::State stateout) +static void IB_action_state_changed_callback(simgrid::surf::NetworkAction* action) { using simgrid::surf::NetworkIBModel; using simgrid::surf::IBNode; - if(statein!=simgrid::surf::Action::State::running || stateout!=simgrid::surf::Action::State::done) + if (action->getState() != simgrid::surf::Action::State::done) return; std::pair pair = ((NetworkIBModel*)surf_network_model)->active_comms[action]; XBT_DEBUG("IB callback - action %p finished", action); @@ -79,15 +79,13 @@ static void IB_action_init_callback(simgrid::surf::NetworkAction* action, simgri /* } */ void surf_network_model_init_IB() { - using simgrid::surf::networkActionStateChangedCallbacks; - if (surf_network_model) return; surf_network_model = new simgrid::surf::NetworkIBModel(); all_existing_models->push_back(surf_network_model); - networkActionStateChangedCallbacks.connect(IB_action_state_changed_callback); - Link::onCommunicate.connect(IB_action_init_callback); + simgrid::s4u::Link::onCommunicationStateChange.connect(IB_action_state_changed_callback); + simgrid::s4u::Link::onCommunicate.connect(IB_action_init_callback); simgrid::s4u::Host::onCreation.connect(IB_create_host_callback); xbt_cfg_setdefault_double("network/weight-S", 8775); @@ -102,16 +100,18 @@ namespace simgrid { active_nodes=nullptr; const char* IB_factors_string=xbt_cfg_get_string("smpi/IB-penalty-factors"); - xbt_dynar_t radical_elements = xbt_str_split(IB_factors_string, ";"); - - surf_parse_assert(xbt_dynar_length(radical_elements)==3, - "smpi/IB-penalty-factors should be provided and contain 3 elements, semi-colon separated. Example: 0.965;0.925;1.35"); - - Be = xbt_str_parse_double(xbt_dynar_get_as(radical_elements, 0, char *), "First part of smpi/IB-penalty-factors is not numerical: %s"); - Bs = xbt_str_parse_double(xbt_dynar_get_as(radical_elements, 1, char *), "Second part of smpi/IB-penalty-factors is not numerical: %s"); - ys = xbt_str_parse_double(xbt_dynar_get_as(radical_elements, 2, char *), "Third part of smpi/IB-penalty-factors is not numerical: %s"); - - xbt_dynar_free(&radical_elements); + std::vector radical_elements; + boost::split(radical_elements, IB_factors_string, boost::is_any_of(";")); + + surf_parse_assert(radical_elements.size() == 3, "smpi/IB-penalty-factors should be provided and contain 3 " + "elements, semi-colon separated. Example: 0.965;0.925;1.35"); + + Be = xbt_str_parse_double(radical_elements.front().c_str(), + "First part of smpi/IB-penalty-factors is not numerical: %s"); + Bs = xbt_str_parse_double((radical_elements.at(1)).c_str(), + "Second part of smpi/IB-penalty-factors is not numerical: %s"); + ys = xbt_str_parse_double(radical_elements.back().c_str(), + "Third part of smpi/IB-penalty-factors is not numerical: %s"); } NetworkIBModel::~NetworkIBModel() @@ -125,7 +125,6 @@ namespace simgrid { } void NetworkIBModel::computeIBfactors(IBNode *root) { - double penalized_bw=0.0; double num_comm_out = (double) root->ActiveCommsUp.size(); double max_penalty_out=0.0; //first, compute all outbound penalties to get their max @@ -159,9 +158,9 @@ namespace simgrid { if((*it)->init_rate==-1) (*it)->init_rate= rate_before_update; - penalized_bw= ! num_comm_out ? (*it)->init_rate : (*it)->init_rate /penalty; + double penalized_bw = num_comm_out ? (*it)->init_rate / penalty : (*it)->init_rate; - if (!double_equals(penalized_bw, rate_before_update, sg_surf_precision)){ + if (not double_equals(penalized_bw, rate_before_update, sg_surf_precision)) { XBT_DEBUG("%d->%d action %p penalty updated : bw now %f, before %f , initial rate %f", root->id,(*it)->destination->id,(*it)->action,penalized_bw, (*it)->action->getBound(), (*it)->init_rate ); lmm_update_variable_bound(maxminSystem_, (*it)->action->getVariable(), penalized_bw); }else{