DPC++ Runtime
Runtime libraries for oneAPI DPC++
accessor_image.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <sycl/accessor.hpp>
5 #include <sycl/device.hpp>
6 #include <sycl/image.hpp>
7 
8 #ifdef __SYCL_DEVICE_ONLY__
10 #endif
11 
12 namespace sycl {
13 inline namespace _V1 {
14 namespace detail {
15 void __SYCL_EXPORT unsampledImageConstructorNotification(
16  void *ImageObj, void *AccessorObj,
17  const std::optional<image_target> &Target, access::mode Mode,
18  const void *Type, uint32_t ElemSize, const code_location &CodeLoc);
19 
20 void __SYCL_EXPORT sampledImageConstructorNotification(
21  void *ImageObj, void *AccessorObj,
22  const std::optional<image_target> &Target, const void *Type,
23  uint32_t ElemSize, const code_location &CodeLoc);
24 
25 class UnsampledImageAccessorImplHost;
26 class SampledImageAccessorImplHost;
28  std::shared_ptr<UnsampledImageAccessorImplHost>;
30  std::shared_ptr<SampledImageAccessorImplHost>;
31 
32 void __SYCL_EXPORT
34 void __SYCL_EXPORT
36 
37 class __SYCL_EXPORT UnsampledImageAccessorBaseHost {
38 protected:
40  : impl{Impl} {}
41 
42 public:
44  void *SYCLMemObject, int Dims, int ElemSize,
45  id<3> Pitch, image_channel_type ChannelType,
46  image_channel_order ChannelOrder,
47  const property_list &PropertyList = {});
48  const sycl::range<3> &getSize() const;
49  void *getMemoryObject() const;
50  detail::AccHostDataT &getAccData();
51  void *getPtr();
52  void *getPtr() const;
53  int getNumOfDims() const;
54  int getElementSize() const;
55  id<3> getPitch() const;
56  image_channel_type getChannelType() const;
57  image_channel_order getChannelOrder() const;
58  const property_list &getPropList() const;
59 
60 protected:
61  template <class Obj>
62  friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject);
63 
64  template <class T>
65  friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);
66 
68 
69  // The function references helper methods required by GDB pretty-printers
71 #ifndef NDEBUG
72  const auto *this_const = this;
73  (void)getSize();
74  (void)this_const->getSize();
75  (void)getPtr();
76  (void)this_const->getPtr();
77 #endif
78  }
79 
80 #ifndef __SYCL_DEVICE_ONLY__
81  // Reads a pixel of the underlying image at the specified coordinate. It is
82  // the responsibility of the caller to ensure that the coordinate type is
83  // valid.
84  template <typename DataT, typename CoordT>
85  DataT read(const CoordT &Coords) const noexcept {
89  return imageReadSamplerHostImpl<CoordT, DataT>(
90  Coords, Smpl, getSize(), getPitch(), getChannelType(),
91  getChannelOrder(), getPtr(), getElementSize());
92  }
93 
94  // Writes to a pixel of the underlying image at the specified coordinate. It
95  // is the responsibility of the caller to ensure that the coordinate type is
96  // valid.
97  template <typename DataT, typename CoordT>
98  void write(const CoordT &Coords, const DataT &Color) const {
99  imageWriteHostImpl(Coords, Color, getPitch(), getElementSize(),
100  getChannelType(), getChannelOrder(), getPtr());
101  }
102 #endif
103 };
104 
105 class __SYCL_EXPORT SampledImageAccessorBaseHost {
106 protected:
108  : impl{Impl} {}
109 
110 public:
111  SampledImageAccessorBaseHost(sycl::range<3> Size, void *SYCLMemObject,
112  int Dims, int ElemSize, id<3> Pitch,
113  image_channel_type ChannelType,
114  image_channel_order ChannelOrder,
115  image_sampler Sampler,
116  const property_list &PropertyList = {});
117  const sycl::range<3> &getSize() const;
118  void *getMemoryObject() const;
119  detail::AccHostDataT &getAccData();
120  void *getPtr();
121  void *getPtr() const;
122  int getNumOfDims() const;
123  int getElementSize() const;
124  id<3> getPitch() const;
125  image_channel_type getChannelType() const;
126  image_channel_order getChannelOrder() const;
127  image_sampler getSampler() const;
128  const property_list &getPropList() const;
129 
130 protected:
131  template <class Obj>
132  friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject);
133 
134  template <class T>
135  friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);
136 
138 
139  // The function references helper methods required by GDB pretty-printers
141 #ifndef NDEBUG
142  const auto *this_const = this;
143  (void)getSize();
144  (void)this_const->getSize();
145  (void)getPtr();
146  (void)this_const->getPtr();
147 #endif
148  }
149 
150 #ifndef __SYCL_DEVICE_ONLY__
151  // Reads a pixel of the underlying image at the specified coordinate. It is
152  // the responsibility of the caller to ensure that the coordinate type is
153  // valid.
154  template <typename DataT, typename CoordT>
155  DataT read(const CoordT &Coords) const {
156  return imageReadSamplerHostImpl<CoordT, DataT>(
157  Coords, getSampler(), getSize(), getPitch(), getChannelType(),
158  getChannelOrder(), getPtr(), getElementSize());
159  }
160 #endif
161 };
162 
163 template <typename DataT, int Dimensions, access::mode AccessMode,
165 class __image_array_slice__;
166 
167 // Image accessor
168 template <typename DataT, int Dimensions, access::mode AccessMode,
171 #ifndef __SYCL_DEVICE_ONLY__
172  : public detail::AccessorBaseHost {
173  size_t MImageCount;
174  image_channel_order MImgChannelOrder;
175  image_channel_type MImgChannelType;
176 #else
177 {
178 
179  using OCLImageTy = typename detail::opencl_image_type<Dimensions, AccessMode,
180  AccessTarget>::type;
181  OCLImageTy MImageObj;
182  char MPadding[sizeof(detail::AccessorBaseHost) +
183  sizeof(size_t /*MImageCount*/) + sizeof(image_channel_order) +
184  sizeof(image_channel_type) - sizeof(OCLImageTy)];
185 
186 protected:
187  void imageAccessorInit(OCLImageTy Image) { MImageObj = Image; }
188 
189 private:
190 #endif
191  template <typename T1, int T2, access::mode T3, access::placeholder T4>
192  friend class __image_array_slice__;
193 
194  constexpr static bool IsHostImageAcc =
195  (AccessTarget == access::target::host_image);
196 
197  constexpr static bool IsImageAcc = (AccessTarget == access::target::image);
198 
199  constexpr static bool IsImageArrayAcc =
200  (AccessTarget == access::target::image_array);
201 
202  constexpr static bool IsImageAccessWriteOnly =
205 
206  constexpr static bool IsImageAccessAnyWrite =
207  (IsImageAccessWriteOnly || AccessMode == access::mode::read_write);
208 
209  constexpr static bool IsImageAccessReadOnly =
211 
212  constexpr static bool IsImageAccessAnyRead =
213  (IsImageAccessReadOnly || AccessMode == access::mode::read_write);
214 
215  static_assert(std::is_same_v<DataT, vec<opencl::cl_int, 4>> ||
216  std::is_same_v<DataT, vec<opencl::cl_uint, 4>> ||
217  std::is_same_v<DataT, vec<opencl::cl_float, 4>> ||
218  std::is_same_v<DataT, vec<opencl::cl_half, 4>>,
219  "The data type of an image accessor must be only cl_int4, "
220  "cl_uint4, cl_float4 or cl_half4 from SYCL namespace");
221 
222  static_assert(IsImageAcc || IsHostImageAcc || IsImageArrayAcc,
223  "Expected image type");
224 
226  "Expected false as Placeholder value for image accessor.");
227 
228  static_assert(
229  ((IsImageAcc || IsImageArrayAcc) &&
230  (IsImageAccessWriteOnly || IsImageAccessReadOnly)) ||
231  (IsHostImageAcc && (IsImageAccessAnyWrite || IsImageAccessAnyRead)),
232  "Access modes can be only read/write/discard_write for image/image_array "
233  "target accessor, or they can be only "
234  "read/write/discard_write/read_write for host_image target accessor.");
235 
236  static_assert(Dimensions > 0 && Dimensions <= 3,
237  "Dimensions can be 1/2/3 for image accessor.");
238 
239 #ifdef __SYCL_DEVICE_ONLY__
240 
241  sycl::vec<int, Dimensions> getRangeInternal() const {
242  return __invoke_ImageQuerySize<sycl::vec<int, Dimensions>, OCLImageTy>(
243  MImageObj);
244  }
245 
246  size_t getElementSize() const {
247  int ChannelType = __invoke_ImageQueryFormat<int, OCLImageTy>(MImageObj);
248  int ChannelOrder = __invoke_ImageQueryOrder<int, OCLImageTy>(MImageObj);
249  int ElementSize = getSPIRVElementSize(ChannelType, ChannelOrder);
250  return ElementSize;
251  }
252 
253 #else
254 
255  sycl::vec<int, Dimensions> getRangeInternal() const {
256  // TODO: Implement for host.
257  throw sycl::exception(
259  "image::getRangeInternal() is not implemented for host");
260  return sycl::vec<int, Dimensions>{1};
261  }
262 
263 #endif
264 
265 #ifndef __SYCL_DEVICE_ONLY__
266 protected:
268 #endif // __SYCL_DEVICE_ONLY__
269 
270 private:
272 
273 #ifdef __SYCL_DEVICE_ONLY__
274  const OCLImageTy getNativeImageObj() const { return MImageObj; }
275 #endif // __SYCL_DEVICE_ONLY__
276 
277 public:
278  using value_type = DataT;
279  using reference = DataT &;
280  using const_reference = const DataT &;
281 
282  // image_accessor Constructors.
283 
284 #ifdef __SYCL_DEVICE_ONLY__
285  // Default constructor for objects later initialized with __init member.
286  image_accessor() {}
287 #endif
288 
289  // Available only when: accessTarget == access::target::host_image
290  // template <typename AllocatorT>
291  // accessor(image<dimensions, AllocatorT> &imageRef);
292  template <
293  typename AllocatorT, int Dims = Dimensions,
294  typename = std::enable_if_t<(Dims > 0 && Dims <= 3) && IsHostImageAcc>>
295  image_accessor(image<Dims, AllocatorT> &ImageRef, int ImageElementSize)
296 #ifdef __SYCL_DEVICE_ONLY__
297  {
298  (void)ImageRef;
299  (void)ImageElementSize;
300  // No implementation needed for device. The constructor is only called by
301  // host.
302  }
303 #else
304  : AccessorBaseHost({ImageRef.getRowPitch(), ImageRef.getSlicePitch(), 0},
305  detail::convertToArrayOfN<3, 1>(ImageRef.get_range()),
306  detail::convertToArrayOfN<3, 1>(ImageRef.get_range()),
307  AccessMode, detail::getSyclObjImpl(ImageRef).get(),
308  Dimensions, ImageElementSize, size_t(0)),
309  MImageCount(ImageRef.size()),
310  MImgChannelOrder(ImageRef.getChannelOrder()),
311  MImgChannelType(ImageRef.getChannelType()) {
313  }
314 #endif
315 
316  // Available only when: accessTarget == access::target::image
317  // template <typename AllocatorT>
318  // accessor(image<dimensions, AllocatorT> &imageRef,
319  // handler &commandGroupHandlerRef);
320  template <typename AllocatorT, int Dims = Dimensions,
321  typename = std::enable_if_t<(Dims > 0 && Dims <= 3) && IsImageAcc>>
323  handler &CommandGroupHandlerRef, int ImageElementSize)
324 #ifdef __SYCL_DEVICE_ONLY__
325  {
326  (void)ImageRef;
327  (void)CommandGroupHandlerRef;
328  (void)ImageElementSize;
329  // No implementation needed for device. The constructor is only called by
330  // host.
331  }
332 #else
333  : AccessorBaseHost({ImageRef.getRowPitch(), ImageRef.getSlicePitch(), 0},
334  detail::convertToArrayOfN<3, 1>(ImageRef.get_range()),
335  detail::convertToArrayOfN<3, 1>(ImageRef.get_range()),
336  AccessMode, detail::getSyclObjImpl(ImageRef).get(),
337  Dimensions, ImageElementSize, size_t(0)),
338  MImageCount(ImageRef.size()),
339  MImgChannelOrder(ImageRef.getChannelOrder()),
340  MImgChannelType(ImageRef.getChannelType()) {
341 
342  device Device = getDeviceFromHandler(CommandGroupHandlerRef);
343  if (!Device.has(aspect::ext_intel_legacy_image))
344  throw sycl::exception(
345  sycl::errc::feature_not_supported,
346  "SYCL 1.2.1 images are not supported by this device.");
347  }
348 #endif
349 
350  /* -- common interface members -- */
351 
352  // operator == and != need to be defined only for host application as per the
353  // SYCL spec 1.2.1
354 #ifndef __SYCL_DEVICE_ONLY__
355  bool operator==(const image_accessor &Rhs) const { return Rhs.impl == impl; }
356 #else
357  // The operator with __SYCL_DEVICE_ONLY__ need to be declared for compilation
358  // of host application with device compiler.
359  // Usage of this operator inside the kernel code will give a runtime failure.
360  bool operator==(const image_accessor &Rhs) const;
361 #endif
362 
363  bool operator!=(const image_accessor &Rhs) const { return !(Rhs == *this); }
364 
365  // get_count() method : Returns the number of elements of the SYCL image this
366  // SYCL accessor is accessing.
367  //
368  // get_range() method : Returns a range object which represents the number of
369  // elements of dataT per dimension that this accessor may access.
370  // The range object returned must equal to the range of the image this
371  // accessor is associated with.
372 
373 #ifdef __SYCL_DEVICE_ONLY__
374 
375  __SYCL2020_DEPRECATED("get_count() is deprecated, please use size() instead")
376  size_t get_count() const { return size(); }
377  size_t size() const noexcept { return get_range<Dimensions>().size(); }
378 
379  template <int Dims = Dimensions, typename = std::enable_if_t<Dims == 1>>
380  range<1> get_range() const {
381  int Range = getRangeInternal();
382  return range<1>(Range);
383  }
384  template <int Dims = Dimensions, typename = std::enable_if_t<Dims == 2>>
385  range<2> get_range() const {
386  int2 Range = getRangeInternal();
387  return range<2>(Range[0], Range[1]);
388  }
389  template <int Dims = Dimensions, typename = std::enable_if_t<Dims == 3>>
390  range<3> get_range() const {
391  int3 Range = getRangeInternal();
392  return range<3>(Range[0], Range[1], Range[2]);
393  }
394 
395 #else
396  __SYCL2020_DEPRECATED("get_count() is deprecated, please use size() instead")
397  size_t get_count() const { return size(); };
398  size_t size() const noexcept { return MImageCount; };
399 
400  template <int Dims = Dimensions, typename = std::enable_if_t<(Dims > 0)>>
402  return detail::convertToArrayOfN<Dims, 1>(getAccessRange());
403  }
404 
405 #endif
406 
407  // Available only when:
408  // (accessTarget == access::target::image && accessMode == access::mode::read)
409  // || (accessTarget == access::target::host_image && ( accessMode ==
410  // access::mode::read || accessMode == access::mode::read_write))
411  template <typename CoordT, int Dims = Dimensions,
412  typename = std::enable_if_t<
413  (Dims > 0) && (IsValidCoordDataT<Dims, CoordT>::value) &&
414  (detail::is_genint_v<CoordT>) &&
415  ((IsImageAcc && IsImageAccessReadOnly) ||
416  (IsHostImageAcc && IsImageAccessAnyRead))>>
417  DataT read(const CoordT &Coords) const {
418 #ifdef __SYCL_DEVICE_ONLY__
419  return __invoke__ImageRead<DataT, OCLImageTy, CoordT>(MImageObj, Coords);
420 #else
423  return read<CoordT, Dims>(Coords, Smpl);
424 #endif
425  }
426 
427  // Available only when:
428  // (accessTarget == access::target::image && accessMode == access::mode::read)
429  // || (accessTarget == access::target::host_image && ( accessMode ==
430  // access::mode::read || accessMode == access::mode::read_write))
431  template <typename CoordT, int Dims = Dimensions,
432  typename = std::enable_if_t<
433  (Dims > 0) && (IsValidCoordDataT<Dims, CoordT>::value) &&
434  ((IsImageAcc && IsImageAccessReadOnly) ||
435  (IsHostImageAcc && IsImageAccessAnyRead))>>
436  DataT read(const CoordT &Coords, const sampler &Smpl) const {
437 #ifdef __SYCL_DEVICE_ONLY__
438  return __invoke__ImageReadSampler<DataT, OCLImageTy, CoordT>(
439  MImageObj, Coords, Smpl.impl.m_Sampler);
440 #else
441  return imageReadSamplerHostImpl<CoordT, DataT>(
442  Coords, Smpl, getAccessRange() /*Image Range*/,
443  getOffset() /*Image Pitch*/, MImgChannelType, MImgChannelOrder,
444  AccessorBaseHost::getPtr() /*ptr to image*/,
446 #endif
447  }
448 
449  // Available only when:
450  // (accessTarget == access::target::image && (accessMode ==
451  // access::mode::write || accessMode == access::mode::discard_write)) ||
452  // (accessTarget == access::target::host_image && (accessMode ==
453  // access::mode::write || accessMode == access::mode::discard_write ||
454  // accessMode == access::mode::read_write))
455  template <
456  typename CoordT, int Dims = Dimensions,
457  typename = std::enable_if_t<(Dims > 0) && (detail::is_genint_v<CoordT>) &&
459  ((IsImageAcc && IsImageAccessWriteOnly) ||
460  (IsHostImageAcc && IsImageAccessAnyWrite))>>
461  void write(const CoordT &Coords, const DataT &Color) const {
462 #ifdef __SYCL_DEVICE_ONLY__
463  __invoke__ImageWrite<OCLImageTy, CoordT, DataT>(MImageObj, Coords, Color);
464 #else
465  imageWriteHostImpl(Coords, Color, getOffset() /*ImagePitch*/,
466  AccessorBaseHost::getElemSize(), MImgChannelType,
467  MImgChannelOrder,
468  AccessorBaseHost::getPtr() /*Ptr to Image*/);
469 #endif
470  }
471 };
472 
473 template <typename DataT, int Dimensions, access::mode AccessMode,
476 
477  static_assert(Dimensions < 3,
478  "Image slice cannot have more then 2 dimensions");
479 
480  constexpr static int AdjustedDims = (Dimensions == 2) ? 4 : Dimensions + 1;
481 
482  template <typename CoordT, typename CoordElemType = get_elem_type_t<CoordT>>
484  getAdjustedCoords(const CoordT &Coords) const {
485  CoordElemType LastCoord = 0;
486 
487  if (std::is_same<float, CoordElemType>::value) {
488  sycl::vec<int, Dimensions + 1> Size = MBaseAcc.getRangeInternal();
489  LastCoord =
490  MIdx / static_cast<float>(Size.template swizzle<Dimensions>());
491  } else {
492  LastCoord = MIdx;
493  }
494 
495  sycl::vec<CoordElemType, Dimensions> LeftoverCoords{LastCoord};
496  sycl::vec<CoordElemType, AdjustedDims> AdjustedCoords{Coords,
497  LeftoverCoords};
498  return AdjustedCoords;
499  }
500 
501 public:
505  BaseAcc,
506  size_t Idx)
507  : MBaseAcc(BaseAcc), MIdx(Idx) {}
508 
509  template <typename CoordT, int Dims = Dimensions,
510  typename = std::enable_if_t<
512  DataT read(const CoordT &Coords) const {
513  return MBaseAcc.read(getAdjustedCoords(Coords));
514  }
515 
516  template <typename CoordT, int Dims = Dimensions,
517  typename = std::enable_if_t<(Dims > 0) &&
519  DataT read(const CoordT &Coords, const sampler &Smpl) const {
520  return MBaseAcc.read(getAdjustedCoords(Coords), Smpl);
521  }
522 
523  template <typename CoordT, int Dims = Dimensions,
524  typename = std::enable_if_t<(Dims > 0) &&
526  void write(const CoordT &Coords, const DataT &Color) const {
527  return MBaseAcc.write(getAdjustedCoords(Coords), Color);
528  }
529 
530 #ifdef __SYCL_DEVICE_ONLY__
531  __SYCL2020_DEPRECATED("get_count() is deprecated, please use size() instead")
532  size_t get_count() const { return size(); }
533  size_t size() const noexcept { return get_range<Dimensions>().size(); }
534 
535  template <int Dims = Dimensions, typename = std::enable_if_t<Dims == 1>>
536  range<1> get_range() const {
537  int2 Count = MBaseAcc.getRangeInternal();
538  return range<1>(Count.x());
539  }
540  template <int Dims = Dimensions, typename = std::enable_if_t<Dims == 2>>
541  range<2> get_range() const {
542  int3 Count = MBaseAcc.getRangeInternal();
543  return range<2>(Count.x(), Count.y());
544  }
545 
546 #else
547 
548  __SYCL2020_DEPRECATED("get_count() is deprecated, please use size() instead")
549  size_t get_count() const { return size(); }
550  size_t size() const noexcept {
551  return MBaseAcc.MImageCount / MBaseAcc.getAccessRange()[Dimensions];
552  }
553 
554  template <int Dims = Dimensions,
555  typename = std::enable_if_t<(Dims == 1 || Dims == 2)>>
557  return detail::convertToArrayOfN<Dims, 1>(MBaseAcc.getAccessRange());
558  }
559 
560 #endif
561 
562 private:
563  size_t MIdx;
566  MBaseAcc;
567 };
568 
569 } // namespace detail
575 template <typename DataT, int Dimensions, access::mode AccessMode,
578  DataT, Dimensions, AccessMode, access::target::image, IsPlaceholder>
579  : public detail::image_accessor<DataT, Dimensions, AccessMode,
580  access::target::image, IsPlaceholder>,
581  public detail::OwnerLessBase<
582  accessor<DataT, Dimensions, AccessMode, access::target::image,
583  IsPlaceholder>> {
584 private:
585  accessor(const detail::AccessorImplPtr &Impl)
586  : detail::image_accessor<DataT, Dimensions, AccessMode,
588 
589 public:
590  template <typename AllocatorT>
592  handler &CommandGroupHandler)
593  : detail::image_accessor<DataT, Dimensions, AccessMode,
595  Image, CommandGroupHandler, Image.getElementSize()) {
596 #ifndef __SYCL_DEVICE_ONLY__
597  detail::associateWithHandler(CommandGroupHandler, this,
599 #endif
600  }
601 
602  template <typename AllocatorT>
604  handler &CommandGroupHandler, const property_list &propList)
605  : detail::image_accessor<DataT, Dimensions, AccessMode,
607  Image, CommandGroupHandler, Image.getElementSize()) {
608  (void)propList;
609 #ifndef __SYCL_DEVICE_ONLY__
610  detail::associateWithHandler(CommandGroupHandler, this,
612 #endif
613  }
614 #ifdef __SYCL_DEVICE_ONLY__
615 private:
616  using OCLImageTy =
617  typename detail::opencl_image_type<Dimensions, AccessMode,
618  access::target::image>::type;
619 
620  // Front End requires this method to be defined in the accessor class.
621  // It does not call the base class's init method.
622  void __init(OCLImageTy Image) { this->imageAccessorInit(Image); }
623 
624  // __init variant used by the device compiler for ESIMD kernels.
625  void __init_esimd(OCLImageTy Image) { this->imageAccessorInit(Image); }
626 
627 public:
628  // Default constructor for objects later initialized with __init member.
629  accessor() = default;
630 #endif
631 };
632 
640 template <typename DataT, int Dimensions, access::mode AccessMode,
643  access::target::host_image, IsPlaceholder>
644  : public detail::image_accessor<DataT, Dimensions, AccessMode,
645  access::target::host_image, IsPlaceholder>,
646  public detail::OwnerLessBase<
647  accessor<DataT, Dimensions, AccessMode, access::target::host_image,
648  IsPlaceholder>> {
649 public:
650  template <typename AllocatorT>
652  : detail::image_accessor<DataT, Dimensions, AccessMode,
653  access::target::host_image, IsPlaceholder>(
654  Image, Image.getElementSize()) {}
655 
656  template <typename AllocatorT>
658  const property_list &propList)
659  : detail::image_accessor<DataT, Dimensions, AccessMode,
660  access::target::host_image, IsPlaceholder>(
661  Image, Image.getElementSize()) {
662  (void)propList;
663  }
664 };
665 
674 template <typename DataT, int Dimensions, access::mode AccessMode,
677  DataT, Dimensions, AccessMode, access::target::image_array, IsPlaceholder>
678  : public detail::image_accessor<DataT, Dimensions + 1, AccessMode,
679  access::target::image, IsPlaceholder>,
680  public detail::OwnerLessBase<
681  accessor<DataT, Dimensions, AccessMode, access::target::image_array,
682  IsPlaceholder>> {
683 #ifdef __SYCL_DEVICE_ONLY__
684 private:
685  using OCLImageTy =
686  typename detail::opencl_image_type<Dimensions + 1, AccessMode,
687  access::target::image>::type;
688 
689  // Front End requires this method to be defined in the accessor class.
690  // It does not call the base class's init method.
691  void __init(OCLImageTy Image) { this->imageAccessorInit(Image); }
692 
693  // __init variant used by the device compiler for ESIMD kernels.
694  void __init_esimd(OCLImageTy Image) { this->imageAccessorInit(Image); }
695 
696 public:
697  // Default constructor for objects later initialized with __init member.
698  accessor() = default;
699 #endif
700 public:
701  template <typename AllocatorT>
703  handler &CommandGroupHandler)
704  : detail::image_accessor<DataT, Dimensions + 1, AccessMode,
705  access::target::image, IsPlaceholder>(
706  Image, CommandGroupHandler, Image.getElementSize()) {
707 #ifndef __SYCL_DEVICE_ONLY__
708  detail::associateWithHandler(CommandGroupHandler, this,
710 #endif
711  }
712 
713  template <typename AllocatorT>
715  handler &CommandGroupHandler, const property_list &propList)
716  : detail::image_accessor<DataT, Dimensions + 1, AccessMode,
717  access::target::image, IsPlaceholder>(
718  Image, CommandGroupHandler, Image.getElementSize()) {
719  (void)propList;
720 #ifndef __SYCL_DEVICE_ONLY__
721  detail::associateWithHandler(CommandGroupHandler, this,
723 #endif
724  }
725 
726  detail::__image_array_slice__<DataT, Dimensions, AccessMode, IsPlaceholder>
727  operator[](size_t Index) const {
728  return detail::__image_array_slice__<DataT, Dimensions, AccessMode,
729  IsPlaceholder>(*this, Index);
730  }
731 };
732 
733 // SYCL 2020 image accessors
734 
735 template <typename DataT, int Dimensions, access_mode AccessMode,
736  image_target AccessTarget = image_target::device>
738 #ifndef __SYCL_DEVICE_ONLY__
740 #endif // __SYCL_DEVICE_ONLY__
741  public detail::OwnerLessBase<
742  unsampled_image_accessor<DataT, Dimensions, AccessMode, AccessTarget>> {
743  static_assert(std::is_same_v<DataT, int4> || std::is_same_v<DataT, uint4> ||
744  std::is_same_v<DataT, float4> ||
745  std::is_same_v<DataT, half4>,
746  "The data type of an image accessor must be only int4, "
747  "uint4, float4 or half4 from SYCL namespace");
748  static_assert(AccessMode == access_mode::read ||
750  "Access mode must be either read or write.");
751 
752 #ifdef __SYCL_DEVICE_ONLY__
753  char MPadding[sizeof(detail::UnsampledImageAccessorBaseHost)];
754 #else
756 #endif // __SYCL_DEVICE_ONLY__
757 
758 public:
759  using value_type = typename std::conditional<AccessMode == access_mode::read,
760  const DataT, DataT>::type;
762  using const_reference = const DataT &;
763 
764  template <typename AllocatorT>
767  handler &CommandGroupHandlerRef, const property_list &PropList = {},
769 #ifdef __SYCL_DEVICE_ONLY__
770  {
771  (void)ImageRef;
772  (void)CommandGroupHandlerRef;
773  (void)PropList;
774  (void)CodeLoc;
775  }
776 #else
777  : host_base_class(detail::convertToArrayOfN<3, 1>(ImageRef.get_range()),
778  AccessMode, detail::getSyclObjImpl(ImageRef).get(),
779  Dimensions, ImageRef.getElementSize(),
780  {ImageRef.getRowPitch(), ImageRef.getSlicePitch(), 0},
781  ImageRef.getChannelType(), ImageRef.getChannelOrder(),
782  PropList) {
783  device Device = detail::getDeviceFromHandler(CommandGroupHandlerRef);
784  // Avoid aspect::image warning.
785  aspect ImageAspect = aspect::image;
786  if (AccessTarget == image_target::device && !Device.has(ImageAspect))
787  throw sycl::exception(
788  sycl::make_error_code(sycl::errc::feature_not_supported),
789  "Device associated with command group handler does not have "
790  "aspect::image.");
791 
793  detail::getSyclObjImpl(ImageRef).get(), this->impl.get(), AccessTarget,
794  AccessMode, (const void *)typeid(DataT).name(), sizeof(DataT), CodeLoc);
795  detail::associateWithHandler(CommandGroupHandlerRef, this, AccessTarget);
796  GDBMethodsAnchor();
797  }
798 #endif // __SYCL_DEVICE_ONLY__
799 
800  /* -- common interface members -- */
801 
803 
805 
807  operator=(const unsampled_image_accessor &Rhs) = default;
808 
810 
812 
813 #ifdef __SYCL_DEVICE_ONLY__
814  bool operator==(const unsampled_image_accessor &Rhs) const;
815 #else
816  bool operator==(const unsampled_image_accessor &Rhs) const {
817  return Rhs.impl == impl;
818  }
819 #endif // __SYCL_DEVICE_ONLY__
820 
821  bool operator!=(const unsampled_image_accessor &Rhs) const {
822  return !(Rhs == *this);
823  }
824 
825  /* -- property interface members -- */
826  template <typename Property> bool has_property() const noexcept {
827 #ifndef __SYCL_DEVICE_ONLY__
828  return getPropList().template has_property<Property>();
829 #else
830  return false;
831 #endif
832  }
833  template <typename Property> Property get_property() const {
834 #ifndef __SYCL_DEVICE_ONLY__
835  return getPropList().template get_property<Property>();
836 #else
837  return Property();
838 #endif
839  }
840 
841  size_t size() const noexcept {
842 #ifdef __SYCL_DEVICE_ONLY__
843  // Currently not reachable on device.
844  return 0;
845 #else
846  return host_base_class::getSize().size();
847 #endif // __SYCL_DEVICE_ONLY__
848  }
849 
850  /* Available only when: AccessMode == access_mode::read
851  if Dimensions == 1, CoordT = int
852  if Dimensions == 2, CoordT = int2
853  if Dimensions == 3, CoordT = int4 */
854  template <typename CoordT,
855  typename = std::enable_if_t<AccessMode == access_mode::read &&
857  Dimensions, CoordT>::value>>
858  DataT read(const CoordT &Coords) const noexcept {
859 #ifdef __SYCL_DEVICE_ONLY__
860  // Currently not reachable on device.
861  std::ignore = Coords;
862  return {0, 0, 0, 0};
863 #else
864  return host_base_class::read<DataT>(Coords);
865 #endif // __SYCL_DEVICE_ONLY__
866  }
867 
868  /* Available only when: AccessMode == access_mode::write
869  if Dimensions == 1, CoordT = int
870  if Dimensions == 2, CoordT = int2
871  if Dimensions == 3, CoordT = int4 */
872  template <typename CoordT,
873  typename = std::enable_if_t<AccessMode == access_mode::write &&
875  Dimensions, CoordT>::value>>
876  void write(const CoordT &Coords, const DataT &Color) const {
877 #ifdef __SYCL_DEVICE_ONLY__
878  // Currently not reachable on device.
879  std::ignore = Coords;
880  std::ignore = Color;
881 #else
882  host_base_class::write<DataT>(Coords, Color);
883 #endif // __SYCL_DEVICE_ONLY__
884  }
885 
886 private:
888 #ifndef __SYCL_DEVICE_ONLY__
889  : host_base_class{Impl}
890 #endif // __SYCL_DEVICE_ONLY__
891  {
892  std::ignore = Impl;
893  }
894 
895  template <class Obj>
896  friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject);
897 
898  template <class T>
899  friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);
900 };
901 
902 template <typename DataT, int Dimensions = 1,
904  (std::is_const_v<DataT> ? access_mode::read
908  public detail::OwnerLessBase<
910  static_assert(std::is_same_v<DataT, int4> || std::is_same_v<DataT, uint4> ||
911  std::is_same_v<DataT, float4> ||
912  std::is_same_v<DataT, half4>,
913  "The data type of an image accessor must be only int4, "
914  "uint4, float4 or half4 from SYCL namespace");
915 
917 
918 public:
919  using value_type = typename std::conditional<AccessMode == access_mode::read,
920  const DataT, DataT>::type;
922  using const_reference = const DataT &;
923 
924  template <typename AllocatorT>
927  const property_list &PropList = {},
929  : base_class(detail::convertToArrayOfN<3, 1>(ImageRef.get_range()),
930  AccessMode, detail::getSyclObjImpl(ImageRef).get(),
931  Dimensions, ImageRef.getElementSize(),
932  {ImageRef.getRowPitch(), ImageRef.getSlicePitch(), 0},
933  ImageRef.getChannelType(), ImageRef.getChannelOrder(),
934  PropList) {
935  addHostUnsampledImageAccessorAndWait(base_class::impl.get());
936 
938  detail::getSyclObjImpl(ImageRef).get(), this->impl.get(), std::nullopt,
939  AccessMode, (const void *)typeid(DataT).name(), sizeof(DataT), CodeLoc);
940  }
941 
942  /* -- common interface members -- */
943 
945  default;
946 
948 
951 
954 
956 
957  bool operator==(const host_unsampled_image_accessor &Rhs) const {
958  return Rhs.impl == impl;
959  }
960  bool operator!=(const host_unsampled_image_accessor &Rhs) const {
961  return !(Rhs == *this);
962  }
963 
964  /* -- property interface members -- */
965  template <typename Property> bool has_property() const noexcept {
966 #ifndef __SYCL_DEVICE_ONLY__
967  return getPropList().template has_property<Property>();
968 #else
969  return false;
970 #endif
971  }
972  template <typename Property> Property get_property() const {
973 #ifndef __SYCL_DEVICE_ONLY__
974  return getPropList().template get_property<Property>();
975 #else
976  return Property();
977 #endif
978  }
979 
980  size_t size() const noexcept { return base_class::getSize().size(); }
981 
982  /* Available only when: (AccessMode == access_mode::read ||
983  AccessMode == access_mode::read_write)
984  if Dimensions == 1, CoordT = int
985  if Dimensions == 2, CoordT = int2
986  if Dimensions == 3, CoordT = int4 */
987  template <
988  typename CoordT,
989  typename = std::enable_if_t<
993  DataT read(const CoordT &Coords) const noexcept
994 #ifdef __SYCL_DEVICE_ONLY__
995  ;
996 #else
997  {
998  // Host implementation is only available in host code. Device is not allowed
999  // to use host_unsampled_image_accessor.
1000  return base_class::read<DataT>(Coords);
1001  }
1002 #endif
1003 
1004  /* Available only when: (AccessMode == access_mode::write ||
1005  AccessMode == access_mode::read_write)
1006  if Dimensions == 1, CoordT = int
1007  if Dimensions == 2, CoordT = int2
1008  if Dimensions == 3, CoordT = int4 */
1009  template <
1010  typename CoordT,
1011  typename = std::enable_if_t<
1015  void write(const CoordT &Coords, const DataT &Color) const
1016 #ifdef __SYCL_DEVICE_ONLY__
1017  ;
1018 #else
1019  {
1020  // Host implementation is only available in host code. Device is not allowed
1021  // to use host_unsampled_image_accessor.
1022  base_class::write<DataT>(Coords, Color);
1023  }
1024 #endif
1025 
1026 private:
1029  : base_class{Impl} {}
1030 
1031  template <class Obj>
1032  friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject);
1033 
1034  template <class T>
1035  friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);
1036 };
1037 
1038 template <typename DataT, int Dimensions,
1039  image_target AccessTarget = image_target::device>
1041 #ifndef __SYCL_DEVICE_ONLY__
1043 #endif // __SYCL_DEVICE_ONLY__
1044  public detail::OwnerLessBase<
1045  sampled_image_accessor<DataT, Dimensions, AccessTarget>> {
1046  static_assert(std::is_same_v<DataT, int4> || std::is_same_v<DataT, uint4> ||
1047  std::is_same_v<DataT, float4> ||
1048  std::is_same_v<DataT, half4>,
1049  "The data type of an image accessor must be only int4, "
1050  "uint4, float4 or half4 from SYCL namespace");
1051 
1052 #ifdef __SYCL_DEVICE_ONLY__
1053  char MPadding[sizeof(detail::SampledImageAccessorBaseHost)];
1054 #else
1056 #endif // __SYCL_DEVICE_ONLY__
1057 
1058 public:
1059  using value_type = const DataT;
1060  using reference = const DataT &;
1061  using const_reference = const DataT &;
1062 
1063  template <typename AllocatorT>
1066  handler &CommandGroupHandlerRef, const property_list &PropList = {},
1068 #ifdef __SYCL_DEVICE_ONLY__
1069  {
1070  (void)ImageRef;
1071  (void)CommandGroupHandlerRef;
1072  (void)PropList;
1073  (void)CodeLoc;
1074  }
1075 #else
1076  : host_base_class(detail::convertToArrayOfN<3, 1>(ImageRef.get_range()),
1077  detail::getSyclObjImpl(ImageRef).get(), Dimensions,
1078  ImageRef.getElementSize(),
1079  {ImageRef.getRowPitch(), ImageRef.getSlicePitch(), 0},
1080  ImageRef.getChannelType(), ImageRef.getChannelOrder(),
1081  ImageRef.getSampler(), PropList) {
1082  device Device = detail::getDeviceFromHandler(CommandGroupHandlerRef);
1083  // Avoid aspect::image warning.
1084  aspect ImageAspect = aspect::image;
1085  if (AccessTarget == image_target::device && !Device.has(ImageAspect))
1086  throw sycl::exception(
1087  sycl::make_error_code(sycl::errc::feature_not_supported),
1088  "Device associated with command group handler does not have "
1089  "aspect::image.");
1090 
1092  detail::getSyclObjImpl(ImageRef).get(), this->impl.get(), AccessTarget,
1093  (const void *)typeid(DataT).name(), sizeof(DataT), CodeLoc);
1094  detail::associateWithHandler(CommandGroupHandlerRef, this, AccessTarget);
1095  GDBMethodsAnchor();
1096  }
1097 #endif // __SYCL_DEVICE_ONLY__
1098 
1099  /* -- common interface members -- */
1100 
1102 
1104 
1106  operator=(const sampled_image_accessor &Rhs) = default;
1107 
1109 
1111 
1112 #ifdef __SYCL_DEVICE_ONLY__
1113  bool operator==(const sampled_image_accessor &Rhs) const;
1114 #else
1115  bool operator==(const sampled_image_accessor &Rhs) const {
1116  return Rhs.impl == impl;
1117  }
1118 #endif // __SYCL_DEVICE_ONLY__
1119 
1120  bool operator!=(const sampled_image_accessor &Rhs) const {
1121  return !(Rhs == *this);
1122  }
1123 
1124  /* -- property interface members -- */
1125  template <typename Property> bool has_property() const noexcept {
1126 #ifndef __SYCL_DEVICE_ONLY__
1127  return getPropList().template has_property<Property>();
1128 #else
1129  return false;
1130 #endif
1131  }
1132  template <typename Property> Property get_property() const {
1133 #ifndef __SYCL_DEVICE_ONLY__
1134  return getPropList().template get_property<Property>();
1135 #else
1136  return Property();
1137 #endif
1138  }
1139 
1140  size_t size() const noexcept {
1141 #ifdef __SYCL_DEVICE_ONLY__
1142  // Currently not reachable on device.
1143  return 0;
1144 #else
1145  return host_base_class::getSize().size();
1146 #endif // __SYCL_DEVICE_ONLY__
1147  }
1148 
1149  /* if Dimensions == 1, CoordT = float
1150  if Dimensions == 2, CoordT = float2
1151  if Dimensions == 3, CoordT = float4 */
1152  template <typename CoordT,
1153  typename = std::enable_if_t<detail::IsValidSampledCoord2020DataT<
1154  Dimensions, CoordT>::value>>
1155  DataT read(const CoordT &Coords) const noexcept {
1156 #ifdef __SYCL_DEVICE_ONLY__
1157  // Currently not reachable on device.
1158  std::ignore = Coords;
1159  return {0, 0, 0, 0};
1160 #else
1161  return host_base_class::read<DataT>(Coords);
1162 #endif // __SYCL_DEVICE_ONLY__
1163  }
1164 
1165 private:
1167 #ifndef __SYCL_DEVICE_ONLY__
1168  : host_base_class{Impl}
1169 #endif // __SYCL_DEVICE_ONLY__
1170  {
1171  std::ignore = Impl;
1172  }
1173 
1174  template <class Obj>
1175  friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject);
1176 
1177  template <class T>
1178  friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);
1179 };
1180 
1181 template <typename DataT, int Dimensions>
1184  public detail::OwnerLessBase<
1185  host_sampled_image_accessor<DataT, Dimensions>> {
1186  static_assert(std::is_same_v<DataT, int4> || std::is_same_v<DataT, uint4> ||
1187  std::is_same_v<DataT, float4> ||
1188  std::is_same_v<DataT, half4>,
1189  "The data type of an image accessor must be only int4, "
1190  "uint4, float4 or half4 from SYCL namespace");
1191 
1193 
1194 public:
1195  using value_type = const DataT;
1196  using reference = const DataT &;
1197  using const_reference = const DataT &;
1198 
1199  template <typename AllocatorT>
1202  const property_list &PropList = {},
1204  : base_class(detail::convertToArrayOfN<3, 1>(ImageRef.get_range()),
1205  detail::getSyclObjImpl(ImageRef).get(), Dimensions,
1206  ImageRef.getElementSize(),
1207  {ImageRef.getRowPitch(), ImageRef.getSlicePitch(), 0},
1208  ImageRef.getChannelType(), ImageRef.getChannelOrder(),
1209  ImageRef.getSampler(), PropList) {
1210  addHostSampledImageAccessorAndWait(base_class::impl.get());
1211 
1213  detail::getSyclObjImpl(ImageRef).get(), this->impl.get(), std::nullopt,
1214  (const void *)typeid(DataT).name(), sizeof(DataT), CodeLoc);
1215  }
1216 
1217  /* -- common interface members -- */
1218 
1220 
1222 
1225 
1228 
1230 
1231  bool operator==(const host_sampled_image_accessor &Rhs) const {
1232  return Rhs.impl == impl;
1233  }
1234  bool operator!=(const host_sampled_image_accessor &Rhs) const {
1235  return !(Rhs == *this);
1236  }
1237 
1238  /* -- property interface members -- */
1239  template <typename Property> bool has_property() const noexcept {
1240 #ifndef __SYCL_DEVICE_ONLY__
1241  return getPropList().template has_property<Property>();
1242 #else
1243  return false;
1244 #endif
1245  }
1246  template <typename Property> Property get_property() const {
1247 #ifndef __SYCL_DEVICE_ONLY__
1248  return getPropList().template get_property<Property>();
1249 #else
1250  return Property();
1251 #endif
1252  }
1253 
1254  size_t size() const noexcept { return base_class::getSize().size(); }
1255 
1256  /* if Dimensions == 1, CoordT = float
1257  if Dimensions == 2, CoordT = float2
1258  if Dimensions == 3, CoordT = float4 */
1259  template <typename CoordT,
1260  typename = std::enable_if_t<detail::IsValidSampledCoord2020DataT<
1261  Dimensions, CoordT>::value>>
1262  DataT read(const CoordT &Coords) const
1263 #ifdef __SYCL_DEVICE_ONLY__
1264  ;
1265 #else
1266  {
1267  // Host implementation is only available in host code. Device is not allowed
1268  // to use host_sampled_image_accessor.
1269  return base_class::read<DataT>(Coords);
1270  }
1271 #endif
1272 
1273 private:
1275  : base_class{Impl} {}
1276 
1277  template <class Obj>
1278  friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject);
1279 
1280  template <class T>
1281  friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);
1282 };
1283 
1284 } // namespace _V1
1285 } // namespace sycl
1286 
1287 namespace std {
1288 template <typename DataT, int Dimensions, sycl::access_mode AccessMode,
1289  sycl::image_target AccessTarget>
1290 struct hash<sycl::unsampled_image_accessor<DataT, Dimensions, AccessMode,
1291  AccessTarget>> {
1293  AccessTarget>;
1294 
1295  size_t operator()(const AccType &A) const {
1296 #ifdef __SYCL_DEVICE_ONLY__
1297  // Hash is not supported on DEVICE. Just return 0 here.
1298  (void)A;
1299  return 0;
1300 #else
1301  auto AccImplPtr = sycl::detail::getSyclObjImpl(A);
1302  return hash<decltype(AccImplPtr)>()(AccImplPtr);
1303 #endif
1304  }
1305 };
1306 
1307 template <typename DataT, int Dimensions, sycl::access_mode AccessMode>
1308 struct hash<
1309  sycl::host_unsampled_image_accessor<DataT, Dimensions, AccessMode>> {
1310  using AccType =
1312 
1313  size_t operator()(const AccType &A) const {
1314  auto AccImplPtr = sycl::detail::getSyclObjImpl(A);
1315  return hash<decltype(AccImplPtr)>()(AccImplPtr);
1316  }
1317 };
1318 
1319 template <typename DataT, int Dimensions, sycl::image_target AccessTarget>
1320 struct hash<sycl::sampled_image_accessor<DataT, Dimensions, AccessTarget>> {
1322 
1323  size_t operator()(const AccType &A) const {
1324 #ifdef __SYCL_DEVICE_ONLY__
1325  // Hash is not supported on DEVICE. Just return 0 here.
1326  (void)A;
1327  return 0;
1328 #else
1329  auto AccImplPtr = sycl::detail::getSyclObjImpl(A);
1330  return hash<decltype(AccImplPtr)>()(AccImplPtr);
1331 #endif
1332  }
1333 };
1334 
1335 template <typename DataT, int Dimensions>
1336 struct hash<sycl::host_sampled_image_accessor<DataT, Dimensions>> {
1338 
1339  size_t operator()(const AccType &A) const {
1340  auto AccImplPtr = sycl::detail::getSyclObjImpl(A);
1341  return hash<decltype(AccImplPtr)>()(AccImplPtr);
1342  }
1343 };
1344 
1345 } // namespace std
The file contains implementations of accessor class.
accessor(sycl::image< Dimensions, AllocatorT > &Image, const property_list &propList)
unsigned int getElemSize() const
Definition: accessor.cpp:87
AccessorBaseHost(const AccessorImplPtr &Impl)
Definition: accessor.hpp:519
DataT read(const CoordT &Coords) const
SampledImageAccessorBaseHost(const SampledImageAccessorImplPtr &Impl)
UnsampledImageAccessorBaseHost(const UnsampledImageAccessorImplPtr &Impl)
void write(const CoordT &Coords, const DataT &Color) const
DataT read(const CoordT &Coords) const noexcept
__SYCL2020_DEPRECATED("get_count() is deprecated, please use size() instead") size_t get_count() const
DataT read(const CoordT &Coords) const
void write(const CoordT &Coords, const DataT &Color) const
DataT read(const CoordT &Coords, const sampler &Smpl) const
__image_array_slice__(accessor< DataT, Dimensions, AccessMode, access::target::image_array, IsPlaceholder, ext::oneapi::accessor_property_list<>> BaseAcc, size_t Idx)
image_accessor(image< Dims, AllocatorT > &ImageRef, int ImageElementSize)
bool operator!=(const image_accessor &Rhs) const
__SYCL2020_DEPRECATED("get_count() is deprecated, please use size() instead") size_t get_count() const
friend class sycl::ext::intel::esimd::detail::AccessorPrivateProxy
void write(const CoordT &Coords, const DataT &Color) const
image_accessor(const AccessorImplPtr &Impl)
bool operator==(const image_accessor &Rhs) const
DataT read(const CoordT &Coords) const
DataT read(const CoordT &Coords, const sampler &Smpl) const
image_accessor(image< Dims, AllocatorT > &ImageRef, handler &CommandGroupHandlerRef, int ImageElementSize)
range< Dimensions > get_range() const
Definition: image.hpp:323
size_t size() const noexcept
Definition: image.hpp:335
size_t getElementSize() const
Definition: image.cpp:187
image_sampler getSampler() const noexcept
Definition: image.cpp:193
size_t getRowPitch() const
Definition: image.cpp:189
image_channel_order getChannelOrder() const
Definition: image.cpp:197
size_t getSlicePitch() const
Definition: image.cpp:191
image_channel_type getChannelType() const
Definition: image.cpp:201
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
Definition: device.hpp:64
bool has(aspect Aspect) const __SYCL_WARN_IMAGE_ASPECT(Aspect)
Indicates if the SYCL device has the given feature.
Definition: device.cpp:219
Command group handler class.
Definition: handler.hpp:461
bool operator!=(const host_sampled_image_accessor &Rhs) const
host_sampled_image_accessor(const host_sampled_image_accessor &Rhs)=default
DataT read(const CoordT &Coords) const
host_sampled_image_accessor & operator=(const host_sampled_image_accessor &Rhs)=default
host_sampled_image_accessor(host_sampled_image_accessor &&Rhs)=default
bool operator==(const host_sampled_image_accessor &Rhs) const
host_sampled_image_accessor(sampled_image< Dimensions, AllocatorT > &ImageRef, const property_list &PropList={}, const detail::code_location CodeLoc=detail::code_location::current())
host_sampled_image_accessor & operator=(host_sampled_image_accessor &&Rhs)=default
host_unsampled_image_accessor(unsampled_image< Dimensions, AllocatorT > &ImageRef, const property_list &PropList={}, const detail::code_location CodeLoc=detail::code_location::current())
void write(const CoordT &Coords, const DataT &Color) const
host_unsampled_image_accessor(const host_unsampled_image_accessor &Rhs)=default
host_unsampled_image_accessor(host_unsampled_image_accessor &&Rhs)=default
DataT read(const CoordT &Coords) const noexcept
bool operator==(const host_unsampled_image_accessor &Rhs) const
typename std::conditional< AccessMode==access_mode::read, const DataT, DataT >::type value_type
host_unsampled_image_accessor & operator=(host_unsampled_image_accessor &&Rhs)=default
host_unsampled_image_accessor & operator=(const host_unsampled_image_accessor &Rhs)=default
bool operator!=(const host_unsampled_image_accessor &Rhs) const
Defines a shared image data.
Definition: image.hpp:443
range< Dimensions > get_range() const
Definition: image.hpp:629
Objects of the property_list class are containers for the SYCL properties.
Defines the iteration domain of either a single work-group in a parallel dispatch,...
Definition: range.hpp:26
sampled_image_accessor(const sampled_image_accessor &Rhs)=default
bool operator==(const sampled_image_accessor &Rhs) const
sampled_image_accessor(sampled_image_accessor &&Rhs)=default
sampled_image_accessor & operator=(sampled_image_accessor &&Rhs)=default
sampled_image_accessor(sampled_image< Dimensions, AllocatorT > &ImageRef, handler &CommandGroupHandlerRef, const property_list &PropList={}, const detail::code_location CodeLoc=detail::code_location::current())
sampled_image_accessor & operator=(const sampled_image_accessor &Rhs)=default
DataT read(const CoordT &Coords) const noexcept
bool operator!=(const sampled_image_accessor &Rhs) const
DataT read(const CoordT &Coords) const noexcept
bool operator!=(const unsampled_image_accessor &Rhs) const
void write(const CoordT &Coords, const DataT &Color) const
unsampled_image_accessor & operator=(unsampled_image_accessor &&Rhs)=default
bool operator==(const unsampled_image_accessor &Rhs) const
unsampled_image_accessor & operator=(const unsampled_image_accessor &Rhs)=default
typename std::conditional< AccessMode==access_mode::read, const DataT, DataT >::type value_type
unsampled_image_accessor(const unsampled_image_accessor &Rhs)=default
unsampled_image_accessor(unsampled_image_accessor &&Rhs)=default
unsampled_image_accessor(unsampled_image< Dimensions, AllocatorT > &ImageRef, handler &CommandGroupHandlerRef, const property_list &PropList={}, const detail::code_location CodeLoc=detail::code_location::current())
class sycl::vec ///////////////////////// Provides a cross-patform vector class template that works e...
#define __SYCL_SPECIAL_CLASS
Definition: defines.hpp:29
#define __SYCL_EBO
Definition: common.hpp:250
class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor< DataT
Image accessors.
class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor accessor(buffer< DataT, Dimensions, AllocatorT >) -> accessor< DataT, Dimensions, access::mode::read_write, target::device, access::placeholder::true_t >
Buffer accessor.
void unsampledImageConstructorNotification(void *ImageObj, void *AccessorObj, const std::optional< image_target > &Target, access::mode Mode, const void *Type, uint32_t ElemSize, const code_location &CodeLoc)
void addHostUnsampledImageAccessorAndWait(UnsampledImageAccessorImplHost *Req)
void addHostAccessorAndWait(AccessorImplHost *Req)
device getDeviceFromHandler(handler &CommandGroupHandlerRef)
Definition: accessor.cpp:17
std::shared_ptr< UnsampledImageAccessorImplHost > UnsampledImageAccessorImplPtr
void imageWriteHostImpl(const CoordT &Coords, const WriteDataT &Color, id< 3 > ImgPitch, uint8_t ElementSize, image_channel_type ImgChannelType, image_channel_order ImgChannelOrder, void *BasePtr)
void addHostSampledImageAccessorAndWait(SampledImageAccessorImplHost *Req)
std::shared_ptr< SampledImageAccessorImplHost > SampledImageAccessorImplPtr
decltype(Obj::impl) getSyclObjImpl(const Obj &SyclObject)
Definition: impl_utils.hpp:30
T createSyclObjFromImpl(decltype(T::impl) ImplObj)
Definition: impl_utils.hpp:48
void sampledImageConstructorNotification(void *ImageObj, void *AccessorObj, const std::optional< image_target > &Target, const void *Type, uint32_t ElemSize, const code_location &CodeLoc)
void associateWithHandler(handler &, AccessorBaseHost *, access::target)
std::shared_ptr< AccessorImplHost > AccessorImplPtr
Definition: accessor.hpp:515
T & operator[](std::ptrdiff_t idx) const noexcept
access::mode access_mode
Definition: access.hpp:72
image_target
Definition: access.hpp:74
class __SYCL_EBO __SYCL_SPECIAL_CLASS Dimensions
constexpr mode_tag_t< access_mode::read_write > read_write
Definition: access.hpp:85
pointer get() const
Definition: multi_ptr.hpp:544
image_channel_order
Definition: image.hpp:56
class __SYCL_EBO __SYCL_SPECIAL_CLASS IsPlaceholder
class __SYCL_EBO __SYCL_SPECIAL_CLASS AccessMode
image_channel_type
Definition: image.hpp:74
std::error_code make_error_code(sycl::errc E) noexcept
Constructs an error code using e and sycl_category()
Definition: exception.cpp:93
Definition: access.hpp:18
_Abi const simd< _Tp, _Abi > & noexcept
Definition: simd.hpp:1324
static constexpr code_location current(const char *fileName=__CODELOC_FILE_NAME, const char *funcName=__CODELOC_FUNCTION, unsigned long lineNo=__CODELOC_LINE, unsigned long columnNo=__CODELOC_COLUMN) noexcept
Definition: common.hpp:68