Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Introduce class simgrid::smpi::utils::FactorSet to reduce code dupplication
[simgrid.git] / src / surf / network_smpi.cpp
1 /* Copyright (c) 2013-2022. 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 <simgrid/kernel/routing/NetZoneImpl.hpp>
7 #include <simgrid/s4u/Engine.hpp>
8
9 #include "simgrid/sg_config.hpp"
10 #include "smpi_utils.hpp"
11 #include "src/kernel/EngineImpl.hpp"
12 #include "src/surf/network_smpi.hpp"
13
14 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_network);
15
16 /*********
17  * Model *
18  *********/
19
20 /************************************************************************/
21 /* New model based on LV08 and experimental results of MPI ping-pongs   */
22 /************************************************************************/
23 /* @Inproceedings{smpi_ipdps, */
24 /*  author={Pierre-Nicolas Clauss and Mark Stillwell and Stéphane Genaud and Frédéric Suter and Henri Casanova and
25  * 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   auto net_model = std::make_shared<simgrid::kernel::resource::NetworkSmpiModel>("Network_SMPI");
35   auto* engine   = simgrid::kernel::EngineImpl::get_instance();
36   engine->add_model(net_model);
37   engine->get_netzone_root()->set_network_model(net_model);
38
39   simgrid::config::set_default<double>("network/weight-S", 8775);
40 }
41
42 namespace simgrid::kernel::resource {
43
44 void NetworkSmpiModel::check_lat_factor_cb()
45 {
46   if (not simgrid::config::is_default("smpi/lat-factor")) {
47     throw std::invalid_argument(
48         "NetworkModelIntf: Cannot mix network/latency-factor and callback configuration. Choose only one of them.");
49   }
50 }
51
52 void NetworkSmpiModel::check_bw_factor_cb()
53 {
54   if (not simgrid::config::is_default("smpi/bw-factor")) {
55     throw std::invalid_argument(
56         "NetworkModelIntf: Cannot mix network/bandwidth-factor and callback configuration. Choose only one of them.");
57   }
58 }
59
60 double NetworkSmpiModel::get_bandwidth_factor(double size)
61 {
62   static smpi::utils::FactorSet smpi_bw_factor("smpi/bw-factor");
63   if (not smpi_bw_factor.is_initialized())
64     smpi_bw_factor.parse(config::get_value<std::string>("smpi/bw-factor"));
65
66   return smpi_bw_factor(size);
67 }
68
69 double NetworkSmpiModel::get_latency_factor(double size)
70 {
71   static smpi::utils::FactorSet smpi_lat_factor("smpi/lat-factor");
72   if (not smpi_lat_factor.is_initialized())
73     smpi_lat_factor.parse(config::get_value<std::string>("smpi/lat-factor"));
74
75   return smpi_lat_factor(size);
76 }
77 } // namespace simgrid::kernel::resource