15 #include <type_traits>
18 inline namespace _V1 {
21 template <
typename DataT>
40 template <
typename AllocatorT,
typename OwnerDataT>
44 : MAllocator(Allocator),
45 MValueSize(sizeof(typename AllocatorT::
value_type)) {}
48 : MAllocator(AllocatorT()),
49 MValueSize(sizeof(typename AllocatorT::
value_type)) {}
53 virtual void *
allocate(std::size_t Count)
override {
54 return reinterpret_cast<void *
>(MAllocator.allocate(Count));
57 virtual void deallocate(
void *Ptr, std::size_t Count)
override {
58 MAllocator.deallocate(
63 setAlignImpl(RequiredAlign);
66 virtual std::size_t
getValueSize()
const override {
return MValueSize; }
73 using EnableIfDefaultAllocator = std::enable_if_t<
74 std::is_same_v<T, sycl_memory_object_allocator<OwnerDataT>>>;
77 using EnableIfNonDefaultAllocator = std::enable_if_t<
78 !std::is_same_v<T, sycl_memory_object_allocator<OwnerDataT>>>;
80 template <
typename T = AllocatorT>
81 EnableIfNonDefaultAllocator<T> setAlignImpl(std::size_t) {
85 template <
typename T = AllocatorT>
86 EnableIfDefaultAllocator<T> setAlignImpl(std::size_t RequiredAlign) {
87 MAllocator.setAlignment(std::max<size_t>(RequiredAlign, 64));
90 AllocatorT MAllocator;
91 std::size_t MValueSize;
virtual void deallocate(void *Ptr, std::size_t Count) override
void setAlignment(std::size_t RequiredAlign) override
SYCLMemObjAllocatorHolder()
~SYCLMemObjAllocatorHolder()=default
SYCLMemObjAllocatorHolder(AllocatorT Allocator)
virtual void * getAllocatorImpl() override
virtual void * allocate(std::size_t Count) override
virtual std::size_t getValueSize() const override
virtual void deallocate(void *, std::size_t)=0
AllocatorT getAllocator()
virtual void * allocate(std::size_t)=0
virtual ~SYCLMemObjAllocator()=default
virtual std::size_t getValueSize() const =0
virtual void * getAllocatorImpl()=0
virtual void setAlignment(std::size_t RequiredAlign)=0