| 1 |
// 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 |
| 2 |
// RUN: %clang_cc1 -fopenmp -x c++ -w -std=c++11 -triple amdgcn-amd-amdhsa -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -target-cpu gfx906 -o - | FileCheck %s |
| 3 |
// RUN: %clang_cc1 -fopenmp -x c++ -w -std=c++11 -triple x86_64-unknown-unknown -fopenmp-targets=spirv64-intel -emit-llvm-bc %s -o %t-ppc-spirv-host.bc |
| 4 |
// RUN: %clang_cc1 -fopenmp -x c++ -w -std=c++11 -triple spirv64-intel -fopenmp-targets=spirv64-intel -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-spirv-host.bc -o - | FileCheck %s |
| 5 |
// expected-no-diagnostics |
| 6 |
|
| 7 |
|
| 8 |
/*===-----------------------------------------------------------------------=== |
| 9 |
|
| 10 |
Inspired from SOLLVE tests: |
| 11 |
- 5.0/metadirective/test_metadirective_arch_is_nvidia.c |
| 12 |
|
| 13 |
|
| 14 |
===------------------------------------------------------------------------===*/ |
| 15 |
|
| 16 |
|
| 17 |
#define N 1024 |
| 18 |
|
| 19 |
#ifdef __AMDGPU__ |
| 20 |
#define GPU "amdgcn" |
| 21 |
#else |
| 22 |
#define GPU "spirv64" |
| 23 |
#endif |
| 24 |
|
| 25 |
int metadirective1() { |
| 26 |
|
| 27 |
int v1[N], v2[N], v3[N]; |
| 28 |
|
| 29 |
int target_device_num, host_device_num, default_device; |
| 30 |
int errors = 0; |
| 31 |
|
| 32 |
#pragma omp target map(to:v1,v2) map(from:v3, target_device_num) device(default_device) |
| 33 |
{ |
| 34 |
#pragma omp metadirective \ |
| 35 |
when(device={arch(GPU)}: teams distribute parallel for) \ |
| 36 |
default(parallel for) |
| 37 |
|
| 38 |
for (int i = 0; i < N; i++) { |
| 39 |
#pragma omp atomic write |
| 40 |
v3[i] = v1[i] * v2[i]; |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
return errors; |
| 45 |
} |
| 46 |
|
| 47 |
// CHECK: define weak_odr protected {{amdgpu|spir}}_kernel void @[[METADIRECTIVE:.+metadirective1[a-z0-9_]+]] |
| 48 |
// CHECK: entry: |
| 49 |
// CHECK: %{{[0-9]}} = call{{.*}} i32 @__kmpc_target_init |
| 50 |
// CHECK: user_code.entry: |
| 51 |
// CHECK: call{{.*}} void @[[METADIRECTIVE]]_omp_outlined |
| 52 |
// CHECK-NOT: call{{.*}} void @__kmpc_parallel_60 |
| 53 |
// CHECK: ret void |
| 54 |
|
| 55 |
|
| 56 |
// CHECK: define internal void @[[METADIRECTIVE]]_omp_outlined |
| 57 |
// CHECK: entry: |
| 58 |
// CHECK: call{{.*}} void @__kmpc_distribute_static_init |
| 59 |
// CHECK: omp.loop.exit: |
| 60 |
// CHECK: call{{.*}} void @__kmpc_distribute_static_fini |
| 61 |
|
| 62 |
|
| 63 |
// CHECK: define internal void @[[METADIRECTIVE]]_omp_outlined_omp_outlined |
| 64 |
// CHECK: entry: |
| 65 |
// CHECK: call{{.*}} void @__kmpc_for_static_init_4 |
| 66 |
// CHECK: omp.inner.for.body: |
| 67 |
// CHECK: store atomic {{.*}} monotonic |
| 68 |
// CHECK: omp.loop.exit: |
| 69 |
// CHECK-NEXT: call{{.*}} void @__kmpc_for_static_fini |
| 70 |
// CHECK-NEXT: ret void |
| 71 |
|