Skip to content

[CUB] Test and document in-place BlockExchange overloads#10227

Open
BoyJayy wants to merge 1 commit into
NVIDIA:mainfrom
BoyJayy:issue-932-block-exchange-inplace
Open

[CUB] Test and document in-place BlockExchange overloads#10227
BoyJayy wants to merge 1 commit into
NVIDIA:mainfrom
BoyJayy:issue-932-block-exchange-inplace

Conversation

@BoyJayy

@BoyJayy BoyJayy commented Jul 24, 2026

Copy link
Copy Markdown

Description

Closes #932

This PR adds direct test coverage and documentation for all eight in-place cub::BlockExchange overloads.

The new Catch2 tests cover blocked, striped, warp-striped, and scatter exchanges across multiple block sizes, item counts, and data types. The in-place overloads are moved next to their corresponding output-parameter overloads, documented, and exposed to Doxygen by removing the _CCCL_DOXYGEN_INVOKED guard.

Testing

  • pre-commit run --files cub/cub/block/block_exchange.cuh cub/test/catch2_test_block_exchange.cu
  • CUDA build and runtime tests were not run locally because CUDA is unavailable on the development machine.

Checklist

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@copy-pr-bot

copy-pr-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Progress in CCCL Jul 24, 2026
@BoyJayy
BoyJayy marked this pull request as ready for review July 24, 2026 18:12
@BoyJayy
BoyJayy requested a review from a team as a code owner July 24, 2026 18:12
@BoyJayy
BoyJayy requested a review from miscco July 24, 2026 18:12
@cccl-authenticator-app cccl-authenticator-app Bot moved this from In Progress to In Review in CCCL Jul 24, 2026
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added in-place data rearrangement operations for blocked, striped, warp-striped, and scatter layouts.
    • Added guarded and validity-flagged in-place scatter operations.
    • Expanded API documentation for the new operations.
  • Tests

    • Added comprehensive CUDA tests covering all new exchange modes, data types, block sizes, and validity scenarios.

Walkthrough

Changes

In-place BlockExchange API

Layer / File(s) Summary
Documented in-place overloads
cub/cub/block/block_exchange.cuh
Adds in-place wrappers for striped, warp-striped, and rank-scatter operations, including guarded and validity-flagged variants.
Kernel and reference execution
cub/test/catch2_test_block_exchange.cu
Adds a parameterized CUDA kernel, launch wrapper, host reference mappings, and validity-aware scatter checks.
Parameterized operation coverage
cub/test/catch2_test_block_exchange.cu
Adds eight C2H tests covering integer types, block configurations, exchange modes, and scatter validity behavior.

Assessment against linked issues

Objective Addressed Explanation
Document the public in-place BlockExchange overloads [#932]
Add tests for the in-place exchange and scatter overloads [#932]

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

Warning

⚠️ This pull request shows signs of AI-generated slop (trivial_assertion). It has been flagged by CodeRabbit slop detection and should be reviewed carefully.

@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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
cub/test/catch2_test_block_exchange.cu (1)

24-28: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

suggestion: Parameterize WarpTimeSlicing and instantiate cub::BlockExchange<T, BlockThreads, ItemsPerThread, WarpTimeSlicing>. The current alias always selects the default false, leaving all eight in-place overloads untested against their time-sliced implementations.

As per path instructions, focus on test coverage.

Source: Path instructions


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: fade38b4-2d9d-4b76-9163-afacb85d2e3b

📥 Commits

Reviewing files that changed from the base of the PR and between 95081b6 and 88e0bfd.

📒 Files selected for processing (2)
  • cub/cub/block/block_exchange.cuh
  • cub/test/catch2_test_block_exchange.cu

Comment on lines +903 to +906
_CCCL_DEVICE _CCCL_FORCEINLINE void StripedToBlocked(T (&items)[ItemsPerThread])
{
StripedToBlocked(items, items);
}

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

python3 - <<'PY'
from pathlib import Path
path = Path("cub/cub/block/block_exchange.cuh")
lines = path.read_text().splitlines()
for start,end in [(890,920),(965,990),(1036,1060),(1108,1135),(1164,1240),(1290,1320),(1380,1410)]:
    print(f"\n--- {start}-{end} ---")
    for i in range(start-1, min(end, len(lines))):
        print(f"{i+1:4}: {lines[i]}")
PY

Repository: NVIDIA/cccl

Length of output: 8469


🏁 Script executed:

python3 - <<'PY'
from pathlib import Path
import re

path = Path("cub/cub/block/block_exchange.cuh")
text = path.read_text().splitlines()

names = [
    "StripedToBlocked(",
    "BlockedToStriped(",
    "WarpStripedToBlocked(",
    "BlockedToWarpStriped(",
    "ScatterToBlocked(",
    "ScatterToStriped(",
    "ScatterToStripedGuarded(",
    "ScatterToStripedFlagged(",
]
for name in names:
    print(f"\n### {name}")
    for i, line in enumerate(text, 1):
        if name in line:
            # print a small window around each occurrence
            for j in range(max(1, i-2), min(len(text), i+4)+1):
                print(f"{j:4}: {text[j-1]}")
            print("---")
PY

Repository: NVIDIA/cccl

Length of output: 18952


🏁 Script executed:

rg -n "noexcept" cub/cub/block/block_exchange.cuh

Repository: NVIDIA/cccl

Length of output: 149


suggestion: add noexcept to these forwarding overloads
Each wrapper only forwards to another BlockExchange method, so the in-place overloads should be marked noexcept too:

  • cub/cub/block/block_exchange.cuh#L903-L906
  • cub/cub/block/block_exchange.cuh#L974-L977
  • cub/cub/block/block_exchange.cuh#L1045-L1048
  • cub/cub/block/block_exchange.cuh#L1119-L1122
  • cub/cub/block/block_exchange.cuh#L1173-L1176
  • cub/cub/block/block_exchange.cuh#L1224-L1227
  • cub/cub/block/block_exchange.cuh#L1301-L1305
  • cub/cub/block/block_exchange.cuh#L1393-L1397
📍 Affects 1 file
  • cub/cub/block/block_exchange.cuh#L903-L906 (this comment)
  • cub/cub/block/block_exchange.cuh#L974-L977
  • cub/cub/block/block_exchange.cuh#L1045-L1048
  • cub/cub/block/block_exchange.cuh#L1119-L1122
  • cub/cub/block/block_exchange.cuh#L1173-L1176
  • cub/cub/block/block_exchange.cuh#L1224-L1227
  • cub/cub/block/block_exchange.cuh#L1301-L1305
  • cub/cub/block/block_exchange.cuh#L1393-L1397

Source: Coding guidelines

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.

[FEA]: Inplace overloads for BlockExchange need tests and documentation

1 participant