From 9355d0dc13c01c80e74f0dd14230356f58a99e55 Mon Sep 17 00:00:00 2001 From: Jonathan Peyton Date: Tue, 15 Jan 2019 19:39:32 +0000 Subject: [OpenMP] Fix for nested proc_bind affinity bug Using proc_bind clause on a nested #pragma omp parallel region with KMP_AFFINITY set causes an assertion error. This assertion occurs because the place-partition-var is not properly initialized in the nested master threads. Trying to get an intuitive result with KMP_AFFINITY + proc_bind is difficult because of how the KMP_AFFINITY gtid-to-place mapping occurs. This patch creates an initial place list no matter what affinity mechanism is used. For KMP_AFFINITY, the place-partition-var is initialized to all the places. Differential Revision: https://reviews.llvm.org/D55795 llvm-svn: 351227 --- openmp/runtime/test/affinity/bug-nested.c | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 openmp/runtime/test/affinity/bug-nested.c (limited to 'openmp/runtime/test/affinity/bug-nested.c') diff --git a/openmp/runtime/test/affinity/bug-nested.c b/openmp/runtime/test/affinity/bug-nested.c new file mode 100644 index 00000000000..a81b5f36292 --- /dev/null +++ b/openmp/runtime/test/affinity/bug-nested.c @@ -0,0 +1,33 @@ +// RUN: %libomp-compile && env KMP_AFFINITY=compact %libomp-run +// REQUIRES: openmp-4.0 + +#include +#include +#include +#include "omp_testsuite.h" + +int test_nested_affinity_bug() { + int a = 0; + omp_set_nested(1); + #pragma omp parallel num_threads(2) shared(a) + { + #pragma omp parallel num_threads(2) shared(a) proc_bind(close) + { + #pragma omp atomic + a++; + } + } + return 1; +} + +int main() { + int i; + int num_failed = 0; + + for (i = 0; i < REPETITIONS; i++) { + if (!test_nested_affinity_bug()) { + num_failed++; + } + } + return num_failed; +} -- cgit v1.2.3