surf_cpu_model_description.by_name(cpu_model_name).init();
surf_disk_model_description.by_name(disk_model_name).init();
- surf_network_model_description.by_name(network_model_name).init();
+ simgrid_network_models().by_name(network_model_name).init();
}
surf_host_model_description.by_name(host_model_name).init();
/* -------------------------------------------------------------------------------------------------------------- */
simgrid::ModuleGroup surf_optimization_mode_description("optimization mode");
simgrid::ModuleGroup surf_cpu_model_description("CPU model");
-simgrid::ModuleGroup surf_network_model_description("network model");
simgrid::ModuleGroup surf_disk_model_description("disk model");
simgrid::ModuleGroup surf_host_model_description("host model");
void simgrid_create_models()
{
- surf_network_model_description
- .add("LV08",
- "Realistic network analytic model (slow-start modeled by multiplying latency by 13.01, bandwidth by .97; "
- "bottleneck sharing uses a payload of S=20537 for evaluating RTT). ",
- &surf_network_model_init_LegrandVelho)
- .add("Constant",
- "Simplistic network model where all communication take a constant time (one second). This model "
- "provides the lowest realism, but is (marginally) faster.",
- &surf_network_model_init_Constant)
- .add("SMPI",
- "Realistic network model specifically tailored for HPC settings (accurate modeling of slow start with "
- "correction factors on three intervals: < 1KiB, < 64 KiB, >= 64 KiB)",
- &surf_network_model_init_SMPI)
- .add("IB",
-#if HAVE_SMPI
- "Realistic network model specifically tailored for HPC settings, with Infiniband contention model",
-#else
- "(Infiniband model is only enabled when SMPI is)",
-#endif
- &surf_network_model_init_IB)
- .add("CM02",
- "Legacy network analytic model (Very similar to LV08, but without corrective factors. The timings of "
- "small messages are thus poorly modeled).",
- &surf_network_model_init_CM02)
- .add("ns-3",
-#if SIMGRID_HAVE_NS3
- "Network pseudo-model using the ns-3 tcp model instead of an analytic model",
-#else
- "(ns-3 pseudo-model is only activated when ns-3 support was compiled it)",
-#endif
- &surf_network_model_init_NS3);
-
surf_cpu_model_description.add("Cas01", "Simplistic CPU model (time=size/speed).", &surf_cpu_model_init_Cas01);
surf_disk_model_description.add("S19", "Simplistic disk model.", &surf_disk_model_init_S19);
nullptr)
.add("Full", "Full update of remaining and variables. Slow but may be useful when debugging.", nullptr);
}
-
-#if !HAVE_SMPI
-void surf_network_model_init_IB()
-{
- xbt_die("Please activate SMPI support in cmake to use the IB network model.");
-}
-#endif
-#if !SIMGRID_HAVE_NS3
-void surf_network_model_init_NS3()
-{
- xbt_die("Please activate ns-3 support in cmake and install the dependencies to use the NS3 network model.");
-}
-#endif
class ModuleGroup {
std::vector<Module> table_;
- std::string kind_; // either 'plugin' or 'CPU model' or whatever. Used in error messages only
+ const std::string kind_; // either 'plugin' or 'CPU model' or whatever. Used in error messages only
public:
ModuleGroup(std::string kind) : kind_(kind) {}
ModuleGroup& add(const char* id, const char* desc, std::function<void()> init);
Module const& by_name(const std::string& name) const;
void help() const;
+ const std::string get_kind() const { return kind_; }
std::string existing_values() const;
};
return plugins;
}
+#define SIMGRID_REGISTER_NETWORK_MODEL(id, desc, init) \
+ static void XBT_ATTRIB_CONSTRUCTOR(800) _XBT_CONCAT3(simgrid_, id, _network_model_register)() \
+ { \
+ simgrid_network_models().add(_XBT_STRINGIFY(id), (desc), (init)); \
+ }
+/** @brief The list of all available network model (pick one with --cfg=network/model) */
+inline auto& simgrid_network_models() // Function to avoid static initialization order fiasco
+{
+ static simgrid::ModuleGroup plugins("network model");
+ return plugins;
+}
+
#endif
\ No newline at end of file
XBT_HELP("%s", "");
surf_cpu_model_description.help();
XBT_HELP("%s", "");
- surf_network_model_description.help();
+ simgrid_network_models().help();
XBT_HELP("\nLong description of all optimization levels accepted by the models of this simulator:");
surf_optimization_mode_description.help();
XBT_HELP("Both network and CPU models have 'Lazy' as default optimization level\n");
xbt_assert(_sg_cfg_init_status < 2, "Cannot change the model after the initialization");
if (value == "help") {
- surf_network_model_description.help();
+ simgrid_network_models().help();
exit(0);
}
- surf_network_model_description.by_name(value);
+ simgrid_network_models().by_name(value); // Simply ensure that it exists
}
static void _sg_cfg_cb_contexts_parallel_mode(std::string_view mode_name)
const simgrid::ModuleGroup& model_description, const std::string& type,
const std::string& descr)
{
- std::string description = descr + ". Possible values: " + model_description.existing_values();
+ std::string description = descr + ". Possible values (other compilation flags may activate more " +
+ model_description.get_kind() + "): " + model_description.existing_values();
description += ".\n (use 'help' as a value to see the long description of each " + type + ")";
simgrid::config::declare_flag<std::string>(name, description, value, callback);
}
declare_model_flag("disk/model", "S19", &_sg_cfg_cb__disk_model, surf_disk_model_description, "model",
"The model to use for the disk");
- declare_model_flag("network/model", "LV08", &_sg_cfg_cb__network_model, surf_network_model_description, "model",
+ declare_model_flag("network/model", "LV08", &_sg_cfg_cb__network_model, simgrid_network_models(), "model",
"The model to use for the network");
declare_model_flag("network/optim", "Lazy", &_sg_cfg_cb__optimization_mode, surf_optimization_mode_description,
engine->get_netzone_root()->set_host_model(host_model);
surf_cpu_model_init_Cas01();
surf_disk_model_init_S19();
- surf_network_model_init_LegrandVelho();
+ simgrid_network_models().by_name("LV08").init();
}
void surf_host_model_init_compound()
"Set linear equations solver used by network model",
"maxmin", &simgrid::kernel::lmm::System::validate_solver);
-/************************************************************************/
-/* New model based on optimizations discussed during Pedro Velho's thesis*/
-/************************************************************************/
+/******************************************************************************/
+/* Network model based on optimizations discussed during Pedro Velho's thesis */
+/******************************************************************************/
/* @techreport{VELHO:2011:HAL-00646896:1, */
/* url = {http://hal.inria.fr/hal-00646896/en/}, */
/* title = {{Flow-level network models: have we reached the limits?}}, */
/* month = Nov, */
/* pdf = {http://hal.inria.fr/hal-00646896/PDF/rr-validity.pdf}, */
/* } */
-void surf_network_model_init_LegrandVelho()
-{
- auto net_model = std::make_shared<simgrid::kernel::resource::NetworkCm02Model>("Network_LegrandVelho");
- auto* engine = simgrid::kernel::EngineImpl::get_instance();
- engine->add_model(net_model);
- engine->get_netzone_root()->set_network_model(net_model);
-
- simgrid::config::set_default<std::string>("network/latency-factor", "13.01");
- simgrid::config::set_default<std::string>("network/bandwidth-factor", "0.97");
- simgrid::config::set_default<double>("network/weight-S", 20537);
-}
-
-/***************************************************************************/
-/* The nice TCP sharing model designed by Loris Marchal and Henri Casanova */
-/***************************************************************************/
+SIMGRID_REGISTER_NETWORK_MODEL(
+ LV08,
+ "Realistic network analytic model (slow-start modeled by multiplying latency by 13.01, bandwidth by .97; "
+ "bottleneck sharing uses a payload of S=20537 for evaluating RTT). ",
+ []() {
+ auto net_model = std::make_shared<simgrid::kernel::resource::NetworkCm02Model>("Network_LegrandVelho");
+ auto* engine = simgrid::kernel::EngineImpl::get_instance();
+ engine->add_model(net_model);
+ engine->get_netzone_root()->set_network_model(net_model);
+
+ simgrid::config::set_default<std::string>("network/latency-factor", "13.01");
+ simgrid::config::set_default<std::string>("network/bandwidth-factor", "0.97");
+ simgrid::config::set_default<double>("network/weight-S", 20537);
+ });
+
+/****************************************************************************/
+/* The older TCP sharing model designed by Loris Marchal and Henri Casanova */
+/****************************************************************************/
/* @TechReport{ rr-lip2002-40, */
/* author = {Henri Casanova and Loris Marchal}, */
/* institution = {LIP}, */
/* month = {oct}, */
/* year = {2002} */
/* } */
-void surf_network_model_init_CM02()
-{
- simgrid::config::set_default<std::string>("network/latency-factor", "1.0");
- simgrid::config::set_default<std::string>("network/bandwidth-factor", "1.0");
- simgrid::config::set_default<double>("network/weight-S", 0.0);
-
- auto net_model = std::make_shared<simgrid::kernel::resource::NetworkCm02Model>("Network_CM02");
- auto* engine = simgrid::kernel::EngineImpl::get_instance();
- engine->add_model(net_model);
- engine->get_netzone_root()->set_network_model(net_model);
-}
+SIMGRID_REGISTER_NETWORK_MODEL(
+ CM02,
+ "Legacy network analytic model (Very similar to LV08, but without corrective factors. The timings of "
+ "small messages are thus poorly modeled).",
+ []() {
+ simgrid::config::set_default<std::string>("network/latency-factor", "1.0");
+ simgrid::config::set_default<std::string>("network/bandwidth-factor", "1.0");
+ simgrid::config::set_default<double>("network/weight-S", 0.0);
+
+ auto net_model = std::make_shared<simgrid::kernel::resource::NetworkCm02Model>("Network_CM02");
+ auto* engine = simgrid::kernel::EngineImpl::get_instance();
+ engine->add_model(net_model);
+ engine->get_netzone_root()->set_network_model(net_model);
+ });
/********************************************************************/
/* Model based on LV08 and experimental results of MPI ping-pongs */
/* month=may, */
/* year={2011} */
/* } */
-void surf_network_model_init_SMPI()
-{
- auto net_model = std::make_shared<simgrid::kernel::resource::NetworkCm02Model>("Network_SMPI");
- auto* engine = simgrid::kernel::EngineImpl::get_instance();
- engine->add_model(net_model);
- engine->get_netzone_root()->set_network_model(net_model);
-
- simgrid::config::set_default<double>("network/weight-S", 8775);
- simgrid::config::set_default<std::string>("network/bandwidth-factor",
- "65472:0.940694;15424:0.697866;9376:0.58729;5776:1.08739;3484:0.77493;"
- "1426:0.608902;732:0.341987;257:0.338112;0:0.812084");
- simgrid::config::set_default<std::string>("network/latency-factor",
- "65472:11.6436;15424:3.48845;9376:2.59299;5776:2.18796;3484:1.88101;"
- "1426:1.61075;732:1.9503;257:1.95341;0:2.01467");
-}
+SIMGRID_REGISTER_NETWORK_MODEL(
+ SMPI,
+ "Realistic network model specifically tailored for HPC settings (accurate modeling of slow start with "
+ "correction factors on three intervals: < 1KiB, < 64 KiB, >= 64 KiB)",
+ []() {
+ auto net_model = std::make_shared<simgrid::kernel::resource::NetworkCm02Model>("Network_SMPI");
+ auto* engine = simgrid::kernel::EngineImpl::get_instance();
+ engine->add_model(net_model);
+ engine->get_netzone_root()->set_network_model(net_model);
+
+ simgrid::config::set_default<double>("network/weight-S", 8775);
+ simgrid::config::set_default<std::string>("network/bandwidth-factor",
+ "65472:0.940694;15424:0.697866;9376:0.58729;5776:1.08739;3484:0.77493;"
+ "1426:0.608902;732:0.341987;257:0.338112;0:0.812084");
+ simgrid::config::set_default<std::string>("network/latency-factor",
+ "65472:11.6436;15424:3.48845;9376:2.59299;5776:2.18796;3484:1.88101;"
+ "1426:1.61075;732:1.9503;257:1.95341;0:2.01467");
+ });
namespace simgrid::kernel::resource {
/*********
* Model *
*********/
-void surf_network_model_init_Constant()
-{
- auto net_model = std::make_shared<simgrid::kernel::resource::NetworkConstantModel>("Network_Constant");
- auto* engine = simgrid::kernel::EngineImpl::get_instance();
- engine->add_model(net_model);
- engine->get_netzone_root()->set_network_model(net_model);
-}
+SIMGRID_REGISTER_NETWORK_MODEL(
+ Constant,
+ "Simplistic network model where all communication take a constant time (one second). This model "
+ "provides the lowest realism, but is (marginally) faster. It is mostly useful when studying theoretical "
+ "distributed algorithms where the network is usually abstracted away.",
+ []() {
+ auto net_model = std::make_shared<simgrid::kernel::resource::NetworkConstantModel>("Network_Constant");
+ auto* engine = simgrid::kernel::EngineImpl::get_instance();
+ engine->add_model(net_model);
+ engine->get_netzone_root()->set_network_model(net_model);
+ });
namespace simgrid::kernel::resource {
/* month=june, */
/* year={2010} */
/* } */
-void surf_network_model_init_IB()
-{
- using simgrid::kernel::resource::NetworkIBModel;
-
- auto net_model = std::make_shared<NetworkIBModel>("Network_IB");
- auto* engine = simgrid::kernel::EngineImpl::get_instance();
- engine->add_model(net_model);
- engine->get_netzone_root()->set_network_model(net_model);
-
- simgrid::s4u::Link::on_communication_state_change_cb(NetworkIBModel::IB_action_state_changed_callback);
- simgrid::kernel::activity::CommImpl::on_start.connect(NetworkIBModel::IB_comm_start_callback);
- simgrid::s4u::Host::on_creation_cb(NetworkIBModel::IB_create_host_callback);
- simgrid::config::set_default<double>("network/weight-S", 8775);
-}
+SIMGRID_REGISTER_NETWORK_MODEL(
+ IB,
+ "Realistic network model specifically tailored for HPC settings, with Infiniband contention model as described in "
+ "http://mescal.imag.fr/membres/jean-marc.vincent/index.html/PhD/Vienne.pdf",
+ []() {
+ using simgrid::kernel::resource::NetworkIBModel;
+
+ auto net_model = std::make_shared<NetworkIBModel>("Network_IB");
+ auto* engine = simgrid::kernel::EngineImpl::get_instance();
+ engine->add_model(net_model);
+ engine->get_netzone_root()->set_network_model(net_model);
+
+ simgrid::s4u::Link::on_communication_state_change_cb(NetworkIBModel::IB_action_state_changed_callback);
+ simgrid::kernel::activity::CommImpl::on_start.connect(NetworkIBModel::IB_comm_start_callback);
+ simgrid::s4u::Host::on_creation_cb(NetworkIBModel::IB_create_host_callback);
+ simgrid::config::set_default<double>("network/weight-S", 8775);
+ });
namespace simgrid::kernel::resource {
/*********
* Model *
*********/
-void surf_network_model_init_NS3()
+// We can't use SIMGRID_REGISTER_NETWORK_MODEL here because ns-3 has a dash in its name
+static void XBT_ATTRIB_CONSTRUCTOR(800) simgrid_ns3_network_model_register()
{
- auto net_model = std::make_shared<simgrid::kernel::resource::NetworkNS3Model>("NS3 network model");
- auto* engine = simgrid::kernel::EngineImpl::get_instance();
- engine->add_model(net_model);
- engine->get_netzone_root()->set_network_model(net_model);
+ simgrid_network_models().add(
+ "ns-3", "Network pseudo-model using the real ns-3 simulator instead of an analytic model", []() {
+ auto net_model = std::make_shared<simgrid::kernel::resource::NetworkNS3Model>("NS3 network model");
+ auto* engine = simgrid::kernel::EngineImpl::get_instance();
+ engine->add_model(net_model);
+ engine->get_netzone_root()->set_network_model(net_model);
+ });
}
static simgrid::config::Flag<std::string>
XBT_PUBLIC void surf_disk_model_init_S19();
-/** @ingroup SURF_models
- * @brief Same as network model 'LagrangeVelho', only with different correction factors.
- *
- * This model is proposed by Pierre-Nicolas Clauss and Martin Quinson and Stéphane Génaud based on the model 'LV08' and
- * different correction factors depending on the communication size (< 1KiB, < 64KiB, >= 64KiB).
- * See comments in the code for more information.
- *
- * @see surf_host_model_init_SMPI()
- */
-XBT_PUBLIC void surf_network_model_init_SMPI();
-
-/** @ingroup SURF_models
- * @brief Same as network model 'LagrangeVelho', only with different correction factors.
- *
- * This model implements a variant of the contention model on Infiniband networks based on
- * the works of Jérôme Vienne : http://mescal.imag.fr/membres/jean-marc.vincent/index.html/PhD/Vienne.pdf
- *
- * @see surf_host_model_init_IB()
- */
-#if !HAVE_SMPI
-XBT_ATTRIB_NORETURN
-#endif
-XBT_PUBLIC void surf_network_model_init_IB();
-
-/** @ingroup SURF_models
- * @brief Initializes the platform with the network model 'LegrandVelho'
- *
- * This model is proposed by Arnaud Legrand and Pedro Velho based on the results obtained with the GTNets simulator for
- * onelink and dogbone sharing scenarios. See comments in the code for more information.
- *
- * @see surf_host_model_init_LegrandVelho()
- */
-XBT_PUBLIC void surf_network_model_init_LegrandVelho();
-
-/** @ingroup SURF_models
- * @brief Initializes the platform with the network model 'Constant'
- *
- * In this model, the communication time between two network cards is constant, hence no need for a routing table.
- * This is particularly useful when simulating huge distributed algorithms where scalability is really an issue. This
- * function is called in conjunction with surf_host_model_init_compound.
- *
- * @see surf_host_model_init_compound()
- */
-XBT_PUBLIC void surf_network_model_init_Constant();
-
-/** @ingroup SURF_models
- * @brief Initializes the platform with the network model CM02
- *
- * You should call this function by yourself only if you plan using surf_host_model_init_compound.
- * See comments in the code for more information.
- */
-XBT_PUBLIC void surf_network_model_init_CM02();
-
-/** @ingroup SURF_models
- * @brief Initializes the platform with the network model NS3
- *
- * This function is called by surf_host_model_init_NS3 or by yourself only if you plan using
- * surf_host_model_init_compound
- *
- * @see surf_host_model_init_NS3()
- */
-#if !SIMGRID_HAVE_NS3
-XBT_ATTRIB_NORETURN
-#endif
-XBT_PUBLIC void surf_network_model_init_NS3();
-
/** @ingroup SURF_models
* @brief Initializes the VM model used in the platform
*
XBT_PUBLIC_DATA simgrid::ModuleGroup surf_optimization_mode_description;
/** @brief The list of all cpu models (pick one with --cfg=cpu/model) */
XBT_PUBLIC_DATA simgrid::ModuleGroup surf_cpu_model_description;
-/** @brief The list of all network models (pick one with --cfg=network/model) */
-XBT_PUBLIC_DATA simgrid::ModuleGroup surf_network_model_description;
/** @brief The list of all disk models (pick one with --cfg=disk/model) */
XBT_PUBLIC_DATA simgrid::ModuleGroup surf_disk_model_description;
/** @brief The list of all host models (pick one with --cfg=host/model:) */
#include <vector>
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_parse);
-
/* Trace related stuff */
XBT_PRIVATE std::unordered_map<std::string, simgrid::kernel::profile::Profile*> traces_set_list;
static std::unordered_map<std::string, std::string> trace_connect_list_host_avail;