From 54e823301162e7bdd9b4f583808f8e26dd43f459 Mon Sep 17 00:00:00 2001 From: Xavier Teruel Date: Tue, 15 Jan 2019 16:52:21 +0100 Subject: [PATCH] The service omp_get_thread_num() now returns -1 if thread is not part of the runtime yet; this query allows to determine either we need to call and admit_current_thread service or not; closes #1247 --- src/pms/openmp/omp_api.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pms/openmp/omp_api.cpp b/src/pms/openmp/omp_api.cpp index 938a5581a..8adf77c9f 100644 --- a/src/pms/openmp/omp_api.cpp +++ b/src/pms/openmp/omp_api.cpp @@ -62,7 +62,11 @@ extern "C" NANOS_API_DEF(int, omp_get_thread_num, ( void )) { //! \todo check if master always gets a 0 -> ensure condition ? - return myThread->getTeamData()->getId(); + if (myThread && myThread->getTeamData()) { + return myThread->getTeamData()->getId(); + } else { + return -1; + } } int nanos_omp_get_thread_num ( void ) __attribute__ ((alias ("omp_get_thread_num"))); -- GitLab