-
Notifications
You must be signed in to change notification settings - Fork 788
[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
[SYCL] reqd_work_group_size attribute is reversed #1234
Conversation
Signed-off-by: Aleksander Fadeev <[email protected]>
Signed-off-by: Aleksander Fadeev <[email protected]>
Signed-off-by: Aleksander Fadeev <[email protected]>
Signed-off-by: Aleksander Fadeev <[email protected]>
Signed-off-by: Aleksander Fadeev <[email protected]>
Signed-off-by: Aleksander Fadeev <[email protected]>
Signed-off-by: Aleksander Fadeev <[email protected]>
Signed-off-by: Aleksander Fadeev <[email protected]>
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 can't make the value judgement required here, but the code changes seem innocuous enough. There are a couple of unnecessary formatting changes (see handleWorkGroupSize:2942), but I'll leave it up to @bader to see if its worth reverting that in this patch.
I make automatic formatting and this is that I got. |
Existing->getYDim() == WGSize[1] && | ||
Existing->getZDim() == WGSize[2])) | ||
if (Existing && | ||
!(Existing->getXDim() == WGSize[0] && Existing->getYDim() == WGSize[1] && |
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.
This check is not reversed. Does the warning below still work correctly?
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 think it can work. Is there test for it?
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.
If yes, then it works fine.
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 think it can work. Is there test for it?
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?
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.
Maybe you are right
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 will try to prove it.
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, it need to be reversed.
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 suspect that the diagnostic was not tested. Can you add a test for it?
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.
A general case was tested, see: reqd-work-group-size.cpp:23 - 31, and these diagnostics are firing anyway.
But with this patch there is a corner case introduced, that was untested, like:
[[cl::reqd_work_group_size(4, 4, 1)]]
[[cl::reqd_work_group_size(1, 4, 4)]]
void foo() { /*...*/ }
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 add one test, that prove rightness of the implementation.
Signed-off-by: Aleksander Fadeev <[email protected]>
Signed-off-by: Aleksander Fadeev <[email protected]>
[[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()() {} |
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.
This is a new one.
Signed-off-by: Aleksander Fadeev <[email protected]>
Signed-off-by: Aleksander Fadeev <[email protected]>
Signed-off-by: Aleksander Fadeev <[email protected]>
clang/lib/Sema/SemaDeclAttr.cpp
Outdated
|
||
if (const auto *A = D->getAttr<SYCLIntelMaxWorkGroupSizeAttr>()) { | ||
if (!(WGSize[0] <= A->getXDim() && WGSize[1] <= A->getYDim() && | ||
if (S.getLangOpts().SYCLIsDevice && |
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.
There is a lot of code duplication around S.getLangOpts().SYCLIsDevice
.
Consider the following improvement:
int XDim = WGSize[0];
int YDim = WGSize[1];
int ZDim = WGSize[2];
if (S.getLangOpts().SYCLIsDevice) {
std::swap(XDim, ZDim); // add a good comment here
}
and then use *Dim
variables instead of WGSize
.
Signed-off-by: Aleksander Fadeev <[email protected]>
Signed-off-by: Aleksander Fadeev <[email protected]>
5831eb4
to
dc704bf
Compare
Signed-off-by: Aleksander Fadeev <[email protected]>
clang/include/clang/Basic/Attr.td
Outdated
@@ -1147,7 +1147,7 @@ def SYCLIntelKernelArgsRestrict : InheritableAttr { | |||
|
|||
def SYCLIntelNumSimdWorkItems : InheritableAttr { | |||
let Spellings = [CXX11<"intelfpga","num_simd_work_items">]; | |||
let Args = [UnsignedArgument<"Number">]; | |||
let Args = [IntArgument<"Number">]; |
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.
Signed-off-by: Aleksander Fadeev <[email protected]>
…e_api_test * origin/sycl: [SYCL][NFC] Fix static code analysis concerns (intel#1283) [SYCL] Fix the test/basic_tests/buffer/subbuffer.cpp (intel#1277) [SYCL][CUDA] Implement the program kernel names query (intel#1248) [SYCL] Honor the LLVM_LIBDIR_SUFFIX variable at installation time (intel#1261) [SYCL][UX] Diagnostic for undefined device functions (intel#1026) [SYCL] Reverse reqd_work_group_size attribute (intel#1234) [SYCL] Rename project to oneAPI DPC++ Compiler (intel#1249) [SYCL][XPTI] Instrumentation of SYCL runtime with XPTI (intel#1129)
…st_commit * otcshare/sycl: (469 commits) [SYCL] Implement thread-local storage restriction (intel#1281) [Driver][SYCL][FPGA] Adjust the output location for the project report (intel#1278) [SYCL][NFC] Fix static code analysis concerns (intel#1283) [SYCL] Fix the test/basic_tests/buffer/subbuffer.cpp (intel#1277) [SYCL][CUDA] Implement the program kernel names query (intel#1248) [SYCL] Honor the LLVM_LIBDIR_SUFFIX variable at installation time (intel#1261) [SYCL][UX] Diagnostic for undefined device functions (intel#1026) [SYCL] Reverse reqd_work_group_size attribute (intel#1234) [SYCL] Rename project to oneAPI DPC++ Compiler (intel#1249) [SYCL][XPTI] Instrumentation of SYCL runtime with XPTI (intel#1129) [SYCL] Add buffer dimensions restriction (intel#1147) [SYCL][NFC] Update copyright header in handler files (intel#1271) [SYCL][NFC] Format the code with clang-format [SYCL][Test] Fix SYCL library location path for LIT tests (intel#1228) [SYCL][NFC] Fix doxygen warnings (intel#1270) [SYCL][CUDA] Add the CUDA backend to the deploy-sycl-toolchain target (intel#1268) [SYCL][NFC] Fix a misleading comment regarding the SYCL flow (intel#1266) Change capability for SpecId decoration README.md: Mention retrieving llvm archive signatures travis: Restore macOS builds ...
…_accessor_refactor * origin/sycl: (454 commits) [SYCL][NFC] Fix static code analysis concerns (intel#1283) [SYCL] Fix the test/basic_tests/buffer/subbuffer.cpp (intel#1277) [SYCL][CUDA] Implement the program kernel names query (intel#1248) [SYCL] Honor the LLVM_LIBDIR_SUFFIX variable at installation time (intel#1261) [SYCL][UX] Diagnostic for undefined device functions (intel#1026) [SYCL] Reverse reqd_work_group_size attribute (intel#1234) [SYCL] Rename project to oneAPI DPC++ Compiler (intel#1249) [SYCL][XPTI] Instrumentation of SYCL runtime with XPTI (intel#1129) [SYCL] Add buffer dimensions restriction (intel#1147) [SYCL][NFC] Update copyright header in handler files (intel#1271) [SYCL][NFC] Format the code with clang-format [SYCL][Test] Fix SYCL library location path for LIT tests (intel#1228) [SYCL][NFC] Fix doxygen warnings (intel#1270) [SYCL][CUDA] Add the CUDA backend to the deploy-sycl-toolchain target (intel#1268) Change capability for SpecId decoration README.md: Mention retrieving llvm archive signatures travis: Restore macOS builds Fix DebugInfo creation after LLVM change 7a42bab Add more missing mixes Add missing fixes ...
The reqd_work_group_size attribute should follow the SYCL/C++ convention, where the rightmost index maps to the linear dimension.
Signed-off-by: Aleksander Fadeev [email protected]