X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/1bd1bbd35034c2e93a030a676dc244ad2cf74c70..b9d349f4e630752232d93f23b5cb3c33e02e0d05:/src/surf/network_smpi.cpp diff --git a/src/surf/network_smpi.cpp b/src/surf/network_smpi.cpp index 47b0d16a0d..54185c6b9b 100644 --- a/src/surf/network_smpi.cpp +++ b/src/surf/network_smpi.cpp @@ -1,19 +1,18 @@ -/* Copyright (c) 2013-2017. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2013-2021. 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 "network_smpi.hpp" -#include "simgrid/sg_config.h" +#include "simgrid/kernel/routing/NetZoneImpl.hpp" +#include "simgrid/s4u/Engine.hpp" +#include "simgrid/sg_config.hpp" #include "smpi_utils.hpp" +#include "src/kernel/EngineImpl.hpp" +#include "src/surf/surf_interface.hpp" +#include "surf/surf.hpp" -XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_network); +XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_network); std::vector smpi_bw_factor; std::vector smpi_lat_factor; @@ -26,7 +25,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,27 +35,24 @@ 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); + auto net_model = std::make_shared(); + net_model->set_name("Network_SMPI"); + simgrid::kernel::EngineImpl::get_instance()->add_model(net_model, {}); + simgrid::s4u::Engine::get_instance()->get_netzone_root()->get_impl()->set_network_model(net_model); - xbt_cfg_setdefault_double("network/weight-S", 8775); + simgrid::config::set_default("network/weight-S", 8775); } namespace simgrid { -namespace surf { - -NetworkSmpiModel::NetworkSmpiModel() : NetworkCm02Model() -{ -} +namespace kernel { +namespace resource { -NetworkSmpiModel::~NetworkSmpiModel() = default; +NetworkSmpiModel::NetworkSmpiModel() : NetworkCm02Model() {} -double NetworkSmpiModel::bandwidthFactor(double size) +double NetworkSmpiModel::get_bandwidth_factor(double size) { if (smpi_bw_factor.empty()) - smpi_bw_factor = parse_factor(xbt_cfg_get_string("smpi/bw-factor")); + smpi_bw_factor = simgrid::smpi::utils::parse_factor(config::get_value("smpi/bw-factor")); double current = 1.0; for (auto const& fact : smpi_bw_factor) { @@ -70,10 +67,10 @@ double NetworkSmpiModel::bandwidthFactor(double size) return current; } -double NetworkSmpiModel::latencyFactor(double size) +double NetworkSmpiModel::get_latency_factor(double size) { if (smpi_lat_factor.empty()) - smpi_lat_factor = parse_factor(xbt_cfg_get_string("smpi/lat-factor")); + smpi_lat_factor = simgrid::smpi::utils::parse_factor(config::get_value("smpi/lat-factor")); double current = 1.0; for (auto const& fact : smpi_lat_factor) { @@ -88,17 +85,10 @@ double NetworkSmpiModel::latencyFactor(double size) return current; } -double NetworkSmpiModel::bandwidthConstraint(double rate, double bound, double size) +double NetworkSmpiModel::get_bandwidth_constraint(double rate, double bound, double size) { - return rate < 0 ? bound : std::min(bound, rate * bandwidthFactor(size)); -} - -/************ - * Resource * - ************/ - -/********** - * Action * - **********/ -} + return rate < 0 ? bound : std::min(bound, rate * get_bandwidth_factor(size)); } +} // namespace resource +} // namespace kernel +} // namespace simgrid