Skip to content

Fix mdspan support in modernized CUB interfaces - #9020

Merged
pauleonix merged 2 commits into
NVIDIA:mainfrom
pauleonix:thread_reduce_partial_test_fix
May 15, 2026
Merged

pauleonix merged 2 commits into
NVIDIA:mainfrom
pauleonix:thread_reduce_partial_test_fix

Conversation

@pauleonix

@pauleonix pauleonix commented May 15, 2026 •

Copy link
Copy Markdown
Contributor

Description

A growing number of CUB thread primitives accept not only C-style arrays, but any "fixed-size random access range" like cuda::std::array, cuda::std::span and 1D cuda::std::mdspan. See #1877 for context.

The tests for mdspan where not build/executed in the past due to #if _CCCL_STD_VER >= 2023. This is unnecessary as we have operator[] on 1D mdpsans even with C++17.

This PR

  • removes the unnecessary preprocessor conditionals from tests
  • Adds missing includes to tests
  • Fixes helpers for handling of mdspan in the mentioned primitives (they were not compiling).

The later two issues did not surface before because the corresponding tests were not compiled.

Checklist

  • I am familiar with the Contributing Guidelines. -->
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

pauleonix added 2 commits May 15, 2026 14:37
Also make mdspan tests run with all supported C++ standards as we have a
backported operator[] for the 1D mdspan case.
mdspan support was broken due to missing parentheses.
@pauleonix pauleonix self-assigned this May 15, 2026
@pauleonix
pauleonix requested a review from a team as a code owner May 15, 2026 12:48
@pauleonix
pauleonix requested a review from srinivasyadav18 May 15, 2026 12:48
@github-project-automation github-project-automation Bot moved this to Todo in CCCL May 15, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL May 15, 2026
@pauleonix
pauleonix requested a review from fbusato May 15, 2026 12:49
@coderabbitai

coderabbitai Bot commented May 15, 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: bd9c0029-cbaa-45fd-b29a-57bd174735c8

📥 Commits

Reviewing files that changed from the base of the PR and between a987210 and 71612f8.

📒 Files selected for processing (5)
  • cub/cub/detail/type_traits.cuh
  • cub/test/catch2_test_thread_scan_exclusive_partial.cu
  • cub/test/catch2_test_thread_scan_inclusive_partial.cu
  • cub/test/thread_reduce/catch2_test_thread_reduce.cu
  • cub/test/thread_reduce/catch2_test_thread_reduce_partial.cu

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • mdspan support for thread scan and reduce operations is now unconditionally enabled (previously required C++2023 or later)
  • Tests

    • Extended mdspan test coverage to run across all compiler configurations for scan, reduce, and partial operations

Walkthrough

Type traits specializations for std::mdspan are corrected to call rank() and rank_dynamic() as methods. Four test files add mdspan headers and remove C++ version guards, allowing mdspan-based kernels in scan and reduce operations to compile unconditionally.

Changes

Unconditional mdspan support

Layer / File(s) Summary
Type traits mdspan method call syntax
cub/cub/detail/type_traits.cuh
is_fixed_size_random_access_range_v and static_size_v specializations for ::cuda::std::mdspan switch from accessing E::rank and E::rank_dynamic as values to calling E::rank() and E::rank_dynamic() as functions in their enable conditions.
Scan tests unconditional mdspan compilation
cub/test/catch2_test_thread_scan_exclusive_partial.cu, cub/test/catch2_test_thread_scan_inclusive_partial.cu
Both exclusive and inclusive partial scan test files add <cuda/std/mdspan> includes and remove _CCCL_STD_VER >= 2023 guards from mdspan kernel definitions and test invocations.
Reduce tests unconditional mdspan compilation
cub/test/thread_reduce/catch2_test_thread_reduce.cu, cub/test/thread_reduce/catch2_test_thread_reduce_partial.cu
Both reduce and reduce partial test files add <cuda/std/mdspan> includes and remove _CCCL_STD_VER >= 2023 preprocessor guards around kernel definitions and container test launches.

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

@pauleonix
pauleonix enabled auto-merge (squash) May 15, 2026 12:57
@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 2h 49m: Pass: 100%/283 | Total: 11d 18h | Max: 2h 49m | Hits: 11%/1387079

See results here.

@pauleonix
pauleonix merged commit 9c11be2 into NVIDIA:main May 15, 2026
304 of 307 checks passed
@github-project-automation github-project-automation Bot moved this from In Review to Done in CCCL May 15, 2026
@pauleonix
pauleonix deleted the thread_reduce_partial_test_fix branch May 15, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants