[OpenMP] Make use of sched_yield optional in runtime
authorJonathan Peyton <jonathan.l.peyton@intel.com>
Thu, 28 Feb 2019 19:11:29 +0000 (19:11 +0000)
committerJonathan Peyton <jonathan.l.peyton@intel.com>
Thu, 28 Feb 2019 19:11:29 +0000 (19:11 +0000)
commite47d32f165c01e6cb3dcf71f6a9963ce66ea0972
tree347e0a18aaba4342d3388b03ce5421e25a40edf0
parent23452e1c85ce6add4657584f4c6b3fa264ff8028
[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
19 files changed:
openmp/runtime/src/dllexports
openmp/runtime/src/exports_so.txt
openmp/runtime/src/kmp.h
openmp/runtime/src/kmp_csupport.cpp
openmp/runtime/src/kmp_dispatch.cpp
openmp/runtime/src/kmp_dispatch.h
openmp/runtime/src/kmp_dispatch_hier.h
openmp/runtime/src/kmp_global.cpp
openmp/runtime/src/kmp_itt.h
openmp/runtime/src/kmp_lock.cpp
openmp/runtime/src/kmp_lock.h
openmp/runtime/src/kmp_os.h
openmp/runtime/src/kmp_runtime.cpp
openmp/runtime/src/kmp_settings.cpp
openmp/runtime/src/kmp_tasking.cpp
openmp/runtime/src/kmp_taskq.cpp
openmp/runtime/src/kmp_wait_release.h
openmp/runtime/src/z_Linux_util.cpp
openmp/runtime/src/z_Windows_NT_util.cpp