Skip to content

Remove most CCCL_GRID_CONSTANT annotations - #9858

Merged
bernhardmgruber merged 4 commits into
NVIDIA:mainfrom
bernhardmgruber:revert_grid_constant
Jul 14, 2026
Merged

Remove most CCCL_GRID_CONSTANT annotations#9858
bernhardmgruber merged 4 commits into
NVIDIA:mainfrom
bernhardmgruber:revert_grid_constant

Conversation

@bernhardmgruber

@bernhardmgruber bernhardmgruber commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

QA reported several regressions caused by the introduction of _CCCL_GRID_CONSTANT in #6642. The regressions include:

The cause of the regression is probably a compiler bug, reported in NVBug 6448961. When the fix is available, we will be able to bring the _CCCL_GRID_CONSTANT annotations back, but this time after carefully benchmarking their impact :)

This PR mainly reverts #6642, but since a lot of time has passed, I needed to do a lot of manual editing as well.

This PR supersedes:

Previous PRs removing annotations:

This PR will not remove annotations from these kernels, because they have not been added by #6642 and QA did not report any regressions:

  • device_partition_find_bound_sorted_values_kernel
  • device_find_bound_sorted_values_kernel
  • __copy_contiguous_kernel
  • __copy_optimized_kernel
  • __copy_shared_mem_kernel
  • loop (in parallel_for_scope.cuh in STF)
  • __kernel_launcher_with_block_size (part of cuda::launch)
  • benchmark_kernel (part of nvbench_helper)

Fixes: #9768
Fixes: #9822
Fixes: #9851

@bernhardmgruber
bernhardmgruber requested a review from a team as a code owner July 14, 2026 15:30
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Jul 14, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Jul 14, 2026
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

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: 3f778b8c-06e7-4aac-b3cf-2204d66109e2

📥 Commits

Reviewing files that changed from the base of the PR and between 0a21375 and 9b4fe36.

📒 Files selected for processing (1)
  • cub/cub/device/dispatch/kernels/kernel_scan.cuh
💤 Files with no reviewable changes (1)
  • cub/cub/device/dispatch/kernels/kernel_scan.cuh

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved CUDA kernel build compatibility by standardizing kernel parameter qualifiers across multiple CUB device algorithms (e.g., scan, reduce, sort, merge, top-k, transform, partition, histogram).
    • Preserved existing kernel and dispatch behavior while reducing the likelihood of toolchain-specific compilation issues.
  • Performance
    • No runtime behavior changes expected; algorithm and dispatch logic remain the same.

Walkthrough

Changes

CUB CUDA kernel signatures remove _CCCL_GRID_CONSTANT annotations and retain equivalent standard const and pointer-const qualifiers. Kernel bodies, dispatch flow, parameter ordering, and algorithm behavior are unchanged.

CUB kernel entrypoints

Layer / File(s) Summary
Dispatch kernel entrypoints
cub/cub/device/dispatch/dispatch_*.cuh
Adjacent-difference, batch-memcpy, merge, reduce-by-key, RLE, scan-by-key, segmented-sort, and TopK kernel parameters no longer use _CCCL_GRID_CONSTANT.
General algorithm kernels
cub/cub/device/dispatch/kernels/kernel_for_each.cuh, kernel_histogram.cuh, kernel_transform.cuh, kernel_unique_by_key.cuh, kernel_three_way_partition.cuh
Kernel scalar, iterator, wrapper, and pointer parameters use standard qualifiers instead of _CCCL_GRID_CONSTANT.
Sorting and selection kernels
cub/cub/device/dispatch/kernels/kernel_radix_sort.cuh, kernel_segmented_radix_sort.cuh, kernel_segmented_sort.cuh
Radix-sort and segmented-sort kernel signatures remove grid-constant annotations while preserving parameter types and ordering.
Reduction and scan kernels
cub/cub/device/dispatch/kernels/kernel_reduce.cuh, kernel_scan.cuh, kernel_segmented_reduce.cuh, kernel_segmented_scan.cuh
Reduction and scan kernel entrypoints replace _CCCL_GRID_CONSTANT with ordinary const and pointer-const declarations.

Possibly related PRs

Suggested reviewers: gevtushenko, pauleonix, srinivasyadav18, jacobfaib


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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
cub/cub/device/dispatch/kernels/kernel_scan.cuh (1)

205-211: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

