-
Notifications
You must be signed in to change notification settings - Fork 795
[SYCL] Implement user-defined reduction extension #7587
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] Implement user-defined reduction extension #7587
Conversation
PR #7436 closed due to unsuccessful merge conflict resolving. This is a copy of that PR. |
/verify with intel/llvm-test-suite#1395 |
if (g.leader()) { | ||
for (int i = 1; i < g.get_local_linear_range(); i++) { | ||
result = binary_op(result, Memory[i]); | ||
} | ||
} |
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 doubt people would be happy with this naive implementation. Might be fine for the initial commit though.
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 intentional. Making this through SPIR-V extensions is too long (spec, impl for them). The plan is to re-write the current using these extensions without rush if customers would not be happy with the performance.
sycl/include/sycl/ext/oneapi/experimental/user_defined_reductions.hpp
Outdated
Show resolved
Hide resolved
sycl/include/sycl/ext/oneapi/experimental/user_defined_reductions.hpp
Outdated
Show resolved
Hide resolved
auto g = group_helper.get_group(); | ||
T partial = *(first + g.get_local_linear_id()); | ||
Ptr second = first + g.get_local_linear_range(); | ||
sycl::detail::for_each(g, second, last, |
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.
Would it work with non-pointer iterators?
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.
Probably not, SYCL2020 sycl::joint_reduce
also uses this approach. User passes sycl::accessor::get_pointer() to this func.
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.
Can we claim the extension as supported with that implementation though?
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.
At the moment this won't work with non-pointer iterators simply because we have enable_if
at the beginning of the function, which requires Ptr
to be a pointer type.
I would suggest that we go with the current approach as a first iteration of the extension: we will anyway only claim it as experimental for now.
@dm-vodopyanov, we should raise this question with spec writers, because both extension and core spec do not say whether Ptr
can be a generic iterator or is it a mere pointer.
/verify with intel/llvm-test-suite#1395 |
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.
Good enough for the initial implementation.
Spec: intel/llvm#7202 Implementation: intel/llvm#7587
Spec: #7202
Tests: intel/llvm-test-suite#1395