Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
1d0d2cd7b71e32b69197b933bdba5cb5cb43ffff
[simgrid.git] / src / surf / network_smpi.cpp
1 /* Copyright (c) 2013-2017. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include <cstddef>
8 #include <algorithm>
9
10 #include <xbt/log.h>
11
12 #include "network_smpi.hpp"
13 #include "simgrid/sg_config.h"
14 #include "smpi/smpi_utils.hpp"
15
16 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_network);
17
18 std::vector<s_smpi_factor_t> smpi_bw_factor;
19 std::vector<s_smpi_factor_t> smpi_lat_factor;
20
21 /*********
22  * Model *
23  *********/
24
25 /************************************************************************/
26 /* New model based on LV08 and experimental results of MPI ping-pongs   */
27 /************************************************************************/
28 /* @Inproceedings{smpi_ipdps, */
29 /*  author={Pierre-Nicolas Clauss and Mark Stillwell and Stéphane Genaud and Frédéric Suter and Henri Casanova and 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   if (surf_network_model)
39     return;
40   surf_network_model = new simgrid::surf::NetworkSmpiModel();
41   all_existing_models->push_back(surf_network_model);
42
43   xbt_cfg_setdefault_double("network/sender-gap", 10e-6);
44   xbt_cfg_setdefault_double("network/weight-S", 8775);
45 }
46
47 namespace simgrid {
48 namespace surf {
49
50 NetworkSmpiModel::NetworkSmpiModel() : NetworkCm02Model()
51 {
52 }
53
54 NetworkSmpiModel::~NetworkSmpiModel() = default;
55
56 double NetworkSmpiModel::bandwidthFactor(double size)
57 {
58   if (smpi_bw_factor.empty())
59     smpi_bw_factor = parse_factor(xbt_cfg_get_string("smpi/bw-factor"));
60
61   double current = 1.0;
62   for (const auto& fact : smpi_bw_factor) {
63     if (size <= fact.factor) {
64       XBT_DEBUG("%f <= %zu return %f", size, fact.factor, current);
65       return current;
66     } else
67       current = fact.values.front();
68   }
69   XBT_DEBUG("%f > %zu return %f", size, smpi_bw_factor.back().factor, current);
70
71   return current;
72 }
73
74 double NetworkSmpiModel::latencyFactor(double size)
75 {
76   if (smpi_lat_factor.empty())
77     smpi_lat_factor = parse_factor(xbt_cfg_get_string("smpi/lat-factor"));
78
79   double current = 1.0;
80   for (const auto& fact : smpi_lat_factor) {
81     if (size <= fact.factor) {
82       XBT_DEBUG("%f <= %zu return %f", size, fact.factor, current);
83       return current;
84     } else
85       current = fact.values.front();
86   }
87   XBT_DEBUG("%f > %zu return %f", size, smpi_lat_factor.back().factor, current);
88
89   return current;
90 }
91
92 double NetworkSmpiModel::bandwidthConstraint(double rate, double bound, double size)
93 {
94   return rate < 0 ? bound : std::min(bound, rate * bandwidthFactor(size));
95 }
96
97 /************
98  * Resource *
99  ************/
100
101 /**********
102  * Action *
103  **********/
104 }
105 }