Skip to content

Commit 8696f6e

Browse files
committed
[SYCL] reqd_work_group_size attribute is reversed (fix intel#13)
Signed-off-by: Aleksander Fadeev <aleksander.fadeev@intel.com>
1 parent 43f265f commit 8696f6e

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

clang/include/clang/Basic/Attr.td

+9-1
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,7 @@ def SYCLIntelKernelArgsRestrict : InheritableAttr {
11471147

11481148
def SYCLIntelNumSimdWorkItems : InheritableAttr {
11491149
let Spellings = [CXX11<"intelfpga","num_simd_work_items">];
1150-
let Args = [UnsignedArgument<"Number">];
1150+
let Args = [IntArgument<"Number">];
11511151
let LangOpts = [SYCLIsDevice, SYCLIsHost];
11521152
let Subjects = SubjectList<[Function], ErrorDiag>;
11531153
let Documentation = [SYCLIntelNumSimdWorkItemsAttrDocs];
@@ -2420,6 +2420,14 @@ def ReqdWorkGroupSize : InheritableAttr {
24202420
let Documentation = [Undocumented];
24212421
}
24222422

2423+
def SYCLIntelReqdWorkGroupSize : InheritableAttr {
2424+
let Spellings = [CXX11<"intel","reqd_work_group_size">];
2425+
let Args = [IntArgument<"XDim">, DefaultIntArgument<"YDim", 1>,
2426+
DefaultIntArgument<"ZDim", 1>];
2427+
let Subjects = SubjectList<[Function], ErrorDiag>;
2428+
let Documentation = [Undocumented];
2429+
}
2430+
24232431
def WorkGroupSizeHint : InheritableAttr {
24242432
// Does not have a [[]] spelling because it is an OpenCL-related attribute.
24252433
let Spellings = [GNU<"work_group_size_hint">];

clang/lib/Sema/SemaDeclAttr.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -2914,7 +2914,7 @@ static bool checkWorkGroupSizeValues(Sema &S, Decl *D, const ParsedAttr &Attr,
29142914
}
29152915
}
29162916
if (const auto *A = D->getAttr<ReqdWorkGroupSizeAttr>()) {
2917-
2917+
29182918
if (S.getLangOpts().SYCLIsDevice &&
29192919
!(WGSize[2] >= A->getXDim() && WGSize[1] >= A->getYDim() &&
29202920
WGSize[0] >= A->getZDim())) {
@@ -2940,9 +2940,13 @@ static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) {
29402940
return;
29412941

29422942
uint32_t WGSize[3];
2943+
if (const auto *A = D->getAttr<SYCLIntelReqdWorkGroupSizeAttr>()){
2944+
WGSize[1] = SYCLIntelReqdWorkGroupSizeAttr::DefaultYDim;
2945+
WGSize[2] = SYCLIntelReqdWorkGroupSizeAttr::DefaultZDim;
2946+
}
29432947
for (unsigned i = 0; i < 3; ++i) {
29442948
const Expr *E = AL.getArgAsExpr(i);
2945-
if (!checkUInt32Argument(S, AL, E, WGSize[i], i,
2949+
if (i < AL.getNumArgs() && !checkUInt32Argument(S, AL, E, WGSize[i], i,
29462950
/*StrictlyUnsigned=*/true))
29472951
return;
29482952
if (WGSize[i] == 0) {

clang/test/SemaSYCL/reqd-work-group-size.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Functor32 {
4040
//expected-warning@+2{{attribute 'reqd_work_group_size' is already applied with different parameters}}
4141
// expected-error@+1{{'reqd_work_group_size' attribute conflicts with 'reqd_work_group_size' attribute}}
4242
[[cl::reqd_work_group_size(32, 1, 1)]] [[cl::reqd_work_group_size(1, 1, 32)]] void operator()() {}
43-
};
43+
};
4444
#endif
4545
class Functor16x16x16 {
4646
public:
@@ -74,7 +74,7 @@ __attribute__((sycl_kernel)) void kernel(Func kernelFunc) {
7474
void bar() {
7575
Functor16 f16;
7676
kernel<class kernel_name1>(f16);
77-
77+
7878
Functor f;
7979
kernel<class kernel_name2>(f);
8080

@@ -96,7 +96,6 @@ void bar() {
9696
kernel<class kernel_name1>(f32);
9797

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

0 commit comments

Comments
 (0)