1 /* Copyright (c) 2013-2021. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "network_smpi.hpp"
7 #include "simgrid/kernel/routing/NetZoneImpl.hpp"
8 #include "simgrid/s4u/Engine.hpp"
9 #include "simgrid/sg_config.hpp"
10 #include "smpi_utils.hpp"
11 #include "src/kernel/EngineImpl.hpp"
12 #include "src/surf/surf_interface.hpp"
13 #include "surf/surf.hpp"
15 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_network);
21 /************************************************************************/
22 /* New model based on LV08 and experimental results of MPI ping-pongs */
23 /************************************************************************/
24 /* @Inproceedings{smpi_ipdps, */
25 /* author={Pierre-Nicolas Clauss and Mark Stillwell and Stéphane Genaud and Frédéric Suter and Henri Casanova and
27 /* title={Single Node On-Line Simulation of {MPI} Applications with SMPI}, */
28 /* booktitle={25th IEEE International Parallel and Distributed Processing Symposium (IPDPS'11)}, */
29 /* address={Anchorage (Alaska) USA}, */
33 void surf_network_model_init_SMPI()
35 auto net_model = std::make_shared<simgrid::kernel::resource::NetworkSmpiModel>("Network_SMPI");
36 auto* engine = simgrid::kernel::EngineImpl::get_instance();
37 engine->add_model(net_model);
38 engine->get_netzone_root()->set_network_model(net_model);
40 simgrid::config::set_default<double>("network/weight-S", 8775);
47 void NetworkSmpiModel::check_lat_factor_cb()
49 if (not simgrid::config::is_default("smpi/lat-factor")) {
50 throw std::invalid_argument(
51 "NetworkModelIntf: Cannot mix network/latency-factor and callback configuration. Choose only one of them.");
55 void NetworkSmpiModel::check_bw_factor_cb()
57 if (not simgrid::config::is_default("smpi/bw-factor")) {
58 throw std::invalid_argument(
59 "NetworkModelIntf: Cannot mix network/bandwidth-factor and callback configuration. Choose only one of them.");
63 double NetworkSmpiModel::get_bandwidth_factor(double size)
65 static std::vector<s_smpi_factor_t> smpi_bw_factor;
66 if (smpi_bw_factor.empty())
67 smpi_bw_factor = smpi::utils::parse_factor(config::get_value<std::string>("smpi/bw-factor"));
70 for (auto const& fact : smpi_bw_factor) {
71 if (size <= fact.factor) {
72 XBT_DEBUG("%f <= %zu return %f", size, fact.factor, current);
75 current = fact.values.front();
77 XBT_DEBUG("%f > %zu return %f", size, smpi_bw_factor.back().factor, current);
82 double NetworkSmpiModel::get_latency_factor(double size)
84 static std::vector<s_smpi_factor_t> smpi_lat_factor;
85 if (smpi_lat_factor.empty())
86 smpi_lat_factor = smpi::utils::parse_factor(config::get_value<std::string>("smpi/lat-factor"));
89 for (auto const& fact : smpi_lat_factor) {
90 if (size <= fact.factor) {
91 XBT_DEBUG("%f <= %zu return %f", size, fact.factor, current);
94 current = fact.values.front();
96 XBT_DEBUG("%f > %zu return %f", size, smpi_lat_factor.back().factor, current);
100 } // namespace resource
101 } // namespace kernel
102 } // namespace simgrid