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(ur_native_handle_t MemObject,
134  const context &SyclContext, 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 range<3> image_plain::get_range() const { return impl->get_range(); }
145 
146 range<2> image_plain::get_pitch() const { return impl->get_pitch(); }
147 
148 size_t image_plain::get_size() const noexcept { return impl->getSizeInBytes(); }
149 
150 size_t image_plain::get_count() const noexcept { return impl->get_count(); }
151 
152 void image_plain::set_final_data_internal() { impl->set_final_data(nullptr); }
153 
155  const std::function<void(const std::function<void(void *const Ptr)> &)>
156  &FinalDataFunc) {
157  impl->set_final_data(FinalDataFunc);
158 }
159 
160 void image_plain::set_write_back(bool NeedWriteBack) {
161  impl->set_write_back(NeedWriteBack);
162 }
163 
164 const std::unique_ptr<SYCLMemObjAllocator> &
166  return impl->get_allocator_internal();
167 }
168 
169 size_t image_plain::getElementSize() const { return impl->getElementSize(); }
170 
171 size_t image_plain::getRowPitch() const { return impl->getRowPitch(); }
172 
173 size_t image_plain::getSlicePitch() const { return impl->getSlicePitch(); }
174 
176  return impl->getSampler();
177 }
178 
180  return impl->getChannelOrder();
181 }
182 
184  return impl->getChannelType();
185 }
186 
188  const detail::code_location &CodeLoc, void *UserObj, const void *HostObj,
189  uint32_t Dim, size_t Range[3], image_format Format,
190  const image_sampler &Sampler) {
191  impl->sampledImageConstructorNotification(CodeLoc, UserObj, HostObj, Dim,
192  Range, Format, Sampler);
193 }
194 
196  impl->sampledImageDestructorNotification(UserObj);
197 }
198 
200  const detail::code_location &CodeLoc, void *UserObj, const void *HostObj,
201  uint32_t Dim, size_t Range[3], image_format Format) {
202  impl->unsampledImageConstructorNotification(CodeLoc, UserObj, HostObj, Dim,
203  Range, Format);
204 }
205 
207  impl->unsampledImageDestructorNotification(UserObj);
208 }
209 
211  return impl->getPropList();
212 }
213 
214 } // namespace detail
215 } // namespace _V1
216 } // 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:150
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:199
range< 2 > get_pitch() const
Definition: image.cpp:146
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
range< 3 > get_range() const
Definition: image.cpp:144
void set_write_back(bool flag)
Definition: image.cpp:160
std::shared_ptr< detail::image_impl > impl
Definition: image.hpp:307
const std::unique_ptr< SYCLMemObjAllocator > & get_allocator_internal() const
Definition: image.cpp:165
image_channel_order getChannelOrder() const
Definition: image.cpp:179
size_t getSlicePitch() const
Definition: image.cpp:173
void unsampledImageDestructorNotification(void *UserObj)
Definition: image.cpp:206
const property_list & getPropList() const
Definition: image.cpp:210
size_t get_size() const noexcept
Definition: image.cpp:148
image_channel_type getChannelType() const
Definition: image.cpp:183
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:187
image_plain(const std::shared_ptr< detail::image_impl > &Impl)
Definition: image.hpp:176
void sampledImageDestructorNotification(void *UserObj)
Definition: image.cpp:195
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
_Abi const simd< _Tp, _Abi > & noexcept
Definition: simd.hpp:1324