X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/77bbf3027c4240a2e833209a3a3f186589da8577..f6b6ec5ae0cc5d28201720961c23277c4a72e152:/src/surf/network_smpi.cpp diff --git a/src/surf/network_smpi.cpp b/src/surf/network_smpi.cpp index 47b0d16a0d..4ca339fc9d 100644 --- a/src/surf/network_smpi.cpp +++ b/src/surf/network_smpi.cpp @@ -1,22 +1,17 @@ -/* Copyright (c) 2013-2017. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2013-2022. 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. */ -#include -#include +#include +#include -#include - -#include "network_smpi.hpp" -#include "simgrid/sg_config.h" +#include "simgrid/sg_config.hpp" #include "smpi_utils.hpp" +#include "src/kernel/EngineImpl.hpp" +#include "src/surf/network_smpi.hpp" -XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_network); - -std::vector smpi_bw_factor; -std::vector smpi_lat_factor; +XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_network); /********* * Model * @@ -26,7 +21,8 @@ std::vector smpi_lat_factor; /* New model based on LV08 and experimental results of MPI ping-pongs */ /************************************************************************/ /* @Inproceedings{smpi_ipdps, */ -/* author={Pierre-Nicolas Clauss and Mark Stillwell and Stéphane Genaud and Frédéric Suter and Henri Casanova and Martin Quinson}, */ +/* author={Pierre-Nicolas Clauss and Mark Stillwell and Stéphane Genaud and Frédéric Suter and Henri Casanova and + * Martin Quinson}, */ /* title={Single Node On-Line Simulation of {MPI} Applications with SMPI}, */ /* booktitle={25th IEEE International Parallel and Distributed Processing Symposium (IPDPS'11)}, */ /* address={Anchorage (Alaska) USA}, */ @@ -35,70 +31,36 @@ std::vector smpi_lat_factor; /* } */ void surf_network_model_init_SMPI() { - if (surf_network_model) - return; - surf_network_model = new simgrid::surf::NetworkSmpiModel(); - all_existing_models->push_back(surf_network_model); - - xbt_cfg_setdefault_double("network/weight-S", 8775); + auto net_model = std::make_shared("Network_SMPI"); + auto* engine = simgrid::kernel::EngineImpl::get_instance(); + engine->add_model(net_model); + engine->get_netzone_root()->set_network_model(net_model); + + simgrid::config::set_default("network/weight-S", 8775); + simgrid::config::set_default("network/bandwidth-factor", + "65472:0.940694;15424:0.697866;9376:0.58729;5776:1.08739;3484:0.77493;" + "1426:0.608902;732:0.341987;257:0.338112;0:0.812084"); + simgrid::config::set_default("network/latency-factor", + "65472:11.6436;15424:3.48845;9376:2.59299;5776:2.18796;3484:1.88101;" + "1426:1.61075;732:1.9503;257:1.95341;0:2.01467"); } -namespace simgrid { -namespace surf { +namespace simgrid::kernel::resource { -NetworkSmpiModel::NetworkSmpiModel() : NetworkCm02Model() +void NetworkSmpiModel::check_lat_factor_cb() { -} - -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(); + if (not simgrid::config::is_default("network/latency-factor")) { + throw std::invalid_argument( + "NetworkModelIntf: Cannot mix network/latency-factor and callback configuration. Choose only one of them."); } - XBT_DEBUG("%f > %zu return %f", size, smpi_bw_factor.back().factor, current); - - return current; } -double NetworkSmpiModel::latencyFactor(double size) +void NetworkSmpiModel::check_bw_factor_cb() { - if (smpi_lat_factor.empty()) - smpi_lat_factor = parse_factor(xbt_cfg_get_string("smpi/lat-factor")); - - 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(); + if (not simgrid::config::is_default("network/bandwidth-factor")) { + throw std::invalid_argument( + "NetworkModelIntf: Cannot mix network/bandwidth-factor and callback configuration. Choose only one of them."); } - 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)); } -/************ - * Resource * - ************/ - -/********** - * Action * - **********/ -} -} +} // namespace simgrid::kernel::resource