X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c0f3756528127131a1947179f56871657a084259..5ba2d6ee8d01dce90e5f829ab693aea28976df58:/src/surf/network_ib.cpp diff --git a/src/surf/network_ib.cpp b/src/surf/network_ib.cpp index a6335848b3..344cf11f0d 100644 --- a/src/surf/network_ib.cpp +++ b/src/surf/network_ib.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2014-2018. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2014-2019. The SimGrid Team. 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. */ @@ -27,7 +27,8 @@ static void IB_create_host_callback(simgrid::s4u::Host& host){ ((NetworkIBModel*)surf_network_model)->active_nodes.insert({host.get_name(), act}); } -static void IB_action_state_changed_callback(simgrid::kernel::resource::NetworkAction* action) +static void IB_action_state_changed_callback(simgrid::kernel::resource::NetworkAction* action, + simgrid::kernel::resource::Action::State /*previous*/) { using simgrid::kernel::resource::IBNode; using simgrid::kernel::resource::NetworkIBModel; @@ -85,11 +86,9 @@ static void IB_action_init_callback(simgrid::kernel::resource::NetworkAction* ac /* } */ void surf_network_model_init_IB() { - if (surf_network_model) - return; + xbt_assert(surf_network_model == nullptr, "Cannot set the network model twice"); surf_network_model = new simgrid::kernel::resource::NetworkIBModel(); - all_existing_models->push_back(surf_network_model); simgrid::s4u::Link::on_communication_state_change.connect(IB_action_state_changed_callback); simgrid::s4u::Link::on_communicate.connect(IB_action_init_callback); simgrid::s4u::Host::on_creation.connect(IB_create_host_callback); @@ -102,6 +101,8 @@ namespace resource { NetworkIBModel::NetworkIBModel() : NetworkSmpiModel() { + /* Do not add this into all_existing_models: our ancestor already does so */ + std::string IB_factors_string = simgrid::config::get_value("smpi/IB-penalty-factors"); std::vector radical_elements; boost::split(radical_elements, IB_factors_string, boost::is_any_of(";")); @@ -203,7 +204,6 @@ void NetworkIBModel::updateIBfactors(NetworkAction* action, IBNode* from, IBNode if (from == to) // disregard local comms (should use loopback) return; - ActiveComm* comm = nullptr; if (remove) { if (to->ActiveCommsDown[from] == 1) to->ActiveCommsDown.erase(from); @@ -213,7 +213,7 @@ void NetworkIBModel::updateIBfactors(NetworkAction* action, IBNode* from, IBNode to->nbActiveCommsDown--; for (std::vector::iterator it = from->ActiveCommsUp.begin(); it != from->ActiveCommsUp.end(); ++it) { if ((*it)->action == action) { - comm = (*it); + delete *it; from->ActiveCommsUp.erase(it); break; } @@ -233,7 +233,6 @@ void NetworkIBModel::updateIBfactors(NetworkAction* action, IBNode* from, IBNode std::vector updated(active_nodes.size(), false); updateIBfactors_rec(from, updated); XBT_DEBUG("IB - Finished updating %d", from->id); - delete comm; } } }