1 // REQUIRES: amdgpu-registered-target 2 3 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-ppc-host.bc 4 // RUN: %clang_cc1 -fopenmp -x c++ -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 -o - | FileCheck %s --check-prefix=AMD 5 // RUN: %clang_cc1 -target-cpu gfx900 -fopenmp -x c++ -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 -o - | FileCheck %s --check-prefix=AMD 6 // RUN: %clang_cc1 -target-cpu gfx900 -fopenmp -x c++ -std=c++11 -triple amdgcn-amd-amdhsa -fopenmp-targets=amdgcn-amd-amdhsa -dwarf-version=5 -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix=AMD 7 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple nvptx64 -fopenmp-targets=nvptx64 -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix=NVIDIA 8 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple nvptx64 -fopenmp-targets=nvptx64 -emit-llvm %s -fopenmp-is-target-device -dwarf-version=5 -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix=NVIDIA 9 // expected-no-diagnostics 10 11 12 // Check that the target attributes are set on the generated kernel 13 void func() { 14 // AMD: amdgpu_kernel void @__omp_offloading[[HASH:.*]]_l18(ptr {{[^,]+}}) #0 15 // AMD: amdgpu_kernel void @__omp_offloading[[HASH:.*]]_l20(ptr {{[^,]+}}) 16 // AMD: amdgpu_kernel void @__omp_offloading[[HASH:.*]]_l22(ptr {{[^,]+}}) #4 17 18 #pragma omp target ompx_attribute([[clang::amdgpu_flat_work_group_size(10, 20)]]) 19 {} 20 #pragma omp target teams ompx_attribute(__attribute__((launch_bounds(45, 90)))) 21 {} 22 #pragma omp target teams distribute parallel for simd ompx_attribute([[clang::amdgpu_flat_work_group_size(3, 17)]]) device(3) ompx_attribute(__attribute__((amdgpu_waves_per_eu(3, 7)))) 23 for (int i = 0; i < 1000; ++i) 24 {} 25 } 26 27 // AMD: attributes #0 28 // AMD-SAME: "amdgpu-flat-work-group-size"="10,20" 29 // AMD-SAME: "omp_target_thread_limit"="20" 30 // AMD: "omp_target_thread_limit"="45" 31 // AMD: attributes #4 32 // AMD-SAME: "amdgpu-flat-work-group-size"="3,17" 33 // AMD-SAME: "amdgpu-waves-per-eu"="3,7" 34 // AMD-SAME: "omp_target_thread_limit"="17" 35 36 // It is unclear if we should use the AMD annotations for other targets, we do for now. 37 // NVIDIA: "omp_target_thread_limit"="20" 38 // NVIDIA: "omp_target_thread_limit"="45" 39 // NVIDIA: "omp_target_thread_limit"="17" 40 // NVIDIA: !{ptr @__omp_offloading[[HASH1:.*]]_l18, !"maxntidx", i32 20} 41 // NVIDIA: !{ptr @__omp_offloading[[HASH2:.*]]_l20, !"maxntidx", i32 45} 42 // NVIDIA: !{ptr @__omp_offloading[[HASH3:.*]]_l22, !"maxntidx", i32 17} 43