X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/e2f13c6eb4d0c1b07e1b32a75016431dd75a68d2..237fd22b56db7d1c67360c37559ce3aab16a002d:/src/simix/smx_global.cpp diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index 5831192050..5e14abbee1 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -29,8 +29,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_kernel, simix, "Logging specific to SIMIX std::unique_ptr simix_global; -void (*SMPI_switch_data_segment)(simgrid::s4u::ActorPtr) = nullptr; - namespace simgrid { namespace simix { config::Flag cfg_verbose_exit{"debug/verbose-exit", "Display the actor status at exit", true}; @@ -75,7 +73,7 @@ static void segvhandler(int signum, siginfo_t* siginfo, void* /*context*/) "Access violation or Bus error detected.\n" "This probably comes from a programming error in your code, or from a stack\n" "overflow. If you are certain of your code, try increasing the stack size\n" - " --cfg=contexts/stack-size=XXX (current size is %u KiB).\n" + " --cfg=contexts/stack-size:XXX (current size is %u KiB).\n" "\n" "If it does not help, this may have one of the following causes:\n" "a bug in SimGrid, a bug in the OS or a bug in a third-party libraries.\n" @@ -140,14 +138,6 @@ static void install_segvhandler() #endif /* _WIN32 */ -/********************************* SIMIX **************************************/ -namespace simgrid { -namespace simix { - - -} // namespace simix -} // namespace simgrid - static simgrid::kernel::actor::ActorCode maestro_code; void SIMIX_set_maestro(void (*code)(void*), void* data) { @@ -174,7 +164,6 @@ void SIMIX_global_init(int* argc, char** argv) surf_init(argc, argv); /* Initialize SURF structures */ - simix_global->maestro_ = nullptr; SIMIX_context_mod_init(); // Either create a new context with maestro or create @@ -192,61 +181,7 @@ void SIMIX_global_init(int* argc, char** argv) simgrid::s4u::Engine::on_platform_created.connect(surf_presolve); if (simgrid::config::get_value("debug/clean-atexit")) - atexit(SIMIX_clean); -} - -/** - * @ingroup SIMIX_API - * @brief Clean the SIMIX simulation - * - * This functions remove the memory used by SIMIX - */ -void SIMIX_clean() -{ - static bool smx_cleaned = false; - if (smx_cleaned) - return; // to avoid double cleaning by java and C - - smx_cleaned = true; - XBT_DEBUG("SIMIX_clean called. Simulation's over."); - auto* engine = simgrid::kernel::EngineImpl::get_instance(); - if (engine->has_actors_to_run() && SIMIX_get_clock() <= 0.0) { - XBT_CRITICAL(" "); - XBT_CRITICAL("The time is still 0, and you still have processes ready to run."); - XBT_CRITICAL("It seems that you forgot to run the simulation that you setup."); - xbt_die("Bailing out to avoid that stop-before-start madness. Please fix your code."); - } - -#if HAVE_SMPI - if (not engine->get_actor_list().empty()) { - if (smpi_process()->initialized()) { - xbt_die("Process exited without calling MPI_Finalize - Killing simulation"); - } else { - XBT_WARN("Process called exit when leaving - Skipping cleanups"); - return; - } - } -#endif - - /* Kill all processes (but maestro) */ - simix_global->maestro_->kill_all(); - engine->run_all_actors(); - engine->empty_trash(); - - /* Exit the SIMIX network module */ - SIMIX_mailbox_exit(); - - - /* Let's free maestro now */ - delete simix_global->maestro_; - simix_global->maestro_ = nullptr; - - /* Finish context module and SURF */ - SIMIX_context_mod_exit(); - - surf_exit(); - - simix_global = nullptr; + atexit(simgrid::kernel::EngineImpl::shutdown); } /** @@ -255,13 +190,9 @@ void SIMIX_clean() * * @return Return the clock. */ -double SIMIX_get_clock() +double SIMIX_get_clock() // XBT_ATTRIB_DEPRECATED_v332 { - if (MC_is_active() || MC_record_replay_is_active()) { - return MC_process_clock_get(SIMIX_process_self()); - } else { - return surf_get_clock(); - } + return simgrid::s4u::Engine::get_clock(); } void SIMIX_run() // XBT_ATTRIB_DEPRECATED_v332 @@ -269,37 +200,10 @@ void SIMIX_run() // XBT_ATTRIB_DEPRECATED_v332 simgrid::kernel::EngineImpl::get_instance()->run(); } -double SIMIX_timer_next() // XBT_ATTRIB_DEPRECATED_v329 -{ - return simgrid::kernel::timer::Timer::next(); -} - -smx_timer_t SIMIX_timer_set(double date, void (*callback)(void*), void* arg) // XBT_ATTRIB_DEPRECATED_v329 -{ - return simgrid::kernel::timer::Timer::set(date, std::bind(callback, arg)); -} - -/** @brief cancels a timer that was added earlier */ -void SIMIX_timer_remove(smx_timer_t timer) // XBT_ATTRIB_DEPRECATED_v329 -{ - timer->remove(); -} - -/** @brief Returns the date at which the timer will trigger (or 0 if nullptr timer) */ -double SIMIX_timer_get_date(smx_timer_t timer) // XBT_ATTRIB_DEPRECATED_v329 -{ - return timer ? timer->get_date() : 0.0; -} - -void SIMIX_display_process_status() // XBT_ATTRIB_DEPRECATED_v329 -{ - simgrid::kernel::EngineImpl::get_instance()->display_all_actor_status(); -} - int SIMIX_is_maestro() { if (simix_global == nullptr) // SimDag return true; const simgrid::kernel::actor::ActorImpl* self = SIMIX_process_self(); - return self == nullptr || self == simix_global->maestro_; + return self == nullptr || simix_global->is_maestro(self); }