Skip to content

[SYCL] Implement SYCL2020 reductions with set initialize_to_identity … #3410

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

Conversation

v-klochkov
Copy link
Contributor

…property

The corresponding LIT tests PR: intel/llvm-test-suite#194

SYCL2020 reductions use dynamic information (instead of static info used
previously) to ask to do discard-write to user's reduction variable or USM
memory. That caused big changes removing/re-structuring the code that
previously relied on accessor-mode (read-write vs discard-write).

With this patch the SYCL-2020 reductions become on par with ONEAPI::reduction

Signed-off-by: Vyacheslav N Klochkov [email protected]

@v-klochkov v-klochkov force-pushed the public_vklochkov_reduction_2020_discard_write branch from de9293a to 0c254dd Compare March 25, 2021 20:37
…property

The corresponding LIT tests PR: intel/llvm-test-suite#194

SYCL2020 reductions use dynamic information (instead of static info used
previously) to ask to do discard-write to user's reduction variable or USM
memory. That caused big changes removing/re-structuring the code that
previously relied on accessor-mode (read-write vs discard-write).

With this patch the SYCL-2020 reductions become on par with ONEAPI::reduction

Signed-off-by: Vyacheslav N Klochkov <[email protected]>
@v-klochkov v-klochkov force-pushed the public_vklochkov_reduction_2020_discard_write branch from 0c254dd to 8d3af03 Compare March 26, 2021 04:33
@v-klochkov v-klochkov marked this pull request as ready for review March 26, 2021 06:04
@v-klochkov v-klochkov requested a review from a team as a code owner March 26, 2021 06:04
@romanovvlad
Copy link
Contributor

Will try to review on Monday

Pennycook
Pennycook previously approved these changes Mar 26, 2021
if (MRWAcc)
CGH.associateWithHandler(MRWAcc.get(), access::target::global_buffer);
if (MDWAcc)
CGH.associateWithHandler(MDWAcc.get(), access::target::global_buffer);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, add assert that only one accessor is defined.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My initial move was to add the assert here:
assert((!MRWAcc || !MDWAcc) && "Reduction cannot be created with read-write AND discard-write accessor");
But then I thought that MRWAcc and MDWAcc fields are initialized only in reduction_impl constructor and those places are obvious, thus having that assert here would be pretty much useless/redundant.

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 going though to change the line 'if (MDWAcc)' to 'else if (MDWAcc)'

shared_ptr_class<rw_accessor_type>{}, &Acc)),
MIdentity(Identity), MBinaryOp(BOp), InitializeToIdentity(false) {
if (Acc.get_count() != 1)
throw runtime_error("Reduction variable must be a scalar.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please clarify what scalar means in this context?

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 used the word 'scalar' here as opposite to 'vector'. Accessor may be 1-dimensional, but it must not be a true 1-dimensional array, it may have only 1 element, i.e. be a scalar.

DataLessPropKindSize = 7,
InitializeToIdentity = 8
InitializeToIdentity = 7,
DataLessPropKindSize = 8
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems changing DataLessPropKindSize can be an ABI break since it can change MDataLessProps.
But, it looks like the minimum value already allocated for MDataLessProps is 4 bytes, so that should be OK.
Can we define something like DataLessPropKindMax = 32 with comment "exceeding this is an ABI break" and use it as the size of MDataLessProps? Could you please do it as a separate PR?

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, sure, I'll do that in a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created that PR here: #3458

@v-klochkov
Copy link
Contributor Author

v-klochkov commented Mar 30, 2021

The only failed test Jenkins/Precommit is SYCL :: Sampler/unnormalized-clamp-linear-float.cpp. It is unrelated to this PR.
#8814 is already created for that flaky fail.

@v-klochkov v-klochkov merged commit 3473c1a into intel:sycl Mar 31, 2021
@v-klochkov v-klochkov deleted the public_vklochkov_reduction_2020_discard_write branch March 31, 2021 04:26
v-klochkov added a commit to v-klochkov/llvm-test-suite that referenced this pull request Apr 7, 2021
…y property

The corresponding changes in SYCL RT:
  intel/llvm#3410
  intel/llvm#3481

Signed-off-by: Vyacheslav N Klochkov <[email protected]>
v-klochkov added a commit to intel/llvm-test-suite that referenced this pull request Apr 8, 2021
* [SYCL] Add test cases for SYCL2020 reductions + initialize_to_identity property

The corresponding changes in SYCL RT:
  intel/llvm#3410
  intel/llvm#3481

This patch
- adds checks for SYCL-2020 reductions with initialize_to_identity property (#3410)
- enables the test reduction_nd_N_vars.cpp for level-zero (#3481)
- reduces some of tests by eliminating unneeded/duplicated checks.
- removes the test reduction_transparent.cpp as useless because transparent 
  operators already checked in many other tests.
- reduces runtime of reduction tests by about 200x in average by re-using
  queue created once instead of creating it in each of test-cases

Signed-off-by: Vyacheslav N Klochkov <[email protected]>
aelovikov-intel pushed a commit to aelovikov-intel/llvm that referenced this pull request Mar 27, 2023
)

* [SYCL] Add test cases for SYCL2020 reductions + initialize_to_identity property

The corresponding changes in SYCL RT:
  intel#3410
  intel#3481

This patch
- adds checks for SYCL-2020 reductions with initialize_to_identity property (intel/llvm-test-suite#3410)
- enables the test reduction_nd_N_vars.cpp for level-zero (intel/llvm-test-suite#3481)
- reduces some of tests by eliminating unneeded/duplicated checks.
- removes the test reduction_transparent.cpp as useless because transparent 
  operators already checked in many other tests.
- reduces runtime of reduction tests by about 200x in average by re-using
  queue created once instead of creating it in each of test-cases

Signed-off-by: Vyacheslav N Klochkov <[email protected]>
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.

3 participants