[llvm] [offload] add support for aligned allocations (PR #203353)
Piotr Balcer via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 12 02:37:17 PDT 2026
================
@@ -324,10 +328,31 @@ struct AMDGPUMemoryPoolTy {
/// Get the allocation granularity of the pool.
size_t getGranule() const { return Granule; }
+ /// Get the allocation alignment of the pool.
+ size_t getAlignment() const { return AllocationAlignment; }
+
/// Allocate memory on the memory pool.
- Error allocate(size_t Size, void **PtrStorage) {
+ Error allocate(size_t Size, void **PtrStorage, size_t Alignment) {
+ // A non-zero value passed as the Alignment indicates that the user expects
+ // the allocation to have a specific alignment. However, the HSA API does
+ // not allow users to define alignment. Therefore, the passed alignment is
+ // compared with the alignment of the memory allocated using the given pool.
+ // If the default alignment is greater than or equal to the alignment
+ // requested by the user, it would still meet the user's requirements.
+ if (Alignment > 0 && Alignment >= AllocationAlignment) {
----------------
pbalcer wrote:
I found the name `AllocationAlignment` confusing in the context of this function. I had to look at the function signature to know which Alignment variable is which. Maybe we should call this `PoolAllocationAlignment` to disambiguate from the user-provided `Alignment` ?
https://github.com/llvm/llvm-project/pull/203353
More information about the llvm-commits
mailing list