diff options
author | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2019-02-11 21:04:23 +0000 |
---|---|---|
committer | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2019-02-11 21:04:23 +0000 |
commit | 65ebfeecf88e68f34c8fc1604da042ffad5ebd8b (patch) | |
tree | 563c34e4b57e3e0702871829062d2b89c73e27c0 /openmp/runtime/cmake | |
parent | 24e0af69066e1d5ab0a6b4d75ff81d57f5b02f18 (diff) | |
download | bcm5719-llvm-65ebfeecf88e68f34c8fc1604da042ffad5ebd8b.tar.gz bcm5719-llvm-65ebfeecf88e68f34c8fc1604da042ffad5ebd8b.zip |
[OpenMP] Fix thread_limits to work properly for teams construct
The thread-limit-var and omp_get_thread_limit API was not perfectly handled for
teams construct. Now, when modified by thread_limit clause, omp_get_thread_limit
reports the correct value. In addition, the value is restored when leaving the
teams construct to what it was in the encountering context.
This is done partly by creating the notion of a Contention Group root (CG root)
that keeps track of the thread at the root of each separate CG, the
thread-limit-var associated with the CG, and associated counter of active
threads within the contention group.
thread-limits are passed from master to worker threads via an entry in the ICV
data structure. When a "contention group switch" occurs, a new CG root record is
made and passed from master to worker. A thread could potentially have several
CG root records if it encounters multiple nested teams constructs (but at the
moment the spec doesn't allow for nested teams, so the most one could have
currently is 2). The master of the teams masters gets the thread-limit clause
value stored to its local ICV structure, and the other teams masters copy it
from the master. The thread-limit is set from that ICV copy and restored to the
ICV copy when entering and leaving the teams construct.
This change also fixes a bug when the top-level teams construct team gets
reused, and OMP_DYNAMIC was true, which can cause the expected size of this team
to be smaller than what was actually allocated. The fix updates the size of the
team after its threads were reserved.
Patch by Terry Wilmarth
Differential Revision: https://reviews.llvm.org/D56804
llvm-svn: 353747
Diffstat (limited to 'openmp/runtime/cmake')
-rw-r--r-- | openmp/runtime/cmake/config-ix.cmake | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/openmp/runtime/cmake/config-ix.cmake b/openmp/runtime/cmake/config-ix.cmake index 5404715b6d9..61b6618ee6d 100644 --- a/openmp/runtime/cmake/config-ix.cmake +++ b/openmp/runtime/cmake/config-ix.cmake @@ -10,6 +10,7 @@ include(CheckCCompilerFlag) include(CheckCSourceCompiles) +include(CheckCXXSourceCompiles) include(CheckCXXCompilerFlag) include(CheckIncludeFile) include(CheckLibraryExists) @@ -38,6 +39,42 @@ function(libomp_check_version_symbols retval) file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/__version_script.txt) endfunction() +function(libomp_check_attribute_fallthrough retval) + set(fallthroughs "[[fallthrough]]" "[[clang::fallthrough]]" "__attribute__((__fallthrough__))") + foreach(fallthrough IN LISTS fallthroughs) + string(MAKE_C_IDENTIFIER "${fallthrough}" test_name) + set(source_code + "#include <stdio.h> + enum class foo_e { zero, one, two, three, four }; + int main(int argc, char** argv) { + foo_e foo; + if (argc == 0) foo = foo_e::zero; + else if (argc == 1) foo = foo_e::one; + else if (argc == 2) foo = foo_e::two; + else if (argc == 3) foo = foo_e::three; + else if (argc == 4) foo = foo_e::four; + switch (foo) { + case foo_e::zero: + ${fallthrough} + case foo_e::one: + return 1; + case foo_e::two: + return 2; + case foo_e::three: + return 3; + case foo_e::four: + return 4; + } + return 0; + }") + check_cxx_source_compiles("${source_code}" ${test_name}) + if(${test_name}) + set(${retval} ${fallthrough} PARENT_SCOPE) + break() + endif() + endforeach() +endfunction() + # Includes the architecture flag in both compile and link phase function(libomp_check_architecture_flag flag retval) set(CMAKE_REQUIRED_FLAGS "${flag}") @@ -172,6 +209,7 @@ endif() # Checking features # Check if version symbol assembler directives are supported libomp_check_version_symbols(LIBOMP_HAVE_VERSION_SYMBOLS) +libomp_check_attribute_fallthrough(LIBOMP_FALLTHROUGH) # Check if quad precision types are available if(CMAKE_C_COMPILER_ID STREQUAL "GNU") |