From: Jonathan Peyton Date: Tue, 2 Oct 2018 19:15:04 +0000 (+0000) Subject: [OpenMP] Shutdown library on Windows if possible for better OMPT behavior X-Git-Tag: llvmorg-8.0.0-rc1~7389 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8bb8a92de9fb63925acf402099d3e71b471aeeef;p=platform%2Fupstream%2Fllvm.git [OpenMP] Shutdown library on Windows if possible for better OMPT behavior On Windows, child workers are terminated by the parent during the normal program exit process (ExitProcess()) and they are not able to finish generating their OpenMP events. We can force manual library shut down in __kmpc_end() to fix this at least for the cases where __kmpc_end() is properly inserted. Patch by Hansang Bae Differential Revision: https://reviews.llvm.org/D52628 llvm-svn: 343619 --- diff --git a/openmp/runtime/src/kmp_csupport.cpp b/openmp/runtime/src/kmp_csupport.cpp index 51934cb..ac76794 100644 --- a/openmp/runtime/src/kmp_csupport.cpp +++ b/openmp/runtime/src/kmp_csupport.cpp @@ -71,6 +71,14 @@ void __kmpc_end(ident_t *loc) { __kmp_internal_end_thread(-1); } +#if KMP_OS_WINDOWS && OMPT_SUPPORT + // Normal exit process on Windows does not allow worker threads of the final + // parallel region to finish reporting their events, so shutting down the + // library here fixes the issue at least for the cases where __kmpc_end() is + // placed properly. + if (ompt_enabled.enabled) + __kmp_internal_end_library(__kmp_gtid_get_specific()); +#endif } /*!