[OpenMP][clang] 6.0: num_threads strict (part 2: device runtime) by ro-i · Pull Request #146404 · llvm/llvm-project (original) (raw)

@llvm/pr-subscribers-offload

Author: Robert Imschweiler (ro-i)

Changes

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 device runtime changes.


Full diff: https://github.com/llvm/llvm-project/pull/146404.diff

3 Files Affected:

diff --git a/offload/DeviceRTL/include/DeviceTypes.h b/offload/DeviceRTL/include/DeviceTypes.h index 2e5d92380f040..111143a5578f1 100644 --- a/offload/DeviceRTL/include/DeviceTypes.h +++ b/offload/DeviceRTL/include/DeviceTypes.h @@ -136,6 +136,12 @@ struct omp_lock_t { void *Lock; };

+// see definition in openmp/runtime kmp.h +typedef enum omp_severity_t {

diff --git a/offload/DeviceRTL/src/Parallelism.cpp b/offload/DeviceRTL/src/Parallelism.cpp index 08ce616aee1c4..78438a60454b8 100644 --- a/offload/DeviceRTL/src/Parallelism.cpp +++ b/offload/DeviceRTL/src/Parallelism.cpp @@ -45,7 +45,24 @@ using namespace ompx;

namespace {

-uint32_t determineNumberOfThreads(int32_t NumThreadsClause) { +void num_threads_strict_error(int32_t nt_strict, int32_t nt_severity,

+} + +uint32_t determineNumberOfThreads(int32_t NumThreadsClause,

} @@ -82,12 +103,14 @@ uint32_t determineNumberOfThreads(int32_t NumThreadsClause) {

extern "C" {

-[[clang::always_inline]] void __kmpc_parallel_spmd(IdentTy *ident,

+[[clang::always_inline]] void +__kmpc_parallel_spmd(IdentTy *ident, int32_t num_threads, void *fn, void **args,

-[[clang::always_inline]] void -__kmpc_parallel_51(IdentTy *ident, int32_t, int32_t if_expr,

+[[clang::always_inline]] void __kmpc_parallel_51(

uint32_t TId = mapping::getThreadIdInBlock();

// Assert the parallelism level is zero if disabled by the user. @@ -156,6 +180,12 @@ __kmpc_parallel_51(IdentTy *ident, int32_t, int32_t if_expr, // 3) nested parallel regions if (OMP_UNLIKELY(!if_expr || state::HasThreadState || (config::mayUseNestedParallelism() && icv::Level))) {

@@ -277,6 +309,16 @@ __kmpc_parallel_51(IdentTy *ident, int32_t, int32_t if_expr, __kmpc_end_sharing_variables(); }

+[[clang::always_inline]] void __kmpc_parallel_60(

+} + [[clang::noinline]] bool __kmpc_kernel_parallel(ParallelRegionFnTy *WorkFn) { // Work function and arguments for L1 parallel region. *WorkFn = state::ParallelRegionFn; diff --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h index a2cacc8792b15..983e1c34f76b8 100644 --- a/openmp/runtime/src/kmp.h +++ b/openmp/runtime/src/kmp.h @@ -4666,6 +4666,7 @@ static inline int __kmp_adjust_gtid_for_hidden_helpers(int gtid) { }

// Support for error directive +// See definition in offload/DeviceRTL DeviceTypes.h typedef enum kmp_severity_t { severity_warning = 1, severity_fatal = 2