Skip to content

[libcu++] Improve the implementation of tuple_cat - #11323

Open
miscco wants to merge 3 commits into
NVIDIA:mainfrom
miscco:improve_tuple_cat
Open

[libcu++] Improve the implementation of tuple_cat#11323
miscco wants to merge 3 commits into
NVIDIA:mainfrom
miscco:improve_tuple_cat

Conversation

@miscco

@miscco miscco commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

It relied on recursive types. Rather than that use recursive functions and type aliases.

Every event matching tuple_cat when compiling MatX

tuple_cat were some of the more costly templates in Matx

Inclusive duration, grouped by NVCC primary template / header / function. 506 distinct specializations collapse into these six keys.

Event Primary key Baseline (s) Current (s) Δ (s) Count (base → cur)
Instantiating Template Class __tuple_cat_return_1 195.694 0.000 −195.694 39180 → 0
Instantiating Template Function __tuple_cat_return_impl 0.000 171.677 +171.677 0 → 38708
Instantiating Template Class __tuple_cat_return 41.981 0.000 −41.981 7082 → 0
Instantiating Template Class __tuple_cat_type 3.069 0.000 −3.069 25492 → 0
Processing Header File tuple_cat.h 3.660 1.530 −2.130 626 → 626
Scanning Function Body tuple_cat() 0.047 0.046 −0.002 626 → 626

Old recursive class helpers (__tuple_cat_return_1, __tuple_cat_return, __tuple_cat_type) drop to zero. They are replaced by __tuple_cat_return_impl at 171.7 s inclusive — cheaper than the 195.7 s class it replaces, plus the extra ~45 s of the other two helpers.

@miscco
miscco requested a review from a team as a code owner September 10, 2026 06:51
@miscco
miscco requested a review from ericniebler September 10, 2026 06:51
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Sep 10, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Sep 10, 2026
@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: 2fca374a-cd0a-4131-bb01-8f6b1f1a636f

📥 Commits

Reviewing files that changed from the base of the PR and between 8da8a83 and c576d42.

📒 Files selected for processing (1)
  • libcudacxx/include/cuda/std/__tuple_dir/tuple_cat.h
🚧 Files skipped from review as they are similar to previous changes (1)
  • libcudacxx/include/cuda/std/__tuple_dir/tuple_cat.h

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.


📝 Summary

Summary by CodeRabbit

  • New Features

    • Expanded tuple concatenation support for CUDA tuple-like types, arrays, pairs, complex values, and host standard-library tuples.
    • Added compile-time (constexpr) tuple concatenation support.
  • Bug Fixes

    • Improved Microsoft Visual C++ compatibility when working with CUDA and standard arrays.
  • Tests

    • Expanded coverage for empty, nested, move-only, reference, ordering, and mixed tuple concatenation scenarios, including host and CUDA tuple-like inputs.

Walkthrough

The change refactors tuple_cat type construction and element assembly, adds MSVC-specific std::array tuple-type support, and expands compile-time and runtime coverage for CUDA and host tuple-like inputs.

Changes

Tuple concatenation

Layer / File(s) Summary
Tuple type contracts and compiler support
libcudacxx/include/cuda/std/__tuple_dir/tuple_cat.h, libcudacxx/include/cuda/std/__tuple_dir/make_tuple_types.h
Return types now derive from merged __tuple_types. CUDA and host std::array tuple-type specializations add an MSVC-compatible path.
Constrained tuple concatenation implementation
libcudacxx/include/cuda/std/__tuple_dir/tuple_cat.h
tuple_cat constrains tuple-like inputs and assembles elements through get and forward_as_tuple with forwarding preserved.
Tuple concatenation test coverage
libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp
Tests now run at compile time and runtime and cover CUDA, host, empty, nested, reference, movable, array, complex, pair, and tuple-like inputs.

Suggested reviewers: davebayer

Priority: ⬇️ Low

Change: Refactor

Merge Risk: 🔵 Low · up to c576d

The remaining concern is limited to annotated preprocessor comment consistency in a tuple type-support header and does not indicate a functional regression.


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

It relied on recursive types. Rather than that use recursive functions and type aliases.
@miscco
miscco force-pushed the improve_tuple_cat branch 2 times, most recently from d8a7407 to a7d41d6 Compare September 10, 2026 08:33
@github-actions

This comment has been minimized.

@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)
libcudacxx/include/cuda/std/__tuple_dir/make_tuple_types.h (1)

72-77: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

suggestion: Use the exact #if _CCCL_COMPILER(MSVC) condition in each annotated #else and #endif comment. Do not use the negated !_CCCL_COMPILER(MSVC) form.

  • libcudacxx/include/cuda/std/__tuple_dir/make_tuple_types.h#L72-L77: update the #else and #endif comments.
  • libcudacxx/include/cuda/std/__tuple_dir/make_tuple_types.h#L92-L97: update the #else and #endif comments.

Source: Learnings


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a3326b36-2078-4179-b9f7-7309e33c6dec

📥 Commits

Reviewing files that changed from the base of the PR and between d8a7407 and 8da8a83.

📒 Files selected for processing (1)
  • libcudacxx/include/cuda/std/__tuple_dir/make_tuple_types.h

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 3h 07m: Pass: 100%/195 | Total: 2d 23h | Max: 3h 06m | Hits: 74%/792259

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.

2 participants