[llvm] [libsycl] add USM alloc/free functions (PR #184111)

Sergey Semenov via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 5 09:57:34 PST 2026


================
@@ -0,0 +1,300 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBSYCL___IMPL_USM_FUNCTIONS_HPP
+#define _LIBSYCL___IMPL_USM_FUNCTIONS_HPP
+
+#include <sycl/__impl/context.hpp>
+#include <sycl/__impl/queue.hpp>
+#include <sycl/__impl/usm_alloc_type.hpp>
+
+#include <sycl/__impl/detail/config.hpp>
+
+_LIBSYCL_BEGIN_NAMESPACE_SYCL
+
+// SYCL 2020 4.8.3.2. Device allocation functions.
+
+/// Allocates device USM.
+///
+/// \param numBytes  allocation size that is specified in bytes.
+/// \param syclDevice device that is used for allocation.
+/// \param syclContext context that contains syclDevice or its parent device if
+/// syclDevice is a subdevice.
+/// \param propList properties for the memory 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.
----------------
sergey-semenov wrote:

```suggestion
/// \param numBytes the allocation size that is specified in bytes.
/// \param syclDevice the device that is used for the allocation.
/// \param syclContext the context associated with the allocation that contains 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.
```
Also applies to the rest of the functions in this file.

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


More information about the llvm-commits mailing list