From 18bea7185569a1ac4170ae139e71e0f0e32e8601 Mon Sep 17 00:00:00 2001 From: Brad Langhorst Date: Tue, 6 Oct 2026 22:02:08 -0400 Subject: [PATCH] ensures correct allocation sizes via integer math --- src/acc/cuda/custom_allocator.cuh | 2 +- src/acc/hip/custom_allocator.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/acc/cuda/custom_allocator.cuh b/src/acc/cuda/custom_allocator.cuh index 4d5e44e53..5c0bf8ecb 100644 --- a/src/acc/cuda/custom_allocator.cuh +++ b/src/acc/cuda/custom_allocator.cuh @@ -509,7 +509,7 @@ public: if (cache) { - size = alignmentSize*ceilf( (float)size / (float)alignmentSize) ; //To prevent miss-aligned memory + size = ((size + alignmentSize - 1) / alignmentSize) * alignmentSize; //To prevent miss-aligned memory (integer arithmetic: float rounding returned undersized allocations above 16 MB) Alloc *curAlloc = _getFirstSuitedFree(size); diff --git a/src/acc/hip/custom_allocator.h b/src/acc/hip/custom_allocator.h index 537860850..b8dee64f5 100644 --- a/src/acc/hip/custom_allocator.h +++ b/src/acc/hip/custom_allocator.h @@ -511,7 +511,7 @@ class HipCustomAllocator if (cache) { - size = alignmentSize*ceilf( (float)size / (float)alignmentSize) ; //To prevent miss-aligned memory + size = ((size + alignmentSize - 1) / alignmentSize) * alignmentSize; //To prevent miss-aligned memory (integer arithmetic: float rounding returned undersized allocations above 16 MB) Alloc *curAlloc = _getFirstSuitedFree(size);