Skip to content

[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

Merged

Conversation

dm-vodopyanov
Copy link
Contributor

@dm-vodopyanov dm-vodopyanov requested a review from a team as a code owner November 29, 2022 23:37
@dm-vodopyanov
Copy link
Contributor Author

PR #7436 closed due to unsuccessful merge conflict resolving. This is a copy of that PR.

@dm-vodopyanov
Copy link
Contributor Author

/verify with intel/llvm-test-suite#1395

Comment on lines +31 to +35
if (g.leader()) {
for (int i = 1; i < g.get_local_linear_range(); i++) {
result = binary_op(result, Memory[i]);
}
}
Copy link
Contributor

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.

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 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.

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,
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor

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.

@dm-vodopyanov
Copy link
Contributor Author

/verify with intel/llvm-test-suite#1395

Copy link
Contributor

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

@dm-vodopyanov dm-vodopyanov merged commit 8311d79 into intel:sycl Dec 1, 2022
dm-vodopyanov added a commit to intel/llvm-test-suite that referenced this pull request Dec 1, 2022
aelovikov-intel pushed a commit to aelovikov-intel/llvm that referenced this pull request Mar 27, 2023
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