Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'models_type_rework_part2_try2' into 'master'
[simgrid.git] / src / surf / network_smpi.cpp
1 /* Copyright (c) 2013-2021. The SimGrid Team. All rights reserved.          */
2
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. */
5
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"
14
15 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_network);
16
17 std::vector<s_smpi_factor_t> smpi_bw_factor;
18 std::vector<s_smpi_factor_t> smpi_lat_factor;
19
20 /*********
21  * Model *
22  *********/
23
24 /************************************************************************/
25 /* New model based on LV08 and experimental results of MPI ping-pongs   */
26 /************************************************************************/
27 /* @Inproceedings{smpi_ipdps, */
28 /*  author={Pierre-Nicolas Clauss and Mark Stillwell and Stéphane Genaud and Frédéric Suter and Henri Casanova and
29  * Martin Quinson}, */
30 /*  title={Single Node On-Line Simulation of {MPI} Applications with SMPI}, */
31 /*  booktitle={25th IEEE International Parallel and Distributed Processing Symposium (IPDPS'11)}, */
32 /*  address={Anchorage (Alaska) USA}, */
33 /*  month=may, */
34 /*  year={2011} */
35 /*  } */
36 void surf_network_model_init_SMPI()
37 {
38   auto net_model = std::make_shared<simgrid::kernel::resource::NetworkSmpiModel>();
39   net_model->set_name("Network_SMPI");
40   simgrid::kernel::EngineImpl::get_instance()->add_model(net_model, {});
41   simgrid::s4u::Engine::get_instance()->get_netzone_root()->get_impl()->set_network_model(net_model);
42
43   simgrid::config::set_default<double>("network/weight-S", 8775);
44 }
45
46 namespace simgrid {
47 namespace kernel {
48 namespace resource {
49
50 NetworkSmpiModel::NetworkSmpiModel() : NetworkCm02Model() {}
51
52 double NetworkSmpiModel::get_bandwidth_factor(double size)
53 {
54   if (smpi_bw_factor.empty())
55     smpi_bw_factor = simgrid::smpi::utils::parse_factor(config::get_value<std::string>("smpi/bw-factor"));
56
57   double current = 1.0;
58   for (auto const& fact : smpi_bw_factor) {
59     if (size <= fact.factor) {
60       XBT_DEBUG("%f <= %zu return %f", size, fact.factor, current);
61       return current;
62     } else
63       current = fact.values.front();
64   }
65   XBT_DEBUG("%f > %zu return %f", size, smpi_bw_factor.back().factor, current);
66
67   return current;
68 }
69
70 double NetworkSmpiModel::get_latency_factor(double size)
71 {
72   if (smpi_lat_factor.empty())
73     smpi_lat_factor = simgrid::smpi::utils::parse_factor(config::get_value<std::string>("smpi/lat-factor"));
74
75   double current = 1.0;
76   for (auto const& fact : smpi_lat_factor) {
77     if (size <= fact.factor) {
78       XBT_DEBUG("%f <= %zu return %f", size, fact.factor, current);
79       return current;
80     } else
81       current = fact.values.front();
82   }
83   XBT_DEBUG("%f > %zu return %f", size, smpi_lat_factor.back().factor, current);
84
85   return current;
86 }
87
88 double NetworkSmpiModel::get_bandwidth_constraint(double rate, double bound, double size)
89 {
90   return rate < 0 ? bound : std::min(bound, rate * get_bandwidth_factor(size));
91 }
92 } // namespace resource
93 } // namespace kernel
94 } // namespace simgrid