[llvm-branch-commits] [openmp] 171ca93 - [OpenMP] Initialize runtime in the forked child process
Hansang Bae via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Dec 15 05:38:17 PST 2020
Author: Hansang Bae
Date: 2020-12-15T07:29:28-06:00
New Revision: 171ca93c543098d5e0bef459847de14cf17b5faf
URL: https://github.com/llvm/llvm-project/commit/171ca93c543098d5e0bef459847de14cf17b5faf
DIFF: https://github.com/llvm/llvm-project/commit/171ca93c543098d5e0bef459847de14cf17b5faf.diff
LOG: [OpenMP] Initialize runtime in the forked child process
This patch enables serial initialization in the forked child process
to fix unstable runtime behavior when used with Python-based AI tools.
Differential Revision: https://reviews.llvm.org/D93230
Added:
Modified:
openmp/runtime/src/z_Linux_util.cpp
Removed:
################################################################################
diff --git a/openmp/runtime/src/z_Linux_util.cpp b/openmp/runtime/src/z_Linux_util.cpp
index 15237d631958..d039a454f00d 100644
--- a/openmp/runtime/src/z_Linux_util.cpp
+++ b/openmp/runtime/src/z_Linux_util.cpp
@@ -1272,8 +1272,8 @@ static void __kmp_atfork_prepare(void) {
}
static void __kmp_atfork_parent(void) {
- __kmp_release_bootstrap_lock(&__kmp_initz_lock);
__kmp_release_bootstrap_lock(&__kmp_forkjoin_lock);
+ __kmp_release_bootstrap_lock(&__kmp_initz_lock);
}
/* Reset the library so execution in the child starts "all over again" with
@@ -1281,6 +1281,7 @@ static void __kmp_atfork_parent(void) {
allocated by parent, just abandon it to be safe. */
static void __kmp_atfork_child(void) {
__kmp_release_bootstrap_lock(&__kmp_forkjoin_lock);
+ __kmp_release_bootstrap_lock(&__kmp_initz_lock);
/* TODO make sure this is done right for nested/sibling */
// ATT: Memory leaks are here? TODO: Check it and fix.
/* KMP_ASSERT( 0 ); */
@@ -1302,7 +1303,6 @@ static void __kmp_atfork_child(void) {
}
#endif // KMP_AFFINITY_SUPPORTED
- __kmp_init_runtime = FALSE;
#if KMP_USE_MONITOR
__kmp_init_monitor = 0;
#endif
@@ -1355,6 +1355,8 @@ static void __kmp_atfork_child(void) {
__kmp_itt_reset(); // reset ITT's global state
#endif /* USE_ITT_BUILD */
+ __kmp_serial_initialize();
+
/* This is necessary to make sure no stale data is left around */
/* AC: customers complain that we use unsafe routines in the atfork
handler. Mathworks: dlsym() is unsafe. We call dlsym and dlopen
More information about the llvm-branch-commits
mailing list