[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:36 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:
Also, not directly related to this PR, but I think right now there's a mix of
`\param ParamName the...` (e.g. __impl/context.hpp or here)
and
`\param ParamName is the...` (e.g., __impl/queue.hpp)
in the comments. I don't really have a preference here, but we should stick to one of those two.
https://github.com/llvm/llvm-project/pull/184111
More information about the llvm-commits
mailing list