https://github.com/SunilKuravinakop updated https://github.com/llvm/llvm-project/pull/82604
>From 6444ef3f60a9f8ed8b3f413997259fe5006396b7 Mon Sep 17 00:00:00 2001 From: Sunil Kuravinakop <kurav...@pe28vega.us.cray.com> Date: Tue, 20 Feb 2024 11:29:49 -0600 Subject: [PATCH 1/3] Accept multiple init clauses in interop directive. Changes to be committed: modified: clang/lib/CodeGen/CGStmtOpenMP.cpp --- clang/lib/CodeGen/CGStmtOpenMP.cpp | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 8fd74697de3c0f..c512b0bd851f7a 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -7023,19 +7023,25 @@ void CodeGenFunction::EmitOMPInteropDirective(const OMPInteropDirective &S) { S.getSingleClause<OMPUseClause>())) && "OMPNowaitClause clause is used separately in OMPInteropDirective."); - if (const auto *C = S.getSingleClause<OMPInitClause>()) { - llvm::Value *InteropvarPtr = - EmitLValue(C->getInteropVar()).getPointer(*this); - llvm::omp::OMPInteropType InteropType = llvm::omp::OMPInteropType::Unknown; - if (C->getIsTarget()) { - InteropType = llvm::omp::OMPInteropType::Target; - } else { - assert(C->getIsTargetSync() && "Expected interop-type target/targetsync"); - InteropType = llvm::omp::OMPInteropType::TargetSync; + auto It = S.getClausesOfKind<OMPInitClause>(); + if (!It.empty()) { + // Look at the multiple init clauses + for (auto C : It) { + llvm::Value *InteropvarPtr = + EmitLValue(C->getInteropVar()).getPointer(*this); + llvm::omp::OMPInteropType InteropType = + llvm::omp::OMPInteropType::Unknown; + if (C->getIsTarget()) { + InteropType = llvm::omp::OMPInteropType::Target; + } else { + assert(C->getIsTargetSync() && + "Expected interop-type target/targetsync"); + InteropType = llvm::omp::OMPInteropType::TargetSync; + } + OMPBuilder.createOMPInteropInit(Builder, InteropvarPtr, InteropType, + Device, NumDependences, DependenceList, + Data.HasNowaitClause); } - OMPBuilder.createOMPInteropInit(Builder, InteropvarPtr, InteropType, Device, - NumDependences, DependenceList, - Data.HasNowaitClause); } else if (const auto *C = S.getSingleClause<OMPDestroyClause>()) { llvm::Value *InteropvarPtr = EmitLValue(C->getInteropVar()).getPointer(*this); >From f4779f0dfd0fbf3a9e851f3df276840f254d87a7 Mon Sep 17 00:00:00 2001 From: Sunil Kuravinakop <kurav...@pe28vega.us.cray.com> Date: Sat, 24 Feb 2024 00:41:03 -0600 Subject: [PATCH 2/3] Adding a testcase for interop_codegen.cpp to check "init" clause being provided twice. This check is being done only for AMD GPU. Changes to be committed: new file: clang/test/OpenMP/interop_codegen.cpp --- clang/test/OpenMP/interop_codegen.cpp | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 clang/test/OpenMP/interop_codegen.cpp diff --git a/clang/test/OpenMP/interop_codegen.cpp b/clang/test/OpenMP/interop_codegen.cpp new file mode 100644 index 00000000000000..6277db27bd4da8 --- /dev/null +++ b/clang/test/OpenMP/interop_codegen.cpp @@ -0,0 +1,30 @@ +// expected-no-diagnostics +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -o - | FileCheck %s + +#ifndef HEADER +#define HEADER + +typedef void *omp_interop_t; +#define omp_interop_none 0 +#define omp_ipr_fr_id -1 +typedef long omp_intptr_t; +#define NULL 0 + +extern omp_intptr_t omp_get_interop_int(const omp_interop_t, int, int *); + +int main() { + omp_interop_t i1 = omp_interop_none; + omp_interop_t obj = omp_interop_none; + + #pragma omp interop init(targetsync: i1) init(targetsync: obj) + int id = (int )omp_get_interop_int(obj, omp_ipr_fr_id, NULL); + int id1 = (int )omp_get_interop_int(i1, omp_ipr_fr_id, NULL); + + +} +#endif + +// CHECK-LABEL: define {{.+}}main{{.+}} +// CHECK: call {{.+}}__tgt_interop_init({{.+}}i1{{.*}}) +// CHECK: call {{.+}}__tgt_interop_init({{.+}}obj{{.*}}) >From f7ddf6eb5df9ec9a1f84e5918f05854465ca74bc Mon Sep 17 00:00:00 2001 From: Sunil Kuravinakop <kurav...@pe28vega.us.cray.com> Date: Sat, 24 Feb 2024 05:27:19 -0600 Subject: [PATCH 3/3] Added -fopenmp-targets=nvptx64-nvidia-cuda & -fopenmp-targets=powerpc64le-ibm-linux-gnu. Changes to be committed: modified: clang/test/OpenMP/interop_codegen.cpp --- clang/test/OpenMP/interop_codegen.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/test/OpenMP/interop_codegen.cpp b/clang/test/OpenMP/interop_codegen.cpp index 6277db27bd4da8..e814fd9b23d47c 100644 --- a/clang/test/OpenMP/interop_codegen.cpp +++ b/clang/test/OpenMP/interop_codegen.cpp @@ -1,6 +1,7 @@ // expected-no-diagnostics -// REQUIRES: amdgpu-registered-target // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s #ifndef HEADER #define HEADER _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits