Skip to content

[cudax] Extend group_as to support compile-time ranges - #12572

Merged
davebayer merged 2 commits into
NVIDIA:mainfrom
davebayer:group_as_constant_range
Nov 10, 2026
Merged

davebayer merged 2 commits into
NVIDIA:mainfrom
davebayer:group_as_constant_range

Conversation

@davebayer

Copy link
Copy Markdown
Contributor

Fixes #12554

@davebayer
davebayer requested a review from a team as a code owner November 10, 2026 13:39
@davebayer
davebayer requested a review from caugonnet November 10, 2026 13:39
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Nov 10, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Nov 10, 2026
{
template <bool _Exhaustive, class _Unit, class _PrevMappingResult, class _Range>
[[nodiscard]] _CCCL_DEVICE_API auto
__group_as_map(const _Unit&, const _PrevMappingResult& __prev_mapping_result, const _Range& __unit_counts)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This method is just extracted from group_as, so we can reuse it for both specializations

@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • New Features
    • Added compile-time group mappings from sequences of unit counts and constant-wrapped ranges.
    • Mappings provide compile-time results when the previous group count is statically known.
  • Tests
    • Expanded coverage for mapping validity, subgroup and unit ranks and counts, lane masks, mapping composition, and partial mappings.
    • Added tests for dynamic ranges represented by arrays and spans, as well as compile-time count sequences and class-valued inputs.

group_as now supports compile-time count sequences and constant-wrapped ranges. Its mapping logic is shared with runtime-range mappings. Tests cover static mapping results, compatibility with prior mappings, composition, and use with static-unit-count groups.

Changes: Compile-time group_as mappings

Layer / File(s) Summary
Shared mapping algorithm
cudax/include/cuda/experimental/coop/__group/mapping/group_as.cuh
The runtime-range mapping delegates exhaustive and non-exhaustive cases to a shared helper that accepts unit counts.
Compile-time count sequences
cudax/include/cuda/experimental/coop/__group/mapping/group_as.cuh
A specialization materializes compile-time ranges, validates count constraints and compatibility with prior mappings, and returns static mapping results when prior group counts are static.
Mapping validation and group integration
cudax/test/coop/group/mapping/group_as.cu, cudax/test/coop/group/with_static_unit_count.cu
Tests cover runtime and static mappings, composition, special cases, and group_as mappings used with static-unit-count groups.

Assessment against linked issues

Objective Addressed Explanation
Extend group_as to support compile-time known ranges [#12554] ✅

Possibly related issues

Possibly related PRs

  • NVIDIA/cccl#12223: This PR builds on the range-based group_as API by adding compile-time count sequences and static mapping results.
  • NVIDIA/cccl#12553: This PR uses statically known prior-group counts to validate and produce compile-time group_as mappings.
  • NVIDIA/cccl#12561: This PR updates static-unit-count tests to use compile-time group_as count sequences.

Suggested reviewers: andralex

Change: Feature

Merge Risk: Minimal · up to 1b001

No merge-blocking regression was identified in the mapping changes.

Security architecture risk: Minimal · up to 1b001

The extension adds compile-time mapping inputs without introducing a separate runtime entrypoint or expanding caller authority. The existing runtime mapping algorithm and its preconditions are retained. No material security risk introduced or worsened by this change was identified in the reviewed paths.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated exposure is cooperative-group metadata within the caller's CUDA execution context. The new counts are encoded in program types or constant values, while the flagged test invocations use local or literal inputs. The inspected paths establish no independently attackable service boundary or added privilege.

Trust Boundaries and Controls

  • observed — The extracted runtime algorithm retains the base behavior for predecessor validity, exhaustive count equality, non-exhaustive count limits, and lane-mask derivation. The static interface delegates to this same algorithm rather than introducing an alternative mapping-control path.

Resilience and Maintainability Implications

  • inferred — The new specialization stores no mutable per-instance state and computes results from const inputs. Its successful and invalid-result paths do not reserve resources or mutate shared ownership, so interruption, repetition, or concurrent invocation introduces no new cleanup or recovery transition in this implementation.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: NVIDIA/cccl
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: 5060e9b
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 784d8aa0-d413-4b4a-ac8d-43bb01808f2b
Commits

Reviewing files that changed from the base of the PR and between 830d133 and 1b001fc.

Files selected for processing: 1

  • cudax/test/coop/group/mapping/group_as.cu

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 9 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 1h 30m: Pass: 100%/75 | Total: 12h 09m | Max: 1h 18m | Hits: 90%/54193

See results here.

@davebayer
davebayer merged commit 2937b83 into NVIDIA:main Nov 10, 2026
95 checks passed
@davebayer
davebayer deleted the group_as_constant_range branch November 10, 2026 16:37
@github-project-automation github-project-automation Bot moved this from In Review to Done in CCCL Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[FEA]: Extend group_as to support compile-time known ranges

2 participants