From: Martin Quinson Date: Sun, 12 Jun 2022 23:00:11 +0000 (+0200) Subject: Add a function to determine whether SMPI is currently used X-Git-Tag: v3.32~193 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/2681271f2b5164d6a56f5c1a6645baf381a597a4 Add a function to determine whether SMPI is currently used --- diff --git a/include/simgrid/forward.h b/include/simgrid/forward.h index e8356af3bd..9b81d2a643 100644 --- a/include/simgrid/forward.h +++ b/include/simgrid/forward.h @@ -324,4 +324,6 @@ typedef enum { SG_ERROR_VM } sg_error_t; +XBT_PUBLIC int SMPI_is_inited(); + #endif /* SIMGRID_TYPES_H */ diff --git a/src/smpi/internals/smpi_global.cpp b/src/smpi/internals/smpi_global.cpp index 03048a0bae..3ff42f8613 100644 --- a/src/smpi/internals/smpi_global.cpp +++ b/src/smpi/internals/smpi_global.cpp @@ -583,6 +583,11 @@ int smpi_main(const char* executable, int argc, char* argv[]) return smpi_exit_status; } +static bool smpi_inited = false; +int SMPI_is_inited() +{ + return smpi_inited; +} // Called either directly from the user code, or from the code called by smpirun void SMPI_init(){ smpi_init_options_internal(false); @@ -601,6 +606,7 @@ void SMPI_init(){ } smpi_init_papi(); smpi_check_options(); + smpi_inited = true; } void SMPI_finalize() diff --git a/src/xbt/xbt_main.cpp b/src/xbt/xbt_main.cpp index 065f79a2a2..1dc8020c69 100644 --- a/src/xbt/xbt_main.cpp +++ b/src/xbt/xbt_main.cpp @@ -157,3 +157,10 @@ void xbt_abort() #endif abort(); } + +#ifndef HAVE_SMPI +int SMPI_is_inited() +{ + return false; +} +#endif \ No newline at end of file