From 6491544fc7f96aec6fbee6c200c4f169091aa28e Mon Sep 17 00:00:00 2001 From: Przemek Malon Date: Thu, 13 Mar 2025 16:51:03 +0000 Subject: [PATCH 01/13] Add image memory and handle support queries This patch introduces two new SYCL queries for Bindless Images. `get_image_memory_support` returns a vector of supported image backing memory types for a device given an `image_descriptor. `get_image_handle_supported` returns a boolean indicating whether the device supports creation of either a `sampled_image_handle` or `unsampled_image_handle`, given an `image_descriptor` and image backing memory type. Some tests are updated to use these queries to filter out unsupported image properties, e.g. allocating `unorm` channel types on the LevelZero backend. --- .../sycl_ext_oneapi_bindless_images.asciidoc | 72 ++++ .../sycl/ext/oneapi/bindless_images.hpp | 83 +++++ .../ext/oneapi/bindless_images_memory.hpp | 6 + sycl/source/detail/bindless_images.cpp | 124 +++++++ .../bindless_images/3_channel_format.cpp | 27 +- .../dx12_interop/read_write_unsampled.cpp | 26 +- .../bindless_images/helpers/common.hpp | 12 + sycl/test-e2e/bindless_images/read_2D.cpp | 28 ++ .../bindless_images/read_norm_types.cpp | 18 + .../vulkan_interop/sampled_images.cpp | 39 +- sycl/test/abi/sycl_symbols_linux.dump | 6 + sycl/test/abi/sycl_symbols_windows.dump | 14 +- unified-runtime/include/ur_api.h | 196 ++++++++++ unified-runtime/include/ur_api_funcs.def | 4 + unified-runtime/include/ur_ddi.h | 37 ++ unified-runtime/include/ur_print.h | 52 +++ unified-runtime/include/ur_print.hpp | 187 ++++++++++ .../scripts/core/EXP-BINDLESS-IMAGES.rst | 14 + .../scripts/core/exp-bindless-images.yml | 104 ++++++ unified-runtime/scripts/core/registry.yml | 12 + .../source/adapters/cuda/image.cpp | 341 ++++++++++++++++++ .../source/adapters/cuda/image.hpp | 5 + .../adapters/cuda/ur_interface_loader.cpp | 9 + .../source/adapters/hip/device.cpp | 89 ++--- unified-runtime/source/adapters/hip/image.cpp | 198 ++++++++++ unified-runtime/source/adapters/hip/image.hpp | 5 + .../adapters/hip/ur_interface_loader.cpp | 9 + .../level_zero/helpers/image_helpers.cpp | 88 +++++ .../level_zero/helpers/image_helpers.hpp | 5 + .../source/adapters/level_zero/image.cpp | 81 +++++ .../level_zero/ur_interface_loader.cpp | 8 + .../level_zero/ur_interface_loader.hpp | 16 + .../source/adapters/level_zero/v2/api.cpp | 32 ++ .../source/adapters/mock/ur_mockddi.cpp | 246 +++++++++++++ .../source/adapters/native_cpu/image.cpp | 42 +++ .../native_cpu/ur_interface_loader.cpp | 9 + .../source/adapters/opencl/image.cpp | 42 +++ .../adapters/opencl/ur_interface_loader.cpp | 8 + .../loader/layers/tracing/ur_trcddi.cpp | 244 +++++++++++++ .../loader/layers/validation/ur_valddi.cpp | 254 +++++++++++++ unified-runtime/source/loader/loader.def.in | 8 + unified-runtime/source/loader/loader.map.in | 8 + unified-runtime/source/loader/ur_ldrddi.cpp | 174 +++++++++ unified-runtime/source/loader/ur_libapi.cpp | 173 +++++++++ unified-runtime/source/loader/ur_print.cpp | 36 ++ unified-runtime/source/ur_api.cpp | 139 +++++++ 46 files changed, 3234 insertions(+), 96 deletions(-) diff --git a/sycl/doc/extensions/experimental/sycl_ext_oneapi_bindless_images.asciidoc b/sycl/doc/extensions/experimental/sycl_ext_oneapi_bindless_images.asciidoc index 5c0c547edb1cf..de6138d60c8fd 100644 --- a/sycl/doc/extensions/experimental/sycl_ext_oneapi_bindless_images.asciidoc +++ b/sycl/doc/extensions/experimental/sycl_ext_oneapi_bindless_images.asciidoc @@ -259,6 +259,78 @@ type of the returned `image_descriptor` will be `image_type::standard`. Only array image types support more than one array layer. +==== Querying image support + +Not all devices support all combinations of image channel type, the number of +channels, the type of backing memory, and dimensionality. We provide functions +to query device support for the allocation and creation of images for a given +`image_descriptor` and the type of backing memory. + +===== Querying image memory support + +Before allocating memory for an image, the user may first query whether their +desired image backing memory type is supported by the device. + +The following query returns a vector of supported `image_memory_handle_type`s +based on the properties of a given `image_descriptor`. + +The `image_memory_handle_type::usm_pointer` relates to USM allocations, while +the `image_memory_handle_type::opaque_handle` relates to memory allocations of +the `image_mem_handle` type. + +If the returned vector is empty, this indicates that the device does not support +allocating or creating images for the specified `image_descriptor`. + +```cpp +namespace sycl::ext::oneapi::experimental { + +enum class image_memory_handle_type : /* unspecified */ { + usm_pointer, + opaque_handle +}; + +std::vector +get_image_memory_support(const image_descriptor &imageDescriptor, + const sycl::device &syclDevice, + const sycl::context &syclContext); + +std::vector +get_image_memory_support(const image_descriptor &imageDescriptor, + const sycl::queue &syclQueue); +} +``` + +===== Querying image handle support + +In order to query what types of image handles are supported for a combination +of a given `image_descriptor` and `image_memory_handle_type`, the user should +use the `get_image_handle_supported` query. + +The template parameter passed to this query should be either +`unsampled_image_handle` or `sampled_image_handle`. + +The boolean value returned from the query indicates whether the device supports +creating the given image handle type (sampled or unsampled) given the specified +`image_descriptor` and `image_memory_handle_type`. + +```cpp +namespace sycl::ext::oneapi::experimental { + +template +bool +get_image_handle_supported(const image_descriptor &imageDescriptor, + image_memory_handle_type imageMemoryHandleType, + const sycl::device &syclDevice, + const sycl::context &syclContext); + +template +bool +get_image_handle_supported(const image_descriptor &imageDescriptor, + image_memory_handle_type imageMemoryHandleType, + const sycl::queue &syclQueue); +} +``` + === Allocating image memory The process of creating an image is two-fold: diff --git a/sycl/include/sycl/ext/oneapi/bindless_images.hpp b/sycl/include/sycl/ext/oneapi/bindless_images.hpp index b83e01b0bba9f..671ecccf1a269 100644 --- a/sycl/include/sycl/ext/oneapi/bindless_images.hpp +++ b/sycl/include/sycl/ext/oneapi/bindless_images.hpp @@ -593,6 +593,89 @@ __SYCL_EXPORT unsigned int get_image_num_channels(const image_mem_handle memHandle, const sycl::queue &syclQueue); +/** + * @brief Returns a vector of image-backing memory types supported by the + * device for a given `image_descriptor`. If the returned vector is + * empty, it indicates that the device does not support allocating or + * creating images with the properties described in the + * `image_descriptor`. + * + * @param imageDescriptor Properties of the image we want to query support + * for. + * @param syclDevice The device in which we created our image memory handle + * @param syclContext The context in which we created our image memory handle + * @return List of supported image-backing memory types + */ +__SYCL_EXPORT std::vector +get_image_memory_support(const image_descriptor &imageDescriptor, + const sycl::device &syclDevice, + const sycl::context &syclContext); + +/** + * @brief Returns a vector of image-backing memory types supported by the + * device for a given `image_descriptor`. If the returned vector is + * empty, it indicates that the device does not support allocating or + * creating images with the properties described in the + * `image_descriptor`. + * + * @param imageDescriptor Properties of the image we want to query support + * for. + * @param syclQueue The device/context association for which we want to query + * image memory support. + * @return List of supported image-backing memory types + */ +__SYCL_EXPORT std::vector +get_image_memory_support(const image_descriptor &imageDescriptor, + const sycl::queue &syclQueue); + +/** + * @brief Returns `true` if the device supports creation of images of the + * ImageHandleType, given the combination of `image_descriptor` and + * `image_memory_handle_type`. + * + * @tparam ImageHandleType Either `sampled_image_handle` or + * `unsampled_image_handle`. + * @param imageDescriptor Properties of the image we want to query support + * for. + * @param imageMemoryHandleType Image memory handle type we want to query + * support for. + * @param syclDevice The device in which we want to query image handle + * support + * @param syclContext The context in which we want to query image handle + * support + * @return Boolean indicating support for image creation with the specified + * parameter. + */ + +template +__SYCL_EXPORT bool +get_image_handle_supported(const image_descriptor &imageDescriptor, + image_memory_handle_type imageMemoryHandleType, + const sycl::device &syclDevice, + const sycl::context &syclContext); + +/** + * @brief Returns `true` if the device supports creation of images of the + * ImageHandleType, given the combination of `image_descriptor` and + * `image_memory_handle_type`. + * + * @tparam ImageHandleType Either `sampled_image_handle` or + * `unsampled_image_handle` + * @param imageDescriptor Properties of the image we want to query support + * for. + * @param imageMemoryHandleType Image memory handle type we want to query + * support for. + * @param syclQueue The device/context association for which we want to query + * image handle support. + * @return Boolean indicating support for image creation with the specified + * parameter. + */ +template +__SYCL_EXPORT bool +get_image_handle_supported(const image_descriptor &imageDescriptor, + image_memory_handle_type imageMemoryHandleType, + const sycl::queue &syclQueue); + namespace detail { // is sycl::vec diff --git a/sycl/include/sycl/ext/oneapi/bindless_images_memory.hpp b/sycl/include/sycl/ext/oneapi/bindless_images_memory.hpp index da3e254036baa..74e16d0c27be3 100644 --- a/sycl/include/sycl/ext/oneapi/bindless_images_memory.hpp +++ b/sycl/include/sycl/ext/oneapi/bindless_images_memory.hpp @@ -107,6 +107,12 @@ enum image_copy_flags : unsigned int { DtoD = 2, }; +// The types of handles to image-backing memory +enum class image_memory_handle_type : unsigned int { + usm_pointer = 0, + opaque_handle = 1, +}; + } // namespace ext::oneapi::experimental } // namespace _V1 } // namespace sycl diff --git a/sycl/source/detail/bindless_images.cpp b/sycl/source/detail/bindless_images.cpp index 5ba0d16ebb67a..971ae11ccf071 100644 --- a/sycl/source/detail/bindless_images.cpp +++ b/sycl/source/detail/bindless_images.cpp @@ -904,6 +904,130 @@ get_image_num_channels(const image_mem_handle memHandle, syclQueue.get_context()); } +__SYCL_EXPORT std::vector +get_image_memory_support(const image_descriptor &imageDescriptor, + const sycl::device &syclDevice, + const sycl::context &syclContext) { + std::shared_ptr DevImpl = + sycl::detail::getSyclObjImpl(syclDevice); + std::shared_ptr CtxImpl = + sycl::detail::getSyclObjImpl(syclContext); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); + + ur_image_desc_t urDesc; + ur_image_format_t urFormat; + populate_ur_structs(imageDescriptor, urDesc, urFormat); + + bool supportsPointerAllocation = false; + Adapter->call< + sycl::errc::runtime, + sycl::detail::UrApiKind::urBindlessImagesGetImageMemoryPointerSupportExp>( + CtxImpl->getHandleRef(), DevImpl->getHandleRef(), &urDesc, &urFormat, + &supportsPointerAllocation); + + bool supportsOpaqueAllocation = false; + Adapter->call< + sycl::errc::runtime, + sycl::detail::UrApiKind::urBindlessImagesGetImageMemoryOpaqueSupportExp>( + CtxImpl->getHandleRef(), DevImpl->getHandleRef(), &urDesc, &urFormat, + &supportsOpaqueAllocation); + + std::vector supportedMemHandleTypes; + + if (supportsPointerAllocation) { + supportedMemHandleTypes.push_back(image_memory_handle_type::usm_pointer); + } + + if (supportsOpaqueAllocation) { + supportedMemHandleTypes.push_back(image_memory_handle_type::opaque_handle); + } + + return supportedMemHandleTypes; +} + +__SYCL_EXPORT std::vector +get_image_memory_support(const image_descriptor &imageDescriptor, + const sycl::queue &syclQueue) { + return get_image_memory_support(imageDescriptor, syclQueue.get_device(), + syclQueue.get_context()); +} + +template <> +__SYCL_EXPORT bool get_image_handle_supported( + const image_descriptor &imageDescriptor, + image_memory_handle_type imageMemoryHandleType, + const sycl::device &syclDevice, const sycl::context &syclContext) { + std::shared_ptr DevImpl = + sycl::detail::getSyclObjImpl(syclDevice); + std::shared_ptr CtxImpl = + sycl::detail::getSyclObjImpl(syclContext); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); + + ur_image_desc_t urDesc; + ur_image_format_t urFormat; + populate_ur_structs(imageDescriptor, urDesc, urFormat); + + const bool isOpaqueMemoryHandle = + (imageMemoryHandleType == image_memory_handle_type::opaque_handle); + + bool supportsUnsampledHandle = false; + Adapter->call( + CtxImpl->getHandleRef(), DevImpl->getHandleRef(), &urDesc, &urFormat, + isOpaqueMemoryHandle, &supportsUnsampledHandle); + + return supportsUnsampledHandle; +} + +template <> +__SYCL_EXPORT bool get_image_handle_supported( + const image_descriptor &imageDescriptor, + image_memory_handle_type imageMemoryHandleType, + const sycl::queue &syclQueue) { + return get_image_handle_supported( + imageDescriptor, imageMemoryHandleType, syclQueue.get_device(), + syclQueue.get_context()); +} + +template <> +__SYCL_EXPORT bool get_image_handle_supported( + const image_descriptor &imageDescriptor, + image_memory_handle_type imageMemoryHandleType, + const sycl::device &syclDevice, const sycl::context &syclContext) { + std::shared_ptr DevImpl = + sycl::detail::getSyclObjImpl(syclDevice); + std::shared_ptr CtxImpl = + sycl::detail::getSyclObjImpl(syclContext); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); + + ur_image_desc_t urDesc; + ur_image_format_t urFormat; + populate_ur_structs(imageDescriptor, urDesc, urFormat); + + const bool isOpaqueMemoryHandle = + (imageMemoryHandleType == image_memory_handle_type::opaque_handle); + + bool supportsSampledHandle = false; + Adapter->call< + sycl::errc::runtime, + sycl::detail::UrApiKind::urBindlessImagesGetImageSampledHandleSupportExp>( + CtxImpl->getHandleRef(), DevImpl->getHandleRef(), &urDesc, &urFormat, + isOpaqueMemoryHandle, &supportsSampledHandle); + + return supportsSampledHandle; +} + +template <> +__SYCL_EXPORT bool get_image_handle_supported( + const image_descriptor &imageDescriptor, + image_memory_handle_type imageMemoryHandleType, + const sycl::queue &syclQueue) { + return get_image_handle_supported( + imageDescriptor, imageMemoryHandleType, syclQueue.get_device(), + syclQueue.get_context()); +} + } // namespace ext::oneapi::experimental } // namespace _V1 } // namespace sycl diff --git a/sycl/test-e2e/bindless_images/3_channel_format.cpp b/sycl/test-e2e/bindless_images/3_channel_format.cpp index 7c502170bab11..62ae76adf32c3 100644 --- a/sycl/test-e2e/bindless_images/3_channel_format.cpp +++ b/sycl/test-e2e/bindless_images/3_channel_format.cpp @@ -13,6 +13,7 @@ #include #include +#include "helpers/common.hpp" #include // Uncomment to print additional test information @@ -45,14 +46,26 @@ int main() { syclexp::image_descriptor desc({width}, 3, sycl::image_channel_type::unsigned_int16); + // Verify ability to allocate the above image descriptor + if (!bindless_helpers::memoryAllocationSupported( + desc, syclexp::image_memory_handle_type::opaque_handle, q)) { + // We cannot allocate the opaque `image_mem` below + // Skip the test + if (ctxt.get_backend() == sycl::backend::ext_oneapi_cuda) { + std::cout << "CUDA doesn't support 3-channel formats. Skipping test.\n"; + } else { + std::cout << "Memory allocation unsupported. Skipping test.\n"; + } + return 0; + } + syclexp::image_mem imgMem(desc, dev, ctxt); q.ext_oneapi_copy(dataIn.data(), imgMem.get_handle(), desc); q.wait_and_throw(); - // Some backends don't support 3-channel formats - // We still try to create the image, - // but we expect it to fail with UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT + // Backends which do not support 3-channel formats will have been skipped + // with the check above. syclexp::unsampled_image_handle imgHandle = sycl::ext::oneapi::experimental::create_image(imgMem, desc, dev, ctxt); @@ -77,14 +90,6 @@ int main() { } catch (const sycl::exception &ex) { const std::string_view errMsg(ex.what()); - if (ctxt.get_backend() == sycl::backend::ext_oneapi_cuda) { - if (errMsg.find("UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT") != - std::string::npos) { - std::cout << "CUDA doesn't support 3-channel formats, test passed." - << std::endl; - return 0; - } - } std::cerr << "Unexpected SYCL exception: " << errMsg << "\n"; return 1; } catch (...) { diff --git a/sycl/test-e2e/bindless_images/dx12_interop/read_write_unsampled.cpp b/sycl/test-e2e/bindless_images/dx12_interop/read_write_unsampled.cpp index e00fd26271372..5961df933c6fc 100644 --- a/sycl/test-e2e/bindless_images/dx12_interop/read_write_unsampled.cpp +++ b/sycl/test-e2e/bindless_images/dx12_interop/read_write_unsampled.cpp @@ -1,9 +1,8 @@ // REQUIRES: aspect-ext_oneapi_bindless_images // REQUIRES: windows -// DEFINE: %{link-flags}=%if cl_options %{ /clang:-ld3d12 /clang:-ldxgi /clang:-ldxguid %} %else %{ -ld3d12 -ldxgi -ldxguid %} -// RUN: %{build} %{link-flags} -o %t.out %if target-spir %{ -DDISABLE_UNORM_TESTS %} -// RUN: %{run-unfiltered-devices} env NEOReadDebugKeys=1 UseBindlessMode=1 UseExternalAllocatorForSshAndDsh=1 %t.out +// DEFINE: %{link-flags}=%if cl_options %{ /clang:-ld3d12 /clang:-ldxgi /clang:-ldxguid %} %else %{ -ld3d12 -ldxgi -ldxguid %} RUN: %{build} +// %{link-flags} -o %t.out RUN: %{run-unfiltered-devices} env NEOReadDebugKeys=1 UseBindlessMode=1 UseExternalAllocatorForSshAndDsh=1 %t.out #pragma clang diagnostic ignored "-Waddress-of-temporary" @@ -696,8 +695,23 @@ template static bool runTest(DX12SYCLDevice &device, sycl::image_channel_type channelType, sycl::range globalSize, sycl::range localSize) { + + syclexp::image_descriptor syclImageDesc{m_globalSize, NChannels, + m_channelType}; + + // Verify ability to allocate the above image descriptor. + // E.g. LevelZero does not support `unorm` channel types. + if (!bindless_helpers::memoryAllocationSupported( + syclImageDesc, syclexp::image_memory_handle_type::opaque_handle, + m_device.getSyclQueue())) { + // We cannot allocate the image memory, skip the test. + std::cout << "Memory allocation unsupported. Skipping test.\n"; + return true; + } + DX12InteropTest interopTestInstance( device, channelType, globalSize, localSize); + interopTestInstance.initDX12Resources(); interopTestInstance.callSYCLKernel(); bool validated = interopTestInstance.validateOutput(); @@ -732,10 +746,8 @@ int main() { validated &= runTest<1, uint32_t, 1>(device, sycl::image_channel_type::unsigned_int32, globalSize1, localSize1); -#ifndef DISABLE_UNORM_TESTS validated &= runTest<1, uint8_t, 4>( device, sycl::image_channel_type::unorm_int8, globalSize1, localSize1); -#endif validated &= runTest<1, float, 1>(device, sycl::image_channel_type::fp32, globalSize1, localSize1); validated &= runTest<1, sycl::half, 2>(device, sycl::image_channel_type::fp16, @@ -753,10 +765,8 @@ int main() { validated &= runTest<2, uint32_t, 1>(device, sycl::image_channel_type::unsigned_int32, globalSize2[0], {16, 16}); -#ifndef DISABLE_UNORM_TESTS validated &= runTest<2, uint8_t, 4>( device, sycl::image_channel_type::unorm_int8, globalSize2[1], {16, 8}); -#endif validated &= runTest<2, float, 1>(device, sycl::image_channel_type::fp32, globalSize2[2], {16, 8}); validated &= runTest<2, sycl::half, 2>(device, sycl::image_channel_type::fp16, @@ -777,10 +787,8 @@ int main() { validated &= runTest<3, uint32_t, 1>(device, sycl::image_channel_type::unsigned_int32, globalSize3[0], {16, 16, 1}); -#ifndef DISABLE_UNORM_TESTS validated &= runTest<3, uint8_t, 4>( device, sycl::image_channel_type::unorm_int8, globalSize3[1], {16, 8, 2}); -#endif validated &= runTest<3, float, 1>(device, sycl::image_channel_type::fp32, globalSize3[2], {16, 8, 1}); validated &= runTest<3, sycl::half, 2>(device, sycl::image_channel_type::fp16, diff --git a/sycl/test-e2e/bindless_images/helpers/common.hpp b/sycl/test-e2e/bindless_images/helpers/common.hpp index 8a5096779181f..b46df6168b644 100644 --- a/sycl/test-e2e/bindless_images/helpers/common.hpp +++ b/sycl/test-e2e/bindless_images/helpers/common.hpp @@ -1,6 +1,7 @@ #pragma once #include #include +#include #include template @@ -17,6 +18,17 @@ std::ostream &operator<<(std::ostream &os, namespace bindless_helpers { +namespace syclexp = sycl::ext::oneapi::experimental; + +bool memoryAllocationSupported(syclexp::image_descriptor imgDesc, + syclexp::image_memory_handle_type memHandleType, + sycl::queue syclQueue) { + auto supportedMemTypes = + syclexp::get_image_memory_support(imgDesc, syclQueue); + return std::find(supportedMemTypes.begin(), supportedMemTypes.end(), + memHandleType) != supportedMemTypes.end(); +} + template static void printTestName(std::string name, sycl::range globalSize, sycl::range localSize) { diff --git a/sycl/test-e2e/bindless_images/read_2D.cpp b/sycl/test-e2e/bindless_images/read_2D.cpp index af0d02cd8c3e7..cfc2291ccd93e 100644 --- a/sycl/test-e2e/bindless_images/read_2D.cpp +++ b/sycl/test-e2e/bindless_images/read_2D.cpp @@ -6,6 +6,7 @@ #include #include +#include "helpers/common.hpp" #include // Uncomment to print additional test information @@ -40,10 +41,37 @@ int main() { {width, height}, 4, sycl::image_channel_type::fp32); try { + + // Verify ability to allocate the above image descriptor + if (!bindless_helpers::memoryAllocationSupported( + desc, + sycl::ext::oneapi::experimental::image_memory_handle_type:: + opaque_handle, + q)) { + // We cannot allocate the opaque `image_mem` below + std::cout << "Memory allocation unsupported. Skipping test.\n"; + return 1; + } + // Extension: allocate memory on device and create the handle sycl::ext::oneapi::experimental::image_mem imgMem0(desc, dev, ctxt); sycl::ext::oneapi::experimental::image_mem imgMem1(desc, dev, ctxt); + // Extension: verify ability to create the unsampled image handles below + bool supportedUnsampledHandle = + sycl::ext::oneapi::experimental::get_image_handle_supported< + sycl::ext::oneapi::experimental::unsampled_image_handle>( + desc, + sycl::ext::oneapi::experimental::image_memory_handle_type:: + opaque_handle, + q); + if (!supportedUnsampledHandle) { + // We cannot create the unsampled handles below + std::cout << "Unsampled image handle creation unsupported. Skipping " + "test.\n"; + return 1; + } + // Extension: create the image and return the handle sycl::ext::oneapi::experimental::unsampled_image_handle imgHandle1 = sycl::ext::oneapi::experimental::create_image(imgMem0, desc, dev, ctxt); diff --git a/sycl/test-e2e/bindless_images/read_norm_types.cpp b/sycl/test-e2e/bindless_images/read_norm_types.cpp index 9eec60c61178c..a29832271127c 100644 --- a/sycl/test-e2e/bindless_images/read_norm_types.cpp +++ b/sycl/test-e2e/bindless_images/read_norm_types.cpp @@ -43,6 +43,24 @@ bool run_test(sycl::range globalSize, sycl::range localSize) { syclexp::image_descriptor descOut(globalSize, NChannels, sycl::image_channel_type::fp32); + // Verify ability to allocate the descIn descriptor. + // The LevelZero device does not support unnormalized types. + if (!bindless_helpers::memoryAllocationSupported( + descIn, syclexp::image_memory_handle_type::opaque_handle, q)) { + // The device does not support allocating opaque memory or creating images + // from descIn. Skip the test. + std::cout << "Memory allocation unsupported. Skipping test.\n"; + return true; + } + if (NDims == 2 && + !bindless_helpers::memoryAllocationSupported( + descIn, syclexp::image_memory_handle_type::usm_pointer, q)) { + // The device does not support allocating usm memory or creating images + // from descIn. Skip the test. + std::cout << "Memory allocation unsupported. Skipping test.\n"; + return true; + } + syclexp::image_mem_handle imgMemIn = syclexp::alloc_image_mem(descIn, q); syclexp::image_mem_handle imgMemOut = syclexp::alloc_image_mem(descOut, q); diff --git a/sycl/test-e2e/bindless_images/vulkan_interop/sampled_images.cpp b/sycl/test-e2e/bindless_images/vulkan_interop/sampled_images.cpp index 8efe7ce1f4012..46b34eb6d482a 100644 --- a/sycl/test-e2e/bindless_images/vulkan_interop/sampled_images.cpp +++ b/sycl/test-e2e/bindless_images/vulkan_interop/sampled_images.cpp @@ -90,12 +90,12 @@ handles_t create_test_handles( template -bool run_sycl(sycl::range globalSize, sycl::range localSize, +bool run_sycl(sycl::queue syclQueue, sycl::range globalSize, + sycl::range localSize, InteropHandleT inputInteropMemHandle, InteropSemHandleT sycl_wait_semaphore_handle) { - sycl::device dev; - sycl::queue q(dev); - auto ctxt = q.get_context(); + auto dev = syclQueue.get_device(); + auto ctxt = syclQueue.get_context(); // Image descriptor - mapped to Vulkan image layout syclexp::image_descriptor desc(globalSize, NChannels, CType); @@ -134,13 +134,14 @@ bool run_sycl(sycl::range globalSize, sycl::range localSize, #ifdef TEST_SEMAPHORE_IMPORT // Extension: wait for imported semaphore - q.ext_oneapi_wait_external_semaphore(handles.sycl_wait_external_semaphore); + syclQueue.ext_oneapi_wait_external_semaphore( + handles.sycl_wait_external_semaphore); #endif std::vector out(numElems); try { sycl::buffer buf((VecType *)out.data(), outBufferRange); - q.submit([&](sycl::handler &cgh) { + syclQueue.submit([&](sycl::handler &cgh) { auto outAcc = buf.template get_access( cgh, outBufferRange); cgh.parallel_for( @@ -195,7 +196,7 @@ bool run_sycl(sycl::range globalSize, sycl::range localSize, } }); }); - q.wait_and_throw(); + syclQueue.wait_and_throw(); #ifdef TEST_SEMAPHORE_IMPORT syclexp::release_external_semaphore(handles.sycl_wait_external_semaphore, @@ -261,6 +262,27 @@ bool run_test(sycl::range dims, sycl::range localSize, uint32_t height = 1; uint32_t depth = 1; + sycl::queue syclQueue; + + // Skip `sycl::half` tests if fp16 is unsupported. + if constexpr (std::is_same_v) { + if (!syclQueue.get_device().has(sycl::aspect::fp16)) { + return true; + } + } + + // Verify SYCL device support for allocating/creating an image from the + // descriptor being tested. + // This test always maps to an `image_mem_handle` (opaque_handle). + syclexp::image_descriptor desc{dims, NChannels, CType}; + if (!bindless_helpers::memoryAllocationSupported( + desc, syclexp::image_memory_handle_type::opaque_handle, syclQueue)) { + // The device does not support allocating/creating the image with the given + // properties. Skip the test. + std::cout << "Memory allocation unsupported. Skipping test.\n"; + return true; + } + size_t numElems = dims[0]; VkImageType imgType = VK_IMAGE_TYPE_1D; @@ -449,7 +471,8 @@ bool run_test(sycl::range dims, sycl::range localSize, bool validated = run_sycl( - dims, localSize, input_mem_handle, sycl_wait_semaphore_handle); + syclQueue, dims, localSize, input_mem_handle, + sycl_wait_semaphore_handle); // Cleanup vkDestroyBuffer(vk_device, inputStagingBuffer, nullptr); diff --git a/sycl/test/abi/sycl_symbols_linux.dump b/sycl/test/abi/sycl_symbols_linux.dump index bbbe31d702d51..e14102cf72534 100644 --- a/sycl/test/abi/sycl_symbols_linux.dump +++ b/sycl/test/abi/sycl_symbols_linux.dump @@ -3047,6 +3047,8 @@ _ZN4sycl3_V13ext6oneapi12experimental23prepare_for_device_copyEPKvmRKNS0_5queueE _ZN4sycl3_V13ext6oneapi12experimental23prepare_for_device_copyEPKvmRKNS0_7contextE _ZN4sycl3_V13ext6oneapi12experimental23release_external_memoryENS3_12external_memERKNS0_5queueE _ZN4sycl3_V13ext6oneapi12experimental23release_external_memoryENS3_12external_memERKNS0_6deviceERKNS0_7contextE +_ZN4sycl3_V13ext6oneapi12experimental24get_image_memory_supportERKNS3_16image_descriptorERKNS0_5queueE +_ZN4sycl3_V13ext6oneapi12experimental24get_image_memory_supportERKNS3_16image_descriptorERKNS0_6deviceERKNS0_7contextE _ZN4sycl3_V13ext6oneapi12experimental24get_mip_level_mem_handleENS3_16image_mem_handleEjRKNS0_5queueE _ZN4sycl3_V13ext6oneapi12experimental24get_mip_level_mem_handleENS3_16image_mem_handleEjRKNS0_6deviceERKNS0_7contextE _ZN4sycl3_V13ext6oneapi12experimental24release_from_device_copyEPKvRKNS0_5queueE @@ -3057,6 +3059,10 @@ _ZN4sycl3_V13ext6oneapi12experimental25import_external_semaphoreINS3_21resource_ _ZN4sycl3_V13ext6oneapi12experimental25import_external_semaphoreINS3_21resource_win32_handleEEENS3_18external_semaphoreENS3_29external_semaphore_descriptorIT_EERKNS0_6deviceERKNS0_7contextE _ZN4sycl3_V13ext6oneapi12experimental25map_external_image_memoryENS3_12external_memERKNS3_16image_descriptorERKNS0_5queueE _ZN4sycl3_V13ext6oneapi12experimental25map_external_image_memoryENS3_12external_memERKNS3_16image_descriptorERKNS0_6deviceERKNS0_7contextE +_ZN4sycl3_V13ext6oneapi12experimental26get_image_handle_supportedINS3_20sampled_image_handleEEEbRKNS3_16image_descriptorENS3_24image_memory_handle_typeERKNS0_5queueE +_ZN4sycl3_V13ext6oneapi12experimental26get_image_handle_supportedINS3_20sampled_image_handleEEEbRKNS3_16image_descriptorENS3_24image_memory_handle_typeERKNS0_6deviceERKNS0_7contextE +_ZN4sycl3_V13ext6oneapi12experimental26get_image_handle_supportedINS3_22unsampled_image_handleEEEbRKNS3_16image_descriptorENS3_24image_memory_handle_typeERKNS0_5queueE +_ZN4sycl3_V13ext6oneapi12experimental26get_image_handle_supportedINS3_22unsampled_image_handleEEEbRKNS3_16image_descriptorENS3_24image_memory_handle_typeERKNS0_6deviceERKNS0_7contextE _ZN4sycl3_V13ext6oneapi12experimental26map_external_linear_memoryENS3_12external_memEmmRKNS0_5queueE _ZN4sycl3_V13ext6oneapi12experimental26map_external_linear_memoryENS3_12external_memEmmRKNS0_6deviceERKNS0_7contextE _ZN4sycl3_V13ext6oneapi12experimental26release_external_semaphoreENS3_18external_semaphoreERKNS0_5queueE diff --git a/sycl/test/abi/sycl_symbols_windows.dump b/sycl/test/abi/sycl_symbols_windows.dump index ff747fcc07346..6f804a0c38049 100644 --- a/sycl/test/abi/sycl_symbols_windows.dump +++ b/sycl/test/abi/sycl_symbols_windows.dump @@ -44,6 +44,10 @@ ??$get_backend_info@Uversion@platform@info@_V1@sycl@@@kernel@_V1@sycl@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ ??$get_backend_info@Uversion@platform@info@_V1@sycl@@@platform@_V1@sycl@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ ??$get_backend_info@Uversion@platform@info@_V1@sycl@@@queue@_V1@sycl@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ +??$get_image_handle_supported@Usampled_image_handle@experimental@oneapi@ext@_V1@sycl@@@experimental@oneapi@ext@_V1@sycl@@YA_NAEBUimage_descriptor@01234@W4image_memory_handle_type@01234@AEBVdevice@34@AEBVcontext@34@@Z +??$get_image_handle_supported@Usampled_image_handle@experimental@oneapi@ext@_V1@sycl@@@experimental@oneapi@ext@_V1@sycl@@YA_NAEBUimage_descriptor@01234@W4image_memory_handle_type@01234@AEBVqueue@34@@Z +??$get_image_handle_supported@Uunsampled_image_handle@experimental@oneapi@ext@_V1@sycl@@@experimental@oneapi@ext@_V1@sycl@@YA_NAEBUimage_descriptor@01234@W4image_memory_handle_type@01234@AEBVdevice@34@AEBVcontext@34@@Z +??$get_image_handle_supported@Uunsampled_image_handle@experimental@oneapi@ext@_V1@sycl@@@experimental@oneapi@ext@_V1@sycl@@YA_NAEBUimage_descriptor@01234@W4image_memory_handle_type@01234@AEBVqueue@34@@Z ??$get_info@U?$max_work_groups@$00@device@info@experimental@oneapi@ext@_V1@sycl@@@device_impl@detail@_V1@sycl@@QEBA?AV?$id@$00@23@XZ ??$get_info@U?$max_work_groups@$01@device@info@experimental@oneapi@ext@_V1@sycl@@@device_impl@detail@_V1@sycl@@QEBA?AV?$id@$01@23@XZ ??$get_info@U?$max_work_groups@$02@device@info@experimental@oneapi@ext@_V1@sycl@@@device_impl@detail@_V1@sycl@@QEBA?AV?$id@$02@23@XZ @@ -354,7 +358,9 @@ ??0dynamic_command_group@experimental@oneapi@ext@_V1@sycl@@QEAA@AEBV?$command_graph@$0A@@12345@AEBV?$vector@V?$function@$$A6AXAEAVhandler@_V1@sycl@@@Z@std@@V?$allocator@V?$function@$$A6AXAEAVhandler@_V1@sycl@@@Z@std@@@2@@std@@@Z ??0dynamic_parameter_base@detail@experimental@oneapi@ext@_V1@sycl@@QEAA@$$QEAV0123456@@Z ??0dynamic_parameter_base@detail@experimental@oneapi@ext@_V1@sycl@@QEAA@AEBV0123456@@Z +??0dynamic_parameter_base@detail@experimental@oneapi@ext@_V1@sycl@@QEAA@V?$command_graph@$0A@@23456@@Z ??0dynamic_parameter_base@detail@experimental@oneapi@ext@_V1@sycl@@QEAA@V?$command_graph@$0A@@23456@_KPEBX@Z +??0dynamic_parameter_base@detail@experimental@oneapi@ext@_V1@sycl@@QEAA@XZ ??0event@_V1@sycl@@AEAA@V?$shared_ptr@Vevent_impl@detail@_V1@sycl@@@std@@@Z ??0event@_V1@sycl@@QEAA@$$QEAV012@@Z ??0event@_V1@sycl@@QEAA@AEBV012@@Z @@ -505,14 +511,10 @@ ??1exception@_V1@sycl@@UEAA@XZ ??1exception_list@_V1@sycl@@QEAA@XZ ??1executable_command_graph@detail@experimental@oneapi@ext@_V1@sycl@@QEAA@XZ -??0dynamic_parameter_base@detail@experimental@oneapi@ext@_V1@sycl@@QEAA@V?$command_graph@$0A@@23456@@Z -?updateWorkGroupMem@dynamic_parameter_base@detail@experimental@oneapi@ext@_V1@sycl@@IEAAX_K@Z ??1filter_selector@ONEAPI@_V1@sycl@@UEAA@XZ ??1filter_selector@oneapi@ext@_V1@sycl@@UEAA@XZ ??1fusion_wrapper@experimental@codeplay@ext@_V1@sycl@@QEAA@XZ ??1gpu_selector@_V1@sycl@@UEAA@XZ -??0dynamic_parameter_base@detail@experimental@oneapi@ext@_V1@sycl@@QEAA@XZ -?setArgHelper@handler@_V1@sycl@@AEAAXHAEAVdynamic_work_group_memory_base@detail@experimental@oneapi@ext@23@@Z ??1handler@_V1@sycl@@AEAA@XZ ??1image_mem@experimental@oneapi@ext@_V1@sycl@@QEAA@XZ ??1image_mem_impl@detail@experimental@oneapi@ext@_V1@sycl@@QEAA@XZ @@ -4136,6 +4138,8 @@ ?get_handle@image_mem@experimental@oneapi@ext@_V1@sycl@@QEBA?AUimage_mem_handle@23456@XZ ?get_image_channel_type@experimental@oneapi@ext@_V1@sycl@@YA?AW4image_channel_type@45@Uimage_mem_handle@12345@AEBVdevice@45@AEBVcontext@45@@Z ?get_image_channel_type@experimental@oneapi@ext@_V1@sycl@@YA?AW4image_channel_type@45@Uimage_mem_handle@12345@AEBVqueue@45@@Z +?get_image_memory_support@experimental@oneapi@ext@_V1@sycl@@YA?AV?$vector@W4image_memory_handle_type@experimental@oneapi@ext@_V1@sycl@@V?$allocator@W4image_memory_handle_type@experimental@oneapi@ext@_V1@sycl@@@std@@@std@@AEBUimage_descriptor@12345@AEBVdevice@45@AEBVcontext@45@@Z +?get_image_memory_support@experimental@oneapi@ext@_V1@sycl@@YA?AV?$vector@W4image_memory_handle_type@experimental@oneapi@ext@_V1@sycl@@V?$allocator@W4image_memory_handle_type@experimental@oneapi@ext@_V1@sycl@@@std@@@std@@AEBUimage_descriptor@12345@AEBVqueue@45@@Z ?get_image_num_channels@experimental@oneapi@ext@_V1@sycl@@YAIUimage_mem_handle@12345@AEBVdevice@45@AEBVcontext@45@@Z ?get_image_num_channels@experimental@oneapi@ext@_V1@sycl@@YAIUimage_mem_handle@12345@AEBVqueue@45@@Z ?get_image_range@experimental@oneapi@ext@_V1@sycl@@YA?AV?$range@$02@45@Uimage_mem_handle@12345@AEBVdevice@45@AEBVcontext@45@@Z @@ -4346,6 +4350,7 @@ ?select_device@filter_selector@oneapi@ext@_V1@sycl@@UEBA?AVdevice@45@XZ ?setArgHelper@handler@_V1@sycl@@AEAAXH$$QEAVraw_kernel_arg@experimental@oneapi@ext@23@@Z ?setArgHelper@handler@_V1@sycl@@AEAAXH$$QEAVsampler@23@@Z +?setArgHelper@handler@_V1@sycl@@AEAAXHAEAVdynamic_work_group_memory_base@detail@experimental@oneapi@ext@23@@Z ?setArgHelper@handler@_V1@sycl@@AEAAXHAEAVwork_group_memory_impl@detail@23@@Z ?setArgsHelper@handler@_V1@sycl@@AEAAXH@Z ?setArgsToAssociatedAccessors@handler@_V1@sycl@@AEAAXXZ @@ -4421,6 +4426,7 @@ ?updateAccessor@dynamic_parameter_base@detail@experimental@oneapi@ext@_V1@sycl@@IEAAXPEBVAccessorBaseHost@267@@Z ?updateValue@dynamic_parameter_base@detail@experimental@oneapi@ext@_V1@sycl@@IEAAXPEBVraw_kernel_arg@34567@_K@Z ?updateValue@dynamic_parameter_base@detail@experimental@oneapi@ext@_V1@sycl@@IEAAXPEBX_K@Z +?updateWorkGroupMem@dynamic_parameter_base@detail@experimental@oneapi@ext@_V1@sycl@@IEAAX_K@Z ?use_kernel_bundle@handler@_V1@sycl@@QEAAXAEBV?$kernel_bundle@$01@23@@Z ?verifyDeviceHasProgressGuarantee@handler@_V1@sycl@@AEAAXW4forward_progress_guarantee@experimental@oneapi@ext@23@W4execution_scope@56723@1@Z ?verifyReductionProps@detail@_V1@sycl@@YAXAEBVproperty_list@23@@Z diff --git a/unified-runtime/include/ur_api.h b/unified-runtime/include/ur_api.h index b50a56f903f28..e72f486f2ea21 100644 --- a/unified-runtime/include/ur_api.h +++ b/unified-runtime/include/ur_api.h @@ -457,6 +457,14 @@ typedef enum ur_function_t { UR_FUNCTION_COMMAND_BUFFER_GET_NATIVE_HANDLE_EXP = 264, /// Enumerator for ::urUSMPoolSetInfoExp UR_FUNCTION_USM_POOL_SET_INFO_EXP = 265, + /// Enumerator for ::urBindlessImagesGetImageMemoryPointerSupportExp + UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_POINTER_SUPPORT_EXP = 266, + /// Enumerator for ::urBindlessImagesGetImageMemoryOpaqueSupportExp + UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_OPAQUE_SUPPORT_EXP = 267, + /// Enumerator for ::urBindlessImagesGetImageUnsampledHandleSupportExp + UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_UNSAMPLED_HANDLE_SUPPORT_EXP = 268, + /// Enumerator for ::urBindlessImagesGetImageSampledHandleSupportExp + UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_SAMPLED_HANDLE_SUPPORT_EXP = 269, /// @cond UR_FUNCTION_FORCE_UINT32 = 0x7fffffff /// @endcond @@ -10081,6 +10089,137 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( /// [out][optional] returned query value size size_t *pPropSizeRet); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Query support for allocating pointer handle type image memory with +/// specific image properties +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hContext` +/// + `NULL == hDevice` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pImageDesc` +/// + `NULL == pImageFormat` +/// + `NULL == pSupportedRet` +/// - ::UR_RESULT_ERROR_INVALID_DEVICE +UR_APIEXPORT ur_result_t UR_APICALL +urBindlessImagesGetImageMemoryPointerSupportExp( + /// [in] handle of the context object + ur_context_handle_t hContext, + /// [in] handle of the device object + ur_device_handle_t hDevice, + /// [in] pointer to image description + const ur_image_desc_t *pImageDesc, + /// [in] pointer to image format specification + const ur_image_format_t *pImageFormat, + /// [out] returned indication of support for allocating USM style memory + bool *pSupportedRet); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Query support for allocating opaque handle type image memory with +/// specific image properties +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hContext` +/// + `NULL == hDevice` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pImageDesc` +/// + `NULL == pImageFormat` +/// + `NULL == pSupportedRet` +/// - ::UR_RESULT_ERROR_INVALID_DEVICE +UR_APIEXPORT ur_result_t UR_APICALL +urBindlessImagesGetImageMemoryOpaqueSupportExp( + /// [in] handle of the context object + ur_context_handle_t hContext, + /// [in] handle of the device object + ur_device_handle_t hDevice, + /// [in] pointer to image description + const ur_image_desc_t *pImageDesc, + /// [in] pointer to image format specification + const ur_image_format_t *pImageFormat, + /// [out] returned indication of support for allocating opaque handle + /// memory + bool *pSupportedRet); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Query support for creating an unsampled image handle with specific +/// image properties +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hContext` +/// + `NULL == hDevice` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pImageDesc` +/// + `NULL == pImageFormat` +/// + `NULL == pSupportedRet` +/// - ::UR_RESULT_ERROR_INVALID_DEVICE +/// - ::UR_RESULT_ERROR_INVALID_CONTEXT +UR_APIEXPORT ur_result_t UR_APICALL +urBindlessImagesGetImageUnsampledHandleSupportExp( + /// [in] handle of the context object + ur_context_handle_t hContext, + /// [in] handle of the device object + ur_device_handle_t hDevice, + /// [in] pointer to image description + const ur_image_desc_t *pImageDesc, + /// [in] pointer to image format specification + const ur_image_format_t *pImageFormat, + /// [in] indicates whether the image memory would be backed by an opaque + /// handle allocation + bool isOpaqueAllocation, + /// [out] returned indication of support for creating unsampled image + /// handles + bool *pSupportedRet); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Query support for creating an unsampled image handle with specific +/// image properties +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hContext` +/// + `NULL == hDevice` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pImageDesc` +/// + `NULL == pImageFormat` +/// + `NULL == pSupportedRet` +/// - ::UR_RESULT_ERROR_INVALID_DEVICE +/// - ::UR_RESULT_ERROR_INVALID_CONTEXT +UR_APIEXPORT ur_result_t UR_APICALL +urBindlessImagesGetImageSampledHandleSupportExp( + /// [in] handle of the context object + ur_context_handle_t hContext, + /// [in] handle of the device object + ur_device_handle_t hDevice, + /// [in] pointer to image description + const ur_image_desc_t *pImageDesc, + /// [in] pointer to image format specification + const ur_image_format_t *pImageFormat, + /// [in] indicates whether the image memory would be backed by an opaque + /// handle allocation + bool isOpaqueAllocation, + /// [out] returned indication of support for creating sampled image + /// handles + bool *pSupportedRet); + /////////////////////////////////////////////////////////////////////////////// /// @brief Retrieve individual image from mipmap /// @@ -14531,6 +14670,63 @@ typedef struct ur_bindless_images_image_get_info_exp_params_t { size_t **ppPropSizeRet; } ur_bindless_images_image_get_info_exp_params_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for +/// urBindlessImagesGetImageMemoryPointerSupportExp +/// @details Each entry is a pointer to the parameter passed to the function; +/// allowing the callback the ability to modify the parameter's value +typedef struct + ur_bindless_images_get_image_memory_pointer_support_exp_params_t { + ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; + const ur_image_desc_t **ppImageDesc; + const ur_image_format_t **ppImageFormat; + bool **ppSupportedRet; +} ur_bindless_images_get_image_memory_pointer_support_exp_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for +/// urBindlessImagesGetImageMemoryOpaqueSupportExp +/// @details Each entry is a pointer to the parameter passed to the function; +/// allowing the callback the ability to modify the parameter's value +typedef struct ur_bindless_images_get_image_memory_opaque_support_exp_params_t { + ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; + const ur_image_desc_t **ppImageDesc; + const ur_image_format_t **ppImageFormat; + bool **ppSupportedRet; +} ur_bindless_images_get_image_memory_opaque_support_exp_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for +/// urBindlessImagesGetImageUnsampledHandleSupportExp +/// @details Each entry is a pointer to the parameter passed to the function; +/// allowing the callback the ability to modify the parameter's value +typedef struct + ur_bindless_images_get_image_unsampled_handle_support_exp_params_t { + ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; + const ur_image_desc_t **ppImageDesc; + const ur_image_format_t **ppImageFormat; + bool *pisOpaqueAllocation; + bool **ppSupportedRet; +} ur_bindless_images_get_image_unsampled_handle_support_exp_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for +/// urBindlessImagesGetImageSampledHandleSupportExp +/// @details Each entry is a pointer to the parameter passed to the function; +/// allowing the callback the ability to modify the parameter's value +typedef struct + ur_bindless_images_get_image_sampled_handle_support_exp_params_t { + ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; + const ur_image_desc_t **ppImageDesc; + const ur_image_format_t **ppImageFormat; + bool *pisOpaqueAllocation; + bool **ppSupportedRet; +} ur_bindless_images_get_image_sampled_handle_support_exp_params_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief Function parameters for urBindlessImagesMipmapGetLevelExp /// @details Each entry is a pointer to the parameter passed to the function; diff --git a/unified-runtime/include/ur_api_funcs.def b/unified-runtime/include/ur_api_funcs.def index de3e0a5e38d92..58eddf0b89123 100644 --- a/unified-runtime/include/ur_api_funcs.def +++ b/unified-runtime/include/ur_api_funcs.def @@ -168,6 +168,10 @@ _UR_API(urBindlessImagesUnsampledImageCreateExp) _UR_API(urBindlessImagesSampledImageCreateExp) _UR_API(urBindlessImagesImageCopyExp) _UR_API(urBindlessImagesImageGetInfoExp) +_UR_API(urBindlessImagesGetImageMemoryPointerSupportExp) +_UR_API(urBindlessImagesGetImageMemoryOpaqueSupportExp) +_UR_API(urBindlessImagesGetImageUnsampledHandleSupportExp) +_UR_API(urBindlessImagesGetImageSampledHandleSupportExp) _UR_API(urBindlessImagesMipmapGetLevelExp) _UR_API(urBindlessImagesMipmapFreeExp) _UR_API(urBindlessImagesImportExternalMemoryExp) diff --git a/unified-runtime/include/ur_ddi.h b/unified-runtime/include/ur_ddi.h index 68dc0a265d284..b7abbae0d52e6 100644 --- a/unified-runtime/include/ur_ddi.h +++ b/unified-runtime/include/ur_ddi.h @@ -1444,6 +1444,35 @@ typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImageGetInfoExp_t)( ur_context_handle_t, ur_exp_image_mem_native_handle_t, ur_image_info_t, void *, size_t *); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urBindlessImagesGetImageMemoryPointerSupportExp +typedef ur_result_t( + UR_APICALL *ur_pfnBindlessImagesGetImageMemoryPointerSupportExp_t)( + ur_context_handle_t, ur_device_handle_t, const ur_image_desc_t *, + const ur_image_format_t *, bool *); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urBindlessImagesGetImageMemoryOpaqueSupportExp +typedef ur_result_t( + UR_APICALL *ur_pfnBindlessImagesGetImageMemoryOpaqueSupportExp_t)( + ur_context_handle_t, ur_device_handle_t, const ur_image_desc_t *, + const ur_image_format_t *, bool *); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for +/// urBindlessImagesGetImageUnsampledHandleSupportExp +typedef ur_result_t( + UR_APICALL *ur_pfnBindlessImagesGetImageUnsampledHandleSupportExp_t)( + ur_context_handle_t, ur_device_handle_t, const ur_image_desc_t *, + const ur_image_format_t *, bool, bool *); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urBindlessImagesGetImageSampledHandleSupportExp +typedef ur_result_t( + UR_APICALL *ur_pfnBindlessImagesGetImageSampledHandleSupportExp_t)( + ur_context_handle_t, ur_device_handle_t, const ur_image_desc_t *, + const ur_image_format_t *, bool, bool *); + /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urBindlessImagesMipmapGetLevelExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesMipmapGetLevelExp_t)( @@ -1520,6 +1549,14 @@ typedef struct ur_bindless_images_exp_dditable_t { ur_pfnBindlessImagesSampledImageCreateExp_t pfnSampledImageCreateExp; ur_pfnBindlessImagesImageCopyExp_t pfnImageCopyExp; ur_pfnBindlessImagesImageGetInfoExp_t pfnImageGetInfoExp; + ur_pfnBindlessImagesGetImageMemoryPointerSupportExp_t + pfnGetImageMemoryPointerSupportExp; + ur_pfnBindlessImagesGetImageMemoryOpaqueSupportExp_t + pfnGetImageMemoryOpaqueSupportExp; + ur_pfnBindlessImagesGetImageUnsampledHandleSupportExp_t + pfnGetImageUnsampledHandleSupportExp; + ur_pfnBindlessImagesGetImageSampledHandleSupportExp_t + pfnGetImageSampledHandleSupportExp; ur_pfnBindlessImagesMipmapGetLevelExp_t pfnMipmapGetLevelExp; ur_pfnBindlessImagesMipmapFreeExp_t pfnMipmapFreeExp; ur_pfnBindlessImagesImportExternalMemoryExp_t pfnImportExternalMemoryExp; diff --git a/unified-runtime/include/ur_print.h b/unified-runtime/include/ur_print.h index d42a2eab16289..f395429991a78 100644 --- a/unified-runtime/include/ur_print.h +++ b/unified-runtime/include/ur_print.h @@ -3025,6 +3025,58 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesImageGetInfoExpParams( const struct ur_bindless_images_image_get_info_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print +/// ur_bindless_images_get_image_memory_pointer_support_exp_params_t struct +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +UR_APIEXPORT ur_result_t UR_APICALL +urPrintBindlessImagesGetImageMemoryPointerSupportExpParams( + const struct + ur_bindless_images_get_image_memory_pointer_support_exp_params_t *params, + char *buffer, const size_t buff_size, size_t *out_size); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_bindless_images_get_image_memory_opaque_support_exp_params_t +/// struct +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +UR_APIEXPORT ur_result_t UR_APICALL +urPrintBindlessImagesGetImageMemoryOpaqueSupportExpParams( + const struct ur_bindless_images_get_image_memory_opaque_support_exp_params_t + *params, + char *buffer, const size_t buff_size, size_t *out_size); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print +/// ur_bindless_images_get_image_unsampled_handle_support_exp_params_t struct +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +UR_APIEXPORT ur_result_t UR_APICALL +urPrintBindlessImagesGetImageUnsampledHandleSupportExpParams( + const struct + ur_bindless_images_get_image_unsampled_handle_support_exp_params_t *params, + char *buffer, const size_t buff_size, size_t *out_size); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print +/// ur_bindless_images_get_image_sampled_handle_support_exp_params_t struct +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +UR_APIEXPORT ur_result_t UR_APICALL +urPrintBindlessImagesGetImageSampledHandleSupportExpParams( + const struct + ur_bindless_images_get_image_sampled_handle_support_exp_params_t *params, + char *buffer, const size_t buff_size, size_t *out_size); + /////////////////////////////////////////////////////////////////////////////// /// @brief Print ur_bindless_images_mipmap_get_level_exp_params_t struct /// @returns diff --git a/unified-runtime/include/ur_print.hpp b/unified-runtime/include/ur_print.hpp index e97063011a4c3..1ff35a6dc617e 100644 --- a/unified-runtime/include/ur_print.hpp +++ b/unified-runtime/include/ur_print.hpp @@ -1234,6 +1234,18 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_function_t value) { case UR_FUNCTION_USM_POOL_SET_INFO_EXP: os << "UR_FUNCTION_USM_POOL_SET_INFO_EXP"; break; + case UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_POINTER_SUPPORT_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_POINTER_SUPPORT_EXP"; + break; + case UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_OPAQUE_SUPPORT_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_OPAQUE_SUPPORT_EXP"; + break; + case UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_UNSAMPLED_HANDLE_SUPPORT_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_UNSAMPLED_HANDLE_SUPPORT_EXP"; + break; + case UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_SAMPLED_HANDLE_SUPPORT_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_SAMPLED_HANDLE_SUPPORT_EXP"; + break; default: os << "unknown enumerator"; break; @@ -18138,6 +18150,161 @@ inline std::ostream &operator<<( return os; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the +/// ur_bindless_images_get_image_memory_pointer_support_exp_params_t type +/// @returns +/// std::ostream & +inline std::ostream &operator<<( + std::ostream &os, [[maybe_unused]] const struct + ur_bindless_images_get_image_memory_pointer_support_exp_params_t *params) { + + os << ".hContext = "; + + ur::details::printPtr(os, *(params->phContext)); + + os << ", "; + os << ".hDevice = "; + + ur::details::printPtr(os, *(params->phDevice)); + + os << ", "; + os << ".pImageDesc = "; + + ur::details::printPtr(os, *(params->ppImageDesc)); + + os << ", "; + os << ".pImageFormat = "; + + ur::details::printPtr(os, *(params->ppImageFormat)); + + os << ", "; + os << ".pSupportedRet = "; + + ur::details::printPtr(os, *(params->ppSupportedRet)); + + return os; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the +/// ur_bindless_images_get_image_memory_opaque_support_exp_params_t type +/// @returns +/// std::ostream & +inline std::ostream &operator<<( + std::ostream &os, [[maybe_unused]] const struct + ur_bindless_images_get_image_memory_opaque_support_exp_params_t *params) { + + os << ".hContext = "; + + ur::details::printPtr(os, *(params->phContext)); + + os << ", "; + os << ".hDevice = "; + + ur::details::printPtr(os, *(params->phDevice)); + + os << ", "; + os << ".pImageDesc = "; + + ur::details::printPtr(os, *(params->ppImageDesc)); + + os << ", "; + os << ".pImageFormat = "; + + ur::details::printPtr(os, *(params->ppImageFormat)); + + os << ", "; + os << ".pSupportedRet = "; + + ur::details::printPtr(os, *(params->ppSupportedRet)); + + return os; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the +/// ur_bindless_images_get_image_unsampled_handle_support_exp_params_t type +/// @returns +/// std::ostream & +inline std::ostream & +operator<<(std::ostream &os, [[maybe_unused]] const struct + ur_bindless_images_get_image_unsampled_handle_support_exp_params_t + *params) { + + os << ".hContext = "; + + ur::details::printPtr(os, *(params->phContext)); + + os << ", "; + os << ".hDevice = "; + + ur::details::printPtr(os, *(params->phDevice)); + + os << ", "; + os << ".pImageDesc = "; + + ur::details::printPtr(os, *(params->ppImageDesc)); + + os << ", "; + os << ".pImageFormat = "; + + ur::details::printPtr(os, *(params->ppImageFormat)); + + os << ", "; + os << ".isOpaqueAllocation = "; + + os << *(params->pisOpaqueAllocation); + + os << ", "; + os << ".pSupportedRet = "; + + ur::details::printPtr(os, *(params->ppSupportedRet)); + + return os; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the +/// ur_bindless_images_get_image_sampled_handle_support_exp_params_t type +/// @returns +/// std::ostream & +inline std::ostream &operator<<( + std::ostream &os, [[maybe_unused]] const struct + ur_bindless_images_get_image_sampled_handle_support_exp_params_t *params) { + + os << ".hContext = "; + + ur::details::printPtr(os, *(params->phContext)); + + os << ", "; + os << ".hDevice = "; + + ur::details::printPtr(os, *(params->phDevice)); + + os << ", "; + os << ".pImageDesc = "; + + ur::details::printPtr(os, *(params->ppImageDesc)); + + os << ", "; + os << ".pImageFormat = "; + + ur::details::printPtr(os, *(params->ppImageFormat)); + + os << ", "; + os << ".isOpaqueAllocation = "; + + os << *(params->pisOpaqueAllocation); + + os << ", "; + os << ".pSupportedRet = "; + + ur::details::printPtr(os, *(params->ppSupportedRet)); + + return os; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Print operator for the /// ur_bindless_images_mipmap_get_level_exp_params_t type @@ -21093,6 +21260,26 @@ inline ur_result_t UR_APICALL printFunctionParams(std::ostream &os, case UR_FUNCTION_BINDLESS_IMAGES_IMAGE_GET_INFO_EXP: { os << (const struct ur_bindless_images_image_get_info_exp_params_t *)params; } break; + case UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_POINTER_SUPPORT_EXP: { + os << (const struct + ur_bindless_images_get_image_memory_pointer_support_exp_params_t *) + params; + } break; + case UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_OPAQUE_SUPPORT_EXP: { + os << (const struct + ur_bindless_images_get_image_memory_opaque_support_exp_params_t *) + params; + } break; + case UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_UNSAMPLED_HANDLE_SUPPORT_EXP: { + os << (const struct + ur_bindless_images_get_image_unsampled_handle_support_exp_params_t *) + params; + } break; + case UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_SAMPLED_HANDLE_SUPPORT_EXP: { + os << (const struct + ur_bindless_images_get_image_sampled_handle_support_exp_params_t *) + params; + } break; case UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_GET_LEVEL_EXP: { os << (const struct ur_bindless_images_mipmap_get_level_exp_params_t *) params; diff --git a/unified-runtime/scripts/core/EXP-BINDLESS-IMAGES.rst b/unified-runtime/scripts/core/EXP-BINDLESS-IMAGES.rst index c2baba23c8db3..ddf026b8ca628 100644 --- a/unified-runtime/scripts/core/EXP-BINDLESS-IMAGES.rst +++ b/unified-runtime/scripts/core/EXP-BINDLESS-IMAGES.rst @@ -146,6 +146,10 @@ Enums * ${X}_FUNCTION_BINDLESS_IMAGES_RELEASE_EXTERNAL_SEMAPHORE_EXP * ${X}_FUNCTION_BINDLESS_IMAGES_WAIT_EXTERNAL_SEMAPHORE_EXP * ${X}_FUNCTION_BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP + * ${X}_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_POINTER_SUPPORT_EXP + * ${X}_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_OPAQUE_SUPPORT_EXP + * ${X}_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_UNSAMPLED_HANDLE_SUPPORT_EXP + * ${X}_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_SAMPLED_HANDLE_SUPPORT_EXP * ${x}_mem_type_t * ${X}_MEM_TYPE_IMAGE_CUBEMAP_EXP @@ -182,6 +186,10 @@ Functions * ${x}BindlessImagesImageGetInfoExp * ${x}BindlessImagesMipmapGetLevelExp * ${x}BindlessImagesMipmapFreeExp + * ${x}BindlessImagesGetImageMemoryPointerSupportExp + * ${x}BindlessImagesGetImageMemoryOpaqueSupportExp + * ${x}BindlessImagesGetImageUnsampledHandleSupportExp + * ${x}BindlessImagesGetImageSampledHandleSupportExp * Interop * ${x}BindlessImagesImportExternalMemoryExp @@ -269,6 +277,12 @@ Changelog | || to DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D_USM_SUPPORT_EXP | | || to be more consistent with other UR enums | +----------+--------------------------------------------------------------------+ +| 22.0 || Added the following APIs: | +| || - GetImageMemoryPointerSupportExp | +| || - GetImageMemoryOpaqueSupportExp | +| || - GetImageUnsampledHandleSupportExp | +| || - GetImageSampledHandleSupportExp | ++----------+-------------------------------------------------------------+ Contributors -------------------------------------------------------------------------------- diff --git a/unified-runtime/scripts/core/exp-bindless-images.yml b/unified-runtime/scripts/core/exp-bindless-images.yml index b0fb250b879b7..c4e8f5d4cbc5a 100644 --- a/unified-runtime/scripts/core/exp-bindless-images.yml +++ b/unified-runtime/scripts/core/exp-bindless-images.yml @@ -643,6 +643,110 @@ returns: - $X_RESULT_ERROR_OUT_OF_HOST_MEMORY --- #-------------------------------------------------------------------------- type: function +desc: "Query support for allocating pointer handle type image memory with specific image properties" +class: $xBindlessImages +name: GetImageMemoryPointerSupportExp +ordinal: "0" +params: + - type: $x_context_handle_t + name: hContext + desc: "[in] handle of the context object" + - type: $x_device_handle_t + name: hDevice + desc: "[in] handle of the device object" + - type: "const $x_image_desc_t*" + name: pImageDesc + desc: "[in] pointer to image description" + - type: "const $x_image_format_t*" + name: pImageFormat + desc: "[in] pointer to image format specification" + - type: bool* + name: pSupportedRet + desc: "[out] returned indication of support for allocating USM style memory" +returns: + - $X_RESULT_ERROR_INVALID_DEVICE +--- #-------------------------------------------------------------------------- +type: function +desc: "Query support for allocating opaque handle type image memory with specific image properties" +class: $xBindlessImages +name: GetImageMemoryOpaqueSupportExp +ordinal: "0" +params: + - type: $x_context_handle_t + name: hContext + desc: "[in] handle of the context object" + - type: $x_device_handle_t + name: hDevice + desc: "[in] handle of the device object" + - type: "const $x_image_desc_t*" + name: pImageDesc + desc: "[in] pointer to image description" + - type: "const $x_image_format_t*" + name: pImageFormat + desc: "[in] pointer to image format specification" + - type: bool* + name: pSupportedRet + desc: "[out] returned indication of support for allocating opaque handle memory" +returns: + - $X_RESULT_ERROR_INVALID_DEVICE +--- #-------------------------------------------------------------------------- +type: function +desc: "Query support for creating an unsampled image handle with specific image properties" +class: $xBindlessImages +name: GetImageUnsampledHandleSupportExp +ordinal: "0" +params: + - type: $x_context_handle_t + name: hContext + desc: "[in] handle of the context object" + - type: $x_device_handle_t + name: hDevice + desc: "[in] handle of the device object" + - type: "const $x_image_desc_t*" + name: pImageDesc + desc: "[in] pointer to image description" + - type: "const $x_image_format_t*" + name: pImageFormat + desc: "[in] pointer to image format specification" + - type: bool + name: isOpaqueAllocation + desc: "[in] indicates whether the image memory would be backed by an opaque handle allocation" + - type: bool* + name: pSupportedRet + desc: "[out] returned indication of support for creating unsampled image handles" +returns: + - $X_RESULT_ERROR_INVALID_DEVICE + - $X_RESULT_ERROR_INVALID_CONTEXT +--- #-------------------------------------------------------------------------- +type: function +desc: "Query support for creating an unsampled image handle with specific image properties" +class: $xBindlessImages +name: GetImageSampledHandleSupportExp +ordinal: "0" +params: + - type: $x_context_handle_t + name: hContext + desc: "[in] handle of the context object" + - type: $x_device_handle_t + name: hDevice + desc: "[in] handle of the device object" + - type: "const $x_image_desc_t*" + name: pImageDesc + desc: "[in] pointer to image description" + - type: "const $x_image_format_t*" + name: pImageFormat + desc: "[in] pointer to image format specification" + - type: bool + name: isOpaqueAllocation + desc: "[in] indicates whether the image memory would be backed by an opaque handle allocation" + - type: bool* + name: pSupportedRet + desc: "[out] returned indication of support for creating sampled image handles" +returns: + - $X_RESULT_ERROR_INVALID_DEVICE + - $X_RESULT_ERROR_INVALID_CONTEXT +--- #-------------------------------------------------------------------------- +type: function desc: "Retrieve individual image from mipmap" class: $xBindlessImages name: MipmapGetLevelExp diff --git a/unified-runtime/scripts/core/registry.yml b/unified-runtime/scripts/core/registry.yml index 9c8a61184dfbb..7cfc2c0eeb6b2 100644 --- a/unified-runtime/scripts/core/registry.yml +++ b/unified-runtime/scripts/core/registry.yml @@ -643,6 +643,18 @@ etors: - name: USM_POOL_SET_INFO_EXP desc: Enumerator for $xUSMPoolSetInfoExp value: '265' +- name: BINDLESS_IMAGES_GET_IMAGE_MEMORY_POINTER_SUPPORT_EXP + desc: Enumerator for $xBindlessImagesGetImageMemoryPointerSupportExp + value: '266' +- name: BINDLESS_IMAGES_GET_IMAGE_MEMORY_OPAQUE_SUPPORT_EXP + desc: Enumerator for $xBindlessImagesGetImageMemoryOpaqueSupportExp + value: '267' +- name: BINDLESS_IMAGES_GET_IMAGE_UNSAMPLED_HANDLE_SUPPORT_EXP + desc: Enumerator for $xBindlessImagesGetImageUnsampledHandleSupportExp + value: '268' +- name: BINDLESS_IMAGES_GET_IMAGE_SAMPLED_HANDLE_SUPPORT_EXP + desc: Enumerator for $xBindlessImagesGetImageSampledHandleSupportExp + value: '269' --- type: enum desc: Defines structure types diff --git a/unified-runtime/source/adapters/cuda/image.cpp b/unified-runtime/source/adapters/cuda/image.cpp index e21d726d4fd9e..080220cd6afb6 100644 --- a/unified-runtime/source/adapters/cuda/image.cpp +++ b/unified-runtime/source/adapters/cuda/image.cpp @@ -1006,6 +1006,347 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( } } +bool verifyCommonImagePropertiesSupport(const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + const ur_image_format_t *pImageFormat, + bool isOpaqueAllocation) { + + // Verify image dimensions are within device limits. + size_t maxImageWidth, maxImageHeight, maxImageDepth; + + if (pImageDesc->depth != 0 && pImageDesc->type == UR_MEM_TYPE_IMAGE3D) { + + // Verify for standard 3D images. + UR_CHECK_ERROR(urDeviceGetInfo(hDevice, UR_DEVICE_INFO_IMAGE3D_MAX_WIDTH, + sizeof(size_t), &maxImageWidth, nullptr)); + UR_CHECK_ERROR(urDeviceGetInfo(hDevice, UR_DEVICE_INFO_IMAGE3D_MAX_HEIGHT, + sizeof(size_t), &maxImageHeight, nullptr)); + UR_CHECK_ERROR(urDeviceGetInfo(hDevice, UR_DEVICE_INFO_IMAGE3D_MAX_DEPTH, + sizeof(size_t), &maxImageDepth, nullptr)); + if ((pImageDesc->width > maxImageWidth) || + (pImageDesc->height > maxImageHeight) || + (pImageDesc->depth > maxImageDepth)) { + return false; + } + } else if (pImageDesc->height != 0 && + pImageDesc->type == UR_MEM_TYPE_IMAGE2D) { + + if (pImageDesc->numMipLevel == 1) { + if (!isOpaqueAllocation) { + // Verify for standard 2D images backed by linear memory. + UR_CHECK_ERROR( + urDeviceGetInfo(hDevice, UR_DEVICE_INFO_MAX_IMAGE_LINEAR_WIDTH_EXP, + sizeof(size_t), &maxImageWidth, nullptr)); + UR_CHECK_ERROR( + urDeviceGetInfo(hDevice, UR_DEVICE_INFO_MAX_IMAGE_LINEAR_HEIGHT_EXP, + sizeof(size_t), &maxImageHeight, nullptr)); + + size_t maxImageLinearPitch; + UR_CHECK_ERROR( + urDeviceGetInfo(hDevice, UR_DEVICE_INFO_MAX_IMAGE_LINEAR_PITCH_EXP, + sizeof(size_t), &maxImageLinearPitch, nullptr)); + if (pImageDesc->rowPitch > maxImageLinearPitch) { + return false; + } + } else { + // Verify for standard 2D images backed by opaque memory. + UR_CHECK_ERROR( + urDeviceGetInfo(hDevice, UR_DEVICE_INFO_IMAGE2D_MAX_WIDTH, + sizeof(size_t), &maxImageWidth, nullptr)); + UR_CHECK_ERROR( + urDeviceGetInfo(hDevice, UR_DEVICE_INFO_IMAGE2D_MAX_HEIGHT, + sizeof(size_t), &maxImageHeight, nullptr)); + } + } else { + // Verify for 2D mipmap images. + int32_t maxMipmapWidth, maxMipmapHeight; + UR_CHECK_ERROR(cuDeviceGetAttribute( + &maxMipmapWidth, + CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_WIDTH, + hDevice->get())); + UR_CHECK_ERROR(cuDeviceGetAttribute( + &maxMipmapHeight, + CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_HEIGHT, + hDevice->get())); + maxImageWidth = static_cast(maxMipmapWidth); + maxImageHeight = static_cast(maxMipmapHeight); + } + + if ((pImageDesc->width > maxImageWidth) || + (pImageDesc->height > maxImageHeight)) { + return false; + } + } else if (pImageDesc->width != 0 && + pImageDesc->type == UR_MEM_TYPE_IMAGE1D) { + + if (pImageDesc->numMipLevel == 1) { + if (!isOpaqueAllocation) { + // Verify for standard 1D images backed by linear memory. + // + /// TODO: We have a query for `max_image_linear_width`, however, that + /// query is for 2D textures (at least as far as the CUDA/HIP + /// implementations go). We should split the `max_image_linear_width` + /// query into 1D and 2D variants to ensure that 1D image dimensions + /// can be properly verified and used to the fullest extent. + int32_t maxImageLinearWidth; + UR_CHECK_ERROR(cuDeviceGetAttribute( + &maxImageLinearWidth, + CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LINEAR_WIDTH, + hDevice->get())); + maxImageWidth = static_cast(maxImageLinearWidth); + } else { + // Verify for standard 1D images backed by opaque memory. + UR_CHECK_ERROR( + urDeviceGetInfo(hDevice, UR_DEVICE_INFO_IMAGE_MAX_BUFFER_SIZE, + sizeof(size_t), &maxImageWidth, nullptr)); + } + } else { + // Verify for 1D mipmap images. + int32_t maxMipmapWidth; + UR_CHECK_ERROR(cuDeviceGetAttribute( + &maxMipmapWidth, + CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_MIPMAPPED_WIDTH, + hDevice->get())); + maxImageWidth = static_cast(maxMipmapWidth); + } + if ((pImageDesc->width > maxImageWidth)) { + return false; + } + } + + // Verify layered image dimensions are within device limits. + size_t maxImageLayers; + + if (pImageDesc->type == UR_MEM_TYPE_IMAGE1D_ARRAY) { + // Take the smaller of maximum surface and maximum texture width, as we do + // for `UR_DEVICE_INFO_IMAGE2D_MAX_WIDTH` and others. + int32_t maxTextureLayeredWidth, maxSurfaceLayeredWidth; + UR_CHECK_ERROR(cuDeviceGetAttribute( + &maxTextureLayeredWidth, + CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_WIDTH, hDevice->get())); + UR_CHECK_ERROR(cuDeviceGetAttribute( + &maxSurfaceLayeredWidth, + CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_WIDTH, hDevice->get())); + + maxImageWidth = static_cast( + std::min(maxTextureLayeredWidth, maxSurfaceLayeredWidth)); + + // Take the smaller of maximum surface and maximum texture layers, as we do + // for `UR_DEVICE_INFO_IMAGE2D_MAX_WIDTH` and others. + int32_t maxTextureLayers, maxSurfaceLayers; + UR_CHECK_ERROR(cuDeviceGetAttribute( + &maxTextureLayers, CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_LAYERS, + hDevice->get())); + UR_CHECK_ERROR(cuDeviceGetAttribute( + &maxSurfaceLayers, CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_LAYERS, + hDevice->get())); + + maxImageLayers = + static_cast(std::min(maxTextureLayers, maxSurfaceLayers)); + + if (pImageDesc->width > maxImageWidth || + pImageDesc->arraySize > maxImageLayers) { + return false; + } + + } else if (pImageDesc->type == UR_MEM_TYPE_IMAGE2D_ARRAY) { + // Take the smaller of maximum surface and maximum texture width and height, + // as we do for `UR_DEVICE_INFO_IMAGE2D_MAX_WIDTH` and others. + int32_t maxTextureLayeredWidth, maxSurfaceLayeredWidth; + UR_CHECK_ERROR(cuDeviceGetAttribute( + &maxTextureLayeredWidth, + CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_WIDTH, hDevice->get())); + UR_CHECK_ERROR(cuDeviceGetAttribute( + &maxSurfaceLayeredWidth, + CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_WIDTH, hDevice->get())); + + int32_t maxTextureLayeredHeight, maxSurfaceLayeredHeight; + UR_CHECK_ERROR(cuDeviceGetAttribute( + &maxTextureLayeredHeight, + CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_HEIGHT, hDevice->get())); + UR_CHECK_ERROR(cuDeviceGetAttribute( + &maxSurfaceLayeredHeight, + CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_HEIGHT, hDevice->get())); + + maxImageWidth = static_cast( + std::min(maxTextureLayeredWidth, maxSurfaceLayeredWidth)); + + maxImageHeight = static_cast( + std::min(maxTextureLayeredHeight, maxSurfaceLayeredHeight)); + + // Take the smaller of maximum surface and maximum texture layers, as we do + // for `UR_DEVICE_INFO_IMAGE2D_MAX_WIDTH` and others. + int32_t maxTextureLayers, maxSurfaceLayers; + UR_CHECK_ERROR(cuDeviceGetAttribute( + &maxTextureLayers, CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_LAYERS, + hDevice->get())); + UR_CHECK_ERROR(cuDeviceGetAttribute( + &maxSurfaceLayers, CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_LAYERS, + hDevice->get())); + + maxImageLayers = static_cast( + std::min(maxTextureLayeredWidth, maxSurfaceLayeredWidth)); + + if (pImageDesc->width > maxImageWidth || + pImageDesc->height > maxImageHeight || + pImageDesc->arraySize > maxImageLayers) { + return false; + } + } + + // Verify cubemap support and whether cubemap image dimensions are within + // device limits. + if (pImageDesc->type == UR_MEM_TYPE_IMAGE_CUBEMAP_EXP) { + + if (!isOpaqueAllocation) { + // Bindless Images do not provide support for cubemaps backed by + // USM/linear memory. + return false; + } + + if (pImageDesc->arraySize != 0) { + // Bindless Images do not provide support for layered cubemaps. + return false; + } + + // Take the smaller of maximum surface and maximum texture cubemap widths, + // as we do for `UR_DEVICE_INFO_IMAGE2D_MAX_WIDTH` and others. + int32_t maxTexCubemapWidth, maxSurfCubemapWidth; + UR_CHECK_ERROR(cuDeviceGetAttribute( + &maxTexCubemapWidth, CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_WIDTH, + hDevice->get())); + UR_CHECK_ERROR(cuDeviceGetAttribute( + &maxSurfCubemapWidth, CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_WIDTH, + hDevice->get())); + + maxImageWidth = + static_cast(std::min(maxTexCubemapWidth, maxSurfCubemapWidth)); + + // Cubemaps always have equal width and height. + if (pImageDesc->width > maxImageWidth || + pImageDesc->height > maxImageWidth) { + return false; + } + } + + // Verify gather image dimensions are within device limits. + if (pImageDesc->type == UR_MEM_TYPE_IMAGE_GATHER_EXP) { + + // Gather images only support 2D. + if (pImageDesc->height == 0 || pImageDesc->depth > 0) { + return false; + } + + int32_t maxGatherTextureWidth, maxGatherTextureHeight; + UR_CHECK_ERROR(cuDeviceGetAttribute( + &maxGatherTextureWidth, + CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_WIDTH, hDevice->get())); + UR_CHECK_ERROR(cuDeviceGetAttribute( + &maxGatherTextureHeight, + CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_HEIGHT, hDevice->get())); + + maxImageWidth = static_cast(maxGatherTextureWidth); + maxImageHeight = static_cast(maxGatherTextureHeight); + + if (pImageDesc->width > maxImageWidth || + pImageDesc->height > maxImageHeight) { + return false; + } + } + + // Verify 3-channel format support. + // CUDA does not allow 3-channel formats. + if (pImageFormat->channelOrder == UR_IMAGE_CHANNEL_ORDER_RGB || + pImageFormat->channelOrder == UR_IMAGE_CHANNEL_ORDER_RGX) { + return false; + } + + // Once we've verified all of the above properties are valid, return true. + return true; +} + +UR_APIEXPORT ur_result_t UR_APICALL +urBindlessImagesGetImageMemoryPointerSupportExp( + ur_context_handle_t hContext, ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, + bool *pSupportedRet) { + UR_ASSERT(std::find(hContext->getDevices().begin(), + hContext->getDevices().end(), + hDevice) != hContext->getDevices().end(), + UR_RESULT_ERROR_INVALID_CONTEXT); + + // Verify support for common image properties (dims, channel types, image + // types, etc.). + *pSupportedRet = verifyCommonImagePropertiesSupport( + hDevice, pImageDesc, pImageFormat, true /* isOpaqueAllocation */); + return UR_RESULT_SUCCESS; +} + +UR_APIEXPORT ur_result_t UR_APICALL +urBindlessImagesGetImageMemoryOpaqueSupportExp( + ur_context_handle_t hContext, ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, + bool *pSupportedRet) { + UR_ASSERT(std::find(hContext->getDevices().begin(), + hContext->getDevices().end(), + hDevice) != hContext->getDevices().end(), + UR_RESULT_ERROR_INVALID_CONTEXT); + + // Verify support for common image properties (dims, channel types, image + // types, etc.). + *pSupportedRet = verifyCommonImagePropertiesSupport( + hDevice, pImageDesc, pImageFormat, false /* isOpaqueAllocation */); + return UR_RESULT_SUCCESS; +} + +UR_APIEXPORT ur_result_t UR_APICALL +urBindlessImagesGetImageUnsampledHandleSupportExp( + ur_context_handle_t hContext, ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, + bool isOpaqueAllocation, bool *pSupportedRet) { + UR_ASSERT(std::find(hContext->getDevices().begin(), + hContext->getDevices().end(), + hDevice) != hContext->getDevices().end(), + UR_RESULT_ERROR_INVALID_CONTEXT); + + // Currently the Bindless Images extension does not allow creation of + // unsampled image handles from non-opaque (USM) memory. + if (!isOpaqueAllocation) { + *pSupportedRet = false; + return UR_RESULT_SUCCESS; + } + + // Bindless Images do not allow creation of `unsampled_image_handle`s for + // mipmap images. + if (pImageDesc->numMipLevel > 1) { + *pSupportedRet = false; + return UR_RESULT_SUCCESS; + } + + // Verify support for common image properties (dims, channel types, image + // types, etc.). + *pSupportedRet = verifyCommonImagePropertiesSupport( + hDevice, pImageDesc, pImageFormat, isOpaqueAllocation); + return UR_RESULT_SUCCESS; +} + +UR_APIEXPORT ur_result_t UR_APICALL +urBindlessImagesGetImageSampledHandleSupportExp( + ur_context_handle_t hContext, ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, + bool isOpaqueAllocation, bool *pSupportedRet) { + UR_ASSERT(std::find(hContext->getDevices().begin(), + hContext->getDevices().end(), + hDevice) != hContext->getDevices().end(), + UR_RESULT_ERROR_INVALID_CONTEXT); + + // Verify support for common image properties (dims, channel types, image + // types, etc.). + *pSupportedRet = verifyCommonImagePropertiesSupport( + hDevice, pImageDesc, pImageFormat, isOpaqueAllocation); + return UR_RESULT_SUCCESS; +} + UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, ur_exp_image_mem_native_handle_t hImageMem, uint32_t mipmapLevel, diff --git a/unified-runtime/source/adapters/cuda/image.hpp b/unified-runtime/source/adapters/cuda/image.hpp index 7233d1785c5ef..4cea4b3d7e1e2 100644 --- a/unified-runtime/source/adapters/cuda/image.hpp +++ b/unified-runtime/source/adapters/cuda/image.hpp @@ -33,3 +33,8 @@ ur_result_t urTextureCreate(ur_sampler_handle_t hSampler, const CUDA_RESOURCE_DESC &ResourceDesc, const unsigned int normalized_dtype_flag, ur_exp_image_native_handle_t *phRetImage); + +bool verifyCommonImagePropertiesSupport(const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + const ur_image_format_t *pImageFormat, + bool isOpaqueAllocation); diff --git a/unified-runtime/source/adapters/cuda/ur_interface_loader.cpp b/unified-runtime/source/adapters/cuda/ur_interface_loader.cpp index 16f2875102de1..b7c676cfb81f4 100644 --- a/unified-runtime/source/adapters/cuda/ur_interface_loader.cpp +++ b/unified-runtime/source/adapters/cuda/ur_interface_loader.cpp @@ -352,6 +352,15 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetBindlessImagesExpProcAddrTable( urBindlessImagesWaitExternalSemaphoreExp; pDdiTable->pfnSignalExternalSemaphoreExp = urBindlessImagesSignalExternalSemaphoreExp; + pDdiTable->pfnGetImageMemoryPointerSupportExp = + urBindlessImagesGetImageMemoryPointerSupportExp; + pDdiTable->pfnGetImageMemoryOpaqueSupportExp = + urBindlessImagesGetImageMemoryOpaqueSupportExp; + pDdiTable->pfnGetImageUnsampledHandleSupportExp = + urBindlessImagesGetImageUnsampledHandleSupportExp; + pDdiTable->pfnGetImageSampledHandleSupportExp = + urBindlessImagesGetImageSampledHandleSupportExp; + return UR_RESULT_SUCCESS; } diff --git a/unified-runtime/source/adapters/hip/device.cpp b/unified-runtime/source/adapters/hip/device.cpp index ffbcfb5bce917..d97c77e949807 100644 --- a/unified-runtime/source/adapters/hip/device.cpp +++ b/unified-runtime/source/adapters/hip/device.cpp @@ -248,94 +248,46 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, return ReturnValue(128u); } case UR_DEVICE_INFO_IMAGE2D_MAX_HEIGHT: { - // Take the smaller of maximum surface and maximum texture height. int TexHeight = 0; UR_CHECK_ERROR(hipDeviceGetAttribute( &TexHeight, hipDeviceAttributeMaxTexture2DHeight, hDevice->get())); detail::ur::assertion(TexHeight >= 0); - int SurfHeight = 0; - UR_CHECK_ERROR(hipDeviceGetAttribute( - &SurfHeight, hipDeviceAttributeMaxTexture2DHeight, hDevice->get())); - detail::ur::assertion(SurfHeight >= 0); - - int Min = std::min(TexHeight, SurfHeight); - - return ReturnValue(static_cast(Min)); + return ReturnValue(static_cast(TexHeight)); } case UR_DEVICE_INFO_IMAGE2D_MAX_WIDTH: { - // Take the smaller of maximum surface and maximum texture width. int TexWidth = 0; UR_CHECK_ERROR(hipDeviceGetAttribute( &TexWidth, hipDeviceAttributeMaxTexture2DWidth, hDevice->get())); detail::ur::assertion(TexWidth >= 0); - int SurfWidth = 0; - UR_CHECK_ERROR(hipDeviceGetAttribute( - &SurfWidth, hipDeviceAttributeMaxTexture2DWidth, hDevice->get())); - detail::ur::assertion(SurfWidth >= 0); - - int Min = std::min(TexWidth, SurfWidth); - - return ReturnValue(static_cast(Min)); + return ReturnValue(static_cast(TexWidth)); } case UR_DEVICE_INFO_IMAGE3D_MAX_HEIGHT: { - // Take the smaller of maximum surface and maximum texture height. int TexHeight = 0; UR_CHECK_ERROR(hipDeviceGetAttribute( &TexHeight, hipDeviceAttributeMaxTexture3DHeight, hDevice->get())); detail::ur::assertion(TexHeight >= 0); - int SurfHeight = 0; - UR_CHECK_ERROR(hipDeviceGetAttribute( - &SurfHeight, hipDeviceAttributeMaxTexture3DHeight, hDevice->get())); - detail::ur::assertion(SurfHeight >= 0); - - int Min = std::min(TexHeight, SurfHeight); - - return ReturnValue(static_cast(Min)); + return ReturnValue(static_cast(TexHeight)); } case UR_DEVICE_INFO_IMAGE3D_MAX_WIDTH: { - // Take the smaller of maximum surface and maximum texture width. int TexWidth = 0; UR_CHECK_ERROR(hipDeviceGetAttribute( &TexWidth, hipDeviceAttributeMaxTexture3DWidth, hDevice->get())); detail::ur::assertion(TexWidth >= 0); - int SurfWidth = 0; - UR_CHECK_ERROR(hipDeviceGetAttribute( - &SurfWidth, hipDeviceAttributeMaxTexture3DWidth, hDevice->get())); - detail::ur::assertion(SurfWidth >= 0); - - int Min = std::min(TexWidth, SurfWidth); - - return ReturnValue(static_cast(Min)); + return ReturnValue(static_cast(TexWidth)); } case UR_DEVICE_INFO_IMAGE3D_MAX_DEPTH: { - // Take the smaller of maximum surface and maximum texture depth. int TexDepth = 0; UR_CHECK_ERROR(hipDeviceGetAttribute( &TexDepth, hipDeviceAttributeMaxTexture3DDepth, hDevice->get())); detail::ur::assertion(TexDepth >= 0); - int SurfDepth = 0; - UR_CHECK_ERROR(hipDeviceGetAttribute( - &SurfDepth, hipDeviceAttributeMaxTexture3DDepth, hDevice->get())); - detail::ur::assertion(SurfDepth >= 0); - - int Min = std::min(TexDepth, SurfDepth); - - return ReturnValue(static_cast(Min)); + return ReturnValue(static_cast(TexDepth)); } case UR_DEVICE_INFO_IMAGE_MAX_BUFFER_SIZE: { - // Take the smaller of maximum surface and maximum texture width. int TexWidth = 0; UR_CHECK_ERROR(hipDeviceGetAttribute( &TexWidth, hipDeviceAttributeMaxTexture1DWidth, hDevice->get())); detail::ur::assertion(TexWidth >= 0); - int SurfWidth = 0; - UR_CHECK_ERROR(hipDeviceGetAttribute( - &SurfWidth, hipDeviceAttributeMaxTexture1DWidth, hDevice->get())); - detail::ur::assertion(SurfWidth >= 0); - - int Min = std::min(TexWidth, SurfWidth); - - return ReturnValue(static_cast(Min)); + return ReturnValue(static_cast(TexWidth)); } case UR_DEVICE_INFO_IMAGE_MAX_ARRAY_SIZE: { return ReturnValue(size_t(0)); @@ -787,22 +739,31 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, &tex_pitch_align, hipDeviceAttributeTexturePitchAlignment, hDevice->get())); detail::ur::assertion(tex_pitch_align >= 0); - return ReturnValue(static_cast(tex_pitch_align)); + return ReturnValue(tex_pitch_align); } case UR_DEVICE_INFO_MAX_IMAGE_LINEAR_WIDTH_EXP: { - // Default values due to non-existent hipamd queries for linear sizes. - constexpr size_t MaxLinearWidth{1}; - return ReturnValue(MaxLinearWidth); + // No direct HIP equivalent. Use `hipDeviceAttributeMaxTexture2DWidth`. + int TexWidth = 0; + UR_CHECK_ERROR(hipDeviceGetAttribute( + &TexWidth, hipDeviceAttributeMaxTexture2DWidth, hDevice->get())); + detail::ur::assertion(TexWidth >= 0); + return ReturnValue(static_cast(TexWidth)); } case UR_DEVICE_INFO_MAX_IMAGE_LINEAR_HEIGHT_EXP: { - // Default values due to non-existent hipamd queries for linear sizes. - constexpr size_t MaxLinearHeight{1}; - return ReturnValue(MaxLinearHeight); + // No direct HIP equivalent. Use `hipDeviceAttributeMaxTexture2DHeight`. + int TexHeight = 0; + UR_CHECK_ERROR(hipDeviceGetAttribute( + &TexHeight, hipDeviceAttributeMaxTexture2DHeight, hDevice->get())); + detail::ur::assertion(TexHeight >= 0); + return ReturnValue(static_cast(TexHeight)); } case UR_DEVICE_INFO_MAX_IMAGE_LINEAR_PITCH_EXP: { - // Default values due to non-existent hipamd queries for linear sizes. - constexpr size_t MaxLinearPitch{1}; - return ReturnValue(MaxLinearPitch); + // No direct HIP equivalent. Use `hipDeviceAttributeMaxTexture2DWidth`. + int TexPitch = 0; + UR_CHECK_ERROR(hipDeviceGetAttribute( + &TexPitch, hipDeviceAttributeMaxTexture2DWidth, hDevice->get())); + detail::ur::assertion(TexPitch >= 0); + return ReturnValue(static_cast(TexPitch)); } case UR_DEVICE_INFO_MIPMAP_SUPPORT_EXP: { // HIP supports mipmaps. diff --git a/unified-runtime/source/adapters/hip/image.cpp b/unified-runtime/source/adapters/hip/image.cpp index 0fa0c128e95b3..c75fba1db0419 100644 --- a/unified-runtime/source/adapters/hip/image.cpp +++ b/unified-runtime/source/adapters/hip/image.cpp @@ -1011,6 +1011,204 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( #endif } +bool verifyCommonImagePropertiesSupport(const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + const ur_image_format_t *pImageFormat, + bool isOpaqueAllocation) { + + // Verify mipmap image support. + // Mimpaps are not currently supported for the AMD target. + if (pImageDesc->numMipLevel > 1) { + return false; + } + + // Verify gather image support. + // Gather images are not currently supported for the AMD target. + if (pImageDesc->type == UR_MEM_TYPE_IMAGE_GATHER_EXP) { + return false; + } + + // Verify cubemap image support. + // Cubemaps are not currently supported for the AMD target. + if (pImageDesc->type == UR_MEM_TYPE_IMAGE_CUBEMAP_EXP) { + return false; + } + + // Verify layered image support. + // Layered images are not currently supported for the AMD target. + if ((pImageDesc->type == UR_MEM_TYPE_IMAGE1D_ARRAY) || + pImageDesc->type == UR_MEM_TYPE_IMAGE2D_ARRAY) { + return false; + } + + // Verify standard image dimensions are within device limits. + size_t maxImageWidth, maxImageHeight, maxImageDepth; + + if (pImageDesc->depth != 0 && pImageDesc->type == UR_MEM_TYPE_IMAGE3D) { + + // Verify for standard 3D images. + UR_CHECK_ERROR(urDeviceGetInfo(hDevice, UR_DEVICE_INFO_IMAGE3D_MAX_WIDTH, + sizeof(size_t), &maxImageWidth, nullptr)); + UR_CHECK_ERROR(urDeviceGetInfo(hDevice, UR_DEVICE_INFO_IMAGE3D_MAX_HEIGHT, + sizeof(size_t), &maxImageHeight, nullptr)); + UR_CHECK_ERROR(urDeviceGetInfo(hDevice, UR_DEVICE_INFO_IMAGE3D_MAX_DEPTH, + sizeof(size_t), &maxImageDepth, nullptr)); + if ((pImageDesc->width > maxImageWidth) || + (pImageDesc->height > maxImageHeight) || + (pImageDesc->depth > maxImageDepth)) { + return false; + } + } else if (pImageDesc->height != 0 && + pImageDesc->type == UR_MEM_TYPE_IMAGE2D) { + + if (!isOpaqueAllocation) { + // Verify for standard 2D images backed by linear memory. + UR_CHECK_ERROR(urDeviceGetInfo(hDevice, + UR_DEVICE_INFO_MAX_IMAGE_LINEAR_WIDTH_EXP, + sizeof(size_t), &maxImageWidth, nullptr)); + UR_CHECK_ERROR(urDeviceGetInfo(hDevice, + UR_DEVICE_INFO_MAX_IMAGE_LINEAR_HEIGHT_EXP, + sizeof(size_t), &maxImageHeight, nullptr)); + + size_t maxImageLinearPitch; + UR_CHECK_ERROR( + urDeviceGetInfo(hDevice, UR_DEVICE_INFO_MAX_IMAGE_LINEAR_PITCH_EXP, + sizeof(size_t), &maxImageLinearPitch, nullptr)); + if (pImageDesc->rowPitch > maxImageLinearPitch) { + return false; + } + } else { + // Verify for standard 2D images backed by opaque memory. + UR_CHECK_ERROR(urDeviceGetInfo(hDevice, UR_DEVICE_INFO_IMAGE2D_MAX_WIDTH, + sizeof(size_t), &maxImageWidth, nullptr)); + UR_CHECK_ERROR(urDeviceGetInfo(hDevice, UR_DEVICE_INFO_IMAGE2D_MAX_HEIGHT, + sizeof(size_t), &maxImageHeight, nullptr)); + } + + if ((pImageDesc->width > maxImageWidth) || + (pImageDesc->height > maxImageHeight)) { + return false; + } + } else if (pImageDesc->width != 0 && + pImageDesc->type == UR_MEM_TYPE_IMAGE1D) { + + if (!isOpaqueAllocation) { + // Verify for standard 1D images backed by linear memory. + // + /// TODO: We have a query for `max_image_linear_width`, however, that + /// query is for 2D textures (at least as far as the CUDA/HIP + /// implementations go). We should split the `max_image_linear_width` + /// query into 1D and 2D variants to ensure that 1D image dimensions + /// can be properly verified and used to the fullest extent. + int32_t maxImageLinearWidth; + UR_CHECK_ERROR(hipDeviceGetAttribute(&maxImageLinearWidth, + hipDeviceAttributeMaxTexture1DLinear, + hDevice->get())); + maxImageWidth = static_cast(maxImageLinearWidth); + } else { + // Verify for standard 1D images backed by opaque memory. + UR_CHECK_ERROR(urDeviceGetInfo(hDevice, + UR_DEVICE_INFO_IMAGE_MAX_BUFFER_SIZE, + sizeof(size_t), &maxImageWidth, nullptr)); + } + if ((pImageDesc->width > maxImageWidth)) { + return false; + } + } + + // Verify 3-channel format support. + // HIP does not allow 3-channel formats. + if (pImageFormat->channelOrder == UR_IMAGE_CHANNEL_ORDER_RGB || + pImageFormat->channelOrder == UR_IMAGE_CHANNEL_ORDER_RGX) { + return false; + } + + // Once we've verified all of the above properties are valid, return true. + return true; +} + +UR_APIEXPORT ur_result_t UR_APICALL +urBindlessImagesGetImageMemoryPointerSupportExp( + ur_context_handle_t hContext, ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, + bool *pSupportedRet) { + UR_ASSERT(std::find(hContext->getDevices().begin(), + hContext->getDevices().end(), + hDevice) != hContext->getDevices().end(), + UR_RESULT_ERROR_INVALID_CONTEXT); + + // Verify support for common image properties (dims, channel types, image + // types, etc.). + *pSupportedRet = verifyCommonImagePropertiesSupport( + hDevice, pImageDesc, pImageFormat, false /* isOpaqueAllocation */); + return UR_RESULT_SUCCESS; +} + +UR_APIEXPORT ur_result_t UR_APICALL +urBindlessImagesGetImageMemoryOpaqueSupportExp( + ur_context_handle_t hContext, ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, + bool *pSupportedRet) { + UR_ASSERT(std::find(hContext->getDevices().begin(), + hContext->getDevices().end(), + hDevice) != hContext->getDevices().end(), + UR_RESULT_ERROR_INVALID_CONTEXT); + + // Verify support for common image properties (dims, channel types, image + // types, etc.). + *pSupportedRet = verifyCommonImagePropertiesSupport( + hDevice, pImageDesc, pImageFormat, true /* isOpaqueAllocation */); + return UR_RESULT_SUCCESS; +} + +UR_APIEXPORT ur_result_t UR_APICALL +urBindlessImagesGetImageUnsampledHandleSupportExp( + ur_context_handle_t hContext, ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, + bool isOpaqueAllocation, bool *pSupportedRet) { + UR_ASSERT(std::find(hContext->getDevices().begin(), + hContext->getDevices().end(), + hDevice) != hContext->getDevices().end(), + UR_RESULT_ERROR_INVALID_CONTEXT); + + // Currently Bindless Images do not allow creation of unsampled image handles + // from non-opaque (USM) memory. + if (!isOpaqueAllocation) { + *pSupportedRet = false; + return UR_RESULT_SUCCESS; + } + + // Bindless Images do not allow creation of `unsampled_image_handle`s for + // mipmap images. + if (pImageDesc->numMipLevel > 1) { + *pSupportedRet = false; + return UR_RESULT_SUCCESS; + } + + // Verify support for common image properties (dims, channel types, image + // types, etc.). + *pSupportedRet = verifyCommonImagePropertiesSupport( + hDevice, pImageDesc, pImageFormat, isOpaqueAllocation); + return UR_RESULT_SUCCESS; +} + +UR_APIEXPORT ur_result_t UR_APICALL +urBindlessImagesGetImageSampledHandleSupportExp( + ur_context_handle_t hContext, ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, + bool isOpaqueAllocation, bool *pSupportedRet) { + UR_ASSERT(std::find(hContext->getDevices().begin(), + hContext->getDevices().end(), + hDevice) != hContext->getDevices().end(), + UR_RESULT_ERROR_INVALID_CONTEXT); + + // Verify support for common image properties (dims, channel types, image + // types, etc.). + *pSupportedRet = verifyCommonImagePropertiesSupport( + hDevice, pImageDesc, pImageFormat, isOpaqueAllocation); + return UR_RESULT_SUCCESS; +} + UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, ur_exp_image_mem_native_handle_t hImageMem, uint32_t mipmapLevel, diff --git a/unified-runtime/source/adapters/hip/image.hpp b/unified-runtime/source/adapters/hip/image.hpp index ef299ffd1194c..e706464c7abd5 100644 --- a/unified-runtime/source/adapters/hip/image.hpp +++ b/unified-runtime/source/adapters/hip/image.hpp @@ -32,3 +32,8 @@ ur_result_t urTextureCreate(ur_sampler_handle_t hSampler, const HIP_RESOURCE_DESC &ResourceDesc, const unsigned int normalized_dtype_flag, ur_exp_image_native_handle_t *phRetImage); + +bool verifyCommonImagePropertiesSupport(const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + const ur_image_format_t *pImageFormat, + bool isOpaqueAllocation); diff --git a/unified-runtime/source/adapters/hip/ur_interface_loader.cpp b/unified-runtime/source/adapters/hip/ur_interface_loader.cpp index d360c5c11bb1e..63bf2af6b939e 100644 --- a/unified-runtime/source/adapters/hip/ur_interface_loader.cpp +++ b/unified-runtime/source/adapters/hip/ur_interface_loader.cpp @@ -349,6 +349,15 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetBindlessImagesExpProcAddrTable( urBindlessImagesWaitExternalSemaphoreExp; pDdiTable->pfnSignalExternalSemaphoreExp = urBindlessImagesSignalExternalSemaphoreExp; + pDdiTable->pfnGetImageMemoryPointerSupportExp = + urBindlessImagesGetImageMemoryPointerSupportExp; + pDdiTable->pfnGetImageMemoryOpaqueSupportExp = + urBindlessImagesGetImageMemoryOpaqueSupportExp; + pDdiTable->pfnGetImageUnsampledHandleSupportExp = + urBindlessImagesGetImageUnsampledHandleSupportExp; + pDdiTable->pfnGetImageSampledHandleSupportExp = + urBindlessImagesGetImageSampledHandleSupportExp; + return UR_RESULT_SUCCESS; } diff --git a/unified-runtime/source/adapters/level_zero/helpers/image_helpers.cpp b/unified-runtime/source/adapters/level_zero/helpers/image_helpers.cpp index 9da1750e8c1f9..0bb47cc0774c7 100644 --- a/unified-runtime/source/adapters/level_zero/helpers/image_helpers.cpp +++ b/unified-runtime/source/adapters/level_zero/helpers/image_helpers.cpp @@ -9,6 +9,7 @@ //===----------------------------------------------------------------------===// #include "image_helpers.hpp" +#include "device.hpp" /// Construct UR image format from ZE image desc. ur_result_t ze2urImageFormat(const ze_image_desc_t *ZeImageDesc, @@ -520,3 +521,90 @@ getImageFormatTypeAndSize(const ur_image_format_t *ImageFormat) { } return {ZeImageFormatType, ZeImageFormatTypeSize}; } + +bool verifyCommonImagePropertiesSupport(const ur_device_handle_t ZeDevice, + const ur_image_desc_t *ZeImageDesc, + const ur_image_format_t *ZeImageFormat, + bool isOpaqueAllocation) { + + // Verify image dimensions are within device limits. + if (ZeImageDesc->depth != 0 && ZeImageDesc->type == UR_MEM_TYPE_IMAGE3D) { + if ((ZeDevice->ZeDeviceImageProperties->maxImageDims3D == 0) || + (ZeImageDesc->width > + ZeDevice->ZeDeviceImageProperties->maxImageDims3D) || + (ZeImageDesc->height > + ZeDevice->ZeDeviceImageProperties->maxImageDims3D) || + (ZeImageDesc->depth > + ZeDevice->ZeDeviceImageProperties->maxImageDims3D)) { + return false; + } + } else if (ZeImageDesc->height != 0 && + ZeImageDesc->type == UR_MEM_TYPE_IMAGE2D) { + if (((ZeDevice->ZeDeviceImageProperties->maxImageDims2D == 0) || + (ZeImageDesc->width > + ZeDevice->ZeDeviceImageProperties->maxImageDims2D) || + (ZeImageDesc->height > + ZeDevice->ZeDeviceImageProperties->maxImageDims2D))) { + return false; + } + } else if (ZeImageDesc->width != 0 && + ZeImageDesc->type == UR_MEM_TYPE_IMAGE1D) { + if ((ZeDevice->ZeDeviceImageProperties->maxImageDims1D == 0) || + (ZeImageDesc->width > + ZeDevice->ZeDeviceImageProperties->maxImageDims1D)) { + return false; + } + } + + // Verify 3-channel format support. + // LevelZero allows 3-channel formats for `uchar` and `ushort`. + if (Is3ChannelOrder(ZeImageFormat->channelOrder)) { + switch (ZeImageFormat->channelType) { + default: + return false; + case UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT8: + case UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT16: + break; + } + } + + // Verify unnormalized channel type support. + // LevelZero currently doesn't support unnormalized channel types. + switch (ZeImageFormat->channelType) { + default: + break; + case UR_IMAGE_CHANNEL_TYPE_UNORM_INT8: + case UR_IMAGE_CHANNEL_TYPE_UNORM_INT16: + return false; + } + + // Verify support for mipmap images. + // LevelZero currently does not support mipmap images. + if (ZeImageDesc->numMipLevel > 1) { + return false; + } + + // Verify support for cubemap images. + // LevelZero current does not support cubemap images. + if (ZeImageDesc->type == UR_MEM_TYPE_IMAGE_CUBEMAP_EXP) { + return false; + } + + // Verify support for gather images. + // LevelZero current does not support gather images. + if (ZeImageDesc->type == UR_MEM_TYPE_IMAGE_GATHER_EXP) { + return false; + } + + // Verify support for layered images. + // Bindless Images do not provide support for layered images/image arrays + // backed by USM pointers. + if (((ZeImageDesc->type == UR_MEM_TYPE_IMAGE1D_ARRAY) || + (ZeImageDesc->type == UR_MEM_TYPE_IMAGE2D_ARRAY)) && + !isOpaqueAllocation) { + return false; + } + + // All properties have been checked. Return true. + return true; +} diff --git a/unified-runtime/source/adapters/level_zero/helpers/image_helpers.hpp b/unified-runtime/source/adapters/level_zero/helpers/image_helpers.hpp index 04c4e08d1b9d1..cebebcc88e966 100644 --- a/unified-runtime/source/adapters/level_zero/helpers/image_helpers.hpp +++ b/unified-runtime/source/adapters/level_zero/helpers/image_helpers.hpp @@ -36,3 +36,8 @@ ur_result_t getImageRegionHelper(ze_image_desc_t ZeImageDesc, std::pair getImageFormatTypeAndSize(const ur_image_format_t *ImageFormat); + +bool verifyCommonImagePropertiesSupport(const ur_device_handle_t ZeDevice, + const ur_image_desc_t *ZeImageDesc, + const ur_image_format_t *ZeImageFormat, + bool isOpaqueAllocation); diff --git a/unified-runtime/source/adapters/level_zero/image.cpp b/unified-runtime/source/adapters/level_zero/image.cpp index 24b2a8cfca758..67c3b9c232a6b 100644 --- a/unified-runtime/source/adapters/level_zero/image.cpp +++ b/unified-runtime/source/adapters/level_zero/image.cpp @@ -14,6 +14,7 @@ #include "helpers/image_helpers.hpp" #include "logger/ur_logger.hpp" #include "sampler.hpp" +#include "ur_api.h" #include "ur_interface_loader.hpp" #include "ur_level_zero.hpp" @@ -610,6 +611,86 @@ ur_result_t urBindlessImagesImageGetInfoExp( } } +ur_result_t urBindlessImagesGetImageMemoryPointerSupportExp( + ur_context_handle_t hContext, ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, + bool *pSupportedRet) { + UR_ASSERT(std::find(hContext->getDevices().begin(), + hContext->getDevices().end(), + hDevice) != hContext->getDevices().end(), + UR_RESULT_ERROR_INVALID_CONTEXT); + + // Verify support for common image properties (dims, channel types, image + // types, etc.). + *pSupportedRet = verifyCommonImagePropertiesSupport( + hDevice, pImageDesc, pImageFormat, false /* isOpaqueAllocation */); + return UR_RESULT_SUCCESS; +} + +ur_result_t urBindlessImagesGetImageMemoryOpaqueSupportExp( + ur_context_handle_t hContext, ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, + bool *pSupportedRet) { + UR_ASSERT(std::find(hContext->getDevices().begin(), + hContext->getDevices().end(), + hDevice) != hContext->getDevices().end(), + UR_RESULT_ERROR_INVALID_CONTEXT); + + // Verify support for common image properties (dims, channel types, image + // types, etc.). + *pSupportedRet = verifyCommonImagePropertiesSupport( + hDevice, pImageDesc, pImageFormat, true /* isOpaqueAllocation */); + return UR_RESULT_SUCCESS; +} + +ur_result_t urBindlessImagesGetImageUnsampledHandleSupportExp( + ur_context_handle_t hContext, ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, + bool isOpaqueAllocation, bool *pSupportedRet) { + UR_ASSERT(std::find(hContext->getDevices().begin(), + hContext->getDevices().end(), + hDevice) != hContext->getDevices().end(), + UR_RESULT_ERROR_INVALID_CONTEXT); + + // Currently the Bindless Images extension does not allow creation of + // unsampled image handles from non-opaque (USM) memory. + if (!isOpaqueAllocation) { + *pSupportedRet = false; + return UR_RESULT_SUCCESS; + } + + // Bindless Images do not allow creation of `unsampled_image_handle`s for + // mipmap images. + if (pImageDesc->numMipLevel > 1) { + *pSupportedRet = false; + return UR_RESULT_SUCCESS; + } + + // Verify support for common image properties (dims, channel types, image + // types, etc.). + *pSupportedRet = verifyCommonImagePropertiesSupport( + hDevice, pImageDesc, pImageFormat, isOpaqueAllocation); + + return UR_RESULT_SUCCESS; +} + +ur_result_t urBindlessImagesGetImageSampledHandleSupportExp( + ur_context_handle_t hContext, ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, + bool isOpaqueAllocation, bool *pSupportedRet) { + UR_ASSERT(std::find(hContext->getDevices().begin(), + hContext->getDevices().end(), + hDevice) != hContext->getDevices().end(), + UR_RESULT_ERROR_INVALID_CONTEXT); + + // Verify support for common image properties (dims, channel types, image + // types, etc.). + *pSupportedRet = verifyCommonImagePropertiesSupport( + hDevice, pImageDesc, pImageFormat, isOpaqueAllocation); + + return UR_RESULT_SUCCESS; +} + ur_result_t urBindlessImagesMipmapGetLevelExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, ur_exp_image_mem_native_handle_t hImageMem, uint32_t mipmapLevel, diff --git a/unified-runtime/source/adapters/level_zero/ur_interface_loader.cpp b/unified-runtime/source/adapters/level_zero/ur_interface_loader.cpp index ede76fa63baf8..b37b7a2f3d1a4 100644 --- a/unified-runtime/source/adapters/level_zero/ur_interface_loader.cpp +++ b/unified-runtime/source/adapters/level_zero/ur_interface_loader.cpp @@ -69,6 +69,14 @@ UR_APIEXPORT ur_result_t UR_APICALL urGetBindlessImagesExpProcAddrTable( pDdiTable->pfnImageCopyExp = ur::level_zero::urBindlessImagesImageCopyExp; pDdiTable->pfnImageGetInfoExp = ur::level_zero::urBindlessImagesImageGetInfoExp; + pDdiTable->pfnGetImageMemoryPointerSupportExp = + ur::level_zero::urBindlessImagesGetImageMemoryPointerSupportExp; + pDdiTable->pfnGetImageMemoryOpaqueSupportExp = + ur::level_zero::urBindlessImagesGetImageMemoryOpaqueSupportExp; + pDdiTable->pfnGetImageUnsampledHandleSupportExp = + ur::level_zero::urBindlessImagesGetImageUnsampledHandleSupportExp; + pDdiTable->pfnGetImageSampledHandleSupportExp = + ur::level_zero::urBindlessImagesGetImageSampledHandleSupportExp; pDdiTable->pfnMipmapGetLevelExp = ur::level_zero::urBindlessImagesMipmapGetLevelExp; pDdiTable->pfnMipmapFreeExp = ur::level_zero::urBindlessImagesMipmapFreeExp; diff --git a/unified-runtime/source/adapters/level_zero/ur_interface_loader.hpp b/unified-runtime/source/adapters/level_zero/ur_interface_loader.hpp index 78eb006d4d2ff..a53fa503ab300 100644 --- a/unified-runtime/source/adapters/level_zero/ur_interface_loader.hpp +++ b/unified-runtime/source/adapters/level_zero/ur_interface_loader.hpp @@ -553,6 +553,22 @@ ur_result_t urBindlessImagesImageCopyExp( ur_result_t urBindlessImagesImageGetInfoExp( ur_context_handle_t hContext, ur_exp_image_mem_native_handle_t hImageMem, ur_image_info_t propName, void *pPropValue, size_t *pPropSizeRet); +ur_result_t urBindlessImagesGetImageMemoryPointerSupportExp( + ur_context_handle_t hContext, ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, + bool *pSupportedRet); +ur_result_t urBindlessImagesGetImageMemoryOpaqueSupportExp( + ur_context_handle_t hContext, ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, + bool *pSupportedRet); +ur_result_t urBindlessImagesGetImageUnsampledHandleSupportExp( + ur_context_handle_t hContext, ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, + bool isOpaqueAllocation, bool *pSupportedRet); +ur_result_t urBindlessImagesGetImageSampledHandleSupportExp( + ur_context_handle_t hContext, ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, + bool isOpaqueAllocation, bool *pSupportedRet); ur_result_t urBindlessImagesMipmapGetLevelExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, ur_exp_image_mem_native_handle_t hImageMem, uint32_t mipmapLevel, diff --git a/unified-runtime/source/adapters/level_zero/v2/api.cpp b/unified-runtime/source/adapters/level_zero/v2/api.cpp index 1912434529127..84365d0d1c171 100644 --- a/unified-runtime/source/adapters/level_zero/v2/api.cpp +++ b/unified-runtime/source/adapters/level_zero/v2/api.cpp @@ -170,6 +170,38 @@ ur_result_t urBindlessImagesReleaseExternalSemaphoreExp( return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } +ur_result_t urBindlessImagesGetImageMemoryPointerSupportExp( + ur_context_handle_t hContext, ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, + bool *pSupportedRet) { + logger::error("{} function not implemented!", __FUNCTION__); + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +ur_result_t urBindlessImagesGetImageMemoryOpaqueSupportExp( + ur_context_handle_t hContext, ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, + bool *pSupportedRet) { + logger::error("{} function not implemented!", __FUNCTION__); + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +ur_result_t urBindlessImagesGetImageUnsampledHandleSupportExp( + ur_context_handle_t hContext, ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, + bool isOpaqueAllocation, bool *pSupportedRet) { + logger::error("{} function not implemented!", __FUNCTION__); + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +ur_result_t urBindlessImagesGetImageSampledHandleSupportExp( + ur_context_handle_t hContext, ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, + bool isOpaqueAllocation, bool *pSupportedRet) { + logger::error("{} function not implemented!", __FUNCTION__); + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + ur_result_t urCommandBufferUpdateKernelLaunchExp( ur_exp_command_buffer_handle_t hCommandBuffer, uint32_t numKernelUpdates, const ur_exp_command_buffer_update_kernel_launch_desc_t diff --git a/unified-runtime/source/adapters/mock/ur_mockddi.cpp b/unified-runtime/source/adapters/mock/ur_mockddi.cpp index 805b612dd69a5..5f950041743ef 100644 --- a/unified-runtime/source/adapters/mock/ur_mockddi.cpp +++ b/unified-runtime/source/adapters/mock/ur_mockddi.cpp @@ -8459,6 +8459,240 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( return exceptionToResult(std::current_exception()); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for +/// urBindlessImagesGetImageMemoryPointerSupportExp +__urdlllocal ur_result_t UR_APICALL +urBindlessImagesGetImageMemoryPointerSupportExp( + /// [in] handle of the context object + ur_context_handle_t hContext, + /// [in] handle of the device object + ur_device_handle_t hDevice, + /// [in] pointer to image description + const ur_image_desc_t *pImageDesc, + /// [in] pointer to image format specification + const ur_image_format_t *pImageFormat, + /// [out] returned indication of support for allocating USM style memory + bool *pSupportedRet) try { + ur_result_t result = UR_RESULT_SUCCESS; + + ur_bindless_images_get_image_memory_pointer_support_exp_params_t params = { + &hContext, &hDevice, &pImageDesc, &pImageFormat, &pSupportedRet}; + + auto beforeCallback = reinterpret_cast( + mock::getCallbacks().get_before_callback( + "urBindlessImagesGetImageMemoryPointerSupportExp")); + if (beforeCallback) { + result = beforeCallback(¶ms); + if (result != UR_RESULT_SUCCESS) { + return result; + } + } + + auto replaceCallback = reinterpret_cast( + mock::getCallbacks().get_replace_callback( + "urBindlessImagesGetImageMemoryPointerSupportExp")); + if (replaceCallback) { + result = replaceCallback(¶ms); + } else { + + result = UR_RESULT_SUCCESS; + } + + if (result != UR_RESULT_SUCCESS) { + return result; + } + + auto afterCallback = reinterpret_cast( + mock::getCallbacks().get_after_callback( + "urBindlessImagesGetImageMemoryPointerSupportExp")); + if (afterCallback) { + return afterCallback(¶ms); + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urBindlessImagesGetImageMemoryOpaqueSupportExp +__urdlllocal ur_result_t UR_APICALL +urBindlessImagesGetImageMemoryOpaqueSupportExp( + /// [in] handle of the context object + ur_context_handle_t hContext, + /// [in] handle of the device object + ur_device_handle_t hDevice, + /// [in] pointer to image description + const ur_image_desc_t *pImageDesc, + /// [in] pointer to image format specification + const ur_image_format_t *pImageFormat, + /// [out] returned indication of support for allocating opaque handle + /// memory + bool *pSupportedRet) try { + ur_result_t result = UR_RESULT_SUCCESS; + + ur_bindless_images_get_image_memory_opaque_support_exp_params_t params = { + &hContext, &hDevice, &pImageDesc, &pImageFormat, &pSupportedRet}; + + auto beforeCallback = reinterpret_cast( + mock::getCallbacks().get_before_callback( + "urBindlessImagesGetImageMemoryOpaqueSupportExp")); + if (beforeCallback) { + result = beforeCallback(¶ms); + if (result != UR_RESULT_SUCCESS) { + return result; + } + } + + auto replaceCallback = reinterpret_cast( + mock::getCallbacks().get_replace_callback( + "urBindlessImagesGetImageMemoryOpaqueSupportExp")); + if (replaceCallback) { + result = replaceCallback(¶ms); + } else { + + result = UR_RESULT_SUCCESS; + } + + if (result != UR_RESULT_SUCCESS) { + return result; + } + + auto afterCallback = reinterpret_cast( + mock::getCallbacks().get_after_callback( + "urBindlessImagesGetImageMemoryOpaqueSupportExp")); + if (afterCallback) { + return afterCallback(¶ms); + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for +/// urBindlessImagesGetImageUnsampledHandleSupportExp +__urdlllocal ur_result_t UR_APICALL +urBindlessImagesGetImageUnsampledHandleSupportExp( + /// [in] handle of the context object + ur_context_handle_t hContext, + /// [in] handle of the device object + ur_device_handle_t hDevice, + /// [in] pointer to image description + const ur_image_desc_t *pImageDesc, + /// [in] pointer to image format specification + const ur_image_format_t *pImageFormat, + /// [in] indicates whether the image memory would be backed by an opaque + /// handle allocation + bool isOpaqueAllocation, + /// [out] returned indication of support for creating unsampled image + /// handles + bool *pSupportedRet) try { + ur_result_t result = UR_RESULT_SUCCESS; + + ur_bindless_images_get_image_unsampled_handle_support_exp_params_t params = { + &hContext, &hDevice, &pImageDesc, &pImageFormat, + &isOpaqueAllocation, &pSupportedRet}; + + auto beforeCallback = reinterpret_cast( + mock::getCallbacks().get_before_callback( + "urBindlessImagesGetImageUnsampledHandleSupportExp")); + if (beforeCallback) { + result = beforeCallback(¶ms); + if (result != UR_RESULT_SUCCESS) { + return result; + } + } + + auto replaceCallback = reinterpret_cast( + mock::getCallbacks().get_replace_callback( + "urBindlessImagesGetImageUnsampledHandleSupportExp")); + if (replaceCallback) { + result = replaceCallback(¶ms); + } else { + + result = UR_RESULT_SUCCESS; + } + + if (result != UR_RESULT_SUCCESS) { + return result; + } + + auto afterCallback = reinterpret_cast( + mock::getCallbacks().get_after_callback( + "urBindlessImagesGetImageUnsampledHandleSupportExp")); + if (afterCallback) { + return afterCallback(¶ms); + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for +/// urBindlessImagesGetImageSampledHandleSupportExp +__urdlllocal ur_result_t UR_APICALL +urBindlessImagesGetImageSampledHandleSupportExp( + /// [in] handle of the context object + ur_context_handle_t hContext, + /// [in] handle of the device object + ur_device_handle_t hDevice, + /// [in] pointer to image description + const ur_image_desc_t *pImageDesc, + /// [in] pointer to image format specification + const ur_image_format_t *pImageFormat, + /// [in] indicates whether the image memory would be backed by an opaque + /// handle allocation + bool isOpaqueAllocation, + /// [out] returned indication of support for creating sampled image + /// handles + bool *pSupportedRet) try { + ur_result_t result = UR_RESULT_SUCCESS; + + ur_bindless_images_get_image_sampled_handle_support_exp_params_t params = { + &hContext, &hDevice, &pImageDesc, &pImageFormat, + &isOpaqueAllocation, &pSupportedRet}; + + auto beforeCallback = reinterpret_cast( + mock::getCallbacks().get_before_callback( + "urBindlessImagesGetImageSampledHandleSupportExp")); + if (beforeCallback) { + result = beforeCallback(¶ms); + if (result != UR_RESULT_SUCCESS) { + return result; + } + } + + auto replaceCallback = reinterpret_cast( + mock::getCallbacks().get_replace_callback( + "urBindlessImagesGetImageSampledHandleSupportExp")); + if (replaceCallback) { + result = replaceCallback(¶ms); + } else { + + result = UR_RESULT_SUCCESS; + } + + if (result != UR_RESULT_SUCCESS) { + return result; + } + + auto afterCallback = reinterpret_cast( + mock::getCallbacks().get_after_callback( + "urBindlessImagesGetImageSampledHandleSupportExp")); + if (afterCallback) { + return afterCallback(¶ms); + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urBindlessImagesMipmapGetLevelExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( @@ -11725,6 +11959,18 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetBindlessImagesExpProcAddrTable( pDdiTable->pfnImageGetInfoExp = driver::urBindlessImagesImageGetInfoExp; + pDdiTable->pfnGetImageMemoryPointerSupportExp = + driver::urBindlessImagesGetImageMemoryPointerSupportExp; + + pDdiTable->pfnGetImageMemoryOpaqueSupportExp = + driver::urBindlessImagesGetImageMemoryOpaqueSupportExp; + + pDdiTable->pfnGetImageUnsampledHandleSupportExp = + driver::urBindlessImagesGetImageUnsampledHandleSupportExp; + + pDdiTable->pfnGetImageSampledHandleSupportExp = + driver::urBindlessImagesGetImageSampledHandleSupportExp; + pDdiTable->pfnMipmapGetLevelExp = driver::urBindlessImagesMipmapGetLevelExp; pDdiTable->pfnMipmapFreeExp = driver::urBindlessImagesMipmapFreeExp; diff --git a/unified-runtime/source/adapters/native_cpu/image.cpp b/unified-runtime/source/adapters/native_cpu/image.cpp index d89990ed10c9e..7400bf9446c75 100644 --- a/unified-runtime/source/adapters/native_cpu/image.cpp +++ b/unified-runtime/source/adapters/native_cpu/image.cpp @@ -97,6 +97,48 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } +UR_APIEXPORT ur_result_t UR_APICALL +urBindlessImagesGetImageMemoryPointerSupportExp( + [[maybe_unused]] ur_context_handle_t hContext, + [[maybe_unused]] ur_device_handle_t hDevice, + [[maybe_unused]] const ur_image_desc_t *pImageDesc, + [[maybe_unused]] const ur_image_format_t *pImageFormat, + [[maybe_unused]] bool *pSupportedRet) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t UR_APICALL +urBindlessImagesGetImageMemoryOpaqueSupportExp( + [[maybe_unused]] ur_context_handle_t hContext, + [[maybe_unused]] ur_device_handle_t hDevice, + [[maybe_unused]] const ur_image_desc_t *pImageDesc, + [[maybe_unused]] const ur_image_format_t *pImageFormat, + [[maybe_unused]] bool *pSupportedRet) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t UR_APICALL +urBindlessImagesGetImageUnsampledHandleSupportExp( + [[maybe_unused]] ur_context_handle_t hContext, + [[maybe_unused]] ur_device_handle_t hDevice, + [[maybe_unused]] const ur_image_desc_t *pImageDesc, + [[maybe_unused]] const ur_image_format_t *pImageFormat, + [[maybe_unused]] bool isOpaqueAllocation, + [[maybe_unused]] bool *pSupportedRet) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t UR_APICALL +urBindlessImagesGetImageSampledHandleSupportExp( + [[maybe_unused]] ur_context_handle_t hContext, + [[maybe_unused]] ur_device_handle_t hDevice, + [[maybe_unused]] const ur_image_desc_t *pImageDesc, + [[maybe_unused]] const ur_image_format_t *pImageFormat, + [[maybe_unused]] bool isOpaqueAllocation, + [[maybe_unused]] bool *pSupportedRet) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( [[maybe_unused]] ur_context_handle_t hContext, [[maybe_unused]] ur_device_handle_t hDevice, diff --git a/unified-runtime/source/adapters/native_cpu/ur_interface_loader.cpp b/unified-runtime/source/adapters/native_cpu/ur_interface_loader.cpp index ca158f82ee07b..c7eaf28d69a56 100644 --- a/unified-runtime/source/adapters/native_cpu/ur_interface_loader.cpp +++ b/unified-runtime/source/adapters/native_cpu/ur_interface_loader.cpp @@ -343,6 +343,15 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetBindlessImagesExpProcAddrTable( urBindlessImagesWaitExternalSemaphoreExp; pDdiTable->pfnSignalExternalSemaphoreExp = urBindlessImagesSignalExternalSemaphoreExp; + pDdiTable->pfnGetImageMemoryPointerSupportExp = + urBindlessImagesGetImageMemoryPointerSupportExp; + pDdiTable->pfnGetImageMemoryOpaqueSupportExp = + urBindlessImagesGetImageMemoryOpaqueSupportExp; + pDdiTable->pfnGetImageUnsampledHandleSupportExp = + urBindlessImagesGetImageUnsampledHandleSupportExp; + pDdiTable->pfnGetImageSampledHandleSupportExp = + urBindlessImagesGetImageSampledHandleSupportExp; + return UR_RESULT_SUCCESS; } diff --git a/unified-runtime/source/adapters/opencl/image.cpp b/unified-runtime/source/adapters/opencl/image.cpp index 0c628594bb55d..e414fbb75643a 100644 --- a/unified-runtime/source/adapters/opencl/image.cpp +++ b/unified-runtime/source/adapters/opencl/image.cpp @@ -97,6 +97,48 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } +UR_APIEXPORT ur_result_t UR_APICALL +urBindlessImagesGetImageMemoryPointerSupportExp( + [[maybe_unused]] ur_context_handle_t hContext, + [[maybe_unused]] ur_device_handle_t hDevice, + [[maybe_unused]] const ur_image_desc_t *pImageDesc, + [[maybe_unused]] const ur_image_format_t *pImageFormat, + [[maybe_unused]] bool *pSupportedRet) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t UR_APICALL +urBindlessImagesGetImageMemoryOpaqueSupportExp( + [[maybe_unused]] ur_context_handle_t hContext, + [[maybe_unused]] ur_device_handle_t hDevice, + [[maybe_unused]] const ur_image_desc_t *pImageDesc, + [[maybe_unused]] const ur_image_format_t *pImageFormat, + [[maybe_unused]] bool *pSupportedRet) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t UR_APICALL +urBindlessImagesGetImageUnsampledHandleSupportExp( + [[maybe_unused]] ur_context_handle_t hContext, + [[maybe_unused]] ur_device_handle_t hDevice, + [[maybe_unused]] const ur_image_desc_t *pImageDesc, + [[maybe_unused]] const ur_image_format_t *pImageFormat, + [[maybe_unused]] bool isOpaqueAllocation, + [[maybe_unused]] bool *pSupportedRet) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t UR_APICALL +urBindlessImagesGetImageSampledHandleSupportExp( + [[maybe_unused]] ur_context_handle_t hContext, + [[maybe_unused]] ur_device_handle_t hDevice, + [[maybe_unused]] const ur_image_desc_t *pImageDesc, + [[maybe_unused]] const ur_image_format_t *pImageFormat, + [[maybe_unused]] bool isOpaqueAllocation, + [[maybe_unused]] bool *pSupportedRet) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( [[maybe_unused]] ur_context_handle_t hContext, [[maybe_unused]] ur_device_handle_t hDevice, diff --git a/unified-runtime/source/adapters/opencl/ur_interface_loader.cpp b/unified-runtime/source/adapters/opencl/ur_interface_loader.cpp index 72e6140526f7d..c6e7cac4951f8 100644 --- a/unified-runtime/source/adapters/opencl/ur_interface_loader.cpp +++ b/unified-runtime/source/adapters/opencl/ur_interface_loader.cpp @@ -362,6 +362,14 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetBindlessImagesExpProcAddrTable( urBindlessImagesWaitExternalSemaphoreExp; pDdiTable->pfnSignalExternalSemaphoreExp = urBindlessImagesSignalExternalSemaphoreExp; + pDdiTable->pfnGetImageMemoryPointerSupportExp = + urBindlessImagesGetImageMemoryPointerSupportExp; + pDdiTable->pfnGetImageMemoryOpaqueSupportExp = + urBindlessImagesGetImageMemoryOpaqueSupportExp; + pDdiTable->pfnGetImageUnsampledHandleSupportExp = + urBindlessImagesGetImageUnsampledHandleSupportExp; + pDdiTable->pfnGetImageSampledHandleSupportExp = + urBindlessImagesGetImageSampledHandleSupportExp; return UR_RESULT_SUCCESS; } diff --git a/unified-runtime/source/loader/layers/tracing/ur_trcddi.cpp b/unified-runtime/source/loader/layers/tracing/ur_trcddi.cpp index 47b804becb41e..132cf41601c42 100644 --- a/unified-runtime/source/loader/layers/tracing/ur_trcddi.cpp +++ b/unified-runtime/source/loader/layers/tracing/ur_trcddi.cpp @@ -7012,6 +7012,230 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for +/// urBindlessImagesGetImageMemoryPointerSupportExp +__urdlllocal ur_result_t UR_APICALL +urBindlessImagesGetImageMemoryPointerSupportExp( + /// [in] handle of the context object + ur_context_handle_t hContext, + /// [in] handle of the device object + ur_device_handle_t hDevice, + /// [in] pointer to image description + const ur_image_desc_t *pImageDesc, + /// [in] pointer to image format specification + const ur_image_format_t *pImageFormat, + /// [out] returned indication of support for allocating USM style memory + bool *pSupportedRet) { + auto pfnGetImageMemoryPointerSupportExp = + getContext() + ->urDdiTable.BindlessImagesExp.pfnGetImageMemoryPointerSupportExp; + + if (nullptr == pfnGetImageMemoryPointerSupportExp) + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ur_bindless_images_get_image_memory_pointer_support_exp_params_t params = { + &hContext, &hDevice, &pImageDesc, &pImageFormat, &pSupportedRet}; + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_POINTER_SUPPORT_EXP, + "urBindlessImagesGetImageMemoryPointerSupportExp", ¶ms); + + auto &logger = getContext()->logger; + logger.info(" ---> urBindlessImagesGetImageMemoryPointerSupportExp\n"); + + ur_result_t result = pfnGetImageMemoryPointerSupportExp( + hContext, hDevice, pImageDesc, pImageFormat, pSupportedRet); + + getContext()->notify_end( + UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_POINTER_SUPPORT_EXP, + "urBindlessImagesGetImageMemoryPointerSupportExp", ¶ms, &result, + instance); + + if (logger.getLevel() <= logger::Level::INFO) { + std::ostringstream args_str; + ur::extras::printFunctionParams( + args_str, + UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_POINTER_SUPPORT_EXP, + ¶ms); + logger.info( + " <--- urBindlessImagesGetImageMemoryPointerSupportExp({}) -> {};\n", + args_str.str(), result); + } + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urBindlessImagesGetImageMemoryOpaqueSupportExp +__urdlllocal ur_result_t UR_APICALL +urBindlessImagesGetImageMemoryOpaqueSupportExp( + /// [in] handle of the context object + ur_context_handle_t hContext, + /// [in] handle of the device object + ur_device_handle_t hDevice, + /// [in] pointer to image description + const ur_image_desc_t *pImageDesc, + /// [in] pointer to image format specification + const ur_image_format_t *pImageFormat, + /// [out] returned indication of support for allocating opaque handle + /// memory + bool *pSupportedRet) { + auto pfnGetImageMemoryOpaqueSupportExp = + getContext() + ->urDdiTable.BindlessImagesExp.pfnGetImageMemoryOpaqueSupportExp; + + if (nullptr == pfnGetImageMemoryOpaqueSupportExp) + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ur_bindless_images_get_image_memory_opaque_support_exp_params_t params = { + &hContext, &hDevice, &pImageDesc, &pImageFormat, &pSupportedRet}; + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_OPAQUE_SUPPORT_EXP, + "urBindlessImagesGetImageMemoryOpaqueSupportExp", ¶ms); + + auto &logger = getContext()->logger; + logger.info(" ---> urBindlessImagesGetImageMemoryOpaqueSupportExp\n"); + + ur_result_t result = pfnGetImageMemoryOpaqueSupportExp( + hContext, hDevice, pImageDesc, pImageFormat, pSupportedRet); + + getContext()->notify_end( + UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_OPAQUE_SUPPORT_EXP, + "urBindlessImagesGetImageMemoryOpaqueSupportExp", ¶ms, &result, + instance); + + if (logger.getLevel() <= logger::Level::INFO) { + std::ostringstream args_str; + ur::extras::printFunctionParams( + args_str, + UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_OPAQUE_SUPPORT_EXP, + ¶ms); + logger.info( + " <--- urBindlessImagesGetImageMemoryOpaqueSupportExp({}) -> {};\n", + args_str.str(), result); + } + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for +/// urBindlessImagesGetImageUnsampledHandleSupportExp +__urdlllocal ur_result_t UR_APICALL +urBindlessImagesGetImageUnsampledHandleSupportExp( + /// [in] handle of the context object + ur_context_handle_t hContext, + /// [in] handle of the device object + ur_device_handle_t hDevice, + /// [in] pointer to image description + const ur_image_desc_t *pImageDesc, + /// [in] pointer to image format specification + const ur_image_format_t *pImageFormat, + /// [in] indicates whether the image memory would be backed by an opaque + /// handle allocation + bool isOpaqueAllocation, + /// [out] returned indication of support for creating unsampled image + /// handles + bool *pSupportedRet) { + auto pfnGetImageUnsampledHandleSupportExp = + getContext() + ->urDdiTable.BindlessImagesExp.pfnGetImageUnsampledHandleSupportExp; + + if (nullptr == pfnGetImageUnsampledHandleSupportExp) + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ur_bindless_images_get_image_unsampled_handle_support_exp_params_t params = { + &hContext, &hDevice, &pImageDesc, &pImageFormat, + &isOpaqueAllocation, &pSupportedRet}; + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_UNSAMPLED_HANDLE_SUPPORT_EXP, + "urBindlessImagesGetImageUnsampledHandleSupportExp", ¶ms); + + auto &logger = getContext()->logger; + logger.info(" ---> urBindlessImagesGetImageUnsampledHandleSupportExp\n"); + + ur_result_t result = pfnGetImageUnsampledHandleSupportExp( + hContext, hDevice, pImageDesc, pImageFormat, isOpaqueAllocation, + pSupportedRet); + + getContext()->notify_end( + UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_UNSAMPLED_HANDLE_SUPPORT_EXP, + "urBindlessImagesGetImageUnsampledHandleSupportExp", ¶ms, &result, + instance); + + if (logger.getLevel() <= logger::Level::INFO) { + std::ostringstream args_str; + ur::extras::printFunctionParams( + args_str, + UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_UNSAMPLED_HANDLE_SUPPORT_EXP, + ¶ms); + logger.info(" <--- urBindlessImagesGetImageUnsampledHandleSupportExp({}) " + "-> {};\n", + args_str.str(), result); + } + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for +/// urBindlessImagesGetImageSampledHandleSupportExp +__urdlllocal ur_result_t UR_APICALL +urBindlessImagesGetImageSampledHandleSupportExp( + /// [in] handle of the context object + ur_context_handle_t hContext, + /// [in] handle of the device object + ur_device_handle_t hDevice, + /// [in] pointer to image description + const ur_image_desc_t *pImageDesc, + /// [in] pointer to image format specification + const ur_image_format_t *pImageFormat, + /// [in] indicates whether the image memory would be backed by an opaque + /// handle allocation + bool isOpaqueAllocation, + /// [out] returned indication of support for creating sampled image + /// handles + bool *pSupportedRet) { + auto pfnGetImageSampledHandleSupportExp = + getContext() + ->urDdiTable.BindlessImagesExp.pfnGetImageSampledHandleSupportExp; + + if (nullptr == pfnGetImageSampledHandleSupportExp) + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ur_bindless_images_get_image_sampled_handle_support_exp_params_t params = { + &hContext, &hDevice, &pImageDesc, &pImageFormat, + &isOpaqueAllocation, &pSupportedRet}; + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_SAMPLED_HANDLE_SUPPORT_EXP, + "urBindlessImagesGetImageSampledHandleSupportExp", ¶ms); + + auto &logger = getContext()->logger; + logger.info(" ---> urBindlessImagesGetImageSampledHandleSupportExp\n"); + + ur_result_t result = pfnGetImageSampledHandleSupportExp( + hContext, hDevice, pImageDesc, pImageFormat, isOpaqueAllocation, + pSupportedRet); + + getContext()->notify_end( + UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_SAMPLED_HANDLE_SUPPORT_EXP, + "urBindlessImagesGetImageSampledHandleSupportExp", ¶ms, &result, + instance); + + if (logger.getLevel() <= logger::Level::INFO) { + std::ostringstream args_str; + ur::extras::printFunctionParams( + args_str, + UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_SAMPLED_HANDLE_SUPPORT_EXP, + ¶ms); + logger.info( + " <--- urBindlessImagesGetImageSampledHandleSupportExp({}) -> {};\n", + args_str.str(), result); + } + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urBindlessImagesMipmapGetLevelExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( @@ -9841,6 +10065,26 @@ __urdlllocal ur_result_t UR_APICALL urGetBindlessImagesExpProcAddrTable( pDdiTable->pfnImageGetInfoExp = ur_tracing_layer::urBindlessImagesImageGetInfoExp; + dditable.pfnGetImageMemoryPointerSupportExp = + pDdiTable->pfnGetImageMemoryPointerSupportExp; + pDdiTable->pfnGetImageMemoryPointerSupportExp = + ur_tracing_layer::urBindlessImagesGetImageMemoryPointerSupportExp; + + dditable.pfnGetImageMemoryOpaqueSupportExp = + pDdiTable->pfnGetImageMemoryOpaqueSupportExp; + pDdiTable->pfnGetImageMemoryOpaqueSupportExp = + ur_tracing_layer::urBindlessImagesGetImageMemoryOpaqueSupportExp; + + dditable.pfnGetImageUnsampledHandleSupportExp = + pDdiTable->pfnGetImageUnsampledHandleSupportExp; + pDdiTable->pfnGetImageUnsampledHandleSupportExp = + ur_tracing_layer::urBindlessImagesGetImageUnsampledHandleSupportExp; + + dditable.pfnGetImageSampledHandleSupportExp = + pDdiTable->pfnGetImageSampledHandleSupportExp; + pDdiTable->pfnGetImageSampledHandleSupportExp = + ur_tracing_layer::urBindlessImagesGetImageSampledHandleSupportExp; + dditable.pfnMipmapGetLevelExp = pDdiTable->pfnMipmapGetLevelExp; pDdiTable->pfnMipmapGetLevelExp = ur_tracing_layer::urBindlessImagesMipmapGetLevelExp; diff --git a/unified-runtime/source/loader/layers/validation/ur_valddi.cpp b/unified-runtime/source/loader/layers/validation/ur_valddi.cpp index 10e630ef1fbbd..e54480334a7b3 100644 --- a/unified-runtime/source/loader/layers/validation/ur_valddi.cpp +++ b/unified-runtime/source/loader/layers/validation/ur_valddi.cpp @@ -7703,6 +7703,240 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for +/// urBindlessImagesGetImageMemoryPointerSupportExp +__urdlllocal ur_result_t UR_APICALL +urBindlessImagesGetImageMemoryPointerSupportExp( + /// [in] handle of the context object + ur_context_handle_t hContext, + /// [in] handle of the device object + ur_device_handle_t hDevice, + /// [in] pointer to image description + const ur_image_desc_t *pImageDesc, + /// [in] pointer to image format specification + const ur_image_format_t *pImageFormat, + /// [out] returned indication of support for allocating USM style memory + bool *pSupportedRet) { + auto pfnGetImageMemoryPointerSupportExp = + getContext() + ->urDdiTable.BindlessImagesExp.pfnGetImageMemoryPointerSupportExp; + + if (nullptr == pfnGetImageMemoryPointerSupportExp) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + if (getContext()->enableParameterValidation) { + if (NULL == pImageDesc) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (NULL == pImageFormat) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (NULL == pSupportedRet) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (NULL == hContext) + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + + if (NULL == hDevice) + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + + if (getContext()->enableLifetimeValidation && + !getContext()->refCountContext->isReferenceValid(hContext)) { + getContext()->refCountContext->logInvalidReference(hContext); + } + + if (getContext()->enableLifetimeValidation && + !getContext()->refCountContext->isReferenceValid(hDevice)) { + getContext()->refCountContext->logInvalidReference(hDevice); + } + + ur_result_t result = pfnGetImageMemoryPointerSupportExp( + hContext, hDevice, pImageDesc, pImageFormat, pSupportedRet); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urBindlessImagesGetImageMemoryOpaqueSupportExp +__urdlllocal ur_result_t UR_APICALL +urBindlessImagesGetImageMemoryOpaqueSupportExp( + /// [in] handle of the context object + ur_context_handle_t hContext, + /// [in] handle of the device object + ur_device_handle_t hDevice, + /// [in] pointer to image description + const ur_image_desc_t *pImageDesc, + /// [in] pointer to image format specification + const ur_image_format_t *pImageFormat, + /// [out] returned indication of support for allocating opaque handle + /// memory + bool *pSupportedRet) { + auto pfnGetImageMemoryOpaqueSupportExp = + getContext() + ->urDdiTable.BindlessImagesExp.pfnGetImageMemoryOpaqueSupportExp; + + if (nullptr == pfnGetImageMemoryOpaqueSupportExp) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + if (getContext()->enableParameterValidation) { + if (NULL == pImageDesc) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (NULL == pImageFormat) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (NULL == pSupportedRet) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (NULL == hContext) + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + + if (NULL == hDevice) + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + + if (getContext()->enableLifetimeValidation && + !getContext()->refCountContext->isReferenceValid(hContext)) { + getContext()->refCountContext->logInvalidReference(hContext); + } + + if (getContext()->enableLifetimeValidation && + !getContext()->refCountContext->isReferenceValid(hDevice)) { + getContext()->refCountContext->logInvalidReference(hDevice); + } + + ur_result_t result = pfnGetImageMemoryOpaqueSupportExp( + hContext, hDevice, pImageDesc, pImageFormat, pSupportedRet); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for +/// urBindlessImagesGetImageUnsampledHandleSupportExp +__urdlllocal ur_result_t UR_APICALL +urBindlessImagesGetImageUnsampledHandleSupportExp( + /// [in] handle of the context object + ur_context_handle_t hContext, + /// [in] handle of the device object + ur_device_handle_t hDevice, + /// [in] pointer to image description + const ur_image_desc_t *pImageDesc, + /// [in] pointer to image format specification + const ur_image_format_t *pImageFormat, + /// [in] indicates whether the image memory would be backed by an opaque + /// handle allocation + bool isOpaqueAllocation, + /// [out] returned indication of support for creating unsampled image + /// handles + bool *pSupportedRet) { + auto pfnGetImageUnsampledHandleSupportExp = + getContext() + ->urDdiTable.BindlessImagesExp.pfnGetImageUnsampledHandleSupportExp; + + if (nullptr == pfnGetImageUnsampledHandleSupportExp) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + if (getContext()->enableParameterValidation) { + if (NULL == pImageDesc) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (NULL == pImageFormat) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (NULL == pSupportedRet) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (NULL == hContext) + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + + if (NULL == hDevice) + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + + if (getContext()->enableLifetimeValidation && + !getContext()->refCountContext->isReferenceValid(hContext)) { + getContext()->refCountContext->logInvalidReference(hContext); + } + + if (getContext()->enableLifetimeValidation && + !getContext()->refCountContext->isReferenceValid(hDevice)) { + getContext()->refCountContext->logInvalidReference(hDevice); + } + + ur_result_t result = pfnGetImageUnsampledHandleSupportExp( + hContext, hDevice, pImageDesc, pImageFormat, isOpaqueAllocation, + pSupportedRet); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for +/// urBindlessImagesGetImageSampledHandleSupportExp +__urdlllocal ur_result_t UR_APICALL +urBindlessImagesGetImageSampledHandleSupportExp( + /// [in] handle of the context object + ur_context_handle_t hContext, + /// [in] handle of the device object + ur_device_handle_t hDevice, + /// [in] pointer to image description + const ur_image_desc_t *pImageDesc, + /// [in] pointer to image format specification + const ur_image_format_t *pImageFormat, + /// [in] indicates whether the image memory would be backed by an opaque + /// handle allocation + bool isOpaqueAllocation, + /// [out] returned indication of support for creating sampled image + /// handles + bool *pSupportedRet) { + auto pfnGetImageSampledHandleSupportExp = + getContext() + ->urDdiTable.BindlessImagesExp.pfnGetImageSampledHandleSupportExp; + + if (nullptr == pfnGetImageSampledHandleSupportExp) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + if (getContext()->enableParameterValidation) { + if (NULL == pImageDesc) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (NULL == pImageFormat) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (NULL == pSupportedRet) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (NULL == hContext) + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + + if (NULL == hDevice) + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + + if (getContext()->enableLifetimeValidation && + !getContext()->refCountContext->isReferenceValid(hContext)) { + getContext()->refCountContext->logInvalidReference(hContext); + } + + if (getContext()->enableLifetimeValidation && + !getContext()->refCountContext->isReferenceValid(hDevice)) { + getContext()->refCountContext->logInvalidReference(hDevice); + } + + ur_result_t result = pfnGetImageSampledHandleSupportExp( + hContext, hDevice, pImageDesc, pImageFormat, isOpaqueAllocation, + pSupportedRet); + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urBindlessImagesMipmapGetLevelExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( @@ -10544,6 +10778,26 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetBindlessImagesExpProcAddrTable( pDdiTable->pfnImageGetInfoExp = ur_validation_layer::urBindlessImagesImageGetInfoExp; + dditable.pfnGetImageMemoryPointerSupportExp = + pDdiTable->pfnGetImageMemoryPointerSupportExp; + pDdiTable->pfnGetImageMemoryPointerSupportExp = + ur_validation_layer::urBindlessImagesGetImageMemoryPointerSupportExp; + + dditable.pfnGetImageMemoryOpaqueSupportExp = + pDdiTable->pfnGetImageMemoryOpaqueSupportExp; + pDdiTable->pfnGetImageMemoryOpaqueSupportExp = + ur_validation_layer::urBindlessImagesGetImageMemoryOpaqueSupportExp; + + dditable.pfnGetImageUnsampledHandleSupportExp = + pDdiTable->pfnGetImageUnsampledHandleSupportExp; + pDdiTable->pfnGetImageUnsampledHandleSupportExp = + ur_validation_layer::urBindlessImagesGetImageUnsampledHandleSupportExp; + + dditable.pfnGetImageSampledHandleSupportExp = + pDdiTable->pfnGetImageSampledHandleSupportExp; + pDdiTable->pfnGetImageSampledHandleSupportExp = + ur_validation_layer::urBindlessImagesGetImageSampledHandleSupportExp; + dditable.pfnMipmapGetLevelExp = pDdiTable->pfnMipmapGetLevelExp; pDdiTable->pfnMipmapGetLevelExp = ur_validation_layer::urBindlessImagesMipmapGetLevelExp; diff --git a/unified-runtime/source/loader/loader.def.in b/unified-runtime/source/loader/loader.def.in index 2c1d2203ad31a..e0600e7beb073 100644 --- a/unified-runtime/source/loader/loader.def.in +++ b/unified-runtime/source/loader/loader.def.in @@ -5,6 +5,10 @@ EXPORTS urAdapterGetLastError urAdapterRelease urAdapterRetain + urBindlessImagesGetImageMemoryOpaqueSupportExp + urBindlessImagesGetImageMemoryPointerSupportExp + urBindlessImagesGetImageSampledHandleSupportExp + urBindlessImagesGetImageUnsampledHandleSupportExp urBindlessImagesImageAllocateExp urBindlessImagesImageCopyExp urBindlessImagesImageFreeExp @@ -182,6 +186,10 @@ EXPORTS urPrintApiVersion urPrintBaseDesc urPrintBaseProperties + urPrintBindlessImagesGetImageMemoryOpaqueSupportExpParams + urPrintBindlessImagesGetImageMemoryPointerSupportExpParams + urPrintBindlessImagesGetImageSampledHandleSupportExpParams + urPrintBindlessImagesGetImageUnsampledHandleSupportExpParams urPrintBindlessImagesImageAllocateExpParams urPrintBindlessImagesImageCopyExpParams urPrintBindlessImagesImageFreeExpParams diff --git a/unified-runtime/source/loader/loader.map.in b/unified-runtime/source/loader/loader.map.in index 687f97b283506..34d9584626e1c 100644 --- a/unified-runtime/source/loader/loader.map.in +++ b/unified-runtime/source/loader/loader.map.in @@ -5,6 +5,10 @@ urAdapterGetLastError; urAdapterRelease; urAdapterRetain; + urBindlessImagesGetImageMemoryOpaqueSupportExp; + urBindlessImagesGetImageMemoryPointerSupportExp; + urBindlessImagesGetImageSampledHandleSupportExp; + urBindlessImagesGetImageUnsampledHandleSupportExp; urBindlessImagesImageAllocateExp; urBindlessImagesImageCopyExp; urBindlessImagesImageFreeExp; @@ -182,6 +186,10 @@ urPrintApiVersion; urPrintBaseDesc; urPrintBaseProperties; + urPrintBindlessImagesGetImageMemoryOpaqueSupportExpParams; + urPrintBindlessImagesGetImageMemoryPointerSupportExpParams; + urPrintBindlessImagesGetImageSampledHandleSupportExpParams; + urPrintBindlessImagesGetImageUnsampledHandleSupportExpParams; urPrintBindlessImagesImageAllocateExpParams; urPrintBindlessImagesImageCopyExpParams; urPrintBindlessImagesImageFreeExpParams; diff --git a/unified-runtime/source/loader/ur_ldrddi.cpp b/unified-runtime/source/loader/ur_ldrddi.cpp index 842e93969f3e0..b3f5fb0d8d524 100644 --- a/unified-runtime/source/loader/ur_ldrddi.cpp +++ b/unified-runtime/source/loader/ur_ldrddi.cpp @@ -7108,6 +7108,172 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for +/// urBindlessImagesGetImageMemoryPointerSupportExp +__urdlllocal ur_result_t UR_APICALL +urBindlessImagesGetImageMemoryPointerSupportExp( + /// [in] handle of the context object + ur_context_handle_t hContext, + /// [in] handle of the device object + ur_device_handle_t hDevice, + /// [in] pointer to image description + const ur_image_desc_t *pImageDesc, + /// [in] pointer to image format specification + const ur_image_format_t *pImageFormat, + /// [out] returned indication of support for allocating USM style memory + bool *pSupportedRet) { + ur_result_t result = UR_RESULT_SUCCESS; + + [[maybe_unused]] auto context = getContext(); + + // extract platform's function pointer table + auto dditable = reinterpret_cast(hContext)->dditable; + auto pfnGetImageMemoryPointerSupportExp = + dditable->ur.BindlessImagesExp.pfnGetImageMemoryPointerSupportExp; + if (nullptr == pfnGetImageMemoryPointerSupportExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to platform handle + hContext = reinterpret_cast(hContext)->handle; + + // convert loader handle to platform handle + hDevice = reinterpret_cast(hDevice)->handle; + + // forward to device-platform + result = pfnGetImageMemoryPointerSupportExp(hContext, hDevice, pImageDesc, + pImageFormat, pSupportedRet); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urBindlessImagesGetImageMemoryOpaqueSupportExp +__urdlllocal ur_result_t UR_APICALL +urBindlessImagesGetImageMemoryOpaqueSupportExp( + /// [in] handle of the context object + ur_context_handle_t hContext, + /// [in] handle of the device object + ur_device_handle_t hDevice, + /// [in] pointer to image description + const ur_image_desc_t *pImageDesc, + /// [in] pointer to image format specification + const ur_image_format_t *pImageFormat, + /// [out] returned indication of support for allocating opaque handle + /// memory + bool *pSupportedRet) { + ur_result_t result = UR_RESULT_SUCCESS; + + [[maybe_unused]] auto context = getContext(); + + // extract platform's function pointer table + auto dditable = reinterpret_cast(hContext)->dditable; + auto pfnGetImageMemoryOpaqueSupportExp = + dditable->ur.BindlessImagesExp.pfnGetImageMemoryOpaqueSupportExp; + if (nullptr == pfnGetImageMemoryOpaqueSupportExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to platform handle + hContext = reinterpret_cast(hContext)->handle; + + // convert loader handle to platform handle + hDevice = reinterpret_cast(hDevice)->handle; + + // forward to device-platform + result = pfnGetImageMemoryOpaqueSupportExp(hContext, hDevice, pImageDesc, + pImageFormat, pSupportedRet); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for +/// urBindlessImagesGetImageUnsampledHandleSupportExp +__urdlllocal ur_result_t UR_APICALL +urBindlessImagesGetImageUnsampledHandleSupportExp( + /// [in] handle of the context object + ur_context_handle_t hContext, + /// [in] handle of the device object + ur_device_handle_t hDevice, + /// [in] pointer to image description + const ur_image_desc_t *pImageDesc, + /// [in] pointer to image format specification + const ur_image_format_t *pImageFormat, + /// [in] indicates whether the image memory would be backed by an opaque + /// handle allocation + bool isOpaqueAllocation, + /// [out] returned indication of support for creating unsampled image + /// handles + bool *pSupportedRet) { + ur_result_t result = UR_RESULT_SUCCESS; + + [[maybe_unused]] auto context = getContext(); + + // extract platform's function pointer table + auto dditable = reinterpret_cast(hContext)->dditable; + auto pfnGetImageUnsampledHandleSupportExp = + dditable->ur.BindlessImagesExp.pfnGetImageUnsampledHandleSupportExp; + if (nullptr == pfnGetImageUnsampledHandleSupportExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to platform handle + hContext = reinterpret_cast(hContext)->handle; + + // convert loader handle to platform handle + hDevice = reinterpret_cast(hDevice)->handle; + + // forward to device-platform + result = pfnGetImageUnsampledHandleSupportExp( + hContext, hDevice, pImageDesc, pImageFormat, isOpaqueAllocation, + pSupportedRet); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for +/// urBindlessImagesGetImageSampledHandleSupportExp +__urdlllocal ur_result_t UR_APICALL +urBindlessImagesGetImageSampledHandleSupportExp( + /// [in] handle of the context object + ur_context_handle_t hContext, + /// [in] handle of the device object + ur_device_handle_t hDevice, + /// [in] pointer to image description + const ur_image_desc_t *pImageDesc, + /// [in] pointer to image format specification + const ur_image_format_t *pImageFormat, + /// [in] indicates whether the image memory would be backed by an opaque + /// handle allocation + bool isOpaqueAllocation, + /// [out] returned indication of support for creating sampled image + /// handles + bool *pSupportedRet) { + ur_result_t result = UR_RESULT_SUCCESS; + + [[maybe_unused]] auto context = getContext(); + + // extract platform's function pointer table + auto dditable = reinterpret_cast(hContext)->dditable; + auto pfnGetImageSampledHandleSupportExp = + dditable->ur.BindlessImagesExp.pfnGetImageSampledHandleSupportExp; + if (nullptr == pfnGetImageSampledHandleSupportExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to platform handle + hContext = reinterpret_cast(hContext)->handle; + + // convert loader handle to platform handle + hDevice = reinterpret_cast(hDevice)->handle; + + // forward to device-platform + result = pfnGetImageSampledHandleSupportExp(hContext, hDevice, pImageDesc, + pImageFormat, isOpaqueAllocation, + pSupportedRet); + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urBindlessImagesMipmapGetLevelExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( @@ -10054,6 +10220,14 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetBindlessImagesExpProcAddrTable( pDdiTable->pfnImageCopyExp = ur_loader::urBindlessImagesImageCopyExp; pDdiTable->pfnImageGetInfoExp = ur_loader::urBindlessImagesImageGetInfoExp; + pDdiTable->pfnGetImageMemoryPointerSupportExp = + ur_loader::urBindlessImagesGetImageMemoryPointerSupportExp; + pDdiTable->pfnGetImageMemoryOpaqueSupportExp = + ur_loader::urBindlessImagesGetImageMemoryOpaqueSupportExp; + pDdiTable->pfnGetImageUnsampledHandleSupportExp = + ur_loader::urBindlessImagesGetImageUnsampledHandleSupportExp; + pDdiTable->pfnGetImageSampledHandleSupportExp = + ur_loader::urBindlessImagesGetImageSampledHandleSupportExp; pDdiTable->pfnMipmapGetLevelExp = ur_loader::urBindlessImagesMipmapGetLevelExp; pDdiTable->pfnMipmapFreeExp = ur_loader::urBindlessImagesMipmapFreeExp; diff --git a/unified-runtime/source/loader/ur_libapi.cpp b/unified-runtime/source/loader/ur_libapi.cpp index 78ae7e5a6364f..b31bdae126a1f 100644 --- a/unified-runtime/source/loader/ur_libapi.cpp +++ b/unified-runtime/source/loader/ur_libapi.cpp @@ -7669,6 +7669,179 @@ ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( return exceptionToResult(std::current_exception()); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Query support for allocating pointer handle type image memory with +/// specific image properties +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hContext` +/// + `NULL == hDevice` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pImageDesc` +/// + `NULL == pImageFormat` +/// + `NULL == pSupportedRet` +/// - ::UR_RESULT_ERROR_INVALID_DEVICE +ur_result_t UR_APICALL urBindlessImagesGetImageMemoryPointerSupportExp( + /// [in] handle of the context object + ur_context_handle_t hContext, + /// [in] handle of the device object + ur_device_handle_t hDevice, + /// [in] pointer to image description + const ur_image_desc_t *pImageDesc, + /// [in] pointer to image format specification + const ur_image_format_t *pImageFormat, + /// [out] returned indication of support for allocating USM style memory + bool *pSupportedRet) try { + auto pfnGetImageMemoryPointerSupportExp = + ur_lib::getContext() + ->urDdiTable.BindlessImagesExp.pfnGetImageMemoryPointerSupportExp; + if (nullptr == pfnGetImageMemoryPointerSupportExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + return pfnGetImageMemoryPointerSupportExp(hContext, hDevice, pImageDesc, + pImageFormat, pSupportedRet); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Query support for allocating opaque handle type image memory with +/// specific image properties +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hContext` +/// + `NULL == hDevice` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pImageDesc` +/// + `NULL == pImageFormat` +/// + `NULL == pSupportedRet` +/// - ::UR_RESULT_ERROR_INVALID_DEVICE +ur_result_t UR_APICALL urBindlessImagesGetImageMemoryOpaqueSupportExp( + /// [in] handle of the context object + ur_context_handle_t hContext, + /// [in] handle of the device object + ur_device_handle_t hDevice, + /// [in] pointer to image description + const ur_image_desc_t *pImageDesc, + /// [in] pointer to image format specification + const ur_image_format_t *pImageFormat, + /// [out] returned indication of support for allocating opaque handle + /// memory + bool *pSupportedRet) try { + auto pfnGetImageMemoryOpaqueSupportExp = + ur_lib::getContext() + ->urDdiTable.BindlessImagesExp.pfnGetImageMemoryOpaqueSupportExp; + if (nullptr == pfnGetImageMemoryOpaqueSupportExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + return pfnGetImageMemoryOpaqueSupportExp(hContext, hDevice, pImageDesc, + pImageFormat, pSupportedRet); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Query support for creating an unsampled image handle with specific +/// image properties +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hContext` +/// + `NULL == hDevice` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pImageDesc` +/// + `NULL == pImageFormat` +/// + `NULL == pSupportedRet` +/// - ::UR_RESULT_ERROR_INVALID_DEVICE +/// - ::UR_RESULT_ERROR_INVALID_CONTEXT +ur_result_t UR_APICALL urBindlessImagesGetImageUnsampledHandleSupportExp( + /// [in] handle of the context object + ur_context_handle_t hContext, + /// [in] handle of the device object + ur_device_handle_t hDevice, + /// [in] pointer to image description + const ur_image_desc_t *pImageDesc, + /// [in] pointer to image format specification + const ur_image_format_t *pImageFormat, + /// [in] indicates whether the image memory would be backed by an opaque + /// handle allocation + bool isOpaqueAllocation, + /// [out] returned indication of support for creating unsampled image + /// handles + bool *pSupportedRet) try { + auto pfnGetImageUnsampledHandleSupportExp = + ur_lib::getContext() + ->urDdiTable.BindlessImagesExp.pfnGetImageUnsampledHandleSupportExp; + if (nullptr == pfnGetImageUnsampledHandleSupportExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + return pfnGetImageUnsampledHandleSupportExp(hContext, hDevice, pImageDesc, + pImageFormat, isOpaqueAllocation, + pSupportedRet); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Query support for creating an unsampled image handle with specific +/// image properties +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hContext` +/// + `NULL == hDevice` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pImageDesc` +/// + `NULL == pImageFormat` +/// + `NULL == pSupportedRet` +/// - ::UR_RESULT_ERROR_INVALID_DEVICE +/// - ::UR_RESULT_ERROR_INVALID_CONTEXT +ur_result_t UR_APICALL urBindlessImagesGetImageSampledHandleSupportExp( + /// [in] handle of the context object + ur_context_handle_t hContext, + /// [in] handle of the device object + ur_device_handle_t hDevice, + /// [in] pointer to image description + const ur_image_desc_t *pImageDesc, + /// [in] pointer to image format specification + const ur_image_format_t *pImageFormat, + /// [in] indicates whether the image memory would be backed by an opaque + /// handle allocation + bool isOpaqueAllocation, + /// [out] returned indication of support for creating sampled image + /// handles + bool *pSupportedRet) try { + auto pfnGetImageSampledHandleSupportExp = + ur_lib::getContext() + ->urDdiTable.BindlessImagesExp.pfnGetImageSampledHandleSupportExp; + if (nullptr == pfnGetImageSampledHandleSupportExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + return pfnGetImageSampledHandleSupportExp(hContext, hDevice, pImageDesc, + pImageFormat, isOpaqueAllocation, + pSupportedRet); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Retrieve individual image from mipmap /// diff --git a/unified-runtime/source/loader/ur_print.cpp b/unified-runtime/source/loader/ur_print.cpp index 50af3986b2f38..352cb224a9ed8 100644 --- a/unified-runtime/source/loader/ur_print.cpp +++ b/unified-runtime/source/loader/ur_print.cpp @@ -1255,6 +1255,42 @@ ur_result_t urPrintBindlessImagesImageGetInfoExpParams( return str_copy(&ss, buffer, buff_size, out_size); } +ur_result_t urPrintBindlessImagesGetImageMemoryPointerSupportExpParams( + const struct + ur_bindless_images_get_image_memory_pointer_support_exp_params_t *params, + char *buffer, const size_t buff_size, size_t *out_size) { + std::stringstream ss; + ss << params; + return str_copy(&ss, buffer, buff_size, out_size); +} + +ur_result_t urPrintBindlessImagesGetImageMemoryOpaqueSupportExpParams( + const struct ur_bindless_images_get_image_memory_opaque_support_exp_params_t + *params, + char *buffer, const size_t buff_size, size_t *out_size) { + std::stringstream ss; + ss << params; + return str_copy(&ss, buffer, buff_size, out_size); +} + +ur_result_t urPrintBindlessImagesGetImageUnsampledHandleSupportExpParams( + const struct + ur_bindless_images_get_image_unsampled_handle_support_exp_params_t *params, + char *buffer, const size_t buff_size, size_t *out_size) { + std::stringstream ss; + ss << params; + return str_copy(&ss, buffer, buff_size, out_size); +} + +ur_result_t urPrintBindlessImagesGetImageSampledHandleSupportExpParams( + const struct + ur_bindless_images_get_image_sampled_handle_support_exp_params_t *params, + char *buffer, const size_t buff_size, size_t *out_size) { + std::stringstream ss; + ss << params; + return str_copy(&ss, buffer, buff_size, out_size); +} + ur_result_t urPrintBindlessImagesMipmapGetLevelExpParams( const struct ur_bindless_images_mipmap_get_level_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size) { diff --git a/unified-runtime/source/ur_api.cpp b/unified-runtime/source/ur_api.cpp index 3ed7b5771f936..38f371b5b282d 100644 --- a/unified-runtime/source/ur_api.cpp +++ b/unified-runtime/source/ur_api.cpp @@ -6712,6 +6712,145 @@ ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Query support for allocating pointer handle type image memory with +/// specific image properties +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hContext` +/// + `NULL == hDevice` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pImageDesc` +/// + `NULL == pImageFormat` +/// + `NULL == pSupportedRet` +/// - ::UR_RESULT_ERROR_INVALID_DEVICE +ur_result_t UR_APICALL urBindlessImagesGetImageMemoryPointerSupportExp( + /// [in] handle of the context object + ur_context_handle_t hContext, + /// [in] handle of the device object + ur_device_handle_t hDevice, + /// [in] pointer to image description + const ur_image_desc_t *pImageDesc, + /// [in] pointer to image format specification + const ur_image_format_t *pImageFormat, + /// [out] returned indication of support for allocating USM style memory + bool *pSupportedRet) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Query support for allocating opaque handle type image memory with +/// specific image properties +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hContext` +/// + `NULL == hDevice` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pImageDesc` +/// + `NULL == pImageFormat` +/// + `NULL == pSupportedRet` +/// - ::UR_RESULT_ERROR_INVALID_DEVICE +ur_result_t UR_APICALL urBindlessImagesGetImageMemoryOpaqueSupportExp( + /// [in] handle of the context object + ur_context_handle_t hContext, + /// [in] handle of the device object + ur_device_handle_t hDevice, + /// [in] pointer to image description + const ur_image_desc_t *pImageDesc, + /// [in] pointer to image format specification + const ur_image_format_t *pImageFormat, + /// [out] returned indication of support for allocating opaque handle + /// memory + bool *pSupportedRet) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Query support for creating an unsampled image handle with specific +/// image properties +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hContext` +/// + `NULL == hDevice` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pImageDesc` +/// + `NULL == pImageFormat` +/// + `NULL == pSupportedRet` +/// - ::UR_RESULT_ERROR_INVALID_DEVICE +/// - ::UR_RESULT_ERROR_INVALID_CONTEXT +ur_result_t UR_APICALL urBindlessImagesGetImageUnsampledHandleSupportExp( + /// [in] handle of the context object + ur_context_handle_t hContext, + /// [in] handle of the device object + ur_device_handle_t hDevice, + /// [in] pointer to image description + const ur_image_desc_t *pImageDesc, + /// [in] pointer to image format specification + const ur_image_format_t *pImageFormat, + /// [in] indicates whether the image memory would be backed by an opaque + /// handle allocation + bool isOpaqueAllocation, + /// [out] returned indication of support for creating unsampled image + /// handles + bool *pSupportedRet) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Query support for creating an unsampled image handle with specific +/// image properties +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hContext` +/// + `NULL == hDevice` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pImageDesc` +/// + `NULL == pImageFormat` +/// + `NULL == pSupportedRet` +/// - ::UR_RESULT_ERROR_INVALID_DEVICE +/// - ::UR_RESULT_ERROR_INVALID_CONTEXT +ur_result_t UR_APICALL urBindlessImagesGetImageSampledHandleSupportExp( + /// [in] handle of the context object + ur_context_handle_t hContext, + /// [in] handle of the device object + ur_device_handle_t hDevice, + /// [in] pointer to image description + const ur_image_desc_t *pImageDesc, + /// [in] pointer to image format specification + const ur_image_format_t *pImageFormat, + /// [in] indicates whether the image memory would be backed by an opaque + /// handle allocation + bool isOpaqueAllocation, + /// [out] returned indication of support for creating sampled image + /// handles + bool *pSupportedRet) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Retrieve individual image from mipmap /// From e7a57b0f6d87dec1de672d5eb93f546fe8b6a427 Mon Sep 17 00:00:00 2001 From: Przemek Malon Date: Mon, 7 Apr 2025 11:36:46 +0100 Subject: [PATCH 02/13] Fix include --- .../source/adapters/level_zero/helpers/image_helpers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unified-runtime/source/adapters/level_zero/helpers/image_helpers.cpp b/unified-runtime/source/adapters/level_zero/helpers/image_helpers.cpp index 0bb47cc0774c7..122499d99679d 100644 --- a/unified-runtime/source/adapters/level_zero/helpers/image_helpers.cpp +++ b/unified-runtime/source/adapters/level_zero/helpers/image_helpers.cpp @@ -9,7 +9,7 @@ //===----------------------------------------------------------------------===// #include "image_helpers.hpp" -#include "device.hpp" +#include "../device.hpp" /// Construct UR image format from ZE image desc. ur_result_t ze2urImageFormat(const ze_image_desc_t *ZeImageDesc, From b0545758333112ecdc2ba0b76a86a8f6e1d5822e Mon Sep 17 00:00:00 2001 From: Przemek Malon Date: Mon, 7 Apr 2025 12:19:25 +0100 Subject: [PATCH 03/13] Pass image_descriptor by ref --- sycl/test-e2e/bindless_images/helpers/common.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/test-e2e/bindless_images/helpers/common.hpp b/sycl/test-e2e/bindless_images/helpers/common.hpp index b46df6168b644..eabd5243b11b0 100644 --- a/sycl/test-e2e/bindless_images/helpers/common.hpp +++ b/sycl/test-e2e/bindless_images/helpers/common.hpp @@ -20,7 +20,7 @@ namespace bindless_helpers { namespace syclexp = sycl::ext::oneapi::experimental; -bool memoryAllocationSupported(syclexp::image_descriptor imgDesc, +bool memoryAllocationSupported(syclexp::image_descriptor &imgDesc, syclexp::image_memory_handle_type memHandleType, sycl::queue syclQueue) { auto supportedMemTypes = From 18245939e62a670881e2150938512ca25da03d98 Mon Sep 17 00:00:00 2001 From: Przemek Malon Date: Mon, 7 Apr 2025 12:28:00 +0100 Subject: [PATCH 04/13] Fix return value for skipping read_2D test --- sycl/test-e2e/bindless_images/read_2D.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sycl/test-e2e/bindless_images/read_2D.cpp b/sycl/test-e2e/bindless_images/read_2D.cpp index cfc2291ccd93e..fe72e0fad002e 100644 --- a/sycl/test-e2e/bindless_images/read_2D.cpp +++ b/sycl/test-e2e/bindless_images/read_2D.cpp @@ -50,7 +50,7 @@ int main() { q)) { // We cannot allocate the opaque `image_mem` below std::cout << "Memory allocation unsupported. Skipping test.\n"; - return 1; + return 0; } // Extension: allocate memory on device and create the handle @@ -69,7 +69,7 @@ int main() { // We cannot create the unsampled handles below std::cout << "Unsampled image handle creation unsupported. Skipping " "test.\n"; - return 1; + return 0; } // Extension: create the image and return the handle From e0fc137fb7ae940cdbbcb1486497dffa0e9e8bac Mon Sep 17 00:00:00 2001 From: Przemek Malon Date: Tue, 8 Apr 2025 11:46:11 +0100 Subject: [PATCH 05/13] Use ur_bool_t --- unified-runtime/include/ur_api.h | 24 +++++++++---------- unified-runtime/include/ur_ddi.h | 8 +++---- .../scripts/core/exp-bindless-images.yml | 12 +++++----- .../source/adapters/cuda/image.cpp | 8 +++---- unified-runtime/source/adapters/hip/image.cpp | 8 +++---- .../source/adapters/level_zero/image.cpp | 8 +++---- .../level_zero/ur_interface_loader.hpp | 8 +++---- .../source/adapters/mock/ur_mockddi.cpp | 12 +++++----- .../source/adapters/native_cpu/image.cpp | 12 +++++----- .../source/adapters/opencl/image.cpp | 12 +++++----- .../loader/layers/tracing/ur_trcddi.cpp | 12 +++++----- .../loader/layers/validation/ur_valddi.cpp | 12 +++++----- unified-runtime/source/loader/ur_ldrddi.cpp | 12 +++++----- unified-runtime/source/loader/ur_libapi.cpp | 12 +++++----- unified-runtime/source/ur_api.cpp | 12 +++++----- 15 files changed, 86 insertions(+), 86 deletions(-) diff --git a/unified-runtime/include/ur_api.h b/unified-runtime/include/ur_api.h index e72f486f2ea21..3ec1c0cfa2b46 100644 --- a/unified-runtime/include/ur_api.h +++ b/unified-runtime/include/ur_api.h @@ -10117,7 +10117,7 @@ urBindlessImagesGetImageMemoryPointerSupportExp( /// [in] pointer to image format specification const ur_image_format_t *pImageFormat, /// [out] returned indication of support for allocating USM style memory - bool *pSupportedRet); + ur_bool_t *pSupportedRet); /////////////////////////////////////////////////////////////////////////////// /// @brief Query support for allocating opaque handle type image memory with @@ -10148,7 +10148,7 @@ urBindlessImagesGetImageMemoryOpaqueSupportExp( const ur_image_format_t *pImageFormat, /// [out] returned indication of support for allocating opaque handle /// memory - bool *pSupportedRet); + ur_bool_t *pSupportedRet); /////////////////////////////////////////////////////////////////////////////// /// @brief Query support for creating an unsampled image handle with specific @@ -10180,10 +10180,10 @@ urBindlessImagesGetImageUnsampledHandleSupportExp( const ur_image_format_t *pImageFormat, /// [in] indicates whether the image memory would be backed by an opaque /// handle allocation - bool isOpaqueAllocation, + ur_bool_t isOpaqueAllocation, /// [out] returned indication of support for creating unsampled image /// handles - bool *pSupportedRet); + ur_bool_t *pSupportedRet); /////////////////////////////////////////////////////////////////////////////// /// @brief Query support for creating an unsampled image handle with specific @@ -10215,10 +10215,10 @@ urBindlessImagesGetImageSampledHandleSupportExp( const ur_image_format_t *pImageFormat, /// [in] indicates whether the image memory would be backed by an opaque /// handle allocation - bool isOpaqueAllocation, + ur_bool_t isOpaqueAllocation, /// [out] returned indication of support for creating sampled image /// handles - bool *pSupportedRet); + ur_bool_t *pSupportedRet); /////////////////////////////////////////////////////////////////////////////// /// @brief Retrieve individual image from mipmap @@ -14681,7 +14681,7 @@ typedef struct ur_device_handle_t *phDevice; const ur_image_desc_t **ppImageDesc; const ur_image_format_t **ppImageFormat; - bool **ppSupportedRet; + ur_bool_t **ppSupportedRet; } ur_bindless_images_get_image_memory_pointer_support_exp_params_t; /////////////////////////////////////////////////////////////////////////////// @@ -14694,7 +14694,7 @@ typedef struct ur_bindless_images_get_image_memory_opaque_support_exp_params_t { ur_device_handle_t *phDevice; const ur_image_desc_t **ppImageDesc; const ur_image_format_t **ppImageFormat; - bool **ppSupportedRet; + ur_bool_t **ppSupportedRet; } ur_bindless_images_get_image_memory_opaque_support_exp_params_t; /////////////////////////////////////////////////////////////////////////////// @@ -14708,8 +14708,8 @@ typedef struct ur_device_handle_t *phDevice; const ur_image_desc_t **ppImageDesc; const ur_image_format_t **ppImageFormat; - bool *pisOpaqueAllocation; - bool **ppSupportedRet; + ur_bool_t *pisOpaqueAllocation; + ur_bool_t **ppSupportedRet; } ur_bindless_images_get_image_unsampled_handle_support_exp_params_t; /////////////////////////////////////////////////////////////////////////////// @@ -14723,8 +14723,8 @@ typedef struct ur_device_handle_t *phDevice; const ur_image_desc_t **ppImageDesc; const ur_image_format_t **ppImageFormat; - bool *pisOpaqueAllocation; - bool **ppSupportedRet; + ur_bool_t *pisOpaqueAllocation; + ur_bool_t **ppSupportedRet; } ur_bindless_images_get_image_sampled_handle_support_exp_params_t; /////////////////////////////////////////////////////////////////////////////// diff --git a/unified-runtime/include/ur_ddi.h b/unified-runtime/include/ur_ddi.h index b7abbae0d52e6..2f73c42fa3249 100644 --- a/unified-runtime/include/ur_ddi.h +++ b/unified-runtime/include/ur_ddi.h @@ -1449,14 +1449,14 @@ typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImageGetInfoExp_t)( typedef ur_result_t( UR_APICALL *ur_pfnBindlessImagesGetImageMemoryPointerSupportExp_t)( ur_context_handle_t, ur_device_handle_t, const ur_image_desc_t *, - const ur_image_format_t *, bool *); + const ur_image_format_t *, ur_bool_t *); /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urBindlessImagesGetImageMemoryOpaqueSupportExp typedef ur_result_t( UR_APICALL *ur_pfnBindlessImagesGetImageMemoryOpaqueSupportExp_t)( ur_context_handle_t, ur_device_handle_t, const ur_image_desc_t *, - const ur_image_format_t *, bool *); + const ur_image_format_t *, ur_bool_t *); /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for @@ -1464,14 +1464,14 @@ typedef ur_result_t( typedef ur_result_t( UR_APICALL *ur_pfnBindlessImagesGetImageUnsampledHandleSupportExp_t)( ur_context_handle_t, ur_device_handle_t, const ur_image_desc_t *, - const ur_image_format_t *, bool, bool *); + const ur_image_format_t *, ur_bool_t, ur_bool_t *); /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urBindlessImagesGetImageSampledHandleSupportExp typedef ur_result_t( UR_APICALL *ur_pfnBindlessImagesGetImageSampledHandleSupportExp_t)( ur_context_handle_t, ur_device_handle_t, const ur_image_desc_t *, - const ur_image_format_t *, bool, bool *); + const ur_image_format_t *, ur_bool_t, ur_bool_t *); /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urBindlessImagesMipmapGetLevelExp diff --git a/unified-runtime/scripts/core/exp-bindless-images.yml b/unified-runtime/scripts/core/exp-bindless-images.yml index c4e8f5d4cbc5a..62e53e72414f0 100644 --- a/unified-runtime/scripts/core/exp-bindless-images.yml +++ b/unified-runtime/scripts/core/exp-bindless-images.yml @@ -660,7 +660,7 @@ params: - type: "const $x_image_format_t*" name: pImageFormat desc: "[in] pointer to image format specification" - - type: bool* + - type: $x_bool_t* name: pSupportedRet desc: "[out] returned indication of support for allocating USM style memory" returns: @@ -684,7 +684,7 @@ params: - type: "const $x_image_format_t*" name: pImageFormat desc: "[in] pointer to image format specification" - - type: bool* + - type: $x_bool_t* name: pSupportedRet desc: "[out] returned indication of support for allocating opaque handle memory" returns: @@ -708,10 +708,10 @@ params: - type: "const $x_image_format_t*" name: pImageFormat desc: "[in] pointer to image format specification" - - type: bool + - type: $x_bool_t name: isOpaqueAllocation desc: "[in] indicates whether the image memory would be backed by an opaque handle allocation" - - type: bool* + - type: $x_bool_t* name: pSupportedRet desc: "[out] returned indication of support for creating unsampled image handles" returns: @@ -736,10 +736,10 @@ params: - type: "const $x_image_format_t*" name: pImageFormat desc: "[in] pointer to image format specification" - - type: bool + - type: $x_bool_t name: isOpaqueAllocation desc: "[in] indicates whether the image memory would be backed by an opaque handle allocation" - - type: bool* + - type: $x_bool_t* name: pSupportedRet desc: "[out] returned indication of support for creating sampled image handles" returns: diff --git a/unified-runtime/source/adapters/cuda/image.cpp b/unified-runtime/source/adapters/cuda/image.cpp index 080220cd6afb6..5cd572abf7dc2 100644 --- a/unified-runtime/source/adapters/cuda/image.cpp +++ b/unified-runtime/source/adapters/cuda/image.cpp @@ -1269,7 +1269,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesGetImageMemoryPointerSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - bool *pSupportedRet) { + ur_bool_t *pSupportedRet) { UR_ASSERT(std::find(hContext->getDevices().begin(), hContext->getDevices().end(), hDevice) != hContext->getDevices().end(), @@ -1286,7 +1286,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesGetImageMemoryOpaqueSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - bool *pSupportedRet) { + ur_bool_t *pSupportedRet) { UR_ASSERT(std::find(hContext->getDevices().begin(), hContext->getDevices().end(), hDevice) != hContext->getDevices().end(), @@ -1303,7 +1303,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesGetImageUnsampledHandleSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - bool isOpaqueAllocation, bool *pSupportedRet) { + ur_bool_t isOpaqueAllocation, ur_bool_t *pSupportedRet) { UR_ASSERT(std::find(hContext->getDevices().begin(), hContext->getDevices().end(), hDevice) != hContext->getDevices().end(), @@ -1334,7 +1334,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesGetImageSampledHandleSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - bool isOpaqueAllocation, bool *pSupportedRet) { + ur_bool_t isOpaqueAllocation, ur_bool_t *pSupportedRet) { UR_ASSERT(std::find(hContext->getDevices().begin(), hContext->getDevices().end(), hDevice) != hContext->getDevices().end(), diff --git a/unified-runtime/source/adapters/hip/image.cpp b/unified-runtime/source/adapters/hip/image.cpp index c75fba1db0419..3da5e86acca40 100644 --- a/unified-runtime/source/adapters/hip/image.cpp +++ b/unified-runtime/source/adapters/hip/image.cpp @@ -1131,7 +1131,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesGetImageMemoryPointerSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - bool *pSupportedRet) { + ur_bool_t *pSupportedRet) { UR_ASSERT(std::find(hContext->getDevices().begin(), hContext->getDevices().end(), hDevice) != hContext->getDevices().end(), @@ -1148,7 +1148,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesGetImageMemoryOpaqueSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - bool *pSupportedRet) { + ur_bool_t *pSupportedRet) { UR_ASSERT(std::find(hContext->getDevices().begin(), hContext->getDevices().end(), hDevice) != hContext->getDevices().end(), @@ -1165,7 +1165,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesGetImageUnsampledHandleSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - bool isOpaqueAllocation, bool *pSupportedRet) { + ur_bool_t isOpaqueAllocation, ur_bool_t *pSupportedRet) { UR_ASSERT(std::find(hContext->getDevices().begin(), hContext->getDevices().end(), hDevice) != hContext->getDevices().end(), @@ -1196,7 +1196,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesGetImageSampledHandleSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - bool isOpaqueAllocation, bool *pSupportedRet) { + ur_bool_t isOpaqueAllocation, ur_bool_t *pSupportedRet) { UR_ASSERT(std::find(hContext->getDevices().begin(), hContext->getDevices().end(), hDevice) != hContext->getDevices().end(), diff --git a/unified-runtime/source/adapters/level_zero/image.cpp b/unified-runtime/source/adapters/level_zero/image.cpp index 67c3b9c232a6b..5cf2e94026a99 100644 --- a/unified-runtime/source/adapters/level_zero/image.cpp +++ b/unified-runtime/source/adapters/level_zero/image.cpp @@ -614,7 +614,7 @@ ur_result_t urBindlessImagesImageGetInfoExp( ur_result_t urBindlessImagesGetImageMemoryPointerSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - bool *pSupportedRet) { + ur_bool_t *pSupportedRet) { UR_ASSERT(std::find(hContext->getDevices().begin(), hContext->getDevices().end(), hDevice) != hContext->getDevices().end(), @@ -630,7 +630,7 @@ ur_result_t urBindlessImagesGetImageMemoryPointerSupportExp( ur_result_t urBindlessImagesGetImageMemoryOpaqueSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - bool *pSupportedRet) { + ur_bool_t *pSupportedRet) { UR_ASSERT(std::find(hContext->getDevices().begin(), hContext->getDevices().end(), hDevice) != hContext->getDevices().end(), @@ -646,7 +646,7 @@ ur_result_t urBindlessImagesGetImageMemoryOpaqueSupportExp( ur_result_t urBindlessImagesGetImageUnsampledHandleSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - bool isOpaqueAllocation, bool *pSupportedRet) { + ur_bool_t isOpaqueAllocation, ur_bool_t *pSupportedRet) { UR_ASSERT(std::find(hContext->getDevices().begin(), hContext->getDevices().end(), hDevice) != hContext->getDevices().end(), @@ -677,7 +677,7 @@ ur_result_t urBindlessImagesGetImageUnsampledHandleSupportExp( ur_result_t urBindlessImagesGetImageSampledHandleSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - bool isOpaqueAllocation, bool *pSupportedRet) { + ur_bool_t isOpaqueAllocation, ur_bool_t *pSupportedRet) { UR_ASSERT(std::find(hContext->getDevices().begin(), hContext->getDevices().end(), hDevice) != hContext->getDevices().end(), diff --git a/unified-runtime/source/adapters/level_zero/ur_interface_loader.hpp b/unified-runtime/source/adapters/level_zero/ur_interface_loader.hpp index a53fa503ab300..22356bb4b2250 100644 --- a/unified-runtime/source/adapters/level_zero/ur_interface_loader.hpp +++ b/unified-runtime/source/adapters/level_zero/ur_interface_loader.hpp @@ -556,19 +556,19 @@ ur_result_t urBindlessImagesImageGetInfoExp( ur_result_t urBindlessImagesGetImageMemoryPointerSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - bool *pSupportedRet); + ur_bool_t *pSupportedRet); ur_result_t urBindlessImagesGetImageMemoryOpaqueSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - bool *pSupportedRet); + ur_bool_t *pSupportedRet); ur_result_t urBindlessImagesGetImageUnsampledHandleSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - bool isOpaqueAllocation, bool *pSupportedRet); + ur_bool_t isOpaqueAllocation, ur_bool_t *pSupportedRet); ur_result_t urBindlessImagesGetImageSampledHandleSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - bool isOpaqueAllocation, bool *pSupportedRet); + ur_bool_t isOpaqueAllocation, ur_bool_t *pSupportedRet); ur_result_t urBindlessImagesMipmapGetLevelExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, ur_exp_image_mem_native_handle_t hImageMem, uint32_t mipmapLevel, diff --git a/unified-runtime/source/adapters/mock/ur_mockddi.cpp b/unified-runtime/source/adapters/mock/ur_mockddi.cpp index 5f950041743ef..fb561ebf7b676 100644 --- a/unified-runtime/source/adapters/mock/ur_mockddi.cpp +++ b/unified-runtime/source/adapters/mock/ur_mockddi.cpp @@ -8473,7 +8473,7 @@ urBindlessImagesGetImageMemoryPointerSupportExp( /// [in] pointer to image format specification const ur_image_format_t *pImageFormat, /// [out] returned indication of support for allocating USM style memory - bool *pSupportedRet) try { + ur_bool_t *pSupportedRet) try { ur_result_t result = UR_RESULT_SUCCESS; ur_bindless_images_get_image_memory_pointer_support_exp_params_t params = { @@ -8529,7 +8529,7 @@ urBindlessImagesGetImageMemoryOpaqueSupportExp( const ur_image_format_t *pImageFormat, /// [out] returned indication of support for allocating opaque handle /// memory - bool *pSupportedRet) try { + ur_bool_t *pSupportedRet) try { ur_result_t result = UR_RESULT_SUCCESS; ur_bindless_images_get_image_memory_opaque_support_exp_params_t params = { @@ -8586,10 +8586,10 @@ urBindlessImagesGetImageUnsampledHandleSupportExp( const ur_image_format_t *pImageFormat, /// [in] indicates whether the image memory would be backed by an opaque /// handle allocation - bool isOpaqueAllocation, + ur_bool_t isOpaqueAllocation, /// [out] returned indication of support for creating unsampled image /// handles - bool *pSupportedRet) try { + ur_bool_t *pSupportedRet) try { ur_result_t result = UR_RESULT_SUCCESS; ur_bindless_images_get_image_unsampled_handle_support_exp_params_t params = { @@ -8647,10 +8647,10 @@ urBindlessImagesGetImageSampledHandleSupportExp( const ur_image_format_t *pImageFormat, /// [in] indicates whether the image memory would be backed by an opaque /// handle allocation - bool isOpaqueAllocation, + ur_bool_t isOpaqueAllocation, /// [out] returned indication of support for creating sampled image /// handles - bool *pSupportedRet) try { + ur_bool_t *pSupportedRet) try { ur_result_t result = UR_RESULT_SUCCESS; ur_bindless_images_get_image_sampled_handle_support_exp_params_t params = { diff --git a/unified-runtime/source/adapters/native_cpu/image.cpp b/unified-runtime/source/adapters/native_cpu/image.cpp index 7400bf9446c75..cc4a8b8b53e6d 100644 --- a/unified-runtime/source/adapters/native_cpu/image.cpp +++ b/unified-runtime/source/adapters/native_cpu/image.cpp @@ -103,7 +103,7 @@ urBindlessImagesGetImageMemoryPointerSupportExp( [[maybe_unused]] ur_device_handle_t hDevice, [[maybe_unused]] const ur_image_desc_t *pImageDesc, [[maybe_unused]] const ur_image_format_t *pImageFormat, - [[maybe_unused]] bool *pSupportedRet) { + [[maybe_unused]] ur_bool_t *pSupportedRet) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -113,7 +113,7 @@ urBindlessImagesGetImageMemoryOpaqueSupportExp( [[maybe_unused]] ur_device_handle_t hDevice, [[maybe_unused]] const ur_image_desc_t *pImageDesc, [[maybe_unused]] const ur_image_format_t *pImageFormat, - [[maybe_unused]] bool *pSupportedRet) { + [[maybe_unused]] ur_bool_t *pSupportedRet) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -123,8 +123,8 @@ urBindlessImagesGetImageUnsampledHandleSupportExp( [[maybe_unused]] ur_device_handle_t hDevice, [[maybe_unused]] const ur_image_desc_t *pImageDesc, [[maybe_unused]] const ur_image_format_t *pImageFormat, - [[maybe_unused]] bool isOpaqueAllocation, - [[maybe_unused]] bool *pSupportedRet) { + [[maybe_unused]] ur_bool_t isOpaqueAllocation, + [[maybe_unused]] ur_bool_t *pSupportedRet) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -134,8 +134,8 @@ urBindlessImagesGetImageSampledHandleSupportExp( [[maybe_unused]] ur_device_handle_t hDevice, [[maybe_unused]] const ur_image_desc_t *pImageDesc, [[maybe_unused]] const ur_image_format_t *pImageFormat, - [[maybe_unused]] bool isOpaqueAllocation, - [[maybe_unused]] bool *pSupportedRet) { + [[maybe_unused]] ur_bool_t isOpaqueAllocation, + [[maybe_unused]] ur_bool_t *pSupportedRet) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } diff --git a/unified-runtime/source/adapters/opencl/image.cpp b/unified-runtime/source/adapters/opencl/image.cpp index e414fbb75643a..0e8181f3acf2d 100644 --- a/unified-runtime/source/adapters/opencl/image.cpp +++ b/unified-runtime/source/adapters/opencl/image.cpp @@ -103,7 +103,7 @@ urBindlessImagesGetImageMemoryPointerSupportExp( [[maybe_unused]] ur_device_handle_t hDevice, [[maybe_unused]] const ur_image_desc_t *pImageDesc, [[maybe_unused]] const ur_image_format_t *pImageFormat, - [[maybe_unused]] bool *pSupportedRet) { + [[maybe_unused]] ur_bool_t *pSupportedRet) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -113,7 +113,7 @@ urBindlessImagesGetImageMemoryOpaqueSupportExp( [[maybe_unused]] ur_device_handle_t hDevice, [[maybe_unused]] const ur_image_desc_t *pImageDesc, [[maybe_unused]] const ur_image_format_t *pImageFormat, - [[maybe_unused]] bool *pSupportedRet) { + [[maybe_unused]] ur_bool_t *pSupportedRet) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -123,8 +123,8 @@ urBindlessImagesGetImageUnsampledHandleSupportExp( [[maybe_unused]] ur_device_handle_t hDevice, [[maybe_unused]] const ur_image_desc_t *pImageDesc, [[maybe_unused]] const ur_image_format_t *pImageFormat, - [[maybe_unused]] bool isOpaqueAllocation, - [[maybe_unused]] bool *pSupportedRet) { + [[maybe_unused]] ur_bool_t isOpaqueAllocation, + [[maybe_unused]] ur_bool_t *pSupportedRet) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -134,8 +134,8 @@ urBindlessImagesGetImageSampledHandleSupportExp( [[maybe_unused]] ur_device_handle_t hDevice, [[maybe_unused]] const ur_image_desc_t *pImageDesc, [[maybe_unused]] const ur_image_format_t *pImageFormat, - [[maybe_unused]] bool isOpaqueAllocation, - [[maybe_unused]] bool *pSupportedRet) { + [[maybe_unused]] ur_bool_t isOpaqueAllocation, + [[maybe_unused]] ur_bool_t *pSupportedRet) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } diff --git a/unified-runtime/source/loader/layers/tracing/ur_trcddi.cpp b/unified-runtime/source/loader/layers/tracing/ur_trcddi.cpp index 132cf41601c42..b6795e78e62d9 100644 --- a/unified-runtime/source/loader/layers/tracing/ur_trcddi.cpp +++ b/unified-runtime/source/loader/layers/tracing/ur_trcddi.cpp @@ -7026,7 +7026,7 @@ urBindlessImagesGetImageMemoryPointerSupportExp( /// [in] pointer to image format specification const ur_image_format_t *pImageFormat, /// [out] returned indication of support for allocating USM style memory - bool *pSupportedRet) { + ur_bool_t *pSupportedRet) { auto pfnGetImageMemoryPointerSupportExp = getContext() ->urDdiTable.BindlessImagesExp.pfnGetImageMemoryPointerSupportExp; @@ -7079,7 +7079,7 @@ urBindlessImagesGetImageMemoryOpaqueSupportExp( const ur_image_format_t *pImageFormat, /// [out] returned indication of support for allocating opaque handle /// memory - bool *pSupportedRet) { + ur_bool_t *pSupportedRet) { auto pfnGetImageMemoryOpaqueSupportExp = getContext() ->urDdiTable.BindlessImagesExp.pfnGetImageMemoryOpaqueSupportExp; @@ -7133,10 +7133,10 @@ urBindlessImagesGetImageUnsampledHandleSupportExp( const ur_image_format_t *pImageFormat, /// [in] indicates whether the image memory would be backed by an opaque /// handle allocation - bool isOpaqueAllocation, + ur_bool_t isOpaqueAllocation, /// [out] returned indication of support for creating unsampled image /// handles - bool *pSupportedRet) { + ur_bool_t *pSupportedRet) { auto pfnGetImageUnsampledHandleSupportExp = getContext() ->urDdiTable.BindlessImagesExp.pfnGetImageUnsampledHandleSupportExp; @@ -7192,10 +7192,10 @@ urBindlessImagesGetImageSampledHandleSupportExp( const ur_image_format_t *pImageFormat, /// [in] indicates whether the image memory would be backed by an opaque /// handle allocation - bool isOpaqueAllocation, + ur_bool_t isOpaqueAllocation, /// [out] returned indication of support for creating sampled image /// handles - bool *pSupportedRet) { + ur_bool_t *pSupportedRet) { auto pfnGetImageSampledHandleSupportExp = getContext() ->urDdiTable.BindlessImagesExp.pfnGetImageSampledHandleSupportExp; diff --git a/unified-runtime/source/loader/layers/validation/ur_valddi.cpp b/unified-runtime/source/loader/layers/validation/ur_valddi.cpp index e54480334a7b3..acea1efef45d6 100644 --- a/unified-runtime/source/loader/layers/validation/ur_valddi.cpp +++ b/unified-runtime/source/loader/layers/validation/ur_valddi.cpp @@ -7717,7 +7717,7 @@ urBindlessImagesGetImageMemoryPointerSupportExp( /// [in] pointer to image format specification const ur_image_format_t *pImageFormat, /// [out] returned indication of support for allocating USM style memory - bool *pSupportedRet) { + ur_bool_t *pSupportedRet) { auto pfnGetImageMemoryPointerSupportExp = getContext() ->urDdiTable.BindlessImagesExp.pfnGetImageMemoryPointerSupportExp; @@ -7773,7 +7773,7 @@ urBindlessImagesGetImageMemoryOpaqueSupportExp( const ur_image_format_t *pImageFormat, /// [out] returned indication of support for allocating opaque handle /// memory - bool *pSupportedRet) { + ur_bool_t *pSupportedRet) { auto pfnGetImageMemoryOpaqueSupportExp = getContext() ->urDdiTable.BindlessImagesExp.pfnGetImageMemoryOpaqueSupportExp; @@ -7830,10 +7830,10 @@ urBindlessImagesGetImageUnsampledHandleSupportExp( const ur_image_format_t *pImageFormat, /// [in] indicates whether the image memory would be backed by an opaque /// handle allocation - bool isOpaqueAllocation, + ur_bool_t isOpaqueAllocation, /// [out] returned indication of support for creating unsampled image /// handles - bool *pSupportedRet) { + ur_bool_t *pSupportedRet) { auto pfnGetImageUnsampledHandleSupportExp = getContext() ->urDdiTable.BindlessImagesExp.pfnGetImageUnsampledHandleSupportExp; @@ -7891,10 +7891,10 @@ urBindlessImagesGetImageSampledHandleSupportExp( const ur_image_format_t *pImageFormat, /// [in] indicates whether the image memory would be backed by an opaque /// handle allocation - bool isOpaqueAllocation, + ur_bool_t isOpaqueAllocation, /// [out] returned indication of support for creating sampled image /// handles - bool *pSupportedRet) { + ur_bool_t *pSupportedRet) { auto pfnGetImageSampledHandleSupportExp = getContext() ->urDdiTable.BindlessImagesExp.pfnGetImageSampledHandleSupportExp; diff --git a/unified-runtime/source/loader/ur_ldrddi.cpp b/unified-runtime/source/loader/ur_ldrddi.cpp index b3f5fb0d8d524..4dafd5008ac71 100644 --- a/unified-runtime/source/loader/ur_ldrddi.cpp +++ b/unified-runtime/source/loader/ur_ldrddi.cpp @@ -7122,7 +7122,7 @@ urBindlessImagesGetImageMemoryPointerSupportExp( /// [in] pointer to image format specification const ur_image_format_t *pImageFormat, /// [out] returned indication of support for allocating USM style memory - bool *pSupportedRet) { + ur_bool_t *pSupportedRet) { ur_result_t result = UR_RESULT_SUCCESS; [[maybe_unused]] auto context = getContext(); @@ -7161,7 +7161,7 @@ urBindlessImagesGetImageMemoryOpaqueSupportExp( const ur_image_format_t *pImageFormat, /// [out] returned indication of support for allocating opaque handle /// memory - bool *pSupportedRet) { + ur_bool_t *pSupportedRet) { ur_result_t result = UR_RESULT_SUCCESS; [[maybe_unused]] auto context = getContext(); @@ -7201,10 +7201,10 @@ urBindlessImagesGetImageUnsampledHandleSupportExp( const ur_image_format_t *pImageFormat, /// [in] indicates whether the image memory would be backed by an opaque /// handle allocation - bool isOpaqueAllocation, + ur_bool_t isOpaqueAllocation, /// [out] returned indication of support for creating unsampled image /// handles - bool *pSupportedRet) { + ur_bool_t *pSupportedRet) { ur_result_t result = UR_RESULT_SUCCESS; [[maybe_unused]] auto context = getContext(); @@ -7245,10 +7245,10 @@ urBindlessImagesGetImageSampledHandleSupportExp( const ur_image_format_t *pImageFormat, /// [in] indicates whether the image memory would be backed by an opaque /// handle allocation - bool isOpaqueAllocation, + ur_bool_t isOpaqueAllocation, /// [out] returned indication of support for creating sampled image /// handles - bool *pSupportedRet) { + ur_bool_t *pSupportedRet) { ur_result_t result = UR_RESULT_SUCCESS; [[maybe_unused]] auto context = getContext(); diff --git a/unified-runtime/source/loader/ur_libapi.cpp b/unified-runtime/source/loader/ur_libapi.cpp index b31bdae126a1f..3bfc7a22f683b 100644 --- a/unified-runtime/source/loader/ur_libapi.cpp +++ b/unified-runtime/source/loader/ur_libapi.cpp @@ -7696,7 +7696,7 @@ ur_result_t UR_APICALL urBindlessImagesGetImageMemoryPointerSupportExp( /// [in] pointer to image format specification const ur_image_format_t *pImageFormat, /// [out] returned indication of support for allocating USM style memory - bool *pSupportedRet) try { + ur_bool_t *pSupportedRet) try { auto pfnGetImageMemoryPointerSupportExp = ur_lib::getContext() ->urDdiTable.BindlessImagesExp.pfnGetImageMemoryPointerSupportExp; @@ -7737,7 +7737,7 @@ ur_result_t UR_APICALL urBindlessImagesGetImageMemoryOpaqueSupportExp( const ur_image_format_t *pImageFormat, /// [out] returned indication of support for allocating opaque handle /// memory - bool *pSupportedRet) try { + ur_bool_t *pSupportedRet) try { auto pfnGetImageMemoryOpaqueSupportExp = ur_lib::getContext() ->urDdiTable.BindlessImagesExp.pfnGetImageMemoryOpaqueSupportExp; @@ -7779,10 +7779,10 @@ ur_result_t UR_APICALL urBindlessImagesGetImageUnsampledHandleSupportExp( const ur_image_format_t *pImageFormat, /// [in] indicates whether the image memory would be backed by an opaque /// handle allocation - bool isOpaqueAllocation, + ur_bool_t isOpaqueAllocation, /// [out] returned indication of support for creating unsampled image /// handles - bool *pSupportedRet) try { + ur_bool_t *pSupportedRet) try { auto pfnGetImageUnsampledHandleSupportExp = ur_lib::getContext() ->urDdiTable.BindlessImagesExp.pfnGetImageUnsampledHandleSupportExp; @@ -7825,10 +7825,10 @@ ur_result_t UR_APICALL urBindlessImagesGetImageSampledHandleSupportExp( const ur_image_format_t *pImageFormat, /// [in] indicates whether the image memory would be backed by an opaque /// handle allocation - bool isOpaqueAllocation, + ur_bool_t isOpaqueAllocation, /// [out] returned indication of support for creating sampled image /// handles - bool *pSupportedRet) try { + ur_bool_t *pSupportedRet) try { auto pfnGetImageSampledHandleSupportExp = ur_lib::getContext() ->urDdiTable.BindlessImagesExp.pfnGetImageSampledHandleSupportExp; diff --git a/unified-runtime/source/ur_api.cpp b/unified-runtime/source/ur_api.cpp index 38f371b5b282d..d04ae135f079d 100644 --- a/unified-runtime/source/ur_api.cpp +++ b/unified-runtime/source/ur_api.cpp @@ -6739,7 +6739,7 @@ ur_result_t UR_APICALL urBindlessImagesGetImageMemoryPointerSupportExp( /// [in] pointer to image format specification const ur_image_format_t *pImageFormat, /// [out] returned indication of support for allocating USM style memory - bool *pSupportedRet) { + ur_bool_t *pSupportedRet) { ur_result_t result = UR_RESULT_SUCCESS; return result; } @@ -6772,7 +6772,7 @@ ur_result_t UR_APICALL urBindlessImagesGetImageMemoryOpaqueSupportExp( const ur_image_format_t *pImageFormat, /// [out] returned indication of support for allocating opaque handle /// memory - bool *pSupportedRet) { + ur_bool_t *pSupportedRet) { ur_result_t result = UR_RESULT_SUCCESS; return result; } @@ -6806,10 +6806,10 @@ ur_result_t UR_APICALL urBindlessImagesGetImageUnsampledHandleSupportExp( const ur_image_format_t *pImageFormat, /// [in] indicates whether the image memory would be backed by an opaque /// handle allocation - bool isOpaqueAllocation, + ur_bool_t isOpaqueAllocation, /// [out] returned indication of support for creating unsampled image /// handles - bool *pSupportedRet) { + ur_bool_t *pSupportedRet) { ur_result_t result = UR_RESULT_SUCCESS; return result; } @@ -6843,10 +6843,10 @@ ur_result_t UR_APICALL urBindlessImagesGetImageSampledHandleSupportExp( const ur_image_format_t *pImageFormat, /// [in] indicates whether the image memory would be backed by an opaque /// handle allocation - bool isOpaqueAllocation, + ur_bool_t isOpaqueAllocation, /// [out] returned indication of support for creating sampled image /// handles - bool *pSupportedRet) { + ur_bool_t *pSupportedRet) { ur_result_t result = UR_RESULT_SUCCESS; return result; } From 65cb5b4a81c8c10cb843501b58ba7509411aff6e Mon Sep 17 00:00:00 2001 From: Przemek Malon Date: Tue, 8 Apr 2025 12:22:39 +0100 Subject: [PATCH 06/13] Update use of ur_bool_t --- sycl/source/detail/bindless_images.cpp | 12 ++++++------ .../source/adapters/level_zero/v2/api.cpp | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sycl/source/detail/bindless_images.cpp b/sycl/source/detail/bindless_images.cpp index 971ae11ccf071..7e027eb95d6b2 100644 --- a/sycl/source/detail/bindless_images.cpp +++ b/sycl/source/detail/bindless_images.cpp @@ -918,14 +918,14 @@ get_image_memory_support(const image_descriptor &imageDescriptor, ur_image_format_t urFormat; populate_ur_structs(imageDescriptor, urDesc, urFormat); - bool supportsPointerAllocation = false; + ur_bool_t supportsPointerAllocation{0}; Adapter->call< sycl::errc::runtime, sycl::detail::UrApiKind::urBindlessImagesGetImageMemoryPointerSupportExp>( CtxImpl->getHandleRef(), DevImpl->getHandleRef(), &urDesc, &urFormat, &supportsPointerAllocation); - bool supportsOpaqueAllocation = false; + ur_bool_t supportsOpaqueAllocation{0}; Adapter->call< sycl::errc::runtime, sycl::detail::UrApiKind::urBindlessImagesGetImageMemoryOpaqueSupportExp>( @@ -967,10 +967,10 @@ __SYCL_EXPORT bool get_image_handle_supported( ur_image_format_t urFormat; populate_ur_structs(imageDescriptor, urDesc, urFormat); - const bool isOpaqueMemoryHandle = + const ur_bool_t isOpaqueMemoryHandle = (imageMemoryHandleType == image_memory_handle_type::opaque_handle); - bool supportsUnsampledHandle = false; + ur_bool_t supportsUnsampledHandle{0}; Adapter->call( @@ -1005,10 +1005,10 @@ __SYCL_EXPORT bool get_image_handle_supported( ur_image_format_t urFormat; populate_ur_structs(imageDescriptor, urDesc, urFormat); - const bool isOpaqueMemoryHandle = + const ur_bool_t isOpaqueMemoryHandle = (imageMemoryHandleType == image_memory_handle_type::opaque_handle); - bool supportsSampledHandle = false; + ur_bool_t supportsSampledHandle{0}; Adapter->call< sycl::errc::runtime, sycl::detail::UrApiKind::urBindlessImagesGetImageSampledHandleSupportExp>( diff --git a/unified-runtime/source/adapters/level_zero/v2/api.cpp b/unified-runtime/source/adapters/level_zero/v2/api.cpp index 84365d0d1c171..c93687d366a72 100644 --- a/unified-runtime/source/adapters/level_zero/v2/api.cpp +++ b/unified-runtime/source/adapters/level_zero/v2/api.cpp @@ -173,7 +173,7 @@ ur_result_t urBindlessImagesReleaseExternalSemaphoreExp( ur_result_t urBindlessImagesGetImageMemoryPointerSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - bool *pSupportedRet) { + ur_bool_t *pSupportedRet) { logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -181,7 +181,7 @@ ur_result_t urBindlessImagesGetImageMemoryPointerSupportExp( ur_result_t urBindlessImagesGetImageMemoryOpaqueSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - bool *pSupportedRet) { + ur_bool_t *pSupportedRet) { logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -189,7 +189,7 @@ ur_result_t urBindlessImagesGetImageMemoryOpaqueSupportExp( ur_result_t urBindlessImagesGetImageUnsampledHandleSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - bool isOpaqueAllocation, bool *pSupportedRet) { + ur_bool_t isOpaqueAllocation, ur_bool_t *pSupportedRet) { logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -197,7 +197,7 @@ ur_result_t urBindlessImagesGetImageUnsampledHandleSupportExp( ur_result_t urBindlessImagesGetImageSampledHandleSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - bool isOpaqueAllocation, bool *pSupportedRet) { + ur_bool_t isOpaqueAllocation, ur_bool_t *pSupportedRet) { logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } From 0606014586dfcf26a6ce1cf4169470fc8152491c Mon Sep 17 00:00:00 2001 From: Przemek Malon Date: Tue, 8 Apr 2025 16:25:06 +0100 Subject: [PATCH 07/13] Combine UR memory allocation queries. Use more UR helper functions. --- sycl/source/detail/bindless_images.cpp | 30 ++- unified-runtime/include/ur_api.h | 107 +++----- unified-runtime/include/ur_api_funcs.def | 3 +- unified-runtime/include/ur_ddi.h | 24 +- unified-runtime/include/ur_print.h | 28 +- unified-runtime/include/ur_print.hpp | 94 +++---- .../scripts/core/EXP-BINDLESS-IMAGES.rst | 17 +- .../scripts/core/exp-bindless-images.yml | 58 ++--- unified-runtime/scripts/core/registry.yml | 9 +- .../source/adapters/cuda/image.cpp | 242 ++++++++++-------- .../source/adapters/cuda/image.hpp | 28 +- .../adapters/cuda/ur_interface_loader.cpp | 6 +- unified-runtime/source/adapters/hip/image.cpp | 149 ++++++----- unified-runtime/source/adapters/hip/image.hpp | 28 +- .../adapters/hip/ur_interface_loader.cpp | 6 +- .../level_zero/helpers/image_helpers.cpp | 165 +++++++----- .../level_zero/helpers/image_helpers.hpp | 28 +- .../source/adapters/level_zero/image.cpp | 32 +-- .../level_zero/ur_interface_loader.cpp | 6 +- .../level_zero/ur_interface_loader.hpp | 12 +- .../source/adapters/level_zero/v2/api.cpp | 16 +- .../source/adapters/mock/ur_mockddi.cpp | 97 ++----- .../source/adapters/native_cpu/image.cpp | 17 +- .../native_cpu/ur_interface_loader.cpp | 6 +- .../source/adapters/opencl/image.cpp | 17 +- .../adapters/opencl/ur_interface_loader.cpp | 6 +- .../loader/layers/tracing/ur_trcddi.cpp | 124 +++------ .../loader/layers/validation/ur_valddi.cpp | 110 +++----- unified-runtime/source/loader/loader.def.in | 7 +- unified-runtime/source/loader/loader.map.in | 7 +- unified-runtime/source/loader/ur_ldrddi.cpp | 79 ++---- unified-runtime/source/loader/ur_libapi.cpp | 89 +++---- unified-runtime/source/loader/ur_print.cpp | 20 +- unified-runtime/source/ur_api.cpp | 66 ++--- 34 files changed, 772 insertions(+), 961 deletions(-) diff --git a/sycl/source/detail/bindless_images.cpp b/sycl/source/detail/bindless_images.cpp index 7e027eb95d6b2..9f124d1c70cd6 100644 --- a/sycl/source/detail/bindless_images.cpp +++ b/sycl/source/detail/bindless_images.cpp @@ -919,17 +919,19 @@ get_image_memory_support(const image_descriptor &imageDescriptor, populate_ur_structs(imageDescriptor, urDesc, urFormat); ur_bool_t supportsPointerAllocation{0}; - Adapter->call< - sycl::errc::runtime, - sycl::detail::UrApiKind::urBindlessImagesGetImageMemoryPointerSupportExp>( + Adapter->call( CtxImpl->getHandleRef(), DevImpl->getHandleRef(), &urDesc, &urFormat, + ur_exp_image_mem_type_t::UR_EXP_IMAGE_MEM_TYPE_USM_POINTER, &supportsPointerAllocation); ur_bool_t supportsOpaqueAllocation{0}; - Adapter->call< - sycl::errc::runtime, - sycl::detail::UrApiKind::urBindlessImagesGetImageMemoryOpaqueSupportExp>( + Adapter->call( CtxImpl->getHandleRef(), DevImpl->getHandleRef(), &urDesc, &urFormat, + ur_exp_image_mem_type_t::UR_EXP_IMAGE_MEM_TYPE_OPAQUE_HANDLE, &supportsOpaqueAllocation); std::vector supportedMemHandleTypes; @@ -967,15 +969,17 @@ __SYCL_EXPORT bool get_image_handle_supported( ur_image_format_t urFormat; populate_ur_structs(imageDescriptor, urDesc, urFormat); - const ur_bool_t isOpaqueMemoryHandle = - (imageMemoryHandleType == image_memory_handle_type::opaque_handle); + const ur_exp_image_mem_type_t memHandleType = + (imageMemoryHandleType == image_memory_handle_type::opaque_handle) + ? ur_exp_image_mem_type_t::UR_EXP_IMAGE_MEM_TYPE_OPAQUE_HANDLE + : ur_exp_image_mem_type_t::UR_EXP_IMAGE_MEM_TYPE_USM_POINTER; ur_bool_t supportsUnsampledHandle{0}; Adapter->call( CtxImpl->getHandleRef(), DevImpl->getHandleRef(), &urDesc, &urFormat, - isOpaqueMemoryHandle, &supportsUnsampledHandle); + memHandleType, &supportsUnsampledHandle); return supportsUnsampledHandle; } @@ -1005,15 +1009,17 @@ __SYCL_EXPORT bool get_image_handle_supported( ur_image_format_t urFormat; populate_ur_structs(imageDescriptor, urDesc, urFormat); - const ur_bool_t isOpaqueMemoryHandle = - (imageMemoryHandleType == image_memory_handle_type::opaque_handle); + const ur_exp_image_mem_type_t memHandleType = + (imageMemoryHandleType == image_memory_handle_type::opaque_handle) + ? ur_exp_image_mem_type_t::UR_EXP_IMAGE_MEM_TYPE_OPAQUE_HANDLE + : ur_exp_image_mem_type_t::UR_EXP_IMAGE_MEM_TYPE_USM_POINTER; ur_bool_t supportsSampledHandle{0}; Adapter->call< sycl::errc::runtime, sycl::detail::UrApiKind::urBindlessImagesGetImageSampledHandleSupportExp>( CtxImpl->getHandleRef(), DevImpl->getHandleRef(), &urDesc, &urFormat, - isOpaqueMemoryHandle, &supportsSampledHandle); + memHandleType, &supportsSampledHandle); return supportsSampledHandle; } diff --git a/unified-runtime/include/ur_api.h b/unified-runtime/include/ur_api.h index eb5ab4aac1b1a..77335c7f580be 100644 --- a/unified-runtime/include/ur_api.h +++ b/unified-runtime/include/ur_api.h @@ -457,14 +457,12 @@ typedef enum ur_function_t { UR_FUNCTION_COMMAND_BUFFER_GET_NATIVE_HANDLE_EXP = 264, /// Enumerator for ::urUSMPoolSetInfoExp UR_FUNCTION_USM_POOL_SET_INFO_EXP = 265, - /// Enumerator for ::urBindlessImagesGetImageMemoryPointerSupportExp - UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_POINTER_SUPPORT_EXP = 266, - /// Enumerator for ::urBindlessImagesGetImageMemoryOpaqueSupportExp - UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_OPAQUE_SUPPORT_EXP = 267, /// Enumerator for ::urBindlessImagesGetImageUnsampledHandleSupportExp UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_UNSAMPLED_HANDLE_SUPPORT_EXP = 268, /// Enumerator for ::urBindlessImagesGetImageSampledHandleSupportExp UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_SAMPLED_HANDLE_SUPPORT_EXP = 269, + /// Enumerator for ::urBindlessImagesGetImageMemoryHandleTypeSupportExp + UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_HANDLE_TYPE_SUPPORT_EXP = 270, /// @cond UR_FUNCTION_FORCE_UINT32 = 0x7fffffff /// @endcond @@ -9621,6 +9619,19 @@ typedef enum ur_exp_external_semaphore_type_t { } ur_exp_external_semaphore_type_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Indicates the type of image backing memory handle. +typedef enum ur_exp_image_mem_type_t { + /// USM pointer to image memory + UR_EXP_IMAGE_MEM_TYPE_USM_POINTER = 0, + /// Opaque handle to image memory + UR_EXP_IMAGE_MEM_TYPE_OPAQUE_HANDLE = 1, + /// @cond + UR_EXP_IMAGE_MEM_TYPE_FORCE_UINT32 = 0x7fffffff + /// @endcond + +} ur_exp_image_mem_type_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief File descriptor typedef struct ur_exp_file_descriptor_t { @@ -10116,38 +10127,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( size_t *pPropSizeRet); /////////////////////////////////////////////////////////////////////////////// -/// @brief Query support for allocating pointer handle type image memory with -/// specific image properties -/// -/// @returns -/// - ::UR_RESULT_SUCCESS -/// - ::UR_RESULT_ERROR_UNINITIALIZED -/// - ::UR_RESULT_ERROR_DEVICE_LOST -/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC -/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hContext` -/// + `NULL == hDevice` -/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// + `NULL == pImageDesc` -/// + `NULL == pImageFormat` -/// + `NULL == pSupportedRet` -/// - ::UR_RESULT_ERROR_INVALID_DEVICE -UR_APIEXPORT ur_result_t UR_APICALL -urBindlessImagesGetImageMemoryPointerSupportExp( - /// [in] handle of the context object - ur_context_handle_t hContext, - /// [in] handle of the device object - ur_device_handle_t hDevice, - /// [in] pointer to image description - const ur_image_desc_t *pImageDesc, - /// [in] pointer to image format specification - const ur_image_format_t *pImageFormat, - /// [out] returned indication of support for allocating USM style memory - ur_bool_t *pSupportedRet); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Query support for allocating opaque handle type image memory with -/// specific image properties +/// @brief Query support for allocating a given image backing memory handle type +/// with specific image properties /// /// @returns /// - ::UR_RESULT_SUCCESS @@ -10161,9 +10142,12 @@ urBindlessImagesGetImageMemoryPointerSupportExp( /// + `NULL == pImageDesc` /// + `NULL == pImageFormat` /// + `NULL == pSupportedRet` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_EXP_IMAGE_MEM_TYPE_OPAQUE_HANDLE < imageMemHandleType` /// - ::UR_RESULT_ERROR_INVALID_DEVICE +/// - ::UR_RESULT_ERROR_INVALID_CONTEXT UR_APIEXPORT ur_result_t UR_APICALL -urBindlessImagesGetImageMemoryOpaqueSupportExp( +urBindlessImagesGetImageMemoryHandleTypeSupportExp( /// [in] handle of the context object ur_context_handle_t hContext, /// [in] handle of the device object @@ -10172,8 +10156,10 @@ urBindlessImagesGetImageMemoryOpaqueSupportExp( const ur_image_desc_t *pImageDesc, /// [in] pointer to image format specification const ur_image_format_t *pImageFormat, - /// [out] returned indication of support for allocating opaque handle - /// memory + /// [in] type of image backing memory handle to query support for + ur_exp_image_mem_type_t imageMemHandleType, + /// [out] returned indication of support for allocating the given image + /// backing memory handle type ur_bool_t *pSupportedRet); /////////////////////////////////////////////////////////////////////////////// @@ -10192,6 +10178,8 @@ urBindlessImagesGetImageMemoryOpaqueSupportExp( /// + `NULL == pImageDesc` /// + `NULL == pImageFormat` /// + `NULL == pSupportedRet` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_EXP_IMAGE_MEM_TYPE_OPAQUE_HANDLE < imageMemHandleType` /// - ::UR_RESULT_ERROR_INVALID_DEVICE /// - ::UR_RESULT_ERROR_INVALID_CONTEXT UR_APIEXPORT ur_result_t UR_APICALL @@ -10204,16 +10192,16 @@ urBindlessImagesGetImageUnsampledHandleSupportExp( const ur_image_desc_t *pImageDesc, /// [in] pointer to image format specification const ur_image_format_t *pImageFormat, - /// [in] indicates whether the image memory would be backed by an opaque - /// handle allocation - ur_bool_t isOpaqueAllocation, + /// [in] type of image backing memory handle to query support for + ur_exp_image_mem_type_t imageMemHandleType, /// [out] returned indication of support for creating unsampled image /// handles ur_bool_t *pSupportedRet); /////////////////////////////////////////////////////////////////////////////// -/// @brief Query support for creating an unsampled image handle with specific -/// image properties +/// @brief Query support for creating an sampled image handle with specific +/// image +/// properties /// /// @returns /// - ::UR_RESULT_SUCCESS @@ -10227,6 +10215,8 @@ urBindlessImagesGetImageUnsampledHandleSupportExp( /// + `NULL == pImageDesc` /// + `NULL == pImageFormat` /// + `NULL == pSupportedRet` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_EXP_IMAGE_MEM_TYPE_OPAQUE_HANDLE < imageMemHandleType` /// - ::UR_RESULT_ERROR_INVALID_DEVICE /// - ::UR_RESULT_ERROR_INVALID_CONTEXT UR_APIEXPORT ur_result_t UR_APICALL @@ -10239,9 +10229,8 @@ urBindlessImagesGetImageSampledHandleSupportExp( const ur_image_desc_t *pImageDesc, /// [in] pointer to image format specification const ur_image_format_t *pImageFormat, - /// [in] indicates whether the image memory would be backed by an opaque - /// handle allocation - ur_bool_t isOpaqueAllocation, + /// [in] type of image backing memory handle to query support for + ur_exp_image_mem_type_t imageMemHandleType, /// [out] returned indication of support for creating sampled image /// handles ur_bool_t *pSupportedRet); @@ -14698,30 +14687,18 @@ typedef struct ur_bindless_images_image_get_info_exp_params_t { /////////////////////////////////////////////////////////////////////////////// /// @brief Function parameters for -/// urBindlessImagesGetImageMemoryPointerSupportExp +/// urBindlessImagesGetImageMemoryHandleTypeSupportExp /// @details Each entry is a pointer to the parameter passed to the function; /// allowing the callback the ability to modify the parameter's value typedef struct - ur_bindless_images_get_image_memory_pointer_support_exp_params_t { - ur_context_handle_t *phContext; - ur_device_handle_t *phDevice; - const ur_image_desc_t **ppImageDesc; - const ur_image_format_t **ppImageFormat; - ur_bool_t **ppSupportedRet; -} ur_bindless_images_get_image_memory_pointer_support_exp_params_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function parameters for -/// urBindlessImagesGetImageMemoryOpaqueSupportExp -/// @details Each entry is a pointer to the parameter passed to the function; -/// allowing the callback the ability to modify the parameter's value -typedef struct ur_bindless_images_get_image_memory_opaque_support_exp_params_t { + ur_bindless_images_get_image_memory_handle_type_support_exp_params_t { ur_context_handle_t *phContext; ur_device_handle_t *phDevice; const ur_image_desc_t **ppImageDesc; const ur_image_format_t **ppImageFormat; + ur_exp_image_mem_type_t *pimageMemHandleType; ur_bool_t **ppSupportedRet; -} ur_bindless_images_get_image_memory_opaque_support_exp_params_t; +} ur_bindless_images_get_image_memory_handle_type_support_exp_params_t; /////////////////////////////////////////////////////////////////////////////// /// @brief Function parameters for @@ -14734,7 +14711,7 @@ typedef struct ur_device_handle_t *phDevice; const ur_image_desc_t **ppImageDesc; const ur_image_format_t **ppImageFormat; - ur_bool_t *pisOpaqueAllocation; + ur_exp_image_mem_type_t *pimageMemHandleType; ur_bool_t **ppSupportedRet; } ur_bindless_images_get_image_unsampled_handle_support_exp_params_t; @@ -14749,7 +14726,7 @@ typedef struct ur_device_handle_t *phDevice; const ur_image_desc_t **ppImageDesc; const ur_image_format_t **ppImageFormat; - ur_bool_t *pisOpaqueAllocation; + ur_exp_image_mem_type_t *pimageMemHandleType; ur_bool_t **ppSupportedRet; } ur_bindless_images_get_image_sampled_handle_support_exp_params_t; diff --git a/unified-runtime/include/ur_api_funcs.def b/unified-runtime/include/ur_api_funcs.def index 58eddf0b89123..f2e61dacf4241 100644 --- a/unified-runtime/include/ur_api_funcs.def +++ b/unified-runtime/include/ur_api_funcs.def @@ -168,8 +168,7 @@ _UR_API(urBindlessImagesUnsampledImageCreateExp) _UR_API(urBindlessImagesSampledImageCreateExp) _UR_API(urBindlessImagesImageCopyExp) _UR_API(urBindlessImagesImageGetInfoExp) -_UR_API(urBindlessImagesGetImageMemoryPointerSupportExp) -_UR_API(urBindlessImagesGetImageMemoryOpaqueSupportExp) +_UR_API(urBindlessImagesGetImageMemoryHandleTypeSupportExp) _UR_API(urBindlessImagesGetImageUnsampledHandleSupportExp) _UR_API(urBindlessImagesGetImageSampledHandleSupportExp) _UR_API(urBindlessImagesMipmapGetLevelExp) diff --git a/unified-runtime/include/ur_ddi.h b/unified-runtime/include/ur_ddi.h index 2f73c42fa3249..d9b34b36576a5 100644 --- a/unified-runtime/include/ur_ddi.h +++ b/unified-runtime/include/ur_ddi.h @@ -1445,18 +1445,12 @@ typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImageGetInfoExp_t)( void *, size_t *); /////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for urBindlessImagesGetImageMemoryPointerSupportExp -typedef ur_result_t( - UR_APICALL *ur_pfnBindlessImagesGetImageMemoryPointerSupportExp_t)( - ur_context_handle_t, ur_device_handle_t, const ur_image_desc_t *, - const ur_image_format_t *, ur_bool_t *); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for urBindlessImagesGetImageMemoryOpaqueSupportExp +/// @brief Function-pointer for +/// urBindlessImagesGetImageMemoryHandleTypeSupportExp typedef ur_result_t( - UR_APICALL *ur_pfnBindlessImagesGetImageMemoryOpaqueSupportExp_t)( + UR_APICALL *ur_pfnBindlessImagesGetImageMemoryHandleTypeSupportExp_t)( ur_context_handle_t, ur_device_handle_t, const ur_image_desc_t *, - const ur_image_format_t *, ur_bool_t *); + const ur_image_format_t *, ur_exp_image_mem_type_t, ur_bool_t *); /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for @@ -1464,14 +1458,14 @@ typedef ur_result_t( typedef ur_result_t( UR_APICALL *ur_pfnBindlessImagesGetImageUnsampledHandleSupportExp_t)( ur_context_handle_t, ur_device_handle_t, const ur_image_desc_t *, - const ur_image_format_t *, ur_bool_t, ur_bool_t *); + const ur_image_format_t *, ur_exp_image_mem_type_t, ur_bool_t *); /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urBindlessImagesGetImageSampledHandleSupportExp typedef ur_result_t( UR_APICALL *ur_pfnBindlessImagesGetImageSampledHandleSupportExp_t)( ur_context_handle_t, ur_device_handle_t, const ur_image_desc_t *, - const ur_image_format_t *, ur_bool_t, ur_bool_t *); + const ur_image_format_t *, ur_exp_image_mem_type_t, ur_bool_t *); /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urBindlessImagesMipmapGetLevelExp @@ -1549,10 +1543,8 @@ typedef struct ur_bindless_images_exp_dditable_t { ur_pfnBindlessImagesSampledImageCreateExp_t pfnSampledImageCreateExp; ur_pfnBindlessImagesImageCopyExp_t pfnImageCopyExp; ur_pfnBindlessImagesImageGetInfoExp_t pfnImageGetInfoExp; - ur_pfnBindlessImagesGetImageMemoryPointerSupportExp_t - pfnGetImageMemoryPointerSupportExp; - ur_pfnBindlessImagesGetImageMemoryOpaqueSupportExp_t - pfnGetImageMemoryOpaqueSupportExp; + ur_pfnBindlessImagesGetImageMemoryHandleTypeSupportExp_t + pfnGetImageMemoryHandleTypeSupportExp; ur_pfnBindlessImagesGetImageUnsampledHandleSupportExp_t pfnGetImageUnsampledHandleSupportExp; ur_pfnBindlessImagesGetImageSampledHandleSupportExp_t diff --git a/unified-runtime/include/ur_print.h b/unified-runtime/include/ur_print.h index eec03ff8d5970..3c4c39dea080a 100644 --- a/unified-runtime/include/ur_print.h +++ b/unified-runtime/include/ur_print.h @@ -1202,6 +1202,16 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintExpExternalSemaphoreType( enum ur_exp_external_semaphore_type_t value, char *buffer, const size_t buff_size, size_t *out_size); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_exp_image_mem_type_t enum +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +UR_APIEXPORT ur_result_t UR_APICALL +urPrintExpImageMemType(enum ur_exp_image_mem_type_t value, char *buffer, + const size_t buff_size, size_t *out_size); + /////////////////////////////////////////////////////////////////////////////// /// @brief Print ur_exp_file_descriptor_t struct /// @returns @@ -3037,27 +3047,15 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesImageGetInfoExpParams( /////////////////////////////////////////////////////////////////////////////// /// @brief Print -/// ur_bindless_images_get_image_memory_pointer_support_exp_params_t struct +/// ur_bindless_images_get_image_memory_handle_type_support_exp_params_t struct /// @returns /// - ::UR_RESULT_SUCCESS /// - ::UR_RESULT_ERROR_INVALID_SIZE /// - `buff_size < out_size` UR_APIEXPORT ur_result_t UR_APICALL -urPrintBindlessImagesGetImageMemoryPointerSupportExpParams( +urPrintBindlessImagesGetImageMemoryHandleTypeSupportExpParams( const struct - ur_bindless_images_get_image_memory_pointer_support_exp_params_t *params, - char *buffer, const size_t buff_size, size_t *out_size); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_bindless_images_get_image_memory_opaque_support_exp_params_t -/// struct -/// @returns -/// - ::UR_RESULT_SUCCESS -/// - ::UR_RESULT_ERROR_INVALID_SIZE -/// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL -urPrintBindlessImagesGetImageMemoryOpaqueSupportExpParams( - const struct ur_bindless_images_get_image_memory_opaque_support_exp_params_t + ur_bindless_images_get_image_memory_handle_type_support_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); diff --git a/unified-runtime/include/ur_print.hpp b/unified-runtime/include/ur_print.hpp index e4b171e304de8..24ddf970dcd8a 100644 --- a/unified-runtime/include/ur_print.hpp +++ b/unified-runtime/include/ur_print.hpp @@ -528,6 +528,8 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_exp_external_mem_type_t value); inline std::ostream &operator<<(std::ostream &os, enum ur_exp_external_semaphore_type_t value); +inline std::ostream &operator<<(std::ostream &os, + enum ur_exp_image_mem_type_t value); inline std::ostream & operator<<(std::ostream &os, [[maybe_unused]] const struct ur_exp_file_descriptor_t params); @@ -1237,18 +1239,16 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_function_t value) { case UR_FUNCTION_USM_POOL_SET_INFO_EXP: os << "UR_FUNCTION_USM_POOL_SET_INFO_EXP"; break; - case UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_POINTER_SUPPORT_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_POINTER_SUPPORT_EXP"; - break; - case UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_OPAQUE_SUPPORT_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_OPAQUE_SUPPORT_EXP"; - break; case UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_UNSAMPLED_HANDLE_SUPPORT_EXP: os << "UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_UNSAMPLED_HANDLE_SUPPORT_EXP"; break; case UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_SAMPLED_HANDLE_SUPPORT_EXP: os << "UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_SAMPLED_HANDLE_SUPPORT_EXP"; break; + case UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_HANDLE_TYPE_SUPPORT_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_HANDLE_TYPE_SUPPORT_" + "EXP"; + break; default: os << "unknown enumerator"; break; @@ -11163,6 +11163,25 @@ inline std::ostream &operator<<(std::ostream &os, return os; } /////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_exp_image_mem_type_t type +/// @returns +/// std::ostream & +inline std::ostream &operator<<(std::ostream &os, + enum ur_exp_image_mem_type_t value) { + switch (value) { + case UR_EXP_IMAGE_MEM_TYPE_USM_POINTER: + os << "UR_EXP_IMAGE_MEM_TYPE_USM_POINTER"; + break; + case UR_EXP_IMAGE_MEM_TYPE_OPAQUE_HANDLE: + os << "UR_EXP_IMAGE_MEM_TYPE_OPAQUE_HANDLE"; + break; + default: + os << "unknown enumerator"; + break; + } + return os; +} +/////////////////////////////////////////////////////////////////////////////// /// @brief Print operator for the ur_exp_file_descriptor_t type /// @returns /// std::ostream & @@ -18204,12 +18223,13 @@ inline std::ostream &operator<<( /////////////////////////////////////////////////////////////////////////////// /// @brief Print operator for the -/// ur_bindless_images_get_image_memory_pointer_support_exp_params_t type +/// ur_bindless_images_get_image_memory_handle_type_support_exp_params_t type /// @returns /// std::ostream & -inline std::ostream &operator<<( - std::ostream &os, [[maybe_unused]] const struct - ur_bindless_images_get_image_memory_pointer_support_exp_params_t *params) { +inline std::ostream & +operator<<(std::ostream &os, [[maybe_unused]] const struct + ur_bindless_images_get_image_memory_handle_type_support_exp_params_t + *params) { os << ".hContext = "; @@ -18231,40 +18251,9 @@ inline std::ostream &operator<<( ur::details::printPtr(os, *(params->ppImageFormat)); os << ", "; - os << ".pSupportedRet = "; - - ur::details::printPtr(os, *(params->ppSupportedRet)); - - return os; -} - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the -/// ur_bindless_images_get_image_memory_opaque_support_exp_params_t type -/// @returns -/// std::ostream & -inline std::ostream &operator<<( - std::ostream &os, [[maybe_unused]] const struct - ur_bindless_images_get_image_memory_opaque_support_exp_params_t *params) { - - os << ".hContext = "; - - ur::details::printPtr(os, *(params->phContext)); - - os << ", "; - os << ".hDevice = "; + os << ".imageMemHandleType = "; - ur::details::printPtr(os, *(params->phDevice)); - - os << ", "; - os << ".pImageDesc = "; - - ur::details::printPtr(os, *(params->ppImageDesc)); - - os << ", "; - os << ".pImageFormat = "; - - ur::details::printPtr(os, *(params->ppImageFormat)); + os << *(params->pimageMemHandleType); os << ", "; os << ".pSupportedRet = "; @@ -18304,9 +18293,9 @@ operator<<(std::ostream &os, [[maybe_unused]] const struct ur::details::printPtr(os, *(params->ppImageFormat)); os << ", "; - os << ".isOpaqueAllocation = "; + os << ".imageMemHandleType = "; - os << *(params->pisOpaqueAllocation); + os << *(params->pimageMemHandleType); os << ", "; os << ".pSupportedRet = "; @@ -18345,9 +18334,9 @@ inline std::ostream &operator<<( ur::details::printPtr(os, *(params->ppImageFormat)); os << ", "; - os << ".isOpaqueAllocation = "; + os << ".imageMemHandleType = "; - os << *(params->pisOpaqueAllocation); + os << *(params->pimageMemHandleType); os << ", "; os << ".pSupportedRet = "; @@ -21312,15 +21301,10 @@ inline ur_result_t UR_APICALL printFunctionParams(std::ostream &os, case UR_FUNCTION_BINDLESS_IMAGES_IMAGE_GET_INFO_EXP: { os << (const struct ur_bindless_images_image_get_info_exp_params_t *)params; } break; - case UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_POINTER_SUPPORT_EXP: { + case UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_HANDLE_TYPE_SUPPORT_EXP: { os << (const struct - ur_bindless_images_get_image_memory_pointer_support_exp_params_t *) - params; - } break; - case UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_OPAQUE_SUPPORT_EXP: { - os << (const struct - ur_bindless_images_get_image_memory_opaque_support_exp_params_t *) - params; + ur_bindless_images_get_image_memory_handle_type_support_exp_params_t + *)params; } break; case UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_UNSAMPLED_HANDLE_SUPPORT_EXP: { os << (const struct diff --git a/unified-runtime/scripts/core/EXP-BINDLESS-IMAGES.rst b/unified-runtime/scripts/core/EXP-BINDLESS-IMAGES.rst index ddf026b8ca628..88fddd083d06e 100644 --- a/unified-runtime/scripts/core/EXP-BINDLESS-IMAGES.rst +++ b/unified-runtime/scripts/core/EXP-BINDLESS-IMAGES.rst @@ -146,8 +146,7 @@ Enums * ${X}_FUNCTION_BINDLESS_IMAGES_RELEASE_EXTERNAL_SEMAPHORE_EXP * ${X}_FUNCTION_BINDLESS_IMAGES_WAIT_EXTERNAL_SEMAPHORE_EXP * ${X}_FUNCTION_BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP - * ${X}_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_POINTER_SUPPORT_EXP - * ${X}_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_OPAQUE_SUPPORT_EXP + * ${X}_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_HANDLE_TYPE_SUPPORT_EXP * ${X}_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_UNSAMPLED_HANDLE_SUPPORT_EXP * ${X}_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_SAMPLED_HANDLE_SUPPORT_EXP @@ -155,6 +154,10 @@ Enums * ${X}_MEM_TYPE_IMAGE_CUBEMAP_EXP * ${X}_MEM_TYPE_IMAGE_GATHER_EXP +* {x}_exp_image_mem_type_t + * {X}_EXP_IMAGE_MEM_TYPE_USM_POINTER + * {X}_EXP_IMAGE_MEM_TYPE_OPAQUE_HANDLE + Types ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * ${x}_exp_sampler_mip_properties_t @@ -186,8 +189,7 @@ Functions * ${x}BindlessImagesImageGetInfoExp * ${x}BindlessImagesMipmapGetLevelExp * ${x}BindlessImagesMipmapFreeExp - * ${x}BindlessImagesGetImageMemoryPointerSupportExp - * ${x}BindlessImagesGetImageMemoryOpaqueSupportExp + * ${x}BindlessImagesGetImageMemoryHandleTypeSupportExp * ${x}BindlessImagesGetImageUnsampledHandleSupportExp * ${x}BindlessImagesGetImageSampledHandleSupportExp @@ -277,9 +279,10 @@ Changelog | || to DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D_USM_SUPPORT_EXP | | || to be more consistent with other UR enums | +----------+--------------------------------------------------------------------+ -| 22.0 || Added the following APIs: | -| || - GetImageMemoryPointerSupportExp | -| || - GetImageMemoryOpaqueSupportExp | +| 22.0 || Added the following enum: | +| || - exp_image_mem_type_t | +| || Added the following APIs: | +| || - BindlessImagesGetImageMemoryHandleTypeSupportExp | | || - GetImageUnsampledHandleSupportExp | | || - GetImageSampledHandleSupportExp | +----------+-------------------------------------------------------------+ diff --git a/unified-runtime/scripts/core/exp-bindless-images.yml b/unified-runtime/scripts/core/exp-bindless-images.yml index 62e53e72414f0..51e9cacc87db0 100644 --- a/unified-runtime/scripts/core/exp-bindless-images.yml +++ b/unified-runtime/scripts/core/exp-bindless-images.yml @@ -229,6 +229,16 @@ etors: - name: TIMELINE_WIN32_NT desc: "Timeline semaphore Win32 NT handle" --- #-------------------------------------------------------------------------- +type: enum +desc: "Indicates the type of image backing memory handle." +class: $xBindlessImages +name: $x_exp_image_mem_type_t +etors: + - name: USM_POINTER + desc: "USM pointer to image memory" + - name: OPAQUE_HANDLE + desc: "Opaque handle to image memory" +--- #-------------------------------------------------------------------------- type: struct desc: "File descriptor" name: $x_exp_file_descriptor_t @@ -643,9 +653,9 @@ returns: - $X_RESULT_ERROR_OUT_OF_HOST_MEMORY --- #-------------------------------------------------------------------------- type: function -desc: "Query support for allocating pointer handle type image memory with specific image properties" +desc: "Query support for allocating a given image backing memory handle type with specific image properties" class: $xBindlessImages -name: GetImageMemoryPointerSupportExp +name: GetImageMemoryHandleTypeSupportExp ordinal: "0" params: - type: $x_context_handle_t @@ -660,35 +670,15 @@ params: - type: "const $x_image_format_t*" name: pImageFormat desc: "[in] pointer to image format specification" + - type: $x_exp_image_mem_type_t + name: imageMemHandleType + desc: "[in] type of image backing memory handle to query support for" - type: $x_bool_t* name: pSupportedRet - desc: "[out] returned indication of support for allocating USM style memory" -returns: - - $X_RESULT_ERROR_INVALID_DEVICE ---- #-------------------------------------------------------------------------- -type: function -desc: "Query support for allocating opaque handle type image memory with specific image properties" -class: $xBindlessImages -name: GetImageMemoryOpaqueSupportExp -ordinal: "0" -params: - - type: $x_context_handle_t - name: hContext - desc: "[in] handle of the context object" - - type: $x_device_handle_t - name: hDevice - desc: "[in] handle of the device object" - - type: "const $x_image_desc_t*" - name: pImageDesc - desc: "[in] pointer to image description" - - type: "const $x_image_format_t*" - name: pImageFormat - desc: "[in] pointer to image format specification" - - type: $x_bool_t* - name: pSupportedRet - desc: "[out] returned indication of support for allocating opaque handle memory" + desc: "[out] returned indication of support for allocating the given image backing memory handle type" returns: - $X_RESULT_ERROR_INVALID_DEVICE + - $X_RESULT_ERROR_INVALID_CONTEXT --- #-------------------------------------------------------------------------- type: function desc: "Query support for creating an unsampled image handle with specific image properties" @@ -708,9 +698,9 @@ params: - type: "const $x_image_format_t*" name: pImageFormat desc: "[in] pointer to image format specification" - - type: $x_bool_t - name: isOpaqueAllocation - desc: "[in] indicates whether the image memory would be backed by an opaque handle allocation" + - type: $x_exp_image_mem_type_t + name: imageMemHandleType + desc: "[in] type of image backing memory handle to query support for" - type: $x_bool_t* name: pSupportedRet desc: "[out] returned indication of support for creating unsampled image handles" @@ -719,7 +709,7 @@ returns: - $X_RESULT_ERROR_INVALID_CONTEXT --- #-------------------------------------------------------------------------- type: function -desc: "Query support for creating an unsampled image handle with specific image properties" +desc: "Query support for creating an sampled image handle with specific image properties" class: $xBindlessImages name: GetImageSampledHandleSupportExp ordinal: "0" @@ -736,9 +726,9 @@ params: - type: "const $x_image_format_t*" name: pImageFormat desc: "[in] pointer to image format specification" - - type: $x_bool_t - name: isOpaqueAllocation - desc: "[in] indicates whether the image memory would be backed by an opaque handle allocation" + - type: $x_exp_image_mem_type_t + name: imageMemHandleType + desc: "[in] type of image backing memory handle to query support for" - type: $x_bool_t* name: pSupportedRet desc: "[out] returned indication of support for creating sampled image handles" diff --git a/unified-runtime/scripts/core/registry.yml b/unified-runtime/scripts/core/registry.yml index 7d6529af7123c..4243da4a334be 100644 --- a/unified-runtime/scripts/core/registry.yml +++ b/unified-runtime/scripts/core/registry.yml @@ -643,18 +643,15 @@ etors: - name: USM_POOL_SET_INFO_EXP desc: Enumerator for $xUSMPoolSetInfoExp value: '265' -- name: BINDLESS_IMAGES_GET_IMAGE_MEMORY_POINTER_SUPPORT_EXP - desc: Enumerator for $xBindlessImagesGetImageMemoryPointerSupportExp - value: '266' -- name: BINDLESS_IMAGES_GET_IMAGE_MEMORY_OPAQUE_SUPPORT_EXP - desc: Enumerator for $xBindlessImagesGetImageMemoryOpaqueSupportExp - value: '267' - name: BINDLESS_IMAGES_GET_IMAGE_UNSAMPLED_HANDLE_SUPPORT_EXP desc: Enumerator for $xBindlessImagesGetImageUnsampledHandleSupportExp value: '268' - name: BINDLESS_IMAGES_GET_IMAGE_SAMPLED_HANDLE_SUPPORT_EXP desc: Enumerator for $xBindlessImagesGetImageSampledHandleSupportExp value: '269' +- name: BINDLESS_IMAGES_GET_IMAGE_MEMORY_HANDLE_TYPE_SUPPORT_EXP + desc: Enumerator for $xBindlessImagesGetImageMemoryHandleTypeSupportExp + value: '270' --- type: enum desc: Defines structure types diff --git a/unified-runtime/source/adapters/cuda/image.cpp b/unified-runtime/source/adapters/cuda/image.cpp index 5cd572abf7dc2..fa01371a09add 100644 --- a/unified-runtime/source/adapters/cuda/image.cpp +++ b/unified-runtime/source/adapters/cuda/image.cpp @@ -1006,12 +1006,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( } } -bool verifyCommonImagePropertiesSupport(const ur_device_handle_t hDevice, - const ur_image_desc_t *pImageDesc, - const ur_image_format_t *pImageFormat, - bool isOpaqueAllocation) { - - // Verify image dimensions are within device limits. +bool verifyStandardImageSupport(const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType) { + // Verify standard image dimensions are within device limits. size_t maxImageWidth, maxImageHeight, maxImageDepth; if (pImageDesc->depth != 0 && pImageDesc->type == UR_MEM_TYPE_IMAGE3D) { @@ -1028,94 +1026,112 @@ bool verifyCommonImagePropertiesSupport(const ur_device_handle_t hDevice, (pImageDesc->depth > maxImageDepth)) { return false; } - } else if (pImageDesc->height != 0 && + } else if (pImageDesc->height != 0 && pImageDesc->numMipLevel == 1 && pImageDesc->type == UR_MEM_TYPE_IMAGE2D) { - if (pImageDesc->numMipLevel == 1) { - if (!isOpaqueAllocation) { - // Verify for standard 2D images backed by linear memory. - UR_CHECK_ERROR( - urDeviceGetInfo(hDevice, UR_DEVICE_INFO_MAX_IMAGE_LINEAR_WIDTH_EXP, - sizeof(size_t), &maxImageWidth, nullptr)); - UR_CHECK_ERROR( - urDeviceGetInfo(hDevice, UR_DEVICE_INFO_MAX_IMAGE_LINEAR_HEIGHT_EXP, - sizeof(size_t), &maxImageHeight, nullptr)); - - size_t maxImageLinearPitch; - UR_CHECK_ERROR( - urDeviceGetInfo(hDevice, UR_DEVICE_INFO_MAX_IMAGE_LINEAR_PITCH_EXP, - sizeof(size_t), &maxImageLinearPitch, nullptr)); - if (pImageDesc->rowPitch > maxImageLinearPitch) { - return false; - } - } else { - // Verify for standard 2D images backed by opaque memory. - UR_CHECK_ERROR( - urDeviceGetInfo(hDevice, UR_DEVICE_INFO_IMAGE2D_MAX_WIDTH, - sizeof(size_t), &maxImageWidth, nullptr)); - UR_CHECK_ERROR( - urDeviceGetInfo(hDevice, UR_DEVICE_INFO_IMAGE2D_MAX_HEIGHT, - sizeof(size_t), &maxImageHeight, nullptr)); + if (imageMemHandleType == UR_EXP_IMAGE_MEM_TYPE_USM_POINTER) { + // Verify for standard 2D images backed by linear memory. + UR_CHECK_ERROR(urDeviceGetInfo(hDevice, + UR_DEVICE_INFO_MAX_IMAGE_LINEAR_WIDTH_EXP, + sizeof(size_t), &maxImageWidth, nullptr)); + UR_CHECK_ERROR(urDeviceGetInfo(hDevice, + UR_DEVICE_INFO_MAX_IMAGE_LINEAR_HEIGHT_EXP, + sizeof(size_t), &maxImageHeight, nullptr)); + + size_t maxImageLinearPitch; + UR_CHECK_ERROR( + urDeviceGetInfo(hDevice, UR_DEVICE_INFO_MAX_IMAGE_LINEAR_PITCH_EXP, + sizeof(size_t), &maxImageLinearPitch, nullptr)); + if (pImageDesc->rowPitch > maxImageLinearPitch) { + return false; } } else { - // Verify for 2D mipmap images. - int32_t maxMipmapWidth, maxMipmapHeight; - UR_CHECK_ERROR(cuDeviceGetAttribute( - &maxMipmapWidth, - CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_WIDTH, - hDevice->get())); - UR_CHECK_ERROR(cuDeviceGetAttribute( - &maxMipmapHeight, - CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_HEIGHT, - hDevice->get())); - maxImageWidth = static_cast(maxMipmapWidth); - maxImageHeight = static_cast(maxMipmapHeight); + // Verify for standard 2D images backed by opaque memory. + UR_CHECK_ERROR(urDeviceGetInfo(hDevice, UR_DEVICE_INFO_IMAGE2D_MAX_WIDTH, + sizeof(size_t), &maxImageWidth, nullptr)); + UR_CHECK_ERROR(urDeviceGetInfo(hDevice, UR_DEVICE_INFO_IMAGE2D_MAX_HEIGHT, + sizeof(size_t), &maxImageHeight, nullptr)); } if ((pImageDesc->width > maxImageWidth) || (pImageDesc->height > maxImageHeight)) { return false; } - } else if (pImageDesc->width != 0 && + } else if (pImageDesc->width != 0 && pImageDesc->numMipLevel == 1 && pImageDesc->type == UR_MEM_TYPE_IMAGE1D) { - if (pImageDesc->numMipLevel == 1) { - if (!isOpaqueAllocation) { - // Verify for standard 1D images backed by linear memory. - // - /// TODO: We have a query for `max_image_linear_width`, however, that - /// query is for 2D textures (at least as far as the CUDA/HIP - /// implementations go). We should split the `max_image_linear_width` - /// query into 1D and 2D variants to ensure that 1D image dimensions - /// can be properly verified and used to the fullest extent. - int32_t maxImageLinearWidth; - UR_CHECK_ERROR(cuDeviceGetAttribute( - &maxImageLinearWidth, - CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LINEAR_WIDTH, - hDevice->get())); - maxImageWidth = static_cast(maxImageLinearWidth); - } else { - // Verify for standard 1D images backed by opaque memory. - UR_CHECK_ERROR( - urDeviceGetInfo(hDevice, UR_DEVICE_INFO_IMAGE_MAX_BUFFER_SIZE, - sizeof(size_t), &maxImageWidth, nullptr)); - } - } else { - // Verify for 1D mipmap images. - int32_t maxMipmapWidth; + if (imageMemHandleType == UR_EXP_IMAGE_MEM_TYPE_USM_POINTER) { + // Verify for standard 1D images backed by linear memory. + // + /// TODO: We have a query for `max_image_linear_width`, however, that + /// query is for 2D textures (at least as far as the CUDA/HIP + /// implementations go). We should split the `max_image_linear_width` + /// query into 1D and 2D variants to ensure that 1D image dimensions + /// can be properly verified and used to the fullest extent. + int32_t maxImageLinearWidth; UR_CHECK_ERROR(cuDeviceGetAttribute( - &maxMipmapWidth, - CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_MIPMAPPED_WIDTH, - hDevice->get())); - maxImageWidth = static_cast(maxMipmapWidth); + &maxImageLinearWidth, + CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LINEAR_WIDTH, hDevice->get())); + maxImageWidth = static_cast(maxImageLinearWidth); + } else { + // Verify for standard 1D images backed by opaque memory. + UR_CHECK_ERROR(urDeviceGetInfo(hDevice, + UR_DEVICE_INFO_IMAGE_MAX_BUFFER_SIZE, + sizeof(size_t), &maxImageWidth, nullptr)); + } + if ((pImageDesc->width > maxImageWidth)) { + return false; + } + } + + return true; +} + +bool verifyMipmapImageSupport(const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType) { + // Verify mipmap image dimensions are within device limits. + size_t maxImageWidth, maxImageHeight; + + if (pImageDesc->height != 0 && pImageDesc->numMipLevel > 1 && + pImageDesc->type == UR_MEM_TYPE_IMAGE2D) { + // Verify for 2D mipmap images. + int32_t maxMipmapWidth, maxMipmapHeight; + UR_CHECK_ERROR(cuDeviceGetAttribute( + &maxMipmapWidth, CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_WIDTH, + hDevice->get())); + UR_CHECK_ERROR(cuDeviceGetAttribute( + &maxMipmapHeight, + CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_HEIGHT, + hDevice->get())); + maxImageWidth = static_cast(maxMipmapWidth); + maxImageHeight = static_cast(maxMipmapHeight); + + if ((pImageDesc->width > maxImageWidth) || + (pImageDesc->height > maxImageHeight)) { + return false; } + } else if (pImageDesc->width != 0 && pImageDesc->numMipLevel > 1 && + pImageDesc->type == UR_MEM_TYPE_IMAGE1D) { + // Verify for 1D mipmap images. + int32_t maxMipmapWidth; + UR_CHECK_ERROR(cuDeviceGetAttribute( + &maxMipmapWidth, CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_MIPMAPPED_WIDTH, + hDevice->get())); + maxImageWidth = static_cast(maxMipmapWidth); if ((pImageDesc->width > maxImageWidth)) { return false; } } + return true; +} + +bool verifyLayeredImageSupport(const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType) { // Verify layered image dimensions are within device limits. - size_t maxImageLayers; + size_t maxImageWidth, maxImageHeight, maxImageLayers; if (pImageDesc->type == UR_MEM_TYPE_IMAGE1D_ARRAY) { // Take the smaller of maximum surface and maximum texture width, as we do @@ -1194,11 +1210,19 @@ bool verifyCommonImagePropertiesSupport(const ur_device_handle_t hDevice, } } + return true; +} + +bool verifyCubemapImageSupport(const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType) { // Verify cubemap support and whether cubemap image dimensions are within // device limits. + size_t maxImageWidth, maxImageHeight, maxImageLayers; + if (pImageDesc->type == UR_MEM_TYPE_IMAGE_CUBEMAP_EXP) { - if (!isOpaqueAllocation) { + if (imageMemHandleType == UR_EXP_IMAGE_MEM_TYPE_USM_POINTER) { // Bindless Images do not provide support for cubemaps backed by // USM/linear memory. return false; @@ -1229,7 +1253,14 @@ bool verifyCommonImagePropertiesSupport(const ur_device_handle_t hDevice, } } + return true; +} + +bool verifyGatherImageSupport(const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType) { // Verify gather image dimensions are within device limits. + size_t maxImageWidth, maxImageHeight; if (pImageDesc->type == UR_MEM_TYPE_IMAGE_GATHER_EXP) { // Gather images only support 2D. @@ -1254,6 +1285,31 @@ bool verifyCommonImagePropertiesSupport(const ur_device_handle_t hDevice, } } + return true; +} + +bool verifyCommonImagePropertiesSupport( + const ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, + const ur_image_format_t *pImageFormat, + ur_exp_image_mem_type_t imageMemHandleType) { + + bool supported = true; + + supported &= + verifyStandardImageSupport(hDevice, pImageDesc, imageMemHandleType); + + supported &= + verifyMipmapImageSupport(hDevice, pImageDesc, imageMemHandleType); + + supported &= + verifyLayeredImageSupport(hDevice, pImageDesc, imageMemHandleType); + + supported &= + verifyCubemapImageSupport(hDevice, pImageDesc, imageMemHandleType); + + supported &= + verifyGatherImageSupport(hDevice, pImageDesc, imageMemHandleType); + // Verify 3-channel format support. // CUDA does not allow 3-channel formats. if (pImageFormat->channelOrder == UR_IMAGE_CHANNEL_ORDER_RGB || @@ -1261,32 +1317,14 @@ bool verifyCommonImagePropertiesSupport(const ur_device_handle_t hDevice, return false; } - // Once we've verified all of the above properties are valid, return true. - return true; -} - -UR_APIEXPORT ur_result_t UR_APICALL -urBindlessImagesGetImageMemoryPointerSupportExp( - ur_context_handle_t hContext, ur_device_handle_t hDevice, - const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - ur_bool_t *pSupportedRet) { - UR_ASSERT(std::find(hContext->getDevices().begin(), - hContext->getDevices().end(), - hDevice) != hContext->getDevices().end(), - UR_RESULT_ERROR_INVALID_CONTEXT); - - // Verify support for common image properties (dims, channel types, image - // types, etc.). - *pSupportedRet = verifyCommonImagePropertiesSupport( - hDevice, pImageDesc, pImageFormat, true /* isOpaqueAllocation */); - return UR_RESULT_SUCCESS; + return supported; } UR_APIEXPORT ur_result_t UR_APICALL -urBindlessImagesGetImageMemoryOpaqueSupportExp( +urBindlessImagesGetImageMemoryHandleTypeSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - ur_bool_t *pSupportedRet) { + ur_exp_image_mem_type_t imageMemHandleType, ur_bool_t *pSupportedRet) { UR_ASSERT(std::find(hContext->getDevices().begin(), hContext->getDevices().end(), hDevice) != hContext->getDevices().end(), @@ -1295,7 +1333,7 @@ urBindlessImagesGetImageMemoryOpaqueSupportExp( // Verify support for common image properties (dims, channel types, image // types, etc.). *pSupportedRet = verifyCommonImagePropertiesSupport( - hDevice, pImageDesc, pImageFormat, false /* isOpaqueAllocation */); + hDevice, pImageDesc, pImageFormat, imageMemHandleType); return UR_RESULT_SUCCESS; } @@ -1303,7 +1341,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesGetImageUnsampledHandleSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - ur_bool_t isOpaqueAllocation, ur_bool_t *pSupportedRet) { + ur_exp_image_mem_type_t imageMemHandleType, ur_bool_t *pSupportedRet) { UR_ASSERT(std::find(hContext->getDevices().begin(), hContext->getDevices().end(), hDevice) != hContext->getDevices().end(), @@ -1311,7 +1349,7 @@ urBindlessImagesGetImageUnsampledHandleSupportExp( // Currently the Bindless Images extension does not allow creation of // unsampled image handles from non-opaque (USM) memory. - if (!isOpaqueAllocation) { + if (imageMemHandleType == UR_EXP_IMAGE_MEM_TYPE_USM_POINTER) { *pSupportedRet = false; return UR_RESULT_SUCCESS; } @@ -1326,7 +1364,7 @@ urBindlessImagesGetImageUnsampledHandleSupportExp( // Verify support for common image properties (dims, channel types, image // types, etc.). *pSupportedRet = verifyCommonImagePropertiesSupport( - hDevice, pImageDesc, pImageFormat, isOpaqueAllocation); + hDevice, pImageDesc, pImageFormat, imageMemHandleType); return UR_RESULT_SUCCESS; } @@ -1334,7 +1372,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesGetImageSampledHandleSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - ur_bool_t isOpaqueAllocation, ur_bool_t *pSupportedRet) { + ur_exp_image_mem_type_t imageMemHandleType, ur_bool_t *pSupportedRet) { UR_ASSERT(std::find(hContext->getDevices().begin(), hContext->getDevices().end(), hDevice) != hContext->getDevices().end(), @@ -1343,7 +1381,7 @@ urBindlessImagesGetImageSampledHandleSupportExp( // Verify support for common image properties (dims, channel types, image // types, etc.). *pSupportedRet = verifyCommonImagePropertiesSupport( - hDevice, pImageDesc, pImageFormat, isOpaqueAllocation); + hDevice, pImageDesc, pImageFormat, imageMemHandleType); return UR_RESULT_SUCCESS; } diff --git a/unified-runtime/source/adapters/cuda/image.hpp b/unified-runtime/source/adapters/cuda/image.hpp index 4cea4b3d7e1e2..686441cb79ae7 100644 --- a/unified-runtime/source/adapters/cuda/image.hpp +++ b/unified-runtime/source/adapters/cuda/image.hpp @@ -34,7 +34,27 @@ ur_result_t urTextureCreate(ur_sampler_handle_t hSampler, const unsigned int normalized_dtype_flag, ur_exp_image_native_handle_t *phRetImage); -bool verifyCommonImagePropertiesSupport(const ur_device_handle_t hDevice, - const ur_image_desc_t *pImageDesc, - const ur_image_format_t *pImageFormat, - bool isOpaqueAllocation); +bool verifyStandardImageSupport(const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType); + +bool verifyMipmapImageSupport(const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType); + +bool verifyCubemapImageSupport(const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType); + +bool verifyLayeredImageSupport(const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType); + +bool verifyGatherImageSupport(const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType); + +bool verifyCommonImagePropertiesSupport( + const ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, + const ur_image_format_t *pImageFormat, + ur_exp_image_mem_type_t imageMemHandleType); diff --git a/unified-runtime/source/adapters/cuda/ur_interface_loader.cpp b/unified-runtime/source/adapters/cuda/ur_interface_loader.cpp index b7c676cfb81f4..dbbcbc035a5ae 100644 --- a/unified-runtime/source/adapters/cuda/ur_interface_loader.cpp +++ b/unified-runtime/source/adapters/cuda/ur_interface_loader.cpp @@ -352,10 +352,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetBindlessImagesExpProcAddrTable( urBindlessImagesWaitExternalSemaphoreExp; pDdiTable->pfnSignalExternalSemaphoreExp = urBindlessImagesSignalExternalSemaphoreExp; - pDdiTable->pfnGetImageMemoryPointerSupportExp = - urBindlessImagesGetImageMemoryPointerSupportExp; - pDdiTable->pfnGetImageMemoryOpaqueSupportExp = - urBindlessImagesGetImageMemoryOpaqueSupportExp; + pDdiTable->pfnGetImageMemoryHandleTypeSupportExp = + urBindlessImagesGetImageMemoryHandleTypeSupportExp; pDdiTable->pfnGetImageUnsampledHandleSupportExp = urBindlessImagesGetImageUnsampledHandleSupportExp; pDdiTable->pfnGetImageSampledHandleSupportExp = diff --git a/unified-runtime/source/adapters/hip/image.cpp b/unified-runtime/source/adapters/hip/image.cpp index 3da5e86acca40..13b31bb64963e 100644 --- a/unified-runtime/source/adapters/hip/image.cpp +++ b/unified-runtime/source/adapters/hip/image.cpp @@ -1011,36 +1011,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( #endif } -bool verifyCommonImagePropertiesSupport(const ur_device_handle_t hDevice, - const ur_image_desc_t *pImageDesc, - const ur_image_format_t *pImageFormat, - bool isOpaqueAllocation) { - - // Verify mipmap image support. - // Mimpaps are not currently supported for the AMD target. - if (pImageDesc->numMipLevel > 1) { - return false; - } - - // Verify gather image support. - // Gather images are not currently supported for the AMD target. - if (pImageDesc->type == UR_MEM_TYPE_IMAGE_GATHER_EXP) { - return false; - } - - // Verify cubemap image support. - // Cubemaps are not currently supported for the AMD target. - if (pImageDesc->type == UR_MEM_TYPE_IMAGE_CUBEMAP_EXP) { - return false; - } - - // Verify layered image support. - // Layered images are not currently supported for the AMD target. - if ((pImageDesc->type == UR_MEM_TYPE_IMAGE1D_ARRAY) || - pImageDesc->type == UR_MEM_TYPE_IMAGE2D_ARRAY) { - return false; - } - +bool verifyStandardImageSupport(const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType) { // Verify standard image dimensions are within device limits. size_t maxImageWidth, maxImageHeight, maxImageDepth; @@ -1061,7 +1034,7 @@ bool verifyCommonImagePropertiesSupport(const ur_device_handle_t hDevice, } else if (pImageDesc->height != 0 && pImageDesc->type == UR_MEM_TYPE_IMAGE2D) { - if (!isOpaqueAllocation) { + if (imageMemHandleType == UR_EXP_IMAGE_MEM_TYPE_USM_POINTER) { // Verify for standard 2D images backed by linear memory. UR_CHECK_ERROR(urDeviceGetInfo(hDevice, UR_DEVICE_INFO_MAX_IMAGE_LINEAR_WIDTH_EXP, @@ -1092,7 +1065,7 @@ bool verifyCommonImagePropertiesSupport(const ur_device_handle_t hDevice, } else if (pImageDesc->width != 0 && pImageDesc->type == UR_MEM_TYPE_IMAGE1D) { - if (!isOpaqueAllocation) { + if (imageMemHandleType == UR_EXP_IMAGE_MEM_TYPE_USM_POINTER) { // Verify for standard 1D images backed by linear memory. // /// TODO: We have a query for `max_image_linear_width`, however, that @@ -1116,39 +1089,97 @@ bool verifyCommonImagePropertiesSupport(const ur_device_handle_t hDevice, } } - // Verify 3-channel format support. - // HIP does not allow 3-channel formats. - if (pImageFormat->channelOrder == UR_IMAGE_CHANNEL_ORDER_RGB || - pImageFormat->channelOrder == UR_IMAGE_CHANNEL_ORDER_RGX) { + return true; +} + +bool verifyMipmapImageSupport([[maybe_unused]] const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType) { + // Verify mipmap image support. + // Mimpaps are not currently supported for the AMD target. + if (pImageDesc->numMipLevel > 1) { return false; } - // Once we've verified all of the above properties are valid, return true. return true; } -UR_APIEXPORT ur_result_t UR_APICALL -urBindlessImagesGetImageMemoryPointerSupportExp( - ur_context_handle_t hContext, ur_device_handle_t hDevice, - const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - ur_bool_t *pSupportedRet) { - UR_ASSERT(std::find(hContext->getDevices().begin(), - hContext->getDevices().end(), - hDevice) != hContext->getDevices().end(), - UR_RESULT_ERROR_INVALID_CONTEXT); +bool verifyCubemapImageSupport( + [[maybe_unused]] const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType) { + // Verify cubemap image support. + // Cubemaps are not currently supported for the AMD target. + if (pImageDesc->type == UR_MEM_TYPE_IMAGE_CUBEMAP_EXP) { + return false; + } - // Verify support for common image properties (dims, channel types, image - // types, etc.). - *pSupportedRet = verifyCommonImagePropertiesSupport( - hDevice, pImageDesc, pImageFormat, false /* isOpaqueAllocation */); - return UR_RESULT_SUCCESS; + return true; +} + +bool verifyLayeredImageSupport( + [[maybe_unused]] const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType) { + // Verify layered image support. + // Layered images are not currently supported for the AMD target. + if ((pImageDesc->type == UR_MEM_TYPE_IMAGE1D_ARRAY) || + pImageDesc->type == UR_MEM_TYPE_IMAGE2D_ARRAY) { + return false; + } + + return true; +} + +bool verifyGatherImageSupport([[maybe_unused]] const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType) { + // Verify gather image support. + // Gather images are not currently supported for the AMD target. + if (pImageDesc->type == UR_MEM_TYPE_IMAGE_GATHER_EXP) { + return false; + } + + return true; +} + +bool verifyCommonImagePropertiesSupport( + const ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, + const ur_image_format_t *pImageFormat, + ur_exp_image_mem_type_t imageMemHandleType) { + + bool supported = true; + + supported &= + verifyStandardImageSupport(hDevice, pImageDesc, imageMemHandleType); + + supported &= + verifyMipmapImageSupport(hDevice, pImageDesc, imageMemHandleType); + + supported &= + verifyLayeredImageSupport(hDevice, pImageDesc, imageMemHandleType); + + supported &= + verifyCubemapImageSupport(hDevice, pImageDesc, imageMemHandleType); + + supported &= + verifyGatherImageSupport(hDevice, pImageDesc, imageMemHandleType); + + // Verify 3-channel format support. + // HIP does not allow 3-channel formats. + if (pImageFormat->channelOrder == UR_IMAGE_CHANNEL_ORDER_RGB || + pImageFormat->channelOrder == UR_IMAGE_CHANNEL_ORDER_RGX) { + return false; + } + + return supported; } UR_APIEXPORT ur_result_t UR_APICALL -urBindlessImagesGetImageMemoryOpaqueSupportExp( +urBindlessImagesGetImageMemoryHandleTypeSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - ur_bool_t *pSupportedRet) { + ur_exp_image_mem_type_t imageMemHandleType, ur_bool_t *pSupportedRet) { UR_ASSERT(std::find(hContext->getDevices().begin(), hContext->getDevices().end(), hDevice) != hContext->getDevices().end(), @@ -1157,7 +1188,7 @@ urBindlessImagesGetImageMemoryOpaqueSupportExp( // Verify support for common image properties (dims, channel types, image // types, etc.). *pSupportedRet = verifyCommonImagePropertiesSupport( - hDevice, pImageDesc, pImageFormat, true /* isOpaqueAllocation */); + hDevice, pImageDesc, pImageFormat, imageMemHandleType); return UR_RESULT_SUCCESS; } @@ -1165,7 +1196,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesGetImageUnsampledHandleSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - ur_bool_t isOpaqueAllocation, ur_bool_t *pSupportedRet) { + ur_exp_image_mem_type_t imageMemHandleType, ur_bool_t *pSupportedRet) { UR_ASSERT(std::find(hContext->getDevices().begin(), hContext->getDevices().end(), hDevice) != hContext->getDevices().end(), @@ -1173,7 +1204,7 @@ urBindlessImagesGetImageUnsampledHandleSupportExp( // Currently Bindless Images do not allow creation of unsampled image handles // from non-opaque (USM) memory. - if (!isOpaqueAllocation) { + if (imageMemHandleType == UR_EXP_IMAGE_MEM_TYPE_USM_POINTER) { *pSupportedRet = false; return UR_RESULT_SUCCESS; } @@ -1188,7 +1219,7 @@ urBindlessImagesGetImageUnsampledHandleSupportExp( // Verify support for common image properties (dims, channel types, image // types, etc.). *pSupportedRet = verifyCommonImagePropertiesSupport( - hDevice, pImageDesc, pImageFormat, isOpaqueAllocation); + hDevice, pImageDesc, pImageFormat, imageMemHandleType); return UR_RESULT_SUCCESS; } @@ -1196,7 +1227,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesGetImageSampledHandleSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - ur_bool_t isOpaqueAllocation, ur_bool_t *pSupportedRet) { + ur_exp_image_mem_type_t imageMemHandleType, ur_bool_t *pSupportedRet) { UR_ASSERT(std::find(hContext->getDevices().begin(), hContext->getDevices().end(), hDevice) != hContext->getDevices().end(), @@ -1205,7 +1236,7 @@ urBindlessImagesGetImageSampledHandleSupportExp( // Verify support for common image properties (dims, channel types, image // types, etc.). *pSupportedRet = verifyCommonImagePropertiesSupport( - hDevice, pImageDesc, pImageFormat, isOpaqueAllocation); + hDevice, pImageDesc, pImageFormat, imageMemHandleType); return UR_RESULT_SUCCESS; } diff --git a/unified-runtime/source/adapters/hip/image.hpp b/unified-runtime/source/adapters/hip/image.hpp index e706464c7abd5..a4a69e3cbbc76 100644 --- a/unified-runtime/source/adapters/hip/image.hpp +++ b/unified-runtime/source/adapters/hip/image.hpp @@ -33,7 +33,27 @@ ur_result_t urTextureCreate(ur_sampler_handle_t hSampler, const unsigned int normalized_dtype_flag, ur_exp_image_native_handle_t *phRetImage); -bool verifyCommonImagePropertiesSupport(const ur_device_handle_t hDevice, - const ur_image_desc_t *pImageDesc, - const ur_image_format_t *pImageFormat, - bool isOpaqueAllocation); +bool verifyStandardImageSupport(const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType); + +bool verifyMipmapImageSupport(const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType); + +bool verifyCubemapImageSupport(const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType); + +bool verifyLayeredImageSupport(const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType); + +bool verifyGatherImageSupport(const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType); + +bool verifyCommonImagePropertiesSupport( + const ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, + const ur_image_format_t *pImageFormat, + ur_exp_image_mem_type_t imageMemHandleType); diff --git a/unified-runtime/source/adapters/hip/ur_interface_loader.cpp b/unified-runtime/source/adapters/hip/ur_interface_loader.cpp index 63bf2af6b939e..a573db9eca370 100644 --- a/unified-runtime/source/adapters/hip/ur_interface_loader.cpp +++ b/unified-runtime/source/adapters/hip/ur_interface_loader.cpp @@ -349,10 +349,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetBindlessImagesExpProcAddrTable( urBindlessImagesWaitExternalSemaphoreExp; pDdiTable->pfnSignalExternalSemaphoreExp = urBindlessImagesSignalExternalSemaphoreExp; - pDdiTable->pfnGetImageMemoryPointerSupportExp = - urBindlessImagesGetImageMemoryPointerSupportExp; - pDdiTable->pfnGetImageMemoryOpaqueSupportExp = - urBindlessImagesGetImageMemoryOpaqueSupportExp; + pDdiTable->pfnGetImageMemoryHandleTypeSupportExp = + urBindlessImagesGetImageMemoryHandleTypeSupportExp; pDdiTable->pfnGetImageUnsampledHandleSupportExp = urBindlessImagesGetImageUnsampledHandleSupportExp; pDdiTable->pfnGetImageSampledHandleSupportExp = diff --git a/unified-runtime/source/adapters/level_zero/helpers/image_helpers.cpp b/unified-runtime/source/adapters/level_zero/helpers/image_helpers.cpp index 122499d99679d..f7430e38ccb63 100644 --- a/unified-runtime/source/adapters/level_zero/helpers/image_helpers.cpp +++ b/unified-runtime/source/adapters/level_zero/helpers/image_helpers.cpp @@ -522,89 +522,138 @@ getImageFormatTypeAndSize(const ur_image_format_t *ImageFormat) { return {ZeImageFormatType, ZeImageFormatTypeSize}; } -bool verifyCommonImagePropertiesSupport(const ur_device_handle_t ZeDevice, - const ur_image_desc_t *ZeImageDesc, - const ur_image_format_t *ZeImageFormat, - bool isOpaqueAllocation) { - - // Verify image dimensions are within device limits. - if (ZeImageDesc->depth != 0 && ZeImageDesc->type == UR_MEM_TYPE_IMAGE3D) { - if ((ZeDevice->ZeDeviceImageProperties->maxImageDims3D == 0) || - (ZeImageDesc->width > - ZeDevice->ZeDeviceImageProperties->maxImageDims3D) || - (ZeImageDesc->height > - ZeDevice->ZeDeviceImageProperties->maxImageDims3D) || - (ZeImageDesc->depth > - ZeDevice->ZeDeviceImageProperties->maxImageDims3D)) { +bool verifyStandardImageSupport(const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType) { + + // Verify standard image dimensions are within device limits. + if (pImageDesc->depth != 0 && pImageDesc->type == UR_MEM_TYPE_IMAGE3D) { + if ((hDevice->ZeDeviceImageProperties->maxImageDims3D == 0) || + (pImageDesc->width > + hDevice->ZeDeviceImageProperties->maxImageDims3D) || + (pImageDesc->height > + hDevice->ZeDeviceImageProperties->maxImageDims3D) || + (pImageDesc->depth > + hDevice->ZeDeviceImageProperties->maxImageDims3D)) { return false; } - } else if (ZeImageDesc->height != 0 && - ZeImageDesc->type == UR_MEM_TYPE_IMAGE2D) { - if (((ZeDevice->ZeDeviceImageProperties->maxImageDims2D == 0) || - (ZeImageDesc->width > - ZeDevice->ZeDeviceImageProperties->maxImageDims2D) || - (ZeImageDesc->height > - ZeDevice->ZeDeviceImageProperties->maxImageDims2D))) { + } else if (pImageDesc->height != 0 && + pImageDesc->type == UR_MEM_TYPE_IMAGE2D) { + if (((hDevice->ZeDeviceImageProperties->maxImageDims2D == 0) || + (pImageDesc->width > + hDevice->ZeDeviceImageProperties->maxImageDims2D) || + (pImageDesc->height > + hDevice->ZeDeviceImageProperties->maxImageDims2D))) { return false; } - } else if (ZeImageDesc->width != 0 && - ZeImageDesc->type == UR_MEM_TYPE_IMAGE1D) { - if ((ZeDevice->ZeDeviceImageProperties->maxImageDims1D == 0) || - (ZeImageDesc->width > - ZeDevice->ZeDeviceImageProperties->maxImageDims1D)) { + } else if (pImageDesc->width != 0 && + pImageDesc->type == UR_MEM_TYPE_IMAGE1D) { + if ((hDevice->ZeDeviceImageProperties->maxImageDims1D == 0) || + (pImageDesc->width > + hDevice->ZeDeviceImageProperties->maxImageDims1D)) { return false; } } - // Verify 3-channel format support. - // LevelZero allows 3-channel formats for `uchar` and `ushort`. - if (Is3ChannelOrder(ZeImageFormat->channelOrder)) { - switch (ZeImageFormat->channelType) { - default: - return false; - case UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT8: - case UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT16: - break; - } - } - - // Verify unnormalized channel type support. - // LevelZero currently doesn't support unnormalized channel types. - switch (ZeImageFormat->channelType) { - default: - break; - case UR_IMAGE_CHANNEL_TYPE_UNORM_INT8: - case UR_IMAGE_CHANNEL_TYPE_UNORM_INT16: - return false; - } + return true; +} +bool verifyMipmapImageSupport([[maybe_unused]] const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType) { // Verify support for mipmap images. // LevelZero currently does not support mipmap images. - if (ZeImageDesc->numMipLevel > 1) { + if (pImageDesc->numMipLevel > 1) { return false; } + return true; +} + +bool verifyCubemapImageSupport( + [[maybe_unused]] const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType) { // Verify support for cubemap images. // LevelZero current does not support cubemap images. - if (ZeImageDesc->type == UR_MEM_TYPE_IMAGE_CUBEMAP_EXP) { + if (pImageDesc->type == UR_MEM_TYPE_IMAGE_CUBEMAP_EXP) { return false; } - // Verify support for gather images. - // LevelZero current does not support gather images. - if (ZeImageDesc->type == UR_MEM_TYPE_IMAGE_GATHER_EXP) { - return false; - } + return true; +} +bool verifyLayeredImageSupport( + [[maybe_unused]] const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType) { // Verify support for layered images. // Bindless Images do not provide support for layered images/image arrays // backed by USM pointers. - if (((ZeImageDesc->type == UR_MEM_TYPE_IMAGE1D_ARRAY) || - (ZeImageDesc->type == UR_MEM_TYPE_IMAGE2D_ARRAY)) && - !isOpaqueAllocation) { + if (((pImageDesc->type == UR_MEM_TYPE_IMAGE1D_ARRAY) || + (pImageDesc->type == UR_MEM_TYPE_IMAGE2D_ARRAY)) && + imageMemHandleType == UR_EXP_IMAGE_MEM_TYPE_USM_POINTER) { return false; } - // All properties have been checked. Return true. return true; } + +bool verifyGatherImageSupport([[maybe_unused]] const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType) { + // Verify support for gather images. + // LevelZero current does not support gather images. + if (pImageDesc->type == UR_MEM_TYPE_IMAGE_GATHER_EXP) { + return false; + } + + return true; +} + +bool verifyCommonImagePropertiesSupport( + const ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, + const ur_image_format_t *pImageFormat, + ur_exp_image_mem_type_t imageMemHandleType) { + + bool supported = true; + + supported &= + verifyStandardImageSupport(hDevice, pImageDesc, imageMemHandleType); + + supported &= + verifyMipmapImageSupport(hDevice, pImageDesc, imageMemHandleType); + + supported &= + verifyLayeredImageSupport(hDevice, pImageDesc, imageMemHandleType); + + supported &= + verifyCubemapImageSupport(hDevice, pImageDesc, imageMemHandleType); + + supported &= + verifyGatherImageSupport(hDevice, pImageDesc, imageMemHandleType); + + // Verify 3-channel format support. + // LevelZero allows 3-channel formats for `uchar` and `ushort`. + if (Is3ChannelOrder(pImageFormat->channelOrder)) { + switch (pImageFormat->channelType) { + default: + return false; + case UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT8: + case UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT16: + break; + } + } + + // Verify unnormalized channel type support. + // LevelZero currently doesn't support unnormalized channel types. + switch (pImageFormat->channelType) { + default: + break; + case UR_IMAGE_CHANNEL_TYPE_UNORM_INT8: + case UR_IMAGE_CHANNEL_TYPE_UNORM_INT16: + return false; + } + + return supported; +} diff --git a/unified-runtime/source/adapters/level_zero/helpers/image_helpers.hpp b/unified-runtime/source/adapters/level_zero/helpers/image_helpers.hpp index cebebcc88e966..ea38102fbe55d 100644 --- a/unified-runtime/source/adapters/level_zero/helpers/image_helpers.hpp +++ b/unified-runtime/source/adapters/level_zero/helpers/image_helpers.hpp @@ -37,7 +37,27 @@ ur_result_t getImageRegionHelper(ze_image_desc_t ZeImageDesc, std::pair getImageFormatTypeAndSize(const ur_image_format_t *ImageFormat); -bool verifyCommonImagePropertiesSupport(const ur_device_handle_t ZeDevice, - const ur_image_desc_t *ZeImageDesc, - const ur_image_format_t *ZeImageFormat, - bool isOpaqueAllocation); +bool verifyStandardImageSupport(const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType); + +bool verifyMipmapImageSupport(const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType); + +bool verifyCubemapImageSupport(const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType); + +bool verifyLayeredImageSupport(const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType); + +bool verifyGatherImageSupport(const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + ur_exp_image_mem_type_t imageMemHandleType); + +bool verifyCommonImagePropertiesSupport( + const ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, + const ur_image_format_t *pImageFormat, + ur_exp_image_mem_type_t imageMemHandleType); diff --git a/unified-runtime/source/adapters/level_zero/image.cpp b/unified-runtime/source/adapters/level_zero/image.cpp index 5cf2e94026a99..b28c5b3412200 100644 --- a/unified-runtime/source/adapters/level_zero/image.cpp +++ b/unified-runtime/source/adapters/level_zero/image.cpp @@ -611,10 +611,10 @@ ur_result_t urBindlessImagesImageGetInfoExp( } } -ur_result_t urBindlessImagesGetImageMemoryPointerSupportExp( +ur_result_t urBindlessImagesGetImageMemoryHandleTypeSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - ur_bool_t *pSupportedRet) { + ur_exp_image_mem_type_t imageMemHandleType, ur_bool_t *pSupportedRet) { UR_ASSERT(std::find(hContext->getDevices().begin(), hContext->getDevices().end(), hDevice) != hContext->getDevices().end(), @@ -623,30 +623,14 @@ ur_result_t urBindlessImagesGetImageMemoryPointerSupportExp( // Verify support for common image properties (dims, channel types, image // types, etc.). *pSupportedRet = verifyCommonImagePropertiesSupport( - hDevice, pImageDesc, pImageFormat, false /* isOpaqueAllocation */); - return UR_RESULT_SUCCESS; -} - -ur_result_t urBindlessImagesGetImageMemoryOpaqueSupportExp( - ur_context_handle_t hContext, ur_device_handle_t hDevice, - const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - ur_bool_t *pSupportedRet) { - UR_ASSERT(std::find(hContext->getDevices().begin(), - hContext->getDevices().end(), - hDevice) != hContext->getDevices().end(), - UR_RESULT_ERROR_INVALID_CONTEXT); - - // Verify support for common image properties (dims, channel types, image - // types, etc.). - *pSupportedRet = verifyCommonImagePropertiesSupport( - hDevice, pImageDesc, pImageFormat, true /* isOpaqueAllocation */); + hDevice, pImageDesc, pImageFormat, imageMemHandleType); return UR_RESULT_SUCCESS; } ur_result_t urBindlessImagesGetImageUnsampledHandleSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - ur_bool_t isOpaqueAllocation, ur_bool_t *pSupportedRet) { + ur_exp_image_mem_type_t imageMemHandleType, ur_bool_t *pSupportedRet) { UR_ASSERT(std::find(hContext->getDevices().begin(), hContext->getDevices().end(), hDevice) != hContext->getDevices().end(), @@ -654,7 +638,7 @@ ur_result_t urBindlessImagesGetImageUnsampledHandleSupportExp( // Currently the Bindless Images extension does not allow creation of // unsampled image handles from non-opaque (USM) memory. - if (!isOpaqueAllocation) { + if (imageMemHandleType == UR_EXP_IMAGE_MEM_TYPE_USM_POINTER) { *pSupportedRet = false; return UR_RESULT_SUCCESS; } @@ -669,7 +653,7 @@ ur_result_t urBindlessImagesGetImageUnsampledHandleSupportExp( // Verify support for common image properties (dims, channel types, image // types, etc.). *pSupportedRet = verifyCommonImagePropertiesSupport( - hDevice, pImageDesc, pImageFormat, isOpaqueAllocation); + hDevice, pImageDesc, pImageFormat, imageMemHandleType); return UR_RESULT_SUCCESS; } @@ -677,7 +661,7 @@ ur_result_t urBindlessImagesGetImageUnsampledHandleSupportExp( ur_result_t urBindlessImagesGetImageSampledHandleSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - ur_bool_t isOpaqueAllocation, ur_bool_t *pSupportedRet) { + ur_exp_image_mem_type_t imageMemHandleType, ur_bool_t *pSupportedRet) { UR_ASSERT(std::find(hContext->getDevices().begin(), hContext->getDevices().end(), hDevice) != hContext->getDevices().end(), @@ -686,7 +670,7 @@ ur_result_t urBindlessImagesGetImageSampledHandleSupportExp( // Verify support for common image properties (dims, channel types, image // types, etc.). *pSupportedRet = verifyCommonImagePropertiesSupport( - hDevice, pImageDesc, pImageFormat, isOpaqueAllocation); + hDevice, pImageDesc, pImageFormat, imageMemHandleType); return UR_RESULT_SUCCESS; } diff --git a/unified-runtime/source/adapters/level_zero/ur_interface_loader.cpp b/unified-runtime/source/adapters/level_zero/ur_interface_loader.cpp index b37b7a2f3d1a4..fddc2cadede66 100644 --- a/unified-runtime/source/adapters/level_zero/ur_interface_loader.cpp +++ b/unified-runtime/source/adapters/level_zero/ur_interface_loader.cpp @@ -69,10 +69,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urGetBindlessImagesExpProcAddrTable( pDdiTable->pfnImageCopyExp = ur::level_zero::urBindlessImagesImageCopyExp; pDdiTable->pfnImageGetInfoExp = ur::level_zero::urBindlessImagesImageGetInfoExp; - pDdiTable->pfnGetImageMemoryPointerSupportExp = - ur::level_zero::urBindlessImagesGetImageMemoryPointerSupportExp; - pDdiTable->pfnGetImageMemoryOpaqueSupportExp = - ur::level_zero::urBindlessImagesGetImageMemoryOpaqueSupportExp; + pDdiTable->pfnGetImageMemoryHandleTypeSupportExp = + ur::level_zero::urBindlessImagesGetImageMemoryHandleTypeSupportExp; pDdiTable->pfnGetImageUnsampledHandleSupportExp = ur::level_zero::urBindlessImagesGetImageUnsampledHandleSupportExp; pDdiTable->pfnGetImageSampledHandleSupportExp = diff --git a/unified-runtime/source/adapters/level_zero/ur_interface_loader.hpp b/unified-runtime/source/adapters/level_zero/ur_interface_loader.hpp index 22356bb4b2250..ff7054e82cd21 100644 --- a/unified-runtime/source/adapters/level_zero/ur_interface_loader.hpp +++ b/unified-runtime/source/adapters/level_zero/ur_interface_loader.hpp @@ -553,22 +553,18 @@ ur_result_t urBindlessImagesImageCopyExp( ur_result_t urBindlessImagesImageGetInfoExp( ur_context_handle_t hContext, ur_exp_image_mem_native_handle_t hImageMem, ur_image_info_t propName, void *pPropValue, size_t *pPropSizeRet); -ur_result_t urBindlessImagesGetImageMemoryPointerSupportExp( +ur_result_t urBindlessImagesGetImageMemoryHandleTypeSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - ur_bool_t *pSupportedRet); -ur_result_t urBindlessImagesGetImageMemoryOpaqueSupportExp( - ur_context_handle_t hContext, ur_device_handle_t hDevice, - const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - ur_bool_t *pSupportedRet); + ur_exp_image_mem_type_t imageMemHandleType, ur_bool_t *pSupportedRet); ur_result_t urBindlessImagesGetImageUnsampledHandleSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - ur_bool_t isOpaqueAllocation, ur_bool_t *pSupportedRet); + ur_exp_image_mem_type_t imageMemHandleType, ur_bool_t *pSupportedRet); ur_result_t urBindlessImagesGetImageSampledHandleSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - ur_bool_t isOpaqueAllocation, ur_bool_t *pSupportedRet); + ur_exp_image_mem_type_t imageMemHandleType, ur_bool_t *pSupportedRet); ur_result_t urBindlessImagesMipmapGetLevelExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, ur_exp_image_mem_native_handle_t hImageMem, uint32_t mipmapLevel, diff --git a/unified-runtime/source/adapters/level_zero/v2/api.cpp b/unified-runtime/source/adapters/level_zero/v2/api.cpp index c93687d366a72..4d94fe5a83d5b 100644 --- a/unified-runtime/source/adapters/level_zero/v2/api.cpp +++ b/unified-runtime/source/adapters/level_zero/v2/api.cpp @@ -170,18 +170,10 @@ ur_result_t urBindlessImagesReleaseExternalSemaphoreExp( return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } -ur_result_t urBindlessImagesGetImageMemoryPointerSupportExp( +ur_result_t urBindlessImagesGetImageMemoryHandleTypeSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - ur_bool_t *pSupportedRet) { - logger::error("{} function not implemented!", __FUNCTION__); - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; -} - -ur_result_t urBindlessImagesGetImageMemoryOpaqueSupportExp( - ur_context_handle_t hContext, ur_device_handle_t hDevice, - const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - ur_bool_t *pSupportedRet) { + ur_exp_image_mem_type_t imageMemHandleType, ur_bool_t *pSupportedRet) { logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -189,7 +181,7 @@ ur_result_t urBindlessImagesGetImageMemoryOpaqueSupportExp( ur_result_t urBindlessImagesGetImageUnsampledHandleSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - ur_bool_t isOpaqueAllocation, ur_bool_t *pSupportedRet) { + ur_exp_image_mem_type_t imageMemHandleType, ur_bool_t *pSupportedRet) { logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -197,7 +189,7 @@ ur_result_t urBindlessImagesGetImageUnsampledHandleSupportExp( ur_result_t urBindlessImagesGetImageSampledHandleSupportExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, const ur_image_format_t *pImageFormat, - ur_bool_t isOpaqueAllocation, ur_bool_t *pSupportedRet) { + ur_exp_image_mem_type_t imageMemHandleType, ur_bool_t *pSupportedRet) { logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } diff --git a/unified-runtime/source/adapters/mock/ur_mockddi.cpp b/unified-runtime/source/adapters/mock/ur_mockddi.cpp index fb561ebf7b676..56b0654af0fe1 100644 --- a/unified-runtime/source/adapters/mock/ur_mockddi.cpp +++ b/unified-runtime/source/adapters/mock/ur_mockddi.cpp @@ -8461,9 +8461,9 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for -/// urBindlessImagesGetImageMemoryPointerSupportExp +/// urBindlessImagesGetImageMemoryHandleTypeSupportExp __urdlllocal ur_result_t UR_APICALL -urBindlessImagesGetImageMemoryPointerSupportExp( +urBindlessImagesGetImageMemoryHandleTypeSupportExp( /// [in] handle of the context object ur_context_handle_t hContext, /// [in] handle of the device object @@ -8472,16 +8472,20 @@ urBindlessImagesGetImageMemoryPointerSupportExp( const ur_image_desc_t *pImageDesc, /// [in] pointer to image format specification const ur_image_format_t *pImageFormat, - /// [out] returned indication of support for allocating USM style memory + /// [in] type of image backing memory handle to query support for + ur_exp_image_mem_type_t imageMemHandleType, + /// [out] returned indication of support for allocating the given image + /// backing memory handle type ur_bool_t *pSupportedRet) try { ur_result_t result = UR_RESULT_SUCCESS; - ur_bindless_images_get_image_memory_pointer_support_exp_params_t params = { - &hContext, &hDevice, &pImageDesc, &pImageFormat, &pSupportedRet}; + ur_bindless_images_get_image_memory_handle_type_support_exp_params_t params = + {&hContext, &hDevice, &pImageDesc, &pImageFormat, + &imageMemHandleType, &pSupportedRet}; auto beforeCallback = reinterpret_cast( mock::getCallbacks().get_before_callback( - "urBindlessImagesGetImageMemoryPointerSupportExp")); + "urBindlessImagesGetImageMemoryHandleTypeSupportExp")); if (beforeCallback) { result = beforeCallback(¶ms); if (result != UR_RESULT_SUCCESS) { @@ -8491,7 +8495,7 @@ urBindlessImagesGetImageMemoryPointerSupportExp( auto replaceCallback = reinterpret_cast( mock::getCallbacks().get_replace_callback( - "urBindlessImagesGetImageMemoryPointerSupportExp")); + "urBindlessImagesGetImageMemoryHandleTypeSupportExp")); if (replaceCallback) { result = replaceCallback(¶ms); } else { @@ -8505,63 +8509,7 @@ urBindlessImagesGetImageMemoryPointerSupportExp( auto afterCallback = reinterpret_cast( mock::getCallbacks().get_after_callback( - "urBindlessImagesGetImageMemoryPointerSupportExp")); - if (afterCallback) { - return afterCallback(¶ms); - } - - return result; -} catch (...) { - return exceptionToResult(std::current_exception()); -} - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Intercept function for urBindlessImagesGetImageMemoryOpaqueSupportExp -__urdlllocal ur_result_t UR_APICALL -urBindlessImagesGetImageMemoryOpaqueSupportExp( - /// [in] handle of the context object - ur_context_handle_t hContext, - /// [in] handle of the device object - ur_device_handle_t hDevice, - /// [in] pointer to image description - const ur_image_desc_t *pImageDesc, - /// [in] pointer to image format specification - const ur_image_format_t *pImageFormat, - /// [out] returned indication of support for allocating opaque handle - /// memory - ur_bool_t *pSupportedRet) try { - ur_result_t result = UR_RESULT_SUCCESS; - - ur_bindless_images_get_image_memory_opaque_support_exp_params_t params = { - &hContext, &hDevice, &pImageDesc, &pImageFormat, &pSupportedRet}; - - auto beforeCallback = reinterpret_cast( - mock::getCallbacks().get_before_callback( - "urBindlessImagesGetImageMemoryOpaqueSupportExp")); - if (beforeCallback) { - result = beforeCallback(¶ms); - if (result != UR_RESULT_SUCCESS) { - return result; - } - } - - auto replaceCallback = reinterpret_cast( - mock::getCallbacks().get_replace_callback( - "urBindlessImagesGetImageMemoryOpaqueSupportExp")); - if (replaceCallback) { - result = replaceCallback(¶ms); - } else { - - result = UR_RESULT_SUCCESS; - } - - if (result != UR_RESULT_SUCCESS) { - return result; - } - - auto afterCallback = reinterpret_cast( - mock::getCallbacks().get_after_callback( - "urBindlessImagesGetImageMemoryOpaqueSupportExp")); + "urBindlessImagesGetImageMemoryHandleTypeSupportExp")); if (afterCallback) { return afterCallback(¶ms); } @@ -8584,9 +8532,8 @@ urBindlessImagesGetImageUnsampledHandleSupportExp( const ur_image_desc_t *pImageDesc, /// [in] pointer to image format specification const ur_image_format_t *pImageFormat, - /// [in] indicates whether the image memory would be backed by an opaque - /// handle allocation - ur_bool_t isOpaqueAllocation, + /// [in] type of image backing memory handle to query support for + ur_exp_image_mem_type_t imageMemHandleType, /// [out] returned indication of support for creating unsampled image /// handles ur_bool_t *pSupportedRet) try { @@ -8594,7 +8541,7 @@ urBindlessImagesGetImageUnsampledHandleSupportExp( ur_bindless_images_get_image_unsampled_handle_support_exp_params_t params = { &hContext, &hDevice, &pImageDesc, &pImageFormat, - &isOpaqueAllocation, &pSupportedRet}; + &imageMemHandleType, &pSupportedRet}; auto beforeCallback = reinterpret_cast( mock::getCallbacks().get_before_callback( @@ -8645,9 +8592,8 @@ urBindlessImagesGetImageSampledHandleSupportExp( const ur_image_desc_t *pImageDesc, /// [in] pointer to image format specification const ur_image_format_t *pImageFormat, - /// [in] indicates whether the image memory would be backed by an opaque - /// handle allocation - ur_bool_t isOpaqueAllocation, + /// [in] type of image backing memory handle to query support for + ur_exp_image_mem_type_t imageMemHandleType, /// [out] returned indication of support for creating sampled image /// handles ur_bool_t *pSupportedRet) try { @@ -8655,7 +8601,7 @@ urBindlessImagesGetImageSampledHandleSupportExp( ur_bindless_images_get_image_sampled_handle_support_exp_params_t params = { &hContext, &hDevice, &pImageDesc, &pImageFormat, - &isOpaqueAllocation, &pSupportedRet}; + &imageMemHandleType, &pSupportedRet}; auto beforeCallback = reinterpret_cast( mock::getCallbacks().get_before_callback( @@ -11959,11 +11905,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetBindlessImagesExpProcAddrTable( pDdiTable->pfnImageGetInfoExp = driver::urBindlessImagesImageGetInfoExp; - pDdiTable->pfnGetImageMemoryPointerSupportExp = - driver::urBindlessImagesGetImageMemoryPointerSupportExp; - - pDdiTable->pfnGetImageMemoryOpaqueSupportExp = - driver::urBindlessImagesGetImageMemoryOpaqueSupportExp; + pDdiTable->pfnGetImageMemoryHandleTypeSupportExp = + driver::urBindlessImagesGetImageMemoryHandleTypeSupportExp; pDdiTable->pfnGetImageUnsampledHandleSupportExp = driver::urBindlessImagesGetImageUnsampledHandleSupportExp; diff --git a/unified-runtime/source/adapters/native_cpu/image.cpp b/unified-runtime/source/adapters/native_cpu/image.cpp index cc4a8b8b53e6d..8ad2354927afc 100644 --- a/unified-runtime/source/adapters/native_cpu/image.cpp +++ b/unified-runtime/source/adapters/native_cpu/image.cpp @@ -98,21 +98,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( } UR_APIEXPORT ur_result_t UR_APICALL -urBindlessImagesGetImageMemoryPointerSupportExp( - [[maybe_unused]] ur_context_handle_t hContext, - [[maybe_unused]] ur_device_handle_t hDevice, - [[maybe_unused]] const ur_image_desc_t *pImageDesc, - [[maybe_unused]] const ur_image_format_t *pImageFormat, - [[maybe_unused]] ur_bool_t *pSupportedRet) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; -} - -UR_APIEXPORT ur_result_t UR_APICALL -urBindlessImagesGetImageMemoryOpaqueSupportExp( +urBindlessImagesGetImageMemoryHandleTypeSupportExp( [[maybe_unused]] ur_context_handle_t hContext, [[maybe_unused]] ur_device_handle_t hDevice, [[maybe_unused]] const ur_image_desc_t *pImageDesc, [[maybe_unused]] const ur_image_format_t *pImageFormat, + [[maybe_unused]] ur_exp_image_mem_type_t imageMemHandleType, [[maybe_unused]] ur_bool_t *pSupportedRet) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -123,7 +114,7 @@ urBindlessImagesGetImageUnsampledHandleSupportExp( [[maybe_unused]] ur_device_handle_t hDevice, [[maybe_unused]] const ur_image_desc_t *pImageDesc, [[maybe_unused]] const ur_image_format_t *pImageFormat, - [[maybe_unused]] ur_bool_t isOpaqueAllocation, + [[maybe_unused]] ur_exp_image_mem_type_t imageMemHandleType, [[maybe_unused]] ur_bool_t *pSupportedRet) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -134,7 +125,7 @@ urBindlessImagesGetImageSampledHandleSupportExp( [[maybe_unused]] ur_device_handle_t hDevice, [[maybe_unused]] const ur_image_desc_t *pImageDesc, [[maybe_unused]] const ur_image_format_t *pImageFormat, - [[maybe_unused]] ur_bool_t isOpaqueAllocation, + [[maybe_unused]] ur_exp_image_mem_type_t imageMemHandleType, [[maybe_unused]] ur_bool_t *pSupportedRet) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } diff --git a/unified-runtime/source/adapters/native_cpu/ur_interface_loader.cpp b/unified-runtime/source/adapters/native_cpu/ur_interface_loader.cpp index c7eaf28d69a56..c18873be62d63 100644 --- a/unified-runtime/source/adapters/native_cpu/ur_interface_loader.cpp +++ b/unified-runtime/source/adapters/native_cpu/ur_interface_loader.cpp @@ -343,10 +343,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetBindlessImagesExpProcAddrTable( urBindlessImagesWaitExternalSemaphoreExp; pDdiTable->pfnSignalExternalSemaphoreExp = urBindlessImagesSignalExternalSemaphoreExp; - pDdiTable->pfnGetImageMemoryPointerSupportExp = - urBindlessImagesGetImageMemoryPointerSupportExp; - pDdiTable->pfnGetImageMemoryOpaqueSupportExp = - urBindlessImagesGetImageMemoryOpaqueSupportExp; + pDdiTable->pfnGetImageMemoryHandleTypeSupportExp = + urBindlessImagesGetImageMemoryHandleTypeSupportExp; pDdiTable->pfnGetImageUnsampledHandleSupportExp = urBindlessImagesGetImageUnsampledHandleSupportExp; pDdiTable->pfnGetImageSampledHandleSupportExp = diff --git a/unified-runtime/source/adapters/opencl/image.cpp b/unified-runtime/source/adapters/opencl/image.cpp index 0e8181f3acf2d..3be2e3dfc4054 100644 --- a/unified-runtime/source/adapters/opencl/image.cpp +++ b/unified-runtime/source/adapters/opencl/image.cpp @@ -98,21 +98,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( } UR_APIEXPORT ur_result_t UR_APICALL -urBindlessImagesGetImageMemoryPointerSupportExp( - [[maybe_unused]] ur_context_handle_t hContext, - [[maybe_unused]] ur_device_handle_t hDevice, - [[maybe_unused]] const ur_image_desc_t *pImageDesc, - [[maybe_unused]] const ur_image_format_t *pImageFormat, - [[maybe_unused]] ur_bool_t *pSupportedRet) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; -} - -UR_APIEXPORT ur_result_t UR_APICALL -urBindlessImagesGetImageMemoryOpaqueSupportExp( +urBindlessImagesGetImageMemoryHandleTypeSupportExp( [[maybe_unused]] ur_context_handle_t hContext, [[maybe_unused]] ur_device_handle_t hDevice, [[maybe_unused]] const ur_image_desc_t *pImageDesc, [[maybe_unused]] const ur_image_format_t *pImageFormat, + [[maybe_unused]] ur_exp_image_mem_type_t imageMemHandleType, [[maybe_unused]] ur_bool_t *pSupportedRet) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -123,7 +114,7 @@ urBindlessImagesGetImageUnsampledHandleSupportExp( [[maybe_unused]] ur_device_handle_t hDevice, [[maybe_unused]] const ur_image_desc_t *pImageDesc, [[maybe_unused]] const ur_image_format_t *pImageFormat, - [[maybe_unused]] ur_bool_t isOpaqueAllocation, + [[maybe_unused]] ur_exp_image_mem_type_t imageMemHandleType, [[maybe_unused]] ur_bool_t *pSupportedRet) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -134,7 +125,7 @@ urBindlessImagesGetImageSampledHandleSupportExp( [[maybe_unused]] ur_device_handle_t hDevice, [[maybe_unused]] const ur_image_desc_t *pImageDesc, [[maybe_unused]] const ur_image_format_t *pImageFormat, - [[maybe_unused]] ur_bool_t isOpaqueAllocation, + [[maybe_unused]] ur_exp_image_mem_type_t imageMemHandleType, [[maybe_unused]] ur_bool_t *pSupportedRet) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } diff --git a/unified-runtime/source/adapters/opencl/ur_interface_loader.cpp b/unified-runtime/source/adapters/opencl/ur_interface_loader.cpp index c6e7cac4951f8..2d3bc8b20d4d3 100644 --- a/unified-runtime/source/adapters/opencl/ur_interface_loader.cpp +++ b/unified-runtime/source/adapters/opencl/ur_interface_loader.cpp @@ -362,10 +362,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetBindlessImagesExpProcAddrTable( urBindlessImagesWaitExternalSemaphoreExp; pDdiTable->pfnSignalExternalSemaphoreExp = urBindlessImagesSignalExternalSemaphoreExp; - pDdiTable->pfnGetImageMemoryPointerSupportExp = - urBindlessImagesGetImageMemoryPointerSupportExp; - pDdiTable->pfnGetImageMemoryOpaqueSupportExp = - urBindlessImagesGetImageMemoryOpaqueSupportExp; + pDdiTable->pfnGetImageMemoryHandleTypeSupportExp = + urBindlessImagesGetImageMemoryHandleTypeSupportExp; pDdiTable->pfnGetImageUnsampledHandleSupportExp = urBindlessImagesGetImageUnsampledHandleSupportExp; pDdiTable->pfnGetImageSampledHandleSupportExp = diff --git a/unified-runtime/source/loader/layers/tracing/ur_trcddi.cpp b/unified-runtime/source/loader/layers/tracing/ur_trcddi.cpp index b6795e78e62d9..a57951c945fc5 100644 --- a/unified-runtime/source/loader/layers/tracing/ur_trcddi.cpp +++ b/unified-runtime/source/loader/layers/tracing/ur_trcddi.cpp @@ -7014,9 +7014,9 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for -/// urBindlessImagesGetImageMemoryPointerSupportExp +/// urBindlessImagesGetImageMemoryHandleTypeSupportExp __urdlllocal ur_result_t UR_APICALL -urBindlessImagesGetImageMemoryPointerSupportExp( +urBindlessImagesGetImageMemoryHandleTypeSupportExp( /// [in] handle of the context object ur_context_handle_t hContext, /// [in] handle of the device object @@ -7025,93 +7025,46 @@ urBindlessImagesGetImageMemoryPointerSupportExp( const ur_image_desc_t *pImageDesc, /// [in] pointer to image format specification const ur_image_format_t *pImageFormat, - /// [out] returned indication of support for allocating USM style memory + /// [in] type of image backing memory handle to query support for + ur_exp_image_mem_type_t imageMemHandleType, + /// [out] returned indication of support for allocating the given image + /// backing memory handle type ur_bool_t *pSupportedRet) { - auto pfnGetImageMemoryPointerSupportExp = + auto pfnGetImageMemoryHandleTypeSupportExp = getContext() - ->urDdiTable.BindlessImagesExp.pfnGetImageMemoryPointerSupportExp; + ->urDdiTable.BindlessImagesExp.pfnGetImageMemoryHandleTypeSupportExp; - if (nullptr == pfnGetImageMemoryPointerSupportExp) + if (nullptr == pfnGetImageMemoryHandleTypeSupportExp) return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; - ur_bindless_images_get_image_memory_pointer_support_exp_params_t params = { - &hContext, &hDevice, &pImageDesc, &pImageFormat, &pSupportedRet}; + ur_bindless_images_get_image_memory_handle_type_support_exp_params_t params = + {&hContext, &hDevice, &pImageDesc, &pImageFormat, + &imageMemHandleType, &pSupportedRet}; uint64_t instance = getContext()->notify_begin( - UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_POINTER_SUPPORT_EXP, - "urBindlessImagesGetImageMemoryPointerSupportExp", ¶ms); + UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_HANDLE_TYPE_SUPPORT_EXP, + "urBindlessImagesGetImageMemoryHandleTypeSupportExp", ¶ms); auto &logger = getContext()->logger; - logger.info(" ---> urBindlessImagesGetImageMemoryPointerSupportExp\n"); + logger.info(" ---> urBindlessImagesGetImageMemoryHandleTypeSupportExp\n"); - ur_result_t result = pfnGetImageMemoryPointerSupportExp( - hContext, hDevice, pImageDesc, pImageFormat, pSupportedRet); - - getContext()->notify_end( - UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_POINTER_SUPPORT_EXP, - "urBindlessImagesGetImageMemoryPointerSupportExp", ¶ms, &result, - instance); - - if (logger.getLevel() <= logger::Level::INFO) { - std::ostringstream args_str; - ur::extras::printFunctionParams( - args_str, - UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_POINTER_SUPPORT_EXP, - ¶ms); - logger.info( - " <--- urBindlessImagesGetImageMemoryPointerSupportExp({}) -> {};\n", - args_str.str(), result); - } - - return result; -} - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Intercept function for urBindlessImagesGetImageMemoryOpaqueSupportExp -__urdlllocal ur_result_t UR_APICALL -urBindlessImagesGetImageMemoryOpaqueSupportExp( - /// [in] handle of the context object - ur_context_handle_t hContext, - /// [in] handle of the device object - ur_device_handle_t hDevice, - /// [in] pointer to image description - const ur_image_desc_t *pImageDesc, - /// [in] pointer to image format specification - const ur_image_format_t *pImageFormat, - /// [out] returned indication of support for allocating opaque handle - /// memory - ur_bool_t *pSupportedRet) { - auto pfnGetImageMemoryOpaqueSupportExp = - getContext() - ->urDdiTable.BindlessImagesExp.pfnGetImageMemoryOpaqueSupportExp; - - if (nullptr == pfnGetImageMemoryOpaqueSupportExp) - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; - - ur_bindless_images_get_image_memory_opaque_support_exp_params_t params = { - &hContext, &hDevice, &pImageDesc, &pImageFormat, &pSupportedRet}; - uint64_t instance = getContext()->notify_begin( - UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_OPAQUE_SUPPORT_EXP, - "urBindlessImagesGetImageMemoryOpaqueSupportExp", ¶ms); - - auto &logger = getContext()->logger; - logger.info(" ---> urBindlessImagesGetImageMemoryOpaqueSupportExp\n"); - - ur_result_t result = pfnGetImageMemoryOpaqueSupportExp( - hContext, hDevice, pImageDesc, pImageFormat, pSupportedRet); + ur_result_t result = pfnGetImageMemoryHandleTypeSupportExp( + hContext, hDevice, pImageDesc, pImageFormat, imageMemHandleType, + pSupportedRet); getContext()->notify_end( - UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_OPAQUE_SUPPORT_EXP, - "urBindlessImagesGetImageMemoryOpaqueSupportExp", ¶ms, &result, + UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_HANDLE_TYPE_SUPPORT_EXP, + "urBindlessImagesGetImageMemoryHandleTypeSupportExp", ¶ms, &result, instance); if (logger.getLevel() <= logger::Level::INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, - UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_OPAQUE_SUPPORT_EXP, + UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_HANDLE_TYPE_SUPPORT_EXP, ¶ms); logger.info( - " <--- urBindlessImagesGetImageMemoryOpaqueSupportExp({}) -> {};\n", + " <--- urBindlessImagesGetImageMemoryHandleTypeSupportExp({}) -> " + "{};\n", args_str.str(), result); } @@ -7131,9 +7084,8 @@ urBindlessImagesGetImageUnsampledHandleSupportExp( const ur_image_desc_t *pImageDesc, /// [in] pointer to image format specification const ur_image_format_t *pImageFormat, - /// [in] indicates whether the image memory would be backed by an opaque - /// handle allocation - ur_bool_t isOpaqueAllocation, + /// [in] type of image backing memory handle to query support for + ur_exp_image_mem_type_t imageMemHandleType, /// [out] returned indication of support for creating unsampled image /// handles ur_bool_t *pSupportedRet) { @@ -7146,7 +7098,7 @@ urBindlessImagesGetImageUnsampledHandleSupportExp( ur_bindless_images_get_image_unsampled_handle_support_exp_params_t params = { &hContext, &hDevice, &pImageDesc, &pImageFormat, - &isOpaqueAllocation, &pSupportedRet}; + &imageMemHandleType, &pSupportedRet}; uint64_t instance = getContext()->notify_begin( UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_UNSAMPLED_HANDLE_SUPPORT_EXP, "urBindlessImagesGetImageUnsampledHandleSupportExp", ¶ms); @@ -7155,7 +7107,7 @@ urBindlessImagesGetImageUnsampledHandleSupportExp( logger.info(" ---> urBindlessImagesGetImageUnsampledHandleSupportExp\n"); ur_result_t result = pfnGetImageUnsampledHandleSupportExp( - hContext, hDevice, pImageDesc, pImageFormat, isOpaqueAllocation, + hContext, hDevice, pImageDesc, pImageFormat, imageMemHandleType, pSupportedRet); getContext()->notify_end( @@ -7190,9 +7142,8 @@ urBindlessImagesGetImageSampledHandleSupportExp( const ur_image_desc_t *pImageDesc, /// [in] pointer to image format specification const ur_image_format_t *pImageFormat, - /// [in] indicates whether the image memory would be backed by an opaque - /// handle allocation - ur_bool_t isOpaqueAllocation, + /// [in] type of image backing memory handle to query support for + ur_exp_image_mem_type_t imageMemHandleType, /// [out] returned indication of support for creating sampled image /// handles ur_bool_t *pSupportedRet) { @@ -7205,7 +7156,7 @@ urBindlessImagesGetImageSampledHandleSupportExp( ur_bindless_images_get_image_sampled_handle_support_exp_params_t params = { &hContext, &hDevice, &pImageDesc, &pImageFormat, - &isOpaqueAllocation, &pSupportedRet}; + &imageMemHandleType, &pSupportedRet}; uint64_t instance = getContext()->notify_begin( UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_SAMPLED_HANDLE_SUPPORT_EXP, "urBindlessImagesGetImageSampledHandleSupportExp", ¶ms); @@ -7214,7 +7165,7 @@ urBindlessImagesGetImageSampledHandleSupportExp( logger.info(" ---> urBindlessImagesGetImageSampledHandleSupportExp\n"); ur_result_t result = pfnGetImageSampledHandleSupportExp( - hContext, hDevice, pImageDesc, pImageFormat, isOpaqueAllocation, + hContext, hDevice, pImageDesc, pImageFormat, imageMemHandleType, pSupportedRet); getContext()->notify_end( @@ -10065,15 +10016,10 @@ __urdlllocal ur_result_t UR_APICALL urGetBindlessImagesExpProcAddrTable( pDdiTable->pfnImageGetInfoExp = ur_tracing_layer::urBindlessImagesImageGetInfoExp; - dditable.pfnGetImageMemoryPointerSupportExp = - pDdiTable->pfnGetImageMemoryPointerSupportExp; - pDdiTable->pfnGetImageMemoryPointerSupportExp = - ur_tracing_layer::urBindlessImagesGetImageMemoryPointerSupportExp; - - dditable.pfnGetImageMemoryOpaqueSupportExp = - pDdiTable->pfnGetImageMemoryOpaqueSupportExp; - pDdiTable->pfnGetImageMemoryOpaqueSupportExp = - ur_tracing_layer::urBindlessImagesGetImageMemoryOpaqueSupportExp; + dditable.pfnGetImageMemoryHandleTypeSupportExp = + pDdiTable->pfnGetImageMemoryHandleTypeSupportExp; + pDdiTable->pfnGetImageMemoryHandleTypeSupportExp = + ur_tracing_layer::urBindlessImagesGetImageMemoryHandleTypeSupportExp; dditable.pfnGetImageUnsampledHandleSupportExp = pDdiTable->pfnGetImageUnsampledHandleSupportExp; diff --git a/unified-runtime/source/loader/layers/validation/ur_valddi.cpp b/unified-runtime/source/loader/layers/validation/ur_valddi.cpp index acea1efef45d6..acb0f3d66fb87 100644 --- a/unified-runtime/source/loader/layers/validation/ur_valddi.cpp +++ b/unified-runtime/source/loader/layers/validation/ur_valddi.cpp @@ -7705,9 +7705,9 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for -/// urBindlessImagesGetImageMemoryPointerSupportExp +/// urBindlessImagesGetImageMemoryHandleTypeSupportExp __urdlllocal ur_result_t UR_APICALL -urBindlessImagesGetImageMemoryPointerSupportExp( +urBindlessImagesGetImageMemoryHandleTypeSupportExp( /// [in] handle of the context object ur_context_handle_t hContext, /// [in] handle of the device object @@ -7716,13 +7716,16 @@ urBindlessImagesGetImageMemoryPointerSupportExp( const ur_image_desc_t *pImageDesc, /// [in] pointer to image format specification const ur_image_format_t *pImageFormat, - /// [out] returned indication of support for allocating USM style memory + /// [in] type of image backing memory handle to query support for + ur_exp_image_mem_type_t imageMemHandleType, + /// [out] returned indication of support for allocating the given image + /// backing memory handle type ur_bool_t *pSupportedRet) { - auto pfnGetImageMemoryPointerSupportExp = + auto pfnGetImageMemoryHandleTypeSupportExp = getContext() - ->urDdiTable.BindlessImagesExp.pfnGetImageMemoryPointerSupportExp; + ->urDdiTable.BindlessImagesExp.pfnGetImageMemoryHandleTypeSupportExp; - if (nullptr == pfnGetImageMemoryPointerSupportExp) { + if (nullptr == pfnGetImageMemoryHandleTypeSupportExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -7741,62 +7744,9 @@ urBindlessImagesGetImageMemoryPointerSupportExp( if (NULL == hDevice) return UR_RESULT_ERROR_INVALID_NULL_HANDLE; - } - - if (getContext()->enableLifetimeValidation && - !getContext()->refCountContext->isReferenceValid(hContext)) { - getContext()->refCountContext->logInvalidReference(hContext); - } - - if (getContext()->enableLifetimeValidation && - !getContext()->refCountContext->isReferenceValid(hDevice)) { - getContext()->refCountContext->logInvalidReference(hDevice); - } - ur_result_t result = pfnGetImageMemoryPointerSupportExp( - hContext, hDevice, pImageDesc, pImageFormat, pSupportedRet); - - return result; -} - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Intercept function for urBindlessImagesGetImageMemoryOpaqueSupportExp -__urdlllocal ur_result_t UR_APICALL -urBindlessImagesGetImageMemoryOpaqueSupportExp( - /// [in] handle of the context object - ur_context_handle_t hContext, - /// [in] handle of the device object - ur_device_handle_t hDevice, - /// [in] pointer to image description - const ur_image_desc_t *pImageDesc, - /// [in] pointer to image format specification - const ur_image_format_t *pImageFormat, - /// [out] returned indication of support for allocating opaque handle - /// memory - ur_bool_t *pSupportedRet) { - auto pfnGetImageMemoryOpaqueSupportExp = - getContext() - ->urDdiTable.BindlessImagesExp.pfnGetImageMemoryOpaqueSupportExp; - - if (nullptr == pfnGetImageMemoryOpaqueSupportExp) { - return UR_RESULT_ERROR_UNINITIALIZED; - } - - if (getContext()->enableParameterValidation) { - if (NULL == pImageDesc) - return UR_RESULT_ERROR_INVALID_NULL_POINTER; - - if (NULL == pImageFormat) - return UR_RESULT_ERROR_INVALID_NULL_POINTER; - - if (NULL == pSupportedRet) - return UR_RESULT_ERROR_INVALID_NULL_POINTER; - - if (NULL == hContext) - return UR_RESULT_ERROR_INVALID_NULL_HANDLE; - - if (NULL == hDevice) - return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + if (UR_EXP_IMAGE_MEM_TYPE_OPAQUE_HANDLE < imageMemHandleType) + return UR_RESULT_ERROR_INVALID_ENUMERATION; } if (getContext()->enableLifetimeValidation && @@ -7809,8 +7759,9 @@ urBindlessImagesGetImageMemoryOpaqueSupportExp( getContext()->refCountContext->logInvalidReference(hDevice); } - ur_result_t result = pfnGetImageMemoryOpaqueSupportExp( - hContext, hDevice, pImageDesc, pImageFormat, pSupportedRet); + ur_result_t result = pfnGetImageMemoryHandleTypeSupportExp( + hContext, hDevice, pImageDesc, pImageFormat, imageMemHandleType, + pSupportedRet); return result; } @@ -7828,9 +7779,8 @@ urBindlessImagesGetImageUnsampledHandleSupportExp( const ur_image_desc_t *pImageDesc, /// [in] pointer to image format specification const ur_image_format_t *pImageFormat, - /// [in] indicates whether the image memory would be backed by an opaque - /// handle allocation - ur_bool_t isOpaqueAllocation, + /// [in] type of image backing memory handle to query support for + ur_exp_image_mem_type_t imageMemHandleType, /// [out] returned indication of support for creating unsampled image /// handles ur_bool_t *pSupportedRet) { @@ -7857,6 +7807,9 @@ urBindlessImagesGetImageUnsampledHandleSupportExp( if (NULL == hDevice) return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + + if (UR_EXP_IMAGE_MEM_TYPE_OPAQUE_HANDLE < imageMemHandleType) + return UR_RESULT_ERROR_INVALID_ENUMERATION; } if (getContext()->enableLifetimeValidation && @@ -7870,7 +7823,7 @@ urBindlessImagesGetImageUnsampledHandleSupportExp( } ur_result_t result = pfnGetImageUnsampledHandleSupportExp( - hContext, hDevice, pImageDesc, pImageFormat, isOpaqueAllocation, + hContext, hDevice, pImageDesc, pImageFormat, imageMemHandleType, pSupportedRet); return result; @@ -7889,9 +7842,8 @@ urBindlessImagesGetImageSampledHandleSupportExp( const ur_image_desc_t *pImageDesc, /// [in] pointer to image format specification const ur_image_format_t *pImageFormat, - /// [in] indicates whether the image memory would be backed by an opaque - /// handle allocation - ur_bool_t isOpaqueAllocation, + /// [in] type of image backing memory handle to query support for + ur_exp_image_mem_type_t imageMemHandleType, /// [out] returned indication of support for creating sampled image /// handles ur_bool_t *pSupportedRet) { @@ -7918,6 +7870,9 @@ urBindlessImagesGetImageSampledHandleSupportExp( if (NULL == hDevice) return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + + if (UR_EXP_IMAGE_MEM_TYPE_OPAQUE_HANDLE < imageMemHandleType) + return UR_RESULT_ERROR_INVALID_ENUMERATION; } if (getContext()->enableLifetimeValidation && @@ -7931,7 +7886,7 @@ urBindlessImagesGetImageSampledHandleSupportExp( } ur_result_t result = pfnGetImageSampledHandleSupportExp( - hContext, hDevice, pImageDesc, pImageFormat, isOpaqueAllocation, + hContext, hDevice, pImageDesc, pImageFormat, imageMemHandleType, pSupportedRet); return result; @@ -10778,15 +10733,10 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetBindlessImagesExpProcAddrTable( pDdiTable->pfnImageGetInfoExp = ur_validation_layer::urBindlessImagesImageGetInfoExp; - dditable.pfnGetImageMemoryPointerSupportExp = - pDdiTable->pfnGetImageMemoryPointerSupportExp; - pDdiTable->pfnGetImageMemoryPointerSupportExp = - ur_validation_layer::urBindlessImagesGetImageMemoryPointerSupportExp; - - dditable.pfnGetImageMemoryOpaqueSupportExp = - pDdiTable->pfnGetImageMemoryOpaqueSupportExp; - pDdiTable->pfnGetImageMemoryOpaqueSupportExp = - ur_validation_layer::urBindlessImagesGetImageMemoryOpaqueSupportExp; + dditable.pfnGetImageMemoryHandleTypeSupportExp = + pDdiTable->pfnGetImageMemoryHandleTypeSupportExp; + pDdiTable->pfnGetImageMemoryHandleTypeSupportExp = + ur_validation_layer::urBindlessImagesGetImageMemoryHandleTypeSupportExp; dditable.pfnGetImageUnsampledHandleSupportExp = pDdiTable->pfnGetImageUnsampledHandleSupportExp; diff --git a/unified-runtime/source/loader/loader.def.in b/unified-runtime/source/loader/loader.def.in index 9d31f61c3ffd0..c93481a29f5fd 100644 --- a/unified-runtime/source/loader/loader.def.in +++ b/unified-runtime/source/loader/loader.def.in @@ -5,8 +5,7 @@ EXPORTS urAdapterGetLastError urAdapterRelease urAdapterRetain - urBindlessImagesGetImageMemoryOpaqueSupportExp - urBindlessImagesGetImageMemoryPointerSupportExp + urBindlessImagesGetImageMemoryHandleTypeSupportExp urBindlessImagesGetImageSampledHandleSupportExp urBindlessImagesGetImageUnsampledHandleSupportExp urBindlessImagesImageAllocateExp @@ -186,8 +185,7 @@ EXPORTS urPrintApiVersion urPrintBaseDesc urPrintBaseProperties - urPrintBindlessImagesGetImageMemoryOpaqueSupportExpParams - urPrintBindlessImagesGetImageMemoryPointerSupportExpParams + urPrintBindlessImagesGetImageMemoryHandleTypeSupportExpParams urPrintBindlessImagesGetImageSampledHandleSupportExpParams urPrintBindlessImagesGetImageUnsampledHandleSupportExpParams urPrintBindlessImagesImageAllocateExpParams @@ -342,6 +340,7 @@ EXPORTS urPrintExpFileDescriptor urPrintExpImageCopyFlags urPrintExpImageCopyRegion + urPrintExpImageMemType urPrintExpLaunchProperty urPrintExpLaunchPropertyId urPrintExpPeerInfo diff --git a/unified-runtime/source/loader/loader.map.in b/unified-runtime/source/loader/loader.map.in index c3ad1e12ba0ca..b57c96e379383 100644 --- a/unified-runtime/source/loader/loader.map.in +++ b/unified-runtime/source/loader/loader.map.in @@ -5,8 +5,7 @@ urAdapterGetLastError; urAdapterRelease; urAdapterRetain; - urBindlessImagesGetImageMemoryOpaqueSupportExp; - urBindlessImagesGetImageMemoryPointerSupportExp; + urBindlessImagesGetImageMemoryHandleTypeSupportExp; urBindlessImagesGetImageSampledHandleSupportExp; urBindlessImagesGetImageUnsampledHandleSupportExp; urBindlessImagesImageAllocateExp; @@ -186,8 +185,7 @@ urPrintApiVersion; urPrintBaseDesc; urPrintBaseProperties; - urPrintBindlessImagesGetImageMemoryOpaqueSupportExpParams; - urPrintBindlessImagesGetImageMemoryPointerSupportExpParams; + urPrintBindlessImagesGetImageMemoryHandleTypeSupportExpParams; urPrintBindlessImagesGetImageSampledHandleSupportExpParams; urPrintBindlessImagesGetImageUnsampledHandleSupportExpParams; urPrintBindlessImagesImageAllocateExpParams; @@ -342,6 +340,7 @@ urPrintExpFileDescriptor; urPrintExpImageCopyFlags; urPrintExpImageCopyRegion; + urPrintExpImageMemType; urPrintExpLaunchProperty; urPrintExpLaunchPropertyId; urPrintExpPeerInfo; diff --git a/unified-runtime/source/loader/ur_ldrddi.cpp b/unified-runtime/source/loader/ur_ldrddi.cpp index 4dafd5008ac71..149e91d0b3472 100644 --- a/unified-runtime/source/loader/ur_ldrddi.cpp +++ b/unified-runtime/source/loader/ur_ldrddi.cpp @@ -7110,9 +7110,9 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for -/// urBindlessImagesGetImageMemoryPointerSupportExp +/// urBindlessImagesGetImageMemoryHandleTypeSupportExp __urdlllocal ur_result_t UR_APICALL -urBindlessImagesGetImageMemoryPointerSupportExp( +urBindlessImagesGetImageMemoryHandleTypeSupportExp( /// [in] handle of the context object ur_context_handle_t hContext, /// [in] handle of the device object @@ -7121,7 +7121,10 @@ urBindlessImagesGetImageMemoryPointerSupportExp( const ur_image_desc_t *pImageDesc, /// [in] pointer to image format specification const ur_image_format_t *pImageFormat, - /// [out] returned indication of support for allocating USM style memory + /// [in] type of image backing memory handle to query support for + ur_exp_image_mem_type_t imageMemHandleType, + /// [out] returned indication of support for allocating the given image + /// backing memory handle type ur_bool_t *pSupportedRet) { ur_result_t result = UR_RESULT_SUCCESS; @@ -7129,9 +7132,9 @@ urBindlessImagesGetImageMemoryPointerSupportExp( // extract platform's function pointer table auto dditable = reinterpret_cast(hContext)->dditable; - auto pfnGetImageMemoryPointerSupportExp = - dditable->ur.BindlessImagesExp.pfnGetImageMemoryPointerSupportExp; - if (nullptr == pfnGetImageMemoryPointerSupportExp) + auto pfnGetImageMemoryHandleTypeSupportExp = + dditable->ur.BindlessImagesExp.pfnGetImageMemoryHandleTypeSupportExp; + if (nullptr == pfnGetImageMemoryHandleTypeSupportExp) return UR_RESULT_ERROR_UNINITIALIZED; // convert loader handle to platform handle @@ -7141,47 +7144,9 @@ urBindlessImagesGetImageMemoryPointerSupportExp( hDevice = reinterpret_cast(hDevice)->handle; // forward to device-platform - result = pfnGetImageMemoryPointerSupportExp(hContext, hDevice, pImageDesc, - pImageFormat, pSupportedRet); - - return result; -} - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Intercept function for urBindlessImagesGetImageMemoryOpaqueSupportExp -__urdlllocal ur_result_t UR_APICALL -urBindlessImagesGetImageMemoryOpaqueSupportExp( - /// [in] handle of the context object - ur_context_handle_t hContext, - /// [in] handle of the device object - ur_device_handle_t hDevice, - /// [in] pointer to image description - const ur_image_desc_t *pImageDesc, - /// [in] pointer to image format specification - const ur_image_format_t *pImageFormat, - /// [out] returned indication of support for allocating opaque handle - /// memory - ur_bool_t *pSupportedRet) { - ur_result_t result = UR_RESULT_SUCCESS; - - [[maybe_unused]] auto context = getContext(); - - // extract platform's function pointer table - auto dditable = reinterpret_cast(hContext)->dditable; - auto pfnGetImageMemoryOpaqueSupportExp = - dditable->ur.BindlessImagesExp.pfnGetImageMemoryOpaqueSupportExp; - if (nullptr == pfnGetImageMemoryOpaqueSupportExp) - return UR_RESULT_ERROR_UNINITIALIZED; - - // convert loader handle to platform handle - hContext = reinterpret_cast(hContext)->handle; - - // convert loader handle to platform handle - hDevice = reinterpret_cast(hDevice)->handle; - - // forward to device-platform - result = pfnGetImageMemoryOpaqueSupportExp(hContext, hDevice, pImageDesc, - pImageFormat, pSupportedRet); + result = pfnGetImageMemoryHandleTypeSupportExp( + hContext, hDevice, pImageDesc, pImageFormat, imageMemHandleType, + pSupportedRet); return result; } @@ -7199,9 +7164,8 @@ urBindlessImagesGetImageUnsampledHandleSupportExp( const ur_image_desc_t *pImageDesc, /// [in] pointer to image format specification const ur_image_format_t *pImageFormat, - /// [in] indicates whether the image memory would be backed by an opaque - /// handle allocation - ur_bool_t isOpaqueAllocation, + /// [in] type of image backing memory handle to query support for + ur_exp_image_mem_type_t imageMemHandleType, /// [out] returned indication of support for creating unsampled image /// handles ur_bool_t *pSupportedRet) { @@ -7224,7 +7188,7 @@ urBindlessImagesGetImageUnsampledHandleSupportExp( // forward to device-platform result = pfnGetImageUnsampledHandleSupportExp( - hContext, hDevice, pImageDesc, pImageFormat, isOpaqueAllocation, + hContext, hDevice, pImageDesc, pImageFormat, imageMemHandleType, pSupportedRet); return result; @@ -7243,9 +7207,8 @@ urBindlessImagesGetImageSampledHandleSupportExp( const ur_image_desc_t *pImageDesc, /// [in] pointer to image format specification const ur_image_format_t *pImageFormat, - /// [in] indicates whether the image memory would be backed by an opaque - /// handle allocation - ur_bool_t isOpaqueAllocation, + /// [in] type of image backing memory handle to query support for + ur_exp_image_mem_type_t imageMemHandleType, /// [out] returned indication of support for creating sampled image /// handles ur_bool_t *pSupportedRet) { @@ -7268,7 +7231,7 @@ urBindlessImagesGetImageSampledHandleSupportExp( // forward to device-platform result = pfnGetImageSampledHandleSupportExp(hContext, hDevice, pImageDesc, - pImageFormat, isOpaqueAllocation, + pImageFormat, imageMemHandleType, pSupportedRet); return result; @@ -10220,10 +10183,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetBindlessImagesExpProcAddrTable( pDdiTable->pfnImageCopyExp = ur_loader::urBindlessImagesImageCopyExp; pDdiTable->pfnImageGetInfoExp = ur_loader::urBindlessImagesImageGetInfoExp; - pDdiTable->pfnGetImageMemoryPointerSupportExp = - ur_loader::urBindlessImagesGetImageMemoryPointerSupportExp; - pDdiTable->pfnGetImageMemoryOpaqueSupportExp = - ur_loader::urBindlessImagesGetImageMemoryOpaqueSupportExp; + pDdiTable->pfnGetImageMemoryHandleTypeSupportExp = + ur_loader::urBindlessImagesGetImageMemoryHandleTypeSupportExp; pDdiTable->pfnGetImageUnsampledHandleSupportExp = ur_loader::urBindlessImagesGetImageUnsampledHandleSupportExp; pDdiTable->pfnGetImageSampledHandleSupportExp = diff --git a/unified-runtime/source/loader/ur_libapi.cpp b/unified-runtime/source/loader/ur_libapi.cpp index 3bfc7a22f683b..175af6ea803d3 100644 --- a/unified-runtime/source/loader/ur_libapi.cpp +++ b/unified-runtime/source/loader/ur_libapi.cpp @@ -7670,48 +7670,8 @@ ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( } /////////////////////////////////////////////////////////////////////////////// -/// @brief Query support for allocating pointer handle type image memory with -/// specific image properties -/// -/// @returns -/// - ::UR_RESULT_SUCCESS -/// - ::UR_RESULT_ERROR_UNINITIALIZED -/// - ::UR_RESULT_ERROR_DEVICE_LOST -/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC -/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hContext` -/// + `NULL == hDevice` -/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// + `NULL == pImageDesc` -/// + `NULL == pImageFormat` -/// + `NULL == pSupportedRet` -/// - ::UR_RESULT_ERROR_INVALID_DEVICE -ur_result_t UR_APICALL urBindlessImagesGetImageMemoryPointerSupportExp( - /// [in] handle of the context object - ur_context_handle_t hContext, - /// [in] handle of the device object - ur_device_handle_t hDevice, - /// [in] pointer to image description - const ur_image_desc_t *pImageDesc, - /// [in] pointer to image format specification - const ur_image_format_t *pImageFormat, - /// [out] returned indication of support for allocating USM style memory - ur_bool_t *pSupportedRet) try { - auto pfnGetImageMemoryPointerSupportExp = - ur_lib::getContext() - ->urDdiTable.BindlessImagesExp.pfnGetImageMemoryPointerSupportExp; - if (nullptr == pfnGetImageMemoryPointerSupportExp) - return UR_RESULT_ERROR_UNINITIALIZED; - - return pfnGetImageMemoryPointerSupportExp(hContext, hDevice, pImageDesc, - pImageFormat, pSupportedRet); -} catch (...) { - return exceptionToResult(std::current_exception()); -} - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Query support for allocating opaque handle type image memory with -/// specific image properties +/// @brief Query support for allocating a given image backing memory handle type +/// with specific image properties /// /// @returns /// - ::UR_RESULT_SUCCESS @@ -7725,8 +7685,11 @@ ur_result_t UR_APICALL urBindlessImagesGetImageMemoryPointerSupportExp( /// + `NULL == pImageDesc` /// + `NULL == pImageFormat` /// + `NULL == pSupportedRet` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_EXP_IMAGE_MEM_TYPE_OPAQUE_HANDLE < imageMemHandleType` /// - ::UR_RESULT_ERROR_INVALID_DEVICE -ur_result_t UR_APICALL urBindlessImagesGetImageMemoryOpaqueSupportExp( +/// - ::UR_RESULT_ERROR_INVALID_CONTEXT +ur_result_t UR_APICALL urBindlessImagesGetImageMemoryHandleTypeSupportExp( /// [in] handle of the context object ur_context_handle_t hContext, /// [in] handle of the device object @@ -7735,17 +7698,20 @@ ur_result_t UR_APICALL urBindlessImagesGetImageMemoryOpaqueSupportExp( const ur_image_desc_t *pImageDesc, /// [in] pointer to image format specification const ur_image_format_t *pImageFormat, - /// [out] returned indication of support for allocating opaque handle - /// memory + /// [in] type of image backing memory handle to query support for + ur_exp_image_mem_type_t imageMemHandleType, + /// [out] returned indication of support for allocating the given image + /// backing memory handle type ur_bool_t *pSupportedRet) try { - auto pfnGetImageMemoryOpaqueSupportExp = + auto pfnGetImageMemoryHandleTypeSupportExp = ur_lib::getContext() - ->urDdiTable.BindlessImagesExp.pfnGetImageMemoryOpaqueSupportExp; - if (nullptr == pfnGetImageMemoryOpaqueSupportExp) + ->urDdiTable.BindlessImagesExp.pfnGetImageMemoryHandleTypeSupportExp; + if (nullptr == pfnGetImageMemoryHandleTypeSupportExp) return UR_RESULT_ERROR_UNINITIALIZED; - return pfnGetImageMemoryOpaqueSupportExp(hContext, hDevice, pImageDesc, - pImageFormat, pSupportedRet); + return pfnGetImageMemoryHandleTypeSupportExp(hContext, hDevice, pImageDesc, + pImageFormat, imageMemHandleType, + pSupportedRet); } catch (...) { return exceptionToResult(std::current_exception()); } @@ -7766,6 +7732,8 @@ ur_result_t UR_APICALL urBindlessImagesGetImageMemoryOpaqueSupportExp( /// + `NULL == pImageDesc` /// + `NULL == pImageFormat` /// + `NULL == pSupportedRet` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_EXP_IMAGE_MEM_TYPE_OPAQUE_HANDLE < imageMemHandleType` /// - ::UR_RESULT_ERROR_INVALID_DEVICE /// - ::UR_RESULT_ERROR_INVALID_CONTEXT ur_result_t UR_APICALL urBindlessImagesGetImageUnsampledHandleSupportExp( @@ -7777,9 +7745,8 @@ ur_result_t UR_APICALL urBindlessImagesGetImageUnsampledHandleSupportExp( const ur_image_desc_t *pImageDesc, /// [in] pointer to image format specification const ur_image_format_t *pImageFormat, - /// [in] indicates whether the image memory would be backed by an opaque - /// handle allocation - ur_bool_t isOpaqueAllocation, + /// [in] type of image backing memory handle to query support for + ur_exp_image_mem_type_t imageMemHandleType, /// [out] returned indication of support for creating unsampled image /// handles ur_bool_t *pSupportedRet) try { @@ -7790,15 +7757,16 @@ ur_result_t UR_APICALL urBindlessImagesGetImageUnsampledHandleSupportExp( return UR_RESULT_ERROR_UNINITIALIZED; return pfnGetImageUnsampledHandleSupportExp(hContext, hDevice, pImageDesc, - pImageFormat, isOpaqueAllocation, + pImageFormat, imageMemHandleType, pSupportedRet); } catch (...) { return exceptionToResult(std::current_exception()); } /////////////////////////////////////////////////////////////////////////////// -/// @brief Query support for creating an unsampled image handle with specific -/// image properties +/// @brief Query support for creating an sampled image handle with specific +/// image +/// properties /// /// @returns /// - ::UR_RESULT_SUCCESS @@ -7812,6 +7780,8 @@ ur_result_t UR_APICALL urBindlessImagesGetImageUnsampledHandleSupportExp( /// + `NULL == pImageDesc` /// + `NULL == pImageFormat` /// + `NULL == pSupportedRet` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_EXP_IMAGE_MEM_TYPE_OPAQUE_HANDLE < imageMemHandleType` /// - ::UR_RESULT_ERROR_INVALID_DEVICE /// - ::UR_RESULT_ERROR_INVALID_CONTEXT ur_result_t UR_APICALL urBindlessImagesGetImageSampledHandleSupportExp( @@ -7823,9 +7793,8 @@ ur_result_t UR_APICALL urBindlessImagesGetImageSampledHandleSupportExp( const ur_image_desc_t *pImageDesc, /// [in] pointer to image format specification const ur_image_format_t *pImageFormat, - /// [in] indicates whether the image memory would be backed by an opaque - /// handle allocation - ur_bool_t isOpaqueAllocation, + /// [in] type of image backing memory handle to query support for + ur_exp_image_mem_type_t imageMemHandleType, /// [out] returned indication of support for creating sampled image /// handles ur_bool_t *pSupportedRet) try { @@ -7836,7 +7805,7 @@ ur_result_t UR_APICALL urBindlessImagesGetImageSampledHandleSupportExp( return UR_RESULT_ERROR_UNINITIALIZED; return pfnGetImageSampledHandleSupportExp(hContext, hDevice, pImageDesc, - pImageFormat, isOpaqueAllocation, + pImageFormat, imageMemHandleType, pSupportedRet); } catch (...) { return exceptionToResult(std::current_exception()); diff --git a/unified-runtime/source/loader/ur_print.cpp b/unified-runtime/source/loader/ur_print.cpp index 7bafd60557e72..8da919200d102 100644 --- a/unified-runtime/source/loader/ur_print.cpp +++ b/unified-runtime/source/loader/ur_print.cpp @@ -965,6 +965,14 @@ urPrintExpExternalSemaphoreType(enum ur_exp_external_semaphore_type_t value, return str_copy(&ss, buffer, buff_size, out_size); } +ur_result_t urPrintExpImageMemType(enum ur_exp_image_mem_type_t value, + char *buffer, const size_t buff_size, + size_t *out_size) { + std::stringstream ss; + ss << value; + return str_copy(&ss, buffer, buff_size, out_size); +} + ur_result_t urPrintExpFileDescriptor(const struct ur_exp_file_descriptor_t params, char *buffer, const size_t buff_size, @@ -1264,17 +1272,9 @@ ur_result_t urPrintBindlessImagesImageGetInfoExpParams( return str_copy(&ss, buffer, buff_size, out_size); } -ur_result_t urPrintBindlessImagesGetImageMemoryPointerSupportExpParams( +ur_result_t urPrintBindlessImagesGetImageMemoryHandleTypeSupportExpParams( const struct - ur_bindless_images_get_image_memory_pointer_support_exp_params_t *params, - char *buffer, const size_t buff_size, size_t *out_size) { - std::stringstream ss; - ss << params; - return str_copy(&ss, buffer, buff_size, out_size); -} - -ur_result_t urPrintBindlessImagesGetImageMemoryOpaqueSupportExpParams( - const struct ur_bindless_images_get_image_memory_opaque_support_exp_params_t + ur_bindless_images_get_image_memory_handle_type_support_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size) { std::stringstream ss; diff --git a/unified-runtime/source/ur_api.cpp b/unified-runtime/source/ur_api.cpp index d04ae135f079d..77e313ac1a7a2 100644 --- a/unified-runtime/source/ur_api.cpp +++ b/unified-runtime/source/ur_api.cpp @@ -6713,40 +6713,8 @@ ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( } /////////////////////////////////////////////////////////////////////////////// -/// @brief Query support for allocating pointer handle type image memory with -/// specific image properties -/// -/// @returns -/// - ::UR_RESULT_SUCCESS -/// - ::UR_RESULT_ERROR_UNINITIALIZED -/// - ::UR_RESULT_ERROR_DEVICE_LOST -/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC -/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hContext` -/// + `NULL == hDevice` -/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// + `NULL == pImageDesc` -/// + `NULL == pImageFormat` -/// + `NULL == pSupportedRet` -/// - ::UR_RESULT_ERROR_INVALID_DEVICE -ur_result_t UR_APICALL urBindlessImagesGetImageMemoryPointerSupportExp( - /// [in] handle of the context object - ur_context_handle_t hContext, - /// [in] handle of the device object - ur_device_handle_t hDevice, - /// [in] pointer to image description - const ur_image_desc_t *pImageDesc, - /// [in] pointer to image format specification - const ur_image_format_t *pImageFormat, - /// [out] returned indication of support for allocating USM style memory - ur_bool_t *pSupportedRet) { - ur_result_t result = UR_RESULT_SUCCESS; - return result; -} - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Query support for allocating opaque handle type image memory with -/// specific image properties +/// @brief Query support for allocating a given image backing memory handle type +/// with specific image properties /// /// @returns /// - ::UR_RESULT_SUCCESS @@ -6760,8 +6728,11 @@ ur_result_t UR_APICALL urBindlessImagesGetImageMemoryPointerSupportExp( /// + `NULL == pImageDesc` /// + `NULL == pImageFormat` /// + `NULL == pSupportedRet` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_EXP_IMAGE_MEM_TYPE_OPAQUE_HANDLE < imageMemHandleType` /// - ::UR_RESULT_ERROR_INVALID_DEVICE -ur_result_t UR_APICALL urBindlessImagesGetImageMemoryOpaqueSupportExp( +/// - ::UR_RESULT_ERROR_INVALID_CONTEXT +ur_result_t UR_APICALL urBindlessImagesGetImageMemoryHandleTypeSupportExp( /// [in] handle of the context object ur_context_handle_t hContext, /// [in] handle of the device object @@ -6770,8 +6741,10 @@ ur_result_t UR_APICALL urBindlessImagesGetImageMemoryOpaqueSupportExp( const ur_image_desc_t *pImageDesc, /// [in] pointer to image format specification const ur_image_format_t *pImageFormat, - /// [out] returned indication of support for allocating opaque handle - /// memory + /// [in] type of image backing memory handle to query support for + ur_exp_image_mem_type_t imageMemHandleType, + /// [out] returned indication of support for allocating the given image + /// backing memory handle type ur_bool_t *pSupportedRet) { ur_result_t result = UR_RESULT_SUCCESS; return result; @@ -6793,6 +6766,8 @@ ur_result_t UR_APICALL urBindlessImagesGetImageMemoryOpaqueSupportExp( /// + `NULL == pImageDesc` /// + `NULL == pImageFormat` /// + `NULL == pSupportedRet` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_EXP_IMAGE_MEM_TYPE_OPAQUE_HANDLE < imageMemHandleType` /// - ::UR_RESULT_ERROR_INVALID_DEVICE /// - ::UR_RESULT_ERROR_INVALID_CONTEXT ur_result_t UR_APICALL urBindlessImagesGetImageUnsampledHandleSupportExp( @@ -6804,9 +6779,8 @@ ur_result_t UR_APICALL urBindlessImagesGetImageUnsampledHandleSupportExp( const ur_image_desc_t *pImageDesc, /// [in] pointer to image format specification const ur_image_format_t *pImageFormat, - /// [in] indicates whether the image memory would be backed by an opaque - /// handle allocation - ur_bool_t isOpaqueAllocation, + /// [in] type of image backing memory handle to query support for + ur_exp_image_mem_type_t imageMemHandleType, /// [out] returned indication of support for creating unsampled image /// handles ur_bool_t *pSupportedRet) { @@ -6815,8 +6789,9 @@ ur_result_t UR_APICALL urBindlessImagesGetImageUnsampledHandleSupportExp( } /////////////////////////////////////////////////////////////////////////////// -/// @brief Query support for creating an unsampled image handle with specific -/// image properties +/// @brief Query support for creating an sampled image handle with specific +/// image +/// properties /// /// @returns /// - ::UR_RESULT_SUCCESS @@ -6830,6 +6805,8 @@ ur_result_t UR_APICALL urBindlessImagesGetImageUnsampledHandleSupportExp( /// + `NULL == pImageDesc` /// + `NULL == pImageFormat` /// + `NULL == pSupportedRet` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_EXP_IMAGE_MEM_TYPE_OPAQUE_HANDLE < imageMemHandleType` /// - ::UR_RESULT_ERROR_INVALID_DEVICE /// - ::UR_RESULT_ERROR_INVALID_CONTEXT ur_result_t UR_APICALL urBindlessImagesGetImageSampledHandleSupportExp( @@ -6841,9 +6818,8 @@ ur_result_t UR_APICALL urBindlessImagesGetImageSampledHandleSupportExp( const ur_image_desc_t *pImageDesc, /// [in] pointer to image format specification const ur_image_format_t *pImageFormat, - /// [in] indicates whether the image memory would be backed by an opaque - /// handle allocation - ur_bool_t isOpaqueAllocation, + /// [in] type of image backing memory handle to query support for + ur_exp_image_mem_type_t imageMemHandleType, /// [out] returned indication of support for creating sampled image /// handles ur_bool_t *pSupportedRet) { From 8bbe186c13bfa506f9c5051356e718d4c8b7decd Mon Sep 17 00:00:00 2001 From: Przemek Malon Date: Tue, 8 Apr 2025 16:33:45 +0100 Subject: [PATCH 08/13] Fix changelog function name --- unified-runtime/scripts/core/EXP-BINDLESS-IMAGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unified-runtime/scripts/core/EXP-BINDLESS-IMAGES.rst b/unified-runtime/scripts/core/EXP-BINDLESS-IMAGES.rst index 88fddd083d06e..479afb87e4f28 100644 --- a/unified-runtime/scripts/core/EXP-BINDLESS-IMAGES.rst +++ b/unified-runtime/scripts/core/EXP-BINDLESS-IMAGES.rst @@ -282,7 +282,7 @@ Changelog | 22.0 || Added the following enum: | | || - exp_image_mem_type_t | | || Added the following APIs: | -| || - BindlessImagesGetImageMemoryHandleTypeSupportExp | +| || - GetImageMemoryHandleTypeSupportExp | | || - GetImageUnsampledHandleSupportExp | | || - GetImageSampledHandleSupportExp | +----------+-------------------------------------------------------------+ From c26503c3f70dce6e2ecd822d03393aa355b0518b Mon Sep 17 00:00:00 2001 From: Przemek Malon Date: Tue, 8 Apr 2025 16:41:43 +0100 Subject: [PATCH 09/13] Update func enum values in registry.yml --- unified-runtime/include/ur_api.h | 6 +++--- unified-runtime/scripts/core/registry.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/unified-runtime/include/ur_api.h b/unified-runtime/include/ur_api.h index 77335c7f580be..209b73dd13a62 100644 --- a/unified-runtime/include/ur_api.h +++ b/unified-runtime/include/ur_api.h @@ -458,11 +458,11 @@ typedef enum ur_function_t { /// Enumerator for ::urUSMPoolSetInfoExp UR_FUNCTION_USM_POOL_SET_INFO_EXP = 265, /// Enumerator for ::urBindlessImagesGetImageUnsampledHandleSupportExp - UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_UNSAMPLED_HANDLE_SUPPORT_EXP = 268, + UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_UNSAMPLED_HANDLE_SUPPORT_EXP = 266, /// Enumerator for ::urBindlessImagesGetImageSampledHandleSupportExp - UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_SAMPLED_HANDLE_SUPPORT_EXP = 269, + UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_SAMPLED_HANDLE_SUPPORT_EXP = 267, /// Enumerator for ::urBindlessImagesGetImageMemoryHandleTypeSupportExp - UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_HANDLE_TYPE_SUPPORT_EXP = 270, + UR_FUNCTION_BINDLESS_IMAGES_GET_IMAGE_MEMORY_HANDLE_TYPE_SUPPORT_EXP = 268, /// @cond UR_FUNCTION_FORCE_UINT32 = 0x7fffffff /// @endcond diff --git a/unified-runtime/scripts/core/registry.yml b/unified-runtime/scripts/core/registry.yml index 4243da4a334be..53f9c838cf07b 100644 --- a/unified-runtime/scripts/core/registry.yml +++ b/unified-runtime/scripts/core/registry.yml @@ -645,13 +645,13 @@ etors: value: '265' - name: BINDLESS_IMAGES_GET_IMAGE_UNSAMPLED_HANDLE_SUPPORT_EXP desc: Enumerator for $xBindlessImagesGetImageUnsampledHandleSupportExp - value: '268' + value: '266' - name: BINDLESS_IMAGES_GET_IMAGE_SAMPLED_HANDLE_SUPPORT_EXP desc: Enumerator for $xBindlessImagesGetImageSampledHandleSupportExp - value: '269' + value: '267' - name: BINDLESS_IMAGES_GET_IMAGE_MEMORY_HANDLE_TYPE_SUPPORT_EXP desc: Enumerator for $xBindlessImagesGetImageMemoryHandleTypeSupportExp - value: '270' + value: '268' --- type: enum desc: Defines structure types From 2bd03cce20361e712e7f6e27ac3c517cee45fe64 Mon Sep 17 00:00:00 2001 From: Przemek Malon Date: Tue, 8 Apr 2025 17:02:47 +0100 Subject: [PATCH 10/13] Update unused, and maybe unused, function parameters --- .../source/adapters/cuda/image.cpp | 20 +++++++++---------- unified-runtime/source/adapters/hip/image.cpp | 9 +++++---- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/unified-runtime/source/adapters/cuda/image.cpp b/unified-runtime/source/adapters/cuda/image.cpp index fa01371a09add..cb0bfb674a8da 100644 --- a/unified-runtime/source/adapters/cuda/image.cpp +++ b/unified-runtime/source/adapters/cuda/image.cpp @@ -1087,9 +1087,9 @@ bool verifyStandardImageSupport(const ur_device_handle_t hDevice, return true; } -bool verifyMipmapImageSupport(const ur_device_handle_t hDevice, - const ur_image_desc_t *pImageDesc, - ur_exp_image_mem_type_t imageMemHandleType) { +bool verifyMipmapImageSupport( + const ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, + [[maybe_unused]] ur_exp_image_mem_type_t imageMemHandleType) { // Verify mipmap image dimensions are within device limits. size_t maxImageWidth, maxImageHeight; @@ -1127,9 +1127,9 @@ bool verifyMipmapImageSupport(const ur_device_handle_t hDevice, return true; } -bool verifyLayeredImageSupport(const ur_device_handle_t hDevice, - const ur_image_desc_t *pImageDesc, - ur_exp_image_mem_type_t imageMemHandleType) { +bool verifyLayeredImageSupport( + const ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, + [[maybe_unused]] ur_exp_image_mem_type_t imageMemHandleType) { // Verify layered image dimensions are within device limits. size_t maxImageWidth, maxImageHeight, maxImageLayers; @@ -1218,7 +1218,7 @@ bool verifyCubemapImageSupport(const ur_device_handle_t hDevice, ur_exp_image_mem_type_t imageMemHandleType) { // Verify cubemap support and whether cubemap image dimensions are within // device limits. - size_t maxImageWidth, maxImageHeight, maxImageLayers; + size_t maxImageWidth; if (pImageDesc->type == UR_MEM_TYPE_IMAGE_CUBEMAP_EXP) { @@ -1256,9 +1256,9 @@ bool verifyCubemapImageSupport(const ur_device_handle_t hDevice, return true; } -bool verifyGatherImageSupport(const ur_device_handle_t hDevice, - const ur_image_desc_t *pImageDesc, - ur_exp_image_mem_type_t imageMemHandleType) { +bool verifyGatherImageSupport( + const ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, + [[maybe_unused]] ur_exp_image_mem_type_t imageMemHandleType) { // Verify gather image dimensions are within device limits. size_t maxImageWidth, maxImageHeight; if (pImageDesc->type == UR_MEM_TYPE_IMAGE_GATHER_EXP) { diff --git a/unified-runtime/source/adapters/hip/image.cpp b/unified-runtime/source/adapters/hip/image.cpp index 13b31bb64963e..0da237a2af294 100644 --- a/unified-runtime/source/adapters/hip/image.cpp +++ b/unified-runtime/source/adapters/hip/image.cpp @@ -1120,7 +1120,7 @@ bool verifyCubemapImageSupport( bool verifyLayeredImageSupport( [[maybe_unused]] const ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, - ur_exp_image_mem_type_t imageMemHandleType) { + [[maybe_unused]] ur_exp_image_mem_type_t imageMemHandleType) { // Verify layered image support. // Layered images are not currently supported for the AMD target. if ((pImageDesc->type == UR_MEM_TYPE_IMAGE1D_ARRAY) || @@ -1131,9 +1131,10 @@ bool verifyLayeredImageSupport( return true; } -bool verifyGatherImageSupport([[maybe_unused]] const ur_device_handle_t hDevice, - const ur_image_desc_t *pImageDesc, - ur_exp_image_mem_type_t imageMemHandleType) { +bool verifyGatherImageSupport( + [[maybe_unused]] const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + [[maybe_unused]] ur_exp_image_mem_type_t imageMemHandleType) { // Verify gather image support. // Gather images are not currently supported for the AMD target. if (pImageDesc->type == UR_MEM_TYPE_IMAGE_GATHER_EXP) { From 8334791a5c7166a1f24247cf265364b2f76cbd2e Mon Sep 17 00:00:00 2001 From: Przemek Malon Date: Tue, 8 Apr 2025 17:19:28 +0100 Subject: [PATCH 11/13] Update maybe unused function parameters --- .../level_zero/helpers/image_helpers.cpp | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/unified-runtime/source/adapters/level_zero/helpers/image_helpers.cpp b/unified-runtime/source/adapters/level_zero/helpers/image_helpers.cpp index f7430e38ccb63..1eccac4ee5877 100644 --- a/unified-runtime/source/adapters/level_zero/helpers/image_helpers.cpp +++ b/unified-runtime/source/adapters/level_zero/helpers/image_helpers.cpp @@ -522,9 +522,9 @@ getImageFormatTypeAndSize(const ur_image_format_t *ImageFormat) { return {ZeImageFormatType, ZeImageFormatTypeSize}; } -bool verifyStandardImageSupport(const ur_device_handle_t hDevice, - const ur_image_desc_t *pImageDesc, - ur_exp_image_mem_type_t imageMemHandleType) { +bool verifyStandardImageSupport( + const ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, + [[maybe_unused]] ur_exp_image_mem_type_t imageMemHandleType) { // Verify standard image dimensions are within device limits. if (pImageDesc->depth != 0 && pImageDesc->type == UR_MEM_TYPE_IMAGE3D) { @@ -558,9 +558,10 @@ bool verifyStandardImageSupport(const ur_device_handle_t hDevice, return true; } -bool verifyMipmapImageSupport([[maybe_unused]] const ur_device_handle_t hDevice, - const ur_image_desc_t *pImageDesc, - ur_exp_image_mem_type_t imageMemHandleType) { +bool verifyMipmapImageSupport( + [[maybe_unused]] const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + [[maybe_unused]] ur_exp_image_mem_type_t imageMemHandleType) { // Verify support for mipmap images. // LevelZero currently does not support mipmap images. if (pImageDesc->numMipLevel > 1) { @@ -573,7 +574,7 @@ bool verifyMipmapImageSupport([[maybe_unused]] const ur_device_handle_t hDevice, bool verifyCubemapImageSupport( [[maybe_unused]] const ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, - ur_exp_image_mem_type_t imageMemHandleType) { + [[maybe_unused]] ur_exp_image_mem_type_t imageMemHandleType) { // Verify support for cubemap images. // LevelZero current does not support cubemap images. if (pImageDesc->type == UR_MEM_TYPE_IMAGE_CUBEMAP_EXP) { @@ -599,9 +600,10 @@ bool verifyLayeredImageSupport( return true; } -bool verifyGatherImageSupport([[maybe_unused]] const ur_device_handle_t hDevice, - const ur_image_desc_t *pImageDesc, - ur_exp_image_mem_type_t imageMemHandleType) { +bool verifyGatherImageSupport( + [[maybe_unused]] const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + [[maybe_unused]] ur_exp_image_mem_type_t imageMemHandleType) { // Verify support for gather images. // LevelZero current does not support gather images. if (pImageDesc->type == UR_MEM_TYPE_IMAGE_GATHER_EXP) { From b66f94fe1d8196bccaf9f68566b21879e2a9b097 Mon Sep 17 00:00:00 2001 From: Przemek Malon Date: Tue, 8 Apr 2025 17:43:04 +0100 Subject: [PATCH 12/13] Update maybe unused function parameters --- unified-runtime/source/adapters/hip/image.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/unified-runtime/source/adapters/hip/image.cpp b/unified-runtime/source/adapters/hip/image.cpp index 0da237a2af294..c7ea7b5aa7db6 100644 --- a/unified-runtime/source/adapters/hip/image.cpp +++ b/unified-runtime/source/adapters/hip/image.cpp @@ -1092,9 +1092,10 @@ bool verifyStandardImageSupport(const ur_device_handle_t hDevice, return true; } -bool verifyMipmapImageSupport([[maybe_unused]] const ur_device_handle_t hDevice, - const ur_image_desc_t *pImageDesc, - ur_exp_image_mem_type_t imageMemHandleType) { +bool verifyMipmapImageSupport( + [[maybe_unused]] const ur_device_handle_t hDevice, + const ur_image_desc_t *pImageDesc, + [[maybe_unused]] ur_exp_image_mem_type_t imageMemHandleType) { // Verify mipmap image support. // Mimpaps are not currently supported for the AMD target. if (pImageDesc->numMipLevel > 1) { @@ -1107,7 +1108,7 @@ bool verifyMipmapImageSupport([[maybe_unused]] const ur_device_handle_t hDevice, bool verifyCubemapImageSupport( [[maybe_unused]] const ur_device_handle_t hDevice, const ur_image_desc_t *pImageDesc, - ur_exp_image_mem_type_t imageMemHandleType) { + [[maybe_unused]] ur_exp_image_mem_type_t imageMemHandleType) { // Verify cubemap image support. // Cubemaps are not currently supported for the AMD target. if (pImageDesc->type == UR_MEM_TYPE_IMAGE_CUBEMAP_EXP) { From cf2207996486af03cbb9aa7b01877fade7eb71f0 Mon Sep 17 00:00:00 2001 From: Przemek Malon Date: Tue, 8 Apr 2025 19:18:20 +0100 Subject: [PATCH 13/13] Fix DX12 test LIT invocation --- .../bindless_images/dx12_interop/read_write_unsampled.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sycl/test-e2e/bindless_images/dx12_interop/read_write_unsampled.cpp b/sycl/test-e2e/bindless_images/dx12_interop/read_write_unsampled.cpp index 5961df933c6fc..4cdd624f9e2f9 100644 --- a/sycl/test-e2e/bindless_images/dx12_interop/read_write_unsampled.cpp +++ b/sycl/test-e2e/bindless_images/dx12_interop/read_write_unsampled.cpp @@ -1,8 +1,9 @@ // REQUIRES: aspect-ext_oneapi_bindless_images // REQUIRES: windows -// DEFINE: %{link-flags}=%if cl_options %{ /clang:-ld3d12 /clang:-ldxgi /clang:-ldxguid %} %else %{ -ld3d12 -ldxgi -ldxguid %} RUN: %{build} -// %{link-flags} -o %t.out RUN: %{run-unfiltered-devices} env NEOReadDebugKeys=1 UseBindlessMode=1 UseExternalAllocatorForSshAndDsh=1 %t.out +// DEFINE: %{link-flags}=%if cl_options %{ /clang:-ld3d12 /clang:-ldxgi /clang:-ldxguid %} %else %{ -ld3d12 -ldxgi -ldxguid %} +// RUN: %{build} %{link-flags} -o %t.out +// RUN: %{run-unfiltered-devices} env NEOReadDebugKeys=1 UseBindlessMode=1 UseExternalAllocatorForSshAndDsh=1 %t.out #pragma clang diagnostic ignored "-Waddress-of-temporary"