Skip to content

Commit 179b25e

Browse files
committed
Updates to address code review feedback from Mariya Podchishchaeva and Alexey Bader.
- Corrected a misleading comment. - Corrected inconsistent naming style in a test. - Expanded a test to exercise 32-bit and 64-bit SPIR, SPIR-V, and NVPTX.
1 parent 606c9f3 commit 179b25e

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

clang/lib/CodeGen/CodeGenTypes.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,9 @@ class CodeGenTypes {
229229
const CGFunctionInfo &arrangeBuiltinFunctionCall(QualType resultType,
230230
const CallArgList &args);
231231

232-
/// A SYCL device kernel function is a free standing function with
233-
/// spir_kernel calling convention
232+
/// A SYCL kernel caller function is an offload device entry point function
233+
/// with a target device dependent calling convention such as amdgpu_kernel,
234+
/// ptx_kernel, or spir_kernel.
234235
const CGFunctionInfo &
235236
arrangeSYCLKernelCallerDeclaration(QualType resultType,
236237
const FunctionArgList &args);

clang/test/CodeGenSYCL/kernel-caller-entry-point.cpp

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
11
// RUN: %clang_cc1 -fsycl-is-host -emit-llvm -triple x86_64-unknown-linux-gnu %s -o - | FileCheck --check-prefixes=CHECK-HOST,CHECK-HOST-LINUX %s
2-
// RUN: %clang_cc1 -fsycl-is-device -emit-llvm -aux-triple x86_64-unknown-linux-gnu -triple amdgcn %s -o - | FileCheck --check-prefixes=CHECK-DEVICE,CHECK-AMDGCN %s
3-
// RUN: %clang_cc1 -fsycl-is-device -emit-llvm -aux-triple x86_64-unknown-linux-gnu -triple nvptx %s -o - | FileCheck --check-prefixes=CHECK-DEVICE,CHECK-NVPTX %s
4-
// RUN: %clang_cc1 -fsycl-is-device -emit-llvm -aux-triple x86_64-unknown-linux-gnu -triple spir64 %s -o - | FileCheck --check-prefixes=CHECK-DEVICE,CHECK-SPIR %s
2+
// RUN: %clang_cc1 -fsycl-is-device -emit-llvm -aux-triple x86_64-unknown-linux-gnu -triple amdgcn-amd-amdhsa %s -o - | FileCheck --check-prefixes=CHECK-DEVICE,CHECK-AMDGCN %s
3+
// RUN: %clang_cc1 -fsycl-is-device -emit-llvm -aux-triple x86_64-unknown-linux-gnu -triple nvptx-nvidia-cuda %s -o - | FileCheck --check-prefixes=CHECK-DEVICE,CHECK-NVPTX %s
4+
// RUN: %clang_cc1 -fsycl-is-device -emit-llvm -aux-triple x86_64-unknown-linux-gnu -triple nvptx64-nvidia-cuda %s -o - | FileCheck --check-prefixes=CHECK-DEVICE,CHECK-NVPTX %s
5+
// RUN: %clang_cc1 -fsycl-is-device -emit-llvm -aux-triple x86_64-unknown-linux-gnu -triple spir-unknown-unknown %s -o - | FileCheck --check-prefixes=CHECK-DEVICE,CHECK-SPIR %s
6+
// RUN: %clang_cc1 -fsycl-is-device -emit-llvm -aux-triple x86_64-unknown-linux-gnu -triple spir64-unknown-unknown %s -o - | FileCheck --check-prefixes=CHECK-DEVICE,CHECK-SPIR %s
7+
// RUN: %clang_cc1 -fsycl-is-device -emit-llvm -aux-triple x86_64-unknown-linux-gnu -triple spirv32-unknown-unknown %s -o - | FileCheck --check-prefixes=CHECK-DEVICE,CHECK-SPIR %s
8+
// RUN: %clang_cc1 -fsycl-is-device -emit-llvm -aux-triple x86_64-unknown-linux-gnu -triple spirv64-unknown-unknown %s -o - | FileCheck --check-prefixes=CHECK-DEVICE,CHECK-SPIR %s
59
// RUN: %clang_cc1 -fsycl-is-host -emit-llvm -triple x86_64-pc-windows-msvc %s -o - | FileCheck --check-prefixes=CHECK-HOST,CHECK-HOST-WINDOWS %s
6-
// RUN: %clang_cc1 -fsycl-is-device -emit-llvm -aux-triple x86_64-pc-windows-msvc -triple amdgcn %s -o - | FileCheck --check-prefixes=CHECK-DEVICE,CHECK-AMDGCN %s
7-
// RUN: %clang_cc1 -fsycl-is-device -emit-llvm -aux-triple x86_64-pc-windows-msvc -triple nvptx %s -o - | FileCheck --check-prefixes=CHECK-DEVICE,CHECK-NVPTX %s
8-
// RUN: %clang_cc1 -fsycl-is-device -emit-llvm -aux-triple x86_64-pc-windows-msvc -triple spir64 %s -o - | FileCheck --check-prefixes=CHECK-DEVICE,CHECK-SPIR %s
10+
// RUN: %clang_cc1 -fsycl-is-device -emit-llvm -aux-triple x86_64-pc-windows-msvc -triple amdgcn-amd-amdhsa %s -o - | FileCheck --check-prefixes=CHECK-DEVICE,CHECK-AMDGCN %s
11+
// RUN: %clang_cc1 -fsycl-is-device -emit-llvm -aux-triple x86_64-pc-windows-msvc -triple nvptx-nvidia-cuda %s -o - | FileCheck --check-prefixes=CHECK-DEVICE,CHECK-NVPTX %s
12+
// RUN: %clang_cc1 -fsycl-is-device -emit-llvm -aux-triple x86_64-pc-windows-msvc -triple nvptx64-nvidia-cuda %s -o - | FileCheck --check-prefixes=CHECK-DEVICE,CHECK-NVPTX %s
13+
// RUN: %clang_cc1 -fsycl-is-device -emit-llvm -aux-triple x86_64-pc-windows-msvc -triple spir-unknown-unknown %s -o - | FileCheck --check-prefixes=CHECK-DEVICE,CHECK-SPIR %s
14+
// RUN: %clang_cc1 -fsycl-is-device -emit-llvm -aux-triple x86_64-pc-windows-msvc -triple spir64-unknown-unknown %s -o - | FileCheck --check-prefixes=CHECK-DEVICE,CHECK-SPIR %s
15+
// RUN: %clang_cc1 -fsycl-is-device -emit-llvm -aux-triple x86_64-pc-windows-msvc -triple spirv32-unknown-unknown %s -o - | FileCheck --check-prefixes=CHECK-DEVICE,CHECK-SPIR %s
16+
// RUN: %clang_cc1 -fsycl-is-device -emit-llvm -aux-triple x86_64-pc-windows-msvc -triple spirv64-unknown-unknown %s -o - | FileCheck --check-prefixes=CHECK-DEVICE,CHECK-SPIR %s
917

1018
// Test the generation of SYCL kernel caller functions. These functions are
1119
// generated from functions declared with the sycl_kernel_entry_point attribute
1220
// and emited during device compilation. They are not emitted during device
1321
// compilation.
1422

15-
template <typename name, typename Func>
16-
__attribute__((sycl_kernel_entry_point(name))) void kernel_single_task(const Func kernelFunc) {
23+
template <typename KernelName, typename KernelType>
24+
[[clang::sycl_kernel_entry_point(KernelName)]]
25+
void kernel_single_task(KernelType kernelFunc) {
1726
kernelFunc();
1827
}
1928

@@ -22,7 +31,7 @@ struct single_purpose_kernel {
2231
void operator()() const {}
2332
};
2433

25-
__attribute__((sycl_kernel_entry_point(single_purpose_kernel_name)))
34+
[[clang::sycl_kernel_entry_point(single_purpose_kernel_name)]]
2635
void single_purpose_kernel_task(single_purpose_kernel kernelFunc) {
2736
kernelFunc();
2837
}
@@ -89,7 +98,7 @@ int main() {
8998
// FIXME: main(). main() shouldn't be emitted in device code, but that pruning
9099
// FIXME: isn't performed yet.
91100
// CHECK-DEVICE: Function Attrs: convergent mustprogress noinline norecurse nounwind optnone
92-
// CHECK-DEVICE-NEXT: define dso_local noundef i32 @main() #0
101+
// CHECK-DEVICE-NEXT: define {{[a-z_ ]*}}noundef i32 @main() #0
93102

94103
// IR for the SYCL kernel caller function generated for
95104
// single_purpose_kernel_task with single_purpose_kernel_name as the SYCL kernel
@@ -119,7 +128,7 @@ int main() {
119128
// CHECK-NVPTX: define linkonce_odr void @_ZNK21single_purpose_kernelclEv
120129
//
121130
// CHECK-SPIR: Function Attrs: convergent mustprogress noinline norecurse nounwind optnone
122-
// CHECK-SPIR-NEXT: define dso_local spir_kernel void @_ZTS26single_purpose_kernel_name
131+
// CHECK-SPIR-NEXT: define {{[a-z_ ]*}}spir_kernel void @_ZTS26single_purpose_kernel_name
123132
// CHECK-SPIR-SAME: (ptr noundef byval(%struct.single_purpose_kernel) align 1 %kernelFunc) #[[SPIR_ATTR0:[0-9]+]] {
124133
// CHECK-SPIR-NEXT: entry:
125134
// CHECK-SPIR-NEXT: %kernelFunc.ascast = addrspacecast ptr %kernelFunc to ptr addrspace(4)
@@ -157,7 +166,7 @@ int main() {
157166
// CHECK-NVPTX: define internal void @_ZZ4mainENKUlvE_clEv
158167
//
159168
// CHECK-SPIR: Function Attrs: convergent mustprogress noinline norecurse nounwind optnone
160-
// CHECK-SPIR-NEXT: define dso_local spir_kernel void @_ZTSZ4mainE18lambda_kernel_name
169+
// CHECK-SPIR-NEXT: define {{[a-z_ ]*}}spir_kernel void @_ZTSZ4mainE18lambda_kernel_name
161170
// CHECK-SPIR-SAME: (ptr noundef byval(%class.anon) align 4 %kernelFunc) #[[SPIR_ATTR0]] {
162171
// CHECK-SPIR-NEXT: entry:
163172
// CHECK-SPIR-NEXT: %kernelFunc.ascast = addrspacecast ptr %kernelFunc to ptr addrspace(4)

0 commit comments

Comments
 (0)