[PATCH] D90704: [OpenMP] target nested `use_device_ptr() if()` and is_device_ptr trigger asserts
Chi Chun Chen via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 3 11:50:24 PST 2020
cchen created this revision.
cchen added a reviewer: ABataev.
Herald added subscribers: cfe-commits, guansong, yaxunl.
Herald added a project: clang.
cchen requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.
Clang now asserts for the below case for "All ordered entries must
exist!" message.
void
add_one(float *b, int dm)
{
{
{
b[0] += 1;
}
}
}
Clang now register for same device region for both `if_then` codegen and
`else_then` codegen so this patch just add a check to avoid register
twice for same device region.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D90704
Files:
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp
Index: clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp
===================================================================
--- clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp
+++ clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp
@@ -471,5 +471,49 @@
A.foo(arg);
++arg;
}
+#endif
+///==========================================================================///
+// RUN: %clang_cc1 -DCK3 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK3 --check-prefix CK3-64
+// RUN: %clang_cc1 -DCK3 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK3 --check-prefix CK3-64
+// RUN: %clang_cc1 -DCK3 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK3 --check-prefix CK3-32
+// RUN: %clang_cc1 -DCK3 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK3 --check-prefix CK3-32
+
+// RUN: %clang_cc1 -DCK3 -verify -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK3 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK3 -verify -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK3 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// SIMD-ONLY1-NOT: {{__kmpc|__tgt}}
+#ifdef CK3
+
+// CK3: [[MTYPE00:@.+]] = {{.*}}constant [1 x i64] [i64 99]
+// CK3: [[MTYPE01:@.+]] = {{.*}}constant [1 x i64] [i64 288]
+// CK3: [[MTYPE02:@.+]] = {{.*}}constant [1 x i64] [i64 288]
+
+void add_one(float *b, int dm)
+{
+ // CK3: [[BP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* %{{.+}}, i32 0, i32 0
+ // CK3: [[CBP:%.+]] = bitcast i8** [[BP]] to float**
+ // CK3: store float* [[B_ADDR:%.+]], float** [[CBP]]
+ // CK3: call void @__tgt_target_data_begin{{.+}}[[MTYPE00]]
+ // CK3: [[VAL:%.+]] = load float*, float** [[CBP]],
+ // CK3-NOT: store float* [[VAL]], float** [[DECL]],
+ // CK3: store float* [[VAL]], float** [[PVT:%.+]],
+ // CK3: [[TT:%.+]] = load float*, float** [[PVT]],
+ // CK3: call i32 @__tgt_target{{.+}}[[MTYPE01]]
+ // CK3: call i32 @__tgt_target{{.+}}[[MTYPE02]]
+ // CK3: call void @__tgt_target_data_end{{.+}}[[MTYPE00]]
+#pragma omp target data map(tofrom:b[:1]) use_device_ptr(b) if(dm == 0)
+ {
+#pragma omp target is_device_ptr(b)
+ {
+ b[0] += 1;
+ }
+ }
+}
+
#endif
#endif
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===================================================================
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2955,6 +2955,19 @@
Entry.setID(ID);
Entry.setFlags(Flags);
} else {
+ auto PerDevice = OffloadEntriesTargetRegion.find(DeviceID);
+ if (PerDevice != OffloadEntriesTargetRegion.end()) {
+ auto PerFile = PerDevice->second.find(FileID);
+ if (PerFile != PerDevice->second.end()) {
+ auto PerParentName = PerFile->second.find(ParentName);
+ if (PerParentName != PerFile->second.end()) {
+ auto PerLine = PerParentName->second.find(LineNum);
+ if (PerLine != PerParentName->second.end()) {
+ return;
+ }
+ }
+ }
+ }
OffloadEntryInfoTargetRegion Entry(OffloadingEntriesNum, Addr, ID, Flags);
OffloadEntriesTargetRegion[DeviceID][FileID][ParentName][LineNum] = Entry;
++OffloadingEntriesNum;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90704.302649.patch
Type: text/x-patch
Size: 4722 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201103/544a84e1/attachment.bin>
More information about the cfe-commits
mailing list