suggestion: The #if _CCCL_CUDACC_AT_LEAST(12, 8) / #endif block at Lines 206-208 is now empty — it previously guarded a _CCCL_GRID_CONSTANT annotation on init_value that has been removed. Leaving a no-op conditional is confusing dead code; consider dropping the guard entirely since it no longer wraps anything.

🧹 Proposed cleanup
   const ScanOpT scan_op,
-// nvcc 12.0 gets stuck compiling some TUs like `cub.bench.scan.exclusive.sum.base`, so only enable for newer versions
-#if _CCCL_CUDACC_AT_LEAST(12, 8)
-
-#endif // _CCCL_CUDACC_AT_LEAST(12, 8)
   const InitValueT init_value,

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 525248ef-8250-440b-a044-a58937d587f4

📥 Commits

Reviewing files that changed from the base of the PR and between 5f23d49 and 0a21375.

📒 Files selected for processing (20)
  • cub/cub/device/dispatch/dispatch_adjacent_difference.cuh
  • cub/cub/device/dispatch/dispatch_batch_memcpy.cuh
  • cub/cub/device/dispatch/dispatch_merge.cuh
  • cub/cub/device/dispatch/dispatch_reduce_by_key.cuh
  • cub/cub/device/dispatch/dispatch_rle.cuh
  • cub/cub/device/dispatch/dispatch_scan_by_key.cuh
  • cub/cub/device/dispatch/dispatch_segmented_sort.cuh
  • cub/cub/device/dispatch/dispatch_topk.cuh
  • cub/cub/device/dispatch/kernels/kernel_for_each.cuh
  • cub/cub/device/dispatch/kernels/kernel_histogram.cuh
  • cub/cub/device/dispatch/kernels/kernel_radix_sort.cuh
  • cub/cub/device/dispatch/kernels/kernel_reduce.cuh
  • cub/cub/device/dispatch/kernels/kernel_scan.cuh
  • cub/cub/device/dispatch/kernels/kernel_segmented_radix_sort.cuh
  • cub/cub/device/dispatch/kernels/kernel_segmented_reduce.cuh
  • cub/cub/device/dispatch/kernels/kernel_segmented_scan.cuh
  • cub/cub/device/dispatch/kernels/kernel_segmented_sort.cuh
  • cub/cub/device/dispatch/kernels/kernel_three_way_partition.cuh
  • cub/cub/device/dispatch/kernels/kernel_transform.cuh
  • cub/cub/device/dispatch/kernels/kernel_unique_by_key.cuh

@bernhardmgruber
bernhardmgruber enabled auto-merge (squash) July 14, 2026 16:01
@bernhardmgruber
bernhardmgruber disabled auto-merge July 14, 2026 16:20
@bernhardmgruber
bernhardmgruber enabled auto-merge (squash) July 14, 2026 16:20
@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 3h 34m: Pass: 100%/287 | Total: 6d 05h | Max: 2h 12m | Hits: 43%/525623

See results here.

@bernhardmgruber
bernhardmgruber merged commit d8fd76b into NVIDIA:main Jul 14, 2026
606 of 611 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Backport failed for branch/3.4.x, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin branch/3.4.x
git worktree add -d .worktree/backport-9858-to-branch/3.4.x origin/branch/3.4.x
cd .worktree/backport-9858-to-branch/3.4.x
git switch --create backport-9858-to-branch/3.4.x
git cherry-pick -x d8fd76b44b0e4de1ae6e1b4d606fe72636b10df4

@bernhardmgruber
bernhardmgruber deleted the revert_grid_constant branch July 14, 2026 20:28
wmaxey pushed a commit that referenced this pull request Jul 14, 2026
…uding merge sort (#9864)

* Remove most `CCCL_GRID_CONSTANT` annotations (#9858)

QA reported several regressions caused by the introduction of `_CCCL_GRID_CONSTANT` in #6642. The regressions include:

- #9763
- #9765
- #9766
- #9768
- #9822

The cause of the regression is probably a compiler bug, reported in NVBug 6448961. This PR mainly reverts #6642, but since a lot of time has passed, I needed to do a lot of manual editing as well.

Fixes: #9768
Fixes: #9822
Fixes: #9851
(cherry picked from commit d8fd76b)

* Remove _CCCL_GRID_CONSTANT from merge sort kernel parameters (#9829)

Co-authored-by: Paul Grosse-Bley <pauleonix-dev@pm.me>

---------

Co-authored-by: nanan-nvidia <nan@nvidia.com>
Co-authored-by: Paul Grosse-Bley <pauleonix-dev@pm.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

3 participants