58 template<USMKindTarget target>
61 void *usm_ptr =
nullptr;
63 std::shared_ptr<DeviceScheduler>
66 USMPtrHolder(
void *usm_ptr,
size_t size, std::shared_ptr<DeviceScheduler> dev_sched)
67 : usm_ptr(usm_ptr), size(size), dev_sched(std::move(dev_sched)) {}
87 std::shared_ptr<DeviceScheduler> dev_sched,
88 std::optional<size_t> alignment = std::nullopt);
90 static USMPtrHolder create_nullptr(std::shared_ptr<DeviceScheduler> dev_sched);
113 : usm_ptr(std::exchange(other.usm_ptr,
nullptr)), size(other.size),
114 dev_sched(other.dev_sched) {}
131 dev_sched = other.dev_sched;
133 std::swap(usm_ptr, other.usm_ptr);
147 "The USM pointer is not aligned with the given type");
149 return reinterpret_cast<T *
>(usm_ptr);
160 [[nodiscard]]
inline void *
get_raw_ptr()
const {
return usm_ptr; }
Class to manage the scheduling of kernels on a device.
Class for holding a USM pointer.
size_t get_bytesize() const
Get the size of the USM allocation (in byte)
DeviceScheduler & get_dev_scheduler() const
Get the SYCL context used for allocation/freeing the USM buffer.
USMPtrHolder(USMPtrHolder &&other) noexcept
Move constructor.
T * ptr_cast() const
Cast the USM pointer to the given type.
void free_ptr()
Free the held pointer.
~USMPtrHolder()
USM pointer holder destructor.
void * get_raw_ptr() const
Get the raw pointer of the USM allocation.
std::shared_ptr< DeviceScheduler > & get_dev_scheduler_ptr()
Get the SYCL context used for allocation/freeing the USM buffer.
USMPtrHolder & operator=(USMPtrHolder &&other) noexcept
Move assignment operator.
USMPtrHolder & operator=(const USMPtrHolder &other)=delete
Deleted copy assignment operator.
USMPtrHolder(const USMPtrHolder &other)=delete
Deleted copy constructor.
const std::shared_ptr< DeviceScheduler > & get_dev_scheduler_ptr() const
Get the SYCL context used for allocation/freeing the USM buffer.
static USMPtrHolder create(size_t sz, std::shared_ptr< DeviceScheduler > dev_sched, std::optional< size_t > alignment=std::nullopt)
Create a USM pointer holder.
namespace for backends this one is named only sham since shambackends is too long to write
USMKindTarget
Enum listing the different types of USM pointers allocations.
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.