Skip to content

Commit e1b4202

Browse files
[ESIMD] Add CXX11-style [[intel::sycl_explicit_simd]] attribute (#3254)
This patch enables CXX11-style sycl_explicit_simd attribute to conform to the ESIMD specification. This fixes #3229.
1 parent e8965db commit e1b4202

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

clang/include/clang/Basic/Attr.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,8 @@ def SYCLKernel : InheritableAttr {
11811181
// e.g. because the function is already vectorized. Used to mark SYCL
11821182
// explicit SIMD kernels and functions.
11831183
def SYCLSimd : InheritableAttr {
1184-
let Spellings = [GNU<"sycl_explicit_simd">];
1184+
let Spellings = [GNU<"sycl_explicit_simd">,
1185+
CXX11<"intel", "sycl_explicit_simd">];
11851186
let Subjects = SubjectList<[Function]>;
11861187
let LangOpts = [SYCLExplicitSIMD];
11871188
let Documentation = [SYCLSimdDocs];

clang/include/clang/Basic/AttributeCommonInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class AttributeCommonInfo {
167167
ParsedAttr == AT_SYCLIntelMaxGlobalWorkDim ||
168168
ParsedAttr == AT_SYCLIntelNoGlobalWorkOffset ||
169169
ParsedAttr == AT_SYCLIntelUseStallEnableClusters ||
170-
ParsedAttr == AT_SYCLIntelLoopFuse)
170+
ParsedAttr == AT_SYCLIntelLoopFuse || ParsedAttr == AT_SYCLSimd)
171171
return true;
172172

173173
return false;

clang/test/CodeGenSYCL/esimd_metadata1.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ void kernel(const Func &f) __attribute__((sycl_kernel)) {
1616
void bar() {
1717
kernel<class MyKernel>([=]() __attribute__((sycl_explicit_simd)){});
1818
// CHECK: define {{.*}}spir_kernel void @_ZTSZ3barvE8MyKernel() {{.*}} !sycl_explicit_simd ![[EMPTY:[0-9]+]] !intel_reqd_sub_group_size ![[REQD_SIZE:[0-9]+]]
19+
20+
kernel<class MyEsimdKernel>([=]() [[intel::sycl_explicit_simd]]{});
21+
// CHECK: define {{.*}}spir_kernel void @_ZTSZ3barvE13MyEsimdKernel() {{.*}} !sycl_explicit_simd ![[EMPTY:[0-9]+]] !intel_reqd_sub_group_size ![[REQD_SIZE]]
1922
}
2023

2124
// CHECK: !spirv.Source = !{[[LANG:![0-9]+]]}

clang/test/SemaSYCL/sycl-esimd.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,31 @@ struct Kernel3 {
7575
void bar3() {
7676
kernel3(Kernel3{});
7777
}
78+
79+
// -- Clang-style [[sycl_explicit_simd]] attribute for functor object kernel.
80+
81+
template <typename F, typename ID = F>
82+
[[clang::sycl_kernel]] void kernel4(const F &f) {
83+
f();
84+
}
85+
86+
struct Kernel4 {
87+
[[intel::sycl_explicit_simd]] void operator()() const {}
88+
};
89+
90+
void bar4() {
91+
kernel4(Kernel4{});
92+
}
93+
94+
// -- Clang-style [[sycl_explicit_simd]] attribute for lambda and free function.
95+
96+
template <typename ID, typename F>
97+
[[clang::sycl_kernel]] void kernel5(const F &f) {
98+
f();
99+
}
100+
101+
[[intel::sycl_explicit_simd]] void g5() {}
102+
103+
void test5() {
104+
kernel5<class Kernel5>([=]() [[intel::sycl_explicit_simd]] { g5(); });
105+
}

0 commit comments

Comments
 (0)