diff options
author | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2019-02-28 19:11:29 +0000 |
---|---|---|
committer | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2019-02-28 19:11:29 +0000 |
commit | e47d32f165c01e6cb3dcf71f6a9963ce66ea0972 (patch) | |
tree | 347e0a18aaba4342d3388b03ce5421e25a40edf0 /openmp/runtime/src/z_Windows_NT_util.cpp | |
parent | 23452e1c85ce6add4657584f4c6b3fa264ff8028 (diff) | |
download | bcm5719-llvm-e47d32f165c01e6cb3dcf71f6a9963ce66ea0972.tar.gz bcm5719-llvm-e47d32f165c01e6cb3dcf71f6a9963ce66ea0972.zip |
[OpenMP] Make use of sched_yield optional in runtime
This patch cleans up the yielding code and makes it optional. An
environment variable, KMP_USE_YIELD, was added. Yielding is still
on by default (KMP_USE_YIELD=1), but can be turned off completely
(KMP_USE_YIELD=0), or turned on only when oversubscription is detected
(KMP_USE_YIELD=2). Note that oversubscription cannot always be detected
by the runtime (for example, when the runtime is initialized and the
process forks, oversubscription cannot be detected currently over
multiple instances of the runtime).
Because yielding can be controlled by user now, the library mode
settings (from KMP_LIBRARY) for throughput and turnaround have been
adjusted by altering blocktime, unless that was also explicitly set.
In the original code, there were a number of places where a double yield
might have been done under oversubscription. This version checks
oversubscription and if that's not going to yield, then it does
the spin check.
Patch by Terry Wilmarth
Differential Revision: https://reviews.llvm.org/D58148
llvm-svn: 355120
Diffstat (limited to 'openmp/runtime/src/z_Windows_NT_util.cpp')
-rw-r--r-- | openmp/runtime/src/z_Windows_NT_util.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/openmp/runtime/src/z_Windows_NT_util.cpp b/openmp/runtime/src/z_Windows_NT_util.cpp index 038ac86ffb7..0049ca830a6 100644 --- a/openmp/runtime/src/z_Windows_NT_util.cpp +++ b/openmp/runtime/src/z_Windows_NT_util.cpp @@ -483,10 +483,7 @@ void __kmp_resume_oncore(int target_gtid, kmp_flag_oncore *flag) { __kmp_resume_template(target_gtid, flag); } -void __kmp_yield(int cond) { - if (cond) - Sleep(0); -} +void __kmp_yield() { Sleep(0); } void __kmp_gtid_set_specific(int gtid) { if (__kmp_init_gtid) { @@ -1245,8 +1242,8 @@ static void __kmp_reap_common(kmp_info_t *th) { Right solution seems to be waiting for *either* thread termination *or* ds_alive resetting. */ { - // TODO: This code is very similar to KMP_WAIT_YIELD. Need to generalize - // KMP_WAIT_YIELD to cover this usage also. + // TODO: This code is very similar to KMP_WAIT. Need to generalize + // KMP_WAIT to cover this usage also. void *obj = NULL; kmp_uint32 spins; #if USE_ITT_BUILD @@ -1258,8 +1255,7 @@ static void __kmp_reap_common(kmp_info_t *th) { KMP_FSYNC_SPIN_PREPARE(obj); #endif /* USE_ITT_BUILD */ __kmp_is_thread_alive(th, &exit_val); - KMP_YIELD(TCR_4(__kmp_nth) > __kmp_avail_proc); - KMP_YIELD_SPIN(spins); + KMP_YIELD_OVERSUB_ELSE_SPIN(spins); } while (exit_val == STILL_ACTIVE && TCR_4(th->th.th_info.ds.ds_alive)); #if USE_ITT_BUILD if (exit_val == STILL_ACTIVE) { |