From e22da6010c6499813ff88c76041cf499ffbf2b67 Mon Sep 17 00:00:00 2001 From: Bruno Donassolo Date: Tue, 9 Mar 2021 14:31:56 +0100 Subject: [PATCH] Move globals to EngineImpl A step forwards encapsulation. Still not good for ptask model and its particularities. --- doc/doxygen/inside_extending.doc | 1 - doc/doxygen/module-surf.doc | 1 - include/simgrid/kernel/resource/Model.hpp | 11 ---- .../simgrid/kernel/routing/NetZoneImpl.hpp | 1 - src/kernel/EngineImpl.cpp | 24 +++++++++ src/kernel/EngineImpl.hpp | 35 ++++++++++++ src/kernel/routing/NetZoneImpl.cpp | 18 +++---- src/plugins/vm/VirtualMachineImpl.cpp | 10 ++-- src/plugins/vm/s4u_VirtualMachine.cpp | 1 - src/simdag/sd_global.cpp | 53 ++++++++++--------- src/simix/smx_global.cpp | 30 +++++------ src/surf/cpu_cas01.cpp | 17 +++--- src/surf/cpu_interface.cpp | 1 - src/surf/cpu_ti.cpp | 16 +++--- src/surf/disk_s19.cpp | 10 ++-- src/surf/host_clm03.cpp | 17 +++--- src/surf/network_cm02.cpp | 18 +++---- src/surf/network_constant.cpp | 10 ++-- src/surf/network_ib.cpp | 11 ++-- src/surf/network_ns3.cpp | 11 ++-- src/surf/network_smpi.cpp | 12 ++--- src/surf/ptask_L07.cpp | 18 ++++--- src/surf/ptask_L07.hpp | 4 +- src/surf/sg_platf.cpp | 5 +- src/surf/surf_c_bindings.cpp | 21 ++++---- src/surf/surf_interface.cpp | 7 --- teshsuite/surf/surf_usage2/surf_usage2.cpp | 3 +- 27 files changed, 196 insertions(+), 170 deletions(-) diff --git a/doc/doxygen/inside_extending.doc b/doc/doxygen/inside_extending.doc index a8f97d8553..fefe0a21ac 100644 --- a/doc/doxygen/inside_extending.doc +++ b/doc/doxygen/inside_extending.doc @@ -36,7 +36,6 @@ For instance, if you want to add a new cup model called `Plop`, create two files cpu_plop.hpp and cpu_plop_cpp which contains classes CpuPlopModel, CpuPlop and CpuPlopAction implementing respectively the interfaces CpuModel, Cpu and CpuAction. You also need to define an initializing function like this: -FIXME[donassolo]: update doc ~~~~ void surf_cpu_model_init_plop() diff --git a/doc/doxygen/module-surf.doc b/doc/doxygen/module-surf.doc index fdb4e47050..9dc285ede3 100644 --- a/doc/doxygen/module-surf.doc +++ b/doc/doxygen/module-surf.doc @@ -43,7 +43,6 @@ - the CPU resource, - the timer resource. - FIXME[donassolo]: fix doc The implementation of these resources depends on the platform models you choose. You can select your model by calling #surf_host_model_init_current_default() (which will give you a diff --git a/include/simgrid/kernel/resource/Model.hpp b/include/simgrid/kernel/resource/Model.hpp index fac93ac26b..72617af98f 100644 --- a/include/simgrid/kernel/resource/Model.hpp +++ b/include/simgrid/kernel/resource/Model.hpp @@ -151,15 +151,4 @@ private: } // namespace kernel } // namespace simgrid -/** @ingroup SURF_models - * @brief List of initialized models - */ -XBT_PUBLIC_DATA std::vector all_existing_models; -/** @ingroup SURF_models - * @brief Map of initialized models by category - */ -XBT_PUBLIC_DATA -std::unordered_map> - models_by_type; - #endif diff --git a/include/simgrid/kernel/routing/NetZoneImpl.hpp b/include/simgrid/kernel/routing/NetZoneImpl.hpp index ffbf67b93c..b550fc4eb3 100644 --- a/include/simgrid/kernel/routing/NetZoneImpl.hpp +++ b/include/simgrid/kernel/routing/NetZoneImpl.hpp @@ -115,7 +115,6 @@ public: /** @brief Retrieves the disk model associated to this NetZone */ resource::DiskModel* get_disk_model() const { return disk_model_; } /** @brief Retrieves the host model associated to this NetZone */ - // FIXME[donassolo]: why HostModel isn't in resource namespace? simgrid::surf::HostModel* get_host_model() const { return host_model_; } const s4u::NetZone* get_iface() const { return &piface_; } diff --git a/src/kernel/EngineImpl.cpp b/src/kernel/EngineImpl.cpp index 1956f49336..e45b5e0273 100644 --- a/src/kernel/EngineImpl.cpp +++ b/src/kernel/EngineImpl.cpp @@ -53,5 +53,29 @@ void EngineImpl::register_default(const actor::ActorCodeFactory& code) default_function = code; } +void EngineImpl::add_model_ptask(simgrid::kernel::resource::Model::Type type, simgrid::kernel::resource::Model* model, + bool is_default) +{ + if (is_default) + models_by_type_[type].insert(models_by_type_[type].begin(), model); + else + models_by_type_[type].push_back(model); +} + +void EngineImpl::add_model(simgrid::kernel::resource::Model::Type type, + std::unique_ptr model, bool is_default) +{ + add_model_ptask(type, model.get(), is_default); + models_.push_back(std::move(model)); +} + +simgrid::kernel::resource::Model* EngineImpl::get_default_model(simgrid::kernel::resource::Model::Type type) +{ + if (models_by_type_[type].size() > 0) + return models_by_type_[type][0]; + else + return nullptr; +} + } // namespace kernel } // namespace simgrid diff --git a/src/kernel/EngineImpl.hpp b/src/kernel/EngineImpl.hpp index 6a3ee06cec..4599d925fc 100644 --- a/src/kernel/EngineImpl.hpp +++ b/src/kernel/EngineImpl.hpp @@ -6,6 +6,7 @@ #ifndef SIMGRID_KERNEL_ENGINEIMPL_HPP #define SIMGRID_KERNEL_ENGINEIMPL_HPP +#include #include #include #include @@ -23,6 +24,9 @@ class EngineImpl { std::unordered_map netpoints_; std::unordered_map registered_functions; // Maps function names to actor code actor::ActorCodeFactory default_function; // Function to use as a fallback when the provided name matches nothing + std::vector> models_; + std::unordered_map> + models_by_type_; friend s4u::Engine; @@ -37,6 +41,37 @@ public: void register_function(const std::string& name, const actor::ActorCodeFactory& code); void register_default(const actor::ActorCodeFactory& code); + /** + * @brief Add a model to engine list + * + * @param type Model type (network, disk, etc) + * @param model Pointer to model + * @param is_default Is this the default model for this type of resource in this exp + */ + void add_model(simgrid::kernel::resource::Model::Type type, std::unique_ptr model, + bool is_default = false); + /** + * @brief Add a model (specific for ptask) + * + * Ptask is special. The CPU and NETWORK models need to be in the managed + * resources by surf_solve (model_by_type) but cannot be in the list of + * all models (old all_existing_models global variable) + * + * This methods does this job while we cannot handle ptask as the remaining models + */ + void add_model_ptask(simgrid::kernel::resource::Model::Type type, simgrid::kernel::resource::Model* model, + bool is_default); + /** @brief Get current default model for a resource type */ + simgrid::kernel::resource::Model* get_default_model(simgrid::kernel::resource::Model::Type type); + + /** @brief Get list of models created for a resource type */ + const std::vector& get_model_list(simgrid::kernel::resource::Model::Type type) + { + return models_by_type_[type]; + } + /** @brief Get list of all models managed by this engine */ + const std::vector>& get_all_models() { return models_; } + routing::NetZoneImpl* netzone_root_ = nullptr; static EngineImpl* get_instance() { return simgrid::s4u::Engine::get_instance()->pimpl; } actor::ActorCodeFactory get_function(const std::string& name) diff --git a/src/kernel/routing/NetZoneImpl.cpp b/src/kernel/routing/NetZoneImpl.cpp index 11f4c0d255..6ae49f17b4 100644 --- a/src/kernel/routing/NetZoneImpl.cpp +++ b/src/kernel/routing/NetZoneImpl.cpp @@ -7,6 +7,7 @@ #include "simgrid/kernel/routing/NetPoint.hpp" #include "simgrid/s4u/Engine.hpp" #include "simgrid/s4u/Host.hpp" +#include "src/kernel/EngineImpl.hpp" #include "src/kernel/resource/DiskImpl.hpp" #include "src/surf/HostImpl.hpp" #include "src/surf/cpu_interface.hpp" @@ -26,18 +27,15 @@ NetZoneImpl::NetZoneImpl(NetZoneImpl* father, const std::string& name, resource: xbt_assert(nullptr == s4u::Engine::get_instance()->netpoint_by_name_or_null(get_name()), "Refusing to create a second NetZone called '%s'.", get_cname()); - netpoint_ = new NetPoint(name_, NetPoint::Type::NetZone, father_); - if (models_by_type[simgrid::kernel::resource::Model::Type::CPU_VM].size() > 0) { - cpu_model_vm_ = static_cast( - models_by_type[simgrid::kernel::resource::Model::Type::CPU_VM][0]); - } + netpoint_ = new NetPoint(name_, NetPoint::Type::NetZone, father_); + cpu_model_vm_ = static_cast( + simgrid::kernel::EngineImpl::get_instance()->get_default_model(simgrid::kernel::resource::Model::Type::CPU_VM)); cpu_model_pm_ = static_cast( - models_by_type[simgrid::kernel::resource::Model::Type::CPU_PM][0]); + simgrid::kernel::EngineImpl::get_instance()->get_default_model(simgrid::kernel::resource::Model::Type::CPU_PM)); disk_model_ = static_cast( - models_by_type[simgrid::kernel::resource::Model::Type::DISK][0]); - // FIXME[donassolo]: we probably need some validation of the coherence among - // the different models in each netZone - host_model_ = static_cast(models_by_type[simgrid::kernel::resource::Model::Type::HOST][0]); + simgrid::kernel::EngineImpl::get_instance()->get_default_model(simgrid::kernel::resource::Model::Type::DISK)); + host_model_ = static_cast( + simgrid::kernel::EngineImpl::get_instance()->get_default_model(simgrid::kernel::resource::Model::Type::HOST)); XBT_DEBUG("NetZone '%s' created with the id '%u'", get_cname(), netpoint_->id()); } diff --git a/src/plugins/vm/VirtualMachineImpl.cpp b/src/plugins/vm/VirtualMachineImpl.cpp index 4c7d7b10da..371bff41de 100644 --- a/src/plugins/vm/VirtualMachineImpl.cpp +++ b/src/plugins/vm/VirtualMachineImpl.cpp @@ -7,16 +7,16 @@ #include "simgrid/Exception.hpp" #include "simgrid/s4u/Exec.hpp" #include "src/include/surf/surf.hpp" +#include "src/kernel/EngineImpl.hpp" #include "src/kernel/activity/ExecImpl.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(res_vm, ker_resource, "Virtual Machines, containing actors and mobile accross hosts"); void surf_vm_model_init_HL13() { - /* FIXME[donassolo]: this smells bad, but works - * (the constructor saves its pointer in all_existing_models and models_by_type :O). - * We need a manager for these models */ - new simgrid::vm::VMModel(); + auto vm_model = std::make_unique(); + simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::VM, + std::move(vm_model), true); } namespace simgrid { @@ -103,8 +103,6 @@ static void remove_active_activity(kernel::activity::ActivityImpl const& act) VMModel::VMModel() { - all_existing_models.push_back(this); - models_by_type[simgrid::kernel::resource::Model::Type::VM].push_back(this); s4u::Host::on_state_change.connect(host_state_change); s4u::Exec::on_start.connect(add_active_exec); s4u::Exec::on_completion.connect(remove_active_exec); diff --git a/src/plugins/vm/s4u_VirtualMachine.cpp b/src/plugins/vm/s4u_VirtualMachine.cpp index 36470645ba..3b412c8890 100644 --- a/src/plugins/vm/s4u_VirtualMachine.cpp +++ b/src/plugins/vm/s4u_VirtualMachine.cpp @@ -42,7 +42,6 @@ VirtualMachine::VirtualMachine(const std::string& name, s4u::Host* physical_host for (int i = 0; i < physical_host->get_pstate_count(); i++) speeds.push_back(physical_host->get_pstate_speed(i)); - // FIXME[donassolo]: shoud this be done at the Impl class??? physical_host->get_netpoint()->get_englobing_zone()->get_cpu_vm_model()->create_cpu(this, speeds)->set_core_count(core_amount)->seal(); if (physical_host->get_pstate() != 0) set_pstate(physical_host->get_pstate()); diff --git a/src/simdag/sd_global.cpp b/src/simdag/sd_global.cpp index 5a9e8224e6..0670d25f82 100644 --- a/src/simdag/sd_global.cpp +++ b/src/simdag/sd_global.cpp @@ -8,6 +8,7 @@ #include "simgrid/kernel/resource/Model.hpp" #include "simgrid/s4u/Engine.hpp" #include "simgrid/sg_config.hpp" +#include "src/kernel/EngineImpl.hpp" #include "src/surf/surf_interface.hpp" #include @@ -15,12 +16,13 @@ XBT_LOG_NEW_CATEGORY(sd, "Logging specific to SimDag"); XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sd_kernel, sd, "Logging specific to SimDag (kernel)"); -simgrid::sd::Global *sd_global = nullptr; +simgrid::sd::Global* sd_global = nullptr; -namespace simgrid{ -namespace sd{ +namespace simgrid { +namespace sd { -std::set* simulate(double how_long){ +std::set* simulate(double how_long) +{ XBT_VERB("Run simulation for %f seconds", how_long); sd_global->watch_point_reached = false; @@ -31,19 +33,19 @@ std::set* simulate(double how_long){ SD_task_run(*(sd_global->runnable_tasks.begin())); double elapsed_time = 0.0; - double total_time = 0.0; + double total_time = 0.0; /* main loop */ while (elapsed_time >= 0 && (how_long < 0 || 0.00001 < (how_long - total_time)) && not sd_global->watch_point_reached) { XBT_DEBUG("Total time: %f", total_time); - elapsed_time = surf_solve(how_long > 0 ? surf_get_clock() + how_long - total_time: -1.0); + elapsed_time = surf_solve(how_long > 0 ? surf_get_clock() + how_long - total_time : -1.0); XBT_DEBUG("surf_solve() returns %f", elapsed_time); if (elapsed_time > 0.0) total_time += elapsed_time; /* let's see which tasks are done */ - for (auto const& model : all_existing_models) { + for (auto const& model : simgrid::kernel::EngineImpl::get_instance()->get_all_models()) { const simgrid::kernel::resource::Action* action = model->extract_done_action(); while (action != nullptr && action->get_data() != nullptr) { auto* task = static_cast(action->get_data()); @@ -58,7 +60,7 @@ std::set* simulate(double how_long){ succ->predecessors->erase(task); succ->inputs->erase(task); XBT_DEBUG("Release dependency on %s: %zu remain(s). Becomes schedulable if %zu=0", SD_task_get_name(succ), - succ->predecessors->size()+succ->inputs->size(), succ->predecessors->size()); + succ->predecessors->size() + succ->inputs->size(), succ->predecessors->size()); if (SD_task_get_state(succ) == SD_NOT_SCHEDULED && succ->predecessors->empty()) SD_task_set_state(succ, SD_SCHEDULABLE); @@ -75,14 +77,14 @@ std::set* simulate(double how_long){ output->start_time = task->finish_time; output->predecessors->erase(task); if (SD_task_get_state(output) == SD_SCHEDULED) - SD_task_set_state(output, SD_RUNNABLE); + SD_task_set_state(output, SD_RUNNABLE); else - SD_task_set_state(output, SD_SCHEDULABLE); + SD_task_set_state(output, SD_SCHEDULABLE); SD_task_t comm_dst = *(output->successors->begin()); - if (SD_task_get_state(comm_dst) == SD_NOT_SCHEDULED && comm_dst->predecessors->empty()){ - XBT_DEBUG("%s is a transfer, %s may be ready now if %zu=0", - SD_task_get_name(output), SD_task_get_name(comm_dst), comm_dst->predecessors->size()); + if (SD_task_get_state(comm_dst) == SD_NOT_SCHEDULED && comm_dst->predecessors->empty()) { + XBT_DEBUG("%s is a transfer, %s may be ready now if %zu=0", SD_task_get_name(output), + SD_task_get_name(comm_dst), comm_dst->predecessors->size()); SD_task_set_state(comm_dst, SD_SCHEDULABLE); } if (SD_task_get_state(output) == SD_RUNNABLE && not sd_global->watch_point_reached) @@ -110,21 +112,22 @@ std::set* simulate(double how_long){ XBT_WARN("%s is in %s state", SD_task_get_name(t), __get_state_name(SD_task_get_state(t))); } - XBT_DEBUG("elapsed_time = %f, total_time = %f, watch_point_reached = %d", - elapsed_time, total_time, sd_global->watch_point_reached); + XBT_DEBUG("elapsed_time = %f, total_time = %f, watch_point_reached = %d", elapsed_time, total_time, + sd_global->watch_point_reached); XBT_DEBUG("current time = %f", surf_get_clock()); return &sd_global->return_set; } -} -} +} // namespace sd +} // namespace simgrid /** * @brief helper for pretty printing of task state * @param state the state of a task * @return the equivalent as a readable string */ -const char *__get_state_name(e_SD_task_state_t state){ +const char* __get_state_name(e_SD_task_state_t state) +{ static constexpr std::array state_names{ {"not scheduled", "schedulable", "scheduled", "runnable", "running", "done", "failed"}}; return state_names.at(static_cast(log2(static_cast(state)))); @@ -139,7 +142,7 @@ const char *__get_state_name(e_SD_task_state_t state){ * @param argv argument list * @see SD_create_environment(), SD_exit() */ -void SD_init_nocheck(int *argc, char **argv) +void SD_init_nocheck(int* argc, char** argv) { xbt_assert(sd_global == nullptr, "SD_init() already called"); @@ -159,8 +162,9 @@ void SD_init_nocheck(int *argc, char **argv) * * Example: SD_config("host/model","default") */ -void SD_config(const char *key, const char *value){ - xbt_assert(sd_global,"ERROR: Please call SD_init() before using SD_config()"); +void SD_config(const char* key, const char* value) +{ + xbt_assert(sd_global, "ERROR: Please call SD_init() before using SD_config()"); simgrid::config::set_as_string(key, value); } @@ -181,7 +185,7 @@ void SD_config(const char *key, const char *value){ * * @include small_platform.xml */ -void SD_create_environment(const char *platform_file) +void SD_create_environment(const char* platform_file) { simgrid::s4u::Engine::get_instance()->load_platform(platform_file); @@ -190,7 +194,7 @@ void SD_create_environment(const char *platform_file) jedule_sd_init(); #endif XBT_VERB("Starting simulation..."); - surf_presolve(); /* Takes traces into account */ + surf_presolve(); /* Takes traces into account */ } /** @@ -220,7 +224,8 @@ void SD_simulate_with_update(double how_long, xbt_dynar_t changed_tasks_dynar) } /** @brief Returns the current clock, in seconds */ -double SD_get_clock() { +double SD_get_clock() +{ return surf_get_clock(); } diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index 3d2ec1d47a..50fb970def 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -9,6 +9,7 @@ #include "src/smpi/include/smpi_actor.hpp" #include "simgrid/sg_config.hpp" +#include "src/kernel/EngineImpl.hpp" #include "src/kernel/activity/ExecImpl.hpp" #include "src/kernel/activity/IoImpl.hpp" #include "src/kernel/activity/MailboxImpl.hpp" @@ -36,9 +37,7 @@ 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}; +config::Flag cfg_verbose_exit{"debug/verbose-exit", "Display the actor status at exit", true}; } // namespace simix } // namespace simgrid @@ -48,8 +47,7 @@ XBT_ATTRIB_NORETURN static void inthandler(int) XBT_INFO("CTRL-C pressed. The current status will be displayed before exit (disable that behavior with option " "'debug/verbose-exit')."); simix_global->display_all_actor_status(); - } - else { + } else { XBT_INFO("CTRL-C pressed, exiting. Hiding the current process status since 'debug/verbose-exit' is set to false."); } exit(1); @@ -73,7 +71,7 @@ static void segvhandler(int signum, siginfo_t* siginfo, void* /*context*/) "Minimal Working Example (MWE) reproducing your problem and a full backtrace\n" "of the fault captured with gdb or valgrind.\n", smx_context_stack_size / 1024); - } else if (siginfo->si_signo == SIGSEGV) { + } else if (siginfo->si_signo == SIGSEGV) { fprintf(stderr, "Segmentation fault.\n"); #if HAVE_SMPI if (smpi_enabled() && smpi_cfg_privatization() == SmpiPrivStrategies::NONE) { @@ -109,7 +107,7 @@ static void install_segvhandler() struct sigaction action; struct sigaction old_action; action.sa_sigaction = &segvhandler; - action.sa_flags = SA_ONSTACK | SA_RESETHAND | SA_SIGINFO; + action.sa_flags = SA_ONSTACK | SA_RESETHAND | SA_SIGINFO; sigemptyset(&action.sa_mask); /* Linux tend to raise only SIGSEGV where other systems also raise SIGBUS on severe error */ @@ -198,7 +196,7 @@ void Global::run_all_actors() /** Wake up all actors waiting for a Surf action to finish */ void Global::wake_all_waiting_actors() const { - for (auto const& model : all_existing_models) { + for (auto const& model : simgrid::kernel::EngineImpl::get_instance()->get_all_models()) { kernel::resource::Action* action; XBT_DEBUG("Handling the failed actions (if any)"); @@ -255,8 +253,7 @@ void Global::display_all_actor_status() const } config::Flag cfg_breakpoint{"debug/breakpoint", - "When non-negative, raise a SIGTRAP after given (simulated) time", - -1.0}; + "When non-negative, raise a SIGTRAP after given (simulated) time", -1.0}; } // namespace simix } // namespace simgrid @@ -264,7 +261,8 @@ static simgrid::kernel::actor::ActorCode maestro_code; void SIMIX_set_maestro(void (*code)(void*), void* data) { #ifdef _WIN32 - XBT_INFO("WARNING, SIMIX_set_maestro is believed to not work on windows. Please help us investigating this issue if you need that feature"); + XBT_INFO("WARNING, SIMIX_set_maestro is believed to not work on windows. Please help us investigating this issue if " + "you need that feature"); #endif maestro_code = std::bind(code, data); } @@ -273,7 +271,7 @@ void SIMIX_set_maestro(void (*code)(void*), void* data) * @ingroup SIMIX_API * @brief Initialize SIMIX internal data. */ -void SIMIX_global_init(int *argc, char **argv) +void SIMIX_global_init(int* argc, char** argv) { #if SIMGRID_HAVE_MC // The communication initialization is done ASAP. @@ -330,9 +328,9 @@ void SIMIX_clean() #if HAVE_SMPI if (not simix_global->process_list.empty()) { - if(smpi_process()->initialized()){ + if (smpi_process()->initialized()) { xbt_die("Process exited without calling MPI_Finalize - Killing simulation"); - }else{ + } else { XBT_WARN("Process called exit when leaving - Skipping cleanups"); return; } @@ -382,9 +380,9 @@ void SIMIX_clean() */ double SIMIX_get_clock() { - if(MC_is_active() || MC_record_replay_is_active()){ + if (MC_is_active() || MC_record_replay_is_active()) { return MC_process_clock_get(SIMIX_process_self()); - }else{ + } else { return surf_get_clock(); } } diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index 0d56ffe8ee..56e70a743e 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -5,6 +5,7 @@ #include "cpu_cas01.hpp" #include "simgrid/sg_config.hpp" +#include "src/kernel/EngineImpl.hpp" #include "src/kernel/resource/profile/Event.hpp" #include "src/surf/cpu_ti.hpp" #include "src/surf/surf_interface.hpp" @@ -47,10 +48,12 @@ void surf_cpu_model_init_Cas01() else algo = simgrid::kernel::resource::Model::UpdateAlgo::FULL; - auto cpu_model_pm = new simgrid::kernel::resource::CpuCas01Model(algo); - models_by_type[simgrid::kernel::resource::Model::Type::CPU_PM].push_back(cpu_model_pm); - auto cpu_model_vm = new simgrid::kernel::resource::CpuCas01Model(algo); - models_by_type[simgrid::kernel::resource::Model::Type::CPU_VM].push_back(cpu_model_vm); + auto cpu_model_pm = std::make_unique(algo); + simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::CPU_PM, + std::move(cpu_model_pm), true); + auto cpu_model_vm = std::make_unique(algo); + simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::CPU_VM, + std::move(cpu_model_vm), true); } namespace simgrid { @@ -59,8 +62,6 @@ namespace resource { CpuCas01Model::CpuCas01Model(Model::UpdateAlgo algo) : CpuModel(algo) { - all_existing_models.push_back(this); - bool select = config::get_value("cpu/maxmin-selective-update"); if (is_update_lazy()) { @@ -72,9 +73,7 @@ CpuCas01Model::CpuCas01Model(Model::UpdateAlgo algo) : CpuModel(algo) set_maxmin_system(new lmm::System(select)); } -CpuCas01Model::~CpuCas01Model() -{ -} +CpuCas01Model::~CpuCas01Model() {} Cpu* CpuCas01Model::create_cpu(s4u::Host* host, const std::vector& speed_per_pstate) { diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index 840c9a814c..b07f84f9fa 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -54,7 +54,6 @@ Cpu::Cpu(s4u::Host* host, const std::vector& speed_per_pstate) { speed_.scale = 1; speed_.peak = speed_per_pstate_.front(); - // FIXME[donassolo]: don't set here.. everytime I take half an hour to discover where it comes host->pimpl_cpu = this; } diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index f31b334145..5c24e9a55c 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -4,6 +4,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "cpu_ti.hpp" +#include "src/kernel/EngineImpl.hpp" #include "src/kernel/resource/profile/Event.hpp" #include "src/kernel/resource/profile/Profile.hpp" #include "src/surf/surf_interface.hpp" @@ -269,20 +270,19 @@ int CpuTiProfile::binary_search(const std::vector& array, double a) void CpuTiModel::create_pm_vm_models() { - auto cpu_model_pm = new CpuTiModel(); - models_by_type[simgrid::kernel::resource::Model::Type::CPU_PM].push_back(cpu_model_pm); - auto cpu_model_vm = new CpuTiModel(); - models_by_type[simgrid::kernel::resource::Model::Type::CPU_VM].push_back(cpu_model_vm); + auto cpu_model_pm = std::make_unique(); + simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::CPU_PM, + std::move(cpu_model_pm), true); + auto cpu_model_vm = std::make_unique(); + simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::CPU_VM, + std::move(cpu_model_vm), true); } CpuTiModel::CpuTiModel() : CpuModel(Model::UpdateAlgo::FULL) { - all_existing_models.push_back(this); } -CpuTiModel::~CpuTiModel() -{ -} +CpuTiModel::~CpuTiModel() {} Cpu* CpuTiModel::create_cpu(s4u::Host* host, const std::vector& speed_per_pstate) { diff --git a/src/surf/disk_s19.cpp b/src/surf/disk_s19.cpp index c1e4bde901..12722e7957 100644 --- a/src/surf/disk_s19.cpp +++ b/src/surf/disk_s19.cpp @@ -7,6 +7,7 @@ #include "simgrid/kernel/routing/NetPoint.hpp" #include "simgrid/s4u/Engine.hpp" #include "simgrid/s4u/Host.hpp" +#include "src/kernel/EngineImpl.hpp" #include "src/kernel/lmm/maxmin.hpp" #include "src/surf/xml/platf.hpp" #include "surf/surf.hpp" @@ -19,10 +20,9 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_disk); void surf_disk_model_init_default() { - /* FIXME[donassolo]: this smells bad, but works - * (the constructor saves its pointer in all_existing_models and models_by_type :O). - * We need a manager for these models */ - new simgrid::kernel::resource::DiskS19Model(); + auto disk_model = std::make_unique(); + simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::DISK, + std::move(disk_model), true); } namespace simgrid { @@ -31,8 +31,6 @@ namespace resource { DiskS19Model::DiskS19Model() { - all_existing_models.push_back(this); - models_by_type[simgrid::kernel::resource::Model::Type::DISK].push_back(this); } DiskImpl* DiskS19Model::create_disk(const std::string& name, double read_bandwidth, double write_bandwidth) diff --git a/src/surf/host_clm03.cpp b/src/surf/host_clm03.cpp index db3a9953d4..c9bb4c50ad 100644 --- a/src/surf/host_clm03.cpp +++ b/src/surf/host_clm03.cpp @@ -6,35 +6,32 @@ #include "src/surf/host_clm03.hpp" #include "simgrid/kernel/routing/NetPoint.hpp" #include "simgrid/sg_config.hpp" +#include "src/kernel/EngineImpl.hpp" #include "surf/surf.hpp" XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_host); void surf_host_model_init_current_default() { - /* FIXME[donassolo]: this smells bad, but works - * (the constructor saves its pointer in all_existing_models and models_by_type :O). - * We need a manager for these models */ - new simgrid::surf::HostCLM03Model(); + auto host_model = std::make_unique(); simgrid::config::set_default("network/crosstraffic", true); + simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::HOST, + std::move(host_model), true); surf_cpu_model_init_Cas01(); surf_network_model_init_LegrandVelho(); } void surf_host_model_init_compound() { - /* FIXME[donassolo]: this smells bad, but works - * (the constructor saves its pointer in all_existing_models and models_by_type :O). - * We need a manager for these models */ - new simgrid::surf::HostCLM03Model(); + auto host_model = std::make_unique(); + simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::HOST, + std::move(host_model), true); } namespace simgrid { namespace surf { HostCLM03Model::HostCLM03Model() { - all_existing_models.push_back(this); - models_by_type[simgrid::kernel::resource::Model::Type::HOST].push_back(this); } double HostCLM03Model::next_occurring_event(double now) diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index 5793cf14cc..57600aea49 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -6,6 +6,7 @@ #include "src/surf/network_cm02.hpp" #include "simgrid/s4u/Host.hpp" #include "simgrid/sg_config.hpp" +#include "src/kernel/EngineImpl.hpp" #include "src/kernel/resource/profile/Event.hpp" #include "src/surf/network_wifi.hpp" #include "src/surf/surf_interface.hpp" @@ -36,10 +37,9 @@ double sg_weight_S_parameter = 0.0; /* default value; can be set by model or fro /* } */ void surf_network_model_init_LegrandVelho() { - /* FIXME[donassolo]: this smells bad, but works - * (the constructor saves its pointer in all_existing_models and models_by_type :O). - * We need a manager for these models */ - new simgrid::kernel::resource::NetworkCm02Model(); + auto net_model = std::make_unique(); + simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::NETWORK, + std::move(net_model), true); simgrid::config::set_default("network/latency-factor", 13.01); simgrid::config::set_default("network/bandwidth-factor", 0.97); @@ -63,10 +63,9 @@ void surf_network_model_init_CM02() simgrid::config::set_default("network/bandwidth-factor", 1.0); simgrid::config::set_default("network/weight-S", 0.0); - /* FIXME[donassolo]: this smells bad, but works - * (the constructor saves its pointer in all_existing_models and models_by_type :O). - * We need a manager for these models */ - new simgrid::kernel::resource::NetworkCm02Model(); + auto net_model = std::make_unique(); + simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::NETWORK, + std::move(net_model), true); } namespace simgrid { @@ -77,9 +76,6 @@ NetworkCm02Model::NetworkCm02Model() : NetworkModel(config::get_value("network/optim") == "Full" ? Model::UpdateAlgo::FULL : Model::UpdateAlgo::LAZY) { - all_existing_models.push_back(this); - models_by_type[simgrid::kernel::resource::Model::Type::NETWORK].push_back(this); - std::string optim = config::get_value("network/optim"); bool select = config::get_value("network/maxmin-selective-update"); diff --git a/src/surf/network_constant.cpp b/src/surf/network_constant.cpp index 59e4c81690..7c879c8a06 100644 --- a/src/surf/network_constant.cpp +++ b/src/surf/network_constant.cpp @@ -4,6 +4,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "network_constant.hpp" +#include "src/kernel/EngineImpl.hpp" #include "src/surf/surf_interface.hpp" #include "surf/surf.hpp" @@ -14,10 +15,9 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_network); *********/ void surf_network_model_init_Constant() { - /* FIXME[donassolo]: this smells bad, but works - * (the constructor saves its pointer in all_existing_models and models_by_type :O). - * We need a manager for these models */ - new simgrid::kernel::resource::NetworkConstantModel(); + auto net_model = std::make_unique(); + simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::NETWORK, + std::move(net_model), true); } namespace simgrid { @@ -26,8 +26,6 @@ namespace resource { NetworkConstantModel::NetworkConstantModel() : NetworkModel(Model::UpdateAlgo::FULL) { - all_existing_models.push_back(this); - models_by_type[simgrid::kernel::resource::Model::Type::NETWORK].push_back(this); } LinkImpl* NetworkConstantModel::create_link(const std::string& name, const std::vector& /*bandwidth*/, diff --git a/src/surf/network_ib.cpp b/src/surf/network_ib.cpp index 1fda88f010..eedd4594eb 100644 --- a/src/surf/network_ib.cpp +++ b/src/surf/network_ib.cpp @@ -6,6 +6,7 @@ #include "src/surf/network_ib.hpp" #include "simgrid/kernel/routing/NetPoint.hpp" #include "simgrid/sg_config.hpp" +#include "src/kernel/EngineImpl.hpp" #include "src/surf/HostImpl.hpp" #include "src/surf/xml/platf.hpp" #include "surf/surf.hpp" @@ -68,10 +69,10 @@ static void IB_action_init_callback(simgrid::kernel::resource::NetworkAction& ac /* } */ void surf_network_model_init_IB() { - /* FIXME[donassolo]: this smells bad, but works - * (the constructor saves its pointer in all_existing_models and models_by_type :O). - * We need a manager for these models */ - new simgrid::kernel::resource::NetworkIBModel(); + auto net_model = std::make_unique(); + simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::NETWORK, + std::move(net_model), true); + simgrid::s4u::Link::on_communication_state_change.connect(IB_action_state_changed_callback); simgrid::s4u::Link::on_communicate.connect(IB_action_init_callback); simgrid::s4u::Host::on_creation.connect(IB_create_host_callback); @@ -84,8 +85,6 @@ namespace resource { NetworkIBModel::NetworkIBModel() : NetworkSmpiModel() { - /* Do not add this into all_existing_models: our ancestor already does so */ - std::string IB_factors_string = config::get_value("smpi/IB-penalty-factors"); std::vector radical_elements; boost::split(radical_elements, IB_factors_string, boost::is_any_of(";")); diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index 80ebc3bdb2..8ba3f2ea52 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -33,6 +33,7 @@ #include "simgrid/s4u/Engine.hpp" #include "simgrid/s4u/NetZone.hpp" #include "src/instr/instr_private.hpp" // TRACE_is_enabled(). FIXME: remove by subscribing tracing to the surf signals +#include "src/kernel/EngineImpl.hpp" #include "src/surf/surf_interface.hpp" #include "src/surf/xml/platf_private.hpp" #include "surf/surf.hpp" @@ -258,10 +259,9 @@ static void routeCreation_cb(bool symmetrical, simgrid::kernel::routing::NetPoin *********/ void surf_network_model_init_NS3() { - /* FIXME[donassolo]: this smells bad, but works - * (the constructor saves its pointer in all_existing_models and models_by_type :O). - * We need a manager for these models */ - new simgrid::kernel::resource::NetworkNS3Model(); + auto net_model = std::make_unique(); + simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::NETWORK, + std::move(net_model), true); } static simgrid::config::Flag @@ -293,9 +293,6 @@ NetworkNS3Model::NetworkNS3Model() : NetworkModel(Model::UpdateAlgo::FULL) xbt_assert(not sg_link_energy_is_inited(), "LinkEnergy plugin and ns-3 network models are not compatible. Are you looking for Ecofen, maybe?"); - all_existing_models.push_back(this); - models_by_type[simgrid::kernel::resource::Model::Type::NETWORK].push_back(this); - NetPointNs3::EXTENSION_ID = routing::NetPoint::extension_create(); ns3::Config::SetDefault("ns3::TcpSocket::SegmentSize", ns3::UintegerValue(1000)); diff --git a/src/surf/network_smpi.cpp b/src/surf/network_smpi.cpp index 7410aa2e81..0b03bd9d4e 100644 --- a/src/surf/network_smpi.cpp +++ b/src/surf/network_smpi.cpp @@ -6,6 +6,7 @@ #include "network_smpi.hpp" #include "simgrid/sg_config.hpp" #include "smpi_utils.hpp" +#include "src/kernel/EngineImpl.hpp" #include "src/surf/surf_interface.hpp" #include "surf/surf.hpp" @@ -22,7 +23,8 @@ std::vector smpi_lat_factor; /* New model based on LV08 and experimental results of MPI ping-pongs */ /************************************************************************/ /* @Inproceedings{smpi_ipdps, */ -/* author={Pierre-Nicolas Clauss and Mark Stillwell and Stéphane Genaud and Frédéric Suter and Henri Casanova and Martin Quinson}, */ +/* author={Pierre-Nicolas Clauss and Mark Stillwell and Stéphane Genaud and Frédéric Suter and Henri Casanova and + * Martin Quinson}, */ /* title={Single Node On-Line Simulation of {MPI} Applications with SMPI}, */ /* booktitle={25th IEEE International Parallel and Distributed Processing Symposium (IPDPS'11)}, */ /* address={Anchorage (Alaska) USA}, */ @@ -31,10 +33,9 @@ std::vector smpi_lat_factor; /* } */ void surf_network_model_init_SMPI() { - /* FIXME[donassolo]: this smells bad, but works - * (the constructor saves its pointer in all_existing_models and models_by_type :O). - * We need a manager for these models */ - new simgrid::kernel::resource::NetworkSmpiModel(); + auto net_model = std::make_unique(); + simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::NETWORK, + std::move(net_model), true); simgrid::config::set_default("network/weight-S", 8775); } @@ -45,7 +46,6 @@ namespace resource { NetworkSmpiModel::NetworkSmpiModel() : NetworkCm02Model() { - /* Do not add this into all_existing_models: our ancestor already does so */ } double NetworkSmpiModel::get_bandwidth_factor(double size) diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index 570e3aacea..de75a275e1 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -4,6 +4,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "ptask_L07.hpp" +#include "src/kernel/EngineImpl.hpp" #include "src/kernel/resource/profile/Event.hpp" #include "surf/surf.hpp" #include "xbt/config.hpp" @@ -20,9 +21,9 @@ void surf_host_model_init_ptask_L07() { XBT_CINFO(xbt_cfg, "Switching to the L07 model to handle parallel tasks."); - auto host_model = new simgrid::surf::HostL07Model(); - all_existing_models.push_back(host_model); - models_by_type[simgrid::kernel::resource::Model::Type::HOST].push_back(host_model); + auto host_model = std::make_unique(); + simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::HOST, + std::move(host_model), true); } namespace simgrid { @@ -32,10 +33,13 @@ HostL07Model::HostL07Model() : HostModel() { auto* maxmin_system = new simgrid::kernel::lmm::FairBottleneck(true /* selective update */); set_maxmin_system(maxmin_system); - network_model_ = std::make_unique(this, maxmin_system); - models_by_type[simgrid::kernel::resource::Model::Type::NETWORK].push_back(network_model_.get()); - cpu_model_pm_ = std::make_unique(this, maxmin_system); - models_by_type[simgrid::kernel::resource::Model::Type::CPU_PM].push_back(cpu_model_pm_.get()); + + net_model_ = std::make_unique(this, maxmin_system); + auto engine = simgrid::kernel::EngineImpl::get_instance(); + engine->add_model_ptask(simgrid::kernel::resource::Model::Type::NETWORK, net_model_.get(), true); + + cpu_model_ = std::make_unique(this, maxmin_system); + engine->add_model_ptask(simgrid::kernel::resource::Model::Type::CPU_PM, cpu_model_.get(), true); } HostL07Model::~HostL07Model() {} diff --git a/src/surf/ptask_L07.hpp b/src/surf/ptask_L07.hpp index adcc812d19..fe5fe36aa0 100644 --- a/src/surf/ptask_L07.hpp +++ b/src/surf/ptask_L07.hpp @@ -46,8 +46,8 @@ public: const double* bytes_amount, double rate) override; private: - std::unique_ptr network_model_; - std::unique_ptr cpu_model_pm_; + std::unique_ptr net_model_; + std::unique_ptr cpu_model_; }; class CpuL07Model : public kernel::resource::CpuModel { diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 6d9188d630..867b0d29c4 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -476,8 +476,6 @@ static void surf_config_models_setup() surf_host_model_description[host_id].model_init_preparse(); XBT_DEBUG("Call vm_model_init"); - // FIXME[donassolo]: maybe remove it, find a way to create the object and leave the - // dependency with surf_cpu_model_vm explicity surf_vm_model_init_HL13(); XBT_DEBUG("Call disk_model_init"); @@ -518,7 +516,8 @@ simgrid::kernel::routing::NetZoneImpl* sg_platf_new_Zone_begin(const simgrid::ke simgrid::kernel::routing::NetZoneImpl* new_zone = nullptr; simgrid::kernel::resource::NetworkModel* netmodel = current_routing == nullptr ? static_cast( - models_by_type[simgrid::kernel::resource::Model::Type::NETWORK][0]) + simgrid::kernel::EngineImpl::get_instance()->get_default_model( + simgrid::kernel::resource::Model::Type::NETWORK)) : current_routing->get_network_model(); if (strcasecmp(zone->routing.c_str(), "Cluster") == 0) { diff --git a/src/surf/surf_c_bindings.cpp b/src/surf/surf_c_bindings.cpp index a47a841aad..097f218b32 100644 --- a/src/surf/surf_c_bindings.cpp +++ b/src/surf/surf_c_bindings.cpp @@ -6,6 +6,7 @@ #include "simgrid/s4u/Engine.hpp" #include "src/include/surf/surf.hpp" #include "src/instr/instr_private.hpp" +#include "src/kernel/EngineImpl.hpp" #include "src/kernel/resource/DiskImpl.hpp" #include "src/kernel/resource/profile/FutureEvtSet.hpp" #include "src/plugins/vm/VirtualMachineImpl.hpp" @@ -38,7 +39,7 @@ void surf_presolve() } XBT_DEBUG("Set every models in the right state by updating them to 0."); - for (auto const& model : all_existing_models) + for (auto const& model : simgrid::kernel::EngineImpl::get_instance()->get_all_models()) model->update_actions_state(NOW, 0.0); } @@ -76,19 +77,21 @@ double surf_solve(double max_date) /* Physical models MUST be resolved first */ XBT_DEBUG("Looking for next event in physical models"); - surf_update_next_event(models_by_type[simgrid::kernel::resource::Model::Type::HOST], time_delta); + auto engine = simgrid::kernel::EngineImpl::get_instance(); + surf_update_next_event(engine->get_model_list(simgrid::kernel::resource::Model::Type::HOST), time_delta); // following the order it was done in HostCLM03Model->next_occurring_event XBT_DEBUG("Looking for next event in CPU models"); - surf_update_next_event(models_by_type[simgrid::kernel::resource::Model::Type::CPU_PM], time_delta); + surf_update_next_event(engine->get_model_list(simgrid::kernel::resource::Model::Type::CPU_PM), time_delta); + XBT_DEBUG("Looking for next event in network models"); - surf_update_next_event(models_by_type[simgrid::kernel::resource::Model::Type::NETWORK], time_delta); + surf_update_next_event(engine->get_model_list(simgrid::kernel::resource::Model::Type::NETWORK), time_delta); XBT_DEBUG("Looking for next event in disk models"); - surf_update_next_event(models_by_type[simgrid::kernel::resource::Model::Type::DISK], time_delta); + surf_update_next_event(engine->get_model_list(simgrid::kernel::resource::Model::Type::DISK), time_delta); XBT_DEBUG("Looking for next event in virtual models"); - surf_update_next_event(models_by_type[simgrid::kernel::resource::Model::Type::VM], time_delta); - surf_update_next_event(models_by_type[simgrid::kernel::resource::Model::Type::CPU_VM], time_delta); + surf_update_next_event(engine->get_model_list(simgrid::kernel::resource::Model::Type::VM), time_delta); + surf_update_next_event(engine->get_model_list(simgrid::kernel::resource::Model::Type::CPU_VM), time_delta); XBT_DEBUG("Min for resources (remember that NS3 don't update that value): %f", time_delta); @@ -98,7 +101,7 @@ double surf_solve(double max_date) double next_event_date = simgrid::kernel::profile::future_evt_set.next_date(); XBT_DEBUG("Next TRACE event: %f", next_event_date); - for (auto* model : models_by_type[simgrid::kernel::resource::Model::Type::NETWORK]) { + for (auto* model : engine->get_model_list(simgrid::kernel::resource::Model::Type::NETWORK)) { if (model->next_occurring_event_is_idempotent()) continue; @@ -160,7 +163,7 @@ double surf_solve(double max_date) NOW = NOW + time_delta; // Inform the models of the date change - for (auto const& model : all_existing_models) + for (auto const& model : simgrid::kernel::EngineImpl::get_instance()->get_all_models()) model->update_actions_state(NOW, time_delta); simgrid::s4u::Engine::on_time_advance(time_delta); diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index 5a9fd87c70..ba953e9221 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -29,10 +29,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_kernel, surf, "Logging specific to SURF (ke * Utils * *********/ -std::vector all_existing_models; /* to destroy models correctly */ -std::unordered_map> - models_by_type; - simgrid::kernel::profile::FutureEvtSet future_evt_set; std::vector surf_path; @@ -226,9 +222,6 @@ void surf_exit() { simgrid::s4u::Engine::shutdown(); - for (auto const& model : all_existing_models) - delete model; - tmgr_finalize(); sg_platf_exit(); diff --git a/teshsuite/surf/surf_usage2/surf_usage2.cpp b/teshsuite/surf/surf_usage2/surf_usage2.cpp index 4984d793af..27a6e782ef 100644 --- a/teshsuite/surf/surf_usage2/surf_usage2.cpp +++ b/teshsuite/surf/surf_usage2/surf_usage2.cpp @@ -8,6 +8,7 @@ #include "simgrid/host.h" #include "simgrid/kernel/routing/NetZoneImpl.hpp" // full type for NetZoneImpl object #include "simgrid/zone.h" +#include "src/kernel/EngineImpl.hpp" #include "src/surf/cpu_interface.hpp" #include "src/surf/network_interface.hpp" #include "src/surf/surf_interface.hpp" @@ -49,7 +50,7 @@ int main(int argc, char** argv) double now = surf_get_clock(); XBT_INFO("Next Event : %g", now); - for (auto const& model : all_existing_models) { + for (auto const& model : simgrid::kernel::EngineImpl::get_instance()->get_all_models()) { if (model->get_started_action_set()->size() != 0) { XBT_DEBUG("\t Running that model"); running = 1; -- 2.20.1