2018-03-01 04:48:35 +08:00
|
|
|
// Test target codegen - host bc file has to be created first.
|
|
|
|
// 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
|
|
|
|
// 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
|
|
|
|
// 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
|
|
|
|
// 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
|
|
|
|
// 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
|
2020-08-28 02:50:34 +08:00
|
|
|
|
|
|
|
// 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
|
|
|
|
// 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
|
|
|
|
// 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
|
|
|
|
// 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
|
|
|
|
// 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
|
|
|
|
|
2018-03-01 04:48:35 +08:00
|
|
|
// expected-no-diagnostics
|
|
|
|
#ifndef HEADER
|
|
|
|
#define HEADER
|
|
|
|
|
2018-05-12 03:45:14 +08:00
|
|
|
// Check that the execution mode of all 2 target regions on the gpu is set to NonSPMD Mode.
|
2020-08-28 02:50:34 +08:00
|
|
|
// CHECK-DAG: {{@__omp_offloading_.+l37}}_exec_mode = weak constant i8 0
|
|
|
|
// CHECK-DAG: {{@__omp_offloading_.+l43}}_exec_mode = weak constant i8 0
|
|
|
|
// CHECK-DAG: {{@__omp_offloading_.+l48}}_exec_mode = weak constant i8 0
|
|
|
|
// CHECK-DAG: {{@__omp_offloading_.+l53}}_exec_mode = weak constant i8 0
|
2018-03-01 04:48:35 +08:00
|
|
|
|
|
|
|
#define N 1000
|
|
|
|
#define M 10
|
|
|
|
|
|
|
|
template<typename tx>
|
|
|
|
tx ftemplate(int n) {
|
|
|
|
tx a[N];
|
|
|
|
short aa[N];
|
|
|
|
tx b[10];
|
2019-04-18 00:53:08 +08:00
|
|
|
tx c[M][M];
|
2018-03-01 04:48:35 +08:00
|
|
|
tx f = n;
|
|
|
|
tx l;
|
|
|
|
int k;
|
|
|
|
|
|
|
|
#pragma omp target teams distribute simd lastprivate(l) dist_schedule(static,128)
|
|
|
|
for(int i = 0; i < n; i++) {
|
|
|
|
a[i] = 1;
|
|
|
|
l = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma omp target teams distribute simd map(tofrom: aa) num_teams(M) thread_limit(64)
|
|
|
|
for(int i = 0; i < n; i++) {
|
|
|
|
aa[i] += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma omp target teams distribute simd map(tofrom:a, aa, b) if(target: n>40)
|
|
|
|
for(int i = 0; i < 10; i++) {
|
|
|
|
b[i] += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma omp target teams distribute simd collapse(2) firstprivate(f) private(k)
|
|
|
|
for(int i = 0; i < M; i++) {
|
|
|
|
for(int j = 0; j < M; j++) {
|
|
|
|
k = M;
|
2019-04-18 00:53:08 +08:00
|
|
|
c[i][j] = i + j * f + k;
|
2018-03-01 04:48:35 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return a[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
int bar(int n){
|
|
|
|
int a = 0;
|
|
|
|
|
|
|
|
a += ftemplate<int>(n);
|
|
|
|
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
2020-08-28 02:50:34 +08:00
|
|
|
// CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+}}_l37(
|
2020-10-05 20:59:26 +08:00
|
|
|
// CHECK: call void @__kmpc_spmd_kernel_init(i32 %{{.+}}, i16 0)
|
2019-05-21 23:11:58 +08:00
|
|
|
// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(i16 0)
|
|
|
|
|
2018-03-01 04:48:35 +08:00
|
|
|
// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91,
|
|
|
|
// CHECK: call void @__kmpc_for_static_fini(
|
|
|
|
// CHECK: ret void
|
|
|
|
|
2020-08-28 02:50:34 +08:00
|
|
|
// CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+}}_l43(
|
2020-10-05 20:59:26 +08:00
|
|
|
// CHECK: call void @__kmpc_spmd_kernel_init(i32 %{{.+}}, i16 0)
|
2019-05-21 23:11:58 +08:00
|
|
|
// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(i16 0)
|
|
|
|
|
2019-04-18 00:53:08 +08:00
|
|
|
// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91,
|
2018-03-01 04:48:35 +08:00
|
|
|
// CHECK: call void @__kmpc_for_static_fini(
|
|
|
|
// CHECK: ret void
|
|
|
|
|
2020-08-28 02:50:34 +08:00
|
|
|
// CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+}}_l48(
|
2020-10-05 20:59:26 +08:00
|
|
|
// CHECK: call void @__kmpc_spmd_kernel_init(i32 %{{.+}}, i16 0)
|
2019-05-21 23:11:58 +08:00
|
|
|
// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(i16 0)
|
|
|
|
|
2019-04-18 00:53:08 +08:00
|
|
|
// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91,
|
2018-03-01 04:48:35 +08:00
|
|
|
// CHECK: call void @__kmpc_for_static_fini(
|
|
|
|
// CHECK: ret void
|
|
|
|
|
2020-08-28 02:50:34 +08:00
|
|
|
// CHECK: define {{.*}}void {{@__omp_offloading_.+}}_l53({{.+}}, i{{32|64}} [[F_IN:%.+]])
|
2018-03-01 04:48:35 +08:00
|
|
|
// CHECK: store {{.+}} [[F_IN]], {{.+}}* {{.+}},
|
2020-10-05 20:59:26 +08:00
|
|
|
// CHECK: call void @__kmpc_spmd_kernel_init(i32 %{{.+}}, i16 0)
|
2019-05-21 23:11:58 +08:00
|
|
|
// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(i16 0)
|
|
|
|
|
2018-03-01 04:48:35 +08:00
|
|
|
// CHECK: store {{.+}} 99, {{.+}}* [[COMB_UB:%.+]], align
|
2019-04-18 00:53:08 +08:00
|
|
|
// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91, {{.+}}, {{.+}}, {{.+}}* [[COMB_UB]],
|
2018-03-01 04:48:35 +08:00
|
|
|
// CHECK: call void @__kmpc_for_static_fini(
|
|
|
|
// CHECK: ret void
|
|
|
|
|
|
|
|
#endif
|