From b355e26d385e1e8d0f73aeb8a6283385dda6f9a3 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sat, 2 Jul 2022 22:40:42 +0200 Subject: [PATCH] sthread: don't intercept the main when run from smpirun --- src/sthread/sthread_impl.cpp | 6 ++++++ 1 file changed, 6 insertions(+) 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(); -- 2.20.1