aboutsummaryrefslogtreecommitdiff
path: root/openmp/runtime/src/kmp_runtime.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'openmp/runtime/src/kmp_runtime.cpp')
-rw-r--r--openmp/runtime/src/kmp_runtime.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/openmp/runtime/src/kmp_runtime.cpp b/openmp/runtime/src/kmp_runtime.cpp
index 2b339fd38d63..b8d470528798 100644
--- a/openmp/runtime/src/kmp_runtime.cpp
+++ b/openmp/runtime/src/kmp_runtime.cpp
@@ -2641,6 +2641,11 @@ void __kmp_join_call(ident_t *loc, int gtid
__kmp_release_bootstrap_lock(&__kmp_forkjoin_lock);
+#if KMP_AFFINITY_SUPPORTED
+ if (master_th->th.th_team->t.t_level == 0 && __kmp_affin_reset) {
+ __kmp_reset_root_init_mask(gtid);
+ }
+#endif
#if OMPT_SUPPORT
int flags =
OMPT_INVOKER(fork_context) |
@@ -6965,10 +6970,12 @@ static void __kmp_do_serial_initialize(void) {
/* Initialize internal memory allocator */
__kmp_init_allocator();
- /* Register the library startup via an environment variable and check to see
- whether another copy of the library is already registered. */
-
- __kmp_register_library_startup();
+ /* Register the library startup via an environment variable or via mapped
+ shared memory file and check to see whether another copy of the library is
+ already registered. Since forked child process is often terminated, we
+ postpone the registration till middle initialization in the child */
+ if (__kmp_need_register_serial)
+ __kmp_register_library_startup();
/* TODO reinitialization of library */
if (TCR_4(__kmp_global.g.g_done)) {
@@ -7255,6 +7262,12 @@ static void __kmp_do_middle_initialize(void) {
KA_TRACE(10, ("__kmp_middle_initialize: enter\n"));
+ if (UNLIKELY(!__kmp_need_register_serial)) {
+ // We are in a forked child process. The registration was skipped during
+ // serial initialization in __kmp_atfork_child handler. Do it here.
+ __kmp_register_library_startup();
+ }
+
// Save the previous value for the __kmp_dflt_team_nth so that
// we can avoid some reinitialization if it hasn't changed.
prev_dflt_team_nth = __kmp_dflt_team_nth;