[Openmp-commits] [openmp] [OpenMP][clang] 6.0: num_threads strict (part 1: host runtime) (PR #146403)
Robert Imschweiler via Openmp-commits
openmp-commits at lists.llvm.org
Mon Jun 30 12:02:05 PDT 2025
https://github.com/ro-i created https://github.com/llvm/llvm-project/pull/146403
OpenMP 6.0 12.1.2 specifies the behavior of the strict modifier for the num_threads clause on parallel directives, along with the message and severity clauses. This commit implements necessary host runtime changes.
>From b3e7d2eb642b67ab8fbfeeddd8e9178170b1a3dc Mon Sep 17 00:00:00 2001
From: Robert Imschweiler <robert.imschweiler at amd.com>
Date: Fri, 27 Jun 2025 07:54:07 -0500
Subject: [PATCH] [OpenMP][clang] 6.0: num_threads strict (part 1: host
runtime)
OpenMP 6.0 12.1.2 specifies the behavior of the strict modifier for the
num_threads clause on parallel directives, along with the message and
severity clauses. This commit implements necessary host runtime changes.
---
openmp/runtime/src/kmp_runtime.cpp | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/openmp/runtime/src/kmp_runtime.cpp b/openmp/runtime/src/kmp_runtime.cpp
index 417eceb8ebecc..6afea9b994de4 100644
--- a/openmp/runtime/src/kmp_runtime.cpp
+++ b/openmp/runtime/src/kmp_runtime.cpp
@@ -1214,6 +1214,12 @@ void __kmp_serialized_parallel(ident_t *loc, kmp_int32 global_tid) {
// Reset for next parallel region
this_thr->th.th_set_proc_bind = proc_bind_default;
+ // OpenMP 6.0 12.1.2 requires the num_threads 'strict' modifier to also have
+ // effect when parallel execution is disabled by a corresponding if clause
+ // attached to the parallel directive.
+ if (this_thr->th.th_nt_strict && this_thr->th.th_set_nproc > 1)
+ __kmpc_error(this_thr->th.th_nt_loc, this_thr->th.th_nt_sev,
+ this_thr->th.th_nt_msg);
// Reset num_threads for next parallel region
this_thr->th.th_set_nproc = 0;
More information about the Openmp-commits
mailing list