diff --git a/openmp/runtime/src/kmp_settings.cpp b/openmp/runtime/src/kmp_settings.cpp --- a/openmp/runtime/src/kmp_settings.cpp +++ b/openmp/runtime/src/kmp_settings.cpp @@ -2790,14 +2790,6 @@ return; } - // If OMP_PROC_BIND is not specified but OMP_PLACES is, - // then let OMP_PROC_BIND default to true. - if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) { - __kmp_nested_proc_bind.bind_types[0] = proc_bind_true; - } - - //__kmp_affinity_num_places = 0; - if (__kmp_match_str("threads", scan, &next)) { scan = next; __kmp_affinity_type = affinity_compact; @@ -2833,9 +2825,14 @@ __kmp_affinity_type = affinity_explicit; __kmp_affinity_gran = affinity_gran_fine; __kmp_affinity_dups = FALSE; - if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) { - __kmp_nested_proc_bind.bind_types[0] = proc_bind_true; - } + } else { + // Syntax error fallback + __kmp_affinity_type = affinity_compact; + __kmp_affinity_gran = affinity_gran_thread; + __kmp_affinity_dups = FALSE; + } + if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) { + __kmp_nested_proc_bind.bind_types[0] = proc_bind_true; } return; } diff --git a/openmp/runtime/test/affinity/omp-places-invalid-syntax.c b/openmp/runtime/test/affinity/omp-places-invalid-syntax.c new file mode 100644 --- /dev/null +++ b/openmp/runtime/test/affinity/omp-places-invalid-syntax.c @@ -0,0 +1,11 @@ +// RUN: %libomp-compile && env KMP_SETTINGS=1 OMP_PLACES=invalid %libomp-run 2>&1 | FileCheck %s +// CHECK-DAG: Effective settings +// CHECK: OMP_PLACES= +// CHECK-SAME: threads +// REQUIRES: affinity + +int main() { + #pragma omp parallel + {} + return 0; +}