Open
Conversation
This comment has been minimized.
This comment has been minimized.
davebayer
reviewed
Feb 18, 2026
Comment on lines
12
to
13
| [[nodiscard]] __host__ __device__ inline | ||
| size_t ptr_alignment(const void* ptr, size_t max_alignment = 0) noexcept; |
Contributor
There was a problem hiding this comment.
I'm not sure if I understand the motivation of having this function. Why using is_aligned is not enough?
Contributor
Author
There was a problem hiding this comment.
suppose you have the following situation.
auto align = ptr_alignment(ptr, 8);
switch (align) {
case 1:
case 2:
....
}
Contributor
There was a problem hiding this comment.
I see, but is there enough motivation to publicly expose the function?
Contributor
Author
There was a problem hiding this comment.
that's a good question. We could also use it only internally but, the situation described above is very common in CUDA. @bernhardmgruber, @miscco any thought?
Contributor
😬 CI Workflow Results🟥 Finished in 1h 20m: Pass: 98%/99 | Total: 1d 16h | Max: 1h 00m | Hits: 96%/251275See results here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Retrieving the alignment of a pointer is a common utility in CCCL, as well as in other CUDA libraries.; see for example
cudax::hyperloglogThe PR adds
cuda::ptr_alignment(ptr, max_alignment)(<cuda/memory>) to get the alignment of a pointer (the largest power of two dividing its address), optionally capped by a maximum alignment.