Repository navigation
Conversation
OverviewThis PR refactors Key ChangesCore API Updates (
|
| Layer / File(s) | Summary |
|---|---|
DeviceSelect::Flagged environment-based signatures and dispatch cub/cub/device/device_select.cuh |
Flagged temp-storage overloads add EnvT template parameter and accept const EnvT& env = {}; implementations route through dispatch_with_env_and_tuning forwarding environment-derived stream to detail::select::dispatch. Non-temp-storage overloads updated to take env as const EnvT& instead of by-value. Doxygen documentation adjusted for env parameters. |
DeviceSelect::If environment-based signatures and dispatch cub/cub/device/device_select.cuh |
If temp-storage overload adds EnvT template and accepts const EnvT& env = {}; implementation uses dispatch_with_env_and_tuning pattern matching Flagged. Non-temp-storage overloads (non-in-place and potentially in-place) take env as const EnvT&. |
DeviceSelect::FlaggedIf environment-based signatures and dispatch cub/cub/device/device_select.cuh |
FlaggedIf temp-storage overloads (both non-in-place and potentially in-place) add EnvT template and accept const EnvT& env = {}; implementations use dispatch_with_env_and_tuning forwarding policy/stream into select dispatch. Non-temp-storage overloads take env as const EnvT&. |
DeviceSelect test coverage for user temp storage and environments cub/test/catch2_test_device_select_flagged.cu, cub/test/catch2_test_device_select_if.cu, cub/test/catch2_test_device_select_flagged_if.cu |
New test cases added exercising user-provided temporary storage sizing (nullptr query followed by allocation and reuse) and validation across multiple environment forms (raw cudaStream_t, cuda::stream, cuda::stream_ref, cuda::std::execution::env, cuda::execution::gpu). Tests verify CUDA success states, synchronization, and output correctness against reference results. Includes updated CUDA headers for device/iterator/execution support. |
PSTL algorithm adapters for environment-based DeviceSelect libcudacxx/include/cuda/std/__pstl/cuda/copy_if.h, libcudacxx/include/cuda/std/__pstl/cuda/remove_if.h, libcudacxx/include/cuda/std/__pstl/cuda/shift_left.h |
Updated PSTL adapters (copy_if, remove_if, shift_left) to pass nullptr for temp-storage queries instead of explicit stream arguments, and changed pointer retrieval from __get_ptr<0>() to __get_raw_ptr<0>() for both kernel invocation and host result copy operations. |
Suggested labels
backport branch/3.3.x, backport branch/3.4.x
Suggested reviewers
- Jacobfaib
- gevtushenko
Comment @coderabbitai help to get the list of available commands and usage tips.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: eda339c3-aef7-47cf-a100-9f148328fefa
📒 Files selected for processing (6)
cub/cub/detail/env_dispatch.cuhcub/cub/device/device_find.cuhcub/cub/device/device_select.cuhcub/test/catch2_test_device_find_env.cucub/test/catch2_test_device_select_flagged_if.culibcudacxx/include/cuda/std/__pstl/cuda/find_if.h
| return detail::dispatch_with_env( | ||
| d_temp_storage, | ||
| temp_storage_bytes, | ||
| env, | ||
| [&]([[maybe_unused]] auto tuning, void* storage, size_t& bytes, auto stream) { | ||
| if (storage == nullptr) | ||
| { | ||
| bytes = 1; | ||
| return cudaSuccess; | ||
| } | ||
|
|
||
| return DeviceTransform::__transform_internal( | ||
| ::cuda::std::make_tuple(d_values), | ||
| d_output, | ||
| static_cast<ValuesOffsetT>(values_num_items), | ||
| ::cuda::always_true{}, | ||
| detail::find::make_binary_search_transform_op<detail::find::lower_bound>( | ||
| d_range, static_cast<RangeOffsetT>(range_num_items), comp), | ||
| ::cuda::stream_ref{stream}); | ||
| return DeviceTransform::__transform_internal( | ||
| ::cuda::std::make_tuple(d_values), | ||
| d_output, | ||
| static_cast<ValuesOffsetT>(values_num_items), | ||
| ::cuda::always_true{}, | ||
| detail::find::make_binary_search_transform_op<detail::find::lower_bound>( | ||
| d_range, static_cast<RangeOffsetT>(range_num_items), comp), | ||
| ::cuda::stream_ref{stream}); | ||
| }); |
There was a problem hiding this comment.
important: Forward env into DeviceTransform::__transform_internal here instead of collapsing it to ::cuda::stream_ref{stream}. These overloads now accept an execution environment, but the implementation only preserves the stream before entering DeviceTransform. cub/cub/device/device_transform.cuh:76-125 selects transform tuning from the Env it receives, so any tuning carried by env is silently ignored for LowerBound and UpperBound with external temp storage. That misses the stated goal of honoring environment-based tuning on user-provided-memory APIs.
Also applies to: 383-402
e328b00 to
8d2dafa
Compare
This comment has been minimized.
This comment has been minimized.
b1add85 to
bed1844
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
cub/cub/device/device_select.cuh (2)
125-150:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winsuggestion: The new docs describe the last parameter as an execution environment only, but these overloads are also meant to preserve stream-style usage. Please call out raw/default stream arguments explicitly here; otherwise the public API docs read as if stream support was removed. Based on PR objectives, these overloads should accept any environment or stream type.
Also applies to: 630-652, 768-794, 902-924, 1013-1042, 1127-1152
155-165:⚠️ Potential issue | 🔴 Criticalimportant: Restore/bridge
cudaStream_t-style null sentinels (e.g.,0/nullptr) inDeviceSelectenv-based overloads
cub/cub/detail/env_dispatch.cuhderives the stream via::cuda::__call_or(::cuda::get_stream, ::cuda::stream_ref{cudaStream_t{}}, env). If a caller passes0, that will deduceEnvT=intfor the env parameter, and the stream query will only compile ifget_streamis defined for integral types (or convertible), which isn’t evident from the dispatch layer alone.- The in-tree search for
DeviceSelect::{Flagged,If,FlaggedIf}(..., 0/nullptr)produced no matches, so this is likely a compatibility break for external callers rather than existing CCCL call sites.- Keep a
cudaStream_tforwarding overload (or add a constrained bridge that normalizes0/nullptrinto the expected env/stream representation before calling the env dispatch path) to preserve previous overload resolution for null-stream sentinels.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 6d45bece-7658-4272-85e7-e63cbff645bb
📒 Files selected for processing (7)
cub/cub/device/device_select.cuhcub/test/catch2_test_device_select_flagged.cucub/test/catch2_test_device_select_flagged_if.cucub/test/catch2_test_device_select_if.culibcudacxx/include/cuda/std/__pstl/cuda/copy_if.hlibcudacxx/include/cuda/std/__pstl/cuda/remove_if.hlibcudacxx/include/cuda/std/__pstl/cuda/shift_left.h
🚧 Files skipped from review as they are similar to previous changes (1)
- cub/test/catch2_test_device_select_flagged_if.cu
This comment has been minimized.
This comment has been minimized.
We want to be able to pass tunings to the APIs that take user provided memory Make sure we can pass any environment or stream type to them
bed1844 to
d19baae
Compare
🥳 CI Workflow Results🟩 Finished in 2h 29m: Pass: 100%/287 | Total: 11d 20h | Max: 2h 27m | Hits: 20%/931331See results here. |
We want to be able to pass tunings to the APIs that take user provided memory
Make sure we can pass any environment or stream type to them
DeviceFindIf#9318