-
Notifications
You must be signed in to change notification settings - Fork 802
[SYCL] reqd_work_group_size attribute is reversed #1234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 14 commits
2fc939b
3582e97
3c6ea83
b14013d
1d0d751
ff6746a
245f323
9125bc1
a7eef4b
2b6df01
5c3501f
43f265f
5831eb4
8696f6e
dc704bf
9ab8cf7
abe6d2d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2895,7 +2895,7 @@ 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 (!(WGSize[0] <= A->getXDim() && WGSize[1] <= A->getYDim() && | ||
|
|
@@ -2935,14 +2935,17 @@ static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) { | |
| } | ||
| } | ||
|
|
||
| if (!checkWorkGroupSizeValues(S, D, AL, WGSize)) | ||
| return; | ||
|
|
||
| // For a SYCLDevice WorkGroupAttr arguments are reversed | ||
| if (S.getLangOpts().SYCLIsDevice) { | ||
| std::swap(WGSize[0], WGSize[2]); | ||
| } | ||
| WorkGroupAttr *Existing = D->getAttr<WorkGroupAttr>(); | ||
| if (Existing && !(Existing->getXDim() == WGSize[0] && | ||
| Existing->getYDim() == WGSize[1] && | ||
| Existing->getZDim() == WGSize[2])) | ||
| if (Existing && | ||
| !(Existing->getXDim() == WGSize[0] && Existing->getYDim() == WGSize[1] && | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This check is not reversed. Does the warning below still work correctly?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it can work. Is there test for it?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If yes, then it works fine.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That is what I was going to ask. If I'm reading this code correctly, we compare XDim of an existing attribute with WGSize[0], which is going to be ZDim. Shouldn't we compare existing XDim with WGSize[2] instead?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe you are right
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will try to prove it.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it need to be reversed.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suspect that the diagnostic was not tested. Can you add a test for it?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A general case was tested, see: reqd-work-group-size.cpp:23 - 31, and these diagnostics are firing anyway.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I add one test, that prove rightness of the implementation. |
||
| Existing->getZDim() == WGSize[2])) | ||
| S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL; | ||
| if (!checkWorkGroupSizeValues(S, D, AL, WGSize)) | ||
| return; | ||
|
|
||
| D->addAttr(::new (S.Context) | ||
| WorkGroupAttr(S.Context, AL, WGSize[0], WGSize[1], WGSize[2])); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,6 @@ | |
| class Functor { | ||
| public: | ||
| [[cl::reqd_work_group_size(4, 1, 1)]] void operator()() {} | ||
|
|
||
| }; | ||
|
|
||
| template <typename name, typename Func> | ||
|
|
@@ -24,25 +23,33 @@ 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 { | ||
| public: | ||
| [[cl::reqd_work_group_size(16, 1, 1)]] void operator()() {} | ||
| [[cl::reqd_work_group_size(16, 1, 1)]] [[cl::reqd_work_group_size(16, 1, 1)]] void operator()() {} | ||
|
Comment on lines
-35
to
+34
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a new one. |
||
| }; | ||
|
|
||
| #ifdef TRIGGER_ERROR | ||
| class Functor32 { | ||
| public: | ||
| //expected-warning@+2{{attribute 'reqd_work_group_size' is already applied with different parameters}} | ||
| // expected-error@+1{{'reqd_work_group_size' attribute conflicts with 'reqd_work_group_size' attribute}} | ||
| [[cl::reqd_work_group_size(32, 1, 1)]] [[cl::reqd_work_group_size(1, 1, 32)]] void operator()() {} | ||
| }; | ||
| #endif | ||
| class Functor16x16x16 { | ||
| public: | ||
| [[cl::reqd_work_group_size(16, 16, 16)]] void operator()() {} | ||
| }; | ||
|
|
||
| class Functor8 { // expected-error {{conflicting attributes applied to a SYCL kernel}} | ||
| public: | ||
| [[cl::reqd_work_group_size(8, 1, 1)]] void operator()() { // expected-note {{conflicting attribute is here}} | ||
| [[cl::reqd_work_group_size(1, 1, 8)]] void operator()() { // expected-note {{conflicting attribute is here}} | ||
| f4x1x1(); | ||
| } | ||
| }; | ||
|
|
@@ -77,15 +84,17 @@ void bar() { | |
| FunctorAttr fattr; | ||
| kernel<class kernel_name4>(fattr); | ||
|
|
||
| kernel<class kernel_name5>([]() [[cl::reqd_work_group_size(32, 32, 32)]] { | ||
| f32x32x32(); | ||
| kernel<class kernel_name5>([]() [[cl::reqd_work_group_size(32, 32, 32), cl::reqd_work_group_size(32, 32, 32)]] { | ||
| f32x32x32(); | ||
| }); | ||
|
|
||
|
|
||
| #ifdef TRIGGER_ERROR | ||
| Functor8 f8; | ||
| kernel<class kernel_name6>(f8); | ||
|
|
||
| Functor32 f32; | ||
| kernel<class kernel_name1>(f32); | ||
|
|
||
| kernel<class kernel_name7>([]() { // expected-error {{conflicting attributes applied to a SYCL kernel}} | ||
| f4x1x1(); | ||
| f32x1x1(); | ||
|
|
@@ -102,17 +111,17 @@ 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(); | ||
| }); | ||
|
|
||
| #endif | ||
| } | ||
|
|
||
| // CHECK: FunctionDecl {{.*}} {{.*}}kernel_name1 | ||
| // CHECK: ReqdWorkGroupSizeAttr {{.*}} 16 1 1 | ||
| // CHECK: ReqdWorkGroupSizeAttr {{.*}} 1 1 16 | ||
| // CHECK: FunctionDecl {{.*}} {{.*}}kernel_name2 | ||
| // CHECK: ReqdWorkGroupSizeAttr {{.*}} 4 1 1 | ||
| // CHECK: ReqdWorkGroupSizeAttr {{.*}} 1 1 4 | ||
| // CHECK: FunctionDecl {{.*}} {{.*}}kernel_name3 | ||
| // CHECK: ReqdWorkGroupSizeAttr {{.*}} 16 16 16 | ||
| // CHECK: FunctionDecl {{.*}} {{.*}}kernel_name4 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this should be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.