DPC++ Runtime
Runtime libraries for oneAPI DPC++
image.hpp
Go to the documentation of this file.
1 //==------------ image.hpp -------------------------------------------------==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #pragma once
10 
11 #include <sycl/access/access.hpp> // for placeholder
12 #include <sycl/aliases.hpp> // for cl_float, cl_half
13 #include <sycl/backend_types.hpp> // for backend, backe...
14 #include <sycl/buffer.hpp> // for range
15 #include <sycl/context.hpp> // for context
16 #include <sycl/detail/aligned_allocator.hpp> // for aligned_allocator
17 #include <sycl/detail/backend_traits.hpp> // for InteropFeature...
18 #include <sycl/detail/common.hpp> // for convertToArrayOfN
19 #include <sycl/detail/defines_elementary.hpp> // for __SYCL2020_DEP...
20 #include <sycl/detail/export.hpp> // for __SYCL_EXPORT
21 #include <sycl/detail/impl_utils.hpp> // for getSyclObjImpl
22 #include <sycl/detail/owner_less_base.hpp> // for OwnerLessBase
23 #include <sycl/detail/pi.h> // for pi_native_handle
24 #include <sycl/detail/stl_type_traits.hpp> // for iterator_value...
25 #include <sycl/detail/sycl_mem_obj_allocator.hpp> // for SYCLMemObjAllo...
26 #include <sycl/detail/type_list.hpp> // for is_contained
27 #include <sycl/event.hpp> // for event
28 #include <sycl/exception.hpp> // for make_error_code
29 #include <sycl/ext/oneapi/accessor_property_list.hpp> // for accessor_prope...
30 #include <sycl/property_list.hpp> // for property_list
31 #include <sycl/range.hpp> // for range, rangeTo...
32 #include <sycl/sampler.hpp> // for image_sampler
33 #include <sycl/types.hpp> // for vec
34 
35 #include <cstddef> // for size_t, nullptr_t
36 #include <functional> // for function
37 #include <memory> // for shared_ptr
38 #include <stdint.h> // for uint8_t, uint32_t
39 #include <type_traits> // for enable_if_t
40 #include <variant> // for hash
41 
42 namespace sycl {
43 inline namespace _V1 {
44 
45 // forward declarations
46 class handler;
47 
48 template <int D, typename A> class image;
49 
50 // 'friend'
51 template <backend Backend, int D, typename A>
52 std::enable_if_t<Backend == backend::ext_oneapi_level_zero, image<D, A>>
53 make_image(const backend_input_t<Backend, image<D, A>> &BackendObject,
54  const context &TargetContext, event AvailableEvent = {});
55 
56 enum class image_channel_order : unsigned int {
57  a = 0,
58  r = 1,
59  rx = 2,
60  rg = 3,
61  rgx = 4,
62  ra = 5,
63  rgb = 6,
64  rgbx = 7,
65  rgba = 8,
66  argb = 9,
67  bgra = 10,
68  intensity = 11,
69  luminance = 12,
70  abgr = 13,
71  ext_oneapi_srgba = 14 // OpenCL 2.0
72 };
73 
74 enum class image_channel_type : unsigned int {
75  snorm_int8 = 0,
76  snorm_int16 = 1,
77  unorm_int8 = 2,
78  unorm_int16 = 3,
79  unorm_short_565 = 4,
80  unorm_short_555 = 5,
81  unorm_int_101010 = 6,
82  signed_int8 = 7,
83  signed_int16 = 8,
84  signed_int32 = 9,
85  unsigned_int8 = 10,
86  unsigned_int16 = 11,
87  unsigned_int32 = 12,
88  fp16 = 13,
89  fp32 = 14
90 };
91 
92 // SYCL 2020 image_format
93 enum class image_format : unsigned int {
94  r8g8b8a8_unorm = 0,
96  r8g8b8a8_sint = 2,
99  r8g8b8a8_uint = 5,
100  r16g16b16a16_uint = 6,
101  r32b32g32a32_uint = 7,
104  b8g8r8a8_unorm = 10
105 };
106 
107 using byte = unsigned char;
108 
109 using image_allocator = detail::aligned_allocator<byte>;
110 
111 namespace detail {
112 
113 class image_impl;
114 
115 // validImageDataT: cl_int4, cl_uint4, cl_float4, cl_half4
116 template <typename T>
120 
121 template <typename DataT>
123  typename std::enable_if_t<is_validImageDataT<DataT>::value, DataT>;
124 
126  switch (Format) {
148  }
149  throw sycl::exception(sycl::make_error_code(sycl::errc::invalid),
150  "Unrecognized channel type.");
151 }
152 
154  switch (Format) {
168  }
169  throw sycl::exception(sycl::make_error_code(sycl::errc::invalid),
170  "Unrecognized channel order.");
171 }
172 
173 // The non-template base for the sycl::image class
174 class __SYCL_EXPORT image_plain {
175 protected:
176  image_plain(const std::shared_ptr<detail::image_impl> &Impl) : impl{Impl} {}
177 
179  const range<3> &Range,
180  std::unique_ptr<SYCLMemObjAllocator> Allocator,
181  uint8_t Dimensions, const property_list &PropList);
182 
184  const range<3> &Range, const range<2> &Pitch,
185  std::unique_ptr<SYCLMemObjAllocator> Allocator,
186  uint8_t Dimensions, const property_list &PropList);
187 
188  image_plain(void *HostPointer, image_channel_order Order,
189  image_channel_type Type, const range<3> &Range,
190  std::unique_ptr<SYCLMemObjAllocator> Allocator,
191  uint8_t Dimensions, const property_list &PropList);
192 
193  image_plain(const void *HostPointer, image_channel_order Order,
194  image_channel_type Type, const range<3> &Range,
195  std::unique_ptr<SYCLMemObjAllocator> Allocator,
196  uint8_t Dimensions, const property_list &PropList);
197 
198  image_plain(void *HostPointer, image_channel_order Order,
199  image_channel_type Type, const range<3> &Range,
200  const range<2> &Pitch,
201  std::unique_ptr<SYCLMemObjAllocator> Allocator,
202  uint8_t Dimensions, const property_list &PropList);
203 
204  image_plain(const std::shared_ptr<const void> &HostPointer,
206  const range<3> &Range,
207  std::unique_ptr<SYCLMemObjAllocator> Allocator,
208  uint8_t Dimensions, const property_list &PropList,
209  bool IsConstPtr);
210 
211  image_plain(const std::shared_ptr<const void> &HostPointer,
213  const range<3> &Range, const range<2> &Pitch,
214  std::unique_ptr<SYCLMemObjAllocator> Allocator,
215  uint8_t Dimensions, const property_list &PropList,
216  bool IsConstPtr);
217 
218  image_plain(const void *HostPointer, image_channel_order Order,
219  image_channel_type Type, image_sampler Sampler,
220  const range<3> &Range,
221  std::unique_ptr<SYCLMemObjAllocator> Allocator,
222  uint8_t Dimensions, const property_list &PropList);
223 
224  image_plain(const void *HostPointer, image_channel_order Order,
225  image_channel_type Type, image_sampler Sampler,
226  const range<3> &Range, const range<2> &Pitch,
227  std::unique_ptr<SYCLMemObjAllocator> Allocator,
228  uint8_t Dimensions, const property_list &PropList);
229 
230  image_plain(const std::shared_ptr<const void> &HostPointer,
232  image_sampler Sampler, const range<3> &Range,
233  std::unique_ptr<SYCLMemObjAllocator> Allocator,
234  uint8_t Dimensions, const property_list &PropList);
235 
236  image_plain(const std::shared_ptr<const void> &HostPointer,
238  image_sampler Sampler, const range<3> &Range,
239  const range<2> &Pitch,
240  std::unique_ptr<SYCLMemObjAllocator> Allocator,
241  uint8_t Dimensions, const property_list &PropList);
242 
243 #ifdef __SYCL_INTERNAL_API
244  image_plain(cl_mem ClMemObject, const context &SyclContext,
245  event AvailableEvent,
246  std::unique_ptr<SYCLMemObjAllocator> Allocator,
247  uint8_t Dimensions);
248 #endif
249 
250  image_plain(pi_native_handle MemObject, const context &SyclContext,
251  event AvailableEvent,
252  std::unique_ptr<SYCLMemObjAllocator> Allocator,
253  uint8_t Dimensions, image_channel_order Order,
254  image_channel_type Type, bool OwnNativeHandle,
255  range<3> Range3WithOnes);
256 
257  template <typename propertyT> bool has_property() const noexcept {
258  return getPropList().template has_property<propertyT>();
259  }
260 
261  template <typename propertyT> propertyT get_property() const {
262  return getPropList().template get_property<propertyT>();
263  }
264 
265  range<3> get_range() const;
266 
267  range<2> get_pitch() const;
268 
269  size_t get_size() const noexcept;
270 
271  size_t get_count() const noexcept;
272 
273  void set_final_data_internal();
274 
275  void set_final_data_internal(
276  const std::function<void(const std::function<void(void *const Ptr)> &)>
277  &FinalDataFunc);
278 
279  void set_write_back(bool flag);
280 
281  const std::unique_ptr<SYCLMemObjAllocator> &get_allocator_internal() const;
282 
283  size_t getElementSize() const;
284 
285  size_t getRowPitch() const;
286 
287  size_t getSlicePitch() const;
288 
289  image_sampler getSampler() const noexcept;
290 
291  image_channel_order getChannelOrder() const;
292 
293  image_channel_type getChannelType() const;
294 
295  void sampledImageConstructorNotification(const detail::code_location &CodeLoc,
296  void *UserObj, const void *HostObj,
297  uint32_t Dim, size_t Range[3],
298  image_format Format,
299  const image_sampler &Sampler);
300  void sampledImageDestructorNotification(void *UserObj);
301 
303  const detail::code_location &CodeLoc, void *UserObj, const void *HostObj,
304  uint32_t Dim, size_t Range[3], image_format Format);
305  void unsampledImageDestructorNotification(void *UserObj);
306 
307  std::shared_ptr<detail::image_impl> impl;
308 
309  const property_list &getPropList() const;
310 };
311 
312 // Common base class for image implementations
313 template <int Dimensions, typename AllocatorT>
314 class image_common : public image_plain {
315 protected:
316  // Use the same ctors as image_plain.
318 
319 public:
320  /* -- property interface members -- */
321  template <typename propertyT> bool has_property() const noexcept {
322  return image_plain::template has_property<propertyT>();
323  }
324 
325  template <typename propertyT> propertyT get_property() const {
326  return image_plain::get_property<propertyT>();
327  }
328 
330  return detail::convertToArrayOfN<Dimensions, 0>(image_plain::get_range());
331  }
332 
333  /* Available only when: dimensions >1 */
334  template <bool IsMultiDim = (Dimensions > 1)>
335  typename std::enable_if_t<IsMultiDim, range<Dimensions - 1>>
336  get_pitch() const {
337  return detail::convertToArrayOfN<Dimensions - 1, 0>(
339  }
340 
341  size_t size() const noexcept { return image_plain::get_count(); }
342 
343  // Returns the allocator provided to the image
344  AllocatorT get_allocator() const {
346  ->template getAllocator<AllocatorT>();
347  }
348 };
349 
350 // Common base class for unsampled image implementations
351 template <int Dimensions, typename AllocatorT>
352 class unsampled_image_common : public image_common<Dimensions, AllocatorT> {
353 private:
354  using common_base = typename detail::image_common<Dimensions, AllocatorT>;
355 
356 protected:
357  // Use the same ctors as image_plain.
358  using common_base::image_common;
359 
360 public:
361  template <typename Destination = std::nullptr_t>
362  void set_final_data(Destination finalData = nullptr) {
363  this->set_final_data_internal(finalData);
364  }
365 
366  void set_write_back(bool flag = true) { common_base::set_write_back(flag); }
367 
368 private:
369  void set_final_data_internal(std::nullptr_t) {
370  common_base::set_final_data_internal();
371  }
372 
373  template <template <typename WeakT> class WeakPtrT, typename WeakT>
374  std::enable_if_t<
375  std::is_convertible<WeakPtrT<WeakT>, std::weak_ptr<WeakT>>::value>
376  set_final_data_internal(WeakPtrT<WeakT> FinalData) {
377  std::weak_ptr<WeakT> TempFinalData(FinalData);
378  this->set_final_data_internal(TempFinalData);
379  }
380 
381  template <typename WeakT>
382  void set_final_data_internal(std::weak_ptr<WeakT> FinalData) {
383  common_base::set_final_data_internal(
384  [FinalData](const std::function<void(void *const Ptr)> &F) {
385  if (std::shared_ptr<WeakT> LockedFinalData = FinalData.lock())
386  F(LockedFinalData.get());
387  });
388  }
389 
390  template <typename Destination>
391  detail::EnableIfOutputPointerT<Destination>
392  set_final_data_internal(Destination FinalData) {
393  if (!FinalData)
394  common_base::set_final_data_internal();
395  else
396  common_base::set_final_data_internal(
397  [FinalData](const std::function<void(void *const Ptr)> &F) {
398  F(FinalData);
399  });
400  }
401 
402  template <typename Destination>
403  detail::EnableIfOutputIteratorT<Destination>
404  set_final_data_internal(Destination FinalData) {
405  const size_t Size = common_base::size();
406  common_base::set_final_data_internal(
407  [FinalData, Size](const std::function<void(void *const Ptr)> &F) {
408  using DestinationValueT = detail::iterator_value_type_t<Destination>;
409  // TODO if Destination is ContiguousIterator then don't create
410  // ContiguousStorage. updateHostMemory works only with pointer to
411  // continuous data.
412  std::unique_ptr<DestinationValueT[]> ContiguousStorage(
413  new DestinationValueT[Size]);
414  F(ContiguousStorage.get());
415  std::copy(ContiguousStorage.get(), ContiguousStorage.get() + Size,
416  FinalData);
417  });
418  }
419 };
420 
421 template <typename DataT, int Dims, access::mode AccMode,
423 class image_accessor;
424 
425 } // namespace detail
426 
427 template <typename DataT, int Dimensions, access_mode AccessMode,
428  image_target AccessTarget>
429 class unsampled_image_accessor;
430 
431 template <typename DataT, int Dimensions, access_mode AccessMode>
432 class host_unsampled_image_accessor;
433 
434 template <typename DataT, int Dimensions, image_target AccessTarget>
435 class sampled_image_accessor;
436 
437 template <typename DataT, int Dimensions> class host_sampled_image_accessor;
438 
448 template <int Dimensions = 1, typename AllocatorT = sycl::image_allocator>
449 class image : public detail::unsampled_image_common<Dimensions, AllocatorT> {
450 private:
451  using common_base =
453 
454 public:
456  const range<Dimensions> &Range, const property_list &PropList = {})
457  : common_base(Order, Type, detail::convertToArrayOfN<3, 1>(Range),
458  std::make_unique<
460  Dimensions, PropList) {}
461 
463  const range<Dimensions> &Range, AllocatorT Allocator,
464  const property_list &PropList = {})
465  : common_base(
466  Order, Type, detail::convertToArrayOfN<3, 1>(Range),
467  std::make_unique<
469  Dimensions, PropList) {}
470 
471  /* Available only when: dimensions >1 */
472  template <bool B = (Dimensions > 1)>
474  const range<Dimensions> &Range,
475  const typename std::enable_if_t<B, range<Dimensions - 1>> &Pitch,
476  const property_list &PropList = {})
477  : common_base(Order, Type, detail::convertToArrayOfN<3, 1>(Range),
478  detail::convertToArrayOfN<2, 0>(Pitch),
479  std::make_unique<
481  Dimensions, PropList) {}
482 
483  /* Available only when: dimensions >1 */
484  template <bool B = (Dimensions > 1)>
486  const range<Dimensions> &Range,
487  const typename std::enable_if_t<B, range<Dimensions - 1>> &Pitch,
488  AllocatorT Allocator, const property_list &PropList = {})
489  : common_base(
490  Order, Type, detail::convertToArrayOfN<3, 1>(Range),
491  detail::convertToArrayOfN<2, 0>(Pitch),
492  std::make_unique<
494  Dimensions, PropList) {}
495 
496  image(void *HostPointer, image_channel_order Order, image_channel_type Type,
497  const range<Dimensions> &Range, const property_list &PropList = {})
498  : common_base(HostPointer, Order, Type,
499  detail::convertToArrayOfN<3, 1>(Range),
500  std::make_unique<
502  Dimensions, PropList) {}
503 
504  image(void *HostPointer, image_channel_order Order, image_channel_type Type,
505  const range<Dimensions> &Range, AllocatorT Allocator,
506  const property_list &PropList = {})
507  : common_base(
508  HostPointer, Order, Type, detail::convertToArrayOfN<3, 1>(Range),
509  std::make_unique<
511  Dimensions, PropList) {}
512 
513  image(const void *HostPointer, image_channel_order Order,
514  image_channel_type Type, const range<Dimensions> &Range,
515  const property_list &PropList = {})
516  : common_base(HostPointer, Order, Type,
517  detail::convertToArrayOfN<3, 1>(Range),
518  std::make_unique<
520  Dimensions, PropList) {}
521 
522  image(const void *HostPointer, image_channel_order Order,
523  image_channel_type Type, const range<Dimensions> &Range,
524  AllocatorT Allocator, const property_list &PropList = {})
525  : common_base(
526  HostPointer, Order, Type, detail::convertToArrayOfN<3, 1>(Range),
527  std::make_unique<
529  Dimensions, PropList) {}
530 
531  /* Available only when: dimensions >1 */
532  template <bool B = (Dimensions > 1)>
533  image(void *HostPointer, image_channel_order Order, image_channel_type Type,
534  const range<Dimensions> &Range,
535  const typename std::enable_if_t<B, range<Dimensions - 1>> &Pitch,
536  const property_list &PropList = {})
537  : common_base(HostPointer, Order, Type,
538  detail::convertToArrayOfN<3, 1>(Range),
539  detail::convertToArrayOfN<2, 0>(Pitch),
540  std::make_unique<
542  Dimensions, PropList) {}
543 
544  /* Available only when: dimensions >1 */
545  template <bool B = (Dimensions > 1)>
546  image(void *HostPointer, image_channel_order Order, image_channel_type Type,
547  const range<Dimensions> &Range,
548  const typename std::enable_if_t<B, range<Dimensions - 1>> &Pitch,
549  AllocatorT Allocator, const property_list &PropList = {})
550  : common_base(
551  HostPointer, Order, Type, detail::convertToArrayOfN<3, 1>(Range),
552  detail::convertToArrayOfN<2, 0>(Pitch),
553  std::make_unique<
555  Dimensions, PropList) {}
556 
557  image(std::shared_ptr<void> &HostPointer, image_channel_order Order,
558  image_channel_type Type, const range<Dimensions> &Range,
559  const property_list &PropList = {})
560  : common_base(HostPointer, Order, Type,
561  detail::convertToArrayOfN<3, 1>(Range),
562  std::make_unique<
564  Dimensions, PropList, /*IsConstPtr*/ false) {}
565 
566  image(std::shared_ptr<void> &HostPointer, image_channel_order Order,
567  image_channel_type Type, const range<Dimensions> &Range,
568  AllocatorT Allocator, const property_list &PropList = {})
569  : common_base(
570  HostPointer, Order, Type, detail::convertToArrayOfN<3, 1>(Range),
571  std::make_unique<
573  Dimensions, PropList, /*IsConstPtr*/ false) {}
574 
575  /* Available only when: dimensions >1 */
576  template <bool B = (Dimensions > 1)>
577  image(std::shared_ptr<void> &HostPointer, image_channel_order Order,
578  image_channel_type Type, const range<Dimensions> &Range,
579  const typename std::enable_if_t<B, range<Dimensions - 1>> &Pitch,
580  const property_list &PropList = {})
581  : common_base(HostPointer, Order, Type,
582  detail::convertToArrayOfN<3, 1>(Range),
583  detail::convertToArrayOfN<2, 0>(Pitch),
584  std::make_unique<
586  Dimensions, PropList, /*IsConstPtr*/ false) {}
587 
588  /* Available only when: dimensions >1 */
589  template <bool B = (Dimensions > 1)>
590  image(std::shared_ptr<void> &HostPointer, image_channel_order Order,
591  image_channel_type Type, const range<Dimensions> &Range,
592  const typename std::enable_if_t<B, range<Dimensions - 1>> &Pitch,
593  AllocatorT Allocator, const property_list &PropList = {})
594  : common_base(
595  HostPointer, Order, Type, detail::convertToArrayOfN<3, 1>(Range),
596  detail::convertToArrayOfN<2, 0>(Pitch),
597  std::make_unique<
599  Dimensions, PropList, /*IsConstPtr*/ false) {}
600 
601 #ifdef __SYCL_INTERNAL_API
602  image(cl_mem ClMemObject, const context &SyclContext,
603  event AvailableEvent = {})
604  : common_base(ClMemObject, SyclContext, AvailableEvent,
605  std::make_unique<
606  detail::SYCLMemObjAllocatorHolder<AllocatorT, byte>>(),
607  Dimensions) {}
608 #endif
609 
610  /* -- common interface members -- */
611 
612  image(const image &rhs) = default;
613 
614  image(image &&rhs) = default;
615 
616  image &operator=(const image &rhs) = default;
617 
618  image &operator=(image &&rhs) = default;
619 
620  ~image() = default;
621 
622  bool operator==(const image &rhs) const { return this->impl == rhs.impl; }
623 
624  bool operator!=(const image &rhs) const { return !(*this == rhs); }
625 
626  /* -- property interface members -- */
627  template <typename propertyT> bool has_property() const noexcept {
628  return common_base::template has_property<propertyT>();
629  }
630 
631  template <typename propertyT> propertyT get_property() const {
632  return common_base::template get_property<propertyT>();
633  }
634 
636  return detail::convertToArrayOfN<Dimensions, 0>(common_base::get_range());
637  }
638 
639  /* Available only when: dimensions >1 */
640  template <bool B = (Dimensions > 1)>
641  typename std::enable_if_t<B, range<Dimensions - 1>> get_pitch() const {
642  return detail::convertToArrayOfN<Dimensions - 1, 0>(
644  }
645 
646  // Returns the size of the image storage in bytes
647  size_t get_size() const { return common_base::get_size(); }
648 
649  // Returns the total number of elements in the image
650  __SYCL2020_DEPRECATED("get_count() is deprecated, please use size() instead")
651  size_t get_count() const { return common_base::size(); }
652 
653  template <typename DataT, access::mode AccessMode>
657  get_access(handler &commandGroupHandler) {
661  commandGroupHandler);
662  }
663 
664  template <typename DataT, access::mode AccessMode>
672  }
673 
674 private:
675  image(pi_native_handle MemObject, const context &SyclContext,
676  event AvailableEvent, image_channel_order Order,
677  image_channel_type Type, bool OwnNativeHandle, range<Dimensions> Range)
678  : common_base(MemObject, SyclContext, AvailableEvent,
679  std::make_unique<
680  detail::SYCLMemObjAllocatorHolder<AllocatorT, byte>>(),
681  Dimensions, Order, Type, OwnNativeHandle,
682  detail::convertToArrayOfN<3, 1>(Range)) {}
683 
684  // This utility api is currently used by accessor to get the element size of
685  // the image. Element size is dependent on num of channels and channel type.
686  // This information is not accessible from the image using any public API.
687  size_t getElementSize() const { return common_base::getElementSize(); }
688 
689  size_t getRowPitch() const { return common_base::getRowPitch(); }
690 
691  size_t getSlicePitch() const { return common_base::getSlicePitch(); }
692 
693  image_channel_order getChannelOrder() const {
694  return common_base::getChannelOrder();
695  }
696 
697  image_channel_type getChannelType() const {
698  return common_base::getChannelType();
699  }
700 
701  // Declare make_image as a friend function
702  template <backend Backend, int D, typename A>
703  friend std::enable_if_t<
706  image<D, A>>
708  const typename backend_traits<Backend>::template input_type<image<D, A>>
709  &BackendObject,
710  const context &TargetContext, event AvailableEvent);
711 
712  template <backend Backend, int D, typename A>
713  friend std::enable_if_t<Backend == backend::ext_oneapi_level_zero,
714  image<D, A>>
715  make_image(const backend_input_t<Backend, image<D, A>> &BackendObject,
716  const context &TargetContext, event AvailableEvent);
717 
718  template <class Obj>
719  friend const decltype(Obj::impl) &
720  detail::getSyclObjImpl(const Obj &SyclObject);
721 
722  template <typename DataT, int Dims, access::mode AccMode,
724  typename PropertyListT>
725  friend class accessor;
726 
727  template <typename DataT, int Dims, access::mode AccMode,
730 };
731 
732 template <int Dimensions = 1, typename AllocatorT = sycl::image_allocator>
734  : public detail::unsampled_image_common<Dimensions, AllocatorT>,
735  public detail::OwnerLessBase<unsampled_image<Dimensions, AllocatorT>> {
736 private:
737  using common_base =
739 
740  unsampled_image(const std::shared_ptr<detail::image_impl> &Impl)
741  : common_base{Impl} {}
742 
743 public:
745  image_format Format, const range<Dimensions> &Range,
746  const property_list &PropList = {},
748  : common_base(detail::FormatChannelOrder(Format),
750  detail::convertToArrayOfN<3, 1>(Range),
751  std::make_unique<
753  Dimensions, PropList) {
755  CodeLoc, (void *)this->impl.get(), nullptr, Dimensions,
756  detail::rangeToArray(Range).data(), Format);
757  }
758 
760  image_format Format, const range<Dimensions> &Range, AllocatorT Allocator,
761  const property_list &PropList = {},
763  : common_base(
766  detail::convertToArrayOfN<3, 1>(Range),
767  std::make_unique<
769  Dimensions, PropList) {
771  CodeLoc, (void *)this->impl.get(), nullptr, Dimensions,
772  detail::rangeToArray(Range).data(), Format);
773  }
774 
775  template <bool IsMultiDim = (Dimensions > 1),
776  typename = std::enable_if_t<IsMultiDim>>
778  image_format Format, const range<Dimensions> &Range,
779  const range<Dimensions - 1> &Pitch, const property_list &PropList = {},
781  : common_base(detail::FormatChannelOrder(Format),
783  detail::convertToArrayOfN<3, 1>(Range),
784  detail::convertToArrayOfN<2, 0>(Pitch),
785  std::make_unique<
787  Dimensions, PropList) {
789  CodeLoc, (void *)this->impl.get(), nullptr, Dimensions,
790  detail::rangeToArray(Range).data(), Format);
791  }
792 
793  template <bool IsMultiDim = (Dimensions > 1),
794  typename = std::enable_if_t<IsMultiDim>>
796  image_format Format, const range<Dimensions> &Range,
797  const range<Dimensions - 1> &Pitch, AllocatorT Allocator,
798  const property_list &PropList = {},
800  : common_base(
803  detail::convertToArrayOfN<3, 1>(Range),
804  detail::convertToArrayOfN<2, 0>(Pitch),
805  std::make_unique<
807  Dimensions, PropList) {
809  CodeLoc, (void *)this->impl.get(), nullptr, Dimensions,
810  detail::rangeToArray(Range).data(), Format);
811  }
812 
814  void *HostPointer, image_format Format, const range<Dimensions> &Range,
815  const property_list &PropList = {},
817  : common_base(HostPointer, detail::FormatChannelOrder(Format),
819  detail::convertToArrayOfN<3, 1>(Range),
820  std::make_unique<
822  Dimensions, PropList) {
824  CodeLoc, (void *)this->impl.get(), HostPointer, Dimensions,
825  detail::rangeToArray(Range).data(), Format);
826  }
827 
829  void *HostPointer, image_format Format, const range<Dimensions> &Range,
830  AllocatorT Allocator, const property_list &PropList = {},
832  : common_base(
833  HostPointer, detail::FormatChannelOrder(Format),
835  detail::convertToArrayOfN<3, 1>(Range),
836  std::make_unique<
838  Dimensions, PropList) {
840  CodeLoc, (void *)this->impl.get(), HostPointer, Dimensions,
841  detail::rangeToArray(Range).data(), Format);
842  }
843 
844  template <bool IsMultiDim = (Dimensions > 1),
845  typename = std::enable_if_t<IsMultiDim>>
847  void *HostPointer, image_format Format, const range<Dimensions> &Range,
848  const range<Dimensions - 1> &Pitch, const property_list &PropList = {},
850  : common_base(HostPointer, detail::FormatChannelOrder(Format),
852  detail::convertToArrayOfN<3, 1>(Range),
853  detail::convertToArrayOfN<2, 0>(Pitch),
854  std::make_unique<
856  Dimensions, PropList) {
858  CodeLoc, (void *)this->impl.get(), HostPointer, Dimensions,
859  detail::rangeToArray(Range).data(), Format);
860  }
861 
862  template <bool IsMultiDim = (Dimensions > 1),
863  typename = std::enable_if_t<IsMultiDim>>
865  void *HostPointer, image_format Format, const range<Dimensions> &Range,
866  const range<Dimensions - 1> &Pitch, AllocatorT Allocator,
867  const property_list &PropList = {},
869  : common_base(
870  HostPointer, detail::FormatChannelOrder(Format),
872  detail::convertToArrayOfN<3, 1>(Range),
873  detail::convertToArrayOfN<2, 0>(Pitch),
874  std::make_unique<
876  Dimensions, PropList) {
878  CodeLoc, (void *)this->impl.get(), HostPointer, Dimensions,
879  detail::rangeToArray(Range).data(), Format);
880  }
881 
883  std::shared_ptr<void> &HostPointer, image_format Format,
884  const range<Dimensions> &Range, const property_list &PropList = {},
886  : common_base(HostPointer, detail::FormatChannelOrder(Format),
888  detail::convertToArrayOfN<3, 1>(Range),
889  std::make_unique<
891  Dimensions, PropList, /*IsConstPtr*/ false) {
893  CodeLoc, (void *)this->impl.get(), HostPointer.get(), Dimensions,
894  detail::rangeToArray(Range).data(), Format);
895  }
896 
898  std::shared_ptr<void> &HostPointer, image_format Format,
899  const range<Dimensions> &Range, AllocatorT Allocator,
900  const property_list &PropList = {},
902  : common_base(
903  HostPointer, detail::FormatChannelOrder(Format),
905  detail::convertToArrayOfN<3, 1>(Range),
906  std::make_unique<
908  Dimensions, PropList, /*IsConstPtr*/ false) {
910  CodeLoc, (void *)this->impl.get(), HostPointer.get(), Dimensions,
911  detail::rangeToArray(Range).data(), Format);
912  }
913 
914  template <bool IsMultiDim = (Dimensions > 1),
915  typename = std::enable_if_t<IsMultiDim>>
917  std::shared_ptr<void> &HostPointer, image_format Format,
918  const range<Dimensions> &Range, const range<Dimensions - 1> &Pitch,
919  const property_list &PropList = {},
921  : common_base(HostPointer, detail::FormatChannelOrder(Format),
923  detail::convertToArrayOfN<3, 1>(Range),
924  detail::convertToArrayOfN<2, 0>(Pitch),
925  std::make_unique<
927  Dimensions, PropList, /*IsConstPtr*/ false) {
929  CodeLoc, (void *)this->impl.get(), HostPointer.get(), Dimensions,
930  detail::rangeToArray(Range).data(), Format);
931  }
932 
933  template <bool IsMultiDim = (Dimensions > 1),
934  typename = std::enable_if_t<IsMultiDim>>
936  std::shared_ptr<void> &HostPointer, image_format Format,
937  const range<Dimensions> &Range, const range<Dimensions - 1> &Pitch,
938  AllocatorT Allocator, const property_list &PropList = {},
940  : common_base(
941  HostPointer, detail::FormatChannelOrder(Format),
943  detail::convertToArrayOfN<3, 1>(Range),
944  detail::convertToArrayOfN<2, 0>(Pitch),
945  std::make_unique<
947  Dimensions, PropList, /*IsConstPtr*/ false) {
949  CodeLoc, (void *)this->impl.get(), HostPointer.get(), Dimensions,
950  detail::rangeToArray(Range).data(), Format);
951  }
952 
953  /* -- common interface members -- */
954 
955  unsampled_image(const unsampled_image &rhs) = default;
956 
958 
959  unsampled_image &operator=(const unsampled_image &rhs) = default;
960 
962 
964  try {
965  common_base::unsampledImageDestructorNotification(
966  (void *)this->impl.get());
967  } catch (std::exception &e) {
968  __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~unsampled_image", e);
969  }
970  }
971 
972  bool operator==(const unsampled_image &rhs) const {
973  return this->impl == rhs.impl;
974  }
975 
976  bool operator!=(const unsampled_image &rhs) const { return !(*this == rhs); }
977 
978  size_t byte_size() const noexcept { return common_base::get_size(); }
979 
980  using common_base::size;
981 
982  template <typename DataT,
983  access_mode AccessMode = (std::is_const_v<DataT>
986  image_target AccessTarget = image_target::device>
989  handler &CommandGroupHandlerRef, const property_list &PropList = {},
991  return {*this, CommandGroupHandlerRef, PropList, CodeLoc};
992  }
993 
994  template <typename DataT,
995  access_mode AccessMode = (std::is_const_v<DataT>
999  const property_list &PropList = {},
1001  return {*this, PropList, CodeLoc};
1002  }
1003 
1004 private:
1005  template <class Obj>
1006  friend const decltype(Obj::impl) &
1007  detail::getSyclObjImpl(const Obj &SyclObject);
1008 
1009  template <class T>
1010  friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);
1011 
1012  template <typename DataT, int Dims, access_mode AccessMode>
1014 
1015  template <typename DataT, int Dims, access_mode AccessMode,
1016  image_target AccessTarget>
1018 };
1019 
1020 template <int Dimensions = 1, typename AllocatorT = sycl::image_allocator>
1022  : public detail::image_common<Dimensions, AllocatorT>,
1023  public detail::OwnerLessBase<sampled_image<Dimensions, AllocatorT>> {
1024 private:
1025  using common_base = typename detail::image_common<Dimensions, AllocatorT>;
1026 
1027  sampled_image(const std::shared_ptr<detail::image_impl> &Impl)
1028  : common_base{Impl} {}
1029 
1030 public:
1032  const void *HostPointer, image_format Format, image_sampler Sampler,
1033  const range<Dimensions> &Range, const property_list &PropList = {},
1035  : common_base(HostPointer, detail::FormatChannelOrder(Format),
1036  detail::FormatChannelType(Format), Sampler,
1037  detail::convertToArrayOfN<3, 1>(Range),
1038  std::make_unique<
1040  Dimensions, PropList) {
1042  CodeLoc, (void *)this->impl.get(), nullptr, Dimensions,
1043  detail::rangeToArray(Range).data(), Format, Sampler);
1044  }
1045 
1046  template <bool IsMultiDim = (Dimensions > 1),
1047  typename = std::enable_if_t<IsMultiDim>>
1049  const void *HostPointer, image_format Format, image_sampler Sampler,
1050  const range<Dimensions> &Range, const range<Dimensions - 1> &Pitch,
1051  const property_list &PropList = {},
1053  : common_base(HostPointer, detail::FormatChannelOrder(Format),
1054  detail::FormatChannelType(Format), Sampler,
1055  detail::convertToArrayOfN<3, 1>(Range),
1056  detail::convertToArrayOfN<2, 0>(Pitch),
1057  std::make_unique<
1059  Dimensions, PropList) {
1061  CodeLoc, (void *)this->impl.get(), HostPointer, Dimensions,
1062  detail::rangeToArray(Range).data(), Format, Sampler);
1063  }
1064 
1066  std::shared_ptr<const void> &HostPointer, image_format Format,
1067  image_sampler Sampler, const range<Dimensions> &Range,
1068  const property_list &PropList = {},
1070  : common_base(HostPointer, detail::FormatChannelOrder(Format),
1071  detail::FormatChannelType(Format), Sampler,
1072  detail::convertToArrayOfN<3, 1>(Range),
1073  std::make_unique<
1075  Dimensions, PropList) {
1077  CodeLoc, (void *)this->impl.get(), HostPointer.get(), Dimensions,
1078  detail::rangeToArray(Range).data(), Format, Sampler);
1079  }
1080 
1081  template <bool IsMultiDim = (Dimensions > 1),
1082  typename = std::enable_if_t<IsMultiDim>>
1084  std::shared_ptr<const void> &HostPointer, image_format Format,
1085  image_sampler Sampler, const range<Dimensions> &Range,
1086  const range<Dimensions - 1> &Pitch, const property_list &PropList = {},
1088  : common_base(HostPointer, detail::FormatChannelOrder(Format),
1089  detail::FormatChannelType(Format), Sampler,
1090  detail::convertToArrayOfN<3, 1>(Range),
1091  detail::convertToArrayOfN<2, 0>(Pitch),
1092  std::make_unique<
1094  Dimensions, PropList) {
1096  CodeLoc, (void *)this->impl.get(), HostPointer.get(), Dimensions,
1097  detail::rangeToArray(Range).data(), Format, Sampler);
1098  }
1099 
1100  /* -- common interface members -- */
1101 
1102  sampled_image(const sampled_image &rhs) = default;
1103 
1104  sampled_image(sampled_image &&rhs) = default;
1105 
1106  sampled_image &operator=(const sampled_image &rhs) = default;
1107 
1109 
1111  try {
1112  common_base::sampledImageDestructorNotification((void *)this->impl.get());
1113  } catch (std::exception &e) {
1114  __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~sampled_image", e);
1115  }
1116  }
1117 
1118  bool operator==(const sampled_image &rhs) const {
1119  return this->impl == rhs.impl;
1120  }
1121 
1122  bool operator!=(const sampled_image &rhs) const { return !(*this == rhs); }
1123 
1124  size_t byte_size() const noexcept { return common_base::get_size(); }
1125 
1126  template <typename DataT, image_target AccessTarget = image_target::device>
1128  handler &CommandGroupHandlerRef, const property_list &PropList = {},
1130  return {*this, CommandGroupHandlerRef, PropList, CodeLoc};
1131  }
1132 
1133  template <typename DataT>
1135  const property_list &PropList = {},
1137  return {*this, PropList, CodeLoc};
1138  }
1139 
1140 private:
1141  template <class Obj>
1142  friend const decltype(Obj::impl) &
1143  detail::getSyclObjImpl(const Obj &SyclObject);
1144 
1145  template <class T>
1146  friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);
1147 
1148  template <typename DataT, int Dims> friend class host_sampled_image_accessor;
1149 
1150  template <typename DataT, int Dims, image_target AccessTarget>
1152 };
1153 
1154 } // namespace _V1
1155 } // namespace sycl
1156 
1157 namespace std {
1158 template <int Dimensions, typename AllocatorT>
1159 struct hash<sycl::image<Dimensions, AllocatorT>> {
1161  return hash<std::shared_ptr<sycl::detail::image_impl>>()(
1163  }
1164 };
1165 
1166 template <int Dimensions, typename AllocatorT>
1167 struct hash<sycl::unsampled_image<Dimensions, AllocatorT>> {
1168  size_t
1170  return hash<std::shared_ptr<sycl::detail::image_impl>>()(
1172  }
1173 };
1174 
1175 template <int Dimensions, typename AllocatorT>
1176 struct hash<sycl::sampled_image<Dimensions, AllocatorT>> {
1177  size_t
1179  return hash<std::shared_ptr<sycl::detail::image_impl>>()(
1181  }
1182 };
1183 } // namespace std
The context class represents a SYCL context on which kernel functions may be executed.
Definition: context.hpp:50
propertyT get_property() const
Definition: image.hpp:325
AllocatorT get_allocator() const
Definition: image.hpp:344
range< Dimensions > get_range() const
Definition: image.hpp:329
bool has_property() const noexcept
Definition: image.hpp:321
std::enable_if_t< IsMultiDim, range< Dimensions - 1 > > get_pitch() const
Definition: image.hpp:336
size_t size() const noexcept
Definition: image.hpp:341
size_t get_count() const noexcept
Definition: image.cpp:150
range< 2 > get_pitch() const
Definition: image.cpp:146
bool has_property() const noexcept
Definition: image.hpp:257
range< 3 > get_range() const
Definition: image.cpp:144
std::shared_ptr< detail::image_impl > impl
Definition: image.hpp:307
const std::unique_ptr< SYCLMemObjAllocator > & get_allocator_internal() const
Definition: image.cpp:165
propertyT get_property() const
Definition: image.hpp:261
image_plain(const std::shared_ptr< detail::image_impl > &Impl)
Definition: image.hpp:176
void set_final_data(Destination finalData=nullptr)
Definition: image.hpp:362
void set_write_back(bool flag=true)
Definition: image.hpp:366
An event object can be used to synchronize memory transfers, enqueues of kernels and signaling barrie...
Definition: event.hpp:44
Command group handler class.
Definition: handler.hpp:468
Defines a shared image data.
Definition: image.hpp:449
image(std::shared_ptr< void > &HostPointer, image_channel_order Order, image_channel_type Type, const range< Dimensions > &Range, const typename std::enable_if_t< B, range< Dimensions - 1 >> &Pitch, const property_list &PropList={})
Definition: image.hpp:577
std::enable_if_t< B, range< Dimensions - 1 > > get_pitch() const
Definition: image.hpp:641
image(const image &rhs)=default
image(void *HostPointer, image_channel_order Order, image_channel_type Type, const range< Dimensions > &Range, const property_list &PropList={})
Definition: image.hpp:496
image(std::shared_ptr< void > &HostPointer, image_channel_order Order, image_channel_type Type, const range< Dimensions > &Range, const property_list &PropList={})
Definition: image.hpp:557
~image()=default
image(image_channel_order Order, image_channel_type Type, const range< Dimensions > &Range, AllocatorT Allocator, const property_list &PropList={})
Definition: image.hpp:462
accessor< detail::EnableIfImgAccDataT< DataT >, Dimensions, AccessMode, access::target::image, access::placeholder::false_t, ext::oneapi::accessor_property_list<> > get_access(handler &commandGroupHandler)
Definition: image.hpp:657
image(std::shared_ptr< void > &HostPointer, image_channel_order Order, image_channel_type Type, const range< Dimensions > &Range, const typename std::enable_if_t< B, range< Dimensions - 1 >> &Pitch, AllocatorT Allocator, const property_list &PropList={})
Definition: image.hpp:590
image(std::shared_ptr< void > &HostPointer, image_channel_order Order, image_channel_type Type, const range< Dimensions > &Range, AllocatorT Allocator, const property_list &PropList={})
Definition: image.hpp:566
image(image_channel_order Order, image_channel_type Type, const range< Dimensions > &Range, const typename std::enable_if_t< B, range< Dimensions - 1 >> &Pitch, const property_list &PropList={})
Definition: image.hpp:473
image(image_channel_order Order, image_channel_type Type, const range< Dimensions > &Range, const typename std::enable_if_t< B, range< Dimensions - 1 >> &Pitch, AllocatorT Allocator, const property_list &PropList={})
Definition: image.hpp:485
image(const void *HostPointer, image_channel_order Order, image_channel_type Type, const range< Dimensions > &Range, AllocatorT Allocator, const property_list &PropList={})
Definition: image.hpp:522
bool operator!=(const image &rhs) const
Definition: image.hpp:624
range< Dimensions > get_range() const
Definition: image.hpp:635
image(image &&rhs)=default
image(void *HostPointer, image_channel_order Order, image_channel_type Type, const range< Dimensions > &Range, AllocatorT Allocator, const property_list &PropList={})
Definition: image.hpp:504
image(const void *HostPointer, image_channel_order Order, image_channel_type Type, const range< Dimensions > &Range, const property_list &PropList={})
Definition: image.hpp:513
accessor< detail::EnableIfImgAccDataT< DataT >, Dimensions, AccessMode, access::target::host_image, access::placeholder::false_t, ext::oneapi::accessor_property_list<> > get_access()
Definition: image.hpp:668
image(void *HostPointer, image_channel_order Order, image_channel_type Type, const range< Dimensions > &Range, const typename std::enable_if_t< B, range< Dimensions - 1 >> &Pitch, const property_list &PropList={})
Definition: image.hpp:533
__SYCL2020_DEPRECATED("get_count() is deprecated, please use size() instead") size_t get_count() const
Definition: image.hpp:650
friend std::enable_if_t< Backend==backend::ext_oneapi_level_zero, image< D, A > > make_image(const backend_input_t< Backend, image< D, A >> &BackendObject, const context &TargetContext, event AvailableEvent)
image & operator=(image &&rhs)=default
image(void *HostPointer, image_channel_order Order, image_channel_type Type, const range< Dimensions > &Range, const typename std::enable_if_t< B, range< Dimensions - 1 >> &Pitch, AllocatorT Allocator, const property_list &PropList={})
Definition: image.hpp:546
bool has_property() const noexcept
Definition: image.hpp:627
friend std::enable_if_t< detail::InteropFeatureSupportMap< Backend >::MakeImage==true &&Backend !=backend::ext_oneapi_level_zero, image< D, A > > make_image(const typename backend_traits< Backend >::template input_type< image< D, A >> &BackendObject, const context &TargetContext, event AvailableEvent)
bool operator==(const image &rhs) const
Definition: image.hpp:622
image & operator=(const image &rhs)=default
propertyT get_property() const
Definition: image.hpp:631
image(image_channel_order Order, image_channel_type Type, const range< Dimensions > &Range, const property_list &PropList={})
Definition: image.hpp:455
size_t get_size() const
Definition: image.hpp:647
Objects of the property_list class are containers for the SYCL properties.
sampled_image_accessor< DataT, Dimensions, AccessTarget > get_access(handler &CommandGroupHandlerRef, const property_list &PropList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: image.hpp:1127
sampled_image(const sampled_image &rhs)=default
sampled_image(std::shared_ptr< const void > &HostPointer, image_format Format, image_sampler Sampler, const range< Dimensions > &Range, const range< Dimensions - 1 > &Pitch, const property_list &PropList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: image.hpp:1083
sampled_image(const void *HostPointer, image_format Format, image_sampler Sampler, const range< Dimensions > &Range, const range< Dimensions - 1 > &Pitch, const property_list &PropList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: image.hpp:1048
host_sampled_image_accessor< DataT, Dimensions > get_host_access(const property_list &PropList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: image.hpp:1134
bool operator==(const sampled_image &rhs) const
Definition: image.hpp:1118
sampled_image(const void *HostPointer, image_format Format, image_sampler Sampler, const range< Dimensions > &Range, const property_list &PropList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: image.hpp:1031
sampled_image(sampled_image &&rhs)=default
sampled_image(std::shared_ptr< const void > &HostPointer, image_format Format, image_sampler Sampler, const range< Dimensions > &Range, const property_list &PropList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: image.hpp:1065
sampled_image & operator=(sampled_image &&rhs)=default
size_t byte_size() const noexcept
Definition: image.hpp:1124
bool operator!=(const sampled_image &rhs) const
Definition: image.hpp:1122
sampled_image & operator=(const sampled_image &rhs)=default
unsampled_image(image_format Format, const range< Dimensions > &Range, const range< Dimensions - 1 > &Pitch, AllocatorT Allocator, const property_list &PropList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: image.hpp:795
bool operator==(const unsampled_image &rhs) const
Definition: image.hpp:972
unsampled_image & operator=(unsampled_image &&rhs)=default
unsampled_image(std::shared_ptr< void > &HostPointer, image_format Format, const range< Dimensions > &Range, AllocatorT Allocator, const property_list &PropList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: image.hpp:897
unsampled_image & operator=(const unsampled_image &rhs)=default
unsampled_image(const unsampled_image &rhs)=default
unsampled_image_accessor< DataT, Dimensions, AccessMode, AccessTarget > get_access(handler &CommandGroupHandlerRef, const property_list &PropList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: image.hpp:988
unsampled_image(void *HostPointer, image_format Format, const range< Dimensions > &Range, const range< Dimensions - 1 > &Pitch, AllocatorT Allocator, const property_list &PropList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: image.hpp:864
friend class host_unsampled_image_accessor
Definition: image.hpp:1013
unsampled_image(image_format Format, const range< Dimensions > &Range, AllocatorT Allocator, const property_list &PropList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: image.hpp:759
unsampled_image(void *HostPointer, image_format Format, const range< Dimensions > &Range, AllocatorT Allocator, const property_list &PropList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: image.hpp:828
unsampled_image(void *HostPointer, image_format Format, const range< Dimensions > &Range, const property_list &PropList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: image.hpp:813
unsampled_image(void *HostPointer, image_format Format, const range< Dimensions > &Range, const range< Dimensions - 1 > &Pitch, const property_list &PropList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: image.hpp:846
unsampled_image(std::shared_ptr< void > &HostPointer, image_format Format, const range< Dimensions > &Range, const range< Dimensions - 1 > &Pitch, const property_list &PropList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: image.hpp:916
bool operator!=(const unsampled_image &rhs) const
Definition: image.hpp:976
size_t byte_size() const noexcept
Definition: image.hpp:978
unsampled_image(image_format Format, const range< Dimensions > &Range, const range< Dimensions - 1 > &Pitch, const property_list &PropList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: image.hpp:777
unsampled_image(unsampled_image &&rhs)=default
unsampled_image(image_format Format, const range< Dimensions > &Range, const property_list &PropList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: image.hpp:744
unsampled_image(std::shared_ptr< void > &HostPointer, image_format Format, const range< Dimensions > &Range, const property_list &PropList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: image.hpp:882
host_unsampled_image_accessor< DataT, Dimensions, AccessMode > get_host_access(const property_list &PropList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: image.hpp:998
unsampled_image(std::shared_ptr< void > &HostPointer, image_format Format, const range< Dimensions > &Range, const range< Dimensions - 1 > &Pitch, AllocatorT Allocator, const property_list &PropList={}, const detail::code_location CodeLoc=detail::code_location::current())
Definition: image.hpp:935
#define __SYCL_REPORT_EXCEPTION_TO_STREAM(str, e)
Definition: common.hpp:373
static T< NewDim > convertToArrayOfN(T< OldDim > OldObj)
Definition: common.hpp:309
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)
std::array< size_t, 3 > rangeToArray(const range< 3 > &r)
Definition: range.hpp:234
boost::mp11::mp_set_contains< TypeList, std::remove_cv_t< T > > is_contained
Definition: type_list.hpp:32
image_channel_type FormatChannelType(image_format Format)
Definition: image.hpp:125
boost::mp11::mp_list< T... > type_list
Definition: type_list.hpp:22
T createSyclObjFromImpl(decltype(T::impl) ImplObj)
Definition: impl_utils.hpp:40
typename detail::is_contained< T, type_list< vec< opencl::cl_int, 4 >, vec< opencl::cl_uint, 4 >, vec< opencl::cl_float, 4 >, vec< opencl::cl_half, 4 > >>::type is_validImageDataT
Definition: image.hpp:119
image_channel_order FormatChannelOrder(image_format Format)
Definition: image.hpp:153
void sampledImageConstructorNotification(void *ImageObj, void *AccessorObj, const std::optional< image_target > &Target, const void *Type, uint32_t ElemSize, const code_location &CodeLoc)
typename std::enable_if_t< is_validImageDataT< DataT >::value, DataT > EnableIfImgAccDataT
Definition: image.hpp:123
void copy(handler &CGH, const T *Src, T *Dest, size_t Count)
unsigned char byte
Definition: image.hpp:107
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
image_channel_order
Definition: image.hpp:56
std::enable_if_t< detail::InteropFeatureSupportMap< Backend >::MakeImage==true &&Backend !=backend::ext_oneapi_level_zero, image< Dimensions, AllocatorT > > make_image(const typename backend_traits< Backend >::template input_type< image< Dimensions, AllocatorT >> &BackendObject, const context &TargetContext, event AvailableEvent={})
Definition: backend.hpp:389
class __SYCL_EBO __SYCL_SPECIAL_CLASS IsPlaceholder
image_format
Definition: image.hpp:93
class __SYCL_EBO __SYCL_SPECIAL_CLASS AccessMode
detail::aligned_allocator< byte > image_allocator
Definition: image.hpp:109
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:64
typename backend_traits< Backend >::template input_type< SyclType > backend_input_t
Definition: backend.hpp:77
Definition: access.hpp:18
static constexpr size_t get_pitch(size_t x)
Calculate pitch (padded length of major dimension x) by rounding up to multiple of 32.
Definition: memory.hpp:195
uintptr_t pi_native_handle
Definition: pi.h:256
_Abi const simd< _Tp, _Abi > & noexcept
Definition: simd.hpp:1324
size_t operator()(const sycl::image< Dimensions, AllocatorT > &I) const
Definition: image.hpp:1160
size_t operator()(const sycl::sampled_image< Dimensions, AllocatorT > &I) const
Definition: image.hpp:1178
size_t operator()(const sycl::unsampled_image< Dimensions, AllocatorT > &I) const
Definition: image.hpp:1169
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