• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Test target codegen - host bc file has to be created first.
2 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fopenmp-cuda-mode -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
3 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fopenmp-cuda-mode -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
4 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fopenmp-cuda-mode -x c++ -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
5 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fopenmp-cuda-mode -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
6 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fopenmp-cuda-mode -fexceptions -fcxx-exceptions -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
7 
8 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-cuda-mode -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
9 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-cuda-mode -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
10 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-cuda-mode -x c++ -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
11 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-cuda-mode -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
12 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-cuda-mode -fexceptions -fcxx-exceptions -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
13 
14 // expected-no-diagnostics
15 #ifndef HEADER
16 #define HEADER
17 
18 // Check that the execution mode of all 2 target regions on the gpu is set to NonSPMD Mode.
19 // CHECK-DAG: {{@__omp_offloading_.+l32}}_exec_mode = weak constant i8 0
20 // CHECK-DAG: {{@__omp_offloading_.+l37}}_exec_mode = weak constant i8 0
21 // CHECK-DAG: {{@__omp_offloading_.+l42}}_exec_mode = weak constant i8 0
22 // CHECK-DAG: {{@__omp_offloading_.+l47}}_exec_mode = weak constant i8 0
23 
24 #define N 1000
25 
26 template<typename tx>
ftemplate(int n)27 tx ftemplate(int n) {
28   tx a[N];
29   short aa[N];
30   tx b[10];
31 
32   #pragma omp target simd
33   for(int i = 0; i < n; i++) {
34     a[i] = 1;
35   }
36 
37   #pragma omp target simd
38   for (int i = 0; i < n; i++) {
39     aa[i] += 1;
40   }
41 
42   #pragma omp target simd
43   for(int i = 0; i < 10; i++) {
44     b[i] += 1;
45   }
46 
47   #pragma omp target simd reduction(+:n)
48   for(int i = 0; i < 10; i++) {
49     b[i] += 1;
50   }
51 
52   return a[0];
53 }
54 
bar(int n)55 int bar(int n){
56   int a = 0;
57 
58   a += ftemplate<int>(n);
59 
60   return a;
61 }
62 
63 // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+l32}}(
64 // CHECK: call void @__kmpc_spmd_kernel_init(i32 %{{.+}}, i16 0)
65 // CHECK-NOT: call void @__kmpc_for_static_init
66 // CHECK-NOT: call void @__kmpc_for_static_fini
67 // CHECK: call void @__kmpc_spmd_kernel_deinit_v2(i16 0)
68 // CHECK: ret void
69 
70 // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+l37}}(
71 // CHECK: call void @__kmpc_spmd_kernel_init(i32 %{{.+}}, i16 0)
72 // CHECK-NOT: call void @__kmpc_for_static_init
73 // CHECK-NOT: call void @__kmpc_for_static_fini
74 // CHECK: call void @__kmpc_spmd_kernel_deinit_v2(i16 0)
75 // CHECK: ret void
76 
77 // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+l42}}(
78 // CHECK: call void @__kmpc_spmd_kernel_init(i32 %{{.+}}, i16 0)
79 // CHECK-NOT: call void @__kmpc_for_static_init
80 // CHECK-NOT: call void @__kmpc_for_static_fini
81 // CHECK: call void @__kmpc_spmd_kernel_deinit_v2(i16 0)
82 // CHECK: ret void
83 
84 // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+l47}}(
85 // CHECK: call void @__kmpc_spmd_kernel_init(i32 %{{.+}}, i16 0)
86 // CHECK-NOT: call void @__kmpc_for_static_init
87 // CHECK-NOT: call void @__kmpc_for_static_fini
88 // CHECK-NOT: call void @__kmpc_nvptx_end_reduce_nowait(
89 // CHECK: call void @__kmpc_spmd_kernel_deinit_v2(i16 0)
90 // CHECK: ret void
91 
92 #endif
93