[llvm] [offload] add handling of memory alignment to MemoryManagerTy (PR #218418)
Jan Trusiłło via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 26 03:36:58 PDT 2026
================
@@ -264,32 +281,55 @@ class MemoryManagerTy {
ODBG(OLDT_Alloc) << "Got target pointer " << *TgtPtrOrErr
<< ". Return directly.";
+ if (Alignment > 0 && !isAddrAligned(Align(Alignment), *TgtPtrOrErr)) {
+ auto AlignErr = make_error<StringError>(
+ "Allocated address is misaligned", inconvertibleErrorCode());
+ if (auto FreeErr = deleteOnDevice(*TgtPtrOrErr)) {
+ return joinErrors(std::move(FreeErr), std::move(AlignErr));
+ }
+
+ return AlignErr;
+ }
+
return *TgtPtrOrErr;
}
+ if (Alignment > 0) {
+ Size += Alignment - 1;
+ }
NodeTy *NodePtr = nullptr;
// Try to get a node from FreeList
{
const int B = findBucket(Size);
----------------
311Volt wrote:
Note that you added padding to `Size` \*after\* you made the check against threshold to dispatch to direct device alloc. So I can see specific `Size`+`Alignment` combinations where `Size` becomes too big for the pooled case here, depending on how you set the threshold.
https://github.com/llvm/llvm-project/pull/218418
More information about the llvm-commits
mailing list