Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Those damn VM keep getting in our way
[simgrid.git] / src / surf / network_smpi.cpp
1 /* Copyright (c) 2013-2015. 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 xbt_dict_t gap_lookup = nullptr;
22
23 /*********
24  * Model *
25  *********/
26
27 /************************************************************************/
28 /* New model based on LV08 and experimental results of MPI ping-pongs   */
29 /************************************************************************/
30 /* @Inproceedings{smpi_ipdps, */
31 /*  author={Pierre-Nicolas Clauss and Mark Stillwell and Stéphane Genaud and Frédéric Suter and Henri Casanova and Martin Quinson}, */
32 /*  title={Single Node On-Line Simulation of {MPI} Applications with SMPI}, */
33 /*  booktitle={25th IEEE International Parallel and Distributed Processing Symposium (IPDPS'11)}, */
34 /*  address={Anchorage (Alaska) USA}, */
35 /*  month=may, */
36 /*  year={2011} */
37 /*  } */
38 void surf_network_model_init_SMPI()
39 {
40   if (surf_network_model)
41     return;
42   surf_network_model = new simgrid::surf::NetworkSmpiModel();
43   all_existing_models->push_back(surf_network_model);
44
45   xbt_cfg_setdefault_double("network/sender-gap", 10e-6);
46   xbt_cfg_setdefault_double("network/weight-S", 8775);
47 }
48
49 namespace simgrid {
50   namespace surf {
51
52   NetworkSmpiModel::NetworkSmpiModel() : NetworkCm02Model()
53   {
54     haveGap_ = true;
55     }
56
57     NetworkSmpiModel::~NetworkSmpiModel()
58     {
59       xbt_dict_free(&gap_lookup);
60     }
61
62     double NetworkSmpiModel::bandwidthFactor(double size)
63     {
64       if (smpi_bw_factor.empty())
65         smpi_bw_factor = parse_factor(xbt_cfg_get_string("smpi/bw-factor"));
66
67       double current = 1.0;
68       for (const auto& fact : smpi_bw_factor) {
69         if (size <= fact.factor) {
70           XBT_DEBUG("%f <= %zu return %f", size, fact.factor, current);
71           return current;
72         } else
73           current = fact.values.front();
74       }
75       XBT_DEBUG("%f > %zu return %f", size, smpi_bw_factor.back().factor, current);
76
77       return current;
78     }
79
80     double NetworkSmpiModel::latencyFactor(double size)
81     {
82       if (smpi_lat_factor.empty())
83         smpi_lat_factor = parse_factor(xbt_cfg_get_string("smpi/lat-factor"));
84
85       double current=1.0;
86       for (const auto& fact : smpi_lat_factor) {
87         if (size <= fact.factor) {
88           XBT_DEBUG("%f <= %zu return %f", size, fact.factor, current);
89           return current;
90         }else
91           current=fact.values.front();
92       }
93       XBT_DEBUG("%f > %zu return %f", size, smpi_lat_factor.back().factor, current);
94
95       return current;
96     }
97
98     double NetworkSmpiModel::bandwidthConstraint(double rate, double bound, double size)
99     {
100       return rate < 0 ? bound : std::min(bound, rate * bandwidthFactor(size));
101     }
102
103     /************
104      * Resource *
105      ************/
106
107
108
109     /**********
110      * Action *
111      **********/
112
113   }
114 }