Implement parallel cuda::std::remove{_if}#7693
Open
miscco wants to merge 1 commit intoNVIDIA:mainfrom
Open
Conversation
Contributor
Author
|
Algorithms look similar to other algorithms, equal for many elements, slower for few |
b75bed0 to
b8e1d28
Compare
libcudacxx/test/libcudacxx/std/algorithms/alg.modifying/alg.remove/pstl_remove_if.cu
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
b8e1d28 to
9dbc2f9
Compare
This comment has been minimized.
This comment has been minimized.
27e1de9 to
96446aa
Compare
This comment has been minimized.
This comment has been minimized.
96446aa to
7eab5cb
Compare
This comment has been minimized.
This comment has been minimized.
7eab5cb to
58d2f85
Compare
This comment has been minimized.
This comment has been minimized.
58d2f85 to
d8036f8
Compare
|
|
||
| state.exec(nvbench::exec_tag::gpu | nvbench::exec_tag::no_batch | nvbench::exec_tag::sync, | ||
| [&](nvbench::launch& launch) { | ||
| cuda::std::remove(cuda_policy(alloc, launch), in.begin(), in.end(), T{42}); |
Contributor
There was a problem hiding this comment.
Question: is do_not_optimize needed here as well?
Contributor
Author
There was a problem hiding this comment.
The issue here is that the function has no return, so one would have to make some crazy hacks, so I just did not add it
This comment has been minimized.
This comment has been minimized.
davebayer
approved these changes
Feb 25, 2026
This implements the `remove` algorithm for the cuda backend. * `std::remove` see https://en.cppreference.com/w/cpp/algorithm/remove.html * `std::remove_if` see https://en.cppreference.com/w/cpp/algorithm/remove.html It provides tests and benchmarks similar to Thrust and some boilerplate for libcu++ The functionality is publicly available yet and implemented in a private internal header Fixes NVIDIA#7374
d8036f8 to
a3d204c
Compare
Comment on lines
+113
to
+115
| } | ||
|
|
||
| __stream.sync(); |
Contributor
There was a problem hiding this comment.
I would move the sync into the lifetime of __storage
Suggested change
| } | |
| __stream.sync(); | |
| __stream.sync(); | |
| } |
| ::cuda::std::execution::__pstl_select_dispatch<::cuda::std::execution::__pstl_algorithm::__remove_if, _Policy>(); | ||
| if constexpr (::cuda::std::execution::__pstl_can_dispatch<decltype(__dispatch)>) | ||
| { | ||
| _CCCL_NVTX_RANGE_SCOPE("cuda::std::remove_if"); |
Contributor
There was a problem hiding this comment.
Q: Why we we not putting the NVTX range across the entire algorithm? Even if the range is empty? We are doing this for CUB (we only skip the NVTX range for the temporary storage allocation query).
Contributor
😬 CI Workflow Results🟥 Finished in 2h 41m: Pass: 59%/150 | Total: 3d 03h | Max: 2h 34m | Hits: 80%/144364See results here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This implements the
removealgorithm for the cuda backend.std::removesee https://en.cppreference.com/w/cpp/algorithm/remove.htmlstd::remove_ifsee https://en.cppreference.com/w/cpp/algorithm/remove.htmlIt provides tests and benchmarks similar to Thrust and some boilerplate for libcu++
The functionality is publicly available yet and implemented in a private internal header
Fixes #7374