Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
move CPU models to kernel::resource too
[simgrid.git] / src / surf / network_smpi.cpp
1 /* Copyright (c) 2013-2019. 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/sg_config.hpp"
8 #include "smpi_utils.hpp"
9 #include "src/surf/surf_interface.hpp"
10 #include "surf/surf.hpp"
11
12 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_network);
13
14 std::vector<s_smpi_factor_t> smpi_bw_factor;
15 std::vector<s_smpi_factor_t> smpi_lat_factor;
16
17 /*********
18  * Model *
19  *********/
20
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 Martin Quinson}, */
26 /*  title={Single Node On-Line Simulation of {MPI} Applications with SMPI}, */
27 /*  booktitle={25th IEEE International Parallel and Distributed Processing Symposium (IPDPS'11)}, */
28 /*  address={Anchorage (Alaska) USA}, */
29 /*  month=may, */
30 /*  year={2011} */
31 /*  } */
32 void surf_network_model_init_SMPI()
33 {
34   if (surf_network_model)
35     return;
36   surf_network_model = new simgrid::kernel::resource::NetworkSmpiModel();
37
38   simgrid::config::set_default<double>("network/weight-S", 8775);
39 }
40
41 namespace simgrid {
42 namespace kernel {
43 namespace resource {
44
45 NetworkSmpiModel::NetworkSmpiModel() : NetworkCm02Model()
46 {
47   /* Do not add this into all_existing_models: our ancestor already does so */
48 }
49
50 double NetworkSmpiModel::get_bandwidth_factor(double size)
51 {
52   if (smpi_bw_factor.empty())
53     smpi_bw_factor = parse_factor(config::get_value<std::string>("smpi/bw-factor"));
54
55   double current = 1.0;
56   for (auto const& fact : smpi_bw_factor) {
57     if (size <= fact.factor) {
58       XBT_DEBUG("%f <= %zu return %f", size, fact.factor, current);
59       return current;
60     } else
61       current = fact.values.front();
62   }
63   XBT_DEBUG("%f > %zu return %f", size, smpi_bw_factor.back().factor, current);
64
65   return current;
66 }
67
68 double NetworkSmpiModel::get_latency_factor(double size)
69 {
70   if (smpi_lat_factor.empty())
71     smpi_lat_factor = parse_factor(config::get_value<std::string>("smpi/lat-factor"));
72
73   double current = 1.0;
74   for (auto const& fact : smpi_lat_factor) {
75     if (size <= fact.factor) {
76       XBT_DEBUG("%f <= %zu return %f", size, fact.factor, current);
77       return current;
78     } else
79       current = fact.values.front();
80   }
81   XBT_DEBUG("%f > %zu return %f", size, smpi_lat_factor.back().factor, current);
82
83   return current;
84 }
85
86 double NetworkSmpiModel::get_bandwidth_constraint(double rate, double bound, double size)
87 {
88   return rate < 0 ? bound : std::min(bound, rate * get_bandwidth_factor(size));
89 }
90 } // namespace resource
91 } // namespace kernel
92 } // namespace simgrid