20 #include <type_traits>
23 inline namespace _V1 {
24 template <
typename T, usm::alloc AllocKind,
size_t Alignment = 0>
33 template <
typename U>
struct rebind {
39 "usm_allocator does not support AllocKind == usm::alloc::device");
44 : MContext(Ctxt), MDevice(Dev), MPropList(PropList) {}
47 MPropList(PropList) {}
51 MContext = Other.MContext;
52 MDevice = Other.MDevice;
53 MPropList = Other.MPropList;
57 MContext = std::move(Other.MContext);
58 MDevice = std::move(Other.MDevice);
59 MPropList = std::move(Other.MPropList);
65 : MContext(Other.MContext), MDevice(Other.MDevice),
66 MPropList(Other.MPropList) {}
74 if (!NumberOfElements)
77 auto Result =
reinterpret_cast<T *
>(
79 MDevice, MContext, AllocKind, MPropList, CodeLoc));
94 free(Ptr, MContext, CodeLoc);
98 template <
class U, usm::alloc AllocKindU,
size_t AlignmentU>
101 return ((AllocKind == AllocKindU) && (One.MContext == Two.MContext) &&
102 (One.MDevice == Two.MDevice));
105 template <
class U, usm::alloc AllocKindU,
size_t AlignmentU>
108 return !((AllocKind == AllocKindU) && (One.MContext == Two.MContext) &&
109 (One.MDevice == Two.MDevice));
121 constexpr
size_t getAlignment()
const {
return max(
alignof(T),
Alignment); }
123 template <
class U, usm::alloc AllocKindU,
size_t AlignmentU>
The context class represents a SYCL context on which kernel functions may be executed.
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
Objects of the property_list class are containers for the SYCL properties.
bool has_property() const noexcept
PropT get_property() const
Encapsulates a single SYCL queue which schedules kernels on a SYCL device.
device get_device() const
context get_context() const
std::true_type propagate_on_container_swap
friend bool operator==(const usm_allocator< T, AllocKind, Alignment > &One, const usm_allocator< U, AllocKindU, AlignmentU > &Two)
usm_allocator(const usm_allocator &)=default
usm_allocator(usm_allocator &&) noexcept=default
usm_allocator & operator=(usm_allocator &&Other)
bool has_property() const noexcept
friend bool operator!=(const usm_allocator< T, AllocKind, Alignment > &One, const usm_allocator< U, AllocKindU, AlignmentU > &Two)
std::true_type propagate_on_container_copy_assignment
T * allocate(size_t NumberOfElements, const detail::code_location CodeLoc=detail::code_location::current())
Allocates memory.
Property get_property() const
usm_allocator(const queue &Q, const property_list &PropList={})
usm_allocator(const usm_allocator< U, AllocKind, Alignment > &Other) noexcept
std::true_type propagate_on_container_move_assignment
void deallocate(T *Ptr, size_t, const detail::code_location CodeLoc=detail::code_location::current())
Deallocates memory.
usm_allocator(const context &Ctxt, const device &Dev, const property_list &PropList={})
void * aligned_alloc(size_t alignment, size_t size, const device &dev, const context &ctxt, usm::alloc kind, const detail::code_location &CodeLoc=detail::code_location::current())
std::error_code make_error_code(sycl::errc E) noexcept
Constructs an error code using e and sycl_category()
void free(void *ptr, const context &ctxt, const detail::code_location &CodeLoc=detail::code_location::current())
_Abi const simd< _Tp, _Abi > & noexcept
static constexpr code_location current(const char *fileName=__CODELOC_FILE_NAME, const char *funcName=__CODELOC_FUNCTION, unsigned long lineNo=__CODELOC_LINE, unsigned long columnNo=__CODELOC_COLUMN) noexcept
usm_allocator< U, AllocKind, Alignment > other