Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion clang/include/clang/Basic/AttributeCommonInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,14 @@ class AttributeCommonInfo {
// FIXME: Eventually we want to do a list here populated via tablegen. But
// we want C++ attributes to be permissible on Lambdas, and get propagated
// to the call operator declaration.
return getParsedKind() == AT_SYCLIntelKernelArgsRestrict;
// FIXME: Attribute lambda capturing is not a part of SYCL 1.2.1. We shall
// check if a program is being compiled with -sycl-ext option.
auto ParsedAttr = getParsedKind();
if (ParsedAttr == AT_SYCLIntelKernelArgsRestrict ||
(ParsedAttr == AT_ReqdWorkGroupSize && isCXX11Attribute()))
return true;

return false;
}

bool isC2xAttribute() const { return SyntaxUsed == AS_C2x; }
Expand Down
5 changes: 5 additions & 0 deletions clang/test/CodeGenSYCL/reqd-work-group-size.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@ void bar() {

Functor f;
kernel<class kernel_name2>(f);

kernel<class kernel_name3>(
[]() [[cl::reqd_work_group_size(8, 8, 8)]] {});
}

// CHECK: define spir_kernel void @{{.*}}kernel_name1() {{.*}} !reqd_work_group_size ![[WGSIZE32:[0-9]+]]
// CHECK: define spir_kernel void @{{.*}}kernel_name2() {{.*}} !reqd_work_group_size ![[WGSIZE8:[0-9]+]]
// CHECK: define spir_kernel void @{{.*}}kernel_name3() {{.*}} !reqd_work_group_size ![[WGSIZE88:[0-9]+]]
// CHECK: ![[WGSIZE32]] = !{i32 32, i32 16, i32 16}
// CHECK: ![[WGSIZE8]] = !{i32 8, i32 1, i32 1}
// CHECK: ![[WGSIZE88]] = !{i32 8, i32 8, i32 8}

24 changes: 11 additions & 13 deletions clang/test/SemaSYCL/reqd-work-group-size.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,34 +77,30 @@ void bar() {
FunctorAttr fattr;
kernel<class kernel_name4>(fattr);

kernel<class kernel_name5>([]() [[cl::reqd_work_group_size(32, 32, 32)]] {
f32x32x32();
});


#ifdef TRIGGER_ERROR
Functor8 f8;
kernel<class kernel_name5>(f8);
kernel<class kernel_name6>(f8);

kernel<class kernel_name6>([]() { // expected-error {{conflicting attributes applied to a SYCL kernel}}
kernel<class kernel_name7>([]() { // expected-error {{conflicting attributes applied to a SYCL kernel}}
f4x1x1();
f32x1x1();
});

kernel<class kernel_name7>([]() { // expected-error {{conflicting attributes applied to a SYCL kernel}}
kernel<class kernel_name8>([]() { // expected-error {{conflicting attributes applied to a SYCL kernel}}
f16x1x1();
f16x16x1();
});

kernel<class kernel_name8>([]() { // expected-error {{conflicting attributes applied to a SYCL kernel}}
kernel<class kernel_name9>([]() { // expected-error {{conflicting attributes applied to a SYCL kernel}}
f32x32x32();
f32x32x1();
});

// Support for reqd_work_group_size (and other SYCL attributes) that apply to
// lambda expressions is not implemented in clang yet.
// When it lands, the following code is expected to compile successfully.
//
// expected-error@+1 {{'reqd_work_group_size' attribute cannot be applied to types}}
kernel<class kernel_name9>([]() [[cl::reqd_work_group_size(32, 32, 32)]] {
f32x32x32();
});
// While this case is not going to work (wrong syntax):
// expected-error@+1 {{expected variable name or 'this' in lambda capture list}}
kernel<class kernel_name10>([[cl::reqd_work_group_size(32, 32, 32)]] []() {
f32x32x32();
Expand All @@ -121,4 +117,6 @@ void bar() {
// CHECK: ReqdWorkGroupSizeAttr {{.*}} 16 16 16
// CHECK: FunctionDecl {{.*}} {{.*}}kernel_name4
// CHECK: ReqdWorkGroupSizeAttr {{.*}} 128 128 128
// CHECK: FunctionDecl {{.*}} {{.*}}kernel_name5
// CHECK: ReqdWorkGroupSizeAttr {{.*}} 32 32 32
#endif // __SYCL_DEVICE_ONLY__