25 __SYCL_EXPORT
void *
aligned_alloc(
size_t alignment,
size_t size,
26 const device &dev,
const context &ctxt,
28 const property_list &propList,
29 const detail::code_location CodeLoc);
30 __SYCL_EXPORT
void free(
void *ptr,
const context &ctxt,
31 const detail::code_location CodeLoc);
33 template <
typename T, usm::alloc AllocKind,
size_t Alignment = alignof(T)>
42 template <
typename U>
struct rebind {
48 "usm_allocator does not support AllocKind == usm::alloc::device");
53 : MContext(Ctxt), MDevice(Dev), MPropList(PropList) {}
56 MPropList(PropList) {}
57 usm_allocator(
const usm_allocator &) noexcept =
default;
58 usm_allocator(usm_allocator &&) noexcept = default;
60 MContext = Other.MContext;
61 MDevice = Other.MDevice;
62 MPropList = Other.MPropList;
66 MContext = std::move(Other.MContext);
67 MDevice = std::move(Other.MDevice);
68 MPropList = std::move(Other.MPropList);
74 : MContext(Other.MContext), MDevice(Other.MDevice),
75 MPropList(Other.MPropList) {}
81 detail::code_location::current()) {
83 auto Result =
reinterpret_cast<T *
>(
85 MDevice, MContext, AllocKind, MPropList, CodeLoc));
87 throw memory_allocation_error();
100 free(Ptr, MContext, CodeLoc);
104 template <
class U, usm::alloc AllocKindU,
size_t AlignmentU>
107 return ((AllocKind == AllocKindU) && (One.MContext == Two.MContext) &&
108 (One.MDevice == Two.MDevice));
111 template <
class U, usm::alloc AllocKindU,
size_t AlignmentU>
114 return !((AllocKind == AllocKindU) && (One.MContext == Two.MContext) &&
115 (One.MDevice == Two.MDevice));
119 constexpr
size_t getAlignment()
const {
return Alignment; }
121 template <
class U, usm::alloc AllocKindU,
size_t AlignmentU>