Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
sthread: don't intercept the main when run from smpirun
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sat, 2 Jul 2022 20:40:42 +0000 (22:40 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sat, 2 Jul 2022 20:41:59 +0000 (22:41 +0200)
src/sthread/sthread_impl.cpp

index df18541..d1a88a7 100644 (file)
@@ -27,6 +27,12 @@ static sg4::Host* lilibeth = nullptr;
 
 int sthread_main(int argc, char** argv, char** envp, int (*raw_main)(int, char**, char**))
 {
+  /* Do not intercept the main when run from SMPI: it will initialize the simulation properly */
+  for (int i = 0; envp[i] != nullptr; i++)
+    if (strncmp(envp[i], "SMPI_GLOBAL_SIZE", strlen("SMPI_GLOBAL_SIZE")) == 0)
+      return raw_main(argc, argv, envp);
+
+  /* If not in SMPI, the old main becomes an actor in a newly created simulation */
   std::ostringstream id;
   id << std::this_thread::get_id();