Skip to content

Commit

Permalink
[SYCL] reqd_work_group_size attribute is reversed (fix intel#11)
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksander Fadeev <[email protected]>
  • Loading branch information
fadeeval committed Mar 4, 2020
1 parent 2b6df01 commit 5c3501f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
46 changes: 25 additions & 21 deletions clang/lib/Sema/SemaDeclAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2895,35 +2895,39 @@ static bool checkWorkGroupSizeValues(Sema &S, Decl *D, const ParsedAttr &Attr,
if (const auto *A = D->getAttr<SYCLIntelMaxGlobalWorkDimAttr>())
if (A->getNumber() == 0)
Result &= checkZeroDim(A, WGSize[0], WGSize[1], WGSize[2],
/*ReverseAttrs=*/ true);
/*ReverseAttrs=*/true);

if (const auto *A = D->getAttr<SYCLIntelMaxWorkGroupSizeAttr>()) {
if (S.getLangOpts().SYCLIsDevice && !(WGSize[2] <= A->getXDim() && WGSize[1] <= A->getYDim() &&
if (S.getLangOpts().SYCLIsDevice &&
!(WGSize[2] <= A->getXDim() && WGSize[1] <= A->getYDim() &&
WGSize[0] <= A->getZDim())) {
S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes)
<< Attr << A->getSpelling();
Result &= false;
}
if (!S.getLangOpts().SYCLIsDevice && !(WGSize[0] <= A->getXDim() && WGSize[1] <= A->getYDim() &&
if (!S.getLangOpts().SYCLIsDevice &&
!(WGSize[0] <= A->getXDim() && WGSize[1] <= A->getYDim() &&
WGSize[2] <= A->getZDim())) {
S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes)
<< Attr << A->getSpelling();
Result &= false;
}
}
if (const auto *A = D->getAttr<ReqdWorkGroupSizeAttr>()) {
if (S.getLangOpts().SYCLIsDevice && !(WGSize[2] >= A->getXDim() && WGSize[1] >= A->getYDim() &&
WGSize[0] >= A->getZDim())) {
S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes)
<< Attr << A->getSpelling();
Result &= false;
}
if (!S.getLangOpts().SYCLIsDevice && !(WGSize[0] >= A->getXDim() && WGSize[1] >= A->getYDim() &&
WGSize[2] >= A->getZDim())) {
S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes)
<< Attr << A->getSpelling();
Result &= false;
}
if (S.getLangOpts().SYCLIsDevice &&
!(WGSize[2] >= A->getXDim() && WGSize[1] >= A->getYDim() &&
WGSize[0] >= A->getZDim())) {
S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes)
<< Attr << A->getSpelling();
Result &= false;
}
if (!S.getLangOpts().SYCLIsDevice &&
!(WGSize[0] >= A->getXDim() && WGSize[1] >= A->getYDim() &&
WGSize[2] >= A->getZDim())) {
S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes)
<< Attr << A->getSpelling();
Result &= false;
}
}
return Result;
}
Expand Down Expand Up @@ -2951,13 +2955,13 @@ static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) {
return;

WorkGroupAttr *Existing = D->getAttr<WorkGroupAttr>();
if (S.getLangOpts().SYCLIsDevice && Existing && !(Existing->getXDim() == WGSize[2] &&
Existing->getYDim() == WGSize[1] &&
Existing->getZDim() == WGSize[0]))
if (S.getLangOpts().SYCLIsDevice && Existing &&
!(Existing->getXDim() == WGSize[2] && Existing->getYDim() == WGSize[1] &&
Existing->getZDim() == WGSize[0]))
S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL;
if (!S.getLangOpts().SYCLIsDevice && Existing && !(Existing->getXDim() == WGSize[0] &&
Existing->getYDim() == WGSize[1] &&
Existing->getZDim() == WGSize[2]))
if (!S.getLangOpts().SYCLIsDevice && Existing &&
!(Existing->getXDim() == WGSize[0] && Existing->getYDim() == WGSize[1] &&
Existing->getZDim() == WGSize[2]))
S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL;

if (S.getLangOpts().SYCLIsDevice)
Expand Down
10 changes: 4 additions & 6 deletions clang/test/SemaSYCL/reqd-work-group-size.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
class Functor {
public:
[[cl::reqd_work_group_size(4, 1, 1)]] void operator()() {}

};

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

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

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

class Functor16 {
Expand Down Expand Up @@ -78,10 +77,9 @@ void bar() {
kernel<class kernel_name4>(fattr);

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


#ifdef TRIGGER_ERROR
Functor8 f8;
kernel<class kernel_name6>(f8);
Expand All @@ -102,7 +100,7 @@ void bar() {
});

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

Expand Down

0 comments on commit 5c3501f

Please sign in to comment.