1 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa \
2 // RUN: -fcuda-is-device -emit-llvm -o - -x hip %s \
3 // RUN: | FileCheck -check-prefixes=CHECK,DEFAULT %s
4 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa --gpu-max-threads-per-block=1024 \
5 // RUN: -fcuda-is-device -emit-llvm -o - -x hip %s \
6 // RUN: | FileCheck -check-prefixes=CHECK,MAX1024 %s
7 // RUN: %clang_cc1 -triple nvptx \
8 // RUN: -fcuda-is-device -emit-llvm -o - %s | FileCheck %s \
9 // RUN: -check-prefix=NAMD
10 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm \
11 // RUN: -verify -o - -x hip %s | FileCheck -check-prefix=NAMD %s
13 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -foffload-uniform-block \
14 // RUN: -fcuda-is-device -emit-llvm -o - -x hip %s \
15 // RUN: | FileCheck -check-prefixes=CHECK,DEFAULT %s
16 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fno-offload-uniform-block \
17 // RUN: -fcuda-is-device -emit-llvm -o - -x hip %s \
18 // RUN: | FileCheck -check-prefixes=NOUB %s
20 #include "Inputs/cuda.h"
22 __global__ void flat_work_group_size_default() {
23 // CHECK: define{{.*}} amdgpu_kernel void @_Z28flat_work_group_size_defaultv() [[FLAT_WORK_GROUP_SIZE_DEFAULT:#[0-9]+]]
24 // NOUB: define{{.*}} void @_Z28flat_work_group_size_defaultv() [[NOUB:#[0-9]+]]
27 __attribute__((amdgpu_flat_work_group_size(32, 64))) // expected-no-diagnostics
28 __global__ void flat_work_group_size_32_64() {
29 // CHECK: define{{.*}} amdgpu_kernel void @_Z26flat_work_group_size_32_64v() [[FLAT_WORK_GROUP_SIZE_32_64:#[0-9]+]]
31 __attribute__((amdgpu_waves_per_eu(2))) // expected-no-diagnostics
32 __global__ void waves_per_eu_2() {
33 // CHECK: define{{.*}} amdgpu_kernel void @_Z14waves_per_eu_2v() [[WAVES_PER_EU_2:#[0-9]+]]
35 __attribute__((amdgpu_num_sgpr(32))) // expected-no-diagnostics
36 __global__ void num_sgpr_32() {
37 // CHECK: define{{.*}} amdgpu_kernel void @_Z11num_sgpr_32v() [[NUM_SGPR_32:#[0-9]+]]
39 __attribute__((amdgpu_num_vgpr(64))) // expected-no-diagnostics
40 __global__ void num_vgpr_64() {
41 // CHECK: define{{.*}} amdgpu_kernel void @_Z11num_vgpr_64v() [[NUM_VGPR_64:#[0-9]+]]
43 __attribute__((amdgpu_max_num_work_groups(32, 4, 2))) // expected-no-diagnostics
44 __global__ void max_num_work_groups_32_4_2() {
45 // CHECK: define{{.*}} amdgpu_kernel void @_Z26max_num_work_groups_32_4_2v() [[MAX_NUM_WORK_GROUPS_32_4_2:#[0-9]+]]
47 __attribute__((amdgpu_max_num_work_groups(32))) // expected-no-diagnostics
48 __global__ void max_num_work_groups_32() {
49 // CHECK: define{{.*}} amdgpu_kernel void @_Z22max_num_work_groups_32v() [[MAX_NUM_WORK_GROUPS_32_1_1:#[0-9]+]]
51 __attribute__((amdgpu_max_num_work_groups(32,1))) // expected-no-diagnostics
52 __global__ void max_num_work_groups_32_1() {
53 // CHECK: define{{.*}} amdgpu_kernel void @_Z24max_num_work_groups_32_1v() [[MAX_NUM_WORK_GROUPS_32_1_1:#[0-9]+]]
59 __attribute__((amdgpu_max_num_work_groups(a, 4, 2)))
60 __global__ void template_a_4_2_max_num_work_groups() {}
61 template __global__ void template_a_4_2_max_num_work_groups<32>();
62 // CHECK: define{{.*}} amdgpu_kernel void @_Z34template_a_4_2_max_num_work_groupsILj32EEvv() [[MAX_NUM_WORK_GROUPS_32_4_2:#[0-9]+]]
65 __attribute__((amdgpu_max_num_work_groups(32, a, 2)))
66 __global__ void template_32_a_2_max_num_work_groups() {}
67 template __global__ void template_32_a_2_max_num_work_groups<4>();
68 // CHECK: define{{.*}} amdgpu_kernel void @_Z35template_32_a_2_max_num_work_groupsILj4EEvv() [[MAX_NUM_WORK_GROUPS_32_4_2:#[0-9]+]]
71 __attribute__((amdgpu_max_num_work_groups(32, 4, a)))
72 __global__ void template_32_4_a_max_num_work_groups() {}
73 template __global__ void template_32_4_a_max_num_work_groups<2>();
74 // CHECK: define{{.*}} amdgpu_kernel void @_Z35template_32_4_a_max_num_work_groupsILj2EEvv() [[MAX_NUM_WORK_GROUPS_32_4_2:#[0-9]+]]
76 // Make sure this is silently accepted on other targets.
77 // NAMD-NOT: "amdgpu-flat-work-group-size"
78 // NAMD-NOT: "amdgpu-waves-per-eu"
79 // NAMD-NOT: "amdgpu-num-vgpr"
80 // NAMD-NOT: "amdgpu-num-sgpr"
81 // NAMD-NOT: "amdgpu-max-num-work-groups"
83 // DEFAULT-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = {{.*}}"amdgpu-flat-work-group-size"="1,1024"{{.*}}"uniform-work-group-size"="true"
84 // MAX1024-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = {{.*}}"amdgpu-flat-work-group-size"="1,1024"
85 // CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = {{.*}}"amdgpu-flat-work-group-size"="32,64"
86 // CHECK-DAG: attributes [[WAVES_PER_EU_2]] = {{.*}}"amdgpu-waves-per-eu"="2"
87 // CHECK-DAG: attributes [[NUM_SGPR_32]] = {{.*}}"amdgpu-num-sgpr"="32"
88 // CHECK-DAG: attributes [[NUM_VGPR_64]] = {{.*}}"amdgpu-num-vgpr"="64"
89 // CHECK-DAG: attributes [[MAX_NUM_WORK_GROUPS_32_4_2]] = {{.*}}"amdgpu-max-num-workgroups"="32,4,2"
90 // CHECK-DAG: attributes [[MAX_NUM_WORK_GROUPS_32_1_1]] = {{.*}}"amdgpu-max-num-workgroups"="32,1,1"
92 // NOUB-NOT: "uniform-work-group-size"="true"