[llvm] [libsycl] USM Aligned allocation functions (PR #213468)
Kseniya Tikhomirova via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 20 08:47:02 PDT 2026
================
@@ -86,6 +90,73 @@ T *malloc_device(std::size_t count, const queue &syclQueue,
return malloc_device<T>(count, syclQueue.get_device(),
syclQueue.get_context(), propList);
}
+
+/// Allocates device USM with specified alignment.
+///
+/// \param alignment the alignment of the allocated memory.
+/// \param numBytes the number of bytes to allocate.
+/// \param syclDevice the device to use for the allocation.
+/// \param syclContext a context containing syclDevice or its parent device if
+/// syclDevice is a subdevice.
+/// \param propList the list of properties for the allocation.
+/// \return a pointer to the newly allocated memory, which is allocated on
+/// syclDevice and which must eventually be deallocated with sycl::free in order
+/// to avoid a memory leak.
+_LIBSYCL_EXPORT
+void *aligned_alloc_device(std::size_t alignment, std::size_t numBytes,
+ const device &syclDevice, const context &syclContext,
+ const property_list &propList = {});
+
+/// Allocates device USM with specified alignment.
+///
+/// \param alignment the alignment of the allocated memory.
+/// \param count the number of elements of type T to allocate.
+/// \param syclDevice the device to use for the allocation.
+/// \param syclContext a context containing syclDevice or its parent device if
+/// syclDevice is a subdevice.
+/// \param propList the list of properties for the allocation.
+/// \return a pointer to the newly allocated memory, which is allocated on
+/// syclDevice and which must eventually be deallocated with sycl::free in order
+/// to avoid a memory leak.
+template <typename T>
+T *aligned_alloc_device(std::size_t alignment, std::size_t count,
+ const device &syclDevice, const context &syclContext,
+ const property_list &propList) {
+ return static_cast<T *>(aligned_alloc_device(
+ alignment, count * sizeof(T), syclDevice, syclContext, propList));
+}
+
+/// Allocates device USM with specified alignment.
+///
+/// \param alignment the alignment of the allocated memory.
+/// \param numBytes the number of bytes to allocate.
+/// \param syclQueue a queue that provides the device and context.
+/// \param propList the list of properties for the allocation.
+/// \return a pointer to the newly allocated memory, which is allocated on
+/// syclDevice and which must eventually be deallocated with sycl::free in order
----------------
KseniyaTikhomirova wrote:
those comments are incorrect since they mention unexisting parameters. I must have made a mistake in those comments.
https://github.com/llvm/llvm-project/pull/213468
More information about the llvm-commits
mailing list