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 template <int Dim, typename T> struct IsValidCoordDataT;
16 template <typename T> struct IsValidCoordDataT<1, T> {
17  constexpr static bool value = detail::is_contained<
19 };
20 template <typename T> struct IsValidCoordDataT<2, T> {
21  constexpr static bool value = detail::is_contained<
23  vec<opencl::cl_float, 2>>>::type::value;
24 };
25 template <typename T> struct IsValidCoordDataT<3, T> {
26  constexpr static bool value = detail::is_contained<
28  vec<opencl::cl_float, 4>>>::type::value;
29 };
30 
31 template <int Dim, typename T> struct IsValidUnsampledCoord2020DataT;
32 template <typename T> struct IsValidUnsampledCoord2020DataT<1, T> {
33  constexpr static bool value = std::is_same_v<T, int>;
34 };
35 template <typename T> struct IsValidUnsampledCoord2020DataT<2, T> {
36  constexpr static bool value = std::is_same_v<T, int2>;
37 };
38 template <typename T> struct IsValidUnsampledCoord2020DataT<3, T> {
39  constexpr static bool value = std::is_same_v<T, int4>;
40 };
41 
42 template <int Dim, typename T> struct IsValidSampledCoord2020DataT;
43 template <typename T> struct IsValidSampledCoord2020DataT<1, T> {
44  constexpr static bool value = std::is_same_v<T, float>;
45 };
46 template <typename T> struct IsValidSampledCoord2020DataT<2, T> {
47  constexpr static bool value = std::is_same_v<T, float2>;
48 };
49 template <typename T> struct IsValidSampledCoord2020DataT<3, T> {
50  constexpr static bool value = std::is_same_v<T, float4>;
51 };
52 
53 void __SYCL_EXPORT unsampledImageConstructorNotification(
54  void *ImageObj, void *AccessorObj,
55  const std::optional<image_target> &Target, access::mode Mode,
56  const void *Type, uint32_t ElemSize, const code_location &CodeLoc);
57 
58 void __SYCL_EXPORT sampledImageConstructorNotification(
59  void *ImageObj, void *AccessorObj,
60  const std::optional<image_target> &Target, const void *Type,
61  uint32_t ElemSize, const code_location &CodeLoc);
62 
66  std::shared_ptr<UnsampledImageAccessorImplHost>;
68  std::shared_ptr<SampledImageAccessorImplHost>;
69 
70 void __SYCL_EXPORT
72 void __SYCL_EXPORT
74 
75 class __SYCL_EXPORT UnsampledImageAccessorBaseHost {
76 protected:
78  : impl{Impl} {}
79 
80 public:
82  void *SYCLMemObject, int Dims, int ElemSize,
83  id<3> Pitch, image_channel_type ChannelType,
84  image_channel_order ChannelOrder,
85  const property_list &PropertyList = {});
86  const sycl::range<3> &getSize() const;
87  void *getMemoryObject() const;
88  detail::AccHostDataT &getAccData();
89  void *getPtr();
90  void *getPtr() const;
91  int getNumOfDims() const;
92  int getElementSize() const;
93  id<3> getPitch() const;
94  image_channel_type getChannelType() const;
95  image_channel_order getChannelOrder() const;
96  const property_list &getPropList() const;
97 
98 protected:
99  template <class Obj>
100  friend const decltype(Obj::impl) &
101  detail::getSyclObjImpl(const Obj &SyclObject);
102 
103  template <class T>
104  friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);
105 
107 
108  // The function references helper methods required by GDB pretty-printers
110 #ifndef NDEBUG
111  const auto *this_const = this;
112  (void)getSize();
113  (void)this_const->getSize();
114  (void)getPtr();
115  (void)this_const->getPtr();
116 #endif
117  }
118 
119 #ifndef __SYCL_DEVICE_ONLY__
120  // Reads a pixel of the underlying image at the specified coordinate. It is
121  // the responsibility of the caller to ensure that the coordinate type is
122  // valid.
123  template <typename DataT, typename CoordT>
124  DataT read(const CoordT &Coords) const noexcept {
128  return imageReadSamplerHostImpl<CoordT, DataT>(
129  Coords, Smpl, getSize(), getPitch(), getChannelType(),
130  getChannelOrder(), getPtr(), getElementSize());
131  }
132 
133  // Writes to a pixel of the underlying image at the specified coordinate. It
134  // is the responsibility of the caller to ensure that the coordinate type is
135  // valid.
136  template <typename DataT, typename CoordT>
137  void write(const CoordT &Coords, const DataT &Color) const {
138  imageWriteHostImpl(Coords, Color, getPitch(), getElementSize(),
139  getChannelType(), getChannelOrder(), getPtr());
140  }
141 #endif
142 };
143 
144 class __SYCL_EXPORT SampledImageAccessorBaseHost {
145 protected:
147  : impl{Impl} {}
148 
149 public:
150  SampledImageAccessorBaseHost(sycl::range<3> Size, void *SYCLMemObject,
151  int Dims, int ElemSize, id<3> Pitch,
152  image_channel_type ChannelType,
153  image_channel_order ChannelOrder,
154  image_sampler Sampler,
155  const property_list &PropertyList = {});
156  const sycl::range<3> &getSize() const;
157  void *getMemoryObject() const;
158  detail::AccHostDataT &getAccData();
159  void *getPtr();
160  void *getPtr() const;
161  int getNumOfDims() const;
162  int getElementSize() const;
163  id<3> getPitch() const;
164  image_channel_type getChannelType() const;
165  image_channel_order getChannelOrder() const;
166  image_sampler getSampler() const;
167  const property_list &getPropList() const;
168 
169 protected:
170  template <class Obj>
171  friend const decltype(Obj::impl) &
172  detail::getSyclObjImpl(const Obj &SyclObject);
173 
174  template <class T>
175  friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);
176 
178 
179  // The function references helper methods required by GDB pretty-printers
181 #ifndef NDEBUG
182  const auto *this_const = this;
183  (void)getSize();
184  (void)this_const->getSize();
185  (void)getPtr();
186  (void)this_const->getPtr();
187 #endif
188  }
189 
190 #ifndef __SYCL_DEVICE_ONLY__
191  // Reads a pixel of the underlying image at the specified coordinate. It is
192  // the responsibility of the caller to ensure that the coordinate type is
193  // valid.
194  template <typename DataT, typename CoordT>
195  DataT read(const CoordT &Coords) const {
196  return imageReadSamplerHostImpl<CoordT, DataT>(
197  Coords, getSampler(), getSize(), getPitch(), getChannelType(),
198  getChannelOrder(), getPtr(), getElementSize());
199  }
200 #endif
201 };
202 
203 template <typename DataT, int Dimensions, access::mode AccessMode,
205 class __image_array_slice__;
206 
207 // Image accessor
208 template <typename DataT, int Dimensions, access::mode AccessMode,
211 #ifndef __SYCL_DEVICE_ONLY__
212  : public detail::AccessorBaseHost {
213  size_t MImageCount;
214  image_channel_order MImgChannelOrder;
215  image_channel_type MImgChannelType;
216 #else
217 {
218 
219  using OCLImageTy = typename detail::opencl_image_type<Dimensions, AccessMode,
220  AccessTarget>::type;
221  OCLImageTy MImageObj;
222  char MPadding[sizeof(detail::AccessorBaseHost) +
223  sizeof(size_t /*MImageCount*/) + sizeof(image_channel_order) +
224  sizeof(image_channel_type) - sizeof(OCLImageTy)];
225 
226 protected:
227  void imageAccessorInit(OCLImageTy Image) { MImageObj = Image; }
228 
229 private:
230 #endif
231  template <typename T1, int T2, access::mode T3, access::placeholder T4>
232  friend class __image_array_slice__;
233 
234  constexpr static bool IsHostImageAcc =
235  (AccessTarget == access::target::host_image);
236 
237  constexpr static bool IsImageAcc = (AccessTarget == access::target::image);
238 
239  constexpr static bool IsImageArrayAcc =
240  (AccessTarget == access::target::image_array);
241 
242  constexpr static bool IsImageAccessWriteOnly =
245 
246  constexpr static bool IsImageAccessAnyWrite =
247  (IsImageAccessWriteOnly || AccessMode == access::mode::read_write);
248 
249  constexpr static bool IsImageAccessReadOnly =
251 
252  constexpr static bool IsImageAccessAnyRead =
253  (IsImageAccessReadOnly || AccessMode == access::mode::read_write);
254 
255  static_assert(std::is_same_v<DataT, vec<opencl::cl_int, 4>> ||
256  std::is_same_v<DataT, vec<opencl::cl_uint, 4>> ||
257  std::is_same_v<DataT, vec<opencl::cl_float, 4>> ||
258  std::is_same_v<DataT, vec<opencl::cl_half, 4>>,
259  "The data type of an image accessor must be only cl_int4, "
260  "cl_uint4, cl_float4 or cl_half4 from SYCL namespace");
261 
262  static_assert(IsImageAcc || IsHostImageAcc || IsImageArrayAcc,
263  "Expected image type");
264 
266  "Expected false as Placeholder value for image accessor.");
267 
268  static_assert(
269  ((IsImageAcc || IsImageArrayAcc) &&
270  (IsImageAccessWriteOnly || IsImageAccessReadOnly)) ||
271  (IsHostImageAcc && (IsImageAccessAnyWrite || IsImageAccessAnyRead)),
272  "Access modes can be only read/write/discard_write for image/image_array "
273  "target accessor, or they can be only "
274  "read/write/discard_write/read_write for host_image target accessor.");
275 
276  static_assert(Dimensions > 0 && Dimensions <= 3,
277  "Dimensions can be 1/2/3 for image accessor.");
278 
279 #ifdef __SYCL_DEVICE_ONLY__
280 
281  sycl::vec<int, Dimensions> getRangeInternal() const {
282  return __invoke_ImageQuerySize<sycl::vec<int, Dimensions>, OCLImageTy>(
283  MImageObj);
284  }
285 
286  size_t getElementSize() const {
287  int ChannelType = __invoke_ImageQueryFormat<int, OCLImageTy>(MImageObj);
288  int ChannelOrder = __invoke_ImageQueryOrder<int, OCLImageTy>(MImageObj);
289  int ElementSize = getSPIRVElementSize(ChannelType, ChannelOrder);
290  return ElementSize;
291  }
292 
293 #else
294 
295  sycl::vec<int, Dimensions> getRangeInternal() const {
296  // TODO: Implement for host.
297  throw sycl::exception(
299  "image::getRangeInternal() is not implemented for host");
300  return sycl::vec<int, Dimensions>{1};
301  }
302 
303 #endif
304 
305 #ifndef __SYCL_DEVICE_ONLY__
306 protected:
308 #endif // __SYCL_DEVICE_ONLY__
309 
310 private:
312 
313 #ifdef __SYCL_DEVICE_ONLY__
314  const OCLImageTy getNativeImageObj() const { return MImageObj; }
315 #endif // __SYCL_DEVICE_ONLY__
316 
317 public:
318  using value_type = DataT;
319  using reference = DataT &;
320  using const_reference = const DataT &;
321 
322  // image_accessor Constructors.
323 
324 #ifdef __SYCL_DEVICE_ONLY__
325  // Default constructor for objects later initialized with __init member.
326  image_accessor() {}
327 #endif
328 
329  // Available only when: accessTarget == access::target::host_image
330  // template <typename AllocatorT>
331  // accessor(image<dimensions, AllocatorT> &imageRef);
332  template <
333  typename AllocatorT, int Dims = Dimensions,
334  typename = std::enable_if_t<(Dims > 0 && Dims <= 3) && IsHostImageAcc>>
335  image_accessor(image<Dims, AllocatorT> &ImageRef, int ImageElementSize)
336 #ifdef __SYCL_DEVICE_ONLY__
337  {
338  (void)ImageRef;
339  (void)ImageElementSize;
340  // No implementation needed for device. The constructor is only called by
341  // host.
342  }
343 #else
344  : AccessorBaseHost({ImageRef.getRowPitch(), ImageRef.getSlicePitch(), 0},
345  detail::convertToArrayOfN<3, 1>(ImageRef.get_range()),
346  detail::convertToArrayOfN<3, 1>(ImageRef.get_range()),
347  AccessMode, detail::getSyclObjImpl(ImageRef).get(),
348  Dimensions, ImageElementSize, size_t(0)),
349  MImageCount(ImageRef.size()),
350  MImgChannelOrder(ImageRef.getChannelOrder()),
351  MImgChannelType(ImageRef.getChannelType()) {
353  }
354 #endif
355 
356  // Available only when: accessTarget == access::target::image
357  // template <typename AllocatorT>
358  // accessor(image<dimensions, AllocatorT> &imageRef,
359  // handler &commandGroupHandlerRef);
360  template <typename AllocatorT, int Dims = Dimensions,
361  typename = std::enable_if_t<(Dims > 0 && Dims <= 3) && IsImageAcc>>
363  handler &CommandGroupHandlerRef, int ImageElementSize)
364 #ifdef __SYCL_DEVICE_ONLY__
365  {
366  (void)ImageRef;
367  (void)CommandGroupHandlerRef;
368  (void)ImageElementSize;
369  // No implementation needed for device. The constructor is only called by
370  // host.
371  }
372 #else
373  : AccessorBaseHost({ImageRef.getRowPitch(), ImageRef.getSlicePitch(), 0},
374  detail::convertToArrayOfN<3, 1>(ImageRef.get_range()),
375  detail::convertToArrayOfN<3, 1>(ImageRef.get_range()),
376  AccessMode, detail::getSyclObjImpl(ImageRef).get(),
377  Dimensions, ImageElementSize, size_t(0)),
378  MImageCount(ImageRef.size()),
379  MImgChannelOrder(ImageRef.getChannelOrder()),
380  MImgChannelType(ImageRef.getChannelType()) {
381 
382  device Device = getDeviceFromHandler(CommandGroupHandlerRef);
383  if (!Device.has(aspect::ext_intel_legacy_image))
384  throw sycl::exception(
385  sycl::errc::feature_not_supported,
386  "SYCL 1.2.1 images are not supported by this device.");
387  }
388 #endif
389 
390  /* -- common interface members -- */
391 
392  // operator == and != need to be defined only for host application as per the
393  // SYCL spec 1.2.1
394 #ifndef __SYCL_DEVICE_ONLY__
395  bool operator==(const image_accessor &Rhs) const { return Rhs.impl == impl; }
396 #else
397  // The operator with __SYCL_DEVICE_ONLY__ need to be declared for compilation
398  // of host application with device compiler.
399  // Usage of this operator inside the kernel code will give a runtime failure.
400  bool operator==(const image_accessor &Rhs) const;
401 #endif
402 
403  bool operator!=(const image_accessor &Rhs) const { return !(Rhs == *this); }
404 
405  // get_count() method : Returns the number of elements of the SYCL image this
406  // SYCL accessor is accessing.
407  //
408  // get_range() method : Returns a range object which represents the number of
409  // elements of dataT per dimension that this accessor may access.
410  // The range object returned must equal to the range of the image this
411  // accessor is associated with.
412 
413 #ifdef __SYCL_DEVICE_ONLY__
414 
415  __SYCL2020_DEPRECATED("get_count() is deprecated, please use size() instead")
416  size_t get_count() const { return size(); }
417  size_t size() const noexcept { return get_range<Dimensions>().size(); }
418 
419  template <int Dims = Dimensions, typename = std::enable_if_t<Dims == 1>>
420  range<1> get_range() const {
421  int Range = getRangeInternal();
422  return range<1>(Range);
423  }
424  template <int Dims = Dimensions, typename = std::enable_if_t<Dims == 2>>
425  range<2> get_range() const {
426  int2 Range = getRangeInternal();
427  return range<2>(Range[0], Range[1]);
428  }
429  template <int Dims = Dimensions, typename = std::enable_if_t<Dims == 3>>
430  range<3> get_range() const {
431  int3 Range = getRangeInternal();
432  return range<3>(Range[0], Range[1], Range[2]);
433  }
434 
435 #else
436  __SYCL2020_DEPRECATED("get_count() is deprecated, please use size() instead")
437  size_t get_count() const { return size(); };
438  size_t size() const noexcept { return MImageCount; };
439 
440  template <int Dims = Dimensions, typename = std::enable_if_t<(Dims > 0)>>
442  return detail::convertToArrayOfN<Dims, 1>(getAccessRange());
443  }
444 
445 #endif
446 
447  // Available only when:
448  // (accessTarget == access::target::image && accessMode == access::mode::read)
449  // || (accessTarget == access::target::host_image && ( accessMode ==
450  // access::mode::read || accessMode == access::mode::read_write))
451  template <typename CoordT, int Dims = Dimensions,
452  typename = std::enable_if_t<
453  (Dims > 0) && (IsValidCoordDataT<Dims, CoordT>::value) &&
454  (detail::is_genint_v<CoordT>) &&
455  ((IsImageAcc && IsImageAccessReadOnly) ||
456  (IsHostImageAcc && IsImageAccessAnyRead))>>
457  DataT read(const CoordT &Coords) const {
458 #ifdef __SYCL_DEVICE_ONLY__
459  return __invoke__ImageRead<DataT, OCLImageTy, CoordT>(MImageObj, Coords);
460 #else
463  return read<CoordT, Dims>(Coords, Smpl);
464 #endif
465  }
466 
467  // Available only when:
468  // (accessTarget == access::target::image && accessMode == access::mode::read)
469  // || (accessTarget == access::target::host_image && ( accessMode ==
470  // access::mode::read || accessMode == access::mode::read_write))
471  template <typename CoordT, int Dims = Dimensions,
472  typename = std::enable_if_t<
473  (Dims > 0) && (IsValidCoordDataT<Dims, CoordT>::value) &&
474  ((IsImageAcc && IsImageAccessReadOnly) ||
475  (IsHostImageAcc && IsImageAccessAnyRead))>>
476  DataT read(const CoordT &Coords, const sampler &Smpl) const {
477 #ifdef __SYCL_DEVICE_ONLY__
478  return __invoke__ImageReadSampler<DataT, OCLImageTy, CoordT>(
479  MImageObj, Coords, Smpl.impl.m_Sampler);
480 #else
481  return imageReadSamplerHostImpl<CoordT, DataT>(
482  Coords, Smpl, getAccessRange() /*Image Range*/,
483  getOffset() /*Image Pitch*/, MImgChannelType, MImgChannelOrder,
484  AccessorBaseHost::getPtr() /*ptr to image*/,
486 #endif
487  }
488 
489  // Available only when:
490  // (accessTarget == access::target::image && (accessMode ==
491  // access::mode::write || accessMode == access::mode::discard_write)) ||
492  // (accessTarget == access::target::host_image && (accessMode ==
493  // access::mode::write || accessMode == access::mode::discard_write ||
494  // accessMode == access::mode::read_write))
495  template <
496  typename CoordT, int Dims = Dimensions,
497  typename = std::enable_if_t<(Dims > 0) && (detail::is_genint_v<CoordT>) &&
499  ((IsImageAcc && IsImageAccessWriteOnly) ||
500  (IsHostImageAcc && IsImageAccessAnyWrite))>>
501  void write(const CoordT &Coords, const DataT &Color) const {
502 #ifdef __SYCL_DEVICE_ONLY__
503  __invoke__ImageWrite<OCLImageTy, CoordT, DataT>(MImageObj, Coords, Color);
504 #else
505  imageWriteHostImpl(Coords, Color, getOffset() /*ImagePitch*/,
506  AccessorBaseHost::getElemSize(), MImgChannelType,
507  MImgChannelOrder,
508  AccessorBaseHost::getPtr() /*Ptr to Image*/);
509 #endif
510  }
511 };
512 
513 template <typename DataT, int Dimensions, access::mode AccessMode,
516 
517  static_assert(Dimensions < 3,
518  "Image slice cannot have more then 2 dimensions");
519 
520  constexpr static int AdjustedDims = (Dimensions == 2) ? 4 : Dimensions + 1;
521 
522  template <typename CoordT, typename CoordElemType = get_elem_type_t<CoordT>>
524  getAdjustedCoords(const CoordT &Coords) const {
525  CoordElemType LastCoord = 0;
526 
527  if (std::is_same<float, CoordElemType>::value) {
528  sycl::vec<int, Dimensions + 1> Size = MBaseAcc.getRangeInternal();
529  LastCoord =
530  MIdx / static_cast<float>(Size.template swizzle<Dimensions>());
531  } else {
532  LastCoord = MIdx;
533  }
534 
535  sycl::vec<CoordElemType, Dimensions> LeftoverCoords{LastCoord};
536  sycl::vec<CoordElemType, AdjustedDims> AdjustedCoords{Coords,
537  LeftoverCoords};
538  return AdjustedCoords;
539  }
540 
541 public:
545  BaseAcc,
546  size_t Idx)
547  : MBaseAcc(BaseAcc), MIdx(Idx) {}
548 
549  template <typename CoordT, int Dims = Dimensions,
550  typename = std::enable_if_t<
552  DataT read(const CoordT &Coords) const {
553  return MBaseAcc.read(getAdjustedCoords(Coords));
554  }
555 
556  template <typename CoordT, int Dims = Dimensions,
557  typename = std::enable_if_t<(Dims > 0) &&
559  DataT read(const CoordT &Coords, const sampler &Smpl) const {
560  return MBaseAcc.read(getAdjustedCoords(Coords), Smpl);
561  }
562 
563  template <typename CoordT, int Dims = Dimensions,
564  typename = std::enable_if_t<(Dims > 0) &&
566  void write(const CoordT &Coords, const DataT &Color) const {
567  return MBaseAcc.write(getAdjustedCoords(Coords), Color);
568  }
569 
570 #ifdef __SYCL_DEVICE_ONLY__
571  __SYCL2020_DEPRECATED("get_count() is deprecated, please use size() instead")
572  size_t get_count() const { return size(); }
573  size_t size() const noexcept { return get_range<Dimensions>().size(); }
574 
575  template <int Dims = Dimensions, typename = std::enable_if_t<Dims == 1>>
576  range<1> get_range() const {
577  int2 Count = MBaseAcc.getRangeInternal();
578  return range<1>(Count.x());
579  }
580  template <int Dims = Dimensions, typename = std::enable_if_t<Dims == 2>>
581  range<2> get_range() const {
582  int3 Count = MBaseAcc.getRangeInternal();
583  return range<2>(Count.x(), Count.y());
584  }
585 
586 #else
587 
588  __SYCL2020_DEPRECATED("get_count() is deprecated, please use size() instead")
589  size_t get_count() const { return size(); }
590  size_t size() const noexcept {
591  return MBaseAcc.MImageCount / MBaseAcc.getAccessRange()[Dimensions];
592  }
593 
594  template <int Dims = Dimensions,
595  typename = std::enable_if_t<(Dims == 1 || Dims == 2)>>
597  return detail::convertToArrayOfN<Dims, 1>(MBaseAcc.getAccessRange());
598  }
599 
600 #endif
601 
602 private:
603  size_t MIdx;
606  MBaseAcc;
607 };
608 
609 } // namespace detail
615 template <typename DataT, int Dimensions, access::mode AccessMode,
618  DataT, Dimensions, AccessMode, access::target::image, IsPlaceholder>
619  : public detail::image_accessor<DataT, Dimensions, AccessMode,
620  access::target::image, IsPlaceholder>,
621  public detail::OwnerLessBase<
622  accessor<DataT, Dimensions, AccessMode, access::target::image,
623  IsPlaceholder>> {
624 private:
625  accessor(const detail::AccessorImplPtr &Impl)
626  : detail::image_accessor<DataT, Dimensions, AccessMode,
628 
629 public:
630  template <typename AllocatorT>
632  handler &CommandGroupHandler)
633  : detail::image_accessor<DataT, Dimensions, AccessMode,
635  Image, CommandGroupHandler, Image.getElementSize()) {
636 #ifndef __SYCL_DEVICE_ONLY__
637  detail::associateWithHandler(CommandGroupHandler, this,
639 #endif
640  }
641 
642  template <typename AllocatorT>
644  handler &CommandGroupHandler, const property_list &propList)
645  : detail::image_accessor<DataT, Dimensions, AccessMode,
647  Image, CommandGroupHandler, Image.getElementSize()) {
648  (void)propList;
649 #ifndef __SYCL_DEVICE_ONLY__
650  detail::associateWithHandler(CommandGroupHandler, this,
652 #endif
653  }
654 #ifdef __SYCL_DEVICE_ONLY__
655 private:
656  using OCLImageTy =
657  typename detail::opencl_image_type<Dimensions, AccessMode,
658  access::target::image>::type;
659 
660  // Front End requires this method to be defined in the accessor class.
661  // It does not call the base class's init method.
662  void __init(OCLImageTy Image) { this->imageAccessorInit(Image); }
663 
664  // __init variant used by the device compiler for ESIMD kernels.
665  void __init_esimd(OCLImageTy Image) { this->imageAccessorInit(Image); }
666 
667 public:
668  // Default constructor for objects later initialized with __init member.
669  accessor() = default;
670 #endif
671 };
672 
680 template <typename DataT, int Dimensions, access::mode AccessMode,
683  access::target::host_image, IsPlaceholder>
684  : public detail::image_accessor<DataT, Dimensions, AccessMode,
685  access::target::host_image, IsPlaceholder>,
686  public detail::OwnerLessBase<
687  accessor<DataT, Dimensions, AccessMode, access::target::host_image,
688  IsPlaceholder>> {
689 public:
690  template <typename AllocatorT>
692  : detail::image_accessor<DataT, Dimensions, AccessMode,
693  access::target::host_image, IsPlaceholder>(
694  Image, Image.getElementSize()) {}
695 
696  template <typename AllocatorT>
698  const property_list &propList)
699  : detail::image_accessor<DataT, Dimensions, AccessMode,
700  access::target::host_image, IsPlaceholder>(
701  Image, Image.getElementSize()) {
702  (void)propList;
703  }
704 };
705 
714 template <typename DataT, int Dimensions, access::mode AccessMode,
717  DataT, Dimensions, AccessMode, access::target::image_array, IsPlaceholder>
718  : public detail::image_accessor<DataT, Dimensions + 1, AccessMode,
719  access::target::image, IsPlaceholder>,
720  public detail::OwnerLessBase<
721  accessor<DataT, Dimensions, AccessMode, access::target::image_array,
722  IsPlaceholder>> {
723 #ifdef __SYCL_DEVICE_ONLY__
724 private:
725  using OCLImageTy =
726  typename detail::opencl_image_type<Dimensions + 1, AccessMode,
727  access::target::image>::type;
728 
729  // Front End requires this method to be defined in the accessor class.
730  // It does not call the base class's init method.
731  void __init(OCLImageTy Image) { this->imageAccessorInit(Image); }
732 
733  // __init variant used by the device compiler for ESIMD kernels.
734  void __init_esimd(OCLImageTy Image) { this->imageAccessorInit(Image); }
735 
736 public:
737  // Default constructor for objects later initialized with __init member.
738  accessor() = default;
739 #endif
740 public:
741  template <typename AllocatorT>
743  handler &CommandGroupHandler)
744  : detail::image_accessor<DataT, Dimensions + 1, AccessMode,
745  access::target::image, IsPlaceholder>(
746  Image, CommandGroupHandler, Image.getElementSize()) {
747 #ifndef __SYCL_DEVICE_ONLY__
748  detail::associateWithHandler(CommandGroupHandler, this,
750 #endif
751  }
752 
753  template <typename AllocatorT>
755  handler &CommandGroupHandler, const property_list &propList)
756  : detail::image_accessor<DataT, Dimensions + 1, AccessMode,
757  access::target::image, IsPlaceholder>(
758  Image, CommandGroupHandler, Image.getElementSize()) {
759  (void)propList;
760 #ifndef __SYCL_DEVICE_ONLY__
761  detail::associateWithHandler(CommandGroupHandler, this,
763 #endif
764  }
765 
766  detail::__image_array_slice__<DataT, Dimensions, AccessMode, IsPlaceholder>
767  operator[](size_t Index) const {
768  return detail::__image_array_slice__<DataT, Dimensions, AccessMode,
769  IsPlaceholder>(*this, Index);
770  }
771 };
772 
773 // SYCL 2020 image accessors
774 
775 template <typename DataT, int Dimensions, access_mode AccessMode,
776  image_target AccessTarget = image_target::device>
778 #ifndef __SYCL_DEVICE_ONLY__
780 #endif // __SYCL_DEVICE_ONLY__
781  public detail::OwnerLessBase<
782  unsampled_image_accessor<DataT, Dimensions, AccessMode, AccessTarget>> {
783  static_assert(std::is_same_v<DataT, int4> || std::is_same_v<DataT, uint4> ||
784  std::is_same_v<DataT, float4> ||
785  std::is_same_v<DataT, half4>,
786  "The data type of an image accessor must be only int4, "
787  "uint4, float4 or half4 from SYCL namespace");
788  static_assert(AccessMode == access_mode::read ||
790  "Access mode must be either read or write.");
791 
792 #ifdef __SYCL_DEVICE_ONLY__
793  char MPadding[sizeof(detail::UnsampledImageAccessorBaseHost)];
794 #else
796 #endif // __SYCL_DEVICE_ONLY__
797 
798 public:
799  using value_type = typename std::conditional<AccessMode == access_mode::read,
800  const DataT, DataT>::type;
802  using const_reference = const DataT &;
803 
804  template <typename AllocatorT>
807  handler &CommandGroupHandlerRef, const property_list &PropList = {},
809 #ifdef __SYCL_DEVICE_ONLY__
810  {
811  (void)ImageRef;
812  (void)CommandGroupHandlerRef;
813  (void)PropList;
814  (void)CodeLoc;
815  }
816 #else
817  : host_base_class(detail::convertToArrayOfN<3, 1>(ImageRef.get_range()),
818  AccessMode, detail::getSyclObjImpl(ImageRef).get(),
819  Dimensions, ImageRef.getElementSize(),
820  {ImageRef.getRowPitch(), ImageRef.getSlicePitch(), 0},
821  ImageRef.getChannelType(), ImageRef.getChannelOrder(),
822  PropList) {
823  device Device = detail::getDeviceFromHandler(CommandGroupHandlerRef);
824  // Avoid aspect::image warning.
825  aspect ImageAspect = aspect::image;
826  if (AccessTarget == image_target::device && !Device.has(ImageAspect))
827  throw sycl::exception(
828  sycl::make_error_code(sycl::errc::feature_not_supported),
829  "Device associated with command group handler does not have "
830  "aspect::image.");
831 
833  detail::getSyclObjImpl(ImageRef).get(), this->impl.get(), AccessTarget,
834  AccessMode, (const void *)typeid(DataT).name(), sizeof(DataT), CodeLoc);
835  detail::associateWithHandler(CommandGroupHandlerRef, this, AccessTarget);
836  GDBMethodsAnchor();
837  }
838 #endif // __SYCL_DEVICE_ONLY__
839 
840  /* -- common interface members -- */
841 
843 
845 
847  operator=(const unsampled_image_accessor &Rhs) = default;
848 
850 
852 
853 #ifdef __SYCL_DEVICE_ONLY__
854  bool operator==(const unsampled_image_accessor &Rhs) const;
855 #else
856  bool operator==(const unsampled_image_accessor &Rhs) const {
857  return Rhs.impl == impl;
858  }
859 #endif // __SYCL_DEVICE_ONLY__
860 
861  bool operator!=(const unsampled_image_accessor &Rhs) const {
862  return !(Rhs == *this);
863  }
864 
865  /* -- property interface members -- */
866  template <typename Property> bool has_property() const noexcept {
867 #ifndef __SYCL_DEVICE_ONLY__
868  return getPropList().template has_property<Property>();
869 #else
870  return false;
871 #endif
872  }
873  template <typename Property> Property get_property() const {
874 #ifndef __SYCL_DEVICE_ONLY__
875  return getPropList().template get_property<Property>();
876 #else
877  return Property();
878 #endif
879  }
880 
881  size_t size() const noexcept {
882 #ifdef __SYCL_DEVICE_ONLY__
883  // Currently not reachable on device.
884  return 0;
885 #else
886  return host_base_class::getSize().size();
887 #endif // __SYCL_DEVICE_ONLY__
888  }
889 
890  /* Available only when: AccessMode == access_mode::read
891  if Dimensions == 1, CoordT = int
892  if Dimensions == 2, CoordT = int2
893  if Dimensions == 3, CoordT = int4 */
894  template <typename CoordT,
895  typename = std::enable_if_t<AccessMode == access_mode::read &&
897  Dimensions, CoordT>::value>>
898  DataT read(const CoordT &Coords) const noexcept {
899 #ifdef __SYCL_DEVICE_ONLY__
900  // Currently not reachable on device.
901  std::ignore = Coords;
902  return {0, 0, 0, 0};
903 #else
904  return host_base_class::read<DataT>(Coords);
905 #endif // __SYCL_DEVICE_ONLY__
906  }
907 
908  /* Available only when: AccessMode == access_mode::write
909  if Dimensions == 1, CoordT = int
910  if Dimensions == 2, CoordT = int2
911  if Dimensions == 3, CoordT = int4 */
912  template <typename CoordT,
913  typename = std::enable_if_t<AccessMode == access_mode::write &&
915  Dimensions, CoordT>::value>>
916  void write(const CoordT &Coords, const DataT &Color) const {
917 #ifdef __SYCL_DEVICE_ONLY__
918  // Currently not reachable on device.
919  std::ignore = Coords;
920  std::ignore = Color;
921 #else
922  host_base_class::write<DataT>(Coords, Color);
923 #endif // __SYCL_DEVICE_ONLY__
924  }
925 
926 private:
928 #ifndef __SYCL_DEVICE_ONLY__
929  : host_base_class{Impl}
930 #endif // __SYCL_DEVICE_ONLY__
931  {
932  std::ignore = Impl;
933  }
934 
935  template <class Obj>
936  friend const decltype(Obj::impl) &
937  detail::getSyclObjImpl(const Obj &SyclObject);
938 
939  template <class T>
940  friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);
941 };
942 
943 template <typename DataT, int Dimensions = 1,
945  (std::is_const_v<DataT> ? access_mode::read
949  public detail::OwnerLessBase<
951  static_assert(std::is_same_v<DataT, int4> || std::is_same_v<DataT, uint4> ||
952  std::is_same_v<DataT, float4> ||
953  std::is_same_v<DataT, half4>,
954  "The data type of an image accessor must be only int4, "
955  "uint4, float4 or half4 from SYCL namespace");
956 
958 
959 public:
960  using value_type = typename std::conditional<AccessMode == access_mode::read,
961  const DataT, DataT>::type;
963  using const_reference = const DataT &;
964 
965  template <typename AllocatorT>
968  const property_list &PropList = {},
970  : base_class(detail::convertToArrayOfN<3, 1>(ImageRef.get_range()),
971  AccessMode, detail::getSyclObjImpl(ImageRef).get(),
972  Dimensions, ImageRef.getElementSize(),
973  {ImageRef.getRowPitch(), ImageRef.getSlicePitch(), 0},
974  ImageRef.getChannelType(), ImageRef.getChannelOrder(),
975  PropList) {
976  addHostUnsampledImageAccessorAndWait(base_class::impl.get());
977 
979  detail::getSyclObjImpl(ImageRef).get(), this->impl.get(), std::nullopt,
980  AccessMode, (const void *)typeid(DataT).name(), sizeof(DataT), CodeLoc);
981  }
982 
983  /* -- common interface members -- */
984 
986  default;
987 
989 
992 
995 
997 
998  bool operator==(const host_unsampled_image_accessor &Rhs) const {
999  return Rhs.impl == impl;
1000  }
1002  return !(Rhs == *this);
1003  }
1004 
1005  /* -- property interface members -- */
1006  template <typename Property> bool has_property() const noexcept {
1007 #ifndef __SYCL_DEVICE_ONLY__
1008  return getPropList().template has_property<Property>();
1009 #else
1010  return false;
1011 #endif
1012  }
1013  template <typename Property> Property get_property() const {
1014 #ifndef __SYCL_DEVICE_ONLY__
1015  return getPropList().template get_property<Property>();
1016 #else
1017  return Property();
1018 #endif
1019  }
1020 
1021  size_t size() const noexcept { return base_class::getSize().size(); }
1022 
1023  /* Available only when: (AccessMode == access_mode::read ||
1024  AccessMode == access_mode::read_write)
1025  if Dimensions == 1, CoordT = int
1026  if Dimensions == 2, CoordT = int2
1027  if Dimensions == 3, CoordT = int4 */
1028  template <
1029  typename CoordT,
1030  typename = std::enable_if_t<
1034  DataT read(const CoordT &Coords) const noexcept
1035 #ifdef __SYCL_DEVICE_ONLY__
1036  ;
1037 #else
1038  {
1039  // Host implementation is only available in host code. Device is not allowed
1040  // to use host_unsampled_image_accessor.
1041  return base_class::read<DataT>(Coords);
1042  }
1043 #endif
1044 
1045  /* Available only when: (AccessMode == access_mode::write ||
1046  AccessMode == access_mode::read_write)
1047  if Dimensions == 1, CoordT = int
1048  if Dimensions == 2, CoordT = int2
1049  if Dimensions == 3, CoordT = int4 */
1050  template <
1051  typename CoordT,
1052  typename = std::enable_if_t<
1056  void write(const CoordT &Coords, const DataT &Color) const
1057 #ifdef __SYCL_DEVICE_ONLY__
1058  ;
1059 #else
1060  {
1061  // Host implementation is only available in host code. Device is not allowed
1062  // to use host_unsampled_image_accessor.
1063  base_class::write<DataT>(Coords, Color);
1064  }
1065 #endif
1066 
1067 private:
1070  : base_class{Impl} {}
1071 
1072  template <class Obj>
1073  friend const decltype(Obj::impl) &
1074  detail::getSyclObjImpl(const Obj &SyclObject);
1075 
1076  template <class T>
1077  friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);
1078 };
1079 
1080 template <typename DataT, int Dimensions,
1081  image_target AccessTarget = image_target::device>
1083 #ifndef __SYCL_DEVICE_ONLY__
1085 #endif // __SYCL_DEVICE_ONLY__
1086  public detail::OwnerLessBase<
1087  sampled_image_accessor<DataT, Dimensions, AccessTarget>> {
1088  static_assert(std::is_same_v<DataT, int4> || std::is_same_v<DataT, uint4> ||
1089  std::is_same_v<DataT, float4> ||
1090  std::is_same_v<DataT, half4>,
1091  "The data type of an image accessor must be only int4, "
1092  "uint4, float4 or half4 from SYCL namespace");
1093 
1094 #ifdef __SYCL_DEVICE_ONLY__
1095  char MPadding[sizeof(detail::SampledImageAccessorBaseHost)];
1096 #else
1098 #endif // __SYCL_DEVICE_ONLY__
1099 
1100 public:
1101  using value_type = const DataT;
1102  using reference = const DataT &;
1103  using const_reference = const DataT &;
1104 
1105  template <typename AllocatorT>
1108  handler &CommandGroupHandlerRef, const property_list &PropList = {},
1110 #ifdef __SYCL_DEVICE_ONLY__
1111  {
1112  (void)ImageRef;
1113  (void)CommandGroupHandlerRef;
1114  (void)PropList;
1115  (void)CodeLoc;
1116  }
1117 #else
1118  : host_base_class(detail::convertToArrayOfN<3, 1>(ImageRef.get_range()),
1119  detail::getSyclObjImpl(ImageRef).get(), Dimensions,
1120  ImageRef.getElementSize(),
1121  {ImageRef.getRowPitch(), ImageRef.getSlicePitch(), 0},
1122  ImageRef.getChannelType(), ImageRef.getChannelOrder(),
1123  ImageRef.getSampler(), PropList) {
1124  device Device = detail::getDeviceFromHandler(CommandGroupHandlerRef);
1125  // Avoid aspect::image warning.
1126  aspect ImageAspect = aspect::image;
1127  if (AccessTarget == image_target::device && !Device.has(ImageAspect))
1128  throw sycl::exception(
1129  sycl::make_error_code(sycl::errc::feature_not_supported),
1130  "Device associated with command group handler does not have "
1131  "aspect::image.");
1132 
1134  detail::getSyclObjImpl(ImageRef).get(), this->impl.get(), AccessTarget,
1135  (const void *)typeid(DataT).name(), sizeof(DataT), CodeLoc);
1136  detail::associateWithHandler(CommandGroupHandlerRef, this, AccessTarget);
1137  GDBMethodsAnchor();
1138  }
1139 #endif // __SYCL_DEVICE_ONLY__
1140 
1141  /* -- common interface members -- */
1142 
1144 
1146 
1148  operator=(const sampled_image_accessor &Rhs) = default;
1149 
1151 
1153 
1154 #ifdef __SYCL_DEVICE_ONLY__
1155  bool operator==(const sampled_image_accessor &Rhs) const;
1156 #else
1157  bool operator==(const sampled_image_accessor &Rhs) const {
1158  return Rhs.impl == impl;
1159  }
1160 #endif // __SYCL_DEVICE_ONLY__
1161 
1162  bool operator!=(const sampled_image_accessor &Rhs) const {
1163  return !(Rhs == *this);
1164  }
1165 
1166  /* -- property interface members -- */
1167  template <typename Property> bool has_property() const noexcept {
1168 #ifndef __SYCL_DEVICE_ONLY__
1169  return getPropList().template has_property<Property>();
1170 #else
1171  return false;
1172 #endif
1173  }
1174  template <typename Property> Property get_property() const {
1175 #ifndef __SYCL_DEVICE_ONLY__
1176  return getPropList().template get_property<Property>();
1177 #else
1178  return Property();
1179 #endif
1180  }
1181 
1182  size_t size() const noexcept {
1183 #ifdef __SYCL_DEVICE_ONLY__
1184  // Currently not reachable on device.
1185  return 0;
1186 #else
1187  return host_base_class::getSize().size();
1188 #endif // __SYCL_DEVICE_ONLY__
1189  }
1190 
1191  /* if Dimensions == 1, CoordT = float
1192  if Dimensions == 2, CoordT = float2
1193  if Dimensions == 3, CoordT = float4 */
1194  template <typename CoordT,
1195  typename = std::enable_if_t<detail::IsValidSampledCoord2020DataT<
1196  Dimensions, CoordT>::value>>
1197  DataT read(const CoordT &Coords) const noexcept {
1198 #ifdef __SYCL_DEVICE_ONLY__
1199  // Currently not reachable on device.
1200  std::ignore = Coords;
1201  return {0, 0, 0, 0};
1202 #else
1203  return host_base_class::read<DataT>(Coords);
1204 #endif // __SYCL_DEVICE_ONLY__
1205  }
1206 
1207 private:
1209 #ifndef __SYCL_DEVICE_ONLY__
1210  : host_base_class{Impl}
1211 #endif // __SYCL_DEVICE_ONLY__
1212  {
1213  std::ignore = Impl;
1214  }
1215 
1216  template <class Obj>
1217  friend const decltype(Obj::impl) &
1218  detail::getSyclObjImpl(const Obj &SyclObject);
1219 
1220  template <class T>
1221  friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);
1222 };
1223 
1224 template <typename DataT, int Dimensions>
1227  public detail::OwnerLessBase<
1228  host_sampled_image_accessor<DataT, Dimensions>> {
1229  static_assert(std::is_same_v<DataT, int4> || std::is_same_v<DataT, uint4> ||
1230  std::is_same_v<DataT, float4> ||
1231  std::is_same_v<DataT, half4>,
1232  "The data type of an image accessor must be only int4, "
1233  "uint4, float4 or half4 from SYCL namespace");
1234 
1236 
1237 public:
1238  using value_type = const DataT;
1239  using reference = const DataT &;
1240  using const_reference = const DataT &;
1241 
1242  template <typename AllocatorT>
1245  const property_list &PropList = {},
1247  : base_class(detail::convertToArrayOfN<3, 1>(ImageRef.get_range()),
1248  detail::getSyclObjImpl(ImageRef).get(), Dimensions,
1249  ImageRef.getElementSize(),
1250  {ImageRef.getRowPitch(), ImageRef.getSlicePitch(), 0},
1251  ImageRef.getChannelType(), ImageRef.getChannelOrder(),
1252  ImageRef.getSampler(), PropList) {
1253  addHostSampledImageAccessorAndWait(base_class::impl.get());
1254 
1256  detail::getSyclObjImpl(ImageRef).get(), this->impl.get(), std::nullopt,
1257  (const void *)typeid(DataT).name(), sizeof(DataT), CodeLoc);
1258  }
1259 
1260  /* -- common interface members -- */
1261 
1263 
1265 
1268 
1271 
1273 
1274  bool operator==(const host_sampled_image_accessor &Rhs) const {
1275  return Rhs.impl == impl;
1276  }
1277  bool operator!=(const host_sampled_image_accessor &Rhs) const {
1278  return !(Rhs == *this);
1279  }
1280 
1281  /* -- property interface members -- */
1282  template <typename Property> bool has_property() const noexcept {
1283 #ifndef __SYCL_DEVICE_ONLY__
1284  return getPropList().template has_property<Property>();
1285 #else
1286  return false;
1287 #endif
1288  }
1289  template <typename Property> Property get_property() const {
1290 #ifndef __SYCL_DEVICE_ONLY__
1291  return getPropList().template get_property<Property>();
1292 #else
1293  return Property();
1294 #endif
1295  }
1296 
1297  size_t size() const noexcept { return base_class::getSize().size(); }
1298 
1299  /* if Dimensions == 1, CoordT = float
1300  if Dimensions == 2, CoordT = float2
1301  if Dimensions == 3, CoordT = float4 */
1302  template <typename CoordT,
1303  typename = std::enable_if_t<detail::IsValidSampledCoord2020DataT<
1304  Dimensions, CoordT>::value>>
1305  DataT read(const CoordT &Coords) const
1306 #ifdef __SYCL_DEVICE_ONLY__
1307  ;
1308 #else
1309  {
1310  // Host implementation is only available in host code. Device is not allowed
1311  // to use host_sampled_image_accessor.
1312  return base_class::read<DataT>(Coords);
1313  }
1314 #endif
1315 
1316 private:
1318  : base_class{Impl} {}
1319 
1320  template <class Obj>
1321  friend const decltype(Obj::impl) &
1322  detail::getSyclObjImpl(const Obj &SyclObject);
1323 
1324  template <class T>
1325  friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);
1326 };
1327 
1328 } // namespace _V1
1329 } // namespace sycl
1330 
1331 namespace std {
1332 template <typename DataT, int Dimensions, sycl::access_mode AccessMode,
1333  sycl::image_target AccessTarget>
1334 struct hash<sycl::unsampled_image_accessor<DataT, Dimensions, AccessMode,
1335  AccessTarget>> {
1337  AccessTarget>;
1338 
1339  size_t operator()(const AccType &A) const {
1340 #ifdef __SYCL_DEVICE_ONLY__
1341  // Hash is not supported on DEVICE. Just return 0 here.
1342  (void)A;
1343  return 0;
1344 #else
1345  auto AccImplPtr = sycl::detail::getSyclObjImpl(A);
1346  return hash<decltype(AccImplPtr)>()(AccImplPtr);
1347 #endif
1348  }
1349 };
1350 
1351 template <typename DataT, int Dimensions, sycl::access_mode AccessMode>
1352 struct hash<
1353  sycl::host_unsampled_image_accessor<DataT, Dimensions, AccessMode>> {
1354  using AccType =
1356 
1357  size_t operator()(const AccType &A) const {
1358  auto AccImplPtr = sycl::detail::getSyclObjImpl(A);
1359  return hash<decltype(AccImplPtr)>()(AccImplPtr);
1360  }
1361 };
1362 
1363 template <typename DataT, int Dimensions, sycl::image_target AccessTarget>
1364 struct hash<sycl::sampled_image_accessor<DataT, Dimensions, AccessTarget>> {
1366 
1367  size_t operator()(const AccType &A) const {
1368 #ifdef __SYCL_DEVICE_ONLY__
1369  // Hash is not supported on DEVICE. Just return 0 here.
1370  (void)A;
1371  return 0;
1372 #else
1373  auto AccImplPtr = sycl::detail::getSyclObjImpl(A);
1374  return hash<decltype(AccImplPtr)>()(AccImplPtr);
1375 #endif
1376  }
1377 };
1378 
1379 template <typename DataT, int Dimensions>
1380 struct hash<sycl::host_sampled_image_accessor<DataT, Dimensions>> {
1382 
1383  size_t operator()(const AccType &A) const {
1384  auto AccImplPtr = sycl::detail::getSyclObjImpl(A);
1385  return hash<decltype(AccImplPtr)>()(AccImplPtr);
1386  }
1387 };
1388 
1389 } // 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:61
AccessorBaseHost(const AccessorImplPtr &Impl)
Definition: accessor.hpp:518
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:329
size_t size() const noexcept
Definition: image.hpp:341
size_t getElementSize() const
Definition: image.cpp:169
image_sampler getSampler() const noexcept
Definition: image.cpp:175
size_t getRowPitch() const
Definition: image.cpp:171
image_channel_order getChannelOrder() const
Definition: image.cpp:179
size_t getSlicePitch() const
Definition: image.cpp:173
image_channel_type getChannelType() const
Definition: image.cpp:183
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:207
Command group handler class.
Definition: handler.hpp:467
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:449
range< Dimensions > get_range() const
Definition: image.hpp:635
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())
#define __SYCL_SPECIAL_CLASS
Definition: defines.hpp:29
#define __SYCL_EBO
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.
decltype(Obj::impl) const & getSyclObjImpl(const Obj &SyclObject)
Definition: impl_utils.hpp:31
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)
boost::mp11::mp_set_contains< TypeList, std::remove_cv_t< T > > is_contained
Definition: type_list.hpp:32
std::shared_ptr< SampledImageAccessorImplHost > SampledImageAccessorImplPtr
boost::mp11::mp_list< T... > type_list
Definition: type_list.hpp:22
T createSyclObjFromImpl(decltype(T::impl) ImplObj)
Definition: impl_utils.hpp:40
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:514
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:65
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