X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/1747902010b7fc57b15c2e88473c5bb118d362d1..497aee08bf8b36b4981083b79d8473991db1ccde:/src/surf/network_smpi.cpp diff --git a/src/surf/network_smpi.cpp b/src/surf/network_smpi.cpp index 0b03bd9d4e..02d6a00d80 100644 --- a/src/surf/network_smpi.cpp +++ b/src/surf/network_smpi.cpp @@ -1,20 +1,18 @@ -/* Copyright (c) 2013-2021. 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 "network_smpi.hpp" +#include +#include + #include "simgrid/sg_config.hpp" #include "smpi_utils.hpp" #include "src/kernel/EngineImpl.hpp" -#include "src/surf/surf_interface.hpp" -#include "surf/surf.hpp" +#include "src/surf/network_smpi.hpp" XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_network); -std::vector smpi_bw_factor; -std::vector smpi_lat_factor; - /********* * Model * *********/ @@ -33,25 +31,37 @@ std::vector smpi_lat_factor; /* } */ void surf_network_model_init_SMPI() { - auto net_model = std::make_unique(); - simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::NETWORK, - std::move(net_model), true); + 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); } -namespace simgrid { -namespace kernel { -namespace resource { +namespace simgrid::kernel::resource { + +void NetworkSmpiModel::check_lat_factor_cb() +{ + if (not simgrid::config::is_default("smpi/lat-factor")) { + throw std::invalid_argument( + "NetworkModelIntf: Cannot mix network/latency-factor and callback configuration. Choose only one of them."); + } +} -NetworkSmpiModel::NetworkSmpiModel() : NetworkCm02Model() +void NetworkSmpiModel::check_bw_factor_cb() { + if (not simgrid::config::is_default("smpi/bw-factor")) { + throw std::invalid_argument( + "NetworkModelIntf: Cannot mix network/bandwidth-factor and callback configuration. Choose only one of them."); + } } double NetworkSmpiModel::get_bandwidth_factor(double size) { + static std::vector smpi_bw_factor; if (smpi_bw_factor.empty()) - smpi_bw_factor = parse_factor(config::get_value("smpi/bw-factor")); + smpi_bw_factor = smpi::utils::parse_factor(config::get_value("smpi/bw-factor")); double current = 1.0; for (auto const& fact : smpi_bw_factor) { @@ -68,8 +78,9 @@ double NetworkSmpiModel::get_bandwidth_factor(double size) double NetworkSmpiModel::get_latency_factor(double size) { + static std::vector smpi_lat_factor; if (smpi_lat_factor.empty()) - smpi_lat_factor = parse_factor(config::get_value("smpi/lat-factor")); + smpi_lat_factor = smpi::utils::parse_factor(config::get_value("smpi/lat-factor")); double current = 1.0; for (auto const& fact : smpi_lat_factor) { @@ -83,11 +94,4 @@ double NetworkSmpiModel::get_latency_factor(double size) return current; } - -double NetworkSmpiModel::get_bandwidth_constraint(double rate, double bound, double size) -{ - return rate < 0 ? bound : std::min(bound, rate * get_bandwidth_factor(size)); -} -} // namespace resource -} // namespace kernel -} // namespace simgrid +} // namespace simgrid::kernel::resource