| 1 | // expected-no-diagnostics |
| 2 | #ifndef HEADER |
| 3 | #define HEADER |
| 4 | |
| 5 | // Test host codegen. |
| 6 | // RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64 |
| 7 | // RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s |
| 8 | // RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64 |
| 9 | // RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-32 |
| 10 | // RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s |
| 11 | // RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-32 |
| 12 | |
| 13 | // RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix SIMD-ONLY |
| 14 | // RUN: %clang_cc1 -DCK1 -fopenmp-simd -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s |
| 15 | // RUN: %clang_cc1 -DCK1 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix SIMD-ONLY |
| 16 | // RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix SIMD-ONLY |
| 17 | // RUN: %clang_cc1 -DCK1 -fopenmp-simd -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s |
| 18 | // RUN: %clang_cc1 -DCK1 -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix SIMD-ONLY |
| 19 | // SIMD-ONLY-NOT: {{__kmpc|__tgt}} |
| 20 | #ifdef CK1 |
| 21 | |
| 22 | template <typename T, int X, long long Y> |
| 23 | struct SS{ |
| 24 | T a[X]; |
| 25 | float b; |
| 26 | // CK1: define {{.*}}i32 @{{.+}}foo{{.+}}( |
| 27 | int foo(void) { |
| 28 | |
| 29 | // CK1: call i32 @__tgt_target_teams( |
| 30 | // CK1: call void @[[OFFL1:.+]]( |
| 31 | #pragma omp target teams distribute parallel for |
| 32 | for(int i = 0; i < X; i++) { |
| 33 | a[i] = (T)0; |
| 34 | } |
| 35 | // CK1: call i32 @__tgt_target_teams( |
| 36 | // CK1: call void @[[OFFL2:.+]]( |
| 37 | #pragma omp target teams distribute parallel for dist_schedule(static) |
| 38 | for(int i = 0; i < X; i++) { |
| 39 | a[i] = (T)0; |
| 40 | } |
| 41 | // CK1: call i32 @__tgt_target_teams( |
| 42 | // CK1: call void @[[OFFL3:.+]]( |
| 43 | #pragma omp target teams distribute parallel for dist_schedule(static, X/2) |
| 44 | for(int i = 0; i < X; i++) { |
| 45 | a[i] = (T)0; |
| 46 | } |
| 47 | // CK1: define internal void @[[OFFL1]]( |
| 48 | // CK1: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}} @[[OUTL1:.+]] to {{.+}}, |
| 49 | // CK1: ret void |
| 50 | |
| 51 | // CK1: define internal void @[[OUTL1]]({{.+}}) |
| 52 | // CK1: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 92 |
| 53 | // CK1: call void {{.*}} @__kmpc_fork_call({{.+}}, {{.+}}, {{.+}} @[[PAR_OUTL1:.+]] to |
| 54 | // CK1: call void @__kmpc_for_static_fini( |
| 55 | // CK1: ret void |
| 56 | |
| 57 | // CK1: define internal void @[[PAR_OUTL1]]({{.+}}) |
| 58 | // CK1: call void @__kmpc_for_static_init_4( |
| 59 | // CK1: call void @__kmpc_for_static_fini( |
| 60 | // CK1: ret void |
| 61 | |
| 62 | // CK1: define internal void @[[OFFL2]]( |
| 63 | // CK1: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}} @[[OUTL2:.+]] to {{.+}}, |
| 64 | // CK1: ret void |
| 65 | |
| 66 | // CK1: define internal void @[[OUTL2]]({{.+}}) |
| 67 | // CK1: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 92 |
| 68 | // CK1: call void {{.*}} @__kmpc_fork_call({{.+}}, {{.+}}, {{.+}} @[[PAR_OUTL2:.+]] to |
| 69 | // CK1: call void @__kmpc_for_static_fini( |
| 70 | // CK1: ret void |
| 71 | |
| 72 | // CK1: define internal void @[[PAR_OUTL2]]({{.+}}) |
| 73 | // CK1: call void @__kmpc_for_static_init_4( |
| 74 | // CK1: call void @__kmpc_for_static_fini( |
| 75 | // CK1: ret void |
| 76 | |
| 77 | |
| 78 | // CK1: define internal void @[[OFFL3]]( |
| 79 | // CK1: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}} @[[OUTL3:.+]] to {{.+}}, |
| 80 | // CK1: ret void |
| 81 | |
| 82 | // CK1: define internal void @[[OUTL3]]({{.+}}) |
| 83 | // CK1: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 91 |
| 84 | // CK1: call void {{.*}} @__kmpc_fork_call({{.+}}, {{.+}}, {{.+}} @[[PAR_OUTL3:.+]] to |
| 85 | // CK1: call void @__kmpc_for_static_fini( |
| 86 | // CK1: ret void |
| 87 | |
| 88 | // CK1: define internal void @[[PAR_OUTL3]]({{.+}}) |
| 89 | // CK1: call void @__kmpc_for_static_init_4( |
| 90 | // CK1: call void @__kmpc_for_static_fini( |
| 91 | // CK1: ret void |
| 92 | |
| 93 | return a[0]; |
| 94 | } |
| 95 | }; |
| 96 | |
| 97 | int teams_template_struct(void) { |
| 98 | SS<int, 123, 456> V; |
| 99 | return V.foo(); |
| 100 | |
| 101 | } |
| 102 | #endif // CK1 |
| 103 | |
| 104 | // Test host codegen. |
| 105 | // RUN: %clang_cc1 -DCK2 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CK2 --check-prefix CK2-64 |
| 106 | // RUN: %clang_cc1 -DCK2 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s |
| 107 | // RUN: %clang_cc1 -DCK2 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK2 --check-prefix CK2-64 |
| 108 | // RUN: %clang_cc1 -DCK2 -verify -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CK2 --check-prefix CK2-32 |
| 109 | // RUN: %clang_cc1 -DCK2 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s |
| 110 | // RUN: %clang_cc1 -DCK2 -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK2 --check-prefix CK2-32 |
| 111 | |
| 112 | // RUN: %clang_cc1 -DCK2 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix SIMD-ONLY |
| 113 | // RUN: %clang_cc1 -DCK2 -fopenmp-simd -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s |
| 114 | // RUN: %clang_cc1 -DCK2 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix SIMD-ONLY |
| 115 | // RUN: %clang_cc1 -DCK2 -verify -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix SIMD-ONLY |
| 116 | // RUN: %clang_cc1 -DCK2 -fopenmp-simd -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s |
| 117 | // RUN: %clang_cc1 -DCK2 -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix SIMD-ONLY |
| 118 | // SIMD-ONLY-NOT: {{__kmpc|__tgt}} |
| 119 | #ifdef CK2 |
| 120 | |
| 121 | template <typename T, int n> |
| 122 | int tmain(T argc) { |
| 123 | T a[n]; |
| 124 | int m = 10; |
| 125 | #pragma omp target teams distribute parallel for |
| 126 | for(int i = 0; i < n; i++) { |
| 127 | a[i] = (T)0; |
| 128 | } |
| 129 | #pragma omp target teams distribute parallel for dist_schedule(static) |
| 130 | for(int i = 0; i < n; i++) { |
| 131 | a[i] = (T)0; |
| 132 | } |
| 133 | #pragma omp target teams distribute parallel for dist_schedule(static, m) |
| 134 | for(int i = 0; i < n; i++) { |
| 135 | a[i] = (T)0; |
| 136 | } |
| 137 | return 0; |
| 138 | } |
| 139 | |
| 140 | int main (int argc, char **argv) { |
| 141 | int n = 100; |
| 142 | int a[n]; |
| 143 | int m = 10; |
| 144 | #pragma omp target teams distribute parallel for |
| 145 | for(int i = 0; i < n; i++) { |
| 146 | a[i] = 0; |
| 147 | } |
| 148 | #pragma omp target teams distribute parallel for dist_schedule(static) |
| 149 | for(int i = 0; i < n; i++) { |
| 150 | a[i] = 0; |
| 151 | } |
| 152 | #pragma omp target teams distribute parallel for dist_schedule(static, m) |
| 153 | for(int i = 0; i < n; i++) { |
| 154 | a[i] = 0; |
| 155 | } |
| 156 | return tmain<int, 10>(argc); |
| 157 | } |
| 158 | |
| 159 | // CK2: define {{.*}}i32 @{{[^,]+}}(i{{.+}}{{.+}} %[[ARGC:.+]], {{.+}}) |
| 160 | // CK2: call i32 @__tgt_target_teams( |
| 161 | // CK2: call void @[[OFFL1:.+]]({{.+}}) |
| 162 | // CK2: call i32 @__tgt_target_teams( |
| 163 | // CK2: call void @[[OFFL2:.+]]({{.+}}) |
| 164 | // CK2: call i32 @__tgt_target_teams( |
| 165 | // CK2: call void @[[OFFL3:.+]]({{.+}}) |
| 166 | // CK2: {{%.+}} = call{{.*}} i32 @[[TMAIN:.+]]({{.+}}) |
| 167 | // CK2: ret |
| 168 | |
| 169 | // CK2: define {{.*}}void @[[OFFL1]]({{.+}}) |
| 170 | // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 3, {{.+}} @[[OUTL1:.+]] to {{.+}}, |
| 171 | // CK2: ret void |
| 172 | |
| 173 | // CK2: define internal void @[[OUTL1]]({{.+}}) |
| 174 | // CK2: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 92 |
| 175 | // CK2: call void {{.*}} @__kmpc_fork_call({{.+}}, {{.+}}, {{.+}} @[[PAR_OUTL1:.+]] to |
| 176 | // CK2: call void @__kmpc_for_static_fini( |
| 177 | // CK2: ret void |
| 178 | |
| 179 | // CK2: define internal void @[[PAR_OUTL1]]({{.+}}) |
| 180 | // CK2: call void @__kmpc_for_static_init_4( |
| 181 | // CK2: call void @__kmpc_for_static_fini( |
| 182 | // CK2: ret void |
| 183 | |
| 184 | // CK2: define {{.*}}void @[[OFFL2]]({{.+}}) |
| 185 | // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 3, {{.+}} @[[OUTL2:.+]] to {{.+}}, |
| 186 | // CK2: ret void |
| 187 | |
| 188 | // CK2: define internal void @[[OUTL2]]({{.+}}) |
| 189 | // CK2: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 92 |
| 190 | // CK2: call void {{.*}} @__kmpc_fork_call({{.+}}, {{.+}}, {{.+}} @[[PAR_OUTL2:.+]] to |
| 191 | // CK2: call void @__kmpc_for_static_fini( |
| 192 | // CK2: ret void |
| 193 | |
| 194 | // CK2: define internal void @[[PAR_OUTL2]]({{.+}}) |
| 195 | // CK2: call void @__kmpc_for_static_init_4( |
| 196 | // CK2: call void @__kmpc_for_static_fini( |
| 197 | // CK2: ret void |
| 198 | |
| 199 | // CK2: define {{.*}}void @[[OFFL3]]({{.+}}) |
| 200 | // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 4, {{.+}} @[[OUTL3:.+]] to {{.+}}, |
| 201 | // CK2: ret void |
| 202 | |
| 203 | // CK2: define internal void @[[OUTL3]]({{.+}}) |
| 204 | // CK2: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 91 |
| 205 | // CK2: call void {{.*}} @__kmpc_fork_call({{.+}}, {{.+}}, {{.+}} @[[PAR_OUTL3:.+]] to |
| 206 | // CK2: call void @__kmpc_for_static_fini( |
| 207 | // CK2: ret void |
| 208 | |
| 209 | // CK2: define internal void @[[PAR_OUTL3]]({{.+}}) |
| 210 | // CK2: call void @__kmpc_for_static_init_4( |
| 211 | // CK2: call void @__kmpc_for_static_fini( |
| 212 | // CK2: ret void |
| 213 | |
| 214 | // CK2: define {{.*}}i32 @[[TMAIN]]({{.+}}) |
| 215 | // CK2: call i32 @__tgt_target_teams( |
| 216 | // CK2: call void @[[OFFLT1:.+]]({{.+}}) |
| 217 | // CK2: call i32 @__tgt_target_teams( |
| 218 | // CK2: call void @[[OFFLT2:.+]]({{.+}}) |
| 219 | // CK2: call i32 @__tgt_target_teams( |
| 220 | // CK2: call void @[[OFFLT3:.+]]({{.+}}) |
| 221 | // CK2: ret |
| 222 | // CK2-NEXT: } |
| 223 | |
| 224 | // CK2: define {{.*}}void @[[OFFLT1]]({{.+}}) |
| 225 | // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}} @[[OUTLT1:.+]] to {{.+}}, |
| 226 | // CK2: ret void |
| 227 | |
| 228 | // CK2: define internal void @[[OUTLT1]]({{.+}}) |
| 229 | // CK2: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 92 |
| 230 | // CK2: call void {{.*}} @__kmpc_fork_call({{.+}}, {{.+}}, {{.+}} @[[PAR_OUTLT1:.+]] to |
| 231 | // CK2: call void @__kmpc_for_static_fini( |
| 232 | // CK2: ret void |
| 233 | |
| 234 | // CK2: define internal void @[[PAR_OUTLT1]]({{.+}}) |
| 235 | // CK2: call void @__kmpc_for_static_init_4( |
| 236 | // CK2: call void @__kmpc_for_static_fini( |
| 237 | // CK2: ret void |
| 238 | |
| 239 | // CK2: define {{.*}}void @[[OFFLT2]]({{.+}}) |
| 240 | // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}} @[[OUTLT2:.+]] to {{.+}}, |
| 241 | // CK2: ret void |
| 242 | |
| 243 | // CK2: define internal void @[[OUTLT2]]({{.+}}) |
| 244 | // CK2: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 92 |
| 245 | // CK2: call void {{.*}} @__kmpc_fork_call({{.+}}, {{.+}}, {{.+}} @[[PAR_OUTLT2:.+]] to |
| 246 | // CK2: call void @__kmpc_for_static_fini( |
| 247 | // CK2: ret void |
| 248 | |
| 249 | // CK2: define internal void @[[PAR_OUTLT2]]({{.+}}) |
| 250 | // CK2: call void @__kmpc_for_static_init_4( |
| 251 | // CK2: call void @__kmpc_for_static_fini( |
| 252 | // CK2: ret void |
| 253 | |
| 254 | // CK2: define {{.*}}void @[[OFFLT3]]({{.+}}) |
| 255 | // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 {{.+}}, {{.+}} @[[OUTLT3:.+]] to {{.+}}, |
| 256 | // CK2: ret void |
| 257 | |
| 258 | // CK2: define internal void @[[OUTLT3]]({{.+}}) |
| 259 | // CK2: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 91 |
| 260 | // CK2: call void {{.*}} @__kmpc_fork_call({{.+}}, {{.+}}, {{.+}} @[[PAR_OUTLT3:.+]] to |
| 261 | // CK2: call void @__kmpc_for_static_fini( |
| 262 | // CK2: ret void |
| 263 | |
| 264 | // CK2: define internal void @[[PAR_OUTLT3]]({{.+}}) |
| 265 | // CK2: call void @__kmpc_for_static_init_4( |
| 266 | // CK2: call void @__kmpc_for_static_fini( |
| 267 | // CK2: ret void |
| 268 | |
| 269 | #endif // CK2 |
| 270 | #endif // #ifndef HEADER |
| 271 | |