Skip to content
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

Implement Kokkos::sort with execution space #4490

Merged
merged 9 commits into from
Nov 10, 2021

Conversation

masterleinad
Copy link
Contributor

I saw multiple projects introducing extra fences for Kokkos::sort because it couldn't take an execution space as an argument. This pull request adds the respective overloads.

algorithms/src/Kokkos_Sort.hpp Outdated Show resolved Hide resolved
algorithms/src/Kokkos_Sort.hpp Outdated Show resolved Hide resolved
algorithms/src/Kokkos_Sort.hpp Show resolved Hide resolved
Comment on lines 555 to 557
if (!always_use_kokkos_sort) {
if (Impl::try_std_sort(view)) return;
}
Copy link
Member

Choose a reason for hiding this comment

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

This shortcut becomes interesting when passing an execution space. I need to think about it more.

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, we can discuss this. In case, we want Kokkos::sort to behave as deep_copy, we should add a fence after std::sort so that the user can rely on the kernel being enqueued.

@masterleinad masterleinad added the Upcoming Vote Tracking label for Enhancements, Feature Requests that will be voted on in Wed. developer meeting label Nov 2, 2021
@masterleinad masterleinad removed the Upcoming Vote Tracking label for Enhancements, Feature Requests that will be voted on in Wed. developer meeting label Nov 3, 2021
@masterleinad masterleinad force-pushed the async_sort branch 2 times, most recently from b18ad85 to 8d3d7e8 Compare November 3, 2021 21:24
@masterleinad
Copy link
Contributor Author

default_exec.overlap_mdrange_policy for one CUDA build is unrelated.

@masterleinad
Copy link
Contributor Author

Retest this please.

@ajpowelsnl
Copy link
Contributor

Morning @masterleinad , @dalg24 and @PhilMiller -- Would you like to add this issue to the list of things we'll discuss tomorrow? If so, please just let me know.

@masterleinad
Copy link
Contributor Author

Morning @masterleinad , @dalg24 and @PhilMiller -- Would you like to add this issue to the list of things we'll discuss tomorrow? If so, please just let me know.

We did discuss this already last week. I don't think there is anything new to talk about. We just need more reviews here.

Copy link
Contributor

@PhilMiller PhilMiller left a comment

Choose a reason for hiding this comment

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

Other than Damien's concern about the forwarding to std::sort, I'm +1 on this.

algorithms/src/Kokkos_Sort.hpp Outdated Show resolved Hide resolved
Copy link
Member

@dalg24 dalg24 left a comment

Choose a reason for hiding this comment

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

sorry forgot to finish the review

algorithms/src/Kokkos_Sort.hpp Outdated Show resolved Hide resolved
@@ -533,6 +533,7 @@ bool try_std_sort(ViewType view) {
possible = possible && (ViewType::Rank == 1);
possible = possible && (stride[0] == 1);
if (possible) {
exec.fence("Kokkos::sort: Fence before sorting on the host");
Copy link
Member

Choose a reason for hiding this comment

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

Although I don't necessarily object to that change, it needs to be highlighted not just committed along with addressing another unrelated review comment.

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 split the commit.

@dalg24 dalg24 merged commit 72418c2 into kokkos:develop Nov 10, 2021
ndellingwood pushed a commit to ndellingwood/kokkos that referenced this pull request Nov 12, 2021
* Implement Kokkos::sort with execution space

* Use Kokkos::sort overloads with execution space in unit tests

* Use three-argument deep_copy in Kokkos_Sort

* Use execution_space instead of DefaultExecutionSpace

* Move fence() to versions not taking an execution space

* Use given execution space for view allocations

* Use default argument for create_permute_vector

* Use class execution_space

* Fence execution_space when using std::sort

(cherry picked from commit 72418c2)

 Conflicts:
	algorithms/src/Kokkos_Sort.hpp
crtrott added a commit that referenced this pull request Nov 18, 2021
[3.5] Implement Kokkos::sort with execution space (#4490)
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.

None yet

5 participants