Skip to content

Commit 5c3501f

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

File tree

2 files changed

+29
-27
lines changed

2 files changed

+29
-27
lines changed

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2895,35 +2895,39 @@ static bool checkWorkGroupSizeValues(Sema &S, Decl *D, const ParsedAttr &Attr,
28952895
if (const auto *A = D->getAttr<SYCLIntelMaxGlobalWorkDimAttr>())
28962896
if (A->getNumber() == 0)
28972897
Result &= checkZeroDim(A, WGSize[0], WGSize[1], WGSize[2],
2898-
/*ReverseAttrs=*/ true);
2898+
/*ReverseAttrs=*/true);
28992899

29002900
if (const auto *A = D->getAttr<SYCLIntelMaxWorkGroupSizeAttr>()) {
2901-
if (S.getLangOpts().SYCLIsDevice && !(WGSize[2] <= A->getXDim() && WGSize[1] <= A->getYDim() &&
2901+
if (S.getLangOpts().SYCLIsDevice &&
2902+
!(WGSize[2] <= A->getXDim() && WGSize[1] <= A->getYDim() &&
29022903
WGSize[0] <= A->getZDim())) {
29032904
S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes)
29042905
<< Attr << A->getSpelling();
29052906
Result &= false;
29062907
}
2907-
if (!S.getLangOpts().SYCLIsDevice && !(WGSize[0] <= A->getXDim() && WGSize[1] <= A->getYDim() &&
2908+
if (!S.getLangOpts().SYCLIsDevice &&
2909+
!(WGSize[0] <= A->getXDim() && WGSize[1] <= A->getYDim() &&
29082910
WGSize[2] <= A->getZDim())) {
29092911
S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes)
29102912
<< Attr << A->getSpelling();
29112913
Result &= false;
29122914
}
29132915
}
29142916
if (const auto *A = D->getAttr<ReqdWorkGroupSizeAttr>()) {
2915-
if (S.getLangOpts().SYCLIsDevice && !(WGSize[2] >= A->getXDim() && WGSize[1] >= A->getYDim() &&
2916-
WGSize[0] >= A->getZDim())) {
2917-
S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes)
2918-
<< Attr << A->getSpelling();
2919-
Result &= false;
2920-
}
2921-
if (!S.getLangOpts().SYCLIsDevice && !(WGSize[0] >= A->getXDim() && WGSize[1] >= A->getYDim() &&
2922-
WGSize[2] >= A->getZDim())) {
2923-
S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes)
2924-
<< Attr << A->getSpelling();
2925-
Result &= false;
2926-
}
2917+
if (S.getLangOpts().SYCLIsDevice &&
2918+
!(WGSize[2] >= A->getXDim() && WGSize[1] >= A->getYDim() &&
2919+
WGSize[0] >= A->getZDim())) {
2920+
S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes)
2921+
<< Attr << A->getSpelling();
2922+
Result &= false;
2923+
}
2924+
if (!S.getLangOpts().SYCLIsDevice &&
2925+
!(WGSize[0] >= A->getXDim() && WGSize[1] >= A->getYDim() &&
2926+
WGSize[2] >= A->getZDim())) {
2927+
S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes)
2928+
<< Attr << A->getSpelling();
2929+
Result &= false;
2930+
}
29272931
}
29282932
return Result;
29292933
}
@@ -2951,13 +2955,13 @@ static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) {
29512955
return;
29522956

29532957
WorkGroupAttr *Existing = D->getAttr<WorkGroupAttr>();
2954-
if (S.getLangOpts().SYCLIsDevice && Existing && !(Existing->getXDim() == WGSize[2] &&
2955-
Existing->getYDim() == WGSize[1] &&
2956-
Existing->getZDim() == WGSize[0]))
2958+
if (S.getLangOpts().SYCLIsDevice && Existing &&
2959+
!(Existing->getXDim() == WGSize[2] && Existing->getYDim() == WGSize[1] &&
2960+
Existing->getZDim() == WGSize[0]))
29572961
S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL;
2958-
if (!S.getLangOpts().SYCLIsDevice && Existing && !(Existing->getXDim() == WGSize[0] &&
2959-
Existing->getYDim() == WGSize[1] &&
2960-
Existing->getZDim() == WGSize[2]))
2962+
if (!S.getLangOpts().SYCLIsDevice && Existing &&
2963+
!(Existing->getXDim() == WGSize[0] && Existing->getYDim() == WGSize[1] &&
2964+
Existing->getZDim() == WGSize[2]))
29612965
S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL;
29622966

29632967
if (S.getLangOpts().SYCLIsDevice)

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
class Functor {
88
public:
99
[[cl::reqd_work_group_size(4, 1, 1)]] void operator()() {}
10-
1110
};
1211

1312
template <typename name, typename Func>
@@ -24,10 +23,10 @@ void bar() {
2423
// expected-note@-1 {{conflicting attribute is here}}
2524
[[cl::reqd_work_group_size(32, 1, 1)]] void f32x1x1() {} // expected-note {{conflicting attribute is here}}
2625

27-
[[cl::reqd_work_group_size(16, 1, 1)]] void f16x1x1() {} // expected-note {{conflicting attribute is here}}
26+
[[cl::reqd_work_group_size(16, 1, 1)]] void f16x1x1() {} // expected-note {{conflicting attribute is here}}
2827
[[cl::reqd_work_group_size(16, 16, 1)]] void f16x16x1() {} // expected-note {{conflicting attribute is here}}
2928

30-
[[cl::reqd_work_group_size(32, 32, 1)]] void f32x32x1() {} // expected-note {{conflicting attribute is here}}
29+
[[cl::reqd_work_group_size(32, 32, 1)]] void f32x32x1() {} // expected-note {{conflicting attribute is here}}
3130
[[cl::reqd_work_group_size(32, 32, 32)]] void f32x32x32() {} // expected-note {{conflicting attribute is here}}
3231

3332
class Functor16 {
@@ -78,10 +77,9 @@ void bar() {
7877
kernel<class kernel_name4>(fattr);
7978

8079
kernel<class kernel_name5>([]() [[cl::reqd_work_group_size(32, 32, 32), cl::reqd_work_group_size(32, 32, 32)]] {
81-
f32x32x32();
80+
f32x32x32();
8281
});
8382

84-
8583
#ifdef TRIGGER_ERROR
8684
Functor8 f8;
8785
kernel<class kernel_name6>(f8);
@@ -102,7 +100,7 @@ void bar() {
102100
});
103101

104102
// expected-error@+1 {{expected variable name or 'this' in lambda capture list}}
105-
kernel<class kernel_name10>([[cl::reqd_work_group_size(32, 32, 32)]] []() {
103+
kernel<class kernel_name10>([[cl::reqd_work_group_size(32, 32, 32)]][]() {
106104
f32x32x32();
107105
});
108106

0 commit comments

Comments
 (0)