Skip to content

Commit 43f265f

Browse files
committed
[SYCL] reqd_work_group_size attribute is reversed (fix intel#12)
Signed-off-by: Aleksander Fadeev <[email protected]>
1 parent 5c3501f commit 43f265f

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2914,6 +2914,7 @@ static bool checkWorkGroupSizeValues(Sema &S, Decl *D, const ParsedAttr &Attr,
29142914
}
29152915
}
29162916
if (const auto *A = D->getAttr<ReqdWorkGroupSizeAttr>()) {
2917+
29172918
if (S.getLangOpts().SYCLIsDevice &&
29182919
!(WGSize[2] >= A->getXDim() && WGSize[1] >= A->getYDim() &&
29192920
WGSize[0] >= A->getZDim())) {
@@ -2951,9 +2952,6 @@ static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) {
29512952
}
29522953
}
29532954

2954-
if (!checkWorkGroupSizeValues(S, D, AL, WGSize))
2955-
return;
2956-
29572955
WorkGroupAttr *Existing = D->getAttr<WorkGroupAttr>();
29582956
if (S.getLangOpts().SYCLIsDevice && Existing &&
29592957
!(Existing->getXDim() == WGSize[2] && Existing->getYDim() == WGSize[1] &&
@@ -2964,6 +2962,9 @@ static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) {
29642962
Existing->getZDim() == WGSize[2]))
29652963
S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL;
29662964

2965+
if (!checkWorkGroupSizeValues(S, D, AL, WGSize))
2966+
return;
2967+
29672968
if (S.getLangOpts().SYCLIsDevice)
29682969
D->addAttr(::new (S.Context) WorkGroupAttr(S.Context, AL, WGSize[2],
29692970
WGSize[1], WGSize[0]));

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ class Functor16 {
3434
[[cl::reqd_work_group_size(16, 1, 1)]] [[cl::reqd_work_group_size(16, 1, 1)]] void operator()() {}
3535
};
3636

37+
#ifdef TRIGGER_ERROR
38+
class Functor32 {
39+
public:
40+
//expected-warning@+2{{attribute 'reqd_work_group_size' is already applied with different parameters}}
41+
// expected-error@+1{{'reqd_work_group_size' attribute conflicts with 'reqd_work_group_size' attribute}}
42+
[[cl::reqd_work_group_size(32, 1, 1)]] [[cl::reqd_work_group_size(1, 1, 32)]] void operator()() {}
43+
};
44+
#endif
3745
class Functor16x16x16 {
3846
public:
3947
[[cl::reqd_work_group_size(16, 16, 16)]] void operator()() {}
@@ -66,7 +74,7 @@ __attribute__((sycl_kernel)) void kernel(Func kernelFunc) {
6674
void bar() {
6775
Functor16 f16;
6876
kernel<class kernel_name1>(f16);
69-
77+
7078
Functor f;
7179
kernel<class kernel_name2>(f);
7280

@@ -84,7 +92,11 @@ void bar() {
8492
Functor8 f8;
8593
kernel<class kernel_name6>(f8);
8694

95+
Functor32 f32;
96+
kernel<class kernel_name1>(f32);
97+
8798
kernel<class kernel_name7>([]() { // expected-error {{conflicting attributes applied to a SYCL kernel}}
99+
88100
f4x1x1();
89101
f32x1x1();
90102
});

0 commit comments

Comments
 (0)