• 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 3 target regions on the gpu is set to SPMD Mode.
19 // CHECK-DAG: {{@__omp_offloading_.+l29}}_exec_mode = weak constant i8 0
20 // CHECK-DAG: {{@__omp_offloading_.+l33}}_exec_mode = weak constant i8 0
21 // CHECK-DAG: {{@__omp_offloading_.+l38}}_exec_mode = weak constant i8 0
22 
23 template<typename tx>
ftemplate(int n)24 tx ftemplate(int n) {
25   tx a = 0;
26   short aa = 0;
27   tx b[10];
28 
29   #pragma omp target parallel proc_bind(master)
30   {
31   }
32 
33   #pragma omp target parallel proc_bind(spread)
34   {
35     aa += 1;
36   }
37 
38   #pragma omp target parallel proc_bind(close)
39   {
40     a += 1;
41     aa += 1;
42     b[2] += 1;
43   }
44 
45   return a;
46 }
47 
bar(int n)48 int bar(int n){
49   int a = 0;
50 
51   a += ftemplate<int>(n);
52 
53   return a;
54 }
55 
56 // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+template.+l29}}(
57 // CHECK: call void @__kmpc_spmd_kernel_init(i32 {{.+}}, i16 1)
58 // CHECK: call void @__kmpc_data_sharing_init_stack_spmd
59 // CHECK: br label {{%?}}[[EXEC:.+]]
60 //
61 // CHECK: [[EXEC]]
62 // CHECK-NOT: call void @__kmpc_push_proc_bind
63 // CHECK: {{call|invoke}} void [[OP1:@.+]](
64 // CHECK: br label {{%?}}[[DONE:.+]]
65 //
66 // CHECK: [[DONE]]
67 // CHECK: call void @__kmpc_spmd_kernel_deinit_v2(i16 1)
68 // CHECK: br label {{%?}}[[EXIT:.+]]
69 //
70 // CHECK: [[EXIT]]
71 // CHECK: ret void
72 // CHECK: }
73 
74 // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+template.+l33}}(
75 // CHECK: call void @__kmpc_spmd_kernel_init(i32 {{.+}}, i16 1)
76 // CHECK: call void @__kmpc_data_sharing_init_stack_spmd
77 // CHECK: br label {{%?}}[[EXEC:.+]]
78 //
79 // CHECK: [[EXEC]]
80 // CHECK-NOT: call void @__kmpc_push_proc_bind
81 // CHECK: {{call|invoke}} void [[OP1:@.+]](
82 // CHECK: br label {{%?}}[[DONE:.+]]
83 //
84 // CHECK: [[DONE]]
85 // CHECK: call void @__kmpc_spmd_kernel_deinit_v2(i16 1)
86 // CHECK: br label {{%?}}[[EXIT:.+]]
87 //
88 // CHECK: [[EXIT]]
89 // CHECK: ret void
90 // CHECK: }
91 
92 // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+template.+l38}}(
93 // CHECK: call void @__kmpc_spmd_kernel_init(i32 {{.+}}, i16 1)
94 // CHECK: call void @__kmpc_data_sharing_init_stack_spmd
95 // CHECK: br label {{%?}}[[EXEC:.+]]
96 //
97 // CHECK: [[EXEC]]
98 // CHECK-NOT: call void @__kmpc_push_proc_bind
99 // CHECK: {{call|invoke}} void [[OP1:@.+]](
100 // CHECK: br label {{%?}}[[DONE:.+]]
101 //
102 // CHECK: [[DONE]]
103 // CHECK: call void @__kmpc_spmd_kernel_deinit_v2(i16 1)
104 // CHECK: br label {{%?}}[[EXIT:.+]]
105 //
106 // CHECK: [[EXIT]]
107 // CHECK: ret void
108 // CHECK: }
109 #endif
110