@@ -50,71 +50,81 @@ class buffer {
50
50
buffer (const range<dimensions> &bufferRange,
51
51
const property_list &propList = {})
52
52
: Range(bufferRange) {
53
- impl = std::make_shared<detail::buffer_impl<AllocatorT> >(
54
- get_count () * sizeof (T), detail::getNextPowerOfTwo (sizeof (T)),
55
- propList );
53
+ impl = std::make_shared<detail::buffer_impl>(
54
+ get_count () * sizeof (T), detail::getNextPowerOfTwo (sizeof (T)), propList,
55
+ make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>() );
56
56
}
57
57
58
58
buffer (const range<dimensions> &bufferRange, AllocatorT allocator,
59
59
const property_list &propList = {})
60
60
: Range(bufferRange) {
61
- impl = std::make_shared<detail::buffer_impl<AllocatorT> >(
61
+ impl = std::make_shared<detail::buffer_impl>(
62
62
get_count () * sizeof (T), detail::getNextPowerOfTwo (sizeof (T)), propList,
63
- allocator);
63
+ make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>(
64
+ allocator));
64
65
}
65
66
66
67
buffer (T *hostData, const range<dimensions> &bufferRange,
67
68
const property_list &propList = {})
68
69
: Range(bufferRange) {
69
- impl = std::make_shared<detail::buffer_impl<AllocatorT> >(
70
+ impl = std::make_shared<detail::buffer_impl>(
70
71
hostData, get_count () * sizeof (T), detail::getNextPowerOfTwo (sizeof (T)),
71
- propList);
72
+ propList,
73
+ make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>());
72
74
}
73
75
74
76
buffer (T *hostData, const range<dimensions> &bufferRange,
75
77
AllocatorT allocator, const property_list &propList = {})
76
78
: Range(bufferRange) {
77
- impl = std::make_shared<detail::buffer_impl<AllocatorT> >(
79
+ impl = std::make_shared<detail::buffer_impl>(
78
80
hostData, get_count () * sizeof (T), detail::getNextPowerOfTwo (sizeof (T)),
79
- propList, allocator);
81
+ propList,
82
+ make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>(
83
+ allocator));
80
84
}
81
85
82
86
template <typename _T = T>
83
87
buffer (EnableIfSameNonConstIterators<T, _T> const *hostData,
84
88
const range<dimensions> &bufferRange,
85
89
const property_list &propList = {})
86
90
: Range(bufferRange) {
87
- impl = std::make_shared<detail::buffer_impl<AllocatorT> >(
91
+ impl = std::make_shared<detail::buffer_impl>(
88
92
hostData, get_count () * sizeof (T), detail::getNextPowerOfTwo (sizeof (T)),
89
- propList);
93
+ propList,
94
+ make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>());
90
95
}
91
96
92
97
template <typename _T = T>
93
98
buffer (EnableIfSameNonConstIterators<T, _T> const *hostData,
94
99
const range<dimensions> &bufferRange, AllocatorT allocator,
95
100
const property_list &propList = {})
96
101
: Range(bufferRange) {
97
- impl = std::make_shared<detail::buffer_impl<AllocatorT> >(
102
+ impl = std::make_shared<detail::buffer_impl>(
98
103
hostData, get_count () * sizeof (T), detail::getNextPowerOfTwo (sizeof (T)),
99
- propList, allocator);
104
+ propList,
105
+ make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>(
106
+ allocator));
100
107
}
101
108
102
109
buffer (const shared_ptr_class<T> &hostData,
103
110
const range<dimensions> &bufferRange, AllocatorT allocator,
104
111
const property_list &propList = {})
105
112
: Range(bufferRange) {
106
- impl = std::make_shared<detail::buffer_impl<AllocatorT> >(
113
+ impl = std::make_shared<detail::buffer_impl>(
107
114
hostData, get_count () * sizeof (T), detail::getNextPowerOfTwo (sizeof (T)),
108
- propList, allocator);
115
+ propList,
116
+ make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>(
117
+ allocator));
109
118
}
110
119
111
120
buffer (const shared_ptr_class<T> &hostData,
112
121
const range<dimensions> &bufferRange,
113
122
const property_list &propList = {})
114
123
: Range(bufferRange) {
115
- impl = std::make_shared<detail::buffer_impl<AllocatorT> >(
124
+ impl = std::make_shared<detail::buffer_impl>(
116
125
hostData, get_count () * sizeof (T), detail::getNextPowerOfTwo (sizeof (T)),
117
- propList);
126
+ propList,
127
+ make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>());
118
128
}
119
129
120
130
template <class InputIterator , int N = dimensions,
@@ -123,9 +133,11 @@ class buffer {
123
133
buffer (InputIterator first, InputIterator last, AllocatorT allocator,
124
134
const property_list &propList = {})
125
135
: Range(range<1 >(std::distance(first, last))) {
126
- impl = std::make_shared<detail::buffer_impl<AllocatorT> >(
136
+ impl = std::make_shared<detail::buffer_impl>(
127
137
first, last, get_count () * sizeof (T),
128
- detail::getNextPowerOfTwo (sizeof (T)), propList, allocator);
138
+ detail::getNextPowerOfTwo (sizeof (T)), propList,
139
+ make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>(
140
+ allocator));
129
141
}
130
142
131
143
template <class InputIterator , int N = dimensions,
@@ -134,9 +146,10 @@ class buffer {
134
146
buffer (InputIterator first, InputIterator last,
135
147
const property_list &propList = {})
136
148
: Range(range<1 >(std::distance(first, last))) {
137
- impl = std::make_shared<detail::buffer_impl<AllocatorT> >(
149
+ impl = std::make_shared<detail::buffer_impl>(
138
150
first, last, get_count () * sizeof (T),
139
- detail::getNextPowerOfTwo (sizeof (T)), propList);
151
+ detail::getNextPowerOfTwo (sizeof (T)), propList,
152
+ make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>());
140
153
}
141
154
142
155
// This constructor is a prototype for a future SYCL specification
@@ -146,10 +159,11 @@ class buffer {
146
159
buffer (Container &container, AllocatorT allocator,
147
160
const property_list &propList = {})
148
161
: Range(range<1 >(container.size())) {
149
- impl = std::make_shared<detail::buffer_impl<AllocatorT> >(
162
+ impl = std::make_shared<detail::buffer_impl>(
150
163
container.data (), container.data () + container.size (),
151
164
get_count () * sizeof (T), detail::getNextPowerOfTwo (sizeof (T)), propList,
152
- allocator);
165
+ make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>(
166
+ allocator));
153
167
}
154
168
155
169
// This constructor is a prototype for a future SYCL specification
@@ -185,8 +199,10 @@ class buffer {
185
199
CL_MEM_SIZE, sizeof (size_t ), &BufSize, nullptr );
186
200
187
201
Range[0 ] = BufSize / sizeof (T);
188
- impl = std::make_shared<detail::buffer_impl<AllocatorT>>(
189
- MemObject, SyclContext, BufSize, AvailableEvent);
202
+ impl = std::make_shared<detail::buffer_impl>(
203
+ MemObject, SyclContext, BufSize,
204
+ make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>(),
205
+ AvailableEvent);
190
206
}
191
207
192
208
buffer (const buffer &rhs) = default ;
@@ -213,38 +229,42 @@ class buffer {
213
229
214
230
size_t get_size () const { return get_count () * sizeof (T); }
215
231
216
- AllocatorT get_allocator () const { return impl->get_allocator (); }
232
+ AllocatorT get_allocator () const {
233
+ return impl->template get_allocator <AllocatorT>();
234
+ }
217
235
218
- template <access::mode mode ,
219
- access::target target = access::target::global_buffer>
220
- accessor<T, dimensions, mode, target , access::placeholder::false_t >
221
- get_access (handler &commandGroupHandler ) {
222
- return impl-> template get_access <T, dimensions, mode, target >(
223
- *this , commandGroupHandler );
236
+ template <access::mode Mode ,
237
+ access::target Target = access::target::global_buffer>
238
+ accessor<T, dimensions, Mode, Target , access::placeholder::false_t >
239
+ get_access (handler &CommandGroupHandler ) {
240
+ return accessor <T, dimensions, Mode, Target, access::placeholder:: false_t >(
241
+ *this , CommandGroupHandler );
224
242
}
225
243
226
244
template <access::mode mode>
227
245
accessor<T, dimensions, mode, access::target::host_buffer,
228
246
access::placeholder::false_t >
229
247
get_access () {
230
- return impl->template get_access <T, dimensions, mode>(*this );
248
+ return accessor<T, dimensions, mode, access::target::host_buffer,
249
+ access::placeholder::false_t >(*this );
231
250
}
232
251
233
252
template <access::mode mode,
234
253
access::target target = access::target::global_buffer>
235
254
accessor<T, dimensions, mode, target, access::placeholder::false_t >
236
255
get_access (handler &commandGroupHandler, range<dimensions> accessRange,
237
256
id<dimensions> accessOffset = {}) {
238
- return impl-> template get_access <T, dimensions, mode, target>(
257
+ return accessor <T, dimensions, mode, target, access::placeholder:: false_t >(
239
258
*this , commandGroupHandler, accessRange, accessOffset);
240
259
}
241
260
242
261
template <access::mode mode>
243
262
accessor<T, dimensions, mode, access::target::host_buffer,
244
263
access::placeholder::false_t >
245
264
get_access (range<dimensions> accessRange, id<dimensions> accessOffset = {}) {
246
- return impl->template get_access <T, dimensions, mode>(*this , accessRange,
247
- accessOffset);
265
+ return accessor<T, dimensions, mode, access::target::host_buffer,
266
+ access::placeholder::false_t >(*this , accessRange,
267
+ accessOffset);
248
268
}
249
269
250
270
template <typename Destination = std::nullptr_t >
@@ -278,7 +298,7 @@ class buffer {
278
298
}
279
299
280
300
private:
281
- shared_ptr_class<detail::buffer_impl<AllocatorT> > impl;
301
+ shared_ptr_class<detail::buffer_impl> impl;
282
302
template <class Obj >
283
303
friend decltype (Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject);
284
304
template <typename A, int dims, typename C> friend class buffer ;
@@ -292,7 +312,7 @@ class buffer {
292
312
bool IsSubBuffer = false ;
293
313
294
314
// Reinterpret contructor
295
- buffer (shared_ptr_class<detail::buffer_impl<AllocatorT> > Impl,
315
+ buffer (shared_ptr_class<detail::buffer_impl> Impl,
296
316
range<dimensions> reinterpretRange, size_t reinterpretOffset,
297
317
bool isSubBuffer)
298
318
: impl(Impl), Range(reinterpretRange), OffsetInBytes(reinterpretOffset),
@@ -381,7 +401,7 @@ template <typename T, int dimensions, typename AllocatorT>
381
401
struct hash <cl::sycl::buffer<T, dimensions, AllocatorT>> {
382
402
size_t
383
403
operator ()(const cl::sycl::buffer<T, dimensions, AllocatorT> &b) const {
384
- return hash<std::shared_ptr<cl::sycl::detail::buffer_impl<AllocatorT> >>()(
404
+ return hash<std::shared_ptr<cl::sycl::detail::buffer_impl>>()(
385
405
cl::sycl::detail::getSyclObjImpl (b));
386
406
}
387
407
};
0 commit comments