File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed
Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,11 @@ template <typename AllocatorT> class SYCLMemObjT : public SYCLMemObjI {
101101 }
102102
103103 size_t get_size () const { return MSizeInBytes; }
104+ size_t get_count () const {
105+ auto constexpr AllocatorValueSize =
106+ sizeof (allocator_value_type_t <AllocatorT>);
107+ return (get_size () + AllocatorValueSize - 1 ) / AllocatorValueSize;
108+ }
104109
105110 template <typename propertyT> bool has_property () const {
106111 return MProps.has_property <propertyT>();
@@ -112,16 +117,11 @@ template <typename AllocatorT> class SYCLMemObjT : public SYCLMemObjI {
112117
113118 AllocatorT get_allocator () const { return MAllocator; }
114119
115- void *allocateHostMem () override {
116- size_t AllocatorValueSize = sizeof (allocator_value_type_t <AllocatorT>);
117- size_t AllocationSize = get_size () / AllocatorValueSize;
118- AllocationSize += (get_size () % AllocatorValueSize) ? 1 : 0 ;
119- return MAllocator.allocate (AllocationSize);
120- }
120+ void *allocateHostMem () override { return MAllocator.allocate (get_count ()); }
121121
122122 void releaseHostMem (void *Ptr) override {
123123 if (Ptr)
124- MAllocator.deallocate (allocator_pointer_t <AllocatorT>(Ptr), get_size ());
124+ MAllocator.deallocate (allocator_pointer_t <AllocatorT>(Ptr), get_count ());
125125 }
126126
127127 void releaseMem (ContextImplPtr Context, void *MemAllocation) override {
Original file line number Diff line number Diff line change @@ -643,6 +643,13 @@ int main() {
643643 b.set_final_data (voidPtr);
644644 }
645645
646+ {
647+ std::allocator<float8> buf_alloc;
648+ cl::sycl::shared_ptr_class<float8> data (new float8[8 ]);
649+ cl::sycl::buffer<float8, 1 , std::allocator<float8>>
650+ b (data, cl::sycl::range<1 >(8 ), buf_alloc);
651+ }
652+
646653 // TODO tests with mutex property
647654 return failed;
648655}
You can’t perform that action at this time.
0 commit comments