From 16f1630ae434e729cbe0b24fe2f19c8f67f774cd Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Mon, 4 Nov 2019 10:44:11 +0100 Subject: [PATCH] replace SIMIX_process_count by simgrid_get_actor_count --- include/simgrid/engine.h | 2 ++ include/simgrid/simix.h | 5 +++-- src/kernel/actor/ActorImpl.cpp | 2 +- src/msg/msg_legacy.cpp | 6 +++++- src/msg/msg_process.cpp | 6 ------ src/s4u/s4u_Engine.cpp | 4 ++++ src/simix/smx_global.cpp | 2 +- 7 files changed, 16 insertions(+), 11 deletions(-) diff --git a/include/simgrid/engine.h b/include/simgrid/engine.h index 2add0558ae..4a2247eec8 100644 --- a/include/simgrid/engine.h +++ b/include/simgrid/engine.h @@ -38,6 +38,8 @@ XBT_PUBLIC void simgrid_register_function(const char* name, int (*code)(int, cha XBT_PUBLIC void simgrid_register_default(int (*code)(int, char**)); /** Retrieve the simulation time (in seconds) */ XBT_PUBLIC double simgrid_get_clock(); +/** Retrieve the number of actors in the simulation */ +XBT_PUBLIC int simgrid_get_actor_count(); /** @brief Allow other libraries to react to the --help flag, too * diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index f2d5e439d5..8899662e15 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -106,7 +106,7 @@ XBT_PUBLIC void SIMIX_launch_application(const std::string& file); /********************************* Process ************************************/ SG_BEGIN_DECL -XBT_PUBLIC int SIMIX_process_count(); +XBT_ATTRIB_DEPRECATED_v329("Please use simgrid_get_actor_count()") XBT_PUBLIC int SIMIX_process_count(); XBT_PUBLIC smx_actor_t SIMIX_process_self(); XBT_PUBLIC const char* SIMIX_process_self_get_name(); XBT_ATTRIB_DEPRECATED_v329("This function will be removed in 3.29") XBT_PUBLIC @@ -145,7 +145,8 @@ XBT_PUBLIC bool simcall_execution_test(const smx_activity_t& execution); /**************************** Process simcalls ********************************/ SG_BEGIN_DECL -void simcall_process_set_data(smx_actor_t process, void* data); +XBT_ATTRIB_DEPRECATED_v329("This function will be removed in 3.29") void simcall_process_set_data(smx_actor_t process, + void* data); XBT_ATTRIB_DEPRECATED_v328("Please use Actor::suspend()") XBT_PUBLIC void simcall_process_suspend(smx_actor_t process); XBT_ATTRIB_DEPRECATED_v328("Please use Actor::join()") XBT_PUBLIC diff --git a/src/kernel/actor/ActorImpl.cpp b/src/kernel/actor/ActorImpl.cpp index b428cf68d8..6cea03b393 100644 --- a/src/kernel/actor/ActorImpl.cpp +++ b/src/kernel/actor/ActorImpl.cpp @@ -529,7 +529,7 @@ void create_maestro(const std::function& code) } // namespace kernel } // namespace simgrid -int SIMIX_process_count() +int SIMIX_process_count() // XBT_ATTRIB_DEPRECATED_v329 { return simix_global->process_list.size(); } diff --git a/src/msg/msg_legacy.cpp b/src/msg/msg_legacy.cpp index 105105f437..6240acd352 100644 --- a/src/msg/msg_legacy.cpp +++ b/src/msg/msg_legacy.cpp @@ -206,7 +206,11 @@ void MSG_process_unref(msg_process_t process) { sg_actor_unref(process); } - +/** @brief Return the current number MSG processes. */ +int MSG_process_get_number() +{ + return simgrid_get_actor_count(); +} /* ************************** NetZones *************************** */ sg_netzone_t MSG_zone_get_root() { diff --git a/src/msg/msg_process.cpp b/src/msg/msg_process.cpp index 7ecfd442a3..e790079093 100644 --- a/src/msg/msg_process.cpp +++ b/src/msg/msg_process.cpp @@ -110,12 +110,6 @@ xbt_dynar_t MSG_processes_as_dynar() { return res; } -/** @brief Return the current number MSG processes. */ -int MSG_process_get_number() -{ - return SIMIX_process_count(); -} - /** @brief Add a function to the list of "on_exit" functions for the current process. * The on_exit functions are the functions executed when your process is killed. * You should use them to free the data used by your process. diff --git a/src/s4u/s4u_Engine.cpp b/src/s4u/s4u_Engine.cpp index 8b05e049c5..ba96fac442 100644 --- a/src/s4u/s4u_Engine.cpp +++ b/src/s4u/s4u_Engine.cpp @@ -415,3 +415,7 @@ double simgrid_get_clock() { return simgrid::s4u::Engine::get_clock(); } +int simgrid_get_actor_count() +{ + return simgrid::s4u::Engine::get_instance()->get_actor_count(); +} diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index 1af8b5b51e..83c6f920b3 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -276,7 +276,7 @@ void SIMIX_clean() } #if HAVE_SMPI - if (SIMIX_process_count()>0){ + if (simix_global->process_list.size() > 0) { if(smpi_process()->initialized()){ xbt_die("Process exited without calling MPI_Finalize - Killing simulation"); }else{ -- 2.20.1