/** Config Globals */
XBT_PUBLIC_DATA int _sg_cfg_init_status;
-XBT_PUBLIC_DATA bool _sg_cfg_exit_asap;
XBT_PUBLIC void sg_config_init(int* argc, char** argv);
XBT_PUBLIC void sg_config_finalize();
{
xbt_assert(sd_global == nullptr, "SD_init() already called");
- sd_global = new simgrid::sd::Global();
-
surf_init(argc, argv);
+ sd_global = new simgrid::sd::Global();
+
simgrid::config::set_default<std::string>("host/model", "ptask_L07");
if (simgrid::config::get_value<bool>("clean-atexit"))
atexit(SD_exit);
- if (_sg_cfg_exit_asap) {
- exit(0);
- }
}
/** @brief set a configuration variable
*/
int _sg_cfg_init_status = 0;
-/* instruct the upper layer (simix or simdag) to exit as soon as possible */
-bool _sg_cfg_exit_asap = false;
-
-#define sg_cfg_exit_early() \
- do { \
- _sg_cfg_exit_asap = true; \
- return; \
- } while (0)
-
/* Parse the command line, looking for options */
static void sg_config_cmd_line(int *argc, char **argv)
{
*argc = j;
}
if (shall_exit)
- sg_cfg_exit_early();
+ exit(0);
}
/* callback of the plugin variable */
if (value == "help") {
model_help("plugin", surf_plugin_description);
- sg_cfg_exit_early();
+ exit(0);
}
int plugin_id = find_model_description(surf_plugin_description, value);
if (value == "help") {
model_help("host", surf_host_model_description);
- sg_cfg_exit_early();
+ exit(0);
}
/* Make sure that the model exists */
if (value == "help") {
model_help("CPU", surf_cpu_model_description);
- sg_cfg_exit_early();
+ exit(0);
}
/* New Module missing */
if (value == "help") {
model_help("optimization", surf_optimization_mode_description);
- sg_cfg_exit_early();
+ exit(0);
}
/* New Module missing */
if (value == "help") {
model_help("storage", surf_storage_model_description);
- sg_cfg_exit_early();
+ exit(0);
}
find_model_description(surf_storage_model_description, value);
if (value == "help") {
model_help("network", surf_network_model_description);
- sg_cfg_exit_early();
+ exit(0);
}
/* New Module missing */
void sg_config_finalize()
{
- if (not _sg_cfg_init_status)
- return; /* Not initialized yet. Nothing to do */
-
simgrid::config::finalize();
_sg_cfg_init_status = 0;
}
#endif
if (simix_global == nullptr) {
+ surf_init(argc, argv); /* Initialize SURF structures */
+
simix_global.reset(new simgrid::simix::Global());
simix_global->maestro_process = nullptr;
-
- surf_init(argc, argv); /* Initialize SURF structures */
SIMIX_context_mod_init();
// Either create a new context with maestro or create
if (simgrid::config::get_value<bool>("clean-atexit"))
atexit(SIMIX_clean);
-
- if (_sg_cfg_exit_asap)
- exit(0);
}
int smx_cleaned = 0;
extern std::map<std::string, simgrid::kernel::resource::StorageType*> storage_types;
s_surf_model_description_t* surf_plugin_description = nullptr;
+static void XBT_ATTRIB_DESTRUCTOR(800) simgrid_free_plugin_description()
+{
+ xbt_free(surf_plugin_description);
+}
+
XBT_PUBLIC void simgrid_add_plugin_description(const char* name, const char* description, void_f_void_t init_fun)
{
static int plugin_amount = 0;
for (auto const& model : all_existing_models)
delete model;
- xbt_free(surf_plugin_description);
-
tmgr_finalize();
sg_platf_exit();
XBT_PUBLIC int find_model_description(s_surf_model_description_t* table, const std::string& name);
XBT_PUBLIC void model_help(const char* category, s_surf_model_description_t* table);
-#define SIMGRID_REGISTER_PLUGIN(id, desc, init) \
- void simgrid_##id##_plugin_register(); \
- void XBT_ATTRIB_CONSTRUCTOR(800) simgrid_##id##_plugin_register() { \
- simgrid_add_plugin_description(#id, desc, init); \
+#define SIMGRID_REGISTER_PLUGIN(id, desc, init) \
+ static void XBT_ATTRIB_CONSTRUCTOR(800) simgrid_##id##_plugin_register() \
+ { \
+ simgrid_add_plugin_description(#id, desc, init); \
}
XBT_PUBLIC void simgrid_add_plugin_description(const char* name, const char* description, void_f_void_t init_fun);