Skip to content

cuda::std::simd: Add shr, shl, bit_reverse#10058

Merged
fbusato merged 3 commits into
NVIDIA:mainfrom
fbusato:cuda-std-simd-bit
Jul 22, 2026
Merged

cuda::std::simd: Add shr, shl, bit_reverse#10058
fbusato merged 3 commits into
NVIDIA:mainfrom
fbusato:cuda-std-simd-bit

Conversation

@fbusato

@fbusato fbusato commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Description

Add C++29 binding to cuda::std::simd

Fixes #10041

@fbusato fbusato self-assigned this Jul 21, 2026
@fbusato
fbusato requested a review from a team as a code owner July 21, 2026 22:17
@fbusato
fbusato requested a review from Jacobfaib July 21, 2026 22:17
@fbusato fbusato added this to CCCL Jul 21, 2026
@fbusato fbusato added the libcu++ For all items related to libcu++ label Jul 21, 2026
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Jul 21, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Jul 21, 2026
Comment thread libcudacxx/include/cuda/std/__simd/bit/scalar.h Outdated
Comment thread libcudacxx/include/cuda/std/__simd/bit/scalar.h Outdated
@coderabbitai

coderabbitai Bot commented Jul 21, 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: 833c4297-dfc1-4187-9d2b-f8df32c92494

📥 Commits

Reviewing files that changed from the base of the PR and between db424ab and 8b45edf.

📒 Files selected for processing (4)
  • libcudacxx/include/cuda/std/__simd/bit/scalar.h
  • libcudacxx/test/libcudacxx/std/numerics/simd/simd.bit/bit_reverse.pass.cpp
  • libcudacxx/test/libcudacxx/std/numerics/simd/simd.bit/shl.pass.cpp
  • libcudacxx/test/libcudacxx/std/numerics/simd/simd.bit/shr.pass.cpp
🚧 Files skipped from review as they are similar to previous changes (4)
  • libcudacxx/test/libcudacxx/std/numerics/simd/simd.bit/shr.pass.cpp
  • libcudacxx/test/libcudacxx/std/numerics/simd/simd.bit/bit_reverse.pass.cpp
  • libcudacxx/test/libcudacxx/std/numerics/simd/simd.bit/shl.pass.cpp
  • libcudacxx/include/cuda/std/__simd/bit/scalar.h

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added scalar SIMD bit-manipulation APIs for fixed-size vector lanes, including bit reversal, byte swapping, bit ceil/floor, single-bit checks, shift-left/right (vector and scalar counts), rotations (vector counts), and bit-counting queries.
  • Tests
    • Added new pass tests for bit_reverse, shl, and shr, verifying per-lane correctness, return types, noexcept behavior, and overload/type constraints.

Walkthrough

Changes

The SIMD bit header now delegates to a scalar implementation header. The implementation adds per-lane bit manipulation, shift, rotate, and bit-counting APIs with constraints. Tests cover bit_reverse, shl, and shr values, types, noexcept, and overload availability.

SIMD bit operations

Layer / File(s) Summary
Scalar generators and dependencies
libcudacxx/include/cuda/std/__simd/bit.h, libcudacxx/include/cuda/std/__simd/bit/scalar.h
Adds per-lane generators and replaces the aggregate header’s prior dependency list with __simd/bit/scalar.h.
Public SIMD bit APIs
libcudacxx/include/cuda/std/__simd/bit/scalar.h
Exposes constrained wrappers for bit transforms, shifts, rotates, and bit-counting operations.
Bit-reverse validation
libcudacxx/test/libcudacxx/std/numerics/simd/simd.bit/bit_reverse.pass.cpp
Tests bit-reversal results, return types, noexcept, and supported element types.
Shift API validation
libcudacxx/test/libcudacxx/std/numerics/simd/simd.bit/shl.pass.cpp, libcudacxx/test/libcudacxx/std/numerics/simd/simd.bit/shr.pass.cpp
Tests vector and scalar shifts, boundary counts, elementwise results, and overload constraints.

Assessment against linked issues

Objective Addressed Explanation
Implement the SIMD portion of P3793R2 [#10041]

Possibly related issues

Possibly related PRs

  • NVIDIA/cccl#9993 — Provides the scalar shl/shr helpers used by the new SIMD implementations.
  • NVIDIA/cccl#10004 — Covers the scalar rotate helpers delegated to by SIMD rotl/rotr.

Suggested reviewers: davebayer, 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.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 01eaa830-7e69-42c3-8435-6b23a646c7ab

📥 Commits

Reviewing files that changed from the base of the PR and between d7823c5 and db424ab.

📒 Files selected for processing (5)
  • libcudacxx/include/cuda/std/__simd/bit.h
  • libcudacxx/include/cuda/std/__simd/bit/scalar.h
  • libcudacxx/test/libcudacxx/std/numerics/simd/simd.bit/bit_reverse.pass.cpp
  • libcudacxx/test/libcudacxx/std/numerics/simd/simd.bit/shl.pass.cpp
  • libcudacxx/test/libcudacxx/std/numerics/simd/simd.bit/shr.pass.cpp

Comment thread libcudacxx/test/libcudacxx/std/numerics/simd/simd.bit/shl.pass.cpp
@fbusato
fbusato enabled auto-merge (squash) July 21, 2026 22:53
@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 2h 31m: Pass: 100%/120 | Total: 1d 10h | Max: 1h 17m | Hits: 89%/427983

See results here.

@fbusato
fbusato merged commit 1e28ee2 into NVIDIA:main Jul 22, 2026
139 of 140 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libcu++ For all items related to libcu++

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[FEA]: SIMD part of P3793R2

2 participants