DPC++ Runtime
Runtime libraries for oneAPI DPC++
image.cpp
Go to the documentation of this file.
1 #include <detail/image_impl.hpp>
2 #include <sycl/event.hpp>
4 #include <sycl/image.hpp>
6 #include <sycl/property_list.hpp>
7 #include <sycl/range.hpp>
8 
9 #include <memory>
10 
11 namespace sycl {
12 inline namespace _V1 {
13 namespace detail {
14 
16  const range<3> &Range,
17  std::unique_ptr<SYCLMemObjAllocator> Allocator,
18  uint8_t Dimensions, const property_list &PropList) {
19  impl = std::make_shared<detail::image_impl>(
20  Order, Type, Range, std::move(Allocator), Dimensions, PropList);
21 }
22 
24  const range<3> &Range, const range<2> &Pitch,
25  std::unique_ptr<SYCLMemObjAllocator> Allocator,
26  uint8_t Dimensions, const property_list &PropList) {
27  impl = std::make_shared<detail::image_impl>(
28  Order, Type, Range, Pitch, std::move(Allocator), Dimensions, PropList);
29 }
30 
32  image_channel_type Type, const range<3> &Range,
33  std::unique_ptr<SYCLMemObjAllocator> Allocator,
34  uint8_t Dimensions, const property_list &PropList) {
35  impl = std::make_shared<detail::image_impl>(HostPointer, Order, Type, Range,
36  std::move(Allocator), Dimensions,
37  PropList);
38 }
39 
40 image_plain::image_plain(const void *HostPointer, image_channel_order Order,
41  image_channel_type Type, const range<3> &Range,
42  std::unique_ptr<SYCLMemObjAllocator> Allocator,
43  uint8_t Dimensions, const property_list &PropList) {
44  impl = std::make_shared<detail::image_impl>(HostPointer, Order, Type, Range,
45  std::move(Allocator), Dimensions,
46  PropList);
47 }
48 
50  image_channel_type Type, const range<3> &Range,
51  const range<2> &Pitch,
52  std::unique_ptr<SYCLMemObjAllocator> Allocator,
53  uint8_t Dimensions, const property_list &PropList) {
54  impl = std::make_shared<detail::image_impl>(HostPointer, Order, Type, Range,
55  Pitch, std::move(Allocator),
56  Dimensions, PropList);
57 }
58 
59 image_plain::image_plain(const std::shared_ptr<const void> &HostPointer,
61  const range<3> &Range,
62  std::unique_ptr<SYCLMemObjAllocator> Allocator,
63  uint8_t Dimensions, const property_list &PropList,
64  bool IsConstPtr) {
65  impl = std::make_shared<detail::image_impl>(HostPointer, Order, Type, Range,
66  std::move(Allocator), Dimensions,
67  PropList, IsConstPtr);
68 }
69 
70 image_plain::image_plain(const std::shared_ptr<const void> &HostPointer,
72  const range<3> &Range, const range<2> &Pitch,
73  std::unique_ptr<SYCLMemObjAllocator> Allocator,
74  uint8_t Dimensions, const property_list &PropList,
75  bool IsConstPtr) {
76  impl = std::make_shared<detail::image_impl>(HostPointer, Order, Type, Range,
77  Pitch, std::move(Allocator),
78  Dimensions, PropList, IsConstPtr);
79 }
80 
81 image_plain::image_plain(const void *HostPointer, image_channel_order Order,
82  image_channel_type Type, image_sampler Sampler,
83  const range<3> &Range,
84  std::unique_ptr<SYCLMemObjAllocator> Allocator,
85  uint8_t Dimensions, const property_list &PropList) {
86  impl = std::make_shared<detail::image_impl>(HostPointer, Order, Type, Sampler,
87  Range, std::move(Allocator),
88  Dimensions, PropList);
89 }
90 
91 image_plain::image_plain(const void *HostPointer, image_channel_order Order,
92  image_channel_type Type, image_sampler Sampler,
93  const range<3> &Range, const range<2> &Pitch,
94  std::unique_ptr<SYCLMemObjAllocator> Allocator,
95  uint8_t Dimensions, const property_list &PropList) {
96  impl = std::make_shared<detail::image_impl>(
97  HostPointer, Order, Type, Sampler, Range, Pitch, std::move(Allocator),
98  Dimensions, PropList);
99 }
100 
101 image_plain::image_plain(const std::shared_ptr<const void> &HostPointer,
103  image_sampler Sampler, const range<3> &Range,
104  std::unique_ptr<SYCLMemObjAllocator> Allocator,
105  uint8_t Dimensions, const property_list &PropList) {
106  impl = std::make_shared<detail::image_impl>(HostPointer, Order, Type, Sampler,
107  Range, std::move(Allocator),
108  Dimensions, PropList);
109 }
110 
111 image_plain::image_plain(const std::shared_ptr<const void> &HostPointer,
113  image_sampler Sampler, const range<3> &Range,
114  const range<2> &Pitch,
115  std::unique_ptr<SYCLMemObjAllocator> Allocator,
116  uint8_t Dimensions, const property_list &PropList) {
117  impl = std::make_shared<detail::image_impl>(
118  HostPointer, Order, Type, Sampler, Range, Pitch, std::move(Allocator),
119  Dimensions, PropList);
120 }
121 
122 #ifdef __SYCL_INTERNAL_API
123 image_plain::image_plain(cl_mem ClMemObject, const context &SyclContext,
124  event AvailableEvent,
125  std::unique_ptr<SYCLMemObjAllocator> Allocator,
126  uint8_t Dimensions) {
127  impl = std::make_shared<detail::image_impl>(ClMemObject, SyclContext,
128  AvailableEvent,
129  std::move(Allocator), Dimensions);
130 }
131 #endif
132 
133 image_plain::image_plain(pi_native_handle MemObject, const context &SyclContext,
134  event AvailableEvent,
135  std::unique_ptr<SYCLMemObjAllocator> Allocator,
136  uint8_t Dimensions, image_channel_order Order,
137  image_channel_type Type, bool OwnNativeHandle,
138  range<3> Range3WithOnes) {
139  impl = std::make_shared<detail::image_impl>(
140  MemObject, SyclContext, AvailableEvent, std::move(Allocator), Dimensions,
141  Order, Type, OwnNativeHandle, Range3WithOnes);
142 }
143 
144 #define __SYCL_PARAM_TRAITS_SPEC(param_type) \
145  template <> \
146  __SYCL_EXPORT bool image_plain::has_property<param_type>() const noexcept { \
147  return impl->has_property<param_type>(); \
148  }
149 #include <sycl/detail/properties_traits.def>
150 
151 #undef __SYCL_PARAM_TRAITS_SPEC
152 
153 #define __SYCL_PARAM_TRAITS_SPEC(param_type) \
154  template <> \
155  __SYCL_EXPORT param_type image_plain::get_property<param_type>() const { \
156  return impl->get_property<param_type>(); \
157  }
158 #include <sycl/detail/properties_traits.def>
159 
160 #undef __SYCL_PARAM_TRAITS_SPEC
161 
162 range<3> image_plain::get_range() const { return impl->get_range(); }
163 
164 range<2> image_plain::get_pitch() const { return impl->get_pitch(); }
165 
166 size_t image_plain::get_size() const noexcept { return impl->getSizeInBytes(); }
167 
168 size_t image_plain::get_count() const noexcept { return impl->get_count(); }
169 
170 void image_plain::set_final_data_internal() { impl->set_final_data(nullptr); }
171 
173  const std::function<void(const std::function<void(void *const Ptr)> &)>
174  &FinalDataFunc) {
175  impl->set_final_data(FinalDataFunc);
176 }
177 
178 void image_plain::set_write_back(bool NeedWriteBack) {
179  impl->set_write_back(NeedWriteBack);
180 }
181 
182 const std::unique_ptr<SYCLMemObjAllocator> &
184  return impl->get_allocator_internal();
185 }
186 
187 size_t image_plain::getElementSize() const { return impl->getElementSize(); }
188 
189 size_t image_plain::getRowPitch() const { return impl->getRowPitch(); }
190 
191 size_t image_plain::getSlicePitch() const { return impl->getSlicePitch(); }
192 
194  return impl->getSampler();
195 }
196 
198  return impl->getChannelOrder();
199 }
200 
202  return impl->getChannelType();
203 }
204 
206  const detail::code_location &CodeLoc, void *UserObj, const void *HostObj,
207  uint32_t Dim, size_t Range[3], image_format Format,
208  const image_sampler &Sampler) {
209  impl->sampledImageConstructorNotification(CodeLoc, UserObj, HostObj, Dim,
210  Range, Format, Sampler);
211 }
212 
214  impl->sampledImageDestructorNotification(UserObj);
215 }
216 
218  const detail::code_location &CodeLoc, void *UserObj, const void *HostObj,
219  uint32_t Dim, size_t Range[3], image_format Format) {
220  impl->unsampledImageConstructorNotification(CodeLoc, UserObj, HostObj, Dim,
221  Range, Format);
222 }
223 
225  impl->unsampledImageDestructorNotification(UserObj);
226 }
227 
228 } // namespace detail
229 } // namespace _V1
230 } // namespace sycl
The context class represents a SYCL context on which kernel functions may be executed.
Definition: context.hpp:50
size_t get_count() const noexcept
Definition: image.cpp:168
void unsampledImageConstructorNotification(const detail::code_location &CodeLoc, void *UserObj, const void *HostObj, uint32_t Dim, size_t Range[3], image_format Format)
Definition: image.cpp:217
range< 2 > get_pitch() const
Definition: image.cpp:164
size_t getElementSize() const
Definition: image.cpp:187
image_sampler getSampler() const noexcept
Definition: image.cpp:193
size_t getRowPitch() const
Definition: image.cpp:189
range< 3 > get_range() const
Definition: image.cpp:162
void set_write_back(bool flag)
Definition: image.cpp:178
std::shared_ptr< detail::image_impl > impl
Definition: image.hpp:303
const std::unique_ptr< SYCLMemObjAllocator > & get_allocator_internal() const
Definition: image.cpp:183
image_channel_order getChannelOrder() const
Definition: image.cpp:197
size_t getSlicePitch() const
Definition: image.cpp:191
void unsampledImageDestructorNotification(void *UserObj)
Definition: image.cpp:224
size_t get_size() const noexcept
Definition: image.cpp:166
image_channel_type getChannelType() const
Definition: image.cpp:201
void sampledImageConstructorNotification(const detail::code_location &CodeLoc, void *UserObj, const void *HostObj, uint32_t Dim, size_t Range[3], image_format Format, const image_sampler &Sampler)
Definition: image.cpp:205
image_plain(const std::shared_ptr< detail::image_impl > &Impl)
Definition: image.hpp:176
void sampledImageDestructorNotification(void *UserObj)
Definition: image.cpp:213
An event object can be used to synchronize memory transfers, enqueues of kernels and signaling barrie...
Definition: event.hpp:44
Objects of the property_list class are containers for the SYCL properties.
class __SYCL_EBO __SYCL_SPECIAL_CLASS Dimensions
image_channel_order
Definition: image.hpp:56
image_format
Definition: image.hpp:93
image_channel_type
Definition: image.hpp:74
Definition: access.hpp:18
uintptr_t pi_native_handle
Definition: pi.h:226
_Abi const simd< _Tp, _Abi > & noexcept
Definition: simd.hpp:1324