[clang] 0cecc6e - [OpenMP] Add lit test for metadirective device arch inspired
Saiyedul Islam via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 6 05:10:59 PDT 2022
Author: Animesh Kumar
Date: 2022-09-06T07:10:15-05:00
New Revision: 0cecc6e8e27c9913cd2d82a77941dc3a6d11318f
URL: https://github.com/llvm/llvm-project/commit/0cecc6e8e27c9913cd2d82a77941dc3a6d11318f
DIFF: https://github.com/llvm/llvm-project/commit/0cecc6e8e27c9913cd2d82a77941dc3a6d11318f.diff
LOG: [OpenMP] Add lit test for metadirective device arch inspired
from sollve
This lit test is added based upon the tests present in the
tests/5.0/metadirective directory of the SOLLVE repo
https://github.com/SOLLVE/sollve_vv
Reviewed By: saiislam
Differential Revision: https://reviews.llvm.org/D131763
Added:
clang/test/OpenMP/metadirective_device_arch_codegen.cpp
Modified:
clang/test/OpenMP/metadirective_ast_print.c
Removed:
################################################################################
diff --git a/clang/test/OpenMP/metadirective_ast_print.c b/clang/test/OpenMP/metadirective_ast_print.c
index 6c75cb0592d6..ddd5b8633cc5 100644
--- a/clang/test/OpenMP/metadirective_ast_print.c
+++ b/clang/test/OpenMP/metadirective_ast_print.c
@@ -1,6 +1,10 @@
// RUN: %clang_cc1 -verify -fopenmp -triple x86_64-unknown-linux-gnu -x c -std=c99 -ast-print %s -o - | FileCheck %s
// RUN: %clang_cc1 -verify -fopenmp-simd -triple x86_64-unknown-linux-gnu -x c -std=c99 -ast-print %s -o - | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp -triple amdgcn-amd-amdhsa -x c -std=c99 -ast-print %s -o - | FileCheck %s --check-prefix=CHECK-AMDGCN
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -triple amdgcn-amd-amdhsa -x c -std=c99 -ast-print %s -o - | FileCheck %s --check-prefix=CHECK-AMDGCN
// expected-no-diagnostics
#ifndef HEADER
@@ -57,6 +61,12 @@ void foo(void) {
for (int j = 0; j < 16; j++)
array[i] = i;
}
+
+#pragma omp metadirective when(device={arch("amdgcn")}: \
+ teams distribute parallel for)\
+ default(parallel for)
+ for (int i = 0; i < 100; i++)
+ ;
}
// CHECK: void bar(void);
@@ -83,5 +93,7 @@ void foo(void) {
// CHECK-NEXT: for (int i = 0; i < 16; i++) {
// CHECK-NEXT: #pragma omp simd
// CHECK-NEXT: for (int j = 0; j < 16; j++)
+// CHECK-AMDGCN: #pragma omp teams distribute parallel for
+// CHECK-AMDGCN-NEXT: for (int i = 0; i < 100; i++)
#endif
diff --git a/clang/test/OpenMP/metadirective_device_arch_codegen.cpp b/clang/test/OpenMP/metadirective_device_arch_codegen.cpp
new file mode 100644
index 000000000000..eac71d0e5b5a
--- /dev/null
+++ b/clang/test/OpenMP/metadirective_device_arch_codegen.cpp
@@ -0,0 +1,65 @@
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang_cc1 -fopenmp -x c++ -w -std=c++11 -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -fopenmp -x c++ -w -std=c++11 -triple amdgcn-amd-amdhsa -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -target-cpu gfx906 -o - | FileCheck %s
+// expected-no-diagnostics
+
+
+/*===-----------------------------------------------------------------------===
+
+Inspired from SOLLVE tests:
+ - 5.0/metadirective/test_metadirective_arch_is_nvidia.c
+
+
+===------------------------------------------------------------------------===*/
+
+
+#define N 1024
+
+int metadirective1() {
+
+ int v1[N], v2[N], v3[N];
+
+ int target_device_num, host_device_num, default_device;
+ int errors = 0;
+
+ #pragma omp target map(to:v1,v2) map(from:v3, target_device_num) device(default_device)
+ {
+ #pragma omp metadirective \
+ when(device={arch("amdgcn")}: teams distribute parallel for) \
+ default(parallel for)
+
+ for (int i = 0; i < N; i++) {
+ #pragma omp atomic write
+ v3[i] = v1[i] * v2[i];
+ }
+ }
+
+ return errors;
+}
+
+// CHECK-LABEL: define weak_odr amdgpu_kernel void {{.+}}metadirective1
+// CHECK: entry:
+// CHECK: %{{[0-9]}} = call i32 @__kmpc_target_init
+// CHECK: user_code.entry:
+// CHECK: call void @__omp_outlined__
+// CHECK-NOT: call void @__kmpc_parallel_51
+// CHECK: ret void
+
+
+// CHECK-LABEL: define internal void @__omp_outlined__
+// CHECK: entry:
+// CHECK: call void @__kmpc_distribute_static_init
+// CHECK: omp.loop.exit:
+// CHECK: call void @__kmpc_distribute_static_fini
+
+
+// CHECK-LABEL: define internal void @__omp_outlined__.{{[0-9]+}}
+// CHECK: entry:
+// CHECK: call void @__kmpc_for_static_init_4
+// CHECK: omp.inner.for.body:
+// CHECK: store atomic {{.*}} monotonic
+// CHECK: omp.loop.exit:
+// CHECK-NEXT: call void @__kmpc_distribute_static_fini
+// CHECK-NEXT: ret void
+
More information about the cfe-commits
mailing list