18 inline namespace _V1 {
20 #ifdef XPTI_ENABLE_INSTRUMENTATION
21 uint8_t GImageStreamID;
24 template <
typename Param>
27 return Value >= 1 &&
std::all_of(Devices.cbegin(), Devices.cend(),
28 [Value](
const device &Dev) {
29 return Value <= Dev.get_info<Param>();
33 template <
typename T,
typename... Args>
static bool checkAnyImpl(T) {
37 template <
typename ValT,
typename VarT,
typename... Args>
38 static bool checkAnyImpl(ValT Value, VarT Variant, Args... Arguments) {
39 return (Value == Variant) ? true :
checkAnyImpl(Value, Arguments...);
42 template <
typename T,
typename... Args>
43 static bool checkAny(
const T Value, Args... Arguments) {
69 assert(
false &&
"Unhandled image channel order");
88 Retval = 2 * NumChannels;
93 Retval = 4 * NumChannels;
106 assert(((Retval - 1) & Retval) == 0);
144 assert(
false &&
"Unhandled image_channel_order");
182 assert(
false &&
"Unhandled image_channel_order");
220 assert(
false &&
"Unhandled image_channel_order");
258 assert(
false &&
"Unhandled image_channel_order");
262 template <
typename T>
266 const PluginPtr &Plugin = Context->getPlugin();
268 pi::cast<sycl::detail::pi::PiMem>(InteropMemObject);
274 event AvailableEvent,
275 std::unique_ptr<SYCLMemObjAllocator> Allocator,
277 :
BaseT(MemObject, SyclContext,
std::move(AvailableEvent),
278 std::move(Allocator)),
281 pi::cast<sycl::detail::pi::PiMem>(BaseT::MInteropMemObject);
283 const PluginPtr &Plugin = Context->getPlugin();
285 &(BaseT::MSizeInBytes),
nullptr);
299 switch (MDimensions) {
312 event AvailableEvent,
313 std::unique_ptr<SYCLMemObjAllocator> Allocator,
317 :
BaseT(MemObject, SyclContext, OwnNativeHandle,
std::move(AvailableEvent),
321 MDimensions(
Dimensions), MRange(Range3WithOnes) {
332 bool HostPtrReadOnly =
false;
336 assert(checkImageDesc(Desc, Context, HostPtr) &&
337 "The check an image desc failed.");
340 assert(checkImageFormat(Format, Context) &&
341 "The check an image format failed.");
344 std::move(Context),
this, HostPtr, HostPtrReadOnly,
353 !checkImageValueRange<info::device::image2d_max_width>(
355 throw invalid_parameter_error(
356 "For a 1D/2D image/image array, the width must be a Value >= 1 and "
357 "<= info::device::image2d_max_width",
358 PI_ERROR_INVALID_VALUE);
361 !checkImageValueRange<info::device::image3d_max_width>(
363 throw invalid_parameter_error(
364 "For a 3D image, the width must be a Value >= 1 and <= "
365 "info::device::image3d_max_width",
366 PI_ERROR_INVALID_VALUE);
370 !checkImageValueRange<info::device::image2d_max_height>(
372 throw invalid_parameter_error(
"For a 2D image or image array, the height "
373 "must be a Value >= 1 and <= "
374 "info::device::image2d_max_height",
375 PI_ERROR_INVALID_VALUE);
378 !checkImageValueRange<info::device::image3d_max_height>(
380 throw invalid_parameter_error(
381 "For a 3D image, the heightmust be a Value >= 1 and <= "
382 "info::device::image3d_max_height",
383 PI_ERROR_INVALID_VALUE);
386 !checkImageValueRange<info::device::image3d_max_depth>(
388 throw invalid_parameter_error(
389 "For a 3D image, the depth must be a Value >= 1 and <= "
390 "info::device::image2d_max_depth",
391 PI_ERROR_INVALID_VALUE);
395 !checkImageValueRange<info::device::image_max_array_size>(
397 throw invalid_parameter_error(
398 "For a 1D and 2D image array, the array_size must be a "
399 "Value >= 1 and <= info::device::image_max_array_size.",
400 PI_ERROR_INVALID_VALUE);
403 throw invalid_parameter_error(
404 "The row_pitch must be 0 if host_ptr is nullptr.",
405 PI_ERROR_INVALID_VALUE);
408 throw invalid_parameter_error(
409 "The slice_pitch must be 0 if host_ptr is nullptr.",
410 PI_ERROR_INVALID_VALUE);
413 throw invalid_parameter_error(
"The mip_levels must be 0.",
414 PI_ERROR_INVALID_VALUE);
417 throw invalid_parameter_error(
"The num_samples must be 0.",
418 PI_ERROR_INVALID_VALUE);
420 if (
nullptr != Desc.
buffer)
421 throw invalid_parameter_error(
422 "The buffer must be nullptr, because SYCL does not support "
423 "image creation from memory objects.",
424 PI_ERROR_INVALID_VALUE);
429 bool image_impl::checkImageFormat(
439 throw invalid_parameter_error(
440 "CL_INTENSITY or CL_LUMINANCE format can only be used if channel "
441 "data type = CL_UNORM_INT8, CL_UNORM_INT16, CL_SNORM_INT8, "
442 "CL_SNORM_INT16, CL_HALF_FLOAT, or CL_FLOAT.",
443 PI_ERROR_INVALID_VALUE);
451 throw invalid_parameter_error(
452 "type = CL_UNORM_SHORT_565, CL_UNORM_SHORT_555 or "
453 "CL_UNORM_INT_101010."
454 "These channel types can only be used with CL_RGB or CL_RGBx channel "
456 PI_ERROR_INVALID_VALUE);
464 throw invalid_parameter_error(
465 "CL_ARGB, CL_BGRA, CL_ABGR These formats can only be used if "
466 "channel data type = CL_UNORM_INT8, CL_SNORM_INT8, CL_SIGNED_INT8 "
467 "or CL_UNSIGNED_INT8.",
468 PI_ERROR_INVALID_VALUE);
473 std::vector<device> image_impl::getDevices(
const ContextImplPtr Context) {
474 return Context->get_info<info::context::devices>();
482 UserObj, CodeLoc, HostObj, Dim, Range, (uint32_t)Format,
495 UserObj, CodeLoc, HostObj, Dim, Range, (uint32_t)Format);
The context class represents a SYCL context on which kernel functions may be executed.
static void * allocateMemImage(ContextImplPtr TargetContext, SYCLMemObjI *MemObj, void *UserPtr, bool HostPtrReadOnly, size_t Size, const sycl::detail::pi::PiMemImageDesc &Desc, const sycl::detail::pi::PiMemImageFormat &Format, const EventImplPtr &InteropEvent, const ContextImplPtr &InteropContext, const sycl::property_list &PropsList, sycl::detail::pi::PiEvent &OutEventToWait)
ContextImplPtr MInteropContext
size_t getSizeInBytes() const noexcept override
void determineHostPtr(const ContextImplPtr &Context, bool InitFromUserData, void *&HostPtr, bool &HostPtrReadOnly)
EventImplPtr MInteropEvent
static void sampledImageDestructorNotification(const void *)
static void unsampledImageDestructorNotification(const void *)
static void unsampledImageConstructorNotification(const void *, const detail::code_location &, const void *, uint32_t, size_t[3], uint32_t)
static void sampledImageConstructorNotification(const void *, const detail::code_location &, const void *, uint32_t, size_t[3], uint32_t, uint32_t, uint32_t, uint32_t)
void * allocateMem(ContextImplPtr Context, bool InitFromUserData, void *HostPtr, sycl::detail::pi::PiEvent &OutEventToWait) override
void unsampledImageConstructorNotification(const detail::code_location &CodeLoc, void *UserObj, const void *HostObj, uint32_t Dim, size_t Range[3], image_format Format)
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)
void sampledImageDestructorNotification(void *UserObj)
void unsampledImageDestructorNotification(void *UserObj)
image_impl(image_channel_order Order, image_channel_type Type, const range< 3 > &ImageRange, std::unique_ptr< SYCLMemObjAllocator > Allocator, uint8_t Dimensions, const property_list &PropList={})
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
An event object can be used to synchronize memory transfers, enqueues of kernels and signaling barrie...
uint8_t getImageElementSize(uint8_t NumChannels, image_channel_type Type)
sycl::detail::pi::PiMemImageChannelOrder convertChannelOrder(image_channel_order Order)
static bool checkAny(const T Value, Args... Arguments)
std::shared_ptr< sycl::detail::context_impl > ContextImplPtr
decltype(Obj::impl) getSyclObjImpl(const Obj &SyclObject)
static bool checkImageValueRange(const std::vector< device > &Devices, const size_t Value)
std::shared_ptr< plugin > PluginPtr
static bool checkAnyImpl(T)
static void getImageInfo(const ContextImplPtr Context, sycl::detail::pi::PiMemImageInfo Info, T &Dest, sycl::detail::pi::PiMem InteropMemObject)
sycl::detail::pi::PiMemImageChannelType convertChannelType(image_channel_type Type)
uint8_t getImageNumberChannels(image_channel_order Order)
std::shared_ptr< sycl::detail::context_impl > ContextImplPtr
class __SYCL_EBO __SYCL_SPECIAL_CLASS Dimensions
uintptr_t pi_native_handle
pi_result piMemImageGetInfo(pi_mem image, pi_image_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
@ PI_IMAGE_CHANNEL_TYPE_FLOAT
@ PI_IMAGE_CHANNEL_TYPE_UNORM_SHORT_565
@ PI_IMAGE_CHANNEL_TYPE_UNORM_INT8
@ PI_IMAGE_CHANNEL_TYPE_SIGNED_INT16
@ PI_IMAGE_CHANNEL_TYPE_SNORM_INT16
@ PI_IMAGE_CHANNEL_TYPE_UNSIGNED_INT8
@ PI_IMAGE_CHANNEL_TYPE_SIGNED_INT8
@ PI_IMAGE_CHANNEL_TYPE_UNORM_INT_101010
@ PI_IMAGE_CHANNEL_TYPE_UNSIGNED_INT32
@ PI_IMAGE_CHANNEL_TYPE_UNSIGNED_INT16
@ PI_IMAGE_CHANNEL_TYPE_SNORM_INT8
@ PI_IMAGE_CHANNEL_TYPE_UNORM_SHORT_555
@ PI_IMAGE_CHANNEL_TYPE_SIGNED_INT32
@ PI_IMAGE_CHANNEL_TYPE_HALF_FLOAT
@ PI_IMAGE_CHANNEL_TYPE_UNORM_INT16
pi_result piMemGetInfo(pi_mem mem, pi_mem_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
@ PI_IMAGE_INFO_SLICE_PITCH
@ PI_IMAGE_INFO_ROW_PITCH
@ PI_IMAGE_INFO_ELEMENT_SIZE
@ PI_IMAGE_CHANNEL_ORDER_RGB
@ PI_IMAGE_CHANNEL_ORDER_RA
@ PI_IMAGE_CHANNEL_ORDER_RGBA
@ PI_IMAGE_CHANNEL_ORDER_INTENSITY
@ PI_IMAGE_CHANNEL_ORDER_R
@ PI_IMAGE_CHANNEL_ORDER_ABGR
@ PI_IMAGE_CHANNEL_ORDER_RGBx
@ PI_IMAGE_CHANNEL_ORDER_RG
@ PI_IMAGE_CHANNEL_ORDER_BGRA
@ PI_IMAGE_CHANNEL_ORDER_Rx
@ PI_IMAGE_CHANNEL_ORDER_A
@ PI_IMAGE_CHANNEL_ORDER_sRGBA
@ PI_IMAGE_CHANNEL_ORDER_LUMINANCE
@ PI_IMAGE_CHANNEL_ORDER_RGx
@ PI_IMAGE_CHANNEL_ORDER_ARGB
@ PI_MEM_TYPE_IMAGE1D_ARRAY
@ PI_MEM_TYPE_IMAGE2D_ARRAY
bool all_of(const simd_mask< _Tp, _Abi > &) noexcept
addressing_mode addressing
coordinate_normalization_mode coordinate