DPC++ Runtime
Runtime libraries for oneAPI Data Parallel C++
buffer.hpp
Go to the documentation of this file.
1 //==----------- buffer.hpp --- SYCL buffer ---------------------------------==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #pragma once
10 
14 #include <CL/sycl/exception.hpp>
16 #include <CL/sycl/stl.hpp>
18 
20 namespace sycl {
21 
22 class handler;
23 class queue;
24 template <int dimensions> class range;
25 
26 namespace detail {
27 template <typename T, int Dimensions, typename AllocatorT>
30  return buffer<T, Dimensions, AllocatorT, void>(Handle, Ctx, Evt);
31 }
32 } // namespace detail
33 
42 template <typename T, int dimensions = 1,
43  typename AllocatorT = cl::sycl::buffer_allocator,
44  typename __Enabled = typename detail::enable_if_t<(dimensions > 0) &&
45  (dimensions <= 3)>>
46 class buffer {
47  // TODO check is_device_copyable<T>::value after converting sycl::vec into a
48  // trivially copyable class.
49  static_assert(!std::is_same<T, std::string>::value,
50  "'std::string' is not a device copyable type");
51 
52 public:
53  using value_type = T;
54  using reference = value_type &;
55  using const_reference = const value_type &;
56  using allocator_type = AllocatorT;
57  template <int dims>
59  // using same requirement for contiguous container as std::span
60  template <class Container>
61  using EnableIfContiguous =
62  detail::void_t<detail::enable_if_t<std::is_convertible<
64  decltype(std::declval<Container>().data())> (*)[],
65  const T (*)[]>::value>,
66  decltype(std::declval<Container>().size())>;
67  template <class It>
69  std::is_convertible<typename std::iterator_traits<It>::iterator_category,
70  std::input_iterator_tag>::value>;
71  template <typename ItA, typename ItB>
73  std::is_same<ItA, ItB>::value && !std::is_const<ItA>::value, ItA>;
74 
75  buffer(const range<dimensions> &bufferRange,
76  const property_list &propList = {},
77  const detail::code_location CodeLoc = detail::code_location::current())
78  : Range(bufferRange) {
79  impl = std::make_shared<detail::buffer_impl>(
80  size() * sizeof(T), detail::getNextPowerOfTwo(sizeof(T)), propList,
82  impl->constructorNotification(CodeLoc, (void *)impl.get());
83  }
84 
85  buffer(const range<dimensions> &bufferRange, AllocatorT allocator,
86  const property_list &propList = {},
87  const detail::code_location CodeLoc = detail::code_location::current())
88  : Range(bufferRange) {
89  impl = std::make_shared<detail::buffer_impl>(
90  size() * sizeof(T), detail::getNextPowerOfTwo(sizeof(T)), propList,
92  allocator));
93  impl->constructorNotification(CodeLoc, (void *)impl.get());
94  }
95 
96  buffer(T *hostData, const range<dimensions> &bufferRange,
97  const property_list &propList = {},
98  const detail::code_location CodeLoc = detail::code_location::current())
99  : Range(bufferRange) {
100  impl = std::make_shared<detail::buffer_impl>(
101  hostData, size() * sizeof(T), detail::getNextPowerOfTwo(sizeof(T)),
102  propList,
104  impl->constructorNotification(CodeLoc, (void *)impl.get());
105  }
106 
107  buffer(T *hostData, const range<dimensions> &bufferRange,
108  AllocatorT allocator, const property_list &propList = {},
109  const detail::code_location CodeLoc = detail::code_location::current())
110  : Range(bufferRange) {
111  impl = std::make_shared<detail::buffer_impl>(
112  hostData, size() * sizeof(T), detail::getNextPowerOfTwo(sizeof(T)),
113  propList,
115  allocator));
116  impl->constructorNotification(CodeLoc, (void *)impl.get());
117  }
118 
119  template <typename _T = T>
121  const range<dimensions> &bufferRange,
122  const property_list &propList = {},
123  const detail::code_location CodeLoc = detail::code_location::current())
124  : Range(bufferRange) {
125  impl = std::make_shared<detail::buffer_impl>(
126  hostData, size() * sizeof(T), detail::getNextPowerOfTwo(sizeof(T)),
127  propList,
129  impl->constructorNotification(CodeLoc, (void *)impl.get());
130  }
131 
132  template <typename _T = T>
134  const range<dimensions> &bufferRange, AllocatorT allocator,
135  const property_list &propList = {},
136  const detail::code_location CodeLoc = detail::code_location::current())
137  : Range(bufferRange) {
138  impl = std::make_shared<detail::buffer_impl>(
139  hostData, size() * sizeof(T), detail::getNextPowerOfTwo(sizeof(T)),
140  propList,
142  allocator));
143  impl->constructorNotification(CodeLoc, (void *)impl.get());
144  }
145 
146  buffer(const std::shared_ptr<T> &hostData,
147  const range<dimensions> &bufferRange, AllocatorT allocator,
148  const property_list &propList = {},
149  const detail::code_location CodeLoc = detail::code_location::current())
150  : Range(bufferRange) {
151  impl = std::make_shared<detail::buffer_impl>(
152  hostData, size() * sizeof(T), detail::getNextPowerOfTwo(sizeof(T)),
153  propList,
155  allocator));
156  impl->constructorNotification(CodeLoc, (void *)impl.get());
157  }
158 
159  buffer(const std::shared_ptr<T[]> &hostData,
160  const range<dimensions> &bufferRange, AllocatorT allocator,
161  const property_list &propList = {},
162  const detail::code_location CodeLoc = detail::code_location::current())
163  : Range(bufferRange) {
164  impl = std::make_shared<detail::buffer_impl>(
165  hostData, size() * sizeof(T), detail::getNextPowerOfTwo(sizeof(T)),
166  propList,
168  allocator));
169  impl->constructorNotification(CodeLoc, (void *)impl.get());
170  }
171 
172  buffer(const std::shared_ptr<T> &hostData,
173  const range<dimensions> &bufferRange,
174  const property_list &propList = {},
175  const detail::code_location CodeLoc = detail::code_location::current())
176  : Range(bufferRange) {
177  impl = std::make_shared<detail::buffer_impl>(
178  hostData, size() * sizeof(T), detail::getNextPowerOfTwo(sizeof(T)),
179  propList,
181  impl->constructorNotification(CodeLoc, (void *)impl.get());
182  }
183 
184  buffer(const std::shared_ptr<T[]> &hostData,
185  const range<dimensions> &bufferRange,
186  const property_list &propList = {},
187  const detail::code_location CodeLoc = detail::code_location::current())
188  : Range(bufferRange) {
189  impl = std::make_shared<detail::buffer_impl>(
190  hostData, size() * sizeof(T), detail::getNextPowerOfTwo(sizeof(T)),
191  propList,
193  impl->constructorNotification(CodeLoc, (void *)impl.get());
194  }
195 
196  template <class InputIterator, int N = dimensions,
197  typename = EnableIfOneDimension<N>,
198  typename = EnableIfItInputIterator<InputIterator>>
199  buffer(InputIterator first, InputIterator last, AllocatorT allocator,
200  const property_list &propList = {},
201  const detail::code_location CodeLoc = detail::code_location::current())
202  : Range(range<1>(std::distance(first, last))) {
203  impl = std::make_shared<detail::buffer_impl>(
204  first, last, size() * sizeof(T), detail::getNextPowerOfTwo(sizeof(T)),
205  propList,
207  allocator));
208  impl->constructorNotification(CodeLoc, (void *)impl.get());
209  }
210 
211  template <class InputIterator, int N = dimensions,
212  typename = EnableIfOneDimension<N>,
213  typename = EnableIfItInputIterator<InputIterator>>
214  buffer(InputIterator first, InputIterator last,
215  const property_list &propList = {},
216  const detail::code_location CodeLoc = detail::code_location::current())
217  : Range(range<1>(std::distance(first, last))) {
218  impl = std::make_shared<detail::buffer_impl>(
219  first, last, size() * sizeof(T), detail::getNextPowerOfTwo(sizeof(T)),
220  propList,
222  impl->constructorNotification(CodeLoc, (void *)impl.get());
223  }
224 
225  // This constructor is a prototype for a future SYCL specification
226  template <class Container, int N = dimensions,
227  typename = EnableIfOneDimension<N>,
228  typename = EnableIfContiguous<Container>>
229  buffer(Container &container, AllocatorT allocator,
230  const property_list &propList = {},
231  const detail::code_location CodeLoc = detail::code_location::current())
232  : Range(range<1>(container.size())) {
233  impl = std::make_shared<detail::buffer_impl>(
234  container.data(), size() * sizeof(T),
235  detail::getNextPowerOfTwo(sizeof(T)), propList,
237  allocator));
238  impl->constructorNotification(CodeLoc, (void *)impl.get());
239  }
240 
241  // This constructor is a prototype for a future SYCL specification
242  template <class Container, int N = dimensions,
243  typename = EnableIfOneDimension<N>,
244  typename = EnableIfContiguous<Container>>
245  buffer(Container &container, const property_list &propList = {},
246  const detail::code_location CodeLoc = detail::code_location::current())
247  : buffer(container, {}, propList, CodeLoc) {}
248 
250  const range<dimensions> &subRange,
251  const detail::code_location CodeLoc = detail::code_location::current())
252  : impl(b.impl), Range(subRange),
253  OffsetInBytes(getOffsetInBytes<T>(baseIndex, b.Range)),
254  IsSubBuffer(true) {
255  impl->constructorNotification(CodeLoc, (void *)impl.get());
256 
257  if (b.is_sub_buffer())
258  throw cl::sycl::invalid_object_error(
259  "Cannot create sub buffer from sub buffer.", PI_INVALID_VALUE);
260  if (isOutOfBounds(baseIndex, subRange, b.Range))
261  throw cl::sycl::invalid_object_error(
262  "Requested sub-buffer size exceeds the size of the parent buffer",
264  if (!isContiguousRegion(baseIndex, subRange, b.Range))
265  throw cl::sycl::invalid_object_error(
266  "Requested sub-buffer region is not contiguous", PI_INVALID_VALUE);
267  }
268 
269 #ifdef __SYCL_INTERNAL_API
270  template <int N = dimensions, typename = EnableIfOneDimension<N>>
271  buffer(cl_mem MemObject, const context &SyclContext,
272  event AvailableEvent = {},
273  const detail::code_location CodeLoc = detail::code_location::current())
274  : Range{0} {
275 
276  size_t BufSize = detail::SYCLMemObjT::getBufSizeForContext(
277  detail::getSyclObjImpl(SyclContext), MemObject);
278 
279  Range[0] = BufSize / sizeof(T);
280  impl = std::make_shared<detail::buffer_impl>(
281  detail::pi::cast<pi_native_handle>(MemObject), SyclContext, BufSize,
282  make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>(),
283  AvailableEvent);
284  impl->constructorNotification(CodeLoc, (void *)impl.get());
285  }
286 #endif
287 
288  buffer(const buffer &rhs,
289  const detail::code_location CodeLoc = detail::code_location::current())
290  : impl(rhs.impl), Range(rhs.Range), OffsetInBytes(rhs.OffsetInBytes),
291  IsSubBuffer(rhs.IsSubBuffer) {
292  impl->constructorNotification(CodeLoc, (void *)impl.get());
293  }
294 
295  buffer(buffer &&rhs,
296  const detail::code_location CodeLoc = detail::code_location::current())
297  : impl(std::move(rhs.impl)), Range(rhs.Range),
298  OffsetInBytes(rhs.OffsetInBytes), IsSubBuffer(rhs.IsSubBuffer) {
299  impl->constructorNotification(CodeLoc, (void *)impl.get());
300  }
301 
302  buffer &operator=(const buffer &rhs) = default;
303 
304  buffer &operator=(buffer &&rhs) = default;
305 
306  ~buffer() = default;
307 
308  bool operator==(const buffer &rhs) const { return impl == rhs.impl; }
309 
310  bool operator!=(const buffer &rhs) const { return !(*this == rhs); }
311 
312  /* -- common interface members -- */
313 
314  /* -- property interface members -- */
315 
316  range<dimensions> get_range() const { return Range; }
317 
318  __SYCL2020_DEPRECATED("get_count() is deprecated, please use size() instead")
319  size_t get_count() const { return size(); }
320  size_t size() const noexcept { return Range.size(); }
321 
323  "get_size() is deprecated, please use byte_size() instead")
324  size_t get_size() const { return byte_size(); }
325  size_t byte_size() const noexcept { return size() * sizeof(T); }
326 
327  AllocatorT get_allocator() const {
328  return impl->template get_allocator<AllocatorT>();
329  }
330 
331  template <access::mode Mode, access::target Target = access::target::device>
332  accessor<T, dimensions, Mode, Target, access::placeholder::false_t,
335  handler &CommandGroupHandler,
336  const detail::code_location CodeLoc = detail::code_location::current()) {
337  return accessor<T, dimensions, Mode, Target, access::placeholder::false_t,
339  *this, CommandGroupHandler, {}, CodeLoc);
340  }
341 
342  template <access::mode mode>
343  accessor<T, dimensions, mode, access::target::host_buffer,
344  access::placeholder::false_t, ext::oneapi::accessor_property_list<>>
346  const detail::code_location CodeLoc = detail::code_location::current()) {
347  return accessor<T, dimensions, mode, access::target::host_buffer,
348  access::placeholder::false_t,
349  ext::oneapi::accessor_property_list<>>(*this, {}, CodeLoc);
350  }
351 
352  template <access::mode mode, access::target target = access::target::device>
353  accessor<T, dimensions, mode, target, access::placeholder::false_t,
356  handler &commandGroupHandler, range<dimensions> accessRange,
357  id<dimensions> accessOffset = {},
358  const detail::code_location CodeLoc = detail::code_location::current()) {
359  return accessor<T, dimensions, mode, target, access::placeholder::false_t,
361  *this, commandGroupHandler, accessRange, accessOffset, {}, CodeLoc);
362  }
363 
364  template <access::mode mode>
365  accessor<T, dimensions, mode, access::target::host_buffer,
366  access::placeholder::false_t, ext::oneapi::accessor_property_list<>>
368  range<dimensions> accessRange, id<dimensions> accessOffset = {},
369  const detail::code_location CodeLoc = detail::code_location::current()) {
370  return accessor<T, dimensions, mode, access::target::host_buffer,
371  access::placeholder::false_t,
373  *this, accessRange, accessOffset, {}, CodeLoc);
374  }
375 
376 #if __cplusplus > 201402L
377 
378  template <typename... Ts> auto get_access(Ts... args) {
379  return accessor{*this, args...};
380  }
381 
382  template <typename... Ts>
383  auto get_access(handler &commandGroupHandler, Ts... args) {
384  return accessor{*this, commandGroupHandler, args...};
385  }
386 
387  template <typename... Ts> auto get_host_access(Ts... args) {
388  return host_accessor{*this, args...};
389  }
390 
391  template <typename... Ts>
392  auto get_host_access(handler &commandGroupHandler, Ts... args) {
393  return host_accessor{*this, commandGroupHandler, args...};
394  }
395 
396 #endif
397 
398  template <typename Destination = std::nullptr_t>
399  void set_final_data(Destination finalData = nullptr) {
400  impl->set_final_data(finalData);
401  }
402 
403  void set_write_back(bool flag = true) { impl->set_write_back(flag); }
404 
405  bool is_sub_buffer() const { return IsSubBuffer; }
406 
407  template <typename ReinterpretT, int ReinterpretDim>
409  reinterpret(range<ReinterpretDim> reinterpretRange) const {
410  if (sizeof(ReinterpretT) * reinterpretRange.size() != byte_size())
411  throw cl::sycl::invalid_object_error(
412  "Total size in bytes represented by the type and range of the "
413  "reinterpreted SYCL buffer does not equal the total size in bytes "
414  "represented by the type and range of this SYCL buffer",
416 
418  impl, reinterpretRange, OffsetInBytes, IsSubBuffer);
419  }
420 
421  template <typename ReinterpretT, int ReinterpretDim = dimensions>
422  typename std::enable_if<
423  (sizeof(ReinterpretT) == sizeof(T)) && (dimensions == ReinterpretDim),
425  reinterpret() const {
427  impl, get_range(), OffsetInBytes, IsSubBuffer);
428  }
429 
430  template <typename ReinterpretT, int ReinterpretDim = dimensions>
431  typename std::enable_if<
432  (ReinterpretDim == 1) && ((dimensions != ReinterpretDim) ||
433  (sizeof(ReinterpretT) != sizeof(T))),
435  reinterpret() const {
436  long sz = byte_size();
437  if (sz % sizeof(ReinterpretT) != 0)
438  throw cl::sycl::invalid_object_error(
439  "Total byte size of buffer is not evenly divisible by the size of "
440  "the reinterpreted type",
442 
444  impl, range<1>{sz / sizeof(ReinterpretT)}, OffsetInBytes, IsSubBuffer);
445  }
446 
447  template <typename propertyT> bool has_property() const {
448  return impl->template has_property<propertyT>();
449  }
450 
451  template <typename propertyT> propertyT get_property() const {
452  return impl->template get_property<propertyT>();
453  }
454 
455 private:
456  std::shared_ptr<detail::buffer_impl> impl;
457  template <class Obj>
458  friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject);
459  template <typename A, int dims, typename C, typename Enable>
460  friend class buffer;
461  template <typename DataT, int dims, access::mode mode, access::target target,
462  access::placeholder isPlaceholder, typename PropertyListT>
463  friend class accessor;
464  template <typename HT, int HDims, typename HAllocT>
467  range<dimensions> Range;
468  // Offset field specifies the origin of the sub buffer inside the parent
469  // buffer
470  size_t OffsetInBytes = 0;
471  bool IsSubBuffer = false;
472 
473  // Interop constructor
474  template <int N = dimensions, typename = EnableIfOneDimension<N>>
475  buffer(pi_native_handle MemObject, const context &SyclContext,
476  event AvailableEvent = {},
477  const detail::code_location CodeLoc = detail::code_location::current())
478  : Range{0} {
479 
480  size_t BufSize = detail::SYCLMemObjT::getBufSizeForContext(
481  detail::getSyclObjImpl(SyclContext), MemObject);
482 
483  Range[0] = BufSize / sizeof(T);
484  impl = std::make_shared<detail::buffer_impl>(
485  MemObject, SyclContext, BufSize,
486  make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>(),
487  AvailableEvent);
488  impl->constructorNotification(CodeLoc, (void *)impl.get());
489  }
490 
491  // Reinterpret contructor
492  buffer(std::shared_ptr<detail::buffer_impl> Impl,
493  range<dimensions> reinterpretRange, size_t reinterpretOffset,
494  bool isSubBuffer,
495  const detail::code_location CodeLoc = detail::code_location::current())
496  : impl(Impl), Range(reinterpretRange), OffsetInBytes(reinterpretOffset),
497  IsSubBuffer(isSubBuffer) {
498  impl->constructorNotification(CodeLoc, (void *)impl.get());
499  }
500 
501  template <typename Type, int N>
502  size_t getOffsetInBytes(const id<N> &offset, const range<N> &range) {
503  return detail::getLinearIndex(offset, range) * sizeof(Type);
504  }
505 
506  bool isOutOfBounds(const id<dimensions> &offset,
507  const range<dimensions> &newRange,
508  const range<dimensions> &parentRange) {
509  bool outOfBounds = false;
510  for (int i = 0; i < dimensions; ++i)
511  outOfBounds |= newRange[i] + offset[i] > parentRange[i];
512 
513  return outOfBounds;
514  }
515 
516  bool isContiguousRegion(const id<1> &, const range<1> &, const range<1> &) {
517  // 1D sub buffer always has contiguous region
518  return true;
519  }
520 
521  bool isContiguousRegion(const id<2> &offset, const range<2> &newRange,
522  const range<2> &parentRange) {
523  // For 2D sub buffer there are 2 cases:
524  // 1) Offset {Any, Any} | a piece of any line of a buffer
525  // Range {1, Any} |
526  // 2) Offset {Any, 0 } | any number of full lines
527  // Range {Any, Col} |
528  // where Col is a number of columns of original buffer
529  if (offset[1])
530  return newRange[0] == 1;
531  return newRange[1] == parentRange[1];
532  }
533 
534  bool isContiguousRegion(const id<3> &offset, const range<3> &newRange,
535  const range<3> &parentRange) {
536  // For 3D sub buffer there are 3 cases:
537  // 1) Offset {Any, Any, Any} | a piece of any line in any slice of a buffer
538  // Range {1, 1, Any} |
539  // 2) Offset {Any, Any, 0 } | any number of full lines in any slice
540  // Range {1, Any, Col} |
541  // 3) Offset {Any, 0, 0 } | any number of slices
542  // Range {Any, Row, Col} |
543  // where Row and Col are numbers of rows and columns of original buffer
544  if (offset[2])
545  return newRange[0] == 1 && newRange[1] == 1;
546  if (offset[1])
547  return newRange[0] == 1 && newRange[2] == parentRange[2];
548  return newRange[1] == parentRange[1] && newRange[2] == parentRange[2];
549  }
550 };
551 
552 #ifdef __cpp_deduction_guides
553 template <class InputIterator, class AllocatorT>
554 buffer(InputIterator, InputIterator, AllocatorT, const property_list & = {})
555  -> buffer<typename std::iterator_traits<InputIterator>::value_type, 1,
556  AllocatorT>;
557 template <class InputIterator>
558 buffer(InputIterator, InputIterator, const property_list & = {})
559  -> buffer<typename std::iterator_traits<InputIterator>::value_type, 1>;
560 template <class Container, class AllocatorT>
561 buffer(Container &, AllocatorT, const property_list & = {})
562  -> buffer<typename Container::value_type, 1, AllocatorT>;
563 template <class Container>
564 buffer(Container &, const property_list & = {})
565  -> buffer<typename Container::value_type, 1>;
566 template <class T, int dimensions, class AllocatorT>
567 buffer(const T *, const range<dimensions> &, AllocatorT,
568  const property_list & = {}) -> buffer<T, dimensions, AllocatorT>;
569 template <class T, int dimensions>
570 buffer(const T *, const range<dimensions> &, const property_list & = {})
571  -> buffer<T, dimensions>;
572 #endif // __cpp_deduction_guides
573 
574 } // namespace sycl
575 } // __SYCL_INLINE_NAMESPACE(cl)
576 
577 namespace std {
578 template <typename T, int dimensions, typename AllocatorT>
579 struct hash<cl::sycl::buffer<T, dimensions, AllocatorT>> {
580  size_t
582  return hash<std::shared_ptr<cl::sycl::detail::buffer_impl>>()(
584  }
585 };
586 } // namespace std
cl::sycl::buffer::buffer
buffer(const std::shared_ptr< T > &hostData, const range< dimensions > &bufferRange, AllocatorT allocator, const property_list &propList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: buffer.hpp:146
cl::sycl::buffer::has_property
bool has_property() const
Definition: buffer.hpp:447
cl::sycl::buffer< char, 1 >::EnableIfItInputIterator
detail::enable_if_t< std::is_convertible< typename std::iterator_traits< It >::iterator_category, std::input_iterator_tag >::value > EnableIfItInputIterator
Definition: buffer.hpp:70
cl::sycl::buffer::buffer
buffer(const range< dimensions > &bufferRange, AllocatorT allocator, const property_list &propList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: buffer.hpp:85
property_list.hpp
cl::sycl::buffer::get_range
range< dimensions > get_range() const
Definition: buffer.hpp:316
cl::sycl::buffer::get_access
accessor< T, dimensions, mode, target, access::placeholder::false_t, ext::oneapi::accessor_property_list<> > get_access(handler &commandGroupHandler, range< dimensions > accessRange, id< dimensions > accessOffset={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: buffer.hpp:355
cl::sycl::detail::aligned_allocator
Definition: aligned_allocator.hpp:23
type
cl::sycl::buffer::buffer
buffer(const range< dimensions > &bufferRange, const property_list &propList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: buffer.hpp:75
cl::sycl::detail::getLinearIndex
size_t getLinearIndex(const T< Dims > &Index, const U< Dims > &Range)
Definition: common.hpp:330
cl::sycl::buffer::set_final_data
void set_final_data(Destination finalData=nullptr)
Definition: buffer.hpp:399
cl::sycl::buffer::buffer
buffer(Container &container, AllocatorT allocator, const property_list &propList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: buffer.hpp:229
cl::sycl::distance
float distance(T p0, T p1) __NOEXC
Definition: builtins.hpp:1002
T
cl::sycl::event
An event object can be used to synchronize memory transfers, enqueues of kernels and signaling barrie...
Definition: event.hpp:31
cl::sycl::access::placeholder
placeholder
Definition: access.hpp:43
stl.hpp
cl::sycl::id
A unique identifier of an item in an index space.
Definition: array.hpp:17
cl::sycl::buffer::buffer
buffer(InputIterator first, InputIterator last, const property_list &propList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: buffer.hpp:214
accessor_property_list.hpp
cl::sycl::buffer::__SYCL2020_DEPRECATED
__SYCL2020_DEPRECATED("get_size() is deprecated, please use byte_size() instead") size_t get_size() const
Definition: buffer.hpp:322
detail
Definition: pi_opencl.cpp:86
cl::sycl::detail::remove_pointer_t
typename remove_pointer< T >::type remove_pointer_t
Definition: type_traits.hpp:275
cl::sycl::detail::void_t
void void_t
Definition: stl_type_traits.hpp:42
cl::sycl::property_list
Objects of the property_list class are containers for the SYCL properties.
Definition: property_list.hpp:26
cl::sycl::detail::code_location
Definition: common.hpp:54
cl::sycl::buffer
Defines a shared array that can be used by kernels in queues.
Definition: buffer.hpp:46
cl::sycl::info::queue
queue
Definition: info_desc.hpp:223
cl::sycl::buffer< char, 1 >::EnableIfOneDimension
typename detail::enable_if_t< 1==dims > EnableIfOneDimension
Definition: buffer.hpp:58
cl::sycl::range
Defines the iteration domain of either a single work-group in a parallel dispatch,...
Definition: buffer.hpp:24
cl::sycl::buffer::size
size_t size() const noexcept
Definition: buffer.hpp:320
stl_type_traits.hpp
cl::sycl::range::size
size_t size() const
Definition: range.hpp:50
cl::sycl::buffer::buffer
buffer(const std::shared_ptr< T[]> &hostData, const range< dimensions > &bufferRange, AllocatorT allocator, const property_list &propList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: buffer.hpp:159
cl::sycl::buffer::buffer
buffer(EnableIfSameNonConstIterators< T, _T > const *hostData, const range< dimensions > &bufferRange, AllocatorT allocator, const property_list &propList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: buffer.hpp:133
char
cl::sycl::buffer::buffer
buffer(Container &container, const property_list &propList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: buffer.hpp:245
cl::sycl::buffer::buffer
buffer(const buffer &rhs, const detail::code_location CodeLoc=detail::code_location::current())
Definition: buffer.hpp:288
cl::sycl::buffer::__SYCL2020_DEPRECATED
__SYCL2020_DEPRECATED("get_count() is deprecated, please use size() instead") size_t get_count() const
Definition: buffer.hpp:318
cl::sycl::buffer::buffer
buffer(InputIterator first, InputIterator last, AllocatorT allocator, const property_list &propList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: buffer.hpp:199
cl::sycl::accessor
Buffer accessor.
Definition: accessor.hpp:225
cl::sycl::access::target
target
Definition: access.hpp:17
cl
We provide new interfaces for matrix muliply in this patch:
Definition: access.hpp:13
cl::sycl::buffer::buffer
buffer(T *hostData, const range< dimensions > &bufferRange, AllocatorT allocator, const property_list &propList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: buffer.hpp:107
cl::sycl::buffer< char, 1 >::EnableIfContiguous
detail::void_t< detail::enable_if_t< std::is_convertible< detail::remove_pointer_t< decltype(std::declval< Container >().data())>(*)[], const char(*)[]>::value >, decltype(std::declval< Container >().size())> EnableIfContiguous
Definition: buffer.hpp:66
i
int i
Definition: math_intrin.hpp:399
cl::sycl::buffer::operator!=
bool operator!=(const buffer &rhs) const
Definition: buffer.hpp:310
cl::sycl::buffer::get_allocator
AllocatorT get_allocator() const
Definition: buffer.hpp:327
pi_native_handle
uintptr_t pi_native_handle
Definition: pi.h:73
cl::sycl::detail::getNextPowerOfTwo
constexpr size_t getNextPowerOfTwo(size_t Var)
Definition: common.hpp:324
cl::sycl::handler
Command group handler class.
Definition: handler.hpp:361
std::hash< cl::sycl::buffer< T, dimensions, AllocatorT > >::operator()
size_t operator()(const cl::sycl::buffer< T, dimensions, AllocatorT > &b) const
Definition: buffer.hpp:581
cl::sycl::ext::oneapi::accessor_property_list
Objects of the accessor_property_list class are containers for the SYCL properties.
Definition: property_list.hpp:19
cl::sycl::buffer::buffer
buffer(EnableIfSameNonConstIterators< T, _T > const *hostData, const range< dimensions > &bufferRange, const property_list &propList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: buffer.hpp:120
cl::sycl::detail::make_buffer_helper
buffer< T, Dimensions, AllocatorT, void > make_buffer_helper(pi_native_handle Handle, const context &Ctx, event Evt)
Definition: buffer.hpp:29
cl::sycl::buffer::get_access
accessor< T, dimensions, mode, access::target::host_buffer, access::placeholder::false_t, ext::oneapi::accessor_property_list<> > get_access(const detail::code_location CodeLoc=detail::code_location::current())
Definition: buffer.hpp:345
cl::sycl::buffer::buffer
buffer(T *hostData, const range< dimensions > &bufferRange, const property_list &propList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: buffer.hpp:96
cl::sycl::buffer::get_property
propertyT get_property() const
Definition: buffer.hpp:451
PI_INVALID_VALUE
@ PI_INVALID_VALUE
Definition: pi.h:88
cl::sycl::detail::getSyclObjImpl
decltype(Obj::impl) getSyclObjImpl(const Obj &SyclObject)
Definition: common.hpp:198
cl::sycl::buffer::buffer
buffer(const std::shared_ptr< T[]> &hostData, const range< dimensions > &bufferRange, const property_list &propList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: buffer.hpp:184
exception.hpp
cl::sycl::buffer::is_sub_buffer
bool is_sub_buffer() const
Definition: buffer.hpp:405
std
Definition: accessor.hpp:2532
cl::sycl::buffer::reinterpret
buffer< ReinterpretT, ReinterpretDim, AllocatorT > reinterpret(range< ReinterpretDim > reinterpretRange) const
Definition: buffer.hpp:409
cl::sycl::buffer::get_access
accessor< T, dimensions, Mode, Target, access::placeholder::false_t, ext::oneapi::accessor_property_list<> > get_access(handler &CommandGroupHandler, const detail::code_location CodeLoc=detail::code_location::current())
Definition: buffer.hpp:334
cl::sycl::buffer::set_write_back
void set_write_back(bool flag=true)
Definition: buffer.hpp:403
cl::sycl::buffer::operator==
bool operator==(const buffer &rhs) const
Definition: buffer.hpp:308
cl::sycl::context
The context class represents a SYCL context on which kernel functions may be executed.
Definition: context.hpp:35
cl::sycl::buffer::get_access
accessor< T, dimensions, mode, access::target::host_buffer, access::placeholder::false_t, ext::oneapi::accessor_property_list<> > get_access(range< dimensions > accessRange, id< dimensions > accessOffset={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: buffer.hpp:367
cl::sycl::buffer::buffer
buffer(buffer &&rhs, const detail::code_location CodeLoc=detail::code_location::current())
Definition: buffer.hpp:295
cl::sycl::detail::SYCLMemObjAllocatorHolder
Definition: sycl_mem_obj_allocator.hpp:35
common.hpp
cl::sycl::buffer::reinterpret
std::enable_if<(sizeof(ReinterpretT)==sizeof(T)) &&(dimensions==ReinterpretDim), buffer< ReinterpretT, ReinterpretDim, AllocatorT > >::type reinterpret() const
Definition: buffer.hpp:425
cl::sycl::access::mode
mode
Definition: access.hpp:28
cl::sycl::buffer::reinterpret
std::enable_if<(ReinterpretDim==1) &&((dimensions !=ReinterpretDim)||(sizeof(ReinterpretT) !=sizeof(T))), buffer< ReinterpretT, ReinterpretDim, AllocatorT > >::type reinterpret() const
Definition: buffer.hpp:435
cl::sycl::buffer::byte_size
size_t byte_size() const noexcept
Definition: buffer.hpp:325
cl::sycl::detail::enable_if_t
typename std::enable_if< B, T >::type enable_if_t
Definition: stl_type_traits.hpp:24
cl::sycl::buffer::buffer
buffer(buffer< T, dimensions, AllocatorT > &b, const id< dimensions > &baseIndex, const range< dimensions > &subRange, const detail::code_location CodeLoc=detail::code_location::current())
Definition: buffer.hpp:249
cl::sycl::buffer< char, 1 >::EnableIfSameNonConstIterators
typename detail::enable_if_t< std::is_same< ItA, ItB >::value &&!std::is_const< ItA >::value, ItA > EnableIfSameNonConstIterators
Definition: buffer.hpp:73
cl::sycl::buffer_allocator
detail::sycl_memory_object_allocator buffer_allocator
Definition: buffer_impl.hpp:39
cl::sycl::buffer::buffer
buffer(const std::shared_ptr< T > &hostData, const range< dimensions > &bufferRange, const property_list &propList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: buffer.hpp:172
cl::sycl::make_unique_ptr
std::unique_ptr< T > make_unique_ptr(ArgsT &&... Args)
Definition: stl.hpp:51
cl::sycl::errc::accessor
@ accessor
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition: defines_elementary.hpp:12
buffer_impl.hpp