- Remove the Java bindings: they were limited to the MSG interface.
- On Windows, you now need to install WSL2 as the native builds are now disabled.
It was not really working anyway.
+ - Support for 32bits architecture is not tested anymore on our CI infrastructure.
+ It may break in the future, but we think that nobody's using SimGrid on 32 bits.
S4U:
- Activity::set_remaining() is not public anymore. Use for example
include src/s4u/s4u_Semaphore.cpp
include src/s4u/s4u_VirtualMachine.cpp
include src/simgrid/Exception.cpp
+include src/simgrid/module.cpp
+include src/simgrid/module.hpp
include src/simgrid/sg_config.cpp
include src/simgrid/sg_version.cpp
include src/simgrid/util.hpp
.. code-block:: console
$ pip install simgrid
-
-Linux Multi-Arch specific instructions
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-On a multiarch x86_64 Linux, it should be possible to compile a 32-bit
-version of SimGrid with something like:
-
-.. code-block:: console
-
- $ CFLAGS=-m32 \
- CXXFLAGS=-m32 \
- FFLAGS=-m32 \
- PKG_CONFIG_LIBDIR=/usr/lib/i386-linux-gnu/pkgconfig/ \
- cmake . \
- -DCMAKE_SYSTEM_PROCESSOR=i386 \
- -DCMAKE_Fortran_COMPILER=/some/path/to/i686-linux-gnu-gfortran \
- -DGFORTRAN_EXE=/some/path/to/i686-linux-gnu-gfortran \
- -DSMPI_C_FLAGS=-m32 \
- -DSMPI_CXX_FLAGS=-m32 \
- -DSMPI_Fortran_FLAGS=-m32
-
-If needed, implement ``i686-linux-gnu-gfortran`` as a script:
-
-.. code-block:: shell
-
- #!/usr/bin/env sh
- exec gfortran -m32 "$@"
int id = std::stoi(args[3]); // unique id to control statistics
/* master and worker names */
- names.emplace(id, MasterWorkerNames{sg4::Host::current()->get_name(), args[2]});
+ names.try_emplace(id, MasterWorkerNames{sg4::Host::current()->get_name(), args[2]});
sg4::Mailbox* mbox = sg4::Mailbox::by_name(args[3]);
XBT_LOG_NEW_DEFAULT_CATEGORY(sem_test, "Simple test of the semaphore");
-static void producer(std::string& buffer, sg4::SemaphorePtr sem_empty, sg4::SemaphorePtr sem_full,
+static void producer(std::string* buffer, sg4::SemaphorePtr sem_empty, sg4::SemaphorePtr sem_full,
const std::vector<std::string>& args)
{
for (auto const& str : args) {
sem_empty->acquire();
XBT_INFO("Pushing '%s'", str.c_str());
- buffer = str;
+ *buffer = str;
sem_full->release();
}
XBT_INFO("Bye!");
}
-static void consumer(const std::string& buffer, sg4::SemaphorePtr sem_empty, sg4::SemaphorePtr sem_full)
+static void consumer(const std::string* buffer, sg4::SemaphorePtr sem_empty, sg4::SemaphorePtr sem_full)
{
std::string str;
do {
sem_full->acquire();
- str = buffer;
+ str = *buffer;
XBT_INFO("Receiving '%s'", str.c_str());
sem_empty->release();
} while (str != "");
auto sem_empty = sg4::Semaphore::create(1); /* indicates whether the buffer is empty */
auto sem_full = sg4::Semaphore::create(0); /* indicates whether the buffer is full */
- sg4::Actor::create("producer", e.host_by_name("Tremblay"), producer, std::ref(buffer), sem_empty, sem_full,
- std::cref(args));
- sg4::Actor::create("consumer", e.host_by_name("Jupiter"), consumer, std::cref(buffer), sem_empty, sem_full);
+ sg4::Actor::create("producer", e.host_by_name("Tremblay"), producer, &buffer, sem_empty, sem_full, std::cref(args));
+ sg4::Actor::create("consumer", e.host_by_name("Jupiter"), consumer, &buffer, sem_empty, sem_full);
e.run();
return 0;
XBT_PUBLIC int _xbt_log_cat_init(xbt_log_category_t category, e_xbt_log_priority_t priority);
extern s_xbt_log_category_t _XBT_LOGV(XBT_LOG_ROOT_CAT);
-extern xbt_log_appender_t xbt_log_default_appender;
-extern xbt_log_layout_t xbt_log_default_layout;
/* ********************** */
/* Public functions again */
/* Modules definitions */
-void xbt_log_preinit(void);
void xbt_log_postexit(void);
void xbt_dict_preinit(void);
XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_config, instr, "Configuration");
std::ofstream tracing_file;
-std::map<const simgrid::instr::Container*, std::ofstream*> tracing_files; // TI specific
+static std::map<const simgrid::instr::Container*, std::ofstream*> tracing_files; // TI specific
constexpr char OPT_TRACING_BASIC[] = "tracing/basic";
constexpr char OPT_TRACING_COMMENT_FILE[] = "tracing/comment-file";
namespace simgrid::instr {
static bool trace_active = false;
TraceFormat trace_format = TraceFormat::Paje;
-int trace_precision;
+static int trace_precision;
/*************
* Callbacks *
XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_api, instr, "API");
-std::set<std::string, std::less<>> created_categories;
-std::set<std::string, std::less<>> declared_marks;
-std::set<std::string, std::less<>> user_host_variables;
-std::set<std::string, std::less<>> user_vm_variables;
-std::set<std::string, std::less<>> user_link_variables;
+static std::set<std::string, std::less<>> created_categories;
+static std::set<std::string, std::less<>> declared_marks;
+static std::set<std::string, std::less<>> user_host_variables;
+static std::set<std::string, std::less<>> user_vm_variables;
+static std::set<std::string, std::less<>> user_link_variables;
static void instr_user_variable(double time, const std::string& resource, const std::string& variable_name,
const std::string& parent_type, double value, InstrUserVariable what,
*/
enum class TraceFormat { Paje, /*TimeIndependent*/ Ti };
extern TraceFormat trace_format;
-extern int trace_precision;
extern double last_timestamp_to_dump;
void init();
XBT_PRIVATE std::string instr_pid(simgrid::s4u::Actor const& proc);
-extern XBT_PRIVATE std::set<std::string, std::less<>> created_categories;
-extern XBT_PRIVATE std::set<std::string, std::less<>> declared_marks;
-extern XBT_PRIVATE std::set<std::string, std::less<>> user_host_variables;
-extern XBT_PRIVATE std::set<std::string, std::less<>> user_vm_variables;
-extern XBT_PRIVATE std::set<std::string, std::less<>> user_link_variables;
-
/* from instr_config.c */
XBT_PRIVATE bool TRACE_needs_platform();
XBT_PRIVATE bool TRACE_is_enabled();
"If you think you've found a bug in SimGrid, please report it along with a\n"
"Minimal Working Example (MWE) reproducing your problem and a full backtrace\n"
"of the fault captured with gdb or valgrind.\n",
- simgrid::kernel::context::stack_size / 1024);
+ simgrid::kernel::context::Context::stack_size / 1024);
} else if (siginfo->si_signo == SIGSEGV) {
fprintf(stderr, "Segmentation fault.\n");
#if HAVE_SMPI
: ActorIDTrait(name, ppid), host_(host), piface_(this)
{
simcall_.issuer_ = this;
- stacksize_ = context::stack_size;
+ stacksize_ = context::Context::stack_size;
}
ActorImpl::~ActorImpl()
namespace simgrid::kernel::context {
-static e_xbt_parmap_mode_t parallel_synchronization_mode = XBT_PARMAP_DEFAULT;
-static int parallel_contexts = 1;
-unsigned stack_size;
-unsigned guard_size;
-
-/** @brief Returns whether some parallel threads are used for the user contexts. */
-bool is_parallel()
-{
- return parallel_contexts > 1;
-}
-
-/**
- * @brief Returns the number of parallel threads used for the user contexts.
- * @return the number of threads (1 means no parallelism)
- */
-int get_nthreads()
-{
- return parallel_contexts;
-}
-
-/**
- * @brief Sets the number of parallel threads to use for the user contexts.
- *
- * This function should be called before initializing SIMIX.
- * A value of 1 means no parallelism (1 thread only).
- * If the value is greater than 1, the thread support must be enabled.
- *
- * @param nb_threads the number of threads to use
- */
-void set_nthreads(int nb_threads)
+void Context::set_nthreads(int nb_threads)
{
if (nb_threads <= 0) {
nb_threads = std::thread::hardware_concurrency();
XBT_INFO("Auto-setting contexts/nthreads to %d", nb_threads);
}
- parallel_contexts = nb_threads;
-}
-
-/**
- * @brief Sets the synchronization mode to use when actors are run in parallel.
- * @param mode how to synchronize threads if actors are run in parallel
- */
-void set_parallel_mode(e_xbt_parmap_mode_t mode)
-{
- parallel_synchronization_mode = mode;
-}
-
-/**
- * @brief Returns the synchronization mode used when actors are run in parallel.
- * @return how threads are synchronized if actors are run in parallel
- */
-e_xbt_parmap_mode_t get_parallel_mode()
-{
- return parallel_synchronization_mode;
+ Context::parallel_contexts = nb_threads;
}
ContextFactory::~ContextFactory() = default;
+e_xbt_parmap_mode_t Context::parallel_mode = XBT_PARMAP_DEFAULT;
+int Context::parallel_contexts = 1;
+unsigned Context::stack_size;
+unsigned Context::guard_size;
thread_local Context* Context::current_context_ = nullptr;
/* Install or disable alternate signal stack, for SIGSEGV handler. */
#include <functional>
namespace simgrid::kernel::context {
-extern unsigned stack_size;
-extern unsigned guard_size;
class XBT_PUBLIC ContextFactory {
public:
class XBT_PUBLIC Context {
friend ContextFactory;
+ static int parallel_contexts;
static thread_local Context* current_context_;
std::function<void()> code_;
void declare_context(std::size_t size);
public:
+ static e_xbt_parmap_mode_t parallel_mode;
+ static unsigned stack_size;
+ static unsigned guard_size;
+
static int install_sigsegv_stack(bool enable);
Context(std::function<void()>&& code, actor::ActorImpl* actor, bool maestro);
bool has_code() const { return static_cast<bool>(code_); }
actor::ActorImpl* get_actor() const { return this->actor_; }
+ /** @brief Returns whether some parallel threads are used for the user contexts. */
+ static bool is_parallel() { return parallel_contexts > 1; }
+ /** @brief Returns the number of parallel threads used for the user contexts (1 means no parallelism). */
+ static int get_nthreads() { return parallel_contexts; }
+ /**
+ * @brief Sets the number of parallel threads to use for the user contexts.
+ *
+ * This function should be called before initializing SIMIX.
+ * A value of 1 means no parallelism (1 thread only).
+ * If the value is greater than 1, the thread support must be enabled.
+ * If the value is less than 1, the optimal number of threads is chosen automatically.
+ *
+ * @param nb_threads the number of threads to use
+ */
+ static void set_nthreads(int nb_threads);
+
// Scheduling methods
virtual void stop();
virtual void suspend() = 0;
XBT_PRIVATE ContextFactory* raw_factory();
XBT_PRIVATE ContextFactory* boost_factory();
-XBT_PUBLIC bool is_parallel();
-XBT_PUBLIC int get_nthreads();
-XBT_PUBLIC void set_nthreads(int nb_threads);
-XBT_PUBLIC void set_parallel_mode(e_xbt_parmap_mode_t mode);
-XBT_PUBLIC e_xbt_parmap_mode_t get_parallel_mode();
} // namespace simgrid::kernel::context
#endif
* stuff It is much easier to understand what happens if you see the working threads as bodies that swap their soul
* for the ones of the simulated processes that must run.
*/
- if (is_parallel()) {
+ if (Context::is_parallel()) {
// We lazily create the parmap so that all options are actually processed when doing so.
if (parmap_ == nullptr)
- parmap_ = std::make_unique<simgrid::xbt::Parmap<actor::ActorImpl*>>(get_nthreads(), get_parallel_mode());
+ parmap_ =
+ std::make_unique<simgrid::xbt::Parmap<actor::ActorImpl*>>(Context::get_nthreads(), Context::parallel_mode);
// Usually, Parmap::apply() executes the provided function on all elements of the array.
// Here, the executed function does not return the control to the parmap before all the array is processed:
ThreadContextFactory::ThreadContextFactory() : ContextFactory()
{
- if (stack_size != 8 * 1024 * 1024)
+ if (Context::stack_size != 8 * 1024 * 1024)
XBT_INFO("Stack size modifications are ignored by thread factory.");
- if (is_parallel())
+ if (Context::is_parallel())
ParallelThreadContext::initialize();
}
ThreadContextFactory::~ThreadContextFactory()
{
- if (is_parallel())
+ if (Context::is_parallel())
ParallelThreadContext::finalize();
}
ThreadContext* ThreadContextFactory::create_context(std::function<void()>&& code, actor::ActorImpl* actor, bool maestro)
{
- if (is_parallel())
+ if (Context::is_parallel())
return this->new_context<ParallelThreadContext>(std::move(code), actor, maestro);
else
return this->new_context<SerialThreadContext>(std::move(code), actor, maestro);
void ThreadContextFactory::run_all(std::vector<actor::ActorImpl*> const& actors_list)
{
- if (is_parallel())
+ if (Context::is_parallel())
ParallelThreadContext::run_all(actors_list);
else
#include "simgrid/kernel/routing/NetPoint.hpp"
#include "src/kernel/resource/StandardLinkImpl.hpp"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_cluster, ker_routing, "Kernel Cluster Routing");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_cluster, ker_platform, "Kernel Cluster Routing");
/* This routing is specifically setup to represent clusters, aka homogeneous sets of machines
* Note that a router is created, easing the interconnection with the rest of the world. */
#include <queue>
#include <vector>
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_dijkstra, ker_routing, "Kernel Dijkstra Routing");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_dijkstra, ker_platform, "Kernel Dijkstra Routing");
namespace simgrid {
namespace kernel::routing {
#include <numeric>
#include <string>
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_dragonfly, ker_routing, "Kernel Dragonfly Routing");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_dragonfly, ker_platform, "Kernel Dragonfly Routing");
namespace simgrid {
namespace kernel::routing {
#include "simgrid/kernel/routing/EmptyZone.hpp"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_none, ker_routing, "Kernel No Routing");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_none, ker_platform, "Kernel No Routing");
namespace simgrid {
namespace kernel::routing {
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_fat_tree, ker_routing, "Kernel Fat-Tree Routing");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_fat_tree, ker_platform, "Kernel Fat-Tree Routing");
namespace simgrid {
namespace kernel::routing {
#include <climits>
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_floyd, ker_routing, "Kernel Floyd Routing");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_floyd, ker_platform, "Kernel Floyd Routing");
namespace simgrid {
namespace kernel::routing {
#include "src/kernel/resource/NetworkModel.hpp"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_full, ker_routing, "Kernel Full Routing");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_full, ker_platform, "Kernel Full Routing");
namespace simgrid {
namespace kernel::routing {
#include "simgrid/s4u/Host.hpp"
#include "xbt/log.h"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_netpoint, ker_routing, "Kernel implementation of netpoints");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_netpoint, ker_platform, "Kernel implementation of netpoints");
namespace simgrid {
#include "src/kernel/resource/VirtualMachineImpl.hpp"
#include "src/surf/HostImpl.hpp"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing, kernel, "Kernel routing-related information");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_platform, kernel, "Kernel platform-related information");
namespace simgrid::kernel::routing {
xbt_enforce(not disk_model_name.empty(), "Set a disk model to use with the 'compound' host model");
xbt_enforce(not network_model_name.empty(), "Set a network model to use with the 'compound' host model");
- const auto* cpu_model = find_model_description(surf_cpu_model_description, cpu_model_name);
- cpu_model->model_init_preparse();
-
- const auto* disk_model = find_model_description(surf_disk_model_description, disk_model_name);
- disk_model->model_init_preparse();
-
- const auto* network_model = find_model_description(surf_network_model_description, network_model_name);
- network_model->model_init_preparse();
+ surf_cpu_model_description.by_name(cpu_model_name).init();
+ surf_disk_model_description.by_name(disk_model_name).init();
+ simgrid_network_models().by_name(network_model_name).init();
}
- XBT_DEBUG("Call host_model_init");
- const auto* host_model = find_model_description(surf_host_model_description, host_model_name);
- host_model->model_init_preparse();
+ surf_host_model_description.by_name(host_model_name).init();
XBT_DEBUG("Call vm_model_init");
- /* ideally we should get back the pointer to CpuModel from model_init_preparse(), but this
- * requires changing the declaration of surf_cpu_model_description.
- * To be reviewed in the future */
+ /* TODO: ideally we should get back the pointer to CpuModel from init(), but this
+ * requires changing the declaration of surf_cpu_model_description. */
surf_vm_model_init_HL13(
simgrid::s4u::Engine::get_instance()->get_netzone_root()->get_impl()->get_cpu_pm_model().get());
}
#include "xbt/sysdep.h"
#include "xbt/asserts.hpp"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_generic, ker_routing, "Kernel Generic Routing");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_generic, ker_platform, "Kernel Generic Routing");
/* ***************************************************************** */
/* *********************** GENERIC METHODS ************************* */
#include "src/kernel/resource/NetworkModel.hpp"
#include "xbt/string.hpp"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_star, ker_routing, "Kernel Star Routing");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_star, ker_platform, "Kernel Star Routing");
namespace simgrid {
namespace kernel::routing {
#include <string>
#include <vector>
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_torus, ker_routing, "Kernel Torus Routing");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_torus, ker_platform, "Kernel Torus Routing");
namespace simgrid {
namespace kernel ::routing {
#include <boost/algorithm/string.hpp>
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_vivaldi, ker_routing, "Kernel Vivaldi Routing");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_vivaldi, ker_platform, "Kernel Vivaldi Routing");
namespace simgrid {
namespace kernel::routing {
#include "src/kernel/resource/NetworkModel.hpp"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_wifi, ker_routing, "Kernel Wifi Routing");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_wifi, ker_platform, "Kernel Wifi Routing");
namespace simgrid {
namespace kernel::routing {
#include <simgrid/s4u/Host.hpp>
#include <xbt/config.hpp>
-#include "src/surf/surf_interface.hpp" // SIMGRID_REGISTER_PLUGIN
+#include "src/simgrid/module.hpp" // SIMGRID_REGISTER_PLUGIN
namespace sg4 = simgrid::s4u;
static simgrid::config::Flag<bool> cfg_tell{"cmonkey/tell", "Request the Chaos Monkey to display all timestamps",
#include <simgrid/s4u/VirtualMachine.hpp>
#include "src/kernel/activity/ExecImpl.hpp"
-#include "src/surf/surf_interface.hpp"
+#include "src/simgrid/module.hpp" // SIMGRID_REGISTER_PLUGIN
// Makes sure that this plugin can be activated from the command line with ``--cfg=plugin:host_load``
SIMGRID_REGISTER_PLUGIN(host_load, "Cpu load", &sg_host_load_plugin_init)
@endrst
*/
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(host_load, kernel, "Logging specific to the HostLoad plugin");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(host_load, plugin, "Logging specific to the HostLoad plugin");
namespace simgrid::plugin {
#include "src/kernel/activity/CommImpl.hpp"
#include "src/kernel/resource/NetworkModel.hpp"
+#include "src/simgrid/module.hpp" // SIMGRID_REGISTER_PLUGIN
#include <limits>
#include <string>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_host, s4u, "Logging specific to the S4U hosts");
-XBT_LOG_EXTERNAL_CATEGORY(ker_routing);
+XBT_LOG_EXTERNAL_CATEGORY(ker_platform);
namespace simgrid {
void Host::route_to(const Host* dest, std::vector<kernel::resource::StandardLinkImpl*>& links, double* latency) const
{
kernel::routing::NetZoneImpl::get_global_route(pimpl_netpoint_, dest->get_netpoint(), links, latency);
- if (XBT_LOG_ISENABLED(ker_routing, xbt_log_priority_debug)) {
- XBT_CDEBUG(ker_routing, "Route from '%s' to '%s' (latency: %f):", get_cname(), dest->get_cname(),
+ if (XBT_LOG_ISENABLED(ker_platform, xbt_log_priority_debug)) {
+ XBT_CDEBUG(ker_platform, "Route from '%s' to '%s' (latency: %f):", get_cname(), dest->get_cname(),
(latency == nullptr ? -1 : *latency));
for (auto const* link : links)
- XBT_CDEBUG(ker_routing, " Link '%s'", link->get_cname());
+ XBT_CDEBUG(ker_platform, " Link '%s'", link->get_cname());
}
}
--- /dev/null
+/* Copyright (c) 2004-2023. The SimGrid Team. All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include <xbt/asserts.h>
+#include <xbt/log.h>
+
+#include "src/simgrid/module.hpp"
+#include "src/surf/surf_interface.hpp"
+
+#include <sstream>
+
+XBT_LOG_NEW_CATEGORY(plugin, "Common category for the logging of all plugins");
+XBT_LOG_EXTERNAL_CATEGORY(xbt_help);
+
+using namespace simgrid;
+
+ModuleGroup& ModuleGroup::add(const char* id, const char* desc, std::function<void()> init)
+{
+ table_.emplace_back(Module(id, desc, init));
+ return *this;
+}
+
+Module const& ModuleGroup::by_name(const std::string& name) const
+{
+ if (auto pos = std::find_if(table_.begin(), table_.end(), [&name](const Module& item) { return item.name_ == name; });
+ pos != table_.end())
+ return *pos;
+
+ xbt_die("Unable to find %s '%s'. Valid values are: %s.", kind_.c_str(), name.c_str(), existing_values().c_str());
+}
+/** Displays the long description of all registered models, and quit */
+void ModuleGroup::help() const
+{
+ XBT_HELP("Long description of the %s accepted by this simulator:", kind_.c_str());
+ for (auto const& item : table_)
+ XBT_HELP(" %s: %s", item.name_, item.description_);
+}
+std::string ModuleGroup::existing_values() const
+{
+ std::stringstream ss;
+ std::string sep;
+ for (auto const& item : table_) {
+ ss << sep + item.name_;
+ sep = ", ";
+ }
+ return ss.str();
+}
+
+/* -------------------------------------------------------------------------------------------------------------- */
+simgrid::ModuleGroup surf_optimization_mode_description("optimization mode");
+simgrid::ModuleGroup surf_cpu_model_description("CPU model");
+simgrid::ModuleGroup surf_disk_model_description("disk model");
+simgrid::ModuleGroup surf_host_model_description("host model");
+
+void simgrid_create_models()
+{
+ 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);
+
+ surf_host_model_description
+ .add("default",
+ "Default host model. Currently, CPU:Cas01, network:LV08 (with cross traffic enabled), and disk:S19",
+ &surf_host_model_init_current_default)
+ .add("compound", "Host model that is automatically chosen if you change the CPU, network, and disk models",
+ &surf_host_model_init_compound)
+ .add("ptask_L07", "Host model somehow similar to Cas01+CM02+S19 but allowing parallel tasks",
+ &surf_host_model_init_ptask_L07);
+
+ surf_optimization_mode_description
+ .add("Lazy", "Lazy action management (partial invalidation in lmm + heap in action remaining).", nullptr)
+ .add("TI",
+ "Trace integration. Highly optimized mode when using availability traces (only available for the Cas01 CPU "
+ "model for now).",
+ nullptr)
+ .add("Full", "Full update of remaining and variables. Slow but may be useful when debugging.", nullptr);
+}
--- /dev/null
+/* Copyright (c) 2004-2023. The SimGrid Team. All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#ifndef SIMGRID_MODULE_HPP
+#define SIMGRID_MODULE_HPP
+
+#include <xbt/base.h>
+
+#include <functional>
+#include <string>
+#include <vector>
+
+namespace simgrid {
+
+struct Module {
+ const char* name_;
+ const char* description_;
+ std::function<void()> init;
+ Module(const char* id, const char* desc, std::function<void()> init_fun)
+ : name_(id), description_(desc), init(init_fun)
+ {
+ }
+};
+
+class ModuleGroup {
+ std::vector<Module> table_;
+ 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;
+};
+
+}; // namespace simgrid
+
+#define SIMGRID_REGISTER_PLUGIN(id, desc, init) \
+ static void XBT_ATTRIB_CONSTRUCTOR(800) _XBT_CONCAT3(simgrid_, id, _plugin_register)() \
+ { \
+ simgrid_plugins().add(_XBT_STRINGIFY(id), (desc), (init)); \
+ }
+
+/** @brief The list of all available plugins */
+inline auto& simgrid_plugins() // Function to avoid static initialization order fiasco
+{
+ static simgrid::ModuleGroup plugins("plugin");
+ 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
#include "src/kernel/resource/NetworkModel.hpp"
#include "src/mc/mc_config.hpp"
#include "src/mc/mc_replay.hpp"
+#include "src/simgrid/module.hpp"
#include "src/smpi/include/smpi_config.hpp"
#include "src/surf/surf_interface.hpp"
#include <string_view>
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_config, surf, "About the configuration of SimGrid");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(config, kernel, "About the configuration of SimGrid");
static simgrid::config::Flag<bool> cfg_continue_after_help
{"help-nostop", "Do not stop the execution when --help is found", false};
XBT_HELP("Please consider using the recent names");
shall_exit = true;
} else if (parse_args && not strcmp(argv[i], "--help-models")) {
- model_help("host", surf_host_model_description);
+ surf_host_model_description.help();
XBT_HELP("%s", "");
- model_help("CPU", surf_cpu_model_description);
+ surf_cpu_model_description.help();
XBT_HELP("%s", "");
- model_help("network", surf_network_model_description);
+ simgrid_network_models().help();
XBT_HELP("\nLong description of all optimization levels accepted by the models of this simulator:");
- for (auto const& item : surf_optimization_mode_description)
- XBT_HELP(" %s: %s", item.name, item.description);
+ surf_optimization_mode_description.help();
XBT_HELP("Both network and CPU models have 'Lazy' as default optimization level\n");
shall_exit = true;
} else if (parse_args && not strcmp(argv[i], "--help-tracing")) {
return;
if (value == "help") {
- model_help("plugin", surf_plugin_description());
+ simgrid_plugins().help();
exit(0);
}
- const auto* plugin = find_model_description(surf_plugin_description(), value);
- plugin->model_init_preparse();
+ simgrid_plugins().by_name(value).init();
}
/* callback of the host/model variable */
xbt_assert(_sg_cfg_init_status < 2, "Cannot change the model after the initialization");
if (value == "help") {
- model_help("host", surf_host_model_description);
+ surf_host_model_description.help();
exit(0);
}
/* Make sure that the model exists */
- find_model_description(surf_host_model_description, value);
+ surf_host_model_description.by_name(value);
}
/* callback of the cpu/model variable */
xbt_assert(_sg_cfg_init_status < 2, "Cannot change the model after the initialization");
if (value == "help") {
- model_help("CPU", surf_cpu_model_description);
+ surf_cpu_model_description.help();
exit(0);
}
- /* New Module missing */
- find_model_description(surf_cpu_model_description, value);
+ /* Make sure that the model exists */
+ surf_cpu_model_description.by_name(value);
}
/* callback of the cpu/model variable */
xbt_assert(_sg_cfg_init_status < 2, "Cannot change the model after the initialization");
if (value == "help") {
- model_help("optimization", surf_optimization_mode_description);
+ surf_optimization_mode_description.help();
exit(0);
}
- /* New Module missing */
- find_model_description(surf_optimization_mode_description, value);
+ /* Make sure that the model exists */
+ surf_optimization_mode_description.by_name(value);
}
static void _sg_cfg_cb__disk_model(const std::string& value)
xbt_assert(_sg_cfg_init_status < 2, "Cannot change the model after the initialization");
if (value == "help") {
- model_help("disk", surf_disk_model_description);
+ surf_disk_model_description.help();
exit(0);
}
- find_model_description(surf_disk_model_description, value);
+ surf_disk_model_description.by_name(value);
}
/* callback of the network_model variable */
xbt_assert(_sg_cfg_init_status < 2, "Cannot change the model after the initialization");
if (value == "help") {
- model_help("network", surf_network_model_description);
+ simgrid_network_models().help();
exit(0);
}
- /* New Module missing */
- find_model_description(surf_network_model_description, 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)
{
if (mode_name == "posix") {
- simgrid::kernel::context::set_parallel_mode(XBT_PARMAP_POSIX);
+ simgrid::kernel::context::Context::parallel_mode = XBT_PARMAP_POSIX;
} else if (mode_name == "futex") {
- simgrid::kernel::context::set_parallel_mode(XBT_PARMAP_FUTEX);
+ simgrid::kernel::context::Context::parallel_mode = XBT_PARMAP_FUTEX;
} else if (mode_name == "busy_wait") {
- simgrid::kernel::context::set_parallel_mode(XBT_PARMAP_BUSY_WAIT);
+ simgrid::kernel::context::Context::parallel_mode = XBT_PARMAP_BUSY_WAIT;
} else {
xbt_die("Command line setting of the parallel synchronization mode should "
"be one of \"posix\", \"futex\" or \"busy_wait\"");
/* build description line with possible values */
static void declare_model_flag(const std::string& name, const std::string& value,
const std::function<void(std::string const&)>& callback,
- const std::vector<surf_model_description_t>& model_description, const std::string& type,
+ const simgrid::ModuleGroup& model_description, const std::string& type,
const std::string& descr)
{
- std::string description = descr + ". Possible values: ";
- std::string sep = "";
- for (auto const& item : model_description) {
- description += sep + item.name;
- sep = ", ";
- }
+ 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);
}
XBT_WARN("Call to sg_config_init() after initialization ignored");
return;
}
-
+ simgrid_create_models();
/* Plugins configuration */
- declare_model_flag("plugin", "", &_sg_cfg_cb__plugin, surf_plugin_description(), "plugin", "The plugins");
+ declare_model_flag("plugin", "", &_sg_cfg_cb__plugin, simgrid_plugins(), "plugin", "The plugins");
declare_model_flag("cpu/model", "Cas01", &_sg_cfg_cb__cpu_model, surf_cpu_model_description, "model",
"The model to use for the CPU");
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,
static simgrid::config::Flag<int> cfg_context_stack_size{
"contexts/stack-size", "Stack size of contexts in KiB (not with threads)", 8 * 1024,
- [](int value) { simgrid::kernel::context::stack_size = value * 1024; }};
+ [](int value) { simgrid::kernel::context::Context::stack_size = value * 1024; }};
/* guard size for contexts stacks in memory pages */
#if (PTH_STACKGROWTH != -1)
#endif
static simgrid::config::Flag<int> cfg_context_guard_size{
"contexts/guard-size", "Guard size for contexts stacks in memory pages", default_guard_size,
- [](int value) { simgrid::kernel::context::guard_size = value * xbt_pagesize; }};
+ [](int value) { simgrid::kernel::context::Context::guard_size = value * xbt_pagesize; }};
static simgrid::config::Flag<int> cfg_context_nthreads{
"contexts/nthreads", "Number of parallel threads used to execute user contexts", 1, [](int nthreads) {
"Parallel simulation is forbidden in the verified program, as there is no protection against race "
"conditions in mmalloc itself. Please don't be so greedy and show some mercy for our implementation.");
#endif
- simgrid::kernel::context::set_nthreads(nthreads);
+ simgrid::kernel::context::Context::set_nthreads(nthreads);
}};
/* synchronization mode for parallel user contexts */
sg_config_cmd_line(argc, argv);
- xbt_mallocator_initialization_is_done(simgrid::kernel::context::is_parallel());
+ xbt_mallocator_initialization_is_done(simgrid::kernel::context::Context::is_parallel());
}
void sg_config_finalize()
#include "xbt/misc.h"
#include "xbt/sysdep.h"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sg_version, surf, "About the versioning of SimGrid");
-
void sg_version_check(int lib_version_major, int lib_version_minor, int lib_version_patch)
{
if ((lib_version_major != SIMGRID_VERSION_MAJOR) || (lib_version_minor != SIMGRID_VERSION_MINOR)) {
// We only need a simcall if the order of the setters is important (parallel run or MC execution).
// Otherwise, just call the function with no simcall
- if (simgrid::kernel::context::is_parallel()
+ if (simgrid::kernel::context::Context::is_parallel()
#if SIMGRID_HAVE_MC
|| MC_is_active() || MC_record_replay_is_active()
#endif
#define MPI_REQUEST_IGNORED ((MPI_Request*)-100)
/* Bindings for MPI special values */
-extern XBT_PUBLIC int mpi_in_place_;
-extern XBT_PUBLIC int mpi_bottom_;
-extern XBT_PUBLIC int mpi_status_ignore_;
-extern XBT_PUBLIC int mpi_statuses_ignore_;
+extern XBT_PUBLIC const int mpi_in_place_;
+extern XBT_PUBLIC const int mpi_bottom_;
+extern XBT_PUBLIC const int mpi_status_ignore_;
+extern XBT_PUBLIC const int mpi_statuses_ignore_;
/* Convert between Fortran and C */
-#define FORT_ADDR(addr, val, val2) \
- (((void *)(addr) == (void*) &(val2)) \
- ? (val) : (void *)(addr))
+#define FORT_ADDR(addr, val, val2) (((const void*)(addr) == (const void*)&(val2)) ? (val) : (void*)(addr))
#define FORT_BOTTOM(addr) FORT_ADDR((addr), MPI_BOTTOM, mpi_bottom_)
#define FORT_IN_PLACE(addr) FORT_ADDR((addr), MPI_IN_PLACE, mpi_in_place_)
#define FORT_STATUS_IGNORE(addr) static_cast<MPI_Status*>(FORT_ADDR((addr), MPI_STATUS_IGNORE, mpi_status_ignore_))
// utilities
XBT_PRIVATE void smpi_init_options_internal(bool called_by_smpi_main);
-extern XBT_PRIVATE char* smpi_data_exe_start; // start of the data+bss segment of the executable
-extern XBT_PRIVATE size_t smpi_data_exe_size; // size of the data+bss segment of the executable
-
XBT_PRIVATE bool smpi_switch_data_segment(simgrid::s4u::ActorPtr actor, const void* addr = nullptr);
XBT_PRIVATE void smpi_prepare_global_memory_segment();
std::unordered_map<std::string, double> location2speedup;
static int smpi_exit_status = 0;
-xbt_os_timer_t global_timer;
+static xbt_os_timer_t global_timer;
static std::vector<std::string> privatize_libs_paths;
// No instance gets manually created; check also the smpirun.in script as
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_memory, smpi, "Memory layout support for SMPI");
-char* smpi_data_exe_start = nullptr;
-size_t smpi_data_exe_size = 0;
-SmpiPrivStrategies smpi_privatize_global_variables;
+static char* smpi_data_exe_start = nullptr; // start of the data+bss segment of the executable
+static size_t smpi_data_exe_size = 0; // size of the data+bss segment of the executable
+static SmpiPrivStrategies smpi_privatize_global_variables;
static void* smpi_data_exe_copy;
// Initialized by smpi_prepare_global_memory_segment().
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_shared, smpi, "Logging specific to SMPI (shared memory macros)");
-namespace{
+namespace {
/** Some location in the source code
*
* This information is used by SMPI_SHARED_MALLOC to allocate some shared memory for all simulated processes.
int smpi_shared_malloc_bogusfile = -1;
int smpi_shared_malloc_bogusfile_huge_page = -1;
unsigned long smpi_shared_malloc_blocksize = 1UL << 20;
-}
+} // namespace
void smpi_shared_destroy()
{
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_utils, smpi, "Logging specific to SMPI (utils)");
-extern std::string surf_parsed_filename;
-extern int surf_parse_lineno;
-
-namespace simgrid::smpi::utils {
+namespace {
double total_benched_time=0;
unsigned long total_malloc_size=0;
};
alloc_metadata_t max_malloc;
-F2C* current_handle = nullptr;
+simgrid::smpi::F2C* current_handle = nullptr;
current_buffer_metadata_t current_buffer1;
current_buffer_metadata_t current_buffer2;
std::unordered_map<int, std::vector<std::string>> collective_calls;
+} // namespace
+
+namespace simgrid::smpi::utils {
+
void add_benched_time(double time){
total_benched_time += time;
}
#include "src/smpi/include/smpi_actor.hpp"
#include "src/instr/instr_smpi.hpp"
-int mpi_in_place_;
-int mpi_bottom_;
-int mpi_status_ignore_;
-int mpi_statuses_ignore_;
+const int mpi_in_place_ = -222;
+const int mpi_bottom_ = -111;
+const int mpi_status_ignore_ = 0;
+const int mpi_statuses_ignore_ = 0;
namespace simgrid::smpi {
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 {
extern std::map<std::string, SgFlow*, std::less<>> flow_from_sock;
extern std::map<std::string, ns3::ApplicationContainer, std::less<>> sink_from_sock;
-static ns3::InternetStackHelper stack;
-
static int number_of_links = 1;
static int number_of_networks = 1;
NetPointNs3::NetPointNs3()
{
+ static ns3::InternetStackHelper stack;
stack.Install(ns3_node_);
}
/*********
* 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>
#include <algorithm>
#include <string>
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_parse);
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(platf_parse);
namespace simgrid::kernel::routing {
xbt::signal<void(ClusterCreationArgs const&)> on_cluster_creation;
#include <fstream>
#include <string>
-XBT_LOG_NEW_CATEGORY(surf, "All SURF categories");
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_kernel, surf, "Logging specific to SURF (kernel)");
-
/*********
* Utils *
*********/
-simgrid::kernel::profile::FutureEvtSet future_evt_set;
std::vector<std::string> surf_path;
-
-const std::vector<surf_model_description_t> surf_network_model_description = {
- {"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},
- {"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},
- {"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},
- {"IB", "Realistic network model specifically tailored for HPC settings, with Infiniband contention model",
- &surf_network_model_init_IB},
- {"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},
- {"ns-3", "Network pseudo-model using the ns-3 tcp model instead of an analytic model",
- &surf_network_model_init_NS3},
-};
-
-#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
-
-const std::vector<surf_model_description_t> surf_cpu_model_description = {
- {"Cas01", "Simplistic CPU model (time=size/speed).", &surf_cpu_model_init_Cas01},
-};
-
-const std::vector<surf_model_description_t> surf_disk_model_description = {
- {"S19", "Simplistic disk model.", &surf_disk_model_init_S19},
-};
-
-const std::vector<surf_model_description_t> surf_host_model_description = {
- {"default", "Default host model. Currently, CPU:Cas01, network:LV08 (with cross traffic enabled), and disk:S19",
- &surf_host_model_init_current_default},
- {"compound", "Host model that is automatically chosen if you change the CPU, network, and disk models",
- &surf_host_model_init_compound},
- {"ptask_L07", "Host model somehow similar to Cas01+CM02+S19 but allowing parallel tasks",
- &surf_host_model_init_ptask_L07},
-};
-
-const std::vector<surf_model_description_t> surf_optimization_mode_description = {
- {"Lazy", "Lazy action management (partial invalidation in lmm + heap in action remaining).", nullptr},
- {"TI",
- "Trace integration. Highly optimized mode when using availability traces (only available for the Cas01 CPU "
- "model for now).",
- nullptr},
- {"Full", "Full update of remaining and variables. Slow but may be useful when debugging.", nullptr},
-};
-
-/** Displays the long description of all registered models, and quit */
-void model_help(const char* category, const std::vector<surf_model_description_t>& table)
-{
- XBT_HELP("Long description of the %s models accepted by this simulator:", category);
- for (auto const& item : table)
- XBT_HELP(" %s: %s", item.name, item.description);
-}
-
-const surf_model_description_t* find_model_description(const std::vector<surf_model_description_t>& table,
- const std::string& name)
-{
- if (auto pos = std::find_if(table.begin(), table.end(),
- [&name](const surf_model_description_t& item) { return item.name == name; });
- pos != table.end())
- return &*pos;
-
- std::string sep;
- std::string name_list;
- for (auto const& item : table) {
- name_list += sep + item.name;
- sep = ", ";
- }
- xbt_die("Model '%s' is invalid! Valid models are: %s.", name.c_str(), name_list.c_str());
-}
#ifndef SURF_MODEL_H_
#define SURF_MODEL_H_
+#include "src/simgrid/module.hpp"
#include <xbt/asserts.h>
#include <xbt/function_types.h>
#include "src/internal_config.h"
+#include "src/kernel/resource/profile/Profile.hpp"
#include <cfloat>
#include <cmath>
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
*
* A VM model depends on the physical CPU model to share the resources inside the VM
* It will also creates the CPU model for actions running inside the VM
*
- * Such model is subject to modification with warning in the ChangeLog so monitor it!
*/
XBT_PUBLIC void surf_vm_model_init_HL13(simgrid::kernel::resource::CpuModel* cpu_pm_model);
/* --------------------
* Model Descriptions
* -------------------- */
-/** @brief Resource model description */
-struct surf_model_description_t {
- const char* name;
- const char* description;
- std::function<void()> model_init_preparse;
-};
-
-XBT_PUBLIC const surf_model_description_t* find_model_description(const std::vector<surf_model_description_t>& table,
- const std::string& name);
-XBT_PUBLIC void model_help(const char* category, const std::vector<surf_model_description_t>& table);
-
-#define SIMGRID_REGISTER_PLUGIN(id, desc, init) \
- static void XBT_ATTRIB_CONSTRUCTOR(800) _XBT_CONCAT3(simgrid_, id, _plugin_register)() \
- { \
- surf_plugin_description().emplace_back(surf_model_description_t{_XBT_STRINGIFY(id), (desc), (init)}); \
- }
-/** @brief The list of all available plugins */
-inline auto& surf_plugin_description() // Function to avoid static initialization order fiasco
-{
- static std::vector<surf_model_description_t> plugin_description_table;
- return plugin_description_table;
-}
/** @brief The list of all available optimization modes (both for cpu and networks).
* These optimization modes can be set using --cfg=cpu/optim:... and --cfg=network/optim:... */
-XBT_PUBLIC_DATA const std::vector<surf_model_description_t> surf_optimization_mode_description;
+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 const std::vector<surf_model_description_t> surf_cpu_model_description;
-/** @brief The list of all network models (pick one with --cfg=network/model) */
-XBT_PUBLIC_DATA const std::vector<surf_model_description_t> surf_network_model_description;
+XBT_PUBLIC_DATA simgrid::ModuleGroup surf_cpu_model_description;
/** @brief The list of all disk models (pick one with --cfg=disk/model) */
-XBT_PUBLIC_DATA const std::vector<surf_model_description_t> surf_disk_model_description;
+XBT_PUBLIC_DATA simgrid::ModuleGroup surf_disk_model_description;
/** @brief The list of all host models (pick one with --cfg=host/model:) */
-XBT_PUBLIC_DATA const std::vector<surf_model_description_t> surf_host_model_description;
+XBT_PUBLIC_DATA simgrid::ModuleGroup surf_host_model_description;
+
+void simgrid_create_models();
#endif /* SURF_MODEL_H_ */
#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;
-XBT_PRIVATE std::unordered_map<std::string, std::string> trace_connect_list_host_avail;
-XBT_PRIVATE std::unordered_map<std::string, std::string> trace_connect_list_host_speed;
-XBT_PRIVATE std::unordered_map<std::string, std::string> trace_connect_list_link_avail;
-XBT_PRIVATE std::unordered_map<std::string, std::string> trace_connect_list_link_bw;
-XBT_PRIVATE std::unordered_map<std::string, std::string> trace_connect_list_link_lat;
+static std::unordered_map<std::string, std::string> trace_connect_list_host_avail;
+static std::unordered_map<std::string, std::string> trace_connect_list_host_speed;
+static std::unordered_map<std::string, std::string> trace_connect_list_link_avail;
+static std::unordered_map<std::string, std::string> trace_connect_list_link_bw;
+static std::unordered_map<std::string, std::string> trace_connect_list_link_lat;
void sg_platf_trace_connect(simgrid::kernel::routing::TraceConnectCreationArgs* trace_connect)
{
#include "simgrid_dtd.c"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_parse, surf, "Logging specific to the SURF parsing module");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(platf_parse, ker_platform, "Logging specific to the parsing of platform files");
std::string surf_parsed_filename; // Currently parsed file (for the error messages)
-std::vector<simgrid::s4u::LinkInRoute> parsed_link_list; /* temporary store of current link list of a route */
+static std::vector<simgrid::s4u::LinkInRoute> parsed_link_list; /* temporary store of current link list of a route */
/* Helping functions */
void surf_parse_assert(bool cond, const std::string& msg)
/* make sure these symbols are defined as strong ones in this file so that the linker can resolve them */
-std::vector<std::unordered_map<std::string, std::string>> property_sets;
+static std::vector<std::unordered_map<std::string, std::string>> property_sets;
-FILE *surf_file_to_parse = nullptr;
+static FILE* surf_file_to_parse = nullptr;
/* Stuff relative to storage */
void STag_surfxml_storage()
void ETag_surfxml_model___prop(){/* Nothing to do */}
/* Open and Close parse file */
-YY_BUFFER_STATE surf_input_buffer;
+static YY_BUFFER_STATE surf_input_buffer;
void surf_parse_open(const std::string& file)
{
#include <vector>
int xbt_log_no_loc = 0; /* if set to true (with --log=no_loc), file localization will be omitted (for tesh tests) */
-static std::recursive_mutex* log_cat_init_mutex = nullptr;
-
-xbt_log_appender_t xbt_log_default_appender = nullptr; /* set in log_init */
-xbt_log_layout_t xbt_log_default_layout = nullptr; /* set in log_init */
struct xbt_log_setting_t {
std::string catname;
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(log, xbt, "Loggings from the logging mechanism itself");
-/* create the default appender and install it in the root category,
- which were already created (damnit. Too slow little beetle) */
-void xbt_log_preinit(void)
-{
- xbt_log_default_appender = xbt_log_appender_stream(stderr);
- xbt_log_default_layout = xbt_log_layout_simple_new(nullptr);
- _XBT_LOGV(XBT_LOG_ROOT_CAT).appender = xbt_log_default_appender;
- _XBT_LOGV(XBT_LOG_ROOT_CAT).layout = xbt_log_default_layout;
- log_cat_init_mutex = new std::recursive_mutex();
-}
-
static void xbt_log_help();
static void xbt_log_help_categories();
void xbt_log_postexit(void)
{
XBT_VERB("Exiting log");
- delete log_cat_init_mutex;
log_cat_exit(&_XBT_LOGV(XBT_LOG_ROOT_CAT));
}
if (category->initialized)
return priority >= category->threshold;
- if (log_cat_init_mutex != nullptr)
- log_cat_init_mutex->lock();
+ static std::recursive_mutex log_cat_init_mutex;
+ log_cat_init_mutex.lock();
XBT_DEBUG("Initializing category '%s' (firstChild=%s, nextSibling=%s)", category->name,
(category->firstChild ? category->firstChild->name : "none"),
if (category == &_XBT_LOGV(XBT_LOG_ROOT_CAT)) {
category->threshold = xbt_log_priority_info;
- category->appender = xbt_log_default_appender;
- category->layout = xbt_log_default_layout;
+ category->appender = xbt_log_appender_stream(stderr);
+ category->layout = xbt_log_layout_simple_new(nullptr);
} else {
if (not category->parent)
category->parent = &_XBT_LOGV(XBT_LOG_ROOT_CAT);
}
category->initialized = 1;
- if (log_cat_init_mutex != nullptr)
- log_cat_init_mutex->unlock();
+ log_cat_init_mutex.unlock();
return priority >= category->threshold;
}
static void xbt_preinit()
{
- xbt_log_preinit();
xbt_dict_preinit();
atexit(xbt_postexit);
}
XBT_INFO("Parmap benchmark with %d workers (modes = %#x)...", nthreads, modes);
XBT_INFO("%s", "");
- simgrid::kernel::context::set_nthreads(nthreads);
+ simgrid::kernel::context::Context::set_nthreads(nthreads);
XBT_INFO("Benchmark for parmap create+apply+destroy (small comp):");
bench_all_modes(nthreads, timeout, modes, true, &fun_small_comp);
int status = 0;
xbt_log_control_set("parmap_test.fmt:[%c/%p]%e%m%n");
simgrid::s4u::Engine e(&argc, argv);
- simgrid::kernel::context::set_nthreads(16); // dummy value > 1
+ simgrid::kernel::context::Context::set_nthreads(16); // dummy value > 1
XBT_INFO("Basic testing posix");
status += test_parmap_basic(XBT_PARMAP_POSIX);
set(SIMGRID_SRC
src/simgrid/Exception.cpp
+ src/simgrid/module.cpp
+ src/simgrid/module.hpp
src/simgrid/sg_config.cpp
src/simgrid/sg_version.cpp
src/simgrid/util.hpp