diff --git a/openmp/runtime/src/kmp_runtime.cpp b/openmp/runtime/src/kmp_runtime.cpp --- a/openmp/runtime/src/kmp_runtime.cpp +++ b/openmp/runtime/src/kmp_runtime.cpp @@ -6204,6 +6204,16 @@ return; } + // If hidden helper team has been initialized, we need to deinit it + if (TCR_4(__kmp_init_hidden_helper) && + !TCR_4(__kmp_hidden_helper_team_done)) { + TCW_SYNC_4(__kmp_hidden_helper_team_done, TRUE); + // First release the main thread to let it continue its work + __kmp_hidden_helper_main_thread_release(); + // Wait until the hidden helper team has been destroyed + __kmp_hidden_helper_threads_deinitz_wait(); + } + KMP_MB(); /* Flush all pending memory write invalidates. */ /* find out who we are and what we should do */ { @@ -6317,7 +6327,8 @@ } // If hidden helper team has been initialized, we need to deinit it - if (TCR_4(__kmp_init_hidden_helper)) { + if (TCR_4(__kmp_init_hidden_helper) && + !TCR_4(__kmp_hidden_helper_team_done)) { TCW_SYNC_4(__kmp_hidden_helper_team_done, TRUE); // First release the main thread to let it continue its work __kmp_hidden_helper_main_thread_release(); @@ -8697,11 +8708,12 @@ // Globals and functions for hidden helper task kmp_info_t **__kmp_hidden_helper_threads; kmp_info_t *__kmp_hidden_helper_main_thread; -kmp_int32 __kmp_hidden_helper_threads_num = 8; std::atomic __kmp_unexecuted_hidden_helper_tasks; #if KMP_OS_LINUX +kmp_int32 __kmp_hidden_helper_threads_num = 8; kmp_int32 __kmp_enable_hidden_helper = TRUE; #else +kmp_int32 __kmp_hidden_helper_threads_num = 0; kmp_int32 __kmp_enable_hidden_helper = FALSE; #endif diff --git a/openmp/runtime/src/kmp_tasking.cpp b/openmp/runtime/src/kmp_tasking.cpp --- a/openmp/runtime/src/kmp_tasking.cpp +++ b/openmp/runtime/src/kmp_tasking.cpp @@ -436,10 +436,12 @@ gtid, taskdata, thread_data->td.td_deque_ntasks, thread_data->td.td_deque_head, thread_data->td.td_deque_tail)); + auto hidden_helper = taskdata->td_flags.hidden_helper; + __kmp_release_bootstrap_lock(&thread_data->td.td_deque_lock); // Signal one worker thread to execute the task - if (taskdata->td_flags.hidden_helper) { + if (UNLIKELY(hidden_helper)) { // Wake hidden helper threads up if they're sleeping __kmp_hidden_helper_worker_thread_signal(); } diff --git a/openmp/runtime/src/z_Linux_util.cpp b/openmp/runtime/src/z_Linux_util.cpp --- a/openmp/runtime/src/z_Linux_util.cpp +++ b/openmp/runtime/src/z_Linux_util.cpp @@ -25,7 +25,9 @@ #include #endif #include // HUGE_VAL. +#if KMP_OS_LINUX #include +#endif // KMP_OS_LINUX #include #include #include @@ -2468,6 +2470,7 @@ #endif +#if KMP_OS_LINUX // Functions for hidden helper task namespace { // Condition variable for initializing hidden helper team @@ -2628,5 +2631,42 @@ status = pthread_mutex_unlock(&hidden_helper_threads_deinitz_lock); KMP_CHECK_SYSFAIL("pthread_mutex_unlock", status); } +#else // KMP_OS_LINUX +void __kmp_hidden_helper_worker_thread_wait() { + KMP_ASSERT(0 && "Hidden helper task is not supported on this OS"); +} + +void __kmp_do_initialize_hidden_helper_threads() { + KMP_ASSERT(0 && "Hidden helper task is not supported on this OS"); +} + +void __kmp_hidden_helper_threads_initz_wait() { + KMP_ASSERT(0 && "Hidden helper task is not supported on this OS"); +} + +void __kmp_hidden_helper_initz_release() { + KMP_ASSERT(0 && "Hidden helper task is not supported on this OS"); +} + +void __kmp_hidden_helper_main_thread_wait() { + KMP_ASSERT(0 && "Hidden helper task is not supported on this OS"); +} + +void __kmp_hidden_helper_main_thread_release() { + KMP_ASSERT(0 && "Hidden helper task is not supported on this OS"); +} + +void __kmp_hidden_helper_worker_thread_signal() { + KMP_ASSERT(0 && "Hidden helper task is not supported on this OS"); +} + +void __kmp_hidden_helper_threads_deinitz_wait() { + KMP_ASSERT(0 && "Hidden helper task is not supported on this OS"); +} + +void __kmp_hidden_helper_threads_deinitz_release() { + KMP_ASSERT(0 && "Hidden helper task is not supported on this OS"); +} +#endif // KMP_OS_LINUX // end of file //