From 728a1c266d918708c40045c08980ef68ce696833 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Tue, 16 Aug 2016 23:18:44 +0200 Subject: [PATCH] dynar-- for hosts that restart --- src/include/surf/surf.h | 5 ----- src/simix/smx_global.cpp | 10 ++++------ src/surf/cpu_cas01.cpp | 2 +- src/surf/cpu_ti.cpp | 2 +- src/surf/surf_interface.cpp | 4 ++-- src/surf/surf_interface.hpp | 5 +++++ 6 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index d63b9d302d..6b20c10292 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -681,11 +681,6 @@ XBT_PUBLIC(void) surf_vm_model_init_HL13(); */ XBT_PUBLIC_DATA(s_surf_model_description_t) surf_vm_model_description[]; -/** \ingroup SURF_simulation - * \brief List of hosts that have just restarted and whose autorestart process should be restarted. - */ -XBT_PUBLIC_DATA(xbt_dynar_t) host_that_restart; - /** \ingroup SURF_simulation * \brief List of hosts for which one want to be notified if they ever restart. */ diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index 0a8a05c46b..b1e0b70468 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -531,13 +531,11 @@ void SIMIX_run() } while (again); /* Autorestart all process */ - char *hostname = nullptr; - unsigned int iter; - xbt_dynar_foreach(host_that_restart,iter,hostname) { - XBT_INFO("Restart processes on host: %s",hostname); - SIMIX_host_autorestart(sg_host_by_name(hostname)); + for (auto hostname: host_that_restart) { + XBT_INFO("Restart processes on host: %s", hostname.c_str()); + SIMIX_host_autorestart(sg_host_by_name(hostname.c_str())); } - xbt_dynar_reset(host_that_restart); + host_that_restart.clear(); /* Clean processes to destroy */ SIMIX_process_empty_trash(); diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index d581269985..a78b07aa38 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -143,7 +143,7 @@ void CpuCas01::apply_event(tmgr_trace_iterator_t event, double value) if (value > 0) { if(isOff()) - xbt_dynar_push_as(host_that_restart, char*, (char *)getName()); + host_that_restart.push_back(getName()); turnOn(); } else { lmm_constraint_t cnst = getConstraint(); diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index 90e5e8510e..939a2fcbc7 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -459,7 +459,7 @@ void CpuTi::apply_event(tmgr_trace_iterator_t event, double value) } else if (event == stateEvent_) { if (value > 0) { if(isOff()) - xbt_dynar_push_as(host_that_restart, char*, (char *)getName()); + host_that_restart.push_back(getName()); turnOn(); } else { turnOff(); diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index 8a7caad677..87287951b7 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -17,6 +17,7 @@ #include "virtual_machine.hpp" #include "src/instr/instr_private.h" // TRACE_is_enabled(). FIXME: remove by subscribing tracing to the surf signals #include "simgrid/s4u/engine.hpp" +#include XBT_LOG_NEW_CATEGORY(surf, "All SURF categories"); XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_kernel, surf, "Logging specific to SURF (kernel)"); @@ -32,7 +33,7 @@ xbt_dynar_t model_list_invoke = nullptr; /* to invoke callbacks */ simgrid::trace_mgr::future_evt_set *future_evt_set = nullptr; xbt_dynar_t surf_path = nullptr; -xbt_dynar_t host_that_restart = xbt_dynar_new(sizeof(char*), nullptr); +std::vector host_that_restart; xbt_dict_t watched_hosts_lib; namespace simgrid { @@ -326,7 +327,6 @@ void surf_exit() sg_config_finalize(); - xbt_dynar_free(&host_that_restart); xbt_dynar_free(&surf_path); xbt_dict_free(&host_list); diff --git a/src/surf/surf_interface.hpp b/src/surf/surf_interface.hpp index 13749c224c..878a52d9e8 100644 --- a/src/surf/surf_interface.hpp +++ b/src/surf/surf_interface.hpp @@ -40,6 +40,11 @@ extern XBT_PRIVATE xbt_dynar_t surf_path; extern "C" { XBT_PUBLIC(double) surf_get_clock(void); } +/** \ingroup SURF_simulation + * \brief List of hosts that have just restarted and whose autorestart process should be restarted. + */ +XBT_PUBLIC_DATA(std::vector) host_that_restart; + extern XBT_PRIVATE double sg_sender_gap; -- 2.20.1