Skip to content

[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

Merged
merged 17 commits into from
Mar 10, 2020

Conversation

fadeeval
Copy link
Contributor

@fadeeval fadeeval commented Mar 3, 2020

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]

Copy link
Contributor

@erichkeane erichkeane left a 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.

@fadeeval
Copy link
Contributor Author

fadeeval commented Mar 3, 2020

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] &&
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor Author

@fadeeval fadeeval Mar 3, 2020

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.

Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you are right

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor

@MrSidims MrSidims Mar 4, 2020

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() { /*...*/ }

Copy link
Contributor Author

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.

[[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()() {}
Copy link
Contributor Author

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.


if (const auto *A = D->getAttr<SYCLIntelMaxWorkGroupSizeAttr>()) {
if (!(WGSize[0] <= A->getXDim() && WGSize[1] <= A->getYDim() &&
if (S.getLangOpts().SYCLIsDevice &&
Copy link
Contributor

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.

@fadeeval fadeeval force-pushed the private/fadeeval/reqd_work_group_size branch from 5831eb4 to dc704bf Compare March 6, 2020 14:27
@@ -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">];
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

@romanovvlad romanovvlad merged commit 1da6fbe into intel:sycl Mar 10, 2020
alexbatashev pushed a commit to alexbatashev/llvm that referenced this pull request Mar 12, 2020
…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)
@fadeeval fadeeval deleted the private/fadeeval/reqd_work_group_size branch March 13, 2020 12:30
@fadeeval fadeeval restored the private/fadeeval/reqd_work_group_size branch March 13, 2020 12:30
@fadeeval fadeeval deleted the private/fadeeval/reqd_work_group_size branch March 13, 2020 12:31
alexbatashev added a commit to alexbatashev/llvm that referenced this pull request Mar 13, 2020
…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
  ...
alexbatashev pushed a commit to alexbatashev/llvm that referenced this pull request Mar 15, 2020
…_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
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants