Skip to content

Commit b77e5b7

Browse files
MrSidimsbader
authored andcommitted
[SYCL] Fix kernel attribute codegen (#896)
It was failed to process correctly a case of multiple attributes attached to a SYCL kernel. Signed-off-by: Dmitry Sidorov <[email protected]>
1 parent 59f4592 commit b77e5b7

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,9 @@ class MarkDeviceFunction : public RecursiveASTVisitor<MarkDeviceFunction> {
426426

427427
if (auto *A = FD->getAttr<IntelReqdSubGroupSizeAttr>())
428428
Attrs.insert(A);
429-
else if (auto *A = FD->getAttr<ReqdWorkGroupSizeAttr>())
429+
if (auto *A = FD->getAttr<ReqdWorkGroupSizeAttr>())
430430
Attrs.insert(A);
431-
else if (auto *A = FD->getAttr<SYCLIntelKernelArgsRestrictAttr>()) {
431+
if (auto *A = FD->getAttr<SYCLIntelKernelArgsRestrictAttr>()) {
432432
// Allow the intel::kernel_args_restrict only on the lambda (function
433433
// object) function, that is called directly from a kernel (i.e. the one
434434
// passed to the parallel_for function). Emit a warning and ignore all
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %clang_cc1 -std=c++11 -triple spir64-unknown-unknown-sycldevice -disable-llvm-passes -fsycl-is-device -emit-llvm -o - %s | FileCheck %s
2+
3+
class Functor {
4+
public:
5+
[[cl::intel_reqd_sub_group_size(4), cl::reqd_work_group_size(32, 16, 16)]] void operator()() {}
6+
};
7+
8+
9+
template <typename Name, typename Func>
10+
__attribute__((sycl_kernel)) void kernel(Func kernelFunc) {
11+
kernelFunc();
12+
}
13+
14+
void bar() {
15+
Functor foo;
16+
kernel<class kernel_name>(foo);
17+
}
18+
19+
// CHECK: define spir_kernel void @{{.*}}kernel_name() {{.*}} !reqd_work_group_size ![[WGSIZE:[0-9]+]] !intel_reqd_sub_group_size ![[SGSIZE:[0-9]+]]
20+
// CHECK: ![[WGSIZE]] = !{i32 32, i32 16, i32 16}
21+
// CHECK: ![[SGSIZE]] = !{i32 4}

0 commit comments

Comments
 (0)