[llvm] [offload] Document and assert allocation alignment guarantee (PR #223381)
Ćukasz Plewa via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 17 05:51:44 PDT 2026
================
@@ -35,6 +35,21 @@ TEST_P(olMemAllocAllocTypesTest, Success) {
olMemFree(Alloc);
}
+TEST_P(olMemAllocAllocTypesTest, SuccessSmallSizesWordSizeAlignment) {
+ const size_t Sizes[] = {1, 2, 3, 4, 5, 6, 7, 8, 14};
+ for (size_t Size : Sizes) {
+ SCOPED_TRACE("size: " + std::to_string(Size));
+ void *Alloc = nullptr;
+ ASSERT_SUCCESS(allocateDeviceOrHost(Size, &Alloc));
+ ASSERT_NE(Alloc, nullptr);
+
+ // Check word-size alignment without requesting explicit alignment.
+ EXPECT_EQ(reinterpret_cast<uintptr_t>(Alloc) % alignof(uintptr_t), 0U);
+
+ ASSERT_SUCCESS(olMemFree(Alloc));
----------------
lplewa wrote:
please do free in separate loop after all allocations.
In this implementation we are probably getting the same ptr after each allocation (as it is cached in memory manager).
https://github.com/llvm/llvm-project/pull/223381
More information about the llvm-commits
mailing list