From: Martin Quinson Date: Sat, 2 Jul 2022 20:40:42 +0000 (+0200) Subject: sthread: don't intercept the main when run from smpirun X-Git-Tag: v3.32~168 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/b355e26d385e1e8d0f73aeb8a6283385dda6f9a3 sthread: don't intercept the main when run from smpirun --- diff --git a/src/sthread/sthread_impl.cpp b/src/sthread/sthread_impl.cpp index df1854109b..d1a88a7038 100644 --- a/src/sthread/sthread_impl.cpp +++ b/src/sthread/sthread_impl.cpp @@ -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();