Skip to content

[SYCL] Pull oneDPL tuple to use in reduction implementation #3481

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

@v-klochkov v-klochkov commented Apr 2, 2021

Using sycl::detail::tuple is a temporary work-around for various
problems caused by using std::tuple:
a) reduction using std::tuple cannot be compiled on Windows because
std::tuple cannot be copied to DEVICE.
b) internal error in level_zero RT.

The new sycl::detail::tuple class is a very limited version
of oneDPL's implementation of tuple. It includes such functionality:

  • convert from std::tuple and to std::tuple
  • tie(), get(), tuple_element, make_tuple

This change enables parallel_for() with number of reductions
more than 1 for level_zero and for Windows.

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

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

@v-klochkov v-klochkov force-pushed the public_vklochkov_reduction_detail_tuple branch 2 times, most recently from bd85aa1 to 87eeacb Compare April 2, 2021 21:22
@v-klochkov v-klochkov force-pushed the public_vklochkov_reduction_detail_tuple branch 3 times, most recently from eccc202 to 102ec23 Compare April 3, 2021 06:15
Using sycl::detail::tuple is a temporary work-around for various
problems caused by using std::tuple:
a) reduction using std::tuple cannot be compiled on Windows because
   std::tuple cannot be copied to DEVICE.
b) internal error in level_zero RT.

The new sycl::detail::tuple class is a very limited version
of oneDPL's implementation of tuple. It includes such functionality:
- convert from std::tuple and to std::tuple
- tie(), get<I>(), tuple_element, make_tuple

This change enables parallel_for() with number of reductions
more than 1 for level_zero and for Windows.

Signed-off-by: Vyacheslav N Klochkov <[email protected]>
@v-klochkov v-klochkov force-pushed the public_vklochkov_reduction_detail_tuple branch from 102ec23 to 64aece7 Compare April 3, 2021 20:31
@v-klochkov v-klochkov changed the title [SYCL] Pull oneDPL implementation of tuple to use with reduction [SYCL] Pull oneDPL tuple to use in reduction implementation Apr 3, 2021
@v-klochkov v-klochkov marked this pull request as ready for review April 3, 2021 20:42
@v-klochkov v-klochkov requested a review from a team as a code owner April 3, 2021 20:42
const std::tuple<ReducerT...> &Reducers,
const std::tuple<ResultT...> Identities,
ReduTupleT<ResultT...> Identities,
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you mean to drop const here?

const std::tuple<ResultT...> Identities,
ReduTupleT<InputAccT...> LocalAccs,
ReduTupleT<LocalAccT...> InputAccs,
ReduTupleT<ResultT...> Identities,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question about const here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The tuple is passed by value here, so 'const' does not have any effect, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good question, I'm not sure! I just wanted to check if it was deliberate, because you did more than just change the type.

Copy link
Contributor

Choose a reason for hiding this comment

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

The tuple is passed by value here, so 'const' does not have any effect, right?

Both versions are equivalent from the caller POV, but const protects from modifying the value within the callee scope if needed.

@@ -30,6 +31,15 @@ using cl::sycl::detail::is_sgeninteger;
using cl::sycl::detail::queue_impl;
using cl::sycl::detail::remove_AS;

// std::tuple seems to be a) too heavy and b) not copyable to device now
Copy link
Contributor

@romanovvlad romanovvlad Apr 5, 2021

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 specifically makes std::tuple heavy?

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'll eventually have to do that. At this moment I only know that SPIR-V file for a reduction test with std::tuple is 34% bigger than SPIRV for the same reduction test with sycl::detail::tuple (i.e. with this change).

@v-klochkov v-klochkov merged commit 962b00a into intel:sycl Apr 5, 2021
@v-klochkov v-klochkov deleted the public_vklochkov_reduction_detail_tuple branch April 5, 2021 20:02
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.

4 participants