27 #include <type_traits>
30 inline namespace _V1 {
49 using EnableIfOutputPointerT = std::enable_if_t<
50 std::is_pointer<T>::value>;
53 using EnableIfOutputIteratorT = std::enable_if_t<
54 !std::is_pointer<T>::value>;
58 std::unique_ptr<SYCLMemObjAllocator> Allocator)
67 std::unique_ptr<SYCLMemObjAllocator> Allocator)
71 const size_t SizeInBytes,
event AvailableEvent,
72 std::unique_ptr<SYCLMemObjAllocator> Allocator);
76 std::unique_ptr<SYCLMemObjAllocator> Allocator)
78 (size_t)0, AvailableEvent,
79 std::move(Allocator)) {}
82 bool OwnNativeHandle,
event AvailableEvent,
83 std::unique_ptr<SYCLMemObjAllocator> Allocator);
86 bool OwnNativeHandle,
event AvailableEvent,
87 std::unique_ptr<SYCLMemObjAllocator> Allocator,
88 ur_image_format_t Format,
range<3> Range3WithOnes,
97 size_t get_count()
const {
return size(); }
99 size_t AllocatorValueSize =
MAllocator->getValueSize();
100 return (
getSizeInBytes() + AllocatorValueSize - 1) / AllocatorValueSize;
151 const std::function<
void(
const std::function<
void(
void *
const Ptr)> &)>
156 FinalDataFunc(UpdateFunc);
173 return has_property<property::buffer::use_host_ptr>() ||
174 has_property<property::image::use_host_ptr>();
179 (
reinterpret_cast<std::uintptr_t
>(HostPtr) % RequiredAlign) == 0;
190 set_final_data([HostPtr](
const std::function<
void(
void *
const Ptr)> &F) {
222 const size_t RequiredAlign,
bool IsConstPtr) {
251 const size_t RequiredAlign,
bool IsConstPtr) {
256 "Buffer constructor from a pair of iterator values does "
257 "not support use_host_ptr property.");
271 ur_native_handle_t MemObject);
276 void *HostPtr, ur_event_handle_t &InteropEvent)
override {
278 (void)InitFromUserData;
316 if (CurrentVal == 0) {
319 if (
MGraphUseCount.compare_exchange_strong(CurrentVal, CurrentVal - 1) ==
334 void *&HostPtr,
bool &HostPtrReadOnly);
The context class represents a SYCL context on which kernel functions may be executed.
const std::unique_ptr< SYCLMemObjAllocator > & get_allocator_internal() const
ContextImplPtr getInteropContext() const override
const PluginPtr & getPlugin() const
__SYCL2020_DEPRECATED("get_count() is deprecated, please use size() instead") size_t get_count() const
void detachMemoryObject(const std::shared_ptr< SYCLMemObjT > &Self) const
void * allocateHostMem() override
virtual ~SYCLMemObjT()=default
bool has_property() const noexcept
void markNoLongerBeingUsedInGraph()
Decrement an internal counter for how many graphs are currently using this memory object.
ContextImplPtr MInteropContext
size_t getSizeInBytes() const noexcept override
void determineHostPtr(const ContextImplPtr &Context, bool InitFromUserData, void *&HostPtr, bool &HostPtrReadOnly)
void handleHostData(const std::shared_ptr< void > &HostPtr, const size_t RequiredAlign, bool IsConstPtr)
void releaseHostMem(void *Ptr) override
SYCLMemObjT(const property_list &Props, std::unique_ptr< SYCLMemObjAllocator > Allocator)
bool needsWriteBack() const
Returns true if this memory object requires a write_back on destruction.
std::shared_ptr< const void > MSharedPtrStorage
const property_list & getPropList() const
ur_mem_handle_t MInteropMemObject
MemObjType getType() const override
std::atomic< size_t > MGraphUseCount
bool hasUserDataPtr() const override
void releaseMem(ContextImplPtr Context, void *MemAllocation) override
void addOrReplaceAccessorProperties(const property_list &PropertyList)
EventImplPtr MInteropEvent
void handleWriteAccessorCreation()
void * getUserPtr() const
size_t size() const noexcept
void setAlign(size_t RequiredAlign)
SYCLMemObjT(cl_mem MemObject, const context &SyclContext, event AvailableEvent, std::unique_ptr< SYCLMemObjAllocator > Allocator)
void markBeingUsedInGraph()
Increment an internal counter for how many graphs are currently using this memory object.
bool canReadHostPtr(void *HostPtr, const size_t RequiredAlign)
SYCLMemObjT(const size_t SizeInBytes, const property_list &Props, std::unique_ptr< SYCLMemObjAllocator > Allocator)
std::function< void(void)> MUploadDataFunctor
void set_final_data(const std::function< void(const std::function< void(void *const Ptr)> &)> &FinalDataFunc)
bool isHostPointerReadOnly() const override
std::mutex MCreateShadowCopyMtx
void set_final_data(std::nullptr_t)
void handleHostData(const void *HostPtr, const size_t RequiredAlign)
void deleteAccessorProperty(const PropWithDataKind &Kind)
void set_write_back(bool NeedWriteBack)
std::unique_ptr< SYCLMemObjAllocator > MAllocator
std::function< void(void)> MCreateShadowCopy
bool isInterop() const override
static size_t getBufSizeForContext(const ContextImplPtr &Context, ur_native_handle_t MemObject)
void * allocateMem(ContextImplPtr Context, bool InitFromUserData, void *HostPtr, ur_event_handle_t &InteropEvent) override
bool usesPinnedHostMemory() const override
void set_final_data_from_storage()
bool isUsedInGraph() const
Returns true if any graphs are currently using this memory object.
void handleHostData(void *HostPtr, const size_t RequiredAlign)
void handleHostData(const std::function< void(void *)> &CopyFromInput, const size_t RequiredAlign, bool IsConstPtr)
bool canReuseHostPtr(void *HostPtr, const size_t RequiredAlign)
propertyT get_property() const
An event object can be used to synchronize memory transfers, enqueues of kernels and signaling barrie...
Objects of the property_list class are containers for the SYCL properties.
bool has_property() const noexcept
void delete_accessor_property(const sycl::detail::PropWithDataKind &Kind)
PropT get_property() const
void add_or_replace_accessor_properties(const property_list &PropertyList)
To cast(std::vector< cl_event > value)
std::shared_ptr< sycl::detail::context_impl > ContextImplPtr
std::shared_ptr< event_impl > EventImplPtr
std::shared_ptr< plugin > PluginPtr
class __SYCL_EBO __SYCL_SPECIAL_CLASS Dimensions
std::error_code make_error_code(sycl::errc E) noexcept
Constructs an error code using e and sycl_category()
_Abi const simd< _Tp, _Abi > & noexcept
C++ utilities for Unified Runtime integration.