Skip to content

Use uniform type names for init values throughout CUB#9267

Open
gonidelis wants to merge 2 commits into
NVIDIA:mainfrom
gonidelis:init_values_names
Open

Use uniform type names for init values throughout CUB#9267
gonidelis wants to merge 2 commits into
NVIDIA:mainfrom
gonidelis:init_values_names

Conversation

@gonidelis
Copy link
Copy Markdown
Member

@gonidelis gonidelis commented Jun 5, 2026

fixes #7974

enforces existing CUB naming convention:

  • InitValueT: template parameters use PascalCase + T suffix (e.g. InputIteratorT, ReductionOpT, AccumT). These are part of the public/dispatch interface.
  • init_value_t: local using aliases inside function bodies use snake_case + _t suffix.

@gonidelis gonidelis requested review from a team as code owners June 5, 2026 01:09
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Jun 5, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Jun 5, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 5, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 6a9af2ca-76b5-4662-98b4-7e9936c69ed4

📥 Commits

Reviewing files that changed from the base of the PR and between c06e223 and d237898.

📒 Files selected for processing (29)
  • cub/benchmarks/bench/reduce/base.cuh
  • cub/benchmarks/bench/reduce/nondeterministic.cu
  • cub/benchmarks/bench/scan/exclusive/base.cuh
  • cub/benchmarks/bench/scan/exclusive/deterministic.cu
  • cub/benchmarks/bench/segmented_reduce/base.cuh
  • cub/benchmarks/bench/transform_reduce/sum.cu
  • cub/cub/device/device_reduce.cuh
  • cub/cub/device/device_scan.cuh
  • cub/cub/device/device_segmented_reduce.cuh
  • cub/cub/device/dispatch/dispatch_reduce.cuh
  • cub/cub/device/dispatch/dispatch_reduce_deterministic.cuh
  • cub/cub/device/dispatch/dispatch_reduce_nondeterministic.cuh
  • cub/cub/device/dispatch/dispatch_segmented_reduce.cuh
  • cub/cub/device/dispatch/kernels/kernel_reduce.cuh
  • cub/test/catch2_test_device_reduce.cu
  • cub/test/catch2_test_device_reduce_deterministic.cu
  • cub/test/catch2_test_device_reduce_dispatcher.cu
  • cub/test/catch2_test_device_reduce_env.cu
  • cub/test/catch2_test_device_reduce_iterators.cu
  • cub/test/catch2_test_device_reduce_nondeterministic.cu
  • cub/test/catch2_test_device_scan.cu
  • cub/test/catch2_test_device_scan_by_key.cu
  • cub/test/catch2_test_device_scan_by_key_iterators.cu
  • cub/test/catch2_test_device_scan_invalid.cu
  • cub/test/catch2_test_device_scan_iterators.cu
  • cub/test/catch2_test_device_segmented_reduce.cu
  • cub/test/catch2_test_device_segmented_reduce_iterators.cu
  • cub/test/catch2_test_device_segmented_reduce_max_seg_size.cu
  • cub/test/catch2_test_device_transform_reduce.cu
✅ Files skipped from review due to trivial changes (8)
  • cub/test/catch2_test_device_reduce.cu
  • cub/test/catch2_test_device_scan_iterators.cu
  • cub/benchmarks/bench/transform_reduce/sum.cu
  • cub/test/catch2_test_device_scan_by_key.cu
  • cub/test/catch2_test_device_segmented_reduce_max_seg_size.cu
  • cub/cub/device/device_reduce.cuh
  • cub/benchmarks/bench/scan/exclusive/base.cuh
  • cub/test/catch2_test_device_reduce_nondeterministic.cu
🚧 Files skipped from review as they are similar to previous changes (20)
  • cub/test/catch2_test_device_scan_invalid.cu
  • cub/test/catch2_test_device_segmented_reduce.cu
  • cub/test/catch2_test_device_reduce_iterators.cu
  • cub/benchmarks/bench/scan/exclusive/deterministic.cu
  • cub/test/catch2_test_device_scan_by_key_iterators.cu
  • cub/benchmarks/bench/reduce/base.cuh
  • cub/benchmarks/bench/segmented_reduce/base.cuh
  • cub/benchmarks/bench/reduce/nondeterministic.cu
  • cub/test/catch2_test_device_transform_reduce.cu
  • cub/test/catch2_test_device_reduce_dispatcher.cu
  • cub/test/catch2_test_device_segmented_reduce_iterators.cu
  • cub/test/catch2_test_device_reduce_deterministic.cu
  • cub/cub/device/device_scan.cuh
  • cub/cub/device/dispatch/dispatch_reduce_nondeterministic.cuh
  • cub/cub/device/dispatch/dispatch_reduce_deterministic.cuh
  • cub/cub/device/device_segmented_reduce.cuh
  • cub/test/catch2_test_device_reduce_env.cu
  • cub/cub/device/dispatch/dispatch_reduce.cuh
  • cub/cub/device/dispatch/kernels/kernel_reduce.cuh
  • cub/cub/device/dispatch/dispatch_segmented_reduce.cuh

Note: CodeRabbit is enabled on this repository as a convenience for maintainers
and contributors. Use your best judgment when considering its review comments and
suggestions — a suggested change may be inadequate, unnecessary, or safe to ignore.
Contributors are not expected to address every comment. Human reviews are what
ultimately matter for merging.

Summary

This PR standardizes type naming for initial values across the CUB codebase to follow the existing convention:

  • Template parameter names: PascalCase with T suffix → InitValueT
  • Local using/type-alias names: snake_case with _t suffix → init_value_t

Changes are purely identifier/type-name renames and propagation; no algorithmic or behavioral changes were introduced.

Scope of Changes

Affected files: 28 files, ~166 lines changed (mix of benchmarks, core device headers, dispatch plumbing, kernel templates, and tests).

Highlights:

  • Benchmarks: renamed local init aliases to init_value_t and updated usages (reduce, scan, segmented/transform_reduce benchmarks).
  • Core device headers: internal renames (e.g., device_reduce.cuh, device_scan.cuh, device_segmented_reduce.cuh) to use InitValueT / init_value_t.
  • Dispatch infrastructure: propagated InitValueT through dispatch templates and public dispatch entrypoints (reduce, transform-reduce, segmented-reduce, deterministic/nondeterministic paths).
  • Kernel templates: kernel template parameters and init-parameter types renamed to InitValueT; added/adjusted unwrap/finalize helpers for empty_problem_init_t<InitValueT>.
  • Tests: updated numerous Catch2 tests and reference helpers to use init_value_t / InitValueT consistently.

Impact Assessment

  • Public API: No end-user-facing API behavior changes. Some dispatch/kernelling template parameter names were renamed (e.g., InitTInitValueT) in dispatch headers and kernel templates; these are template-parameter identifier changes rather than semantic API changes.
  • Backward compatibility: Typical user code should be unaffected. Code that explicitly references the old template parameter identifier (InitT) in manual instantiations or relies on the prior parameter name in documentation may require small adjustments.
  • Tests/benchmarks: Updated to match new naming; coverage retained.

Notes for Reviewers

  • Review focus: ensure all InitT/init_t occurrences were consistently replaced with InitValueT/init_value_t and that default template computations (accumulator selection, non-void defaults) were updated to derive from InitValueT.
  • Pay attention to dispatch and kernel-template instantiations where the InitValueT propagates to AccumT defaults and to empty_problem_init_t handling.

suggestion: ## Walkthrough

This PR uniformly renames initial-value type identifiers from InitT/init_t to InitValueT/init_value_t across dispatch templates, kernels, device APIs, benchmarks, and tests.

Changes

Initial value type naming consolidation

Layer / File(s) Summary
Dispatch type contracts
cub/cub/device/dispatch/dispatch_reduce.cuh, cub/cub/device/dispatch/dispatch_reduce_deterministic.cuh, cub/cub/device/dispatch/dispatch_reduce_nondeterministic.cuh, cub/cub/device/dispatch/dispatch_segmented_reduce.cuh, cub/cub/device/dispatch/dispatch_streaming_reduce.cuh
Template parameter InitT renamed to InitValueT throughout dispatch signatures, accumulator selection, and detail::reduce/detail::segmented_reduce dispatch entrypoints.
Kernel parameter adaptation
cub/cub/device/dispatch/kernels/kernel_reduce.cuh, cub/cub/device/dispatch/kernels/kernel_reduce_deterministic.cuh, cub/cub/device/dispatch/kernels/kernel_segmented_reduce.cuh
Kernel template parameters and signatures renamed from InitT to InitValueT; helpers unwrap_empty_problem_init and finalize_and_store_aggregate updated to handle empty_problem_init_t<InitValueT>.
Device public APIs
cub/cub/device/device_reduce.cuh, cub/cub/device/device_scan.cuh, cub/cub/device/device_segmented_reduce.cuh
Internal aliases renamed to init_value_t/InitValueT in convenience overloads (Sum, Min, Max, ArgMin, ArgMax), scan ops, and dispatch call sites; public API signatures unchanged.
Benchmark updates
cub/benchmarks/bench/reduce/*, cub/benchmarks/bench/scan/exclusive/*, cub/benchmarks/bench/segmented_reduce/*, cub/benchmarks/bench/transform_reduce/sum.cu
Local aliases and tuned policy accumulator template arguments updated to use init_value_t and initializers constructed as init_value_t{}.
Test helpers and validation
cub/test/* (device reduce/scan/segmented reduce tests and helpers)
Reference helpers and tests updated to use InitValueT/init_value_t in templates and to pass init_value_t{} into device APIs; kernel-type checks and compile-time instantiations adjusted accordingly.

Assessment against linked issues

Objective Addressed Explanation
Consolidate initial value type naming to a single uniform name [#7974]
Use InitValueT/init_value_t consistently across all device headers [#7974]
Update dispatch, kernel, and device API implementations to use unified naming [#7974]

Suggested reviewers

  • bernhardmgruber
  • miscco
  • oleksandr-pavlyk
  • srinivasyadav18

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 5, 2026

🥳 CI Workflow Results

🟩 Finished in 2h 23m: Pass: 100%/284 | Total: 11d 11h | Max: 2h 23m | Hits: 19%/967498

See results here.

// for selecting the extremum across partitions.
//
// @tparam InitT
// @tparam InitValueT
Copy link
Copy Markdown
Contributor

@miscco miscco Jun 5, 2026

Choose a reason for hiding this comment

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

Important, I do not see InitValueT as a template argument

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

InitValueT, init_value_t and init_t in CUB device

3 participants