[llvm] [libsycl] USM Aligned allocation functions (PR #213468)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 10 05:50:08 PDT 2026


================
@@ -115,10 +168,53 @@ int main() {
           [&]() { return Malloc(q, usm::alloc::host, property_list{}); },
           [&]() { return Malloc(d, ctx, usm::alloc::host, property_list{}); }});
 
+  auto AMalloc = [&](auto... args) {
+    return aligned_alloc(Align, 1024, args...);
+  };
+
+  CheckAll(
+      Align,
+      std::tuple{
+          [&]() { return AMalloc(q, usm::alloc::host); },
+          [&]() { return AMalloc(d, ctx, usm::alloc::host); },
+          [&]() { return AMalloc(q, usm::alloc::host, property_list{}); },
+          [&]() { return AMalloc(d, ctx, usm::alloc::host, property_list{}); },
+      });
+
   auto TMalloc = [&](auto... args) { return malloc<Aligned>(1, args...); };
   CheckAll(Align,
            std::tuple{[&]() { return TMalloc(q, usm::alloc::host); },
                       [&]() { return TMalloc(d, ctx, usm::alloc::host); }});
 
+  auto TAMalloc = [&](auto... args) {
+    return aligned_alloc<Aligned>(Align, 1, args...);
+  };
+
+  CheckAll(Align,
+           std::tuple{[&]() { return TAMalloc(q, usm::alloc::host); },
+                      [&]() { return TAMalloc(d, ctx, usm::alloc::host); }});
+
+  // Testing invalid arguments for alignment
+  assert(aligned_alloc_device(3, 1024, q) == nullptr);
+  assert(aligned_alloc_host(3, 1024, q) == nullptr);
+  if (d.has(aspect::usm_shared_allocations))
----------------
Robertkq wrote:

OK, I've pushed a commit that removes the aspect checking, I believe I may have done a poor job with the initial implementation with aspect checking -- even if it is now removed, maybe we can revisit this in the future? Anyways, I did not remove the already existing aspect checking for `shared` allocations, it's just that this PR does not add any additional ones

https://github.com/llvm/llvm-project/pull/213468


More information about the llvm-commits mailing list