Skip to content

[libcu++] Implement tuple protocol for integer_sequence#9129

Open
davebayer wants to merge 1 commit into
NVIDIA:mainfrom
davebayer:intseq_bindings
Open

[libcu++] Implement tuple protocol for integer_sequence#9129
davebayer wants to merge 1 commit into
NVIDIA:mainfrom
davebayer:intseq_bindings

Conversation

@davebayer
Copy link
Copy Markdown
Contributor

This PR implements tuple protocol for integer_sequence (P1789R3) from C++26

@davebayer davebayer requested review from a team as code owners May 26, 2026 13:19
@davebayer davebayer requested a review from caugonnet May 26, 2026 13:19
@davebayer davebayer requested a review from wmaxey May 26, 2026 13:19
@github-project-automation github-project-automation Bot moved this to Todo in CCCL May 26, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL May 26, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 26, 2026

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • cuda::std::integer_sequence now supports tuple protocol: tuple_size, tuple_element, and get() for mutable and const forms.
    • Improved compiler feature detection for structured-binding pack support.
  • Tests

    • Added tests validating tuple-interface integration, structured bindings, and noexcept/get behavior.
  • Chores

    • Updated library feature-test/versioning for integer_sequence and copyright years.

suggestion:

Walkthrough

Centralizes structured-bindings-pack detection, updates visit.cuh to use the new predicate, adds tuple-protocol specializations (tuple_size, tuple_element, get) for cuda::std::integer_sequence, bumps the integer_sequence feature-test macro, and adds tests validating tuple-like access and structured bindings.

Changes

Structured bindings pack support and tuple protocol

Layer / File(s) Summary
Structured bindings pack feature detection
libcudacxx/include/cuda/std/__cccl/dialect.h
Introduces _CCCL_HAS_STRUCTURED_BINDINGS_PACK() macro that detects pack support via __cpp_structured_bindings and compiler-version thresholds; explicitly disables it under NVCC.
Visit API refactoring
cudax/include/cuda/experimental/__execution/visit.cuh
Replaces local __cpp_structured_bindings-based checks with _CCCL_HAS_STRUCTURED_BINDINGS_PACK() to select between pack-based and fixed-arity unrolling implementations in visit_t.
Tuple protocol for integer_sequence
libcudacxx/include/cuda/std/__utility/integer_sequence.h, libcudacxx/include/cuda/std/version
Adds cuda::std::tuple_size, cuda::std::tuple_element (mutable and const), and cuda::std::get overload with bounds-check static_asserts; adds parallel std:: specializations; bumps __cccl_lib_integer_sequence to 202511L.
Tuple protocol integration tests
libcudacxx/test/libcudacxx/std/utilities/intseq/intseq.binding/tuple_interface.pass.cpp
Adds a host/device constexpr test validating tuple_size_v, tuple_element_t, get<I> noexcept, and structured bindings via static_assert and runtime assert.

Suggested reviewers

  • ericniebler
  • elstehle
  • NaderAlAwar

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

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 (2)
libcudacxx/include/cuda/std/__utility/integer_sequence.h (2)

248-248: ⚡ Quick win

suggestion: Fix typo in comment.

"sequnence" → "sequence"

-// specialize cuda::std::tuple_size and cuda::std::tuple_element for cuda::std::integer_sequnence
+// specialize cuda::std::tuple_size and cuda::std::tuple_element for cuda::std::integer_sequence

280-280: ⚡ Quick win

suggestion: Fix typo in comment.

"sequnence" → "sequence"

-// tuple protocol for cuda::std::integer_sequnence
+// tuple protocol for cuda::std::integer_sequence

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 65b20831-4197-4671-a73f-1ca436bac9df

📥 Commits

Reviewing files that changed from the base of the PR and between 8623dab and d649c52.

📒 Files selected for processing (5)
  • cudax/include/cuda/experimental/__execution/visit.cuh
  • libcudacxx/include/cuda/std/__cccl/dialect.h
  • libcudacxx/include/cuda/std/__utility/integer_sequence.h
  • libcudacxx/include/cuda/std/version
  • libcudacxx/test/libcudacxx/std/utilities/intseq/intseq.binding/tuple_interface.pass.cpp

Comment thread libcudacxx/include/cuda/std/__cccl/dialect.h
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
libcudacxx/test/libcudacxx/std/utilities/intseq/intseq.binding/tuple_interface.pass.cpp (1)

59-64: ⚡ Quick win

suggestion: add a const auto [cv0, cv1, cv2, cv3] = seq4; case here. The current test only instantiates the non-const std::tuple_element path through structured bindings, so the new const specialization added in the header can still regress without this file noticing.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 36c3fd09-2d49-48bb-b9f1-60fba8c38625

📥 Commits

Reviewing files that changed from the base of the PR and between d649c52 and 6fdb61b.

📒 Files selected for processing (5)
  • cudax/include/cuda/experimental/__execution/visit.cuh
  • libcudacxx/include/cuda/std/__cccl/dialect.h
  • libcudacxx/include/cuda/std/__utility/integer_sequence.h
  • libcudacxx/include/cuda/std/version
  • libcudacxx/test/libcudacxx/std/utilities/intseq/intseq.binding/tuple_interface.pass.cpp

@github-actions
Copy link
Copy Markdown
Contributor

😬 CI Workflow Results

🟥 Finished in 1h 45m: Pass: 99%/159 | Total: 2d 03h | Max: 1h 44m | Hits: 69%/618936

See results here.

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.

1 participant