Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a function to determine whether SMPI is currently used
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 12 Jun 2022 23:00:11 +0000 (01:00 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Fri, 24 Jun 2022 19:54:54 +0000 (21:54 +0200)
include/simgrid/forward.h
src/smpi/internals/smpi_global.cpp
src/xbt/xbt_main.cpp

index e8356af..9b81d2a 100644 (file)
@@ -324,4 +324,6 @@ typedef enum {
   SG_ERROR_VM
 } sg_error_t;
 
+XBT_PUBLIC int SMPI_is_inited();
+
 #endif /* SIMGRID_TYPES_H */
index 03048a0..3ff42f8 100644 (file)
@@ -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()
index 065f79a..1dc8020 100644 (file)
@@ -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