Skip to content

[libcu++] Add explicit alignment argument to buffer construction#7623

Merged
pciolkosz merged 6 commits intoNVIDIA:mainfrom
pciolkosz:alignment_specification_for_buffer
Feb 26, 2026
Merged

[libcu++] Add explicit alignment argument to buffer construction#7623
pciolkosz merged 6 commits intoNVIDIA:mainfrom
pciolkosz:alignment_specification_for_buffer

Conversation

@pciolkosz
Copy link
Copy Markdown
Contributor

Closes #7506

This PR adds allocation_alignment tag that can be passed to the buffer through env argument, which will be then passed to the resource on allocation and also stored in the buffer for later access and copy construction

@pciolkosz pciolkosz requested a review from a team as a code owner February 11, 2026 01:33
@pciolkosz pciolkosz requested a review from davebayer February 11, 2026 01:33
@copy-pr-bot
Copy link
Copy Markdown
Contributor

copy-pr-bot bot commented Feb 11, 2026

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.

@github-project-automation github-project-automation bot moved this to Todo in CCCL Feb 11, 2026
@cccl-authenticator-app cccl-authenticator-app bot moved this from Todo to In Review in CCCL Feb 11, 2026

{ // from size with no_init and allocation_alignment env (offset_by_alignment_resource verifies alignment)
const ::cuda::std::size_t alignment = ::cuda::mr::default_cuda_malloc_alignment / 2;
const auto env = ::cuda::std::execution::prop{::cuda::allocation_alignment, alignment};
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

question: Is this the expected API most users would use? If so, this is an awfully verbose way to simply specify an allocation alignment.

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.

I plan to discuss some conventions around environment based APIs next week, so we can deep dive into this topic.

But for non-default alignment specifically, I consider it a ninja feature and I am not against it being verbose. But we could try to simplify it, for example having ::cuda::allocation_alignment wrap the alignment value instead of relying on ::cuda::std::execution::prop

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I wouldn't be too quick to assume that non-default alignment is a ninja feature. Many features essential for performance, like vectorized load/stores or TMA, require over-aligned allocations

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.

I believe we default case should be no alignment specified as is done here. If a user wants to specify the alignment they should be prepared to jump through a few hoops

That said, I believe this isn't too bad

@pciolkosz pciolkosz force-pushed the alignment_specification_for_buffer branch from f45b475 to 6afce21 Compare February 11, 2026 19:44
@pciolkosz
Copy link
Copy Markdown
Contributor Author

/ok to test 6afce21

@github-actions

This comment has been minimized.

@pciolkosz
Copy link
Copy Markdown
Contributor Author

/ok to test 0f456c5

@github-actions

This comment has been minimized.


{ // from size with no_init and allocation_alignment env (offset_by_alignment_resource verifies alignment)
const ::cuda::std::size_t alignment = ::cuda::mr::default_cuda_malloc_alignment / 2;
const auto env = ::cuda::std::execution::prop{::cuda::allocation_alignment, alignment};
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.

I believe we default case should be no alignment specified as is done here. If a user wants to specify the alignment they should be prepared to jump through a few hoops

That said, I believe this isn't too bad

@github-project-automation github-project-automation bot moved this from In Review to In Progress in CCCL Feb 13, 2026
@pciolkosz pciolkosz force-pushed the alignment_specification_for_buffer branch 2 times, most recently from 97e41bb to 9975146 Compare February 19, 2026 22:14
@github-project-automation github-project-automation bot moved this from In Progress to In Review in CCCL Feb 25, 2026
anon and others added 4 commits February 25, 2026 15:39
@pciolkosz pciolkosz force-pushed the alignment_specification_for_buffer branch from 2b26070 to 87ce705 Compare February 25, 2026 23:40
@github-actions
Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 2h 40m: Pass: 100%/99 | Total: 1d 22h | Max: 2h 39m | Hits: 80%/252570

See results here.

@pciolkosz pciolkosz merged commit 633cb6b into NVIDIA:main Feb 26, 2026
116 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

Backport failed for branch/3.3.x, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin branch/3.3.x
git worktree add -d .worktree/backport-7623-to-branch/3.3.x origin/branch/3.3.x
cd .worktree/backport-7623-to-branch/3.3.x
git switch --create backport-7623-to-branch/3.3.x
git cherry-pick -x 633cb6bd51a2a36e10e7795a66f6aa61c3f5a3ac

miscco added a commit to miscco/cccl that referenced this pull request Mar 2, 2026
…DIA#7623)

* Add explicit alignment argument to buffer

* Fix format

* Review feedback

* Apply suggestions from code review

Co-authored-by: Michael Schellenberger Costa <miscco@nvidia.com>

* Fix format

* Fix missing include

---------

Co-authored-by: anon <users.noreply.github.com>
Co-authored-by: Michael Schellenberger Costa <miscco@nvidia.com>
wmaxey added a commit that referenced this pull request Mar 3, 2026
* [libcu++] Add explicit alignment argument to buffer construction (#7623)

* Add explicit alignment argument to buffer

* Fix format

* Review feedback

* Apply suggestions from code review

Co-authored-by: Michael Schellenberger Costa <miscco@nvidia.com>

* Fix format

* Fix missing include

---------

Co-authored-by: anon <users.noreply.github.com>
Co-authored-by: Michael Schellenberger Costa <miscco@nvidia.com>

* [libcu++] Add dynamic_accessibility_property added to all resources (#7727)

* Add dynamic_accessibility_property to all memory resources

* Fix forward property test

* Workaround for gcc 7

* Review feedback

* Address review comments

* Fix merge conflict

* Fix replacment issue

---------

Co-authored-by: Michael Schellenberger Costa <miscco@nvidia.com>

* Version bump buffer and resource wrappers (#7833)

* Compilation fixes

---------

Co-authored-by: pciolkosz <pciolkosz@nvidia.com>
Co-authored-by: Wesley Maxey <71408887+wmaxey@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Add alignment argument to cuda::buffer

3 participants