Repository navigation
Take CUB environments by const& - #10105
Conversation
This allows more types to be passed as environments, notably user-defined stream types that are not copyable but convertable to cudaStream_t.
📝 WalkthroughSummary by CodeRabbit
WalkthroughChangesThe PR changes environment parameters across CUB device algorithms and dispatch helpers from pass-by-value to Execution environment API updates
Suggested reviewers: Comment |
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 (1)
cub/cub/device/device_scan.cuh (1)
1568-1576: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick wincritical: Add the missing comma after
NullType{}at Line 1574. Without it,device_scan.cuhis ill-formed and cannot compile.
🧹 Nitpick comments (2)
cub/cub/device/device_reduce.cuh (1)
599-605: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winsuggestion: Add regression coverage for non-copyable environments.
Add a focused test environment with a deleted copy constructor, a
get_streamcustomization, and calls covering these overloads. This verifies the PR’s stated compatibility goal and prevents future reversion to pass-by-value.As per path instructions, CUB API changes should include coverage for relevant API and compile-time risks.
Also applies to: 676-679, 955-958, 1602-1605, 2240-2243, 2351-2354
Source: Path instructions
cub/cub/device/device_topk.cuh (1)
290-314: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuesuggestion: stale
::cuda::std::move(env)calls now meaningless.
dispatch_topk/dispatch_topk_hubtakeenvbyconst EnvT&(lines 57, 133). Passing::cuda::std::move(env)at the call sites (e.g. lines 313, 562, 791, 1040, 1252, 1467, 1671, 1886) just binds the const rvalue to the const lvalue-ref parameter — no move occurs. This misleadingly implies move semantics on an env this PR is explicitly making non-owning/const-ref, and could confuse future edits (e.g. if a param type reverts to by-value for a non-movable EnvT). Just passenvdirectly.♻️ Example fix (repeat pattern at each call site)
- detail::identity_decomposer_t{}, - ::cuda::std::move(env)); + detail::identity_decomposer_t{}, + env);Also applies to: 534-563, 768-792, 1012-1041, 1231-1253, 1441-1468, 1650-1672, 1860-1887
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 06d6d272-4924-4d91-bdea-02f46fd0c7d0
📒 Files selected for processing (17)
cub/cub/device/device_batched_topk.cuhcub/cub/device/device_find.cuhcub/cub/device/device_memcpy.cuhcub/cub/device/device_merge.cuhcub/cub/device/device_merge_sort.cuhcub/cub/device/device_radix_sort.cuhcub/cub/device/device_reduce.cuhcub/cub/device/device_run_length_encode.cuhcub/cub/device/device_scan.cuhcub/cub/device/device_segmented_radix_sort.cuhcub/cub/device/device_segmented_reduce.cuhcub/cub/device/device_segmented_scan.cuhcub/cub/device/device_segmented_sort.cuhcub/cub/device/device_topk.cuhcub/cub/device/dispatch/dispatch_batched_topk.cuhcub/test/catch2_test_env_launch_helper.hdocs/cub/developer/device_scope.rst
const&const&
|
pre-commit.ci autofix |
🥳 CI Workflow Results🟩 Finished in 8h 30m: Pass: 100%/287 | Total: 12d 20h | Max: 2h 40m | Hits: 19%/1023852See results here. |
This allows more types to be passed as environments, notably user-defined stream types that are not copyable but convertable to cudaStream_t.
This allows more types to be passed as environments, notably user-defined stream types that are not copyable but convertable to
cudaStream_t.Some work in this direction was already done while working on #9875.