Skip to content

Commit 424abcb

Browse files
authored
[OpenMP][clang] 6.0: num_threads strict (part 1: host runtime) (#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.
1 parent 7bd06c4 commit 424abcb

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

openmp/runtime/src/kmp_runtime.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,12 @@ void __kmp_serialized_parallel(ident_t *loc, kmp_int32 global_tid) {
12141214
// Reset for next parallel region
12151215
this_thr->th.th_set_proc_bind = proc_bind_default;
12161216

1217+
// OpenMP 6.0 12.1.2 requires the num_threads 'strict' modifier to also have
1218+
// effect when parallel execution is disabled by a corresponding if clause
1219+
// attached to the parallel directive.
1220+
if (this_thr->th.th_nt_strict && this_thr->th.th_set_nproc > 1)
1221+
__kmpc_error(this_thr->th.th_nt_loc, this_thr->th.th_nt_sev,
1222+
this_thr->th.th_nt_msg);
12171223
// Reset num_threads for next parallel region
12181224
this_thr->th.th_set_nproc = 0;
12191225

0 commit comments

Comments
 (0)