From 6a8acc432eb117a9448d849f736c5b7613ad680b Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Fri, 23 Jun 2023 10:13:28 +0100 Subject: [PATCH 001/104] [UR] Clarify UNINITIALIZED error meaning --- include/ur.py | 3 ++- include/ur_api.h | 3 ++- scripts/core/common.yml | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/ur.py b/include/ur.py index f70649998b..9714911c15 100644 --- a/include/ur.py +++ b/include/ur.py @@ -158,7 +158,8 @@ class ur_result_v(IntEnum): ERROR_IMAGE_FORMAT_NOT_SUPPORTED = 35 ## Image format not supported ERROR_MEM_OBJECT_ALLOCATION_FAILURE = 36 ## Memory object allocation failure ERROR_INVALID_PROGRAM_EXECUTABLE = 37 ## Program object parameter is invalid. - ERROR_UNINITIALIZED = 38 ## [Validation] adapter is not initialized + ERROR_UNINITIALIZED = 38 ## [Validation] adapter is not initialized or specific entry-point is not + ## implemented ERROR_OUT_OF_HOST_MEMORY = 39 ## Insufficient host memory to satisfy call ERROR_OUT_OF_DEVICE_MEMORY = 40 ## Insufficient device memory to satisfy call ERROR_OUT_OF_RESOURCES = 41 ## Out of resources diff --git a/include/ur_api.h b/include/ur_api.h index 2f15f4e1d1..fcb7f14353 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -181,7 +181,8 @@ typedef enum ur_result_t { UR_RESULT_ERROR_IMAGE_FORMAT_NOT_SUPPORTED = 35, ///< Image format not supported UR_RESULT_ERROR_MEM_OBJECT_ALLOCATION_FAILURE = 36, ///< Memory object allocation failure UR_RESULT_ERROR_INVALID_PROGRAM_EXECUTABLE = 37, ///< Program object parameter is invalid. - UR_RESULT_ERROR_UNINITIALIZED = 38, ///< [Validation] adapter is not initialized + UR_RESULT_ERROR_UNINITIALIZED = 38, ///< [Validation] adapter is not initialized or specific entry-point is not + ///< implemented UR_RESULT_ERROR_OUT_OF_HOST_MEMORY = 39, ///< Insufficient host memory to satisfy call UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY = 40, ///< Insufficient device memory to satisfy call UR_RESULT_ERROR_OUT_OF_RESOURCES = 41, ///< Out of resources diff --git a/scripts/core/common.yml b/scripts/core/common.yml index 02bffd0751..9797c18ced 100644 --- a/scripts/core/common.yml +++ b/scripts/core/common.yml @@ -201,7 +201,7 @@ etors: - name: ERROR_INVALID_PROGRAM_EXECUTABLE desc: "Program object parameter is invalid." - name: ERROR_UNINITIALIZED - desc: "[Validation] adapter is not initialized" + desc: "[Validation] adapter is not initialized or specific entry-point is not implemented" - name: ERROR_OUT_OF_HOST_MEMORY desc: "Insufficient host memory to satisfy call" - name: ERROR_OUT_OF_DEVICE_MEMORY From e1de66147f026987801d25ba3934e2ad2cdfdc12 Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Fri, 23 Jun 2023 11:12:56 +0100 Subject: [PATCH 002/104] [UR] Add exp-feat docs to rst template --- scripts/templates/exp_feat.rst.mako | 10 ++++++++++ scripts/templates/exp_feat.yml.mako | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/scripts/templates/exp_feat.rst.mako b/scripts/templates/exp_feat.rst.mako index cfa124fd1b..628e9f8c50 100644 --- a/scripts/templates/exp_feat.rst.mako +++ b/scripts/templates/exp_feat.rst.mako @@ -70,6 +70,16 @@ Changelog | 1.0 | Initial Draft | +-----------+------------------------+ +Support +-------------------------------------------------------------------------------- + +Adapters which support this experimental feature *must* return the valid string +defined in ``${"${X}"}_${"_".join(name.split("-")).upper()}_EXTENSION_STRING_EXP`` +as one of the options from ${"${x}"}DeviceGetInfo when querying for +${"${X}"}_DEVICE_INFO_EXTENSIONS. Conversly, before using any of the +functionality defined in this experimental feature the user *must* use the +device query to determine if the adapter supports this feature. + Contributors -------------------------------------------------------------------------------- .. comment: diff --git a/scripts/templates/exp_feat.yml.mako b/scripts/templates/exp_feat.yml.mako index c23eab3f2b..84819697ed 100644 --- a/scripts/templates/exp_feat.yml.mako +++ b/scripts/templates/exp_feat.yml.mako @@ -17,3 +17,10 @@ import datetime type: header desc: "Intel $OneApi Unified Runtime Experimental APIs for ${" ".join(name.split("-")).title()}" ordinal: "99" +--- #-------------------------------------------------------------------------- +type: macro +desc: | + The extension string which defines support for ${name} + which is returned when querying device extensions. +name: $X_${"_".join(name.split("-")).upper()}_EXTENSION_STRING_EXP +value: "\"$x_exp_${"_".join(name.split("-"))}\"" From 3328f87ec0261d65c2f6fcacf3df915b68c79a5a Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Fri, 23 Jun 2023 14:10:44 +0100 Subject: [PATCH 003/104] [UR][CTS] Add urMemImageGetInfo tests and add missing return values to spec --- include/ur_api.h | 11 +++ scripts/core/memory.yml | 12 +++ source/loader/layers/validation/ur_valddi.cpp | 12 +++ source/loader/ur_libapi.cpp | 11 +++ source/ur_api.cpp | 11 +++ test/conformance/memory/urMemImageGetInfo.cpp | 82 +++++++++++++++++++ .../testing/include/uur/fixtures.h | 30 +++++++ 7 files changed, 169 insertions(+) diff --git a/include/ur_api.h b/include/ur_api.h index a719fce5ee..bc8f1fb82f 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -2289,6 +2289,17 @@ urMemGetInfo( /// + `NULL == hMemory` /// - ::UR_RESULT_ERROR_INVALID_ENUMERATION /// + `::UR_IMAGE_INFO_DEPTH < propName` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// + If `propName` is not supported by the adapter. +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `propSize == 0 && pPropValue != NULL` +/// + If `propSize` is less than the real number of bytes needed to return the info. +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `propSize != 0 && pPropValue == NULL` +/// + `pPropValue == NULL && pPropSizeRet == NULL` +/// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY UR_APIEXPORT ur_result_t UR_APICALL urMemImageGetInfo( ur_mem_handle_t hMemory, ///< [in] handle to the image object being queried. diff --git a/scripts/core/memory.yml b/scripts/core/memory.yml index b9c3ef1792..e8b190143c 100644 --- a/scripts/core/memory.yml +++ b/scripts/core/memory.yml @@ -577,3 +577,15 @@ params: name: pPropSizeRet desc: | [out][optional] pointer to the actual size in bytes of the queried propName. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_ENUMERATION: + - "If `propName` is not supported by the adapter." + - $X_RESULT_ERROR_INVALID_SIZE: + - "`propSize == 0 && pPropValue != NULL`" + - "If `propSize` is less than the real number of bytes needed to return the info." + - $X_RESULT_ERROR_INVALID_NULL_POINTER: + - "`propSize != 0 && pPropValue == NULL`" + - "`pPropValue == NULL && pPropSizeRet == NULL`" + - $X_RESULT_ERROR_INVALID_MEM_OBJECT + - $X_RESULT_ERROR_OUT_OF_RESOURCES + - $X_RESULT_ERROR_OUT_OF_HOST_MEMORY diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index 6084954b58..c811674e50 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -1273,9 +1273,21 @@ __urdlllocal ur_result_t UR_APICALL urMemImageGetInfo( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (propSize != 0 && pPropValue == NULL) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + + if (pPropValue == NULL && pPropSizeRet == NULL) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + if (UR_IMAGE_INFO_DEPTH < propName) { return UR_RESULT_ERROR_INVALID_ENUMERATION; } + + if (propSize == 0 && pPropValue != NULL) { + return UR_RESULT_ERROR_INVALID_SIZE; + } } ur_result_t result = diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index 43a81e4a47..a3c87d8a01 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -1488,6 +1488,17 @@ ur_result_t UR_APICALL urMemGetInfo( /// + `NULL == hMemory` /// - ::UR_RESULT_ERROR_INVALID_ENUMERATION /// + `::UR_IMAGE_INFO_DEPTH < propName` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// + If `propName` is not supported by the adapter. +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `propSize == 0 && pPropValue != NULL` +/// + If `propSize` is less than the real number of bytes needed to return the info. +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `propSize != 0 && pPropValue == NULL` +/// + `pPropValue == NULL && pPropSizeRet == NULL` +/// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY ur_result_t UR_APICALL urMemImageGetInfo( ur_mem_handle_t hMemory, ///< [in] handle to the image object being queried. ur_image_info_t propName, ///< [in] type of image info to retrieve. diff --git a/source/ur_api.cpp b/source/ur_api.cpp index 3843c20dca..ecd6555a96 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -1252,6 +1252,17 @@ ur_result_t UR_APICALL urMemGetInfo( /// + `NULL == hMemory` /// - ::UR_RESULT_ERROR_INVALID_ENUMERATION /// + `::UR_IMAGE_INFO_DEPTH < propName` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// + If `propName` is not supported by the adapter. +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `propSize == 0 && pPropValue != NULL` +/// + If `propSize` is less than the real number of bytes needed to return the info. +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `propSize != 0 && pPropValue == NULL` +/// + `pPropValue == NULL && pPropSizeRet == NULL` +/// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY ur_result_t UR_APICALL urMemImageGetInfo( ur_mem_handle_t hMemory, ///< [in] handle to the image object being queried. ur_image_info_t propName, ///< [in] type of image info to retrieve. diff --git a/test/conformance/memory/urMemImageGetInfo.cpp b/test/conformance/memory/urMemImageGetInfo.cpp index 281aa8badb..48e6d6274f 100644 --- a/test/conformance/memory/urMemImageGetInfo.cpp +++ b/test/conformance/memory/urMemImageGetInfo.cpp @@ -2,3 +2,85 @@ // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +using urMemImageGetInfoTest = uur::urMemImageTestWithParam; + +static std::unordered_map image_info_size_map = { + {UR_IMAGE_INFO_FORMAT, sizeof(ur_image_format_t)}, + {UR_IMAGE_INFO_ELEMENT_SIZE, sizeof(size_t)}, + {UR_IMAGE_INFO_ROW_PITCH, sizeof(size_t)}, + {UR_IMAGE_INFO_SLICE_PITCH, sizeof(size_t)}, + {UR_IMAGE_INFO_WIDTH, sizeof(size_t)}, + {UR_IMAGE_INFO_HEIGHT, sizeof(size_t)}, + {UR_IMAGE_INFO_DEPTH, sizeof(size_t)}, +}; + +UUR_TEST_SUITE_P(urMemImageGetInfoTest, + ::testing::Values(UR_IMAGE_INFO_FORMAT, + UR_IMAGE_INFO_ELEMENT_SIZE, + UR_IMAGE_INFO_ROW_PITCH, + UR_IMAGE_INFO_SLICE_PITCH, + UR_IMAGE_INFO_WIDTH, UR_IMAGE_INFO_HEIGHT, + UR_IMAGE_INFO_DEPTH), + uur::deviceTestWithParamPrinter); + +TEST_P(urMemImageGetInfoTest, Success) { + ur_image_info_t info = getParam(); + size_t size; + ASSERT_SUCCESS(urMemImageGetInfo(image, info, 0, nullptr, &size)); + ASSERT_NE(size, 0); + + if (const auto expected_size = image_info_size_map.find(info); + expected_size != image_info_size_map.end()) { + ASSERT_EQ(expected_size->second, size); + } else { + FAIL() << "Missing info value in image info size map"; + } + + std::vector info_data(size); + ASSERT_SUCCESS( + urMemImageGetInfo(image, info, size, info_data.data(), nullptr)); +} + +TEST_P(urMemImageGetInfoTest, InvalidNullHandleImage) { + size_t info_size = 0; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urMemImageGetInfo(nullptr, UR_IMAGE_INFO_FORMAT, + sizeof(size_t), &info_size, nullptr)); +} + +TEST_P(urMemImageGetInfoTest, InvalidEnumerationImageInfoType) { + size_t info_size = 0; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_ENUMERATION, + urMemImageGetInfo(image, UR_IMAGE_INFO_FORCE_UINT32, + sizeof(size_t), &info_size, nullptr)); +} + +TEST_P(urMemImageGetInfoTest, InvalidSizeZero) { + size_t info_size = 0; + ASSERT_EQ_RESULT( + urMemImageGetInfo(image, UR_IMAGE_INFO_FORMAT, 0, &info_size, nullptr), + UR_RESULT_ERROR_INVALID_SIZE); +} + +TEST_P(urMemImageGetInfoTest, InvalidSizeSmall) { + int info_size = 0; + ASSERT_EQ_RESULT(urMemImageGetInfo(image, UR_IMAGE_INFO_FORMAT, + sizeof(info_size) - 1, &info_size, + nullptr), + UR_RESULT_ERROR_INVALID_SIZE); +} + +TEST_P(urMemImageGetInfoTest, InvalidNullPointerParamValue) { + size_t info_size = 0; + ASSERT_EQ_RESULT(urMemImageGetInfo(image, UR_IMAGE_INFO_FORMAT, + sizeof(info_size), nullptr, nullptr), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} + +TEST_P(urMemImageGetInfoTest, InvalidNullPointerPropSizeRet) { + ASSERT_EQ_RESULT( + urMemImageGetInfo(image, UR_IMAGE_INFO_FORMAT, 0, nullptr, nullptr), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} diff --git a/test/conformance/testing/include/uur/fixtures.h b/test/conformance/testing/include/uur/fixtures.h index 8c7adcd2e9..f2a9719537 100644 --- a/test/conformance/testing/include/uur/fixtures.h +++ b/test/conformance/testing/include/uur/fixtures.h @@ -244,6 +244,36 @@ template struct urMemBufferTestWithParam : urContextTestWithParam { ur_mem_handle_t buffer = nullptr; }; +template struct urMemImageTestWithParam : urContextTestWithParam { + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE(urContextTestWithParam::SetUp()); + ASSERT_SUCCESS(urMemImageCreate(this->context, UR_MEM_FLAG_READ_WRITE, + &format, &desc, nullptr, &image)); + ASSERT_NE(nullptr, image); + } + + void TearDown() override { + if (image) { + EXPECT_SUCCESS(urMemRelease(image)); + } + UUR_RETURN_ON_FATAL_FAILURE(urContextTestWithParam::TearDown()); + } + ur_mem_handle_t image = nullptr; + ur_image_format_t format = {UR_IMAGE_CHANNEL_ORDER_RGBA, + UR_IMAGE_CHANNEL_TYPE_FLOAT}; + ur_image_desc_t desc = {UR_STRUCTURE_TYPE_IMAGE_DESC, // stype + nullptr, // pNext + UR_MEM_TYPE_IMAGE1D, // mem object type + 1024, // image width + 1, // image height + 1, // image depth + 1, // array size + 0, // row pitch + 0, // slice pitch + 0, // mip levels + 0}; // num samples +}; + struct urQueueTest : urContextTest { void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urContextTest::SetUp()); From 95a5fb4033285b5fe1b9f09fc0304c4192048881 Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Mon, 26 Jun 2023 11:46:19 +0100 Subject: [PATCH 004/104] [UR][CTS] Fix urKernelSetArgPointer tests --- test/conformance/kernel/urKernelSetArgPointer.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/conformance/kernel/urKernelSetArgPointer.cpp b/test/conformance/kernel/urKernelSetArgPointer.cpp index dfe1085990..4cb4cb2c8f 100644 --- a/test/conformance/kernel/urKernelSetArgPointer.cpp +++ b/test/conformance/kernel/urKernelSetArgPointer.cpp @@ -43,7 +43,8 @@ TEST_P(urKernelSetArgPointerTest, SuccessHost) { ASSERT_NE(allocation, nullptr); ASSERT_SUCCESS(urKernelSetArgPointer(kernel, 0, nullptr, &allocation)); - ASSERT_SUCCESS(urKernelSetArgValue(kernel, 1, sizeof(data), &data)); + ASSERT_SUCCESS( + urKernelSetArgValue(kernel, 1, sizeof(data), nullptr, &data)); Launch1DRange(array_size); ValidateAllocation(allocation); } @@ -60,7 +61,8 @@ TEST_P(urKernelSetArgPointerTest, SuccessDevice) { ASSERT_NE(allocation, nullptr); ASSERT_SUCCESS(urKernelSetArgPointer(kernel, 0, nullptr, &allocation)); - ASSERT_SUCCESS(urKernelSetArgValue(kernel, 1, sizeof(data), &data)); + ASSERT_SUCCESS( + urKernelSetArgValue(kernel, 1, sizeof(data), nullptr, &data)); Launch1DRange(array_size); // Copy the device allocation to a host one so we can validate the results. @@ -86,7 +88,8 @@ TEST_P(urKernelSetArgPointerTest, SuccessShared) { ASSERT_NE(allocation, nullptr); ASSERT_SUCCESS(urKernelSetArgPointer(kernel, 0, nullptr, &allocation)); - ASSERT_SUCCESS(urKernelSetArgValue(kernel, 1, sizeof(data), &data)); + ASSERT_SUCCESS( + urKernelSetArgValue(kernel, 1, sizeof(data), nullptr, &data)); Launch1DRange(array_size); ValidateAllocation(allocation); } From 15a2da0f5cd52b276c68fdb93939c2f0d26df12a Mon Sep 17 00:00:00 2001 From: initial Date: Mon, 26 Jun 2023 13:36:44 +0100 Subject: [PATCH 005/104] [UR] Device CTS fixes --- test/conformance/device/urDeviceGet.cpp | 2 +- test/conformance/device/urDeviceGetInfo.cpp | 3 +-- test/conformance/device/urDeviceRelease.cpp | 6 ++++++ test/conformance/device/urDeviceRetain.cpp | 6 ++++++ test/conformance/device/urDeviceSelectBinary.cpp | 2 +- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/test/conformance/device/urDeviceGet.cpp b/test/conformance/device/urDeviceGet.cpp index 9b053f1f46..85a4818d09 100644 --- a/test/conformance/device/urDeviceGet.cpp +++ b/test/conformance/device/urDeviceGet.cpp @@ -56,6 +56,6 @@ TEST_F(urDeviceGetTest, InvalidValueNumEntries) { ASSERT_NE(count, 0); std::vector devices(count); ASSERT_EQ_RESULT( - UR_RESULT_ERROR_INVALID_VALUE, + UR_RESULT_ERROR_INVALID_SIZE, urDeviceGet(platform, UR_DEVICE_TYPE_ALL, 0, devices.data(), nullptr)); } diff --git a/test/conformance/device/urDeviceGetInfo.cpp b/test/conformance/device/urDeviceGetInfo.cpp index bbe08fe6d8..eb8321b7b4 100644 --- a/test/conformance/device/urDeviceGetInfo.cpp +++ b/test/conformance/device/urDeviceGetInfo.cpp @@ -13,7 +13,6 @@ static std::unordered_map device_info_size_map = { {UR_DEVICE_INFO_MAX_COMPUTE_UNITS, sizeof(uint32_t)}, {UR_DEVICE_INFO_MAX_WORK_ITEM_DIMENSIONS, sizeof(uint32_t)}, {UR_DEVICE_INFO_MAX_WORK_GROUP_SIZE, sizeof(size_t)}, - {UR_DEVICE_INFO_MAX_WORK_GROUP_SIZE, sizeof(size_t)}, {UR_DEVICE_INFO_SINGLE_FP_CONFIG, sizeof(ur_device_fp_capability_flags_t)}, {UR_DEVICE_INFO_HALF_FP_CONFIG, sizeof(ur_device_fp_capability_flags_t)}, {UR_DEVICE_INFO_DOUBLE_FP_CONFIG, sizeof(ur_device_fp_capability_flags_t)}, @@ -258,7 +257,7 @@ TEST_P(urDeviceGetInfoTest, Success) { ASSERT_SUCCESS(urDeviceGetInfo(device, info_type, size, info_data.data(), nullptr)); } else { - ASSERT_EQ_RESULT(result, UR_RESULT_ERROR_INVALID_ENUMERATION); + ASSERT_EQ_RESULT(result, UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION); } } } diff --git a/test/conformance/device/urDeviceRelease.cpp b/test/conformance/device/urDeviceRelease.cpp index 300f646851..3b5e74a575 100644 --- a/test/conformance/device/urDeviceRelease.cpp +++ b/test/conformance/device/urDeviceRelease.cpp @@ -26,6 +26,12 @@ TEST_F(urDeviceReleaseTest, Success) { TEST_F(urDeviceReleaseTest, SuccessSubdevices) { for (auto device : devices) { + if (!uur::hasDevicePartitionSupport(device, + UR_DEVICE_PARTITION_EQUALLY)) { + ::testing::Message() << "Device: \'" << device + << "\' does not support partitioning equally."; + continue; + } ur_device_partition_property_t prop = uur::makePartitionEquallyDesc(1); diff --git a/test/conformance/device/urDeviceRetain.cpp b/test/conformance/device/urDeviceRetain.cpp index e5999ba24b..77a9c58b79 100644 --- a/test/conformance/device/urDeviceRetain.cpp +++ b/test/conformance/device/urDeviceRetain.cpp @@ -27,6 +27,12 @@ TEST_F(urDeviceRetainTest, Success) { TEST_F(urDeviceRetainTest, SuccessSubdevices) { for (auto device : devices) { + if (!uur::hasDevicePartitionSupport(device, + UR_DEVICE_PARTITION_EQUALLY)) { + ::testing::Message() << "Device: \'" << device + << "\' does not support partitioning equally."; + continue; + } ur_device_partition_property_t prop = uur::makePartitionEquallyDesc(1); ur_device_partition_properties_t properties{ diff --git a/test/conformance/device/urDeviceSelectBinary.cpp b/test/conformance/device/urDeviceSelectBinary.cpp index 34d008a3cd..44d32e3c6d 100644 --- a/test/conformance/device/urDeviceSelectBinary.cpp +++ b/test/conformance/device/urDeviceSelectBinary.cpp @@ -56,7 +56,7 @@ TEST_F(urDeviceSelectBinaryTest, InvalidValueNumBinaries) { for (auto device : devices) { uint32_t selected_binary; ASSERT_EQ_RESULT( - UR_RESULT_ERROR_INVALID_VALUE, + UR_RESULT_ERROR_INVALID_SIZE, urDeviceSelectBinary(device, binaries, 0, &selected_binary)); } } From 6f940e39e540f7944f3a6250d6ec6ad7ac4b7d9a Mon Sep 17 00:00:00 2001 From: Przemek Malon Date: Tue, 27 Jun 2023 11:13:53 +0100 Subject: [PATCH 006/104] [Exp][Bindless Images] Add BI revision 4 functionality - Added bindless images revision 4 API changes - Fixed some errors from revision 3 Co-authored-by: Isaac Ault Co-authored-by: Przemek Malon --- include/ur.py | 87 ++++++------ include/ur_api.h | 110 +++++++++++---- include/ur_ddi.h | 21 ++- scripts/core/EXP-BINDLESS-IMAGES.rst | 16 ++- scripts/core/exp-bindless-images.yml | 95 ++++++++++--- source/adapters/null/ur_nullddi.cpp | 82 +++++++---- source/common/ur_params.hpp | 116 +++++++++++++--- source/loader/layers/tracing/ur_trcddi.cpp | 114 ++++++++++------ source/loader/layers/validation/ur_valddi.cpp | 128 ++++++++++++++---- source/loader/ur_ldrddi.cpp | 123 +++++++++++++---- source/loader/ur_libapi.cpp | 88 ++++++++---- source/ur_api.cpp | 50 ++++++- 12 files changed, 759 insertions(+), 271 deletions(-) diff --git a/include/ur.py b/include/ur.py index f70649998b..ba756f07e9 100644 --- a/include/ur.py +++ b/include/ur.py @@ -590,31 +590,29 @@ class ur_device_info_v(IntEnum): ## bindless images backed by USM BINDLESS_IMAGES_2D_USM_SUPPORT_EXP = 0x2002 ## [::ur_bool_t] returns true if the device supports the creation of 2D ## bindless images backed by USM - BINDLESS_IMAGES_3D_USM_SUPPORT_EXP = 0x2003 ## [::ur_bool_t] returns true if the device supports the creation of 3D - ## bindless images backed by USM - IMAGE_PITCH_ALIGN_EXP = 0x2004 ## [uint32_t] returns the required alignment of the pitch between two + IMAGE_PITCH_ALIGN_EXP = 0x2003 ## [uint32_t] returns the required alignment of the pitch between two ## rows of an image in bytes - MAX_IMAGE_LINEAR_WIDTH_EXP = 0x2005 ## [size_t] returns the maximum linear width allowed for images allocated + MAX_IMAGE_LINEAR_WIDTH_EXP = 0x2004 ## [size_t] returns the maximum linear width allowed for images allocated ## using USM - MAX_IMAGE_LINEAR_HEIGHT_EXP = 0x2006 ## [size_t] returns the maximum linear height allowed for images + MAX_IMAGE_LINEAR_HEIGHT_EXP = 0x2005 ## [size_t] returns the maximum linear height allowed for images ## allocated using USM - MAX_IMAGE_LINEAR_PITCH_EXP = 0x2007 ## [size_t] returns the maximum linear pitch allowed for images allocated + MAX_IMAGE_LINEAR_PITCH_EXP = 0x2006 ## [size_t] returns the maximum linear pitch allowed for images allocated ## using USM - MIPMAP_SUPPORT_EXP = 0x2008 ## [::ur_bool_t] returns true if the device supports allocating mipmap + MIPMAP_SUPPORT_EXP = 0x2007 ## [::ur_bool_t] returns true if the device supports allocating mipmap ## resources - MIPMAP_ANISOTROPY_SUPPORT_EXP = 0x2009 ## [::ur_bool_t] returns true if the device supports sampling mipmap + MIPMAP_ANISOTROPY_SUPPORT_EXP = 0x2008 ## [::ur_bool_t] returns true if the device supports sampling mipmap ## images with anisotropic filtering - MIPMAP_MAX_ANISOTROPY_EXP = 0x200A ## [uint32_t] returns the maximum anisotropic ratio supported by the + MIPMAP_MAX_ANISOTROPY_EXP = 0x2009 ## [uint32_t] returns the maximum anisotropic ratio supported by the ## device - MIPMAP_LEVEL_REFERENCE_SUPPORT_EXP = 0x200B ## [::ur_bool_t] returns true if the device supports using images created + MIPMAP_LEVEL_REFERENCE_SUPPORT_EXP = 0x200A ## [::ur_bool_t] returns true if the device supports using images created ## from individual mipmap levels - INTEROP_MEMORY_IMPORT_SUPPORT_EXP = 0x200C ## [::ur_bool_t] returns true if the device supports importing external + INTEROP_MEMORY_IMPORT_SUPPORT_EXP = 0x200B ## [::ur_bool_t] returns true if the device supports importing external ## memory resources - INTEROP_MEMORY_EXPORT_SUPPORT_EXP = 0x200D ## [::ur_bool_t] returns true if the device supports exporting internal + INTEROP_MEMORY_EXPORT_SUPPORT_EXP = 0x200C ## [::ur_bool_t] returns true if the device supports exporting internal ## memory resources - INTEROP_SEMAPHORE_IMPORT_SUPPORT_EXP = 0x200E ## [::ur_bool_t] returns true if the device supports importing external + INTEROP_SEMAPHORE_IMPORT_SUPPORT_EXP = 0x200D ## [::ur_bool_t] returns true if the device supports importing external ## semaphore resources - INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP = 0x200F ## [::ur_bool_t] returns true if the device supports exporting internal + INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP = 0x200E ## [::ur_bool_t] returns true if the device supports exporting internal ## event resources class ur_device_info_t(c_int): @@ -2086,7 +2084,7 @@ class ur_exp_interop_semaphore_handle_t(c_void_p): ############################################################################### ## @brief Dictates the type of memory copy. class ur_exp_image_copy_flags_v(IntEnum): - HOST_TO_DEVICE = UR_BIT(0) ## Host to device. + HOST_TO_DEVICE = UR_BIT(0) ## Host to device DEVICE_TO_HOST = UR_BIT(1) ## Device to host DEVICE_TO_DEVICE = UR_BIT(2) ## Device to device @@ -2110,8 +2108,9 @@ class ur_exp_sampler_mip_properties_t(Structure): ## being 0 ("maxMipmapLevelClamp", c_float), ## [in] maximum mipmap level from which we can sample, maximum value ## being the number of levels - ("maxAnistropy", c_float) ## [in] anisotropic ratio used when samplling the mipmap with anisotropic + ("maxAnisotropy", c_float), ## [in] anisotropic ratio used when samplling the mipmap with anisotropic ## filtering + ("mipFilterMode", ur_sampler_filter_mode_t) ## [in] mipmap filter mode used for filtering between mipmap levels ] ############################################################################### @@ -3044,51 +3043,51 @@ class ur_queue_dditable_t(Structure): ############################################################################### ## @brief Function-pointer for urBindlessImagesUnsampledImageHandleDestroyExp if __use_win_types: - _urBindlessImagesUnsampledImageHandleDestroyExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_image_handle_t ) + _urBindlessImagesUnsampledImageHandleDestroyExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_image_handle_t ) else: - _urBindlessImagesUnsampledImageHandleDestroyExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_image_handle_t ) + _urBindlessImagesUnsampledImageHandleDestroyExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_image_handle_t ) ############################################################################### ## @brief Function-pointer for urBindlessImagesSampledImageHandleDestroyExp if __use_win_types: - _urBindlessImagesSampledImageHandleDestroyExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_image_handle_t ) + _urBindlessImagesSampledImageHandleDestroyExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_image_handle_t ) else: - _urBindlessImagesSampledImageHandleDestroyExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_image_handle_t ) + _urBindlessImagesSampledImageHandleDestroyExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_image_handle_t ) ############################################################################### ## @brief Function-pointer for urBindlessImagesImageAllocateExp if __use_win_types: - _urBindlessImagesImageAllocateExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), POINTER(ur_exp_image_mem_handle_t) ) + _urBindlessImagesImageAllocateExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), POINTER(ur_exp_image_mem_handle_t) ) else: - _urBindlessImagesImageAllocateExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), POINTER(ur_exp_image_mem_handle_t) ) + _urBindlessImagesImageAllocateExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), POINTER(ur_exp_image_mem_handle_t) ) ############################################################################### ## @brief Function-pointer for urBindlessImagesImageFreeExp if __use_win_types: - _urBindlessImagesImageFreeExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_image_mem_handle_t ) + _urBindlessImagesImageFreeExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_image_mem_handle_t ) else: - _urBindlessImagesImageFreeExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_image_mem_handle_t ) + _urBindlessImagesImageFreeExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_image_mem_handle_t ) ############################################################################### ## @brief Function-pointer for urBindlessImagesUnsampledImageCreateExp if __use_win_types: - _urBindlessImagesUnsampledImageCreateExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_image_mem_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), POINTER(ur_mem_handle_t), POINTER(ur_exp_image_handle_t) ) + _urBindlessImagesUnsampledImageCreateExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_image_mem_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), POINTER(ur_mem_handle_t), POINTER(ur_exp_image_handle_t) ) else: - _urBindlessImagesUnsampledImageCreateExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_image_mem_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), POINTER(ur_mem_handle_t), POINTER(ur_exp_image_handle_t) ) + _urBindlessImagesUnsampledImageCreateExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_image_mem_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), POINTER(ur_mem_handle_t), POINTER(ur_exp_image_handle_t) ) ############################################################################### ## @brief Function-pointer for urBindlessImagesSampledImageCreateExp if __use_win_types: - _urBindlessImagesSampledImageCreateExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_image_mem_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), ur_sampler_handle_t, POINTER(ur_mem_handle_t), POINTER(ur_exp_image_handle_t) ) + _urBindlessImagesSampledImageCreateExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_image_mem_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), ur_sampler_handle_t, POINTER(ur_mem_handle_t), POINTER(ur_exp_image_handle_t) ) else: - _urBindlessImagesSampledImageCreateExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_image_mem_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), ur_sampler_handle_t, POINTER(ur_mem_handle_t), POINTER(ur_exp_image_handle_t) ) + _urBindlessImagesSampledImageCreateExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_image_mem_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), ur_sampler_handle_t, POINTER(ur_mem_handle_t), POINTER(ur_exp_image_handle_t) ) ############################################################################### ## @brief Function-pointer for urBindlessImagesImageCopyExp if __use_win_types: - _urBindlessImagesImageCopyExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, c_void_p, c_void_p, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), ur_exp_image_copy_flags_t, c_ulong, POINTER(ur_event_handle_t), POINTER(ur_event_handle_t) ) + _urBindlessImagesImageCopyExp_t = WINFUNCTYPE( ur_result_t, ur_queue_handle_t, c_void_p, c_void_p, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), ur_exp_image_copy_flags_t, ur_rect_offset_t, ur_rect_offset_t, ur_rect_region_t, ur_rect_region_t, c_ulong, POINTER(ur_event_handle_t), POINTER(ur_event_handle_t) ) else: - _urBindlessImagesImageCopyExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, c_void_p, c_void_p, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), ur_exp_image_copy_flags_t, c_ulong, POINTER(ur_event_handle_t), POINTER(ur_event_handle_t) ) + _urBindlessImagesImageCopyExp_t = CFUNCTYPE( ur_result_t, ur_queue_handle_t, c_void_p, c_void_p, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), ur_exp_image_copy_flags_t, ur_rect_offset_t, ur_rect_offset_t, ur_rect_region_t, ur_rect_region_t, c_ulong, POINTER(ur_event_handle_t), POINTER(ur_event_handle_t) ) ############################################################################### ## @brief Function-pointer for urBindlessImagesImageGetInfoExp @@ -3100,51 +3099,51 @@ class ur_queue_dditable_t(Structure): ############################################################################### ## @brief Function-pointer for urBindlessImagesMipmapGetLevelExp if __use_win_types: - _urBindlessImagesMipmapGetLevelExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_image_mem_handle_t, c_ulong, POINTER(ur_exp_image_mem_handle_t) ) + _urBindlessImagesMipmapGetLevelExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_image_mem_handle_t, c_ulong, POINTER(ur_exp_image_mem_handle_t) ) else: - _urBindlessImagesMipmapGetLevelExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_image_mem_handle_t, c_ulong, POINTER(ur_exp_image_mem_handle_t) ) + _urBindlessImagesMipmapGetLevelExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_image_mem_handle_t, c_ulong, POINTER(ur_exp_image_mem_handle_t) ) ############################################################################### ## @brief Function-pointer for urBindlessImagesMipmapFreeExp if __use_win_types: - _urBindlessImagesMipmapFreeExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_image_mem_handle_t ) + _urBindlessImagesMipmapFreeExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_image_mem_handle_t ) else: - _urBindlessImagesMipmapFreeExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_image_mem_handle_t ) + _urBindlessImagesMipmapFreeExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_image_mem_handle_t ) ############################################################################### ## @brief Function-pointer for urBindlessImagesImportOpaqueFDExp if __use_win_types: - _urBindlessImagesImportOpaqueFDExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, c_size_t, c_ulong, POINTER(ur_exp_interop_mem_handle_t) ) + _urBindlessImagesImportOpaqueFDExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, c_size_t, c_ulong, POINTER(ur_exp_interop_mem_handle_t) ) else: - _urBindlessImagesImportOpaqueFDExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, c_size_t, c_ulong, POINTER(ur_exp_interop_mem_handle_t) ) + _urBindlessImagesImportOpaqueFDExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, c_size_t, c_ulong, POINTER(ur_exp_interop_mem_handle_t) ) ############################################################################### ## @brief Function-pointer for urBindlessImagesMapExternalArrayExp if __use_win_types: - _urBindlessImagesMapExternalArrayExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), ur_exp_interop_mem_handle_t, POINTER(ur_exp_image_handle_t) ) + _urBindlessImagesMapExternalArrayExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), ur_exp_interop_mem_handle_t, POINTER(ur_exp_image_mem_handle_t) ) else: - _urBindlessImagesMapExternalArrayExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), ur_exp_interop_mem_handle_t, POINTER(ur_exp_image_handle_t) ) + _urBindlessImagesMapExternalArrayExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), ur_exp_interop_mem_handle_t, POINTER(ur_exp_image_mem_handle_t) ) ############################################################################### ## @brief Function-pointer for urBindlessImagesReleaseInteropExp if __use_win_types: - _urBindlessImagesReleaseInteropExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_interop_mem_handle_t ) + _urBindlessImagesReleaseInteropExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_interop_mem_handle_t ) else: - _urBindlessImagesReleaseInteropExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_interop_mem_handle_t ) + _urBindlessImagesReleaseInteropExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_interop_mem_handle_t ) ############################################################################### ## @brief Function-pointer for urBindlessImagesImportExternalSemaphoreOpaqueFDExp if __use_win_types: - _urBindlessImagesImportExternalSemaphoreOpaqueFDExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, c_ulong, POINTER(ur_exp_interop_semaphore_handle_t) ) + _urBindlessImagesImportExternalSemaphoreOpaqueFDExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, c_ulong, POINTER(ur_exp_interop_semaphore_handle_t) ) else: - _urBindlessImagesImportExternalSemaphoreOpaqueFDExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, c_ulong, POINTER(ur_exp_interop_semaphore_handle_t) ) + _urBindlessImagesImportExternalSemaphoreOpaqueFDExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, c_ulong, POINTER(ur_exp_interop_semaphore_handle_t) ) ############################################################################### ## @brief Function-pointer for urBindlessImagesDestroyExternalSemaphoreExp if __use_win_types: - _urBindlessImagesDestroyExternalSemaphoreExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_interop_semaphore_handle_t ) + _urBindlessImagesDestroyExternalSemaphoreExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_interop_semaphore_handle_t ) else: - _urBindlessImagesDestroyExternalSemaphoreExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_interop_semaphore_handle_t ) + _urBindlessImagesDestroyExternalSemaphoreExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_interop_semaphore_handle_t ) ############################################################################### ## @brief Function-pointer for urBindlessImagesWaitExternalSemaphoreExp diff --git a/include/ur_api.h b/include/ur_api.h index 2f15f4e1d1..cd0d72740a 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -977,31 +977,29 @@ typedef enum ur_device_info_t { ///< bindless images backed by USM UR_DEVICE_INFO_BINDLESS_IMAGES_2D_USM_SUPPORT_EXP = 0x2002, ///< [::ur_bool_t] returns true if the device supports the creation of 2D ///< bindless images backed by USM - UR_DEVICE_INFO_BINDLESS_IMAGES_3D_USM_SUPPORT_EXP = 0x2003, ///< [::ur_bool_t] returns true if the device supports the creation of 3D - ///< bindless images backed by USM - UR_DEVICE_INFO_IMAGE_PITCH_ALIGN_EXP = 0x2004, ///< [uint32_t] returns the required alignment of the pitch between two + UR_DEVICE_INFO_IMAGE_PITCH_ALIGN_EXP = 0x2003, ///< [uint32_t] returns the required alignment of the pitch between two ///< rows of an image in bytes - UR_DEVICE_INFO_MAX_IMAGE_LINEAR_WIDTH_EXP = 0x2005, ///< [size_t] returns the maximum linear width allowed for images allocated + UR_DEVICE_INFO_MAX_IMAGE_LINEAR_WIDTH_EXP = 0x2004, ///< [size_t] returns the maximum linear width allowed for images allocated ///< using USM - UR_DEVICE_INFO_MAX_IMAGE_LINEAR_HEIGHT_EXP = 0x2006, ///< [size_t] returns the maximum linear height allowed for images + UR_DEVICE_INFO_MAX_IMAGE_LINEAR_HEIGHT_EXP = 0x2005, ///< [size_t] returns the maximum linear height allowed for images ///< allocated using USM - UR_DEVICE_INFO_MAX_IMAGE_LINEAR_PITCH_EXP = 0x2007, ///< [size_t] returns the maximum linear pitch allowed for images allocated + UR_DEVICE_INFO_MAX_IMAGE_LINEAR_PITCH_EXP = 0x2006, ///< [size_t] returns the maximum linear pitch allowed for images allocated ///< using USM - UR_DEVICE_INFO_MIPMAP_SUPPORT_EXP = 0x2008, ///< [::ur_bool_t] returns true if the device supports allocating mipmap + UR_DEVICE_INFO_MIPMAP_SUPPORT_EXP = 0x2007, ///< [::ur_bool_t] returns true if the device supports allocating mipmap ///< resources - UR_DEVICE_INFO_MIPMAP_ANISOTROPY_SUPPORT_EXP = 0x2009, ///< [::ur_bool_t] returns true if the device supports sampling mipmap + UR_DEVICE_INFO_MIPMAP_ANISOTROPY_SUPPORT_EXP = 0x2008, ///< [::ur_bool_t] returns true if the device supports sampling mipmap ///< images with anisotropic filtering - UR_DEVICE_INFO_MIPMAP_MAX_ANISOTROPY_EXP = 0x200A, ///< [uint32_t] returns the maximum anisotropic ratio supported by the + UR_DEVICE_INFO_MIPMAP_MAX_ANISOTROPY_EXP = 0x2009, ///< [uint32_t] returns the maximum anisotropic ratio supported by the ///< device - UR_DEVICE_INFO_MIPMAP_LEVEL_REFERENCE_SUPPORT_EXP = 0x200B, ///< [::ur_bool_t] returns true if the device supports using images created + UR_DEVICE_INFO_MIPMAP_LEVEL_REFERENCE_SUPPORT_EXP = 0x200A, ///< [::ur_bool_t] returns true if the device supports using images created ///< from individual mipmap levels - UR_DEVICE_INFO_INTEROP_MEMORY_IMPORT_SUPPORT_EXP = 0x200C, ///< [::ur_bool_t] returns true if the device supports importing external + UR_DEVICE_INFO_INTEROP_MEMORY_IMPORT_SUPPORT_EXP = 0x200B, ///< [::ur_bool_t] returns true if the device supports importing external ///< memory resources - UR_DEVICE_INFO_INTEROP_MEMORY_EXPORT_SUPPORT_EXP = 0x200D, ///< [::ur_bool_t] returns true if the device supports exporting internal + UR_DEVICE_INFO_INTEROP_MEMORY_EXPORT_SUPPORT_EXP = 0x200C, ///< [::ur_bool_t] returns true if the device supports exporting internal ///< memory resources - UR_DEVICE_INFO_INTEROP_SEMAPHORE_IMPORT_SUPPORT_EXP = 0x200E, ///< [::ur_bool_t] returns true if the device supports importing external + UR_DEVICE_INFO_INTEROP_SEMAPHORE_IMPORT_SUPPORT_EXP = 0x200D, ///< [::ur_bool_t] returns true if the device supports importing external ///< semaphore resources - UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP = 0x200F, ///< [::ur_bool_t] returns true if the device supports exporting internal + UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP = 0x200E, ///< [::ur_bool_t] returns true if the device supports exporting internal ///< event resources /// @cond UR_DEVICE_INFO_FORCE_UINT32 = 0x7fffffff @@ -6578,7 +6576,7 @@ typedef struct ur_exp_interop_semaphore_handle_t_ *ur_exp_interop_semaphore_hand /// @brief Dictates the type of memory copy. typedef uint32_t ur_exp_image_copy_flags_t; typedef enum ur_exp_image_copy_flag_t { - UR_EXP_IMAGE_COPY_FLAG_HOST_TO_DEVICE = UR_BIT(0), ///< Host to device. + UR_EXP_IMAGE_COPY_FLAG_HOST_TO_DEVICE = UR_BIT(0), ///< Host to device UR_EXP_IMAGE_COPY_FLAG_DEVICE_TO_HOST = UR_BIT(1), ///< Device to host UR_EXP_IMAGE_COPY_FLAG_DEVICE_TO_DEVICE = UR_BIT(2), ///< Device to device /// @cond @@ -6596,15 +6594,16 @@ typedef enum ur_exp_image_copy_flag_t { /// - Specify these properties in ::urSamplerCreate via ::ur_sampler_desc_t /// as part of a `pNext` chain. typedef struct ur_exp_sampler_mip_properties_t { - ur_structure_type_t stype; ///< [in] type of this structure, must be - ///< ::UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES - void *pNext; ///< [in,out][optional] pointer to extension-specific structure - float minMipmapLevelClamp; ///< [in] minimum mipmap level from which we can sample, minimum value - ///< being 0 - float maxMipmapLevelClamp; ///< [in] maximum mipmap level from which we can sample, maximum value - ///< being the number of levels - float maxAnistropy; ///< [in] anisotropic ratio used when samplling the mipmap with anisotropic - ///< filtering + ur_structure_type_t stype; ///< [in] type of this structure, must be + ///< ::UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES + void *pNext; ///< [in,out][optional] pointer to extension-specific structure + float minMipmapLevelClamp; ///< [in] minimum mipmap level from which we can sample, minimum value + ///< being 0 + float maxMipmapLevelClamp; ///< [in] maximum mipmap level from which we can sample, maximum value + ///< being the number of levels + float maxAnisotropy; ///< [in] anisotropic ratio used when samplling the mipmap with anisotropic + ///< filtering + ur_sampler_filter_mode_t mipFilterMode; ///< [in] mipmap filter mode used for filtering between mipmap levels } ur_exp_sampler_mip_properties_t; @@ -6676,12 +6675,14 @@ urUSMPitchedAllocExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImage` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesUnsampledImageHandleDestroyExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_handle_t hImage ///< [in] pointer to handle of image object to destroy ); @@ -6699,12 +6700,14 @@ urBindlessImagesUnsampledImageHandleDestroyExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImage` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesSampledImageHandleDestroyExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_handle_t hImage ///< [in] pointer to handle of image object to destroy ); @@ -6723,6 +6726,7 @@ urBindlessImagesSampledImageHandleDestroyExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pImageFormat` /// + `NULL == pImageDesc` @@ -6736,6 +6740,7 @@ urBindlessImagesSampledImageHandleDestroyExp( UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_image_mem_handle_t *phImageMem ///< [out] pointer to handle of image memory allocated @@ -6755,12 +6760,14 @@ urBindlessImagesImageAllocateExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImageMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageFreeExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem ///< [in] handle of image memory to be freed ); @@ -6778,6 +6785,7 @@ urBindlessImagesImageFreeExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImageMem` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pImageFormat` @@ -6793,6 +6801,7 @@ urBindlessImagesImageFreeExp( UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] handle to memory from which to create the image const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description @@ -6814,6 +6823,7 @@ urBindlessImagesUnsampledImageCreateExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImageMem` /// + `NULL == hSampler` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER @@ -6831,6 +6841,7 @@ urBindlessImagesUnsampledImageCreateExp( UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] handle to memory from which to create the image const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description @@ -6855,7 +6866,7 @@ urBindlessImagesSampledImageCreateExp( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hContext` +/// + `NULL == hQueue` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pDst` /// + `NULL == pSrc` @@ -6863,7 +6874,7 @@ urBindlessImagesSampledImageCreateExp( /// + `NULL == pImageDesc` /// - ::UR_RESULT_ERROR_INVALID_ENUMERATION /// + `::UR_EXP_IMAGE_COPY_FLAGS_MASK & imageCopyFlags` -/// - ::UR_RESULT_ERROR_INVALID_CONTEXT +/// - ::UR_RESULT_ERROR_INVALID_QUEUE /// - ::UR_RESULT_ERROR_INVALID_VALUE /// - ::UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR /// + `pImageDesc && UR_MEM_TYPE_IMAGE1D_BUFFER < pImageDesc->type` @@ -6871,12 +6882,20 @@ urBindlessImagesSampledImageCreateExp( /// - ::UR_RESULT_ERROR_INVALID_OPERATION UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp( - ur_context_handle_t hContext, ///< [in] handle of the context object + ur_queue_handle_t hQueue, ///< [in] handle of the queue object void *pDst, ///< [in] location the data will be copied to void *pSrc, ///< [in] location the data will be copied from const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_image_copy_flags_t imageCopyFlags, ///< [in] flags describing copy direction e.g. H2D or D2H + ur_rect_offset_t srcOffset, ///< [in] defines the (x,y,z) source offset in pixels in the 1D, 2D, or 3D + ///< image + ur_rect_offset_t dstOffset, ///< [in] defines the (x,y,z) destination offset in pixels in the 1D, 2D, + ///< or 3D image + ur_rect_region_t copyExtent, ///< [in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D + ///< region to copy + ur_rect_region_t hostExtent, ///< [in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D + ///< region on the host uint32_t numEventsInWaitList, ///< [in] size of the event wait list const ur_event_handle_t *phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] pointer to a list of ///< events that must be complete before this command can be executed. @@ -6930,6 +6949,7 @@ urBindlessImagesImageGetInfoExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImageMem` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phImageMem` @@ -6938,6 +6958,7 @@ urBindlessImagesImageGetInfoExp( UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] memory handle to the mipmap image uint32_t mipmapLevel, ///< [in] requested level of the mipmap ur_exp_image_mem_handle_t *phImageMem ///< [out] returning memory handle to the individual image @@ -6957,12 +6978,14 @@ urBindlessImagesMipmapGetLevelExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hMem ///< [in] handle of image memory to be freed ); @@ -6980,6 +7003,7 @@ urBindlessImagesMipmapFreeExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phInteropMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT @@ -6988,6 +7012,7 @@ urBindlessImagesMipmapFreeExp( UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object size_t size, ///< [in] size of the external memory uint32_t fileDescriptor, ///< [in] the file descriptor ur_exp_interop_mem_handle_t *phInteropMem ///< [out] interop memory handle to the external memory @@ -7003,6 +7028,7 @@ urBindlessImagesImportOpaqueFDExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hInteropMem` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pImageFormat` @@ -7018,10 +7044,11 @@ urBindlessImagesImportOpaqueFDExp( UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_interop_mem_handle_t hInteropMem, ///< [in] interop memory handle to the external memory - ur_exp_image_handle_t *phImageMem ///< [out] image memory handle to the externally allocated memory + ur_exp_image_mem_handle_t *phImageMem ///< [out] image memory handle to the externally allocated memory ); /////////////////////////////////////////////////////////////////////////////// @@ -7038,12 +7065,14 @@ urBindlessImagesMapExternalArrayExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hInteropMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_mem_handle_t hInteropMem ///< [in] handle of interop memory to be freed ); @@ -7061,6 +7090,7 @@ urBindlessImagesReleaseInteropExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phInteropSemaphoreHandle` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT @@ -7068,6 +7098,7 @@ urBindlessImagesReleaseInteropExp( UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object uint32_t fileDescriptor, ///< [in] the file descriptor ur_exp_interop_semaphore_handle_t *phInteropSemaphoreHandle ///< [out] interop semaphore handle to the external semaphore ); @@ -7086,12 +7117,14 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hInteropSemaphore` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_semaphore_handle_t hInteropSemaphore ///< [in] handle of interop semaphore to be destroyed ); @@ -9011,6 +9044,7 @@ typedef struct ur_queue_flush_params_t { /// allowing the callback the ability to modify the parameter's value typedef struct ur_bindless_images_unsampled_image_handle_destroy_exp_params_t { ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; ur_exp_image_handle_t *phImage; } ur_bindless_images_unsampled_image_handle_destroy_exp_params_t; @@ -9020,6 +9054,7 @@ typedef struct ur_bindless_images_unsampled_image_handle_destroy_exp_params_t { /// allowing the callback the ability to modify the parameter's value typedef struct ur_bindless_images_sampled_image_handle_destroy_exp_params_t { ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; ur_exp_image_handle_t *phImage; } ur_bindless_images_sampled_image_handle_destroy_exp_params_t; @@ -9029,6 +9064,7 @@ typedef struct ur_bindless_images_sampled_image_handle_destroy_exp_params_t { /// allowing the callback the ability to modify the parameter's value typedef struct ur_bindless_images_image_allocate_exp_params_t { ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; const ur_image_format_t **ppImageFormat; const ur_image_desc_t **ppImageDesc; ur_exp_image_mem_handle_t **pphImageMem; @@ -9040,6 +9076,7 @@ typedef struct ur_bindless_images_image_allocate_exp_params_t { /// allowing the callback the ability to modify the parameter's value typedef struct ur_bindless_images_image_free_exp_params_t { ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; ur_exp_image_mem_handle_t *phImageMem; } ur_bindless_images_image_free_exp_params_t; @@ -9049,6 +9086,7 @@ typedef struct ur_bindless_images_image_free_exp_params_t { /// allowing the callback the ability to modify the parameter's value typedef struct ur_bindless_images_unsampled_image_create_exp_params_t { ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; ur_exp_image_mem_handle_t *phImageMem; const ur_image_format_t **ppImageFormat; const ur_image_desc_t **ppImageDesc; @@ -9062,6 +9100,7 @@ typedef struct ur_bindless_images_unsampled_image_create_exp_params_t { /// allowing the callback the ability to modify the parameter's value typedef struct ur_bindless_images_sampled_image_create_exp_params_t { ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; ur_exp_image_mem_handle_t *phImageMem; const ur_image_format_t **ppImageFormat; const ur_image_desc_t **ppImageDesc; @@ -9075,12 +9114,16 @@ typedef struct ur_bindless_images_sampled_image_create_exp_params_t { /// @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_image_copy_exp_params_t { - ur_context_handle_t *phContext; + ur_queue_handle_t *phQueue; void **ppDst; void **ppSrc; const ur_image_format_t **ppImageFormat; const ur_image_desc_t **ppImageDesc; ur_exp_image_copy_flags_t *pimageCopyFlags; + ur_rect_offset_t *psrcOffset; + ur_rect_offset_t *pdstOffset; + ur_rect_region_t *pcopyExtent; + ur_rect_region_t *phostExtent; uint32_t *pnumEventsInWaitList; const ur_event_handle_t **pphEventWaitList; ur_event_handle_t **pphEvent; @@ -9103,6 +9146,7 @@ typedef struct ur_bindless_images_image_get_info_exp_params_t { /// allowing the callback the ability to modify the parameter's value typedef struct ur_bindless_images_mipmap_get_level_exp_params_t { ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; ur_exp_image_mem_handle_t *phImageMem; uint32_t *pmipmapLevel; ur_exp_image_mem_handle_t **pphImageMem; @@ -9114,6 +9158,7 @@ typedef struct ur_bindless_images_mipmap_get_level_exp_params_t { /// allowing the callback the ability to modify the parameter's value typedef struct ur_bindless_images_mipmap_free_exp_params_t { ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; ur_exp_image_mem_handle_t *phMem; } ur_bindless_images_mipmap_free_exp_params_t; @@ -9123,6 +9168,7 @@ typedef struct ur_bindless_images_mipmap_free_exp_params_t { /// allowing the callback the ability to modify the parameter's value typedef struct ur_bindless_images_import_opaque_fd_exp_params_t { ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; size_t *psize; uint32_t *pfileDescriptor; ur_exp_interop_mem_handle_t **pphInteropMem; @@ -9134,10 +9180,11 @@ typedef struct ur_bindless_images_import_opaque_fd_exp_params_t { /// allowing the callback the ability to modify the parameter's value typedef struct ur_bindless_images_map_external_array_exp_params_t { ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; const ur_image_format_t **ppImageFormat; const ur_image_desc_t **ppImageDesc; ur_exp_interop_mem_handle_t *phInteropMem; - ur_exp_image_handle_t **pphImageMem; + ur_exp_image_mem_handle_t **pphImageMem; } ur_bindless_images_map_external_array_exp_params_t; /////////////////////////////////////////////////////////////////////////////// @@ -9146,6 +9193,7 @@ typedef struct ur_bindless_images_map_external_array_exp_params_t { /// allowing the callback the ability to modify the parameter's value typedef struct ur_bindless_images_release_interop_exp_params_t { ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; ur_exp_interop_mem_handle_t *phInteropMem; } ur_bindless_images_release_interop_exp_params_t; @@ -9155,6 +9203,7 @@ typedef struct ur_bindless_images_release_interop_exp_params_t { /// allowing the callback the ability to modify the parameter's value typedef struct ur_bindless_images_import_external_semaphore_opaque_fd_exp_params_t { ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; uint32_t *pfileDescriptor; ur_exp_interop_semaphore_handle_t **pphInteropSemaphoreHandle; } ur_bindless_images_import_external_semaphore_opaque_fd_exp_params_t; @@ -9165,6 +9214,7 @@ typedef struct ur_bindless_images_import_external_semaphore_opaque_fd_exp_params /// allowing the callback the ability to modify the parameter's value typedef struct ur_bindless_images_destroy_external_semaphore_exp_params_t { ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; ur_exp_interop_semaphore_handle_t *phInteropSemaphore; } ur_bindless_images_destroy_external_semaphore_exp_params_t; diff --git a/include/ur_ddi.h b/include/ur_ddi.h index d99302ea94..3729208835 100644 --- a/include/ur_ddi.h +++ b/include/ur_ddi.h @@ -1279,18 +1279,21 @@ typedef ur_result_t(UR_APICALL *ur_pfnGetQueueProcAddrTable_t)( /// @brief Function-pointer for urBindlessImagesUnsampledImageHandleDestroyExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesUnsampledImageHandleDestroyExp_t)( ur_context_handle_t, + ur_device_handle_t, ur_exp_image_handle_t); /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urBindlessImagesSampledImageHandleDestroyExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesSampledImageHandleDestroyExp_t)( ur_context_handle_t, + ur_device_handle_t, ur_exp_image_handle_t); /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urBindlessImagesImageAllocateExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImageAllocateExp_t)( ur_context_handle_t, + ur_device_handle_t, const ur_image_format_t *, const ur_image_desc_t *, ur_exp_image_mem_handle_t *); @@ -1299,12 +1302,14 @@ typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImageAllocateExp_t)( /// @brief Function-pointer for urBindlessImagesImageFreeExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImageFreeExp_t)( ur_context_handle_t, + ur_device_handle_t, ur_exp_image_mem_handle_t); /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urBindlessImagesUnsampledImageCreateExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesUnsampledImageCreateExp_t)( ur_context_handle_t, + ur_device_handle_t, ur_exp_image_mem_handle_t, const ur_image_format_t *, const ur_image_desc_t *, @@ -1315,6 +1320,7 @@ typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesUnsampledImageCreateExp_t)( /// @brief Function-pointer for urBindlessImagesSampledImageCreateExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesSampledImageCreateExp_t)( ur_context_handle_t, + ur_device_handle_t, ur_exp_image_mem_handle_t, const ur_image_format_t *, const ur_image_desc_t *, @@ -1325,12 +1331,16 @@ typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesSampledImageCreateExp_t)( /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urBindlessImagesImageCopyExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImageCopyExp_t)( - ur_context_handle_t, + ur_queue_handle_t, void *, void *, const ur_image_format_t *, const ur_image_desc_t *, ur_exp_image_copy_flags_t, + ur_rect_offset_t, + ur_rect_offset_t, + ur_rect_region_t, + ur_rect_region_t, uint32_t, const ur_event_handle_t *, ur_event_handle_t *); @@ -1347,6 +1357,7 @@ typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImageGetInfoExp_t)( /// @brief Function-pointer for urBindlessImagesMipmapGetLevelExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesMipmapGetLevelExp_t)( ur_context_handle_t, + ur_device_handle_t, ur_exp_image_mem_handle_t, uint32_t, ur_exp_image_mem_handle_t *); @@ -1355,12 +1366,14 @@ typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesMipmapGetLevelExp_t)( /// @brief Function-pointer for urBindlessImagesMipmapFreeExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesMipmapFreeExp_t)( ur_context_handle_t, + ur_device_handle_t, ur_exp_image_mem_handle_t); /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urBindlessImagesImportOpaqueFDExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImportOpaqueFDExp_t)( ur_context_handle_t, + ur_device_handle_t, size_t, uint32_t, ur_exp_interop_mem_handle_t *); @@ -1369,21 +1382,24 @@ typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImportOpaqueFDExp_t)( /// @brief Function-pointer for urBindlessImagesMapExternalArrayExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesMapExternalArrayExp_t)( ur_context_handle_t, + ur_device_handle_t, const ur_image_format_t *, const ur_image_desc_t *, ur_exp_interop_mem_handle_t, - ur_exp_image_handle_t *); + ur_exp_image_mem_handle_t *); /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urBindlessImagesReleaseInteropExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesReleaseInteropExp_t)( ur_context_handle_t, + ur_device_handle_t, ur_exp_interop_mem_handle_t); /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urBindlessImagesImportExternalSemaphoreOpaqueFDExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImportExternalSemaphoreOpaqueFDExp_t)( ur_context_handle_t, + ur_device_handle_t, uint32_t, ur_exp_interop_semaphore_handle_t *); @@ -1391,6 +1407,7 @@ typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImportExternalSemaphoreOpaqu /// @brief Function-pointer for urBindlessImagesDestroyExternalSemaphoreExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesDestroyExternalSemaphoreExp_t)( ur_context_handle_t, + ur_device_handle_t, ur_exp_interop_semaphore_handle_t); /////////////////////////////////////////////////////////////////////////////// diff --git a/scripts/core/EXP-BINDLESS-IMAGES.rst b/scripts/core/EXP-BINDLESS-IMAGES.rst index c6ecbb7c69..f1b4d94309 100644 --- a/scripts/core/EXP-BINDLESS-IMAGES.rst +++ b/scripts/core/EXP-BINDLESS-IMAGES.rst @@ -69,7 +69,6 @@ Enums * ${X}_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP * ${X}_DEVICE_INFO_BINDLESS_IMAGES_1D_USM_SUPPORT_EXP * ${X}_DEVICE_INFO_BINDLESS_IMAGES_2D_USM_SUPPORT_EXP - * ${X}_DEVICE_INFO_BINDLESS_IMAGES_3D_USM_SUPPORT_EXP * ${X}_DEVICE_INFO_IMAGE_PITCH_ALIGN_EXP * ${X}_DEVICE_INFO_MAX_IMAGE_LINEAR_WIDTH_EXP * ${X}_DEVICE_INFO_MAX_IMAGE_LINEAR_HEIGHT_EXP @@ -149,11 +148,16 @@ Functions Changelog -------------------------------------------------------------------------------- -+-----------+------------------------+ -| Revision | Changes | -+===========+========================+ -| 1.0 | Initial Draft | -+-----------+------------------------+ ++----------+---------------------------------------------------------+ +| Revision | Changes | ++==========+=========================================================+ +| 1.0 | Initial Draft | ++----------+---------------------------------------------------------+ +| 2.0 || Added device parameters to UR functions. | +| || Added sub-region copy paramters to image copy function.| +| || Removed 3D USM capabilities. | +| || Added mip filter mode. | ++----------+---------------------------------------------------------+ Contributors -------------------------------------------------------------------------------- diff --git a/scripts/core/exp-bindless-images.yml b/scripts/core/exp-bindless-images.yml index 1b4d408379..b499d8d8c3 100644 --- a/scripts/core/exp-bindless-images.yml +++ b/scripts/core/exp-bindless-images.yml @@ -38,44 +38,41 @@ etors: - name: BINDLESS_IMAGES_2D_USM_SUPPORT_EXP value: "0x2002" desc: "[$x_bool_t] returns true if the device supports the creation of 2D bindless images backed by USM" - - name: BINDLESS_IMAGES_3D_USM_SUPPORT_EXP - value: "0x2003" - desc: "[$x_bool_t] returns true if the device supports the creation of 3D bindless images backed by USM" - name: IMAGE_PITCH_ALIGN_EXP - value: "0x2004" + value: "0x2003" desc: "[uint32_t] returns the required alignment of the pitch between two rows of an image in bytes" - name: MAX_IMAGE_LINEAR_WIDTH_EXP - value: "0x2005" + value: "0x2004" desc: "[size_t] returns the maximum linear width allowed for images allocated using USM" - name: MAX_IMAGE_LINEAR_HEIGHT_EXP - value: "0x2006" + value: "0x2005" desc: "[size_t] returns the maximum linear height allowed for images allocated using USM" - name: MAX_IMAGE_LINEAR_PITCH_EXP - value: "0x2007" + value: "0x2006" desc: "[size_t] returns the maximum linear pitch allowed for images allocated using USM" - name: MIPMAP_SUPPORT_EXP - value: "0x2008" + value: "0x2007" desc: "[$x_bool_t] returns true if the device supports allocating mipmap resources" - name: MIPMAP_ANISOTROPY_SUPPORT_EXP - value: "0x2009" + value: "0x2008" desc: "[$x_bool_t] returns true if the device supports sampling mipmap images with anisotropic filtering" - name: MIPMAP_MAX_ANISOTROPY_EXP - value: "0x200A" + value: "0x2009" desc: "[uint32_t] returns the maximum anisotropic ratio supported by the device" - name: MIPMAP_LEVEL_REFERENCE_SUPPORT_EXP - value: "0x200B" + value: "0x200A" desc: "[$x_bool_t] returns true if the device supports using images created from individual mipmap levels" - name: INTEROP_MEMORY_IMPORT_SUPPORT_EXP - value: "0x200C" + value: "0x200B" desc: "[$x_bool_t] returns true if the device supports importing external memory resources" - name: INTEROP_MEMORY_EXPORT_SUPPORT_EXP - value: "0x200D" + value: "0x200C" desc: "[$x_bool_t] returns true if the device supports exporting internal memory resources" - name: INTEROP_SEMAPHORE_IMPORT_SUPPORT_EXP - value: "0x200E" + value: "0x200D" desc: "[$x_bool_t] returns true if the device supports importing external semaphore resources" - name: INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP - value: "0x200F" + value: "0x200E" desc: "[$x_bool_t] returns true if the device supports exporting internal event resources" --- #-------------------------------------------------------------------------- type: enum @@ -105,7 +102,7 @@ class: $xBindlessImages name: $x_exp_image_copy_flags_t etors: - name: HOST_TO_DEVICE - desc: "Host to device." + desc: "Host to device" - name: DEVICE_TO_HOST desc: "Device to host" - name: DEVICE_TO_DEVICE @@ -127,8 +124,11 @@ members: name: maxMipmapLevelClamp desc: "[in] maximum mipmap level from which we can sample, maximum value being the number of levels" - type: float - name: maxAnistropy + name: maxAnisotropy desc: "[in] anisotropic ratio used when samplling the mipmap with anisotropic filtering" + - type: $x_sampler_filter_mode_t + name: mipFilterMode + desc: "[in] mipmap filter mode used for filtering between mipmap levels" --- #-------------------------------------------------------------------------- type: function desc: "USM allocate pitched memory" @@ -197,6 +197,9 @@ 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: $x_exp_image_handle_t name: hImage desc: "[in] pointer to handle of image object to destroy" @@ -215,6 +218,9 @@ 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: $x_exp_image_handle_t name: hImage desc: "[in] pointer to handle of image object to destroy" @@ -234,6 +240,9 @@ 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_format_t*" name: pImageFormat desc: "[in] pointer to image format specification" @@ -262,6 +271,9 @@ 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: $x_exp_image_mem_handle_t name: hImageMem desc: "[in] handle of image memory to be freed" @@ -280,6 +292,9 @@ 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: $x_exp_image_mem_handle_t name: hImageMem desc: "[in] handle to memory from which to create the image" @@ -314,6 +329,9 @@ 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: $x_exp_image_mem_handle_t name: hImageMem desc: "[in] handle to memory from which to create the image" @@ -352,9 +370,9 @@ analogue: - "**cuMemcpy2DAsync**" - "**cuMemcpy3DAsync**" params: - - type: $x_context_handle_t - name: hContext - desc: "[in] handle of the context object" + - type: $x_queue_handle_t + name: hQueue + desc: "[in] handle of the queue object" - type: void* name: pDst desc: "[in] location the data will be copied to" @@ -370,6 +388,18 @@ params: - type: $x_exp_image_copy_flags_t name: imageCopyFlags desc: "[in] flags describing copy direction e.g. H2D or D2H" + - type: $x_rect_offset_t + name: srcOffset + desc: "[in] defines the (x,y,z) source offset in pixels in the 1D, 2D, or 3D image" + - type: $x_rect_offset_t + name: dstOffset + desc: "[in] defines the (x,y,z) destination offset in pixels in the 1D, 2D, or 3D image" + - type: $x_rect_region_t + name: copyExtent + desc: "[in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D region to copy" + - type: $x_rect_region_t + name: hostExtent + desc: "[in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D region on the host" - type: uint32_t name: numEventsInWaitList desc: "[in] size of the event wait list" @@ -384,7 +414,7 @@ params: desc: | [out][optional] return an event object that identifies this particular command instance. returns: - - $X_RESULT_ERROR_INVALID_CONTEXT + - $X_RESULT_ERROR_INVALID_QUEUE - $X_RESULT_ERROR_INVALID_VALUE - $X_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR: - "`pImageDesc && UR_MEM_TYPE_IMAGE1D_BUFFER < pImageDesc->type`" @@ -431,6 +461,9 @@ 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: $x_exp_image_mem_handle_t name: hImageMem desc: "[in] memory handle to the mipmap image" @@ -455,6 +488,9 @@ 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: $x_exp_image_mem_handle_t name: hMem desc: "[in] handle of image memory to be freed" @@ -473,6 +509,9 @@ 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: size_t name: size desc: "[in] size of the external memory" @@ -496,6 +535,9 @@ 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_format_t*" name: pImageFormat desc: "[in] pointer to image format specification" @@ -505,7 +547,7 @@ params: - type: $x_exp_interop_mem_handle_t name: hInteropMem desc: "[in] interop memory handle to the external memory" - - type: $x_exp_image_handle_t* + - type: $x_exp_image_mem_handle_t* name: phImageMem desc: "[out] image memory handle to the externally allocated memory" returns: @@ -528,6 +570,9 @@ 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: $x_exp_interop_mem_handle_t name: hInteropMem desc: "[in] handle of interop memory to be freed" @@ -546,6 +591,9 @@ 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: uint32_t name: fileDescriptor desc: "[in] the file descriptor" @@ -567,6 +615,9 @@ 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: $x_exp_interop_semaphore_handle_t name: hInteropSemaphore desc: "[in] handle of interop semaphore to be destroyed" diff --git a/source/adapters/null/ur_nullddi.cpp b/source/adapters/null/ur_nullddi.cpp index 2e19884b23..95b62afb0d 100644 --- a/source/adapters/null/ur_nullddi.cpp +++ b/source/adapters/null/ur_nullddi.cpp @@ -3817,6 +3817,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPitchedAllocExp( __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageHandleDestroyExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_handle_t hImage ///< [in] pointer to handle of image object to destroy ) try { @@ -3827,7 +3828,7 @@ urBindlessImagesUnsampledImageHandleDestroyExp( d_context.urDdiTable.BindlessImagesExp .pfnUnsampledImageHandleDestroyExp; if (nullptr != pfnUnsampledImageHandleDestroyExp) { - result = pfnUnsampledImageHandleDestroyExp(hContext, hImage); + result = pfnUnsampledImageHandleDestroyExp(hContext, hDevice, hImage); } else { // generic implementation } @@ -3842,6 +3843,7 @@ urBindlessImagesUnsampledImageHandleDestroyExp( __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageHandleDestroyExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_handle_t hImage ///< [in] pointer to handle of image object to destroy ) try { @@ -3851,7 +3853,7 @@ urBindlessImagesSampledImageHandleDestroyExp( auto pfnSampledImageHandleDestroyExp = d_context.urDdiTable.BindlessImagesExp.pfnSampledImageHandleDestroyExp; if (nullptr != pfnSampledImageHandleDestroyExp) { - result = pfnSampledImageHandleDestroyExp(hContext, hImage); + result = pfnSampledImageHandleDestroyExp(hContext, hDevice, hImage); } else { // generic implementation } @@ -3865,6 +3867,7 @@ urBindlessImagesSampledImageHandleDestroyExp( /// @brief Intercept function for urBindlessImagesImageAllocateExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description @@ -3877,8 +3880,8 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( auto pfnImageAllocateExp = d_context.urDdiTable.BindlessImagesExp.pfnImageAllocateExp; if (nullptr != pfnImageAllocateExp) { - result = - pfnImageAllocateExp(hContext, pImageFormat, pImageDesc, phImageMem); + result = pfnImageAllocateExp(hContext, hDevice, pImageFormat, + pImageDesc, phImageMem); } else { // generic implementation *phImageMem = @@ -3894,6 +3897,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( /// @brief Intercept function for urBindlessImagesImageFreeExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem ///< [in] handle of image memory to be freed ) try { @@ -3903,7 +3907,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( auto pfnImageFreeExp = d_context.urDdiTable.BindlessImagesExp.pfnImageFreeExp; if (nullptr != pfnImageFreeExp) { - result = pfnImageFreeExp(hContext, hImageMem); + result = pfnImageFreeExp(hContext, hDevice, hImageMem); } else { // generic implementation } @@ -3917,6 +3921,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( /// @brief Intercept function for urBindlessImagesUnsampledImageCreateExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] handle to memory from which to create the image const ur_image_format_t @@ -3932,8 +3937,9 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( auto pfnUnsampledImageCreateExp = d_context.urDdiTable.BindlessImagesExp.pfnUnsampledImageCreateExp; if (nullptr != pfnUnsampledImageCreateExp) { - result = pfnUnsampledImageCreateExp(hContext, hImageMem, pImageFormat, - pImageDesc, phMem, phImage); + result = pfnUnsampledImageCreateExp(hContext, hDevice, hImageMem, + pImageFormat, pImageDesc, phMem, + phImage); } else { // generic implementation *phMem = reinterpret_cast(d_context.get()); @@ -3950,6 +3956,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( /// @brief Intercept function for urBindlessImagesSampledImageCreateExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] handle to memory from which to create the image const ur_image_format_t @@ -3966,8 +3973,9 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( auto pfnSampledImageCreateExp = d_context.urDdiTable.BindlessImagesExp.pfnSampledImageCreateExp; if (nullptr != pfnSampledImageCreateExp) { - result = pfnSampledImageCreateExp(hContext, hImageMem, pImageFormat, - pImageDesc, hSampler, phMem, phImage); + result = + pfnSampledImageCreateExp(hContext, hDevice, hImageMem, pImageFormat, + pImageDesc, hSampler, phMem, phImage); } else { // generic implementation *phMem = reinterpret_cast(d_context.get()); @@ -3983,14 +3991,26 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urBindlessImagesImageCopyExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp( - ur_context_handle_t hContext, ///< [in] handle of the context object - void *pDst, ///< [in] location the data will be copied to - void *pSrc, ///< [in] location the data will be copied from + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + void *pDst, ///< [in] location the data will be copied to + void *pSrc, ///< [in] location the data will be copied from const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_image_copy_flags_t imageCopyFlags, ///< [in] flags describing copy direction e.g. H2D or D2H + ur_rect_offset_t + srcOffset, ///< [in] defines the (x,y,z) source offset in pixels in the 1D, 2D, or 3D + ///< image + ur_rect_offset_t + dstOffset, ///< [in] defines the (x,y,z) destination offset in pixels in the 1D, 2D, + ///< or 3D image + ur_rect_region_t + copyExtent, ///< [in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D + ///< region to copy + ur_rect_region_t + hostExtent, ///< [in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D + ///< region on the host uint32_t numEventsInWaitList, ///< [in] size of the event wait list const ur_event_handle_t * phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] pointer to a list of @@ -4008,8 +4028,9 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp( auto pfnImageCopyExp = d_context.urDdiTable.BindlessImagesExp.pfnImageCopyExp; if (nullptr != pfnImageCopyExp) { - result = pfnImageCopyExp(hContext, pDst, pSrc, pImageFormat, pImageDesc, - imageCopyFlags, numEventsInWaitList, + result = pfnImageCopyExp(hQueue, pDst, pSrc, pImageFormat, pImageDesc, + imageCopyFlags, srcOffset, dstOffset, + copyExtent, hostExtent, numEventsInWaitList, phEventWaitList, phEvent); } else { // generic implementation @@ -4052,6 +4073,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( /// @brief Intercept function for urBindlessImagesMipmapGetLevelExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] memory handle to the mipmap image uint32_t mipmapLevel, ///< [in] requested level of the mipmap @@ -4064,8 +4086,8 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( auto pfnMipmapGetLevelExp = d_context.urDdiTable.BindlessImagesExp.pfnMipmapGetLevelExp; if (nullptr != pfnMipmapGetLevelExp) { - result = - pfnMipmapGetLevelExp(hContext, hImageMem, mipmapLevel, phImageMem); + result = pfnMipmapGetLevelExp(hContext, hDevice, hImageMem, mipmapLevel, + phImageMem); } else { // generic implementation *phImageMem = @@ -4081,6 +4103,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( /// @brief Intercept function for urBindlessImagesMipmapFreeExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hMem ///< [in] handle of image memory to be freed ) try { ur_result_t result = UR_RESULT_SUCCESS; @@ -4089,7 +4112,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( auto pfnMipmapFreeExp = d_context.urDdiTable.BindlessImagesExp.pfnMipmapFreeExp; if (nullptr != pfnMipmapFreeExp) { - result = pfnMipmapFreeExp(hContext, hMem); + result = pfnMipmapFreeExp(hContext, hDevice, hMem); } else { // generic implementation } @@ -4103,6 +4126,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( /// @brief Intercept function for urBindlessImagesImportOpaqueFDExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object size_t size, ///< [in] size of the external memory uint32_t fileDescriptor, ///< [in] the file descriptor ur_exp_interop_mem_handle_t @@ -4114,8 +4138,8 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( auto pfnImportOpaqueFDExp = d_context.urDdiTable.BindlessImagesExp.pfnImportOpaqueFDExp; if (nullptr != pfnImportOpaqueFDExp) { - result = - pfnImportOpaqueFDExp(hContext, size, fileDescriptor, phInteropMem); + result = pfnImportOpaqueFDExp(hContext, hDevice, size, fileDescriptor, + phInteropMem); } else { // generic implementation *phInteropMem = @@ -4131,12 +4155,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( /// @brief Intercept function for urBindlessImagesMapExternalArrayExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_interop_mem_handle_t hInteropMem, ///< [in] interop memory handle to the external memory - ur_exp_image_handle_t * + ur_exp_image_mem_handle_t * phImageMem ///< [out] image memory handle to the externally allocated memory ) try { ur_result_t result = UR_RESULT_SUCCESS; @@ -4145,11 +4170,12 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( auto pfnMapExternalArrayExp = d_context.urDdiTable.BindlessImagesExp.pfnMapExternalArrayExp; if (nullptr != pfnMapExternalArrayExp) { - result = pfnMapExternalArrayExp(hContext, pImageFormat, pImageDesc, - hInteropMem, phImageMem); + result = pfnMapExternalArrayExp(hContext, hDevice, pImageFormat, + pImageDesc, hInteropMem, phImageMem); } else { // generic implementation - *phImageMem = reinterpret_cast(d_context.get()); + *phImageMem = + reinterpret_cast(d_context.get()); } return result; @@ -4161,6 +4187,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( /// @brief Intercept function for urBindlessImagesReleaseInteropExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_mem_handle_t hInteropMem ///< [in] handle of interop memory to be freed ) try { @@ -4170,7 +4197,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( auto pfnReleaseInteropExp = d_context.urDdiTable.BindlessImagesExp.pfnReleaseInteropExp; if (nullptr != pfnReleaseInteropExp) { - result = pfnReleaseInteropExp(hContext, hInteropMem); + result = pfnReleaseInteropExp(hContext, hDevice, hInteropMem); } else { // generic implementation } @@ -4185,6 +4212,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object uint32_t fileDescriptor, ///< [in] the file descriptor ur_exp_interop_semaphore_handle_t * phInteropSemaphoreHandle ///< [out] interop semaphore handle to the external semaphore @@ -4197,7 +4225,7 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( .pfnImportExternalSemaphoreOpaqueFDExp; if (nullptr != pfnImportExternalSemaphoreOpaqueFDExp) { result = pfnImportExternalSemaphoreOpaqueFDExp( - hContext, fileDescriptor, phInteropSemaphoreHandle); + hContext, hDevice, fileDescriptor, phInteropSemaphoreHandle); } else { // generic implementation *phInteropSemaphoreHandle = @@ -4214,6 +4242,7 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( /// @brief Intercept function for urBindlessImagesDestroyExternalSemaphoreExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_semaphore_handle_t hInteropSemaphore ///< [in] handle of interop semaphore to be destroyed ) try { @@ -4223,7 +4252,8 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( auto pfnDestroyExternalSemaphoreExp = d_context.urDdiTable.BindlessImagesExp.pfnDestroyExternalSemaphoreExp; if (nullptr != pfnDestroyExternalSemaphoreExp) { - result = pfnDestroyExternalSemaphoreExp(hContext, hInteropSemaphore); + result = pfnDestroyExternalSemaphoreExp(hContext, hDevice, + hInteropSemaphore); } else { // generic implementation } diff --git a/source/common/ur_params.hpp b/source/common/ur_params.hpp index deab11b7af..15014813a1 100644 --- a/source/common/ur_params.hpp +++ b/source/common/ur_params.hpp @@ -1913,10 +1913,6 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_device_info_t value) { os << "UR_DEVICE_INFO_BINDLESS_IMAGES_2D_USM_SUPPORT_EXP"; break; - case UR_DEVICE_INFO_BINDLESS_IMAGES_3D_USM_SUPPORT_EXP: - os << "UR_DEVICE_INFO_BINDLESS_IMAGES_3D_USM_SUPPORT_EXP"; - break; - case UR_DEVICE_INFO_IMAGE_PITCH_ALIGN_EXP: os << "UR_DEVICE_INFO_IMAGE_PITCH_ALIGN_EXP"; break; @@ -3567,20 +3563,6 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_BINDLESS_IMAGES_3D_USM_SUPPORT_EXP: { - const ur_bool_t *tptr = (const ur_bool_t *)ptr; - if (sizeof(ur_bool_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_bool_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; - case UR_DEVICE_INFO_IMAGE_PITCH_ALIGN_EXP: { const uint32_t *tptr = (const uint32_t *)ptr; if (sizeof(uint32_t) > size) { @@ -9451,9 +9433,14 @@ operator<<(std::ostream &os, os << (params.maxMipmapLevelClamp); os << ", "; - os << ".maxAnistropy = "; + os << ".maxAnisotropy = "; - os << (params.maxAnistropy); + os << (params.maxAnisotropy); + + os << ", "; + os << ".mipFilterMode = "; + + os << (params.mipFilterMode); os << "}"; return os; @@ -9566,6 +9553,11 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); + os << ", "; + os << ".hDevice = "; + + ur_params::serializePtr(os, *(params->phDevice)); + os << ", "; os << ".hImage = "; @@ -9583,6 +9575,11 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); + os << ", "; + os << ".hDevice = "; + + ur_params::serializePtr(os, *(params->phDevice)); + os << ", "; os << ".hImage = "; @@ -9599,6 +9596,11 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); + os << ", "; + os << ".hDevice = "; + + ur_params::serializePtr(os, *(params->phDevice)); + os << ", "; os << ".pImageFormat = "; @@ -9625,6 +9627,11 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); + os << ", "; + os << ".hDevice = "; + + ur_params::serializePtr(os, *(params->phDevice)); + os << ", "; os << ".hImageMem = "; @@ -9642,6 +9649,11 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); + os << ", "; + os << ".hDevice = "; + + ur_params::serializePtr(os, *(params->phDevice)); + os << ", "; os << ".hImageMem = "; @@ -9678,6 +9690,11 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); + os << ", "; + os << ".hDevice = "; + + ur_params::serializePtr(os, *(params->phDevice)); + os << ", "; os << ".hImageMem = "; @@ -9715,9 +9732,9 @@ inline std::ostream & operator<<(std::ostream &os, const struct ur_bindless_images_image_copy_exp_params_t *params) { - os << ".hContext = "; + os << ".hQueue = "; - ur_params::serializePtr(os, *(params->phContext)); + ur_params::serializePtr(os, *(params->phQueue)); os << ", "; os << ".pDst = "; @@ -9745,6 +9762,26 @@ operator<<(std::ostream &os, ur_params::serializeFlag( os, *(params->pimageCopyFlags)); + os << ", "; + os << ".srcOffset = "; + + os << *(params->psrcOffset); + + os << ", "; + os << ".dstOffset = "; + + os << *(params->pdstOffset); + + os << ", "; + os << ".copyExtent = "; + + os << *(params->pcopyExtent); + + os << ", "; + os << ".hostExtent = "; + + os << *(params->phostExtent); + os << ", "; os << ".numEventsInWaitList = "; @@ -9805,6 +9842,11 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); + os << ", "; + os << ".hDevice = "; + + ur_params::serializePtr(os, *(params->phDevice)); + os << ", "; os << ".hImageMem = "; @@ -9831,6 +9873,11 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); + os << ", "; + os << ".hDevice = "; + + ur_params::serializePtr(os, *(params->phDevice)); + os << ", "; os << ".hMem = "; @@ -9847,6 +9894,11 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); + os << ", "; + os << ".hDevice = "; + + ur_params::serializePtr(os, *(params->phDevice)); + os << ", "; os << ".size = "; @@ -9873,6 +9925,11 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); + os << ", "; + os << ".hDevice = "; + + ur_params::serializePtr(os, *(params->phDevice)); + os << ", "; os << ".pImageFormat = "; @@ -9904,6 +9961,11 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); + os << ", "; + os << ".hDevice = "; + + ur_params::serializePtr(os, *(params->phDevice)); + os << ", "; os << ".hInteropMem = "; @@ -9921,6 +9983,11 @@ operator<<(std::ostream &os, const struct ur_params::serializePtr(os, *(params->phContext)); + os << ", "; + os << ".hDevice = "; + + ur_params::serializePtr(os, *(params->phDevice)); + os << ", "; os << ".fileDescriptor = "; @@ -9943,6 +10010,11 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); + os << ", "; + os << ".hDevice = "; + + ur_params::serializePtr(os, *(params->phDevice)); + os << ", "; os << ".hInteropSemaphore = "; diff --git a/source/loader/layers/tracing/ur_trcddi.cpp b/source/loader/layers/tracing/ur_trcddi.cpp index dabbdbe485..9b6d6b34dc 100644 --- a/source/loader/layers/tracing/ur_trcddi.cpp +++ b/source/loader/layers/tracing/ur_trcddi.cpp @@ -4329,6 +4329,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPitchedAllocExp( __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageHandleDestroyExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_handle_t hImage ///< [in] pointer to handle of image object to destroy ) { @@ -4340,12 +4341,13 @@ urBindlessImagesUnsampledImageHandleDestroyExp( } ur_bindless_images_unsampled_image_handle_destroy_exp_params_t params = { - &hContext, &hImage}; + &hContext, &hDevice, &hImage}; uint64_t instance = context.notify_begin( UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_HANDLE_DESTROY_EXP, "urBindlessImagesUnsampledImageHandleDestroyExp", ¶ms); - ur_result_t result = pfnUnsampledImageHandleDestroyExp(hContext, hImage); + ur_result_t result = + pfnUnsampledImageHandleDestroyExp(hContext, hDevice, hImage); context.notify_end( UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_HANDLE_DESTROY_EXP, @@ -4360,6 +4362,7 @@ urBindlessImagesUnsampledImageHandleDestroyExp( __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageHandleDestroyExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_handle_t hImage ///< [in] pointer to handle of image object to destroy ) { @@ -4371,12 +4374,13 @@ urBindlessImagesSampledImageHandleDestroyExp( } ur_bindless_images_sampled_image_handle_destroy_exp_params_t params = { - &hContext, &hImage}; + &hContext, &hDevice, &hImage}; uint64_t instance = context.notify_begin( UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_HANDLE_DESTROY_EXP, "urBindlessImagesSampledImageHandleDestroyExp", ¶ms); - ur_result_t result = pfnSampledImageHandleDestroyExp(hContext, hImage); + ur_result_t result = + pfnSampledImageHandleDestroyExp(hContext, hDevice, hImage); context.notify_end( UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_HANDLE_DESTROY_EXP, @@ -4390,6 +4394,7 @@ urBindlessImagesSampledImageHandleDestroyExp( /// @brief Intercept function for urBindlessImagesImageAllocateExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description @@ -4404,13 +4409,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( } ur_bindless_images_image_allocate_exp_params_t params = { - &hContext, &pImageFormat, &pImageDesc, &phImageMem}; + &hContext, &hDevice, &pImageFormat, &pImageDesc, &phImageMem}; uint64_t instance = context.notify_begin(UR_FUNCTION_BINDLESS_IMAGES_IMAGE_ALLOCATE_EXP, "urBindlessImagesImageAllocateExp", ¶ms); - ur_result_t result = - pfnImageAllocateExp(hContext, pImageFormat, pImageDesc, phImageMem); + ur_result_t result = pfnImageAllocateExp(hContext, hDevice, pImageFormat, + pImageDesc, phImageMem); context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_IMAGE_ALLOCATE_EXP, "urBindlessImagesImageAllocateExp", ¶ms, &result, @@ -4423,6 +4428,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( /// @brief Intercept function for urBindlessImagesImageFreeExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem ///< [in] handle of image memory to be freed ) { @@ -4432,12 +4438,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - ur_bindless_images_image_free_exp_params_t params = {&hContext, &hImageMem}; + ur_bindless_images_image_free_exp_params_t params = {&hContext, &hDevice, + &hImageMem}; uint64_t instance = context.notify_begin(UR_FUNCTION_BINDLESS_IMAGES_IMAGE_FREE_EXP, "urBindlessImagesImageFreeExp", ¶ms); - ur_result_t result = pfnImageFreeExp(hContext, hImageMem); + ur_result_t result = pfnImageFreeExp(hContext, hDevice, hImageMem); context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_IMAGE_FREE_EXP, "urBindlessImagesImageFreeExp", ¶ms, &result, @@ -4450,6 +4457,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( /// @brief Intercept function for urBindlessImagesUnsampledImageCreateExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] handle to memory from which to create the image const ur_image_format_t @@ -4467,13 +4475,14 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( } ur_bindless_images_unsampled_image_create_exp_params_t params = { - &hContext, &hImageMem, &pImageFormat, &pImageDesc, &phMem, &phImage}; + &hContext, &hDevice, &hImageMem, &pImageFormat, + &pImageDesc, &phMem, &phImage}; uint64_t instance = context.notify_begin( UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_CREATE_EXP, "urBindlessImagesUnsampledImageCreateExp", ¶ms); ur_result_t result = pfnUnsampledImageCreateExp( - hContext, hImageMem, pImageFormat, pImageDesc, phMem, phImage); + hContext, hDevice, hImageMem, pImageFormat, pImageDesc, phMem, phImage); context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_CREATE_EXP, "urBindlessImagesUnsampledImageCreateExp", ¶ms, @@ -4486,6 +4495,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( /// @brief Intercept function for urBindlessImagesSampledImageCreateExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] handle to memory from which to create the image const ur_image_format_t @@ -4504,15 +4514,15 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( } ur_bindless_images_sampled_image_create_exp_params_t params = { - &hContext, &hImageMem, &pImageFormat, &pImageDesc, - &hSampler, &phMem, &phImage}; + &hContext, &hDevice, &hImageMem, &pImageFormat, + &pImageDesc, &hSampler, &phMem, &phImage}; uint64_t instance = context.notify_begin( UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_CREATE_EXP, "urBindlessImagesSampledImageCreateExp", ¶ms); ur_result_t result = - pfnSampledImageCreateExp(hContext, hImageMem, pImageFormat, pImageDesc, - hSampler, phMem, phImage); + pfnSampledImageCreateExp(hContext, hDevice, hImageMem, pImageFormat, + pImageDesc, hSampler, phMem, phImage); context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_CREATE_EXP, "urBindlessImagesSampledImageCreateExp", ¶ms, @@ -4524,14 +4534,26 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urBindlessImagesImageCopyExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp( - ur_context_handle_t hContext, ///< [in] handle of the context object - void *pDst, ///< [in] location the data will be copied to - void *pSrc, ///< [in] location the data will be copied from + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + void *pDst, ///< [in] location the data will be copied to + void *pSrc, ///< [in] location the data will be copied from const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_image_copy_flags_t imageCopyFlags, ///< [in] flags describing copy direction e.g. H2D or D2H + ur_rect_offset_t + srcOffset, ///< [in] defines the (x,y,z) source offset in pixels in the 1D, 2D, or 3D + ///< image + ur_rect_offset_t + dstOffset, ///< [in] defines the (x,y,z) destination offset in pixels in the 1D, 2D, + ///< or 3D image + ur_rect_region_t + copyExtent, ///< [in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D + ///< region to copy + ur_rect_region_t + hostExtent, ///< [in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D + ///< region on the host uint32_t numEventsInWaitList, ///< [in] size of the event wait list const ur_event_handle_t * phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] pointer to a list of @@ -4549,12 +4571,16 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp( return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - ur_bindless_images_image_copy_exp_params_t params = {&hContext, + ur_bindless_images_image_copy_exp_params_t params = {&hQueue, &pDst, &pSrc, &pImageFormat, &pImageDesc, &imageCopyFlags, + &srcOffset, + &dstOffset, + ©Extent, + &hostExtent, &numEventsInWaitList, &phEventWaitList, &phEvent}; @@ -4563,8 +4589,9 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp( "urBindlessImagesImageCopyExp", ¶ms); ur_result_t result = pfnImageCopyExp( - hContext, pDst, pSrc, pImageFormat, pImageDesc, imageCopyFlags, - numEventsInWaitList, phEventWaitList, phEvent); + hQueue, pDst, pSrc, pImageFormat, pImageDesc, imageCopyFlags, srcOffset, + dstOffset, copyExtent, hostExtent, numEventsInWaitList, phEventWaitList, + phEvent); context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_IMAGE_COPY_EXP, "urBindlessImagesImageCopyExp", ¶ms, &result, @@ -4608,6 +4635,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( /// @brief Intercept function for urBindlessImagesMipmapGetLevelExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] memory handle to the mipmap image uint32_t mipmapLevel, ///< [in] requested level of the mipmap @@ -4622,13 +4650,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( } ur_bindless_images_mipmap_get_level_exp_params_t params = { - &hContext, &hImageMem, &mipmapLevel, &phImageMem}; + &hContext, &hDevice, &hImageMem, &mipmapLevel, &phImageMem}; uint64_t instance = context.notify_begin(UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_GET_LEVEL_EXP, "urBindlessImagesMipmapGetLevelExp", ¶ms); - ur_result_t result = - pfnMipmapGetLevelExp(hContext, hImageMem, mipmapLevel, phImageMem); + ur_result_t result = pfnMipmapGetLevelExp(hContext, hDevice, hImageMem, + mipmapLevel, phImageMem); context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_GET_LEVEL_EXP, "urBindlessImagesMipmapGetLevelExp", ¶ms, &result, @@ -4641,6 +4669,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( /// @brief Intercept function for urBindlessImagesMipmapFreeExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hMem ///< [in] handle of image memory to be freed ) { auto pfnMipmapFreeExp = @@ -4650,12 +4679,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - ur_bindless_images_mipmap_free_exp_params_t params = {&hContext, &hMem}; + ur_bindless_images_mipmap_free_exp_params_t params = {&hContext, &hDevice, + &hMem}; uint64_t instance = context.notify_begin(UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_FREE_EXP, "urBindlessImagesMipmapFreeExp", ¶ms); - ur_result_t result = pfnMipmapFreeExp(hContext, hMem); + ur_result_t result = pfnMipmapFreeExp(hContext, hDevice, hMem); context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_FREE_EXP, "urBindlessImagesMipmapFreeExp", ¶ms, &result, @@ -4668,6 +4698,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( /// @brief Intercept function for urBindlessImagesImportOpaqueFDExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object size_t size, ///< [in] size of the external memory uint32_t fileDescriptor, ///< [in] the file descriptor ur_exp_interop_mem_handle_t @@ -4681,13 +4712,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( } ur_bindless_images_import_opaque_fd_exp_params_t params = { - &hContext, &size, &fileDescriptor, &phInteropMem}; + &hContext, &hDevice, &size, &fileDescriptor, &phInteropMem}; uint64_t instance = context.notify_begin(UR_FUNCTION_BINDLESS_IMAGES_IMPORT_OPAQUE_FD_EXP, "urBindlessImagesImportOpaqueFDExp", ¶ms); - ur_result_t result = - pfnImportOpaqueFDExp(hContext, size, fileDescriptor, phInteropMem); + ur_result_t result = pfnImportOpaqueFDExp(hContext, hDevice, size, + fileDescriptor, phInteropMem); context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_IMPORT_OPAQUE_FD_EXP, "urBindlessImagesImportOpaqueFDExp", ¶ms, &result, @@ -4700,12 +4731,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( /// @brief Intercept function for urBindlessImagesMapExternalArrayExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_interop_mem_handle_t hInteropMem, ///< [in] interop memory handle to the external memory - ur_exp_image_handle_t * + ur_exp_image_mem_handle_t * phImageMem ///< [out] image memory handle to the externally allocated memory ) { auto pfnMapExternalArrayExp = @@ -4716,13 +4748,14 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( } ur_bindless_images_map_external_array_exp_params_t params = { - &hContext, &pImageFormat, &pImageDesc, &hInteropMem, &phImageMem}; + &hContext, &hDevice, &pImageFormat, + &pImageDesc, &hInteropMem, &phImageMem}; uint64_t instance = context.notify_begin(UR_FUNCTION_BINDLESS_IMAGES_MAP_EXTERNAL_ARRAY_EXP, "urBindlessImagesMapExternalArrayExp", ¶ms); ur_result_t result = pfnMapExternalArrayExp( - hContext, pImageFormat, pImageDesc, hInteropMem, phImageMem); + hContext, hDevice, pImageFormat, pImageDesc, hInteropMem, phImageMem); context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_MAP_EXTERNAL_ARRAY_EXP, "urBindlessImagesMapExternalArrayExp", ¶ms, &result, @@ -4735,6 +4768,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( /// @brief Intercept function for urBindlessImagesReleaseInteropExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_mem_handle_t hInteropMem ///< [in] handle of interop memory to be freed ) { @@ -4745,13 +4779,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - ur_bindless_images_release_interop_exp_params_t params = {&hContext, - &hInteropMem}; + ur_bindless_images_release_interop_exp_params_t params = { + &hContext, &hDevice, &hInteropMem}; uint64_t instance = context.notify_begin(UR_FUNCTION_BINDLESS_IMAGES_RELEASE_INTEROP_EXP, "urBindlessImagesReleaseInteropExp", ¶ms); - ur_result_t result = pfnReleaseInteropExp(hContext, hInteropMem); + ur_result_t result = pfnReleaseInteropExp(hContext, hDevice, hInteropMem); context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_RELEASE_INTEROP_EXP, "urBindlessImagesReleaseInteropExp", ¶ms, &result, @@ -4765,6 +4799,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object uint32_t fileDescriptor, ///< [in] the file descriptor ur_exp_interop_semaphore_handle_t * phInteropSemaphoreHandle ///< [out] interop semaphore handle to the external semaphore @@ -4778,13 +4813,13 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( } ur_bindless_images_import_external_semaphore_opaque_fd_exp_params_t params = - {&hContext, &fileDescriptor, &phInteropSemaphoreHandle}; + {&hContext, &hDevice, &fileDescriptor, &phInteropSemaphoreHandle}; uint64_t instance = context.notify_begin( UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXP, "urBindlessImagesImportExternalSemaphoreOpaqueFDExp", ¶ms); ur_result_t result = pfnImportExternalSemaphoreOpaqueFDExp( - hContext, fileDescriptor, phInteropSemaphoreHandle); + hContext, hDevice, fileDescriptor, phInteropSemaphoreHandle); context.notify_end( UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXP, @@ -4798,6 +4833,7 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( /// @brief Intercept function for urBindlessImagesDestroyExternalSemaphoreExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_semaphore_handle_t hInteropSemaphore ///< [in] handle of interop semaphore to be destroyed ) { @@ -4809,13 +4845,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( } ur_bindless_images_destroy_external_semaphore_exp_params_t params = { - &hContext, &hInteropSemaphore}; + &hContext, &hDevice, &hInteropSemaphore}; uint64_t instance = context.notify_begin( UR_FUNCTION_BINDLESS_IMAGES_DESTROY_EXTERNAL_SEMAPHORE_EXP, "urBindlessImagesDestroyExternalSemaphoreExp", ¶ms); ur_result_t result = - pfnDestroyExternalSemaphoreExp(hContext, hInteropSemaphore); + pfnDestroyExternalSemaphoreExp(hContext, hDevice, hInteropSemaphore); context.notify_end( UR_FUNCTION_BINDLESS_IMAGES_DESTROY_EXTERNAL_SEMAPHORE_EXP, diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index 6a2c2f38c9..a2192d67e2 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -5459,6 +5459,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPitchedAllocExp( __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageHandleDestroyExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_handle_t hImage ///< [in] pointer to handle of image object to destroy ) { @@ -5474,12 +5475,17 @@ urBindlessImagesUnsampledImageHandleDestroyExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (NULL == hDevice) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (NULL == hImage) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } } - ur_result_t result = pfnUnsampledImageHandleDestroyExp(hContext, hImage); + ur_result_t result = + pfnUnsampledImageHandleDestroyExp(hContext, hDevice, hImage); return result; } @@ -5489,6 +5495,7 @@ urBindlessImagesUnsampledImageHandleDestroyExp( __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageHandleDestroyExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_handle_t hImage ///< [in] pointer to handle of image object to destroy ) { @@ -5504,12 +5511,17 @@ urBindlessImagesSampledImageHandleDestroyExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (NULL == hDevice) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (NULL == hImage) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } } - ur_result_t result = pfnSampledImageHandleDestroyExp(hContext, hImage); + ur_result_t result = + pfnSampledImageHandleDestroyExp(hContext, hDevice, hImage); return result; } @@ -5518,6 +5530,7 @@ urBindlessImagesSampledImageHandleDestroyExp( /// @brief Intercept function for urBindlessImagesImageAllocateExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description @@ -5536,6 +5549,10 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (NULL == hDevice) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (NULL == pImageFormat) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } @@ -5553,8 +5570,8 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( } } - ur_result_t result = - pfnImageAllocateExp(hContext, pImageFormat, pImageDesc, phImageMem); + ur_result_t result = pfnImageAllocateExp(hContext, hDevice, pImageFormat, + pImageDesc, phImageMem); return result; } @@ -5563,6 +5580,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( /// @brief Intercept function for urBindlessImagesImageFreeExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem ///< [in] handle of image memory to be freed ) { @@ -5577,12 +5595,16 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (NULL == hDevice) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (NULL == hImageMem) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } } - ur_result_t result = pfnImageFreeExp(hContext, hImageMem); + ur_result_t result = pfnImageFreeExp(hContext, hDevice, hImageMem); return result; } @@ -5591,6 +5613,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( /// @brief Intercept function for urBindlessImagesUnsampledImageCreateExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] handle to memory from which to create the image const ur_image_format_t @@ -5612,6 +5635,10 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (NULL == hDevice) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (NULL == hImageMem) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -5638,7 +5665,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( } ur_result_t result = pfnUnsampledImageCreateExp( - hContext, hImageMem, pImageFormat, pImageDesc, phMem, phImage); + hContext, hDevice, hImageMem, pImageFormat, pImageDesc, phMem, phImage); return result; } @@ -5647,6 +5674,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( /// @brief Intercept function for urBindlessImagesSampledImageCreateExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] handle to memory from which to create the image const ur_image_format_t @@ -5669,6 +5697,10 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (NULL == hDevice) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (NULL == hImageMem) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -5699,8 +5731,8 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( } ur_result_t result = - pfnSampledImageCreateExp(hContext, hImageMem, pImageFormat, pImageDesc, - hSampler, phMem, phImage); + pfnSampledImageCreateExp(hContext, hDevice, hImageMem, pImageFormat, + pImageDesc, hSampler, phMem, phImage); return result; } @@ -5708,14 +5740,26 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urBindlessImagesImageCopyExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp( - ur_context_handle_t hContext, ///< [in] handle of the context object - void *pDst, ///< [in] location the data will be copied to - void *pSrc, ///< [in] location the data will be copied from + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + void *pDst, ///< [in] location the data will be copied to + void *pSrc, ///< [in] location the data will be copied from const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_image_copy_flags_t imageCopyFlags, ///< [in] flags describing copy direction e.g. H2D or D2H + ur_rect_offset_t + srcOffset, ///< [in] defines the (x,y,z) source offset in pixels in the 1D, 2D, or 3D + ///< image + ur_rect_offset_t + dstOffset, ///< [in] defines the (x,y,z) destination offset in pixels in the 1D, 2D, + ///< or 3D image + ur_rect_region_t + copyExtent, ///< [in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D + ///< region to copy + ur_rect_region_t + hostExtent, ///< [in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D + ///< region on the host uint32_t numEventsInWaitList, ///< [in] size of the event wait list const ur_event_handle_t * phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] pointer to a list of @@ -5734,7 +5778,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp( } if (context.enableParameterValidation) { - if (NULL == hContext) { + if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -5764,8 +5808,9 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp( } ur_result_t result = pfnImageCopyExp( - hContext, pDst, pSrc, pImageFormat, pImageDesc, imageCopyFlags, - numEventsInWaitList, phEventWaitList, phEvent); + hQueue, pDst, pSrc, pImageFormat, pImageDesc, imageCopyFlags, srcOffset, + dstOffset, copyExtent, hostExtent, numEventsInWaitList, phEventWaitList, + phEvent); return result; } @@ -5809,6 +5854,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( /// @brief Intercept function for urBindlessImagesMipmapGetLevelExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] memory handle to the mipmap image uint32_t mipmapLevel, ///< [in] requested level of the mipmap @@ -5827,6 +5873,10 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (NULL == hDevice) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (NULL == hImageMem) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -5836,8 +5886,8 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( } } - ur_result_t result = - pfnMipmapGetLevelExp(hContext, hImageMem, mipmapLevel, phImageMem); + ur_result_t result = pfnMipmapGetLevelExp(hContext, hDevice, hImageMem, + mipmapLevel, phImageMem); return result; } @@ -5846,6 +5896,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( /// @brief Intercept function for urBindlessImagesMipmapFreeExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hMem ///< [in] handle of image memory to be freed ) { auto pfnMipmapFreeExp = @@ -5860,12 +5911,16 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (NULL == hDevice) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (NULL == hMem) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } } - ur_result_t result = pfnMipmapFreeExp(hContext, hMem); + ur_result_t result = pfnMipmapFreeExp(hContext, hDevice, hMem); return result; } @@ -5874,6 +5929,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( /// @brief Intercept function for urBindlessImagesImportOpaqueFDExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object size_t size, ///< [in] size of the external memory uint32_t fileDescriptor, ///< [in] the file descriptor ur_exp_interop_mem_handle_t @@ -5891,13 +5947,17 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (NULL == hDevice) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (NULL == phInteropMem) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } } - ur_result_t result = - pfnImportOpaqueFDExp(hContext, size, fileDescriptor, phInteropMem); + ur_result_t result = pfnImportOpaqueFDExp(hContext, hDevice, size, + fileDescriptor, phInteropMem); return result; } @@ -5906,12 +5966,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( /// @brief Intercept function for urBindlessImagesMapExternalArrayExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_interop_mem_handle_t hInteropMem, ///< [in] interop memory handle to the external memory - ur_exp_image_handle_t * + ur_exp_image_mem_handle_t * phImageMem ///< [out] image memory handle to the externally allocated memory ) { auto pfnMapExternalArrayExp = @@ -5926,6 +5987,10 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (NULL == hDevice) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (NULL == hInteropMem) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -5948,7 +6013,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( } ur_result_t result = pfnMapExternalArrayExp( - hContext, pImageFormat, pImageDesc, hInteropMem, phImageMem); + hContext, hDevice, pImageFormat, pImageDesc, hInteropMem, phImageMem); return result; } @@ -5957,6 +6022,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( /// @brief Intercept function for urBindlessImagesReleaseInteropExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_mem_handle_t hInteropMem ///< [in] handle of interop memory to be freed ) { @@ -5972,12 +6038,16 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (NULL == hDevice) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (NULL == hInteropMem) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } } - ur_result_t result = pfnReleaseInteropExp(hContext, hInteropMem); + ur_result_t result = pfnReleaseInteropExp(hContext, hDevice, hInteropMem); if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.decrementRefCount(hInteropMem); @@ -5991,6 +6061,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object uint32_t fileDescriptor, ///< [in] the file descriptor ur_exp_interop_semaphore_handle_t * phInteropSemaphoreHandle ///< [out] interop semaphore handle to the external semaphore @@ -6008,13 +6079,17 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (NULL == hDevice) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (NULL == phInteropSemaphoreHandle) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } } ur_result_t result = pfnImportExternalSemaphoreOpaqueFDExp( - hContext, fileDescriptor, phInteropSemaphoreHandle); + hContext, hDevice, fileDescriptor, phInteropSemaphoreHandle); return result; } @@ -6023,6 +6098,7 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( /// @brief Intercept function for urBindlessImagesDestroyExternalSemaphoreExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_semaphore_handle_t hInteropSemaphore ///< [in] handle of interop semaphore to be destroyed ) { @@ -6038,13 +6114,17 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (NULL == hDevice) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (NULL == hInteropSemaphore) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } } ur_result_t result = - pfnDestroyExternalSemaphoreExp(hContext, hInteropSemaphore); + pfnDestroyExternalSemaphoreExp(hContext, hDevice, hInteropSemaphore); return result; } diff --git a/source/loader/ur_ldrddi.cpp b/source/loader/ur_ldrddi.cpp index ded860ff5b..b7176acac2 100644 --- a/source/loader/ur_ldrddi.cpp +++ b/source/loader/ur_ldrddi.cpp @@ -5264,6 +5264,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPitchedAllocExp( __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageHandleDestroyExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_handle_t hImage ///< [in] pointer to handle of image object to destroy ) { @@ -5280,11 +5281,14 @@ urBindlessImagesUnsampledImageHandleDestroyExp( // convert loader handle to platform handle hContext = reinterpret_cast(hContext)->handle; + // convert loader handle to platform handle + hDevice = reinterpret_cast(hDevice)->handle; + // convert loader handle to platform handle hImage = reinterpret_cast(hImage)->handle; // forward to device-platform - result = pfnUnsampledImageHandleDestroyExp(hContext, hImage); + result = pfnUnsampledImageHandleDestroyExp(hContext, hDevice, hImage); return result; } @@ -5294,6 +5298,7 @@ urBindlessImagesUnsampledImageHandleDestroyExp( __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageHandleDestroyExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_handle_t hImage ///< [in] pointer to handle of image object to destroy ) { @@ -5310,11 +5315,14 @@ urBindlessImagesSampledImageHandleDestroyExp( // convert loader handle to platform handle hContext = reinterpret_cast(hContext)->handle; + // convert loader handle to platform handle + hDevice = reinterpret_cast(hDevice)->handle; + // convert loader handle to platform handle hImage = reinterpret_cast(hImage)->handle; // forward to device-platform - result = pfnSampledImageHandleDestroyExp(hContext, hImage); + result = pfnSampledImageHandleDestroyExp(hContext, hDevice, hImage); return result; } @@ -5323,6 +5331,7 @@ urBindlessImagesSampledImageHandleDestroyExp( /// @brief Intercept function for urBindlessImagesImageAllocateExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description @@ -5342,9 +5351,12 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( // 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 = - pfnImageAllocateExp(hContext, pImageFormat, pImageDesc, phImageMem); + result = pfnImageAllocateExp(hContext, hDevice, pImageFormat, pImageDesc, + phImageMem); if (UR_RESULT_SUCCESS != result) { return result; @@ -5365,6 +5377,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( /// @brief Intercept function for urBindlessImagesImageFreeExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem ///< [in] handle of image memory to be freed ) { @@ -5380,12 +5393,15 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( // convert loader handle to platform handle hContext = reinterpret_cast(hContext)->handle; + // convert loader handle to platform handle + hDevice = reinterpret_cast(hDevice)->handle; + // convert loader handle to platform handle hImageMem = reinterpret_cast(hImageMem)->handle; // forward to device-platform - result = pfnImageFreeExp(hContext, hImageMem); + result = pfnImageFreeExp(hContext, hDevice, hImageMem); return result; } @@ -5394,6 +5410,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( /// @brief Intercept function for urBindlessImagesUnsampledImageCreateExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] handle to memory from which to create the image const ur_image_format_t @@ -5416,13 +5433,16 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( // convert loader handle to platform handle hContext = reinterpret_cast(hContext)->handle; + // convert loader handle to platform handle + hDevice = reinterpret_cast(hDevice)->handle; + // convert loader handle to platform handle hImageMem = reinterpret_cast(hImageMem)->handle; // forward to device-platform - result = pfnUnsampledImageCreateExp(hContext, hImageMem, pImageFormat, - pImageDesc, phMem, phImage); + result = pfnUnsampledImageCreateExp( + hContext, hDevice, hImageMem, pImageFormat, pImageDesc, phMem, phImage); if (UR_RESULT_SUCCESS != result) { return result; @@ -5451,6 +5471,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( /// @brief Intercept function for urBindlessImagesSampledImageCreateExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] handle to memory from which to create the image const ur_image_format_t @@ -5474,6 +5495,9 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( // convert loader handle to platform handle hContext = reinterpret_cast(hContext)->handle; + // convert loader handle to platform handle + hDevice = reinterpret_cast(hDevice)->handle; + // convert loader handle to platform handle hImageMem = reinterpret_cast(hImageMem)->handle; @@ -5482,8 +5506,9 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( hSampler = reinterpret_cast(hSampler)->handle; // forward to device-platform - result = pfnSampledImageCreateExp(hContext, hImageMem, pImageFormat, - pImageDesc, hSampler, phMem, phImage); + result = + pfnSampledImageCreateExp(hContext, hDevice, hImageMem, pImageFormat, + pImageDesc, hSampler, phMem, phImage); if (UR_RESULT_SUCCESS != result) { return result; @@ -5511,14 +5536,26 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urBindlessImagesImageCopyExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp( - ur_context_handle_t hContext, ///< [in] handle of the context object - void *pDst, ///< [in] location the data will be copied to - void *pSrc, ///< [in] location the data will be copied from + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + void *pDst, ///< [in] location the data will be copied to + void *pSrc, ///< [in] location the data will be copied from const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_image_copy_flags_t imageCopyFlags, ///< [in] flags describing copy direction e.g. H2D or D2H + ur_rect_offset_t + srcOffset, ///< [in] defines the (x,y,z) source offset in pixels in the 1D, 2D, or 3D + ///< image + ur_rect_offset_t + dstOffset, ///< [in] defines the (x,y,z) destination offset in pixels in the 1D, 2D, + ///< or 3D image + ur_rect_region_t + copyExtent, ///< [in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D + ///< region to copy + ur_rect_region_t + hostExtent, ///< [in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D + ///< region on the host uint32_t numEventsInWaitList, ///< [in] size of the event wait list const ur_event_handle_t * phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] pointer to a list of @@ -5533,14 +5570,14 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp( ur_result_t result = UR_RESULT_SUCCESS; // extract platform's function pointer table - auto dditable = reinterpret_cast(hContext)->dditable; + auto dditable = reinterpret_cast(hQueue)->dditable; auto pfnImageCopyExp = dditable->ur.BindlessImagesExp.pfnImageCopyExp; if (nullptr == pfnImageCopyExp) { return UR_RESULT_ERROR_UNINITIALIZED; } // convert loader handle to platform handle - hContext = reinterpret_cast(hContext)->handle; + hQueue = reinterpret_cast(hQueue)->handle; // convert loader handles to platform handles auto phEventWaitListLocal = @@ -5551,8 +5588,9 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp( } // forward to device-platform - result = pfnImageCopyExp(hContext, pDst, pSrc, pImageFormat, pImageDesc, - imageCopyFlags, numEventsInWaitList, + result = pfnImageCopyExp(hQueue, pDst, pSrc, pImageFormat, pImageDesc, + imageCopyFlags, srcOffset, dstOffset, copyExtent, + hostExtent, numEventsInWaitList, phEventWaitListLocal.data(), phEvent); if (UR_RESULT_SUCCESS != result) { @@ -5604,6 +5642,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( /// @brief Intercept function for urBindlessImagesMipmapGetLevelExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] memory handle to the mipmap image uint32_t mipmapLevel, ///< [in] requested level of the mipmap @@ -5623,12 +5662,16 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( // convert loader handle to platform handle hContext = reinterpret_cast(hContext)->handle; + // convert loader handle to platform handle + hDevice = reinterpret_cast(hDevice)->handle; + // convert loader handle to platform handle hImageMem = reinterpret_cast(hImageMem)->handle; // forward to device-platform - result = pfnMipmapGetLevelExp(hContext, hImageMem, mipmapLevel, phImageMem); + result = pfnMipmapGetLevelExp(hContext, hDevice, hImageMem, mipmapLevel, + phImageMem); if (UR_RESULT_SUCCESS != result) { return result; @@ -5649,6 +5692,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( /// @brief Intercept function for urBindlessImagesMipmapFreeExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hMem ///< [in] handle of image memory to be freed ) { ur_result_t result = UR_RESULT_SUCCESS; @@ -5663,11 +5707,14 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( // convert loader handle to platform handle hContext = reinterpret_cast(hContext)->handle; + // convert loader handle to platform handle + hDevice = reinterpret_cast(hDevice)->handle; + // convert loader handle to platform handle hMem = reinterpret_cast(hMem)->handle; // forward to device-platform - result = pfnMipmapFreeExp(hContext, hMem); + result = pfnMipmapFreeExp(hContext, hDevice, hMem); return result; } @@ -5676,6 +5723,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( /// @brief Intercept function for urBindlessImagesImportOpaqueFDExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object size_t size, ///< [in] size of the external memory uint32_t fileDescriptor, ///< [in] the file descriptor ur_exp_interop_mem_handle_t @@ -5694,8 +5742,12 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( // 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 = pfnImportOpaqueFDExp(hContext, size, fileDescriptor, phInteropMem); + result = pfnImportOpaqueFDExp(hContext, hDevice, size, fileDescriptor, + phInteropMem); if (UR_RESULT_SUCCESS != result) { return result; @@ -5716,12 +5768,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( /// @brief Intercept function for urBindlessImagesMapExternalArrayExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_interop_mem_handle_t hInteropMem, ///< [in] interop memory handle to the external memory - ur_exp_image_handle_t * + ur_exp_image_mem_handle_t * phImageMem ///< [out] image memory handle to the externally allocated memory ) { ur_result_t result = UR_RESULT_SUCCESS; @@ -5737,12 +5790,15 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( // convert loader handle to platform handle hContext = reinterpret_cast(hContext)->handle; + // convert loader handle to platform handle + hDevice = reinterpret_cast(hDevice)->handle; + // convert loader handle to platform handle hInteropMem = reinterpret_cast(hInteropMem)->handle; // forward to device-platform - result = pfnMapExternalArrayExp(hContext, pImageFormat, pImageDesc, + result = pfnMapExternalArrayExp(hContext, hDevice, pImageFormat, pImageDesc, hInteropMem, phImageMem); if (UR_RESULT_SUCCESS != result) { @@ -5751,8 +5807,8 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( try { // convert platform handle to loader handle - *phImageMem = reinterpret_cast( - ur_exp_image_factory.getInstance(*phImageMem, dditable)); + *phImageMem = reinterpret_cast( + ur_exp_image_mem_factory.getInstance(*phImageMem, dditable)); } catch (std::bad_alloc &) { result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY; } @@ -5764,6 +5820,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( /// @brief Intercept function for urBindlessImagesReleaseInteropExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_mem_handle_t hInteropMem ///< [in] handle of interop memory to be freed ) { @@ -5780,12 +5837,15 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( // convert loader handle to platform handle hContext = reinterpret_cast(hContext)->handle; + // convert loader handle to platform handle + hDevice = reinterpret_cast(hDevice)->handle; + // convert loader handle to platform handle hInteropMem = reinterpret_cast(hInteropMem)->handle; // forward to device-platform - result = pfnReleaseInteropExp(hContext, hInteropMem); + result = pfnReleaseInteropExp(hContext, hDevice, hInteropMem); return result; } @@ -5795,6 +5855,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object uint32_t fileDescriptor, ///< [in] the file descriptor ur_exp_interop_semaphore_handle_t * phInteropSemaphoreHandle ///< [out] interop semaphore handle to the external semaphore @@ -5812,9 +5873,12 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( // 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 = pfnImportExternalSemaphoreOpaqueFDExp(hContext, fileDescriptor, - phInteropSemaphoreHandle); + result = pfnImportExternalSemaphoreOpaqueFDExp( + hContext, hDevice, fileDescriptor, phInteropSemaphoreHandle); if (UR_RESULT_SUCCESS != result) { return result; @@ -5837,6 +5901,7 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( /// @brief Intercept function for urBindlessImagesDestroyExternalSemaphoreExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_semaphore_handle_t hInteropSemaphore ///< [in] handle of interop semaphore to be destroyed ) { @@ -5853,13 +5918,17 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( // convert loader handle to platform handle hContext = reinterpret_cast(hContext)->handle; + // convert loader handle to platform handle + hDevice = reinterpret_cast(hDevice)->handle; + // convert loader handle to platform handle hInteropSemaphore = reinterpret_cast(hInteropSemaphore) ->handle; // forward to device-platform - result = pfnDestroyExternalSemaphoreExp(hContext, hInteropSemaphore); + result = + pfnDestroyExternalSemaphoreExp(hContext, hDevice, hInteropSemaphore); return result; } diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index 3c2fef794a..aef555b1fa 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -5828,11 +5828,13 @@ ur_result_t UR_APICALL urUSMPitchedAllocExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImage` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesUnsampledImageHandleDestroyExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_handle_t hImage ///< [in] pointer to handle of image object to destroy ) try { @@ -5843,7 +5845,7 @@ ur_result_t UR_APICALL urBindlessImagesUnsampledImageHandleDestroyExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnUnsampledImageHandleDestroyExp(hContext, hImage); + return pfnUnsampledImageHandleDestroyExp(hContext, hDevice, hImage); } catch (...) { return exceptionToResult(std::current_exception()); } @@ -5862,11 +5864,13 @@ ur_result_t UR_APICALL urBindlessImagesUnsampledImageHandleDestroyExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImage` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesSampledImageHandleDestroyExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_handle_t hImage ///< [in] pointer to handle of image object to destroy ) try { @@ -5877,7 +5881,7 @@ ur_result_t UR_APICALL urBindlessImagesSampledImageHandleDestroyExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnSampledImageHandleDestroyExp(hContext, hImage); + return pfnSampledImageHandleDestroyExp(hContext, hDevice, hImage); } catch (...) { return exceptionToResult(std::current_exception()); } @@ -5897,6 +5901,7 @@ ur_result_t UR_APICALL urBindlessImagesSampledImageHandleDestroyExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pImageFormat` /// + `NULL == pImageDesc` @@ -5909,6 +5914,7 @@ ur_result_t UR_APICALL urBindlessImagesSampledImageHandleDestroyExp( /// - ::UR_RESULT_ERROR_INVALID_OPERATION ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description @@ -5921,7 +5927,8 @@ ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnImageAllocateExp(hContext, pImageFormat, pImageDesc, phImageMem); + return pfnImageAllocateExp(hContext, hDevice, pImageFormat, pImageDesc, + phImageMem); } catch (...) { return exceptionToResult(std::current_exception()); } @@ -5940,11 +5947,13 @@ ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImageMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesImageFreeExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem ///< [in] handle of image memory to be freed ) try { @@ -5954,7 +5963,7 @@ ur_result_t UR_APICALL urBindlessImagesImageFreeExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnImageFreeExp(hContext, hImageMem); + return pfnImageFreeExp(hContext, hDevice, hImageMem); } catch (...) { return exceptionToResult(std::current_exception()); } @@ -5973,6 +5982,7 @@ ur_result_t UR_APICALL urBindlessImagesImageFreeExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImageMem` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pImageFormat` @@ -5987,6 +5997,7 @@ ur_result_t UR_APICALL urBindlessImagesImageFreeExp( /// - ::UR_RESULT_ERROR_INVALID_OPERATION ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] handle to memory from which to create the image const ur_image_format_t @@ -6003,8 +6014,8 @@ ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnUnsampledImageCreateExp(hContext, hImageMem, pImageFormat, - pImageDesc, phMem, phImage); + return pfnUnsampledImageCreateExp(hContext, hDevice, hImageMem, + pImageFormat, pImageDesc, phMem, phImage); } catch (...) { return exceptionToResult(std::current_exception()); } @@ -6023,6 +6034,7 @@ ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImageMem` /// + `NULL == hSampler` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER @@ -6039,6 +6051,7 @@ ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( /// - ::UR_RESULT_ERROR_INVALID_OPERATION ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] handle to memory from which to create the image const ur_image_format_t @@ -6055,7 +6068,7 @@ ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnSampledImageCreateExp(hContext, hImageMem, pImageFormat, + return pfnSampledImageCreateExp(hContext, hDevice, hImageMem, pImageFormat, pImageDesc, hSampler, phMem, phImage); } catch (...) { return exceptionToResult(std::current_exception()); @@ -6077,7 +6090,7 @@ ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hContext` +/// + `NULL == hQueue` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pDst` /// + `NULL == pSrc` @@ -6085,21 +6098,33 @@ ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( /// + `NULL == pImageDesc` /// - ::UR_RESULT_ERROR_INVALID_ENUMERATION /// + `::UR_EXP_IMAGE_COPY_FLAGS_MASK & imageCopyFlags` -/// - ::UR_RESULT_ERROR_INVALID_CONTEXT +/// - ::UR_RESULT_ERROR_INVALID_QUEUE /// - ::UR_RESULT_ERROR_INVALID_VALUE /// - ::UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR /// + `pImageDesc && UR_MEM_TYPE_IMAGE1D_BUFFER < pImageDesc->type` /// - ::UR_RESULT_ERROR_INVALID_IMAGE_SIZE /// - ::UR_RESULT_ERROR_INVALID_OPERATION ur_result_t UR_APICALL urBindlessImagesImageCopyExp( - ur_context_handle_t hContext, ///< [in] handle of the context object - void *pDst, ///< [in] location the data will be copied to - void *pSrc, ///< [in] location the data will be copied from + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + void *pDst, ///< [in] location the data will be copied to + void *pSrc, ///< [in] location the data will be copied from const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_image_copy_flags_t imageCopyFlags, ///< [in] flags describing copy direction e.g. H2D or D2H + ur_rect_offset_t + srcOffset, ///< [in] defines the (x,y,z) source offset in pixels in the 1D, 2D, or 3D + ///< image + ur_rect_offset_t + dstOffset, ///< [in] defines the (x,y,z) destination offset in pixels in the 1D, 2D, + ///< or 3D image + ur_rect_region_t + copyExtent, ///< [in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D + ///< region to copy + ur_rect_region_t + hostExtent, ///< [in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D + ///< region on the host uint32_t numEventsInWaitList, ///< [in] size of the event wait list const ur_event_handle_t * phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] pointer to a list of @@ -6117,8 +6142,9 @@ ur_result_t UR_APICALL urBindlessImagesImageCopyExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnImageCopyExp(hContext, pDst, pSrc, pImageFormat, pImageDesc, - imageCopyFlags, numEventsInWaitList, phEventWaitList, + return pfnImageCopyExp(hQueue, pDst, pSrc, pImageFormat, pImageDesc, + imageCopyFlags, srcOffset, dstOffset, copyExtent, + hostExtent, numEventsInWaitList, phEventWaitList, phEvent); } catch (...) { return exceptionToResult(std::current_exception()); @@ -6176,6 +6202,7 @@ ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImageMem` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phImageMem` @@ -6183,6 +6210,7 @@ ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] memory handle to the mipmap image uint32_t mipmapLevel, ///< [in] requested level of the mipmap @@ -6195,7 +6223,8 @@ ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnMipmapGetLevelExp(hContext, hImageMem, mipmapLevel, phImageMem); + return pfnMipmapGetLevelExp(hContext, hDevice, hImageMem, mipmapLevel, + phImageMem); } catch (...) { return exceptionToResult(std::current_exception()); } @@ -6214,11 +6243,13 @@ ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hMem ///< [in] handle of image memory to be freed ) try { auto pfnMipmapFreeExp = @@ -6227,7 +6258,7 @@ ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnMipmapFreeExp(hContext, hMem); + return pfnMipmapFreeExp(hContext, hDevice, hMem); } catch (...) { return exceptionToResult(std::current_exception()); } @@ -6246,6 +6277,7 @@ ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phInteropMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT @@ -6253,6 +6285,7 @@ ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( /// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object size_t size, ///< [in] size of the external memory uint32_t fileDescriptor, ///< [in] the file descriptor ur_exp_interop_mem_handle_t @@ -6264,7 +6297,8 @@ ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnImportOpaqueFDExp(hContext, size, fileDescriptor, phInteropMem); + return pfnImportOpaqueFDExp(hContext, hDevice, size, fileDescriptor, + phInteropMem); } catch (...) { return exceptionToResult(std::current_exception()); } @@ -6279,6 +6313,7 @@ ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hInteropMem` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pImageFormat` @@ -6293,12 +6328,13 @@ ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( /// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_interop_mem_handle_t hInteropMem, ///< [in] interop memory handle to the external memory - ur_exp_image_handle_t * + ur_exp_image_mem_handle_t * phImageMem ///< [out] image memory handle to the externally allocated memory ) try { auto pfnMapExternalArrayExp = @@ -6307,7 +6343,7 @@ ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnMapExternalArrayExp(hContext, pImageFormat, pImageDesc, + return pfnMapExternalArrayExp(hContext, hDevice, pImageFormat, pImageDesc, hInteropMem, phImageMem); } catch (...) { return exceptionToResult(std::current_exception()); @@ -6327,11 +6363,13 @@ ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hInteropMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_mem_handle_t hInteropMem ///< [in] handle of interop memory to be freed ) try { @@ -6341,7 +6379,7 @@ ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnReleaseInteropExp(hContext, hInteropMem); + return pfnReleaseInteropExp(hContext, hDevice, hInteropMem); } catch (...) { return exceptionToResult(std::current_exception()); } @@ -6360,12 +6398,14 @@ ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phInteropSemaphoreHandle` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object uint32_t fileDescriptor, ///< [in] the file descriptor ur_exp_interop_semaphore_handle_t * phInteropSemaphoreHandle ///< [out] interop semaphore handle to the external semaphore @@ -6377,8 +6417,8 @@ ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnImportExternalSemaphoreOpaqueFDExp(hContext, fileDescriptor, - phInteropSemaphoreHandle); + return pfnImportExternalSemaphoreOpaqueFDExp( + hContext, hDevice, fileDescriptor, phInteropSemaphoreHandle); } catch (...) { return exceptionToResult(std::current_exception()); } @@ -6397,11 +6437,13 @@ ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hInteropSemaphore` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_semaphore_handle_t hInteropSemaphore ///< [in] handle of interop semaphore to be destroyed ) try { @@ -6412,7 +6454,7 @@ ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnDestroyExternalSemaphoreExp(hContext, hInteropSemaphore); + return pfnDestroyExternalSemaphoreExp(hContext, hDevice, hInteropSemaphore); } catch (...) { return exceptionToResult(std::current_exception()); } diff --git a/source/ur_api.cpp b/source/ur_api.cpp index b13dfdb44c..e367cb7e8c 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -4930,11 +4930,13 @@ ur_result_t UR_APICALL urUSMPitchedAllocExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImage` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesUnsampledImageHandleDestroyExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_handle_t hImage ///< [in] pointer to handle of image object to destroy ) { @@ -4956,11 +4958,13 @@ ur_result_t UR_APICALL urBindlessImagesUnsampledImageHandleDestroyExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImage` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesSampledImageHandleDestroyExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_handle_t hImage ///< [in] pointer to handle of image object to destroy ) { @@ -4983,6 +4987,7 @@ ur_result_t UR_APICALL urBindlessImagesSampledImageHandleDestroyExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pImageFormat` /// + `NULL == pImageDesc` @@ -4995,6 +5000,7 @@ ur_result_t UR_APICALL urBindlessImagesSampledImageHandleDestroyExp( /// - ::UR_RESULT_ERROR_INVALID_OPERATION ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description @@ -5019,11 +5025,13 @@ ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImageMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesImageFreeExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem ///< [in] handle of image memory to be freed ) { @@ -5045,6 +5053,7 @@ ur_result_t UR_APICALL urBindlessImagesImageFreeExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImageMem` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pImageFormat` @@ -5059,6 +5068,7 @@ ur_result_t UR_APICALL urBindlessImagesImageFreeExp( /// - ::UR_RESULT_ERROR_INVALID_OPERATION ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] handle to memory from which to create the image const ur_image_format_t @@ -5086,6 +5096,7 @@ ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImageMem` /// + `NULL == hSampler` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER @@ -5102,6 +5113,7 @@ ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( /// - ::UR_RESULT_ERROR_INVALID_OPERATION ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] handle to memory from which to create the image const ur_image_format_t @@ -5132,7 +5144,7 @@ ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hContext` +/// + `NULL == hQueue` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pDst` /// + `NULL == pSrc` @@ -5140,21 +5152,33 @@ ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( /// + `NULL == pImageDesc` /// - ::UR_RESULT_ERROR_INVALID_ENUMERATION /// + `::UR_EXP_IMAGE_COPY_FLAGS_MASK & imageCopyFlags` -/// - ::UR_RESULT_ERROR_INVALID_CONTEXT +/// - ::UR_RESULT_ERROR_INVALID_QUEUE /// - ::UR_RESULT_ERROR_INVALID_VALUE /// - ::UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR /// + `pImageDesc && UR_MEM_TYPE_IMAGE1D_BUFFER < pImageDesc->type` /// - ::UR_RESULT_ERROR_INVALID_IMAGE_SIZE /// - ::UR_RESULT_ERROR_INVALID_OPERATION ur_result_t UR_APICALL urBindlessImagesImageCopyExp( - ur_context_handle_t hContext, ///< [in] handle of the context object - void *pDst, ///< [in] location the data will be copied to - void *pSrc, ///< [in] location the data will be copied from + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + void *pDst, ///< [in] location the data will be copied to + void *pSrc, ///< [in] location the data will be copied from const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_image_copy_flags_t imageCopyFlags, ///< [in] flags describing copy direction e.g. H2D or D2H + ur_rect_offset_t + srcOffset, ///< [in] defines the (x,y,z) source offset in pixels in the 1D, 2D, or 3D + ///< image + ur_rect_offset_t + dstOffset, ///< [in] defines the (x,y,z) destination offset in pixels in the 1D, 2D, + ///< or 3D image + ur_rect_region_t + copyExtent, ///< [in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D + ///< region to copy + ur_rect_region_t + hostExtent, ///< [in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D + ///< region on the host uint32_t numEventsInWaitList, ///< [in] size of the event wait list const ur_event_handle_t * phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] pointer to a list of @@ -5215,6 +5239,7 @@ ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImageMem` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phImageMem` @@ -5222,6 +5247,7 @@ ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] memory handle to the mipmap image uint32_t mipmapLevel, ///< [in] requested level of the mipmap @@ -5246,11 +5272,13 @@ ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hMem ///< [in] handle of image memory to be freed ) { ur_result_t result = UR_RESULT_SUCCESS; @@ -5271,6 +5299,7 @@ ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phInteropMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT @@ -5278,6 +5307,7 @@ ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( /// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object size_t size, ///< [in] size of the external memory uint32_t fileDescriptor, ///< [in] the file descriptor ur_exp_interop_mem_handle_t @@ -5297,6 +5327,7 @@ ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hInteropMem` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pImageFormat` @@ -5311,12 +5342,13 @@ ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( /// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_interop_mem_handle_t hInteropMem, ///< [in] interop memory handle to the external memory - ur_exp_image_handle_t * + ur_exp_image_mem_handle_t * phImageMem ///< [out] image memory handle to the externally allocated memory ) { ur_result_t result = UR_RESULT_SUCCESS; @@ -5337,11 +5369,13 @@ ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hInteropMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_mem_handle_t hInteropMem ///< [in] handle of interop memory to be freed ) { @@ -5363,12 +5397,14 @@ ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phInteropSemaphoreHandle` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object uint32_t fileDescriptor, ///< [in] the file descriptor ur_exp_interop_semaphore_handle_t * phInteropSemaphoreHandle ///< [out] interop semaphore handle to the external semaphore @@ -5391,11 +5427,13 @@ ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hInteropSemaphore` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_semaphore_handle_t hInteropSemaphore ///< [in] handle of interop semaphore to be destroyed ) { From 4a9ea1734fbe03e82fb91bcf1b882d6b3fef7ec2 Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Tue, 27 Jun 2023 10:54:46 +0100 Subject: [PATCH 007/104] [UR] Install DPCXX --- .github/workflows/cmake.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 0e6bfadc3c..8f82ee0184 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -55,6 +55,12 @@ jobs: make sudo make install cd .. + + - name: Download DPC++ + run: | + sudo apt install libncurses5 + wget -O ${{github.workspace}}/dpcpp_compiler.tar.gz https://github.com/intel/llvm/releases/download/sycl-nightly%2F20230626/dpcpp-compiler.tar.gz + tar -xvf ${{github.workspace}}/dpcpp_compiler.tar.gz - name: Configure CMake run: > @@ -67,6 +73,7 @@ jobs: -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DUR_BUILD_TESTS=ON -DUR_FORMAT_CPP_STYLE=ON + -DUR_DPCXX=${{github.workspace}}/dpcpp_compiler/bin/clang++ ${{matrix.libbacktrace}} - name: Generate source from spec, check for uncommitted diff From fa8ec81ca519c4f2303cd3655ec206860b6d275f Mon Sep 17 00:00:00 2001 From: Igor Chorazewicz Date: Tue, 20 Jun 2023 16:03:22 +0000 Subject: [PATCH 008/104] [uma] Improve reporting of pool/provider specific errors Memory provider: Remove the get_last_result function and replace it with get_last_error. This primary difference is the addition of the pError out parameter which returns a native error code emitted from a failed provider function which resulted in returning UMA_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC. Memory_pool: Remove the get_last_result function and replace it with get_last_allocation_status. For memory pool, I don't think we care about a pool-specific error codes. We do, however, want to know why the previous allocation/de-allocation failed. Memory pool allocation functions only return a pointer so we need an extra function (get_last_allocation_status) to get this information. --- source/common/uma_helpers.hpp | 5 +- source/common/uma_pools/disjoint_pool.cpp | 10 ++-- source/common/uma_pools/disjoint_pool.hpp | 2 +- .../include/uma/base.h | 13 ++--- .../include/uma/memory_pool.h | 33 +++++------- .../include/uma/memory_pool_ops.h | 2 +- .../include/uma/memory_provider.h | 28 +++++----- .../include/uma/memory_provider_ops.h | 4 +- .../src/memory_pool.c | 6 +-- .../src/memory_provider.c | 9 ++-- .../src/memory_tracker.cpp | 8 +-- test/unified_memory_allocation/common/pool.c | 53 +++++++++---------- .../unified_memory_allocation/common/pool.hpp | 7 +-- .../common/provider.c | 19 +++---- .../common/provider.hpp | 4 +- .../memoryPoolAPI.cpp | 9 +--- .../memoryProviderAPI.cpp | 7 ++- 17 files changed, 100 insertions(+), 119 deletions(-) diff --git a/source/common/uma_helpers.hpp b/source/common/uma_helpers.hpp index 67eddd6811..35f4123491 100644 --- a/source/common/uma_helpers.hpp +++ b/source/common/uma_helpers.hpp @@ -87,7 +87,7 @@ auto memoryProviderMakeUnique(Args &&...args) { UMA_ASSIGN_OP(ops, T, alloc, UMA_RESULT_ERROR_UNKNOWN); UMA_ASSIGN_OP(ops, T, free, UMA_RESULT_ERROR_UNKNOWN); - UMA_ASSIGN_OP(ops, T, get_last_result, UMA_RESULT_ERROR_UNKNOWN); + UMA_ASSIGN_OP_NORETURN(ops, T, get_last_native_error); UMA_ASSIGN_OP(ops, T, get_recommended_page_size, UMA_RESULT_ERROR_UNKNOWN); UMA_ASSIGN_OP(ops, T, get_min_page_size, UMA_RESULT_ERROR_UNKNOWN); UMA_ASSIGN_OP(ops, T, purge_lazy, UMA_RESULT_ERROR_UNKNOWN); @@ -147,13 +147,14 @@ auto poolMakeUnique(uma_memory_provider_handle_t *providers, UMA_ASSIGN_OP(ops, T, realloc, ((void *)nullptr)); UMA_ASSIGN_OP(ops, T, malloc_usable_size, ((size_t)0)); UMA_ASSIGN_OP_NORETURN(ops, T, free); - UMA_ASSIGN_OP(ops, T, get_last_result, UMA_RESULT_ERROR_UNKNOWN); + UMA_ASSIGN_OP(ops, T, get_last_allocation_error, UMA_RESULT_ERROR_UNKNOWN); uma_memory_pool_handle_t hPool = nullptr; auto ret = umaPoolCreate(&ops, providers, numProviders, &argsTuple, &hPool); return std::pair{ ret, pool_unique_handle_t(hPool, &umaPoolDestroy)}; } + } // namespace uma #endif /* UMA_HELPERS_H */ diff --git a/source/common/uma_pools/disjoint_pool.cpp b/source/common/uma_pools/disjoint_pool.cpp index 562d8f1d7c..c26e654da7 100644 --- a/source/common/uma_pools/disjoint_pool.cpp +++ b/source/common/uma_pools/disjoint_pool.cpp @@ -332,8 +332,7 @@ static void *memoryProviderAlloc(uma_memory_provider_handle_t hProvider, void *ptr; auto ret = umaMemoryProviderAlloc(hProvider, size, alignment, &ptr); if (ret != UMA_RESULT_SUCCESS) { - // TODO: Set last error appropriately - throw std::runtime_error("umaMemoryProviderAlloc"); + throw MemoryProviderError{ret}; } return ptr; } @@ -342,8 +341,7 @@ static void memoryProviderFree(uma_memory_provider_handle_t hProvider, void *ptr) { auto ret = umaMemoryProviderFree(hProvider, ptr, 0); if (ret != UMA_RESULT_SUCCESS) { - // TODO: introduce custom exceptions? PI L0 relies on those - throw std::runtime_error("memoryProviderFree"); + throw MemoryProviderError{ret}; } } @@ -939,9 +937,7 @@ void DisjointPool::free(void *ptr) { return; } -enum uma_result_t DisjointPool::get_last_result(const char **ppMessage) { - // TODO: implement and return last error, we probably need something like - // https://github.com/oneapi-src/unified-runtime/issues/500 in UMA +enum uma_result_t DisjointPool::get_last_allocation_error() { return UMA_RESULT_ERROR_UNKNOWN; } diff --git a/source/common/uma_pools/disjoint_pool.hpp b/source/common/uma_pools/disjoint_pool.hpp index c991fa07bb..fb1e34f2d7 100644 --- a/source/common/uma_pools/disjoint_pool.hpp +++ b/source/common/uma_pools/disjoint_pool.hpp @@ -68,7 +68,7 @@ class DisjointPool { void *aligned_malloc(size_t size, size_t alignment); size_t malloc_usable_size(void *); void free(void *ptr); - enum uma_result_t get_last_result(const char **ppMessage); + enum uma_result_t get_last_allocation_error(); DisjointPool(); ~DisjointPool(); diff --git a/source/common/unified_memory_allocation/include/uma/base.h b/source/common/unified_memory_allocation/include/uma/base.h index 7d5d34f987..bc00e2db3a 100644 --- a/source/common/unified_memory_allocation/include/uma/base.h +++ b/source/common/unified_memory_allocation/include/uma/base.h @@ -36,16 +36,13 @@ enum uma_result_t { UMA_RESULT_SUCCESS = 0, ///< Success UMA_RESULT_ERROR_OUT_OF_HOST_MEMORY = 1, ///< Insufficient host memory to satisfy call, - UMA_RESULT_ERROR_POOL_SPECIFIC = - 2, ///< A pool specific warning/error has been reported and can be - ///< Retrieved via the umaPoolGetLastResult entry point. UMA_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC = - 3, ///< A provider specific warning/error has been reported and can be - ///< Retrieved via the umaMemoryProviderGetLastResult entry point. + 2, ///< A provider specific warning/error has been reported and can be + ///< Retrieved via the umaMemoryProviderGetLastNativeError entry point. UMA_RESULT_ERROR_INVALID_ARGUMENT = - 4, ///< Generic error code for invalid arguments - UMA_RESULT_ERROR_INVALID_ALIGNMENT = 5, /// Invalid alignment of an argument - UMA_RESULT_ERROR_NOT_SUPPORTED = 6, /// Operation not supported + 3, ///< Generic error code for invalid arguments + UMA_RESULT_ERROR_INVALID_ALIGNMENT = 4, /// Invalid alignment of an argument + UMA_RESULT_ERROR_NOT_SUPPORTED = 5, /// Operation not supported UMA_RESULT_ERROR_UNKNOWN = 0x7ffffffe ///< Unknown or internal error }; diff --git a/source/common/unified_memory_allocation/include/uma/memory_pool.h b/source/common/unified_memory_allocation/include/uma/memory_pool.h index d2cc044a58..812aa0c963 100644 --- a/source/common/unified_memory_allocation/include/uma/memory_pool.h +++ b/source/common/unified_memory_allocation/include/uma/memory_pool.h @@ -104,28 +104,23 @@ void umaPoolFree(uma_memory_pool_handle_t hPool, void *ptr); void umaFree(void *ptr); /// -/// \brief Retrieve string representation of the underlying pool specific -/// result reported by the last API that returned -/// UMA_RESULT_ERROR_POOL_SPECIFIC or NULL ptr (in case of allocation -/// functions). Allows for a pool independent way to -/// return a pool specific result. +/// \brief Retrieve uma_result_t representing the error of the last failed allocation +/// operation in this thread (malloc, calloc, realloc, aligned_malloc). /// /// \details -/// - The string returned via the ppMessage is a NULL terminated C style -/// string. -/// - The string returned via the ppMessage is thread local. -/// - The memory in the string returned via the ppMessage is owned by the -/// adapter. -/// - The application may call this function from simultaneous threads. -/// - The implementation of this function should be lock-free. +/// * Implementations *must* store the error code in thread-local +/// storage prior to returning NULL from the allocation functions. +/// +/// * If the last allocation/de-allocation operation succeeded, the value returned by +/// this function is unspecified. +/// +/// * The application *may* call this function from simultaneous threads. +/// +/// * The implementation of this function *should* be lock-free. /// \param hPool specified memory hPool -/// \param ppMessage [out] pointer to a string containing provider specific -/// result in string representation. -/// \return UMA_RESULT_SUCCESS if the result being -/// reported is to be considered a warning. Any other result code -/// returned indicates that the adapter specific result is an error. -enum uma_result_t umaPoolGetLastResult(uma_memory_pool_handle_t hPool, - const char **ppMessage); +/// \return Error code desciribng the failure of the last failed allocation operation. +/// The value is undefined if the previous allocation was successful. +enum uma_result_t umaPoolGetLastAllocationError(uma_memory_pool_handle_t hPool); /// /// \brief Retrieve memory pool associated with a given ptr. diff --git a/source/common/unified_memory_allocation/include/uma/memory_pool_ops.h b/source/common/unified_memory_allocation/include/uma/memory_pool_ops.h index 31a15ca02f..21fae70b27 100644 --- a/source/common/unified_memory_allocation/include/uma/memory_pool_ops.h +++ b/source/common/unified_memory_allocation/include/uma/memory_pool_ops.h @@ -49,7 +49,7 @@ struct uma_memory_pool_ops_t { void *(*aligned_malloc)(void *pool, size_t size, size_t alignment); size_t (*malloc_usable_size)(void *pool, void *ptr); void (*free)(void *pool, void *); - enum uma_result_t (*get_last_result)(void *pool, const char **ppMessage); + enum uma_result_t (*get_last_allocation_error)(void *pool); }; #ifdef __cplusplus diff --git a/source/common/unified_memory_allocation/include/uma/memory_provider.h b/source/common/unified_memory_allocation/include/uma/memory_provider.h index d3c2df3ac4..8201d54f22 100644 --- a/source/common/unified_memory_allocation/include/uma/memory_provider.h +++ b/source/common/unified_memory_allocation/include/uma/memory_provider.h @@ -67,23 +67,25 @@ enum uma_result_t umaMemoryProviderFree(uma_memory_provider_handle_t hProvider, /// independent way to return a provider specific result. /// /// \details -/// - The string returned via the ppMessage is a NULL terminated C style -/// string. -/// - The string returned via the ppMessage is thread local. -/// - The memory in the string returned via the ppMessage is owned by the -/// adapter. -/// - The application may call this function from simultaneous threads. -/// - The implementation of this function should be lock-free. +/// * Implementations *must* store the message and error code in thread-local +/// storage prior to returning UMA_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC. /// +/// * The message and error code will only be valid if a previously +/// called entry-point returned UMA_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC. +/// +/// * The memory pointed to by the C string returned in `ppMessage` is owned by +/// the adapter and *must* be null terminated. +/// +/// * The application *may* call this function from simultaneous threads. +/// +/// * The implementation of this function *should* be lock-free. /// \param hProvider handle to the memory provider /// \param ppMessage [out] pointer to a string containing provider specific /// result in string representation -/// \return UMA_RESULT_SUCCESS if the result being reported is to be considered -/// a warning. Any other result code returned indicates that the -/// adapter specific result is an error. -enum uma_result_t -umaMemoryProviderGetLastResult(uma_memory_provider_handle_t hProvider, - const char **ppMessage); +/// \param pError [out] pointer to an integer where the adapter specific error code will be stored +void umaMemoryProviderGetLastNativeError(uma_memory_provider_handle_t hProvider, + const char **ppMessage, + int32_t *pError); /// /// \brief Retrieve recommended page size for a given allocation size. diff --git a/source/common/unified_memory_allocation/include/uma/memory_provider_ops.h b/source/common/unified_memory_allocation/include/uma/memory_provider_ops.h index 40c2ac8a0f..e5afbdaa53 100644 --- a/source/common/unified_memory_allocation/include/uma/memory_provider_ops.h +++ b/source/common/unified_memory_allocation/include/uma/memory_provider_ops.h @@ -41,8 +41,8 @@ struct uma_memory_provider_ops_t { enum uma_result_t (*alloc)(void *provider, size_t size, size_t alignment, void **ptr); enum uma_result_t (*free)(void *provider, void *ptr, size_t size); - enum uma_result_t (*get_last_result)(void *provider, - const char **ppMessage); + void (*get_last_native_error)(void *provider, const char **ppMessage, + int32_t *pError); enum uma_result_t (*get_recommended_page_size)(void *provider, size_t size, size_t *pageSize); enum uma_result_t (*get_min_page_size)(void *provider, void *ptr, diff --git a/source/common/unified_memory_allocation/src/memory_pool.c b/source/common/unified_memory_allocation/src/memory_pool.c index 754e4697bd..13a86d8a6c 100644 --- a/source/common/unified_memory_allocation/src/memory_pool.c +++ b/source/common/unified_memory_allocation/src/memory_pool.c @@ -130,9 +130,9 @@ void umaFree(void *ptr) { } } -enum uma_result_t umaPoolGetLastResult(uma_memory_pool_handle_t hPool, - const char **ppMessage) { - return hPool->ops.get_last_result(hPool->pool_priv, ppMessage); +enum uma_result_t +umaPoolGetLastAllocationError(uma_memory_pool_handle_t hPool) { + return hPool->ops.get_last_allocation_error(hPool->pool_priv); } uma_memory_pool_handle_t umaPoolByPtr(const void *ptr) { diff --git a/source/common/unified_memory_allocation/src/memory_provider.c b/source/common/unified_memory_allocation/src/memory_provider.c index 23b05cd4d4..345bc8e6ab 100644 --- a/source/common/unified_memory_allocation/src/memory_provider.c +++ b/source/common/unified_memory_allocation/src/memory_provider.c @@ -62,10 +62,11 @@ enum uma_result_t umaMemoryProviderFree(uma_memory_provider_handle_t hProvider, return hProvider->ops.free(hProvider->provider_priv, ptr, size); } -enum uma_result_t -umaMemoryProviderGetLastResult(uma_memory_provider_handle_t hProvider, - const char **ppMessage) { - return hProvider->ops.get_last_result(hProvider->provider_priv, ppMessage); +void umaMemoryProviderGetLastNativeError(uma_memory_provider_handle_t hProvider, + const char **ppMessage, + int32_t *pError) { + hProvider->ops.get_last_native_error(hProvider->provider_priv, ppMessage, + pError); } void *umaMemoryProviderGetPriv(uma_memory_provider_handle_t hProvider) { diff --git a/source/common/unified_memory_allocation/src/memory_tracker.cpp b/source/common/unified_memory_allocation/src/memory_tracker.cpp index 6f56134db2..0dc118b738 100644 --- a/source/common/unified_memory_allocation/src/memory_tracker.cpp +++ b/source/common/unified_memory_allocation/src/memory_tracker.cpp @@ -168,11 +168,11 @@ static enum uma_result_t trackingInitialize(void *params, void **ret) { static void trackingFinalize(void *provider) { free(provider); } -static enum uma_result_t trackingGetLastResult(void *provider, - const char **msg) { +static void trackingGetLastError(void *provider, const char **msg, + int32_t *pError) { uma_tracking_memory_provider_t *p = (uma_tracking_memory_provider_t *)provider; - return umaMemoryProviderGetLastResult(p->hUpstream, msg); + umaMemoryProviderGetLastNativeError(p->hUpstream, msg, pError); } static enum uma_result_t @@ -224,7 +224,7 @@ enum uma_result_t umaTrackingMemoryProviderCreate( trackingMemoryProviderOps.finalize = trackingFinalize; trackingMemoryProviderOps.alloc = trackingAlloc; trackingMemoryProviderOps.free = trackingFree; - trackingMemoryProviderOps.get_last_result = trackingGetLastResult; + trackingMemoryProviderOps.get_last_native_error = trackingGetLastError; trackingMemoryProviderOps.get_min_page_size = trackingGetMinPageSize; trackingMemoryProviderOps.get_recommended_page_size = trackingGetRecommendedPageSize; diff --git a/test/unified_memory_allocation/common/pool.c b/test/unified_memory_allocation/common/pool.c index 7d229cf11f..200ed75dff 100644 --- a/test/unified_memory_allocation/common/pool.c +++ b/test/unified_memory_allocation/common/pool.c @@ -62,24 +62,23 @@ static void nullFree(void *pool, void *ptr) { (void)ptr; } -enum uma_result_t nullGetLastResult(void *pool, const char **ppMsg) { +enum uma_result_t nullGetLastStatus(void *pool) { (void)pool; - (void)ppMsg; return UMA_RESULT_SUCCESS; } uma_memory_pool_handle_t nullPoolCreate(void) { - struct uma_memory_pool_ops_t ops = {.version = UMA_VERSION_CURRENT, - .initialize = nullInitialize, - .finalize = nullFinalize, - .malloc = nullMalloc, - .realloc = nullRealloc, - .calloc = nullCalloc, - .aligned_malloc = nullAlignedMalloc, - .malloc_usable_size = - nullMallocUsableSize, - .free = nullFree, - .get_last_result = nullGetLastResult}; + struct uma_memory_pool_ops_t ops = { + .version = UMA_VERSION_CURRENT, + .initialize = nullInitialize, + .finalize = nullFinalize, + .malloc = nullMalloc, + .realloc = nullRealloc, + .calloc = nullCalloc, + .aligned_malloc = nullAlignedMalloc, + .malloc_usable_size = nullMallocUsableSize, + .free = nullFree, + .get_last_allocation_error = nullGetLastStatus}; uma_memory_provider_handle_t providerDesc = nullProviderCreate(); uma_memory_pool_handle_t hPool; @@ -159,28 +158,28 @@ static void traceFree(void *pool, void *ptr) { umaPoolFree(tracePool->params.hUpstreamPool, ptr); } -enum uma_result_t traceGetLastResult(void *pool, const char **ppMsg) { +enum uma_result_t traceGetLastStatus(void *pool) { struct tracePool *tracePool = (struct tracePool *)pool; - tracePool->params.trace("get_last_result"); - return umaPoolGetLastResult(tracePool->params.hUpstreamPool, ppMsg); + tracePool->params.trace("get_last_native_error"); + return umaPoolGetLastAllocationError(tracePool->params.hUpstreamPool); } uma_memory_pool_handle_t tracePoolCreate(uma_memory_pool_handle_t hUpstreamPool, uma_memory_provider_handle_t providerDesc, void (*trace)(const char *)) { - struct uma_memory_pool_ops_t ops = {.version = UMA_VERSION_CURRENT, - .initialize = traceInitialize, - .finalize = traceFinalize, - .malloc = traceMalloc, - .realloc = traceRealloc, - .calloc = traceCalloc, - .aligned_malloc = traceAlignedMalloc, - .malloc_usable_size = - traceMallocUsableSize, - .free = traceFree, - .get_last_result = traceGetLastResult}; + struct uma_memory_pool_ops_t ops = { + .version = UMA_VERSION_CURRENT, + .initialize = traceInitialize, + .finalize = traceFinalize, + .malloc = traceMalloc, + .realloc = traceRealloc, + .calloc = traceCalloc, + .aligned_malloc = traceAlignedMalloc, + .malloc_usable_size = traceMallocUsableSize, + .free = traceFree, + .get_last_allocation_error = traceGetLastStatus}; struct traceParams params = {.hUpstreamPool = hUpstreamPool, .trace = trace}; diff --git a/test/unified_memory_allocation/common/pool.hpp b/test/unified_memory_allocation/common/pool.hpp index f360af34dd..f9830f5f83 100644 --- a/test/unified_memory_allocation/common/pool.hpp +++ b/test/unified_memory_allocation/common/pool.hpp @@ -37,8 +37,8 @@ struct pool_base { void *aligned_malloc(size_t, size_t) noexcept { return nullptr; } size_t malloc_usable_size(void *) noexcept { return 0; } void free(void *) noexcept {} - enum uma_result_t get_last_result(const char **ppMessage) noexcept { - return UMA_RESULT_ERROR_UNKNOWN; + enum uma_result_t get_last_allocation_error() noexcept { + return UMA_RESULT_SUCCESS; } }; @@ -102,9 +102,6 @@ struct proxy_pool : public pool_base { auto ret = umaMemoryProviderFree(provider, ptr, 0); EXPECT_EQ_NOEXCEPT(ret, UMA_RESULT_SUCCESS); } - enum uma_result_t get_last_result(const char **ppMessage) noexcept { - return umaMemoryProviderGetLastResult(provider, ppMessage); - } uma_memory_provider_handle_t provider; }; diff --git a/test/unified_memory_allocation/common/provider.c b/test/unified_memory_allocation/common/provider.c index 05dce162ed..55968223da 100644 --- a/test/unified_memory_allocation/common/provider.c +++ b/test/unified_memory_allocation/common/provider.c @@ -34,10 +34,11 @@ static enum uma_result_t nullFree(void *provider, void *ptr, size_t size) { return UMA_RESULT_SUCCESS; } -static enum uma_result_t nullGetLastResult(void *provider, const char **ppMsg) { +static void nullGetLastError(void *provider, const char **ppMsg, + int32_t *pError) { (void)provider; (void)ppMsg; - return UMA_RESULT_SUCCESS; + (void)pError; } static enum uma_result_t nullGetRecommendedPageSize(void *provider, size_t size, @@ -84,7 +85,7 @@ uma_memory_provider_handle_t nullProviderCreate(void) { .finalize = nullFinalize, .alloc = nullAlloc, .free = nullFree, - .get_last_result = nullGetLastResult, + .get_last_native_error = nullGetLastError, .get_recommended_page_size = nullGetRecommendedPageSize, .get_min_page_size = nullGetPageSize, .purge_lazy = nullPurgeLazy, @@ -131,13 +132,13 @@ static enum uma_result_t traceFree(void *provider, void *ptr, size_t size) { return umaMemoryProviderFree(traceProvider->hUpstreamProvider, ptr, size); } -static enum uma_result_t traceGetLastResult(void *provider, - const char **ppMsg) { +static void traceGetLastError(void *provider, const char **ppMsg, + int32_t *pError) { struct traceParams *traceProvider = (struct traceParams *)provider; - traceProvider->trace("get_last_result"); - return umaMemoryProviderGetLastResult(traceProvider->hUpstreamProvider, - ppMsg); + traceProvider->trace("get_last_native_error"); + umaMemoryProviderGetLastNativeError(traceProvider->hUpstreamProvider, ppMsg, + pError); } static enum uma_result_t @@ -193,7 +194,7 @@ traceProviderCreate(uma_memory_provider_handle_t hUpstreamProvider, .finalize = traceFinalize, .alloc = traceAlloc, .free = traceFree, - .get_last_result = traceGetLastResult, + .get_last_native_error = traceGetLastError, .get_recommended_page_size = traceGetRecommendedPageSize, .get_min_page_size = traceGetPageSize, .purge_lazy = tracePurgeLazy, diff --git a/test/unified_memory_allocation/common/provider.hpp b/test/unified_memory_allocation/common/provider.hpp index c60ebf0c3d..6030990f52 100644 --- a/test/unified_memory_allocation/common/provider.hpp +++ b/test/unified_memory_allocation/common/provider.hpp @@ -33,9 +33,7 @@ struct provider_base { enum uma_result_t free(void *ptr, size_t size) noexcept { return UMA_RESULT_ERROR_UNKNOWN; } - enum uma_result_t get_last_result(const char **) noexcept { - return UMA_RESULT_ERROR_UNKNOWN; - } + void get_last_native_error(const char **, int32_t *) noexcept {} enum uma_result_t get_recommended_page_size(size_t size, size_t *pageSize) noexcept { return UMA_RESULT_ERROR_UNKNOWN; diff --git a/test/unified_memory_allocation/memoryPoolAPI.cpp b/test/unified_memory_allocation/memoryPoolAPI.cpp index af5aa5f077..ffcc3afed8 100644 --- a/test/unified_memory_allocation/memoryPoolAPI.cpp +++ b/test/unified_memory_allocation/memoryPoolAPI.cpp @@ -80,15 +80,11 @@ TEST_F(test, memoryPoolTrace) { ASSERT_EQ(providerCalls.size(), provider_call_count); - ret = umaPoolGetLastResult(tracingPool.get(), nullptr); + ret = umaPoolGetLastAllocationError(tracingPool.get()); ASSERT_EQ(ret, UMA_RESULT_SUCCESS); - - ASSERT_EQ(poolCalls["get_last_result"], 1); + ASSERT_EQ(poolCalls["get_last_native_error"], 1); ASSERT_EQ(poolCalls.size(), ++pool_call_count); - ASSERT_EQ(providerCalls["get_last_result"], 1); - ASSERT_EQ(providerCalls.size(), ++provider_call_count); - umaMemoryProviderDestroy(providerDesc); } @@ -194,7 +190,6 @@ struct poolInitializeTest : uma_test::test, INSTANTIATE_TEST_SUITE_P( poolInitializeTest, poolInitializeTest, ::testing::Values(UMA_RESULT_ERROR_OUT_OF_HOST_MEMORY, - UMA_RESULT_ERROR_POOL_SPECIFIC, UMA_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC, UMA_RESULT_ERROR_INVALID_ARGUMENT, UMA_RESULT_ERROR_UNKNOWN)); diff --git a/test/unified_memory_allocation/memoryProviderAPI.cpp b/test/unified_memory_allocation/memoryProviderAPI.cpp index f770050f32..510c2b88be 100644 --- a/test/unified_memory_allocation/memoryProviderAPI.cpp +++ b/test/unified_memory_allocation/memoryProviderAPI.cpp @@ -33,9 +33,9 @@ TEST_F(test, memoryProviderTrace) { ASSERT_EQ(calls["free"], 1); ASSERT_EQ(calls.size(), ++call_count); - ret = umaMemoryProviderGetLastResult(tracingProvider.get(), nullptr); - ASSERT_EQ(ret, UMA_RESULT_SUCCESS); - ASSERT_EQ(calls["get_last_result"], 1); + umaMemoryProviderGetLastNativeError(tracingProvider.get(), nullptr, + nullptr); + ASSERT_EQ(calls["get_last_native_error"], 1); ASSERT_EQ(calls.size(), ++call_count); ret = umaMemoryProviderGetRecommendedPageSize(tracingProvider.get(), 0, @@ -76,7 +76,6 @@ struct providerInitializeTest : uma_test::test, INSTANTIATE_TEST_SUITE_P( providerInitializeTest, providerInitializeTest, ::testing::Values(UMA_RESULT_ERROR_OUT_OF_HOST_MEMORY, - UMA_RESULT_ERROR_POOL_SPECIFIC, UMA_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC, UMA_RESULT_ERROR_INVALID_ARGUMENT, UMA_RESULT_ERROR_UNKNOWN)); From 438c0d37f8b777fb86c9ff571566526b2dddaf36 Mon Sep 17 00:00:00 2001 From: Igor Chorazewicz Date: Tue, 20 Jun 2023 17:33:44 +0000 Subject: [PATCH 009/104] [uma] Improve error reporing int DisjointPool use get_last_allocation_error to return last error from allocation functions. --- source/common/uma_helpers.hpp | 5 ++++ source/common/uma_pools/disjoint_pool.cpp | 28 +++++++++++++++++++---- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/source/common/uma_helpers.hpp b/source/common/uma_helpers.hpp index 35f4123491..2d7d9a4059 100644 --- a/source/common/uma_helpers.hpp +++ b/source/common/uma_helpers.hpp @@ -155,6 +155,11 @@ auto poolMakeUnique(uma_memory_provider_handle_t *providers, ret, pool_unique_handle_t(hPool, &umaPoolDestroy)}; } +template uma_result_t &getPoolLastStatusRef() { + static thread_local uma_result_t last_status = UMA_RESULT_SUCCESS; + return last_status; +} + } // namespace uma #endif /* UMA_HELPERS_H */ diff --git a/source/common/uma_pools/disjoint_pool.cpp b/source/common/uma_pools/disjoint_pool.cpp index c26e654da7..34f72a290e 100644 --- a/source/common/uma_pools/disjoint_pool.cpp +++ b/source/common/uma_pools/disjoint_pool.cpp @@ -74,6 +74,10 @@ static size_t AlignUp(size_t Val, size_t Alignment) { return (Val + Alignment - 1) & (~(Alignment - 1)); } +struct MemoryProviderError { + uma_result_t code; +}; + DisjointPoolConfig::DisjointPoolConfig() : limits(std::make_shared()) {} @@ -371,7 +375,13 @@ Slab::~Slab() { } catch (std::exception &e) { std::cout << "DisjointPool: unexpected error: " << e.what() << "\n"; } - memoryProviderFree(bucket.getMemHandle(), MemPtr); + + try { + memoryProviderFree(bucket.getMemHandle(), MemPtr); + } catch (MemoryProviderError &e) { + std::cout << "DisjointPool: error from memory provider: " << e.code + << "\n"; + } } // Return the index of the first available chunk, SIZE_MAX otherwise @@ -717,7 +727,7 @@ void Bucket::printStats(bool &TitlePrinted, const std::string &Label) { } } -void *DisjointPool::AllocImpl::allocate(size_t Size, bool &FromPool) { +void *DisjointPool::AllocImpl::allocate(size_t Size, bool &FromPool) try { void *Ptr; if (Size == 0) { @@ -742,10 +752,13 @@ void *DisjointPool::AllocImpl::allocate(size_t Size, bool &FromPool) { } return Ptr; +} catch (MemoryProviderError &e) { + uma::getPoolLastStatusRef() = e.code; + return nullptr; } void *DisjointPool::AllocImpl::allocate(size_t Size, size_t Alignment, - bool &FromPool) { + bool &FromPool) try { void *Ptr; if (Size == 0) { @@ -789,6 +802,9 @@ void *DisjointPool::AllocImpl::allocate(size_t Size, size_t Alignment, } return AlignPtrUp(Ptr, Alignment); +} catch (MemoryProviderError &e) { + uma::getPoolLastStatusRef() = e.code; + return nullptr; } Bucket &DisjointPool::AllocImpl::findBucket(size_t Size) { @@ -803,7 +819,7 @@ Bucket &DisjointPool::AllocImpl::findBucket(size_t Size) { return *(*It); } -void DisjointPool::AllocImpl::deallocate(void *Ptr, bool &ToPool) { +void DisjointPool::AllocImpl::deallocate(void *Ptr, bool &ToPool) try { auto *SlabPtr = AlignPtrDown(Ptr, SlabMinSize()); // Lock the map on read @@ -846,6 +862,8 @@ void DisjointPool::AllocImpl::deallocate(void *Ptr, bool &ToPool) { // to some slab with an entry in the map. So we find a slab // but the range checks fail. memoryProviderFree(getMemHandle(), Ptr); +} catch (MemoryProviderError &e) { + uma::getPoolLastStatusRef() = e.code; } void DisjointPool::AllocImpl::printStats(bool &TitlePrinted, @@ -938,7 +956,7 @@ void DisjointPool::free(void *ptr) { } enum uma_result_t DisjointPool::get_last_allocation_error() { - return UMA_RESULT_ERROR_UNKNOWN; + return uma::getPoolLastStatusRef(); } DisjointPool::DisjointPool() {} From 21b15daa1b5a7fae7c651647dfd593575a1322b4 Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Wed, 28 Jun 2023 11:08:31 +0100 Subject: [PATCH 010/104] [UR] Setup Virtual Memory CTS template --- test/conformance/CMakeLists.txt | 1 + test/conformance/virtual_memory/CMakeLists.txt | 17 +++++++++++++++++ .../virtual_memory/urPhysicalMemCreate.cpp | 4 ++++ .../virtual_memory/urPhysicalMemRelease.cpp | 4 ++++ .../virtual_memory/urPhysicalMemRetain.cpp | 4 ++++ .../virtual_memory/urVirtualMemFree.cpp | 4 ++++ .../virtual_memory/urVirtualMemGetInfo.cpp | 4 ++++ .../urVirtualMemGranularityGetInfo.cpp | 4 ++++ .../virtual_memory/urVirtualMemMap.cpp | 4 ++++ .../virtual_memory/urVirtualMemReserve.cpp | 4 ++++ .../virtual_memory/urVirtualMemSetAccess.cpp | 4 ++++ .../virtual_memory/urVirtualMemUnmap.cpp | 4 ++++ 12 files changed, 58 insertions(+) create mode 100644 test/conformance/virtual_memory/CMakeLists.txt create mode 100644 test/conformance/virtual_memory/urPhysicalMemCreate.cpp create mode 100644 test/conformance/virtual_memory/urPhysicalMemRelease.cpp create mode 100644 test/conformance/virtual_memory/urPhysicalMemRetain.cpp create mode 100644 test/conformance/virtual_memory/urVirtualMemFree.cpp create mode 100644 test/conformance/virtual_memory/urVirtualMemGetInfo.cpp create mode 100644 test/conformance/virtual_memory/urVirtualMemGranularityGetInfo.cpp create mode 100644 test/conformance/virtual_memory/urVirtualMemMap.cpp create mode 100644 test/conformance/virtual_memory/urVirtualMemReserve.cpp create mode 100644 test/conformance/virtual_memory/urVirtualMemSetAccess.cpp create mode 100644 test/conformance/virtual_memory/urVirtualMemUnmap.cpp diff --git a/test/conformance/CMakeLists.txt b/test/conformance/CMakeLists.txt index 5c14d3e34a..3b9292e13f 100644 --- a/test/conformance/CMakeLists.txt +++ b/test/conformance/CMakeLists.txt @@ -54,6 +54,7 @@ add_subdirectory(usm) add_subdirectory(event) add_subdirectory(queue) add_subdirectory(sampler) +add_subdirectory(virtual_memory) if(DEFINED UR_DPCXX) add_custom_target(generate_device_binaries) diff --git a/test/conformance/virtual_memory/CMakeLists.txt b/test/conformance/virtual_memory/CMakeLists.txt new file mode 100644 index 0000000000..6ae27f443b --- /dev/null +++ b/test/conformance/virtual_memory/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright (C) 2023 Intel Corporation +# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +# See LICENSE.TXT +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +add_conformance_test_with_devices_environment(virtual_memory + urPhysicalMemCreate.cpp + urPhysicalMemRelease.cpp + urPhysicalMemRetain.cpp + urVirtualMemFree.cpp + urVirtualMemGetInfo.cpp + urVirtualMemGranularityGetInfo.cpp + urVirtualMemMap.cpp + urVirtualMemReserve.cpp + urVirtualMemSetAccess.cpp + urVirtualMemUnmap.cpp +) diff --git a/test/conformance/virtual_memory/urPhysicalMemCreate.cpp b/test/conformance/virtual_memory/urPhysicalMemCreate.cpp new file mode 100644 index 0000000000..281aa8badb --- /dev/null +++ b/test/conformance/virtual_memory/urPhysicalMemCreate.cpp @@ -0,0 +1,4 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception diff --git a/test/conformance/virtual_memory/urPhysicalMemRelease.cpp b/test/conformance/virtual_memory/urPhysicalMemRelease.cpp new file mode 100644 index 0000000000..281aa8badb --- /dev/null +++ b/test/conformance/virtual_memory/urPhysicalMemRelease.cpp @@ -0,0 +1,4 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception diff --git a/test/conformance/virtual_memory/urPhysicalMemRetain.cpp b/test/conformance/virtual_memory/urPhysicalMemRetain.cpp new file mode 100644 index 0000000000..281aa8badb --- /dev/null +++ b/test/conformance/virtual_memory/urPhysicalMemRetain.cpp @@ -0,0 +1,4 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception diff --git a/test/conformance/virtual_memory/urVirtualMemFree.cpp b/test/conformance/virtual_memory/urVirtualMemFree.cpp new file mode 100644 index 0000000000..281aa8badb --- /dev/null +++ b/test/conformance/virtual_memory/urVirtualMemFree.cpp @@ -0,0 +1,4 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception diff --git a/test/conformance/virtual_memory/urVirtualMemGetInfo.cpp b/test/conformance/virtual_memory/urVirtualMemGetInfo.cpp new file mode 100644 index 0000000000..281aa8badb --- /dev/null +++ b/test/conformance/virtual_memory/urVirtualMemGetInfo.cpp @@ -0,0 +1,4 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception diff --git a/test/conformance/virtual_memory/urVirtualMemGranularityGetInfo.cpp b/test/conformance/virtual_memory/urVirtualMemGranularityGetInfo.cpp new file mode 100644 index 0000000000..281aa8badb --- /dev/null +++ b/test/conformance/virtual_memory/urVirtualMemGranularityGetInfo.cpp @@ -0,0 +1,4 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception diff --git a/test/conformance/virtual_memory/urVirtualMemMap.cpp b/test/conformance/virtual_memory/urVirtualMemMap.cpp new file mode 100644 index 0000000000..281aa8badb --- /dev/null +++ b/test/conformance/virtual_memory/urVirtualMemMap.cpp @@ -0,0 +1,4 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception diff --git a/test/conformance/virtual_memory/urVirtualMemReserve.cpp b/test/conformance/virtual_memory/urVirtualMemReserve.cpp new file mode 100644 index 0000000000..281aa8badb --- /dev/null +++ b/test/conformance/virtual_memory/urVirtualMemReserve.cpp @@ -0,0 +1,4 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception diff --git a/test/conformance/virtual_memory/urVirtualMemSetAccess.cpp b/test/conformance/virtual_memory/urVirtualMemSetAccess.cpp new file mode 100644 index 0000000000..281aa8badb --- /dev/null +++ b/test/conformance/virtual_memory/urVirtualMemSetAccess.cpp @@ -0,0 +1,4 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception diff --git a/test/conformance/virtual_memory/urVirtualMemUnmap.cpp b/test/conformance/virtual_memory/urVirtualMemUnmap.cpp new file mode 100644 index 0000000000..281aa8badb --- /dev/null +++ b/test/conformance/virtual_memory/urVirtualMemUnmap.cpp @@ -0,0 +1,4 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception From 95bfbeb08ca9f4b8a973a3ad515eeee2a481738d Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Wed, 28 Jun 2023 12:06:46 +0100 Subject: [PATCH 011/104] [UR][CTS] Adds CTS coverage for urVirtualMemGranularityGetInfo --- include/ur_api.h | 12 +++ scripts/core/virtual_memory.yml | 13 +++ source/loader/layers/validation/ur_valddi.cpp | 12 +++ source/loader/ur_libapi.cpp | 12 +++ source/ur_api.cpp | 12 +++ .../urVirtualMemGranularityGetInfo.cpp | 96 +++++++++++++++++++ 6 files changed, 157 insertions(+) diff --git a/include/ur_api.h b/include/ur_api.h index bd31448845..5c001e9c22 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -3063,6 +3063,18 @@ typedef enum ur_virtual_mem_granularity_info_t { /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_ENUMERATION /// + `::UR_VIRTUAL_MEM_GRANULARITY_INFO_RECOMMENDED < propName` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// + If `propName` is not supported by the adapter. +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `propSize == 0 && pPropValue != NULL` +/// + If `propSize` is less than the real number of bytes needed to return the info. +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `propSize != 0 && pPropValue == NULL` +/// + `pPropValue == NULL && pPropSizeRet == NULL` +/// - ::UR_RESULT_ERROR_INVALID_DEVICE +/// - ::UR_RESULT_ERROR_INVALID_CONTEXT +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY UR_APIEXPORT ur_result_t UR_APICALL urVirtualMemGranularityGetInfo( ur_context_handle_t hContext, ///< [in] handle of the context object. diff --git a/scripts/core/virtual_memory.yml b/scripts/core/virtual_memory.yml index 774890d8f5..c6f707697d 100644 --- a/scripts/core/virtual_memory.yml +++ b/scripts/core/virtual_memory.yml @@ -59,6 +59,19 @@ params: desc: > [out][optional] pointer to the actual size in bytes of the queried propName." +returns: + - $X_RESULT_ERROR_UNSUPPORTED_ENUMERATION: + - "If `propName` is not supported by the adapter." + - $X_RESULT_ERROR_INVALID_SIZE: + - "`propSize == 0 && pPropValue != NULL`" + - "If `propSize` is less than the real number of bytes needed to return the info." + - $X_RESULT_ERROR_INVALID_NULL_POINTER: + - "`propSize != 0 && pPropValue == NULL`" + - "`pPropValue == NULL && pPropSizeRet == NULL`" + - $X_RESULT_ERROR_INVALID_DEVICE + - $X_RESULT_ERROR_INVALID_CONTEXT + - $X_RESULT_ERROR_OUT_OF_RESOURCES + - $X_RESULT_ERROR_OUT_OF_HOST_MEMORY --- #-------------------------------------------------------------------------- type: function diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index 3c0c079e4e..46ba1e9379 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -1890,9 +1890,21 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemGranularityGetInfo( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (propSize != 0 && pPropValue == NULL) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + + if (pPropValue == NULL && pPropSizeRet == NULL) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + if (UR_VIRTUAL_MEM_GRANULARITY_INFO_RECOMMENDED < propName) { return UR_RESULT_ERROR_INVALID_ENUMERATION; } + + if (propSize == 0 && pPropValue != NULL) { + return UR_RESULT_ERROR_INVALID_SIZE; + } } ur_result_t result = pfnGranularityGetInfo( diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index 9a22630002..8e095d05ba 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -2145,6 +2145,18 @@ ur_result_t UR_APICALL urUSMPoolGetInfo( /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_ENUMERATION /// + `::UR_VIRTUAL_MEM_GRANULARITY_INFO_RECOMMENDED < propName` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// + If `propName` is not supported by the adapter. +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `propSize == 0 && pPropValue != NULL` +/// + If `propSize` is less than the real number of bytes needed to return the info. +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `propSize != 0 && pPropValue == NULL` +/// + `pPropValue == NULL && pPropSizeRet == NULL` +/// - ::UR_RESULT_ERROR_INVALID_DEVICE +/// - ::UR_RESULT_ERROR_INVALID_CONTEXT +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY ur_result_t UR_APICALL urVirtualMemGranularityGetInfo( ur_context_handle_t hContext, ///< [in] handle of the context object. ur_device_handle_t diff --git a/source/ur_api.cpp b/source/ur_api.cpp index 4920aae5c2..89c1271a54 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -1807,6 +1807,18 @@ ur_result_t UR_APICALL urUSMPoolGetInfo( /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_ENUMERATION /// + `::UR_VIRTUAL_MEM_GRANULARITY_INFO_RECOMMENDED < propName` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// + If `propName` is not supported by the adapter. +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `propSize == 0 && pPropValue != NULL` +/// + If `propSize` is less than the real number of bytes needed to return the info. +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `propSize != 0 && pPropValue == NULL` +/// + `pPropValue == NULL && pPropSizeRet == NULL` +/// - ::UR_RESULT_ERROR_INVALID_DEVICE +/// - ::UR_RESULT_ERROR_INVALID_CONTEXT +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY ur_result_t UR_APICALL urVirtualMemGranularityGetInfo( ur_context_handle_t hContext, ///< [in] handle of the context object. ur_device_handle_t diff --git a/test/conformance/virtual_memory/urVirtualMemGranularityGetInfo.cpp b/test/conformance/virtual_memory/urVirtualMemGranularityGetInfo.cpp index 281aa8badb..d4feccd6dc 100644 --- a/test/conformance/virtual_memory/urVirtualMemGranularityGetInfo.cpp +++ b/test/conformance/virtual_memory/urVirtualMemGranularityGetInfo.cpp @@ -2,3 +2,99 @@ // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +using urVirtualMemGranularityGetInfoTest = + uur::urContextTestWithParam; + +UUR_TEST_SUITE_P( + urVirtualMemGranularityGetInfoTest, + ::testing::Values(UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM, + UR_VIRTUAL_MEM_GRANULARITY_INFO_RECOMMENDED), + uur::deviceTestWithParamPrinter); + +TEST_P(urVirtualMemGranularityGetInfoTest, Success) { + size_t size = 0; + ur_virtual_mem_granularity_info_t info = getParam(); + ASSERT_SUCCESS(urVirtualMemGranularityGetInfo(context, device, info, 0, + nullptr, &size)); + ASSERT_NE(size, 0); + + std::vector infoData(size); + ASSERT_SUCCESS(urVirtualMemGranularityGetInfo( + context, device, info, infoData.size(), infoData.data(), nullptr)); + + switch (info) { + case UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM: { + ASSERT_EQ(size, sizeof(size_t)); + size_t minimum = *reinterpret_cast(infoData.data()); + ASSERT_GT(minimum, 0); + } break; + case UR_VIRTUAL_MEM_GRANULARITY_INFO_RECOMMENDED: { + ASSERT_EQ(size, sizeof(size_t)); + size_t recommended = *reinterpret_cast(infoData.data()); + ASSERT_GT(recommended, 0); + } break; + default: + FAIL() << "Unhandled ur_virtual_mem_granularity_info_t enumeration: " + << info; + break; + } +} + +using urVirtualMemGranularityGetInfoNegativeTest = uur::urContextTest; +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urVirtualMemGranularityGetInfoNegativeTest); + +TEST_P(urVirtualMemGranularityGetInfoNegativeTest, InvalidNullHandleContext) { + size_t size = 0; + ASSERT_EQ_RESULT( + urVirtualMemGranularityGetInfo(nullptr, device, + UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM, + 0, nullptr, &size), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urVirtualMemGranularityGetInfoNegativeTest, InvalidEnumeration) { + size_t size = 0; + ASSERT_EQ_RESULT(urVirtualMemGranularityGetInfo( + context, device, + UR_VIRTUAL_MEM_GRANULARITY_INFO_FORCE_UINT32, 0, + nullptr, &size), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urVirtualMemGranularityGetInfoNegativeTest, + InvalidNullPointerPropSizeRet) { + ASSERT_EQ_RESULT( + urVirtualMemGranularityGetInfo(context, device, + UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM, + 0, nullptr, nullptr), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} + +TEST_P(urVirtualMemGranularityGetInfoNegativeTest, + InvalidNullPointerPropValue) { + ASSERT_EQ_RESULT( + urVirtualMemGranularityGetInfo(context, device, + UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM, + sizeof(size_t), nullptr, nullptr), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} + +TEST_P(urVirtualMemGranularityGetInfoNegativeTest, InvalidPropSizeZero) { + size_t minimum = 0; + ASSERT_EQ_RESULT( + urVirtualMemGranularityGetInfo(context, device, + UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM, + 0, &minimum, nullptr), + UR_RESULT_ERROR_INVALID_SIZE); +} + +TEST_P(urVirtualMemGranularityGetInfoNegativeTest, InvalidSizePropSizeSmall) { + size_t minimum = 0; + ASSERT_EQ_RESULT( + urVirtualMemGranularityGetInfo(context, device, + UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM, + sizeof(size_t) - 1, &minimum, nullptr), + UR_RESULT_ERROR_INVALID_SIZE); +} From 599942ae9d6def24d49b4735c4e24c9e2c7e45c0 Mon Sep 17 00:00:00 2001 From: Igor Chorazewicz Date: Tue, 20 Jun 2023 19:09:09 +0000 Subject: [PATCH 012/104] [uma] simplify get_name by returning the name directly instead of through out param. This function is not allowed to fail anyway. --- source/common/uma_helpers.hpp | 2 +- .../include/uma/memory_provider.h | 3 +-- .../include/uma/memory_provider_ops.h | 2 +- .../unified_memory_allocation/src/memory_provider.c | 5 ++--- .../unified_memory_allocation/src/memory_tracker.cpp | 4 ++-- test/unified_memory_allocation/common/provider.c | 8 ++++---- test/unified_memory_allocation/common/provider.hpp | 4 ++-- test/unified_memory_allocation/memoryProviderAPI.cpp | 3 +-- 8 files changed, 14 insertions(+), 17 deletions(-) diff --git a/source/common/uma_helpers.hpp b/source/common/uma_helpers.hpp index 2d7d9a4059..95a9c04f05 100644 --- a/source/common/uma_helpers.hpp +++ b/source/common/uma_helpers.hpp @@ -92,7 +92,7 @@ auto memoryProviderMakeUnique(Args &&...args) { UMA_ASSIGN_OP(ops, T, get_min_page_size, UMA_RESULT_ERROR_UNKNOWN); UMA_ASSIGN_OP(ops, T, purge_lazy, UMA_RESULT_ERROR_UNKNOWN); UMA_ASSIGN_OP(ops, T, purge_force, UMA_RESULT_ERROR_UNKNOWN); - UMA_ASSIGN_OP_NORETURN(ops, T, get_name); + UMA_ASSIGN_OP(ops, T, get_name, ""); uma_memory_provider_handle_t hProvider = nullptr; auto ret = umaMemoryProviderCreate(&ops, &argsTuple, &hProvider); diff --git a/source/common/unified_memory_allocation/include/uma/memory_provider.h b/source/common/unified_memory_allocation/include/uma/memory_provider.h index 8201d54f22..cb0f62ccb5 100644 --- a/source/common/unified_memory_allocation/include/uma/memory_provider.h +++ b/source/common/unified_memory_allocation/include/uma/memory_provider.h @@ -138,8 +138,7 @@ umaMemoryProviderPurgeForce(uma_memory_provider_handle_t hProvider, void *ptr, /// \brief Retrive name of a given memory provider. /// \param hProvider handle to the memory provider /// \param ppName [out] pointer to a string containing name of the provider -void umaMemoryProviderGetName(uma_memory_provider_handle_t hProvider, - const char **ppName); +const char *umaMemoryProviderGetName(uma_memory_provider_handle_t hProvider); #ifdef __cplusplus } diff --git a/source/common/unified_memory_allocation/include/uma/memory_provider_ops.h b/source/common/unified_memory_allocation/include/uma/memory_provider_ops.h index e5afbdaa53..404f221cb3 100644 --- a/source/common/unified_memory_allocation/include/uma/memory_provider_ops.h +++ b/source/common/unified_memory_allocation/include/uma/memory_provider_ops.h @@ -49,7 +49,7 @@ struct uma_memory_provider_ops_t { size_t *pageSize); enum uma_result_t (*purge_lazy)(void *provider, void *ptr, size_t size); enum uma_result_t (*purge_force)(void *provider, void *ptr, size_t size); - void (*get_name)(void *provider, const char **ppName); + const char *(*get_name)(void *provider); }; #ifdef __cplusplus diff --git a/source/common/unified_memory_allocation/src/memory_provider.c b/source/common/unified_memory_allocation/src/memory_provider.c index 345bc8e6ab..5ce2bbadbd 100644 --- a/source/common/unified_memory_allocation/src/memory_provider.c +++ b/source/common/unified_memory_allocation/src/memory_provider.c @@ -99,7 +99,6 @@ umaMemoryProviderPurgeForce(uma_memory_provider_handle_t hProvider, void *ptr, return hProvider->ops.purge_force(hProvider->provider_priv, ptr, size); } -void umaMemoryProviderGetName(uma_memory_provider_handle_t hProvider, - const char **ppName) { - hProvider->ops.get_name(hProvider->provider_priv, ppName); +const char *umaMemoryProviderGetName(uma_memory_provider_handle_t hProvider) { + return hProvider->ops.get_name(hProvider->provider_priv); } diff --git a/source/common/unified_memory_allocation/src/memory_tracker.cpp b/source/common/unified_memory_allocation/src/memory_tracker.cpp index 0dc118b738..32f7dff0b1 100644 --- a/source/common/unified_memory_allocation/src/memory_tracker.cpp +++ b/source/common/unified_memory_allocation/src/memory_tracker.cpp @@ -204,10 +204,10 @@ static enum uma_result_t trackingPurgeForce(void *provider, void *ptr, return umaMemoryProviderPurgeForce(p->hUpstream, ptr, size); } -static void trackingName(void *provider, const char **ppName) { +static const char *trackingName(void *provider) { uma_tracking_memory_provider_t *p = (uma_tracking_memory_provider_t *)provider; - return umaMemoryProviderGetName(p->hUpstream, ppName); + return umaMemoryProviderGetName(p->hUpstream); } enum uma_result_t umaTrackingMemoryProviderCreate( diff --git a/test/unified_memory_allocation/common/provider.c b/test/unified_memory_allocation/common/provider.c index 55968223da..a180705a58 100644 --- a/test/unified_memory_allocation/common/provider.c +++ b/test/unified_memory_allocation/common/provider.c @@ -73,9 +73,9 @@ static enum uma_result_t nullPurgeForce(void *provider, void *ptr, return UMA_RESULT_SUCCESS; } -static void nullName(void *provider, const char **ppName) { +static const char *nullName(void *provider) { (void)provider; - *ppName = "null"; + return "null"; } uma_memory_provider_handle_t nullProviderCreate(void) { @@ -178,11 +178,11 @@ static enum uma_result_t tracePurgeForce(void *provider, void *ptr, size); } -static void traceName(void *provider, const char **ppName) { +static const char *traceName(void *provider) { struct traceParams *traceProvider = (struct traceParams *)provider; traceProvider->trace("name"); - umaMemoryProviderGetName(traceProvider->hUpstreamProvider, ppName); + return umaMemoryProviderGetName(traceProvider->hUpstreamProvider); } uma_memory_provider_handle_t diff --git a/test/unified_memory_allocation/common/provider.hpp b/test/unified_memory_allocation/common/provider.hpp index 6030990f52..bca4f66872 100644 --- a/test/unified_memory_allocation/common/provider.hpp +++ b/test/unified_memory_allocation/common/provider.hpp @@ -47,7 +47,7 @@ struct provider_base { enum uma_result_t purge_force(void *ptr, size_t size) noexcept { return UMA_RESULT_ERROR_UNKNOWN; } - void get_name(const char **ppName) noexcept { *ppName = "base"; } + const char *get_name() noexcept { return "base"; } }; struct provider_malloc : public provider_base { @@ -73,7 +73,7 @@ struct provider_malloc : public provider_base { #endif return UMA_RESULT_SUCCESS; } - void get_name(const char **ppName) noexcept { *ppName = "malloc"; } + const char *get_name() noexcept { return "malloc"; } }; } // namespace uma_test diff --git a/test/unified_memory_allocation/memoryProviderAPI.cpp b/test/unified_memory_allocation/memoryProviderAPI.cpp index 510c2b88be..754b86992e 100644 --- a/test/unified_memory_allocation/memoryProviderAPI.cpp +++ b/test/unified_memory_allocation/memoryProviderAPI.cpp @@ -60,8 +60,7 @@ TEST_F(test, memoryProviderTrace) { ASSERT_EQ(calls["purge_force"], 1); ASSERT_EQ(calls.size(), ++call_count); - const char *pName; - umaMemoryProviderGetName(tracingProvider.get(), &pName); + const char *pName = umaMemoryProviderGetName(tracingProvider.get()); ASSERT_EQ(calls["name"], 1); ASSERT_EQ(calls.size(), ++call_count); ASSERT_EQ(std::string(pName), std::string("null")); From 6f0df6c6ca6bf7e963145af47f2eb486db7bb69d Mon Sep 17 00:00:00 2001 From: Igor Chorazewicz Date: Wed, 28 Jun 2023 18:19:17 +0000 Subject: [PATCH 013/104] [uma] add umaGetLastFailedMemoryProvider which returns handle to the last failed provider. This makes error reporting API independent from how memory pool is using the providers (i.e. whether there is only a single provider or multiple) --- .../unified_memory_allocation/CMakeLists.txt | 1 + .../include/uma/memory_provider.h | 10 +++ .../src/memory_provider.c | 44 ++++++++-- .../src/memory_provider_get_last_failed.cpp | 20 +++++ .../src/memory_provider_internal.h | 1 + .../unified_memory_allocation/common/pool.hpp | 8 +- .../memoryPoolAPI.cpp | 87 +++++++++++++++++++ 7 files changed, 161 insertions(+), 10 deletions(-) create mode 100644 source/common/unified_memory_allocation/src/memory_provider_get_last_failed.cpp diff --git a/source/common/unified_memory_allocation/CMakeLists.txt b/source/common/unified_memory_allocation/CMakeLists.txt index 81eb655692..7be1ab2dce 100644 --- a/source/common/unified_memory_allocation/CMakeLists.txt +++ b/source/common/unified_memory_allocation/CMakeLists.txt @@ -7,6 +7,7 @@ set(UMA_SOURCES src/memory_pool.c src/memory_provider.c src/memory_tracker.cpp + src/memory_provider_get_last_failed.cpp ) if(UMA_BUILD_SHARED_LIBRARY) diff --git a/source/common/unified_memory_allocation/include/uma/memory_provider.h b/source/common/unified_memory_allocation/include/uma/memory_provider.h index cb0f62ccb5..9b65dc6419 100644 --- a/source/common/unified_memory_allocation/include/uma/memory_provider.h +++ b/source/common/unified_memory_allocation/include/uma/memory_provider.h @@ -140,6 +140,16 @@ umaMemoryProviderPurgeForce(uma_memory_provider_handle_t hProvider, void *ptr, /// \param ppName [out] pointer to a string containing name of the provider const char *umaMemoryProviderGetName(uma_memory_provider_handle_t hProvider); +/// \brief Retrieve handle to the last memory provider that returned status other +/// than UMA_RESULT_SUCCESS on the calling thread. +/// +/// \details Handle to the memory provider is stored in the thread local +/// storage. The handle is updated every time a memory provider +/// returns status other than UMA_RESULT_SUCCESS. +/// +/// \return Handle to the memory provider +uma_memory_provider_handle_t umaGetLastFailedMemoryProvider(); + #ifdef __cplusplus } #endif diff --git a/source/common/unified_memory_allocation/src/memory_provider.c b/source/common/unified_memory_allocation/src/memory_provider.c index 5ce2bbadbd..103bcef88a 100644 --- a/source/common/unified_memory_allocation/src/memory_provider.c +++ b/source/common/unified_memory_allocation/src/memory_provider.c @@ -51,15 +51,29 @@ void umaMemoryProviderDestroy(uma_memory_provider_handle_t hProvider) { free(hProvider); } +static void +checkErrorAndSetLastProvider(enum uma_result_t result, + uma_memory_provider_handle_t hProvider) { + if (result != UMA_RESULT_SUCCESS) { + *umaGetLastFailedMemoryProviderPtr() = hProvider; + } +} + enum uma_result_t umaMemoryProviderAlloc(uma_memory_provider_handle_t hProvider, size_t size, size_t alignment, void **ptr) { - return hProvider->ops.alloc(hProvider->provider_priv, size, alignment, ptr); + enum uma_result_t res = + hProvider->ops.alloc(hProvider->provider_priv, size, alignment, ptr); + checkErrorAndSetLastProvider(res, hProvider); + return res; } enum uma_result_t umaMemoryProviderFree(uma_memory_provider_handle_t hProvider, void *ptr, size_t size) { - return hProvider->ops.free(hProvider->provider_priv, ptr, size); + enum uma_result_t res = + hProvider->ops.free(hProvider->provider_priv, ptr, size); + checkErrorAndSetLastProvider(res, hProvider); + return res; } void umaMemoryProviderGetLastNativeError(uma_memory_provider_handle_t hProvider, @@ -76,29 +90,43 @@ void *umaMemoryProviderGetPriv(uma_memory_provider_handle_t hProvider) { enum uma_result_t umaMemoryProviderGetRecommendedPageSize(uma_memory_provider_handle_t hProvider, size_t size, size_t *pageSize) { - return hProvider->ops.get_recommended_page_size(hProvider->provider_priv, - size, pageSize); + enum uma_result_t res = hProvider->ops.get_recommended_page_size( + hProvider->provider_priv, size, pageSize); + checkErrorAndSetLastProvider(res, hProvider); + return res; } enum uma_result_t umaMemoryProviderGetMinPageSize(uma_memory_provider_handle_t hProvider, void *ptr, size_t *pageSize) { - return hProvider->ops.get_min_page_size(hProvider->provider_priv, ptr, - pageSize); + enum uma_result_t res = hProvider->ops.get_min_page_size( + hProvider->provider_priv, ptr, pageSize); + checkErrorAndSetLastProvider(res, hProvider); + return res; } enum uma_result_t umaMemoryProviderPurgeLazy(uma_memory_provider_handle_t hProvider, void *ptr, size_t size) { - return hProvider->ops.purge_lazy(hProvider->provider_priv, ptr, size); + enum uma_result_t res = + hProvider->ops.purge_lazy(hProvider->provider_priv, ptr, size); + checkErrorAndSetLastProvider(res, hProvider); + return res; } enum uma_result_t umaMemoryProviderPurgeForce(uma_memory_provider_handle_t hProvider, void *ptr, size_t size) { - return hProvider->ops.purge_force(hProvider->provider_priv, ptr, size); + enum uma_result_t res = + hProvider->ops.purge_force(hProvider->provider_priv, ptr, size); + checkErrorAndSetLastProvider(res, hProvider); + return res; } const char *umaMemoryProviderGetName(uma_memory_provider_handle_t hProvider) { return hProvider->ops.get_name(hProvider->provider_priv); } + +uma_memory_provider_handle_t umaGetLastFailedMemoryProvider() { + return *umaGetLastFailedMemoryProviderPtr(); +} diff --git a/source/common/unified_memory_allocation/src/memory_provider_get_last_failed.cpp b/source/common/unified_memory_allocation/src/memory_provider_get_last_failed.cpp new file mode 100644 index 0000000000..52a4e6ce35 --- /dev/null +++ b/source/common/unified_memory_allocation/src/memory_provider_get_last_failed.cpp @@ -0,0 +1,20 @@ +/* + * + * Copyright (C) 2023 Intel Corporation + * + * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. + * See LICENSE.TXT + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + */ + +#include "memory_provider_internal.h" + +extern "C" { + +static thread_local uma_memory_provider_handle_t lastFailedProvider = nullptr; + +uma_memory_provider_handle_t *umaGetLastFailedMemoryProviderPtr() { + return &lastFailedProvider; +} +} diff --git a/source/common/unified_memory_allocation/src/memory_provider_internal.h b/source/common/unified_memory_allocation/src/memory_provider_internal.h index dce77cb6d6..a2b190488f 100644 --- a/source/common/unified_memory_allocation/src/memory_provider_internal.h +++ b/source/common/unified_memory_allocation/src/memory_provider_internal.h @@ -18,6 +18,7 @@ extern "C" { #endif void *umaMemoryProviderGetPriv(uma_memory_provider_handle_t hProvider); +uma_memory_provider_handle_t *umaGetLastFailedMemoryProviderPtr(); #ifdef __cplusplus } diff --git a/test/unified_memory_allocation/common/pool.hpp b/test/unified_memory_allocation/common/pool.hpp index f9830f5f83..6e1552140d 100644 --- a/test/unified_memory_allocation/common/pool.hpp +++ b/test/unified_memory_allocation/common/pool.hpp @@ -81,7 +81,9 @@ struct proxy_pool : public pool_base { memset(ptr, 0, num * size); - EXPECT_EQ_NOEXCEPT(ret, UMA_RESULT_SUCCESS); + if (ptr) { + EXPECT_EQ_NOEXCEPT(ret, UMA_RESULT_SUCCESS); + } return ptr; } void *realloc(void *ptr, size_t size) noexcept { @@ -91,7 +93,9 @@ struct proxy_pool : public pool_base { void *aligned_malloc(size_t size, size_t alignment) noexcept { void *ptr; auto ret = umaMemoryProviderAlloc(provider, size, alignment, &ptr); - EXPECT_EQ_NOEXCEPT(ret, UMA_RESULT_SUCCESS); + if (ptr) { + EXPECT_EQ_NOEXCEPT(ret, UMA_RESULT_SUCCESS); + } return ptr; } size_t malloc_usable_size(void *ptr) noexcept { diff --git a/test/unified_memory_allocation/memoryPoolAPI.cpp b/test/unified_memory_allocation/memoryPoolAPI.cpp index ffcc3afed8..015d3e1dd5 100644 --- a/test/unified_memory_allocation/memoryPoolAPI.cpp +++ b/test/unified_memory_allocation/memoryPoolAPI.cpp @@ -14,6 +14,7 @@ #include #include +#include #include using uma_test::test; @@ -222,3 +223,89 @@ TEST_F(test, retrieveMemoryProvidersError) { ret = umaPoolGetMemoryProviders(pool.get(), 1, providers.data(), nullptr); ASSERT_EQ(ret, UMA_RESULT_ERROR_INVALID_ARGUMENT); } + +// TODO: extend test for different functions (not only alloc) +TEST_F(test, getLastFailedMemoryProvider) { + static constexpr size_t allocSize = 8; + static uma_result_t allocResult = UMA_RESULT_SUCCESS; + + struct memory_provider : public uma_test::provider_base { + uma_result_t initialize(const char *name) { + this->name = name; + return UMA_RESULT_SUCCESS; + } + + enum uma_result_t alloc(size_t size, size_t, void **ptr) noexcept { + if (allocResult == UMA_RESULT_SUCCESS) { + *ptr = malloc(size); + } else { + *ptr = nullptr; + } + + return allocResult; + } + + enum uma_result_t free(void *ptr, size_t size) noexcept { + ::free(ptr); + return UMA_RESULT_SUCCESS; + } + + const char *get_name() noexcept { return this->name; } + + const char *name; + }; + + auto [ret1, providerUnique1] = + uma::memoryProviderMakeUnique("provider1"); + ASSERT_EQ(ret1, UMA_RESULT_SUCCESS); + auto [ret2, providerUnique2] = + uma::memoryProviderMakeUnique("provider2"); + ASSERT_EQ(ret2, UMA_RESULT_SUCCESS); + + auto hProvider = providerUnique1.get(); + + auto [ret, pool] = uma::poolMakeUnique(&hProvider, 1); + ASSERT_EQ(ret, UMA_RESULT_SUCCESS); + + ASSERT_EQ(umaGetLastFailedMemoryProvider(), nullptr); + auto ptr = umaPoolMalloc(pool.get(), allocSize); + ASSERT_NE(ptr, nullptr); + ASSERT_EQ(umaGetLastFailedMemoryProvider(), nullptr); + + // make provider return an error during allocation + allocResult = UMA_RESULT_ERROR_UNKNOWN; + ptr = umaPoolMalloc(pool.get(), allocSize); + ASSERT_EQ(ptr, nullptr); + ASSERT_EQ(std::string_view( + umaMemoryProviderGetName(umaGetLastFailedMemoryProvider())), + "provider1"); + + ret = umaMemoryProviderAlloc(providerUnique2.get(), allocSize, 0, &ptr); + ASSERT_EQ(ptr, nullptr); + ASSERT_EQ(std::string_view( + umaMemoryProviderGetName(umaGetLastFailedMemoryProvider())), + "provider2"); + + // succesfull provider should not be returned by umaGetLastFailedMemoryProvider + allocResult = UMA_RESULT_SUCCESS; + ptr = umaPoolMalloc(pool.get(), allocSize); + ASSERT_NE(ptr, nullptr); + ASSERT_EQ(std::string_view( + umaMemoryProviderGetName(umaGetLastFailedMemoryProvider())), + "provider2"); + + // erorr in another thread should not impact umaGetLastFailedMemoryProvider on this thread + allocResult = UMA_RESULT_ERROR_UNKNOWN; + std::thread t([&, hPool = pool.get()] { + ptr = umaPoolMalloc(hPool, allocSize); + ASSERT_EQ(ptr, nullptr); + ASSERT_EQ(std::string_view(umaMemoryProviderGetName( + umaGetLastFailedMemoryProvider())), + "provider1"); + }); + t.join(); + + ASSERT_EQ(std::string_view( + umaMemoryProviderGetName(umaGetLastFailedMemoryProvider())), + "provider2"); +} From f5a7881679a3b0ccba673d4b2bb2cf3001bca956 Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Thu, 29 Jun 2023 11:36:05 +0100 Subject: [PATCH 014/104] [UR][CTS] Add urEnqueueMemImageRead/Write tests --- .../enqueue/urEnqueueMemImageRead.cpp | 122 ++++++++++++++++++ .../enqueue/urEnqueueMemImageWrite.cpp | 119 +++++++++++++++++ .../testing/include/uur/fixtures.h | 75 +++++++++++ 3 files changed, 316 insertions(+) diff --git a/test/conformance/enqueue/urEnqueueMemImageRead.cpp b/test/conformance/enqueue/urEnqueueMemImageRead.cpp index 281aa8badb..d40625c3e1 100644 --- a/test/conformance/enqueue/urEnqueueMemImageRead.cpp +++ b/test/conformance/enqueue/urEnqueueMemImageRead.cpp @@ -2,3 +2,125 @@ // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +using urEnqueueMemImageReadTest = uur::urMemImageQueueTest; +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urEnqueueMemImageReadTest); + +// Note that for each test, we multiply the size in pixels by 4 to account for +// each channel in the RGBA image + +TEST_P(urEnqueueMemImageReadTest, Success1D) { + std::vector output(width * 4, 42); + ASSERT_SUCCESS(urEnqueueMemImageRead(queue, image1D, true, origin, region1D, + 0, 0, output.data(), 0, nullptr, + nullptr)); +} + +TEST_P(urEnqueueMemImageReadTest, Success2D) { + std::vector output(width * height * 4, 42); + ASSERT_SUCCESS(urEnqueueMemImageRead(queue, image2D, true, origin, region2D, + 0, 0, output.data(), 0, nullptr, + nullptr)); +} + +TEST_P(urEnqueueMemImageReadTest, Success3D) { + std::vector output(width * height * depth * 4, 42); + ASSERT_SUCCESS(urEnqueueMemImageRead(queue, image3D, true, origin, region3D, + 0, 0, output.data(), 0, nullptr, + nullptr)); +} + +TEST_P(urEnqueueMemImageReadTest, InvalidNullHandleQueue) { + std::vector output(width * 4, 42); + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urEnqueueMemImageRead(nullptr, image1D, true, origin, + region1D, 0, 0, output.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageReadTest, InvalidNullHandleImage) { + std::vector output(width * 4, 42); + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urEnqueueMemImageRead(queue, nullptr, true, origin, + region1D, 0, 0, output.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageReadTest, InvalidNullPointerDst) { + std::vector output(width * 4, 42); + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, + urEnqueueMemImageRead(queue, image1D, true, origin, + region1D, 0, 0, nullptr, 0, nullptr, + nullptr)); +} + +TEST_P(urEnqueueMemImageReadTest, InvalidNullPtrEventWaitList) { + std::vector output(width * 4, 42); + ASSERT_EQ_RESULT(urEnqueueMemImageRead(queue, image1D, true, origin, + region1D, 0, 0, output.data(), 1, + nullptr, nullptr), + UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST); + + ur_event_handle_t validEvent; + ASSERT_SUCCESS(urEnqueueEventsWait(queue, 0, nullptr, &validEvent)); + + ASSERT_EQ_RESULT(urEnqueueMemImageRead(queue, image1D, true, origin, + region1D, 0, 0, output.data(), 0, + &validEvent, nullptr), + UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST); +} + +TEST_P(urEnqueueMemImageReadTest, InvalidOrigin1D) { + std::vector output(width * 4, 42); + ur_rect_offset_t bad_origin{1, 0, 0}; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urEnqueueMemImageRead(queue, image1D, true, bad_origin, + region1D, 0, 0, output.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageReadTest, InvalidOrigin2D) { + std::vector output(width * height * 4, 42); + ur_rect_offset_t bad_origin{0, 1, 0}; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urEnqueueMemImageRead(queue, image2D, true, bad_origin, + region2D, 0, 0, output.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageReadTest, InvalidOrigin3D) { + std::vector output(width * height * depth * 4, 42); + ur_rect_offset_t bad_origin{0, 0, 1}; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urEnqueueMemImageRead(queue, image3D, true, bad_origin, + region3D, 0, 0, output.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageReadTest, InvalidRegion1D) { + std::vector output(width * 4, 42); + ur_rect_region_t bad_region{width + 1, 1, 1}; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urEnqueueMemImageRead(queue, image1D, true, origin, + bad_region, 0, 0, output.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageReadTest, InvalidRegion2D) { + std::vector output(width * height * 4, 42); + ur_rect_region_t bad_region{width, height + 1, 1}; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urEnqueueMemImageRead(queue, image2D, true, origin, + bad_region, 0, 0, output.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageReadTest, InvalidRegion3D) { + std::vector output(width * height * depth * 4, 42); + ur_rect_region_t bad_region{width, height, depth + 1}; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urEnqueueMemImageRead(queue, image3D, true, origin, + bad_region, 0, 0, output.data(), 0, + nullptr, nullptr)); +} diff --git a/test/conformance/enqueue/urEnqueueMemImageWrite.cpp b/test/conformance/enqueue/urEnqueueMemImageWrite.cpp index 281aa8badb..7f7968bdff 100644 --- a/test/conformance/enqueue/urEnqueueMemImageWrite.cpp +++ b/test/conformance/enqueue/urEnqueueMemImageWrite.cpp @@ -2,3 +2,122 @@ // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +using urEnqueueMemImageWriteTest = uur::urMemImageQueueTest; +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urEnqueueMemImageWriteTest); + +TEST_P(urEnqueueMemImageWriteTest, Success1D) { + std::vector input(width * 4, 42); + ASSERT_SUCCESS(urEnqueueMemImageWrite(queue, image1D, true, origin, + region1D, 0, 0, input.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageWriteTest, Success2D) { + std::vector input(width * height * 4, 42); + ASSERT_SUCCESS(urEnqueueMemImageWrite(queue, image2D, true, origin, + region2D, 0, 0, input.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageWriteTest, Success3D) { + std::vector input(width * height * depth * 4, 42); + ASSERT_SUCCESS(urEnqueueMemImageWrite(queue, image3D, true, origin, + region3D, 0, 0, input.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageWriteTest, InvalidNullHandleQueue) { + std::vector input(width * 4, 42); + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urEnqueueMemImageWrite(nullptr, image1D, true, origin, + region1D, 0, 0, input.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageWriteTest, InvalidNullHandleImage) { + std::vector input(width * 4, 42); + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urEnqueueMemImageWrite(queue, nullptr, true, origin, + region1D, 0, 0, input.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageWriteTest, InvalidNullPointerSrc) { + std::vector input(width * 4, 42); + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, + urEnqueueMemImageWrite(queue, image1D, true, origin, + region1D, 0, 0, nullptr, 0, nullptr, + nullptr)); +} + +TEST_P(urEnqueueMemImageWriteTest, InvalidNullPtrEventWaitList) { + std::vector input(width * 4, 42); + ASSERT_EQ_RESULT(urEnqueueMemImageWrite(queue, image1D, true, origin, + region1D, 0, 0, input.data(), 1, + nullptr, nullptr), + UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST); + + ur_event_handle_t validEvent; + ASSERT_SUCCESS(urEnqueueEventsWait(queue, 0, nullptr, &validEvent)); + + ASSERT_EQ_RESULT(urEnqueueMemImageWrite(queue, image1D, true, origin, + region1D, 0, 0, input.data(), 0, + &validEvent, nullptr), + UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST); +} + +TEST_P(urEnqueueMemImageWriteTest, InvalidOrigin1D) { + std::vector input(width * 4, 42); + ur_rect_offset_t bad_origin{1, 0, 0}; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urEnqueueMemImageWrite(queue, image1D, true, bad_origin, + region1D, 0, 0, input.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageWriteTest, InvalidOrigin2D) { + std::vector input(width * height * 4, 42); + ur_rect_offset_t bad_origin{0, 1, 0}; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urEnqueueMemImageWrite(queue, image2D, true, bad_origin, + region2D, 0, 0, input.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageWriteTest, InvalidOrigin3D) { + std::vector input(width * height * depth * 4, 42); + ur_rect_offset_t bad_origin{0, 0, 1}; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urEnqueueMemImageWrite(queue, image3D, true, bad_origin, + region3D, 0, 0, input.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageWriteTest, InvalidRegion1D) { + std::vector input(width * 4, 42); + ur_rect_region_t bad_region{width + 1, 1, 1}; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urEnqueueMemImageWrite(queue, image1D, true, origin, + bad_region, 0, 0, input.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageWriteTest, InvalidRegion2D) { + std::vector input(width * height * 4, 42); + ur_rect_region_t bad_region{width, height + 1, 1}; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urEnqueueMemImageWrite(queue, image2D, true, origin, + bad_region, 0, 0, input.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageWriteTest, InvalidRegion3D) { + std::vector input(width * height * depth * 4, 42); + ur_rect_region_t bad_region{width, height, depth + 1}; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urEnqueueMemImageWrite(queue, image3D, true, origin, + bad_region, 0, 0, input.data(), 0, + nullptr, nullptr)); +} diff --git a/test/conformance/testing/include/uur/fixtures.h b/test/conformance/testing/include/uur/fixtures.h index 0f279f2e74..09116c9a75 100644 --- a/test/conformance/testing/include/uur/fixtures.h +++ b/test/conformance/testing/include/uur/fixtures.h @@ -498,6 +498,81 @@ struct urMemBufferQueueTest : urQueueTest { ur_mem_handle_t buffer = nullptr; }; +struct urMemImageQueueTest : urQueueTest { + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE(urQueueTest::SetUp()); + ASSERT_SUCCESS(urMemImageCreate(this->context, UR_MEM_FLAG_READ_WRITE, + &format, &desc1D, nullptr, &image1D)); + + ASSERT_SUCCESS(urMemImageCreate(this->context, UR_MEM_FLAG_READ_WRITE, + &format, &desc2D, nullptr, &image2D)); + + ASSERT_SUCCESS(urMemImageCreate(this->context, UR_MEM_FLAG_READ_WRITE, + &format, &desc3D, nullptr, &image3D)); + } + + void TearDown() override { + if (image1D) { + EXPECT_SUCCESS(urMemRelease(image1D)); + } + if (image2D) { + EXPECT_SUCCESS(urMemRelease(image2D)); + } + if (image3D) { + EXPECT_SUCCESS(urMemRelease(image3D)); + } + UUR_RETURN_ON_FATAL_FAILURE(urQueueTest::TearDown()); + } + + const size_t width = 1024; + const size_t height = 8; + const size_t depth = 2; + ur_mem_handle_t image1D = nullptr; + ur_mem_handle_t image2D = nullptr; + ur_mem_handle_t image3D = nullptr; + ur_rect_region_t region1D{width, 1, 1}; + ur_rect_region_t region2D{width, height, 1}; + ur_rect_region_t region3D{width, height, depth}; + ur_rect_offset_t origin{0, 0, 0}; + ur_image_format_t format = {UR_IMAGE_CHANNEL_ORDER_RGBA, + UR_IMAGE_CHANNEL_TYPE_FLOAT}; + ur_image_desc_t desc1D = {UR_STRUCTURE_TYPE_IMAGE_DESC, // stype + nullptr, // pNext + UR_MEM_TYPE_IMAGE1D, // mem object type + width, // image width + 1, // image height + 1, // image depth + 1, // array size + 0, // row pitch + 0, // slice pitch + 0, // mip levels + 0}; // num samples + + ur_image_desc_t desc2D = {UR_STRUCTURE_TYPE_IMAGE_DESC, // stype + nullptr, // pNext + UR_MEM_TYPE_IMAGE2D, // mem object type + width, // image width + height, // image height + 1, // image depth + 1, // array size + 0, // row pitch + 0, // slice pitch + 0, // mip levels + 0}; // num samples + + ur_image_desc_t desc3D = {UR_STRUCTURE_TYPE_IMAGE_DESC, // stype + nullptr, // pNext + UR_MEM_TYPE_IMAGE3D, // mem object type + width, // image width + height, // image height + depth, // image depth + 1, // array size + 0, // row pitch + 0, // slice pitch + 0, // mip levels + 0}; // num samples +}; + struct urUSMDeviceAllocTest : urQueueTest { void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(uur::urQueueTest::SetUp()); From dde71998c3fd5bab09dfd75e4bd3fddad37efb64 Mon Sep 17 00:00:00 2001 From: Igor Chorazewicz Date: Thu, 29 Jun 2023 15:45:22 +0000 Subject: [PATCH 015/104] [uma] rename uma to umf to avoid confusion with uniform memory access. --- .github/workflows/cmake.yml | 4 +- CMakeLists.txt | 2 +- source/common/CMakeLists.txt | 10 +- .../{uma_helpers.hpp => umf_helpers.hpp} | 116 +++---- .../{uma_pools => umf_pools}/CMakeLists.txt | 2 +- .../disjoint_pool.cpp | 44 +-- .../disjoint_pool.hpp | 6 +- .../disjoint_pool_config_parser.cpp | 0 .../disjoint_pool_config_parser.hpp | 0 .../CMakeLists.txt | 18 +- .../include/umf.h} | 10 +- .../include/umf/base.h | 54 +++ .../include/umf}/memory_pool.h | 60 ++-- .../include/umf}/memory_pool_ops.h | 20 +- .../include/umf}/memory_provider.h | 80 ++--- .../include/umf}/memory_provider_ops.h | 30 +- .../src/memory_pool.c | 86 ++--- .../src/memory_provider.c | 78 ++--- .../src/memory_provider_get_last_failed.cpp | 4 +- .../src/memory_provider_internal.h | 12 +- .../src/memory_tracker.cpp | 247 ++++++++++++++ .../src/memory_tracker.h | 42 +++ .../include/uma/base.h | 54 --- .../src/memory_tracker.cpp | 247 -------------- .../src/memory_tracker.h | 42 --- source/common/ur_pool_manager.hpp | 2 +- test/CMakeLists.txt | 2 +- test/unified_malloc_framework/CMakeLists.txt | 37 +++ .../base.cpp | 10 +- .../common/base.hpp | 10 +- .../common/pool.c | 66 ++-- .../common/pool.h | 16 +- .../common/pool.hpp | 46 +-- .../common/provider.c | 90 ++--- .../common/provider.h | 14 +- .../common/provider.hpp | 81 +++++ .../memoryPool.hpp | 48 +-- .../memoryPoolAPI.cpp | 311 ++++++++++++++++++ .../memoryProvider.hpp | 18 +- .../memoryProviderAPI.cpp | 54 +-- .../umf_pools}/CMakeLists.txt | 8 +- .../umf_pools}/disjoint_pool.cpp | 20 +- .../disjoint_pool_config_parser.cpp | 0 test/unified_memory_allocation/CMakeLists.txt | 37 --- .../common/provider.hpp | 81 ----- .../memoryPoolAPI.cpp | 311 ------------------ test/usm/usmPoolManager.cpp | 4 +- 47 files changed, 1267 insertions(+), 1267 deletions(-) rename source/common/{uma_helpers.hpp => umf_helpers.hpp} (54%) rename source/common/{uma_pools => umf_pools}/CMakeLists.txt (96%) rename source/common/{uma_pools => umf_pools}/disjoint_pool.cpp (96%) rename source/common/{uma_pools => umf_pools}/disjoint_pool.hpp (93%) rename source/common/{uma_pools => umf_pools}/disjoint_pool_config_parser.cpp (100%) rename source/common/{uma_pools => umf_pools}/disjoint_pool_config_parser.hpp (100%) rename source/common/{unified_memory_allocation => unified_malloc_framework}/CMakeLists.txt (55%) rename source/common/{unified_memory_allocation/include/uma.h => unified_malloc_framework/include/umf.h} (54%) create mode 100644 source/common/unified_malloc_framework/include/umf/base.h rename source/common/{unified_memory_allocation/include/uma => unified_malloc_framework/include/umf}/memory_pool.h (72%) rename source/common/{unified_memory_allocation/include/uma => unified_malloc_framework/include/umf}/memory_pool_ops.h (78%) rename source/common/{unified_memory_allocation/include/uma => unified_malloc_framework/include/umf}/memory_provider.h (68%) rename source/common/{unified_memory_allocation/include/uma => unified_malloc_framework/include/umf}/memory_provider_ops.h (60%) rename source/common/{unified_memory_allocation => unified_malloc_framework}/src/memory_pool.c (54%) rename source/common/{unified_memory_allocation => unified_malloc_framework}/src/memory_provider.c (56%) rename source/common/{unified_memory_allocation => unified_malloc_framework}/src/memory_provider_get_last_failed.cpp (72%) rename source/common/{unified_memory_allocation => unified_malloc_framework}/src/memory_provider_internal.h (52%) create mode 100644 source/common/unified_malloc_framework/src/memory_tracker.cpp create mode 100644 source/common/unified_malloc_framework/src/memory_tracker.h delete mode 100644 source/common/unified_memory_allocation/include/uma/base.h delete mode 100644 source/common/unified_memory_allocation/src/memory_tracker.cpp delete mode 100644 source/common/unified_memory_allocation/src/memory_tracker.h create mode 100644 test/unified_malloc_framework/CMakeLists.txt rename test/{unified_memory_allocation => unified_malloc_framework}/base.cpp (60%) rename test/{unified_memory_allocation => unified_malloc_framework}/common/base.hpp (90%) rename test/{unified_memory_allocation => unified_malloc_framework}/common/pool.c (71%) rename test/{unified_memory_allocation => unified_malloc_framework}/common/pool.h (53%) rename test/{unified_memory_allocation => unified_malloc_framework}/common/pool.hpp (69%) rename test/{unified_memory_allocation => unified_malloc_framework}/common/provider.c (66%) rename test/{unified_memory_allocation => unified_malloc_framework}/common/provider.h (55%) create mode 100644 test/unified_malloc_framework/common/provider.hpp rename test/{unified_memory_allocation => unified_malloc_framework}/memoryPool.hpp (70%) create mode 100644 test/unified_malloc_framework/memoryPoolAPI.cpp rename test/{unified_memory_allocation => unified_malloc_framework}/memoryProvider.hpp (60%) rename test/{unified_memory_allocation => unified_malloc_framework}/memoryProviderAPI.cpp (58%) rename test/{unified_memory_allocation/uma_pools => unified_malloc_framework/umf_pools}/CMakeLists.txt (52%) rename test/{unified_memory_allocation/uma_pools => unified_malloc_framework/umf_pools}/disjoint_pool.cpp (61%) rename test/{unified_memory_allocation/uma_pools => unified_malloc_framework/umf_pools}/disjoint_pool_config_parser.cpp (100%) delete mode 100644 test/unified_memory_allocation/CMakeLists.txt delete mode 100644 test/unified_memory_allocation/common/provider.hpp delete mode 100644 test/unified_memory_allocation/memoryPoolAPI.cpp diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 8f82ee0184..fdfaf6cc1f 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -85,7 +85,7 @@ jobs: - name: Test working-directory: ${{github.workspace}}/build - run: ctest -C ${{matrix.build_type}} --output-on-failure -L "python|uma|loader|validation|tracing|unit|urtrace" + run: ctest -C ${{matrix.build_type}} --output-on-failure -L "python|umf|loader|validation|tracing|unit|urtrace" windows-build: name: Build - Windows @@ -124,4 +124,4 @@ jobs: - name: Test working-directory: ${{github.workspace}}/build - run: ctest -C ${{matrix.build_type}} --output-on-failure -L "python|uma|loader|validation|tracing|unit|urtrace" + run: ctest -C ${{matrix.build_type}} --output-on-failure -L "python|umf|loader|validation|tracing|unit|urtrace" diff --git a/CMakeLists.txt b/CMakeLists.txt index b830166600..5836eb3fd0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ option(UR_FORMAT_CPP_STYLE "format code style of C++ sources" OFF) option(UR_USE_ASAN "enable AddressSanitizer" OFF) option(UR_USE_UBSAN "enable UndefinedBehaviorSanitizer" OFF) option(UR_USE_MSAN "enable MemorySanitizer" OFF) -option(UMA_BUILD_SHARED_LIBRARY "Build UMA as shared library" OFF) +option(UMF_BUILD_SHARED_LIBRARY "Build UMF as shared library" OFF) option(UR_ENABLE_TRACING "enable api tracing through xpti" OFF) option(VAL_USE_LIBBACKTRACE_BACKTRACE "enable libbacktrace validation backtrace for linux" OFF) option(UR_BUILD_TOOLS "build ur tools" ON) diff --git a/source/common/CMakeLists.txt b/source/common/CMakeLists.txt index aefc0c6195..f240f9908b 100644 --- a/source/common/CMakeLists.txt +++ b/source/common/CMakeLists.txt @@ -11,20 +11,20 @@ target_include_directories(ur_common INTERFACE ${CMAKE_SOURCE_DIR}/include ) -add_subdirectory(unified_memory_allocation) -add_subdirectory(uma_pools) -target_link_libraries(ur_common INTERFACE unified_memory_allocation disjoint_pool ${CMAKE_DL_LIBS} ${PROJECT_NAME}::headers) +add_subdirectory(unified_malloc_framework) +add_subdirectory(umf_pools) +target_link_libraries(ur_common INTERFACE unified_malloc_framework disjoint_pool ${CMAKE_DL_LIBS} ${PROJECT_NAME}::headers) if(WIN32) target_sources(ur_common INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/windows/ur_lib_loader.cpp - uma_helpers.hpp ur_pool_manager.hpp + umf_helpers.hpp ur_pool_manager.hpp ) else() target_sources(ur_common INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/linux/ur_lib_loader.cpp - uma_helpers.hpp ur_pool_manager.hpp + umf_helpers.hpp ur_pool_manager.hpp ) endif() diff --git a/source/common/uma_helpers.hpp b/source/common/umf_helpers.hpp similarity index 54% rename from source/common/uma_helpers.hpp rename to source/common/umf_helpers.hpp index 95a9c04f05..510af3e244 100644 --- a/source/common/uma_helpers.hpp +++ b/source/common/umf_helpers.hpp @@ -8,13 +8,13 @@ * */ -#ifndef UMA_HELPERS_H -#define UMA_HELPERS_H 1 +#ifndef UMF_HELPERS_H +#define UMF_HELPERS_H 1 -#include -#include -#include -#include +#include +#include +#include +#include #include #include @@ -22,16 +22,16 @@ #include #include -namespace uma { +namespace umf { using pool_unique_handle_t = - std::unique_ptr>; + std::unique_ptr>; using provider_unique_handle_t = - std::unique_ptr>; + std::unique_ptr>; -#define UMA_ASSIGN_OP(ops, type, func, default_return) \ +#define UMF_ASSIGN_OP(ops, type, func, default_return) \ ops.func = [](void *obj, auto... args) { \ try { \ return reinterpret_cast(obj)->func(args...); \ @@ -40,7 +40,7 @@ using provider_unique_handle_t = } \ } -#define UMA_ASSIGN_OP_NORETURN(ops, type, func) \ +#define UMF_ASSIGN_OP_NORETURN(ops, type, func) \ ops.func = [](void *obj, auto... args) { \ try { \ return reinterpret_cast(obj)->func(args...); \ @@ -48,24 +48,24 @@ using provider_unique_handle_t = } \ } -/// @brief creates UMA memory provider based on given T type. +/// @brief creates UMF memory provider based on given T type. /// T should implement all functions defined by -/// uma_memory_provider_ops_t, except for finalize (it is +/// umf_memory_provider_ops_t, except for finalize (it is /// replaced by dtor). All arguments passed to this function are /// forwarded to T::initialize(). template auto memoryProviderMakeUnique(Args &&...args) { - uma_memory_provider_ops_t ops; + umf_memory_provider_ops_t ops; auto argsTuple = std::make_tuple(std::forward(args)...); - ops.version = UMA_VERSION_CURRENT; + ops.version = UMF_VERSION_CURRENT; ops.initialize = [](void *params, void **obj) { auto *tuple = reinterpret_cast(params); T *provider; try { provider = new T; } catch (...) { - return UMA_RESULT_ERROR_OUT_OF_HOST_MEMORY; + return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; } *obj = provider; @@ -74,45 +74,45 @@ auto memoryProviderMakeUnique(Args &&...args) { auto ret = std::apply(&T::initialize, std::tuple_cat(std::make_tuple(provider), *tuple)); - if (ret != UMA_RESULT_SUCCESS) { + if (ret != UMF_RESULT_SUCCESS) { delete provider; } return ret; } catch (...) { delete provider; - return UMA_RESULT_ERROR_UNKNOWN; + return UMF_RESULT_ERROR_UNKNOWN; } }; ops.finalize = [](void *obj) { delete reinterpret_cast(obj); }; - UMA_ASSIGN_OP(ops, T, alloc, UMA_RESULT_ERROR_UNKNOWN); - UMA_ASSIGN_OP(ops, T, free, UMA_RESULT_ERROR_UNKNOWN); - UMA_ASSIGN_OP_NORETURN(ops, T, get_last_native_error); - UMA_ASSIGN_OP(ops, T, get_recommended_page_size, UMA_RESULT_ERROR_UNKNOWN); - UMA_ASSIGN_OP(ops, T, get_min_page_size, UMA_RESULT_ERROR_UNKNOWN); - UMA_ASSIGN_OP(ops, T, purge_lazy, UMA_RESULT_ERROR_UNKNOWN); - UMA_ASSIGN_OP(ops, T, purge_force, UMA_RESULT_ERROR_UNKNOWN); - UMA_ASSIGN_OP(ops, T, get_name, ""); - - uma_memory_provider_handle_t hProvider = nullptr; - auto ret = umaMemoryProviderCreate(&ops, &argsTuple, &hProvider); - return std::pair{ - ret, provider_unique_handle_t(hProvider, &umaMemoryProviderDestroy)}; + UMF_ASSIGN_OP(ops, T, alloc, UMF_RESULT_ERROR_UNKNOWN); + UMF_ASSIGN_OP(ops, T, free, UMF_RESULT_ERROR_UNKNOWN); + UMF_ASSIGN_OP_NORETURN(ops, T, get_last_native_error); + UMF_ASSIGN_OP(ops, T, get_recommended_page_size, UMF_RESULT_ERROR_UNKNOWN); + UMF_ASSIGN_OP(ops, T, get_min_page_size, UMF_RESULT_ERROR_UNKNOWN); + UMF_ASSIGN_OP(ops, T, purge_lazy, UMF_RESULT_ERROR_UNKNOWN); + UMF_ASSIGN_OP(ops, T, purge_force, UMF_RESULT_ERROR_UNKNOWN); + UMF_ASSIGN_OP(ops, T, get_name, ""); + + umf_memory_provider_handle_t hProvider = nullptr; + auto ret = umfMemoryProviderCreate(&ops, &argsTuple, &hProvider); + return std::pair{ + ret, provider_unique_handle_t(hProvider, &umfMemoryProviderDestroy)}; } -/// @brief creates UMA memory pool based on given T type. +/// @brief creates UMF memory pool based on given T type. /// T should implement all functions defined by -/// uma_memory_provider_ops_t, except for finalize (it is +/// umf_memory_provider_ops_t, except for finalize (it is /// replaced by dtor). All arguments passed to this function are /// forwarded to T::initialize(). template -auto poolMakeUnique(uma_memory_provider_handle_t *providers, +auto poolMakeUnique(umf_memory_provider_handle_t *providers, size_t numProviders, Args &&...args) { - uma_memory_pool_ops_t ops; + umf_memory_pool_ops_t ops; auto argsTuple = std::make_tuple(std::forward(args)...); - ops.version = UMA_VERSION_CURRENT; - ops.initialize = [](uma_memory_provider_handle_t *providers, + ops.version = UMF_VERSION_CURRENT; + ops.initialize = [](umf_memory_provider_handle_t *providers, size_t numProviders, void *params, void **obj) { auto *tuple = reinterpret_cast(params); T *pool; @@ -120,7 +120,7 @@ auto poolMakeUnique(uma_memory_provider_handle_t *providers, try { pool = new T; } catch (...) { - return UMA_RESULT_ERROR_OUT_OF_HOST_MEMORY; + return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; } *obj = pool; @@ -130,36 +130,36 @@ auto poolMakeUnique(uma_memory_provider_handle_t *providers, &T::initialize, std::tuple_cat(std::make_tuple(pool, providers, numProviders), *tuple)); - if (ret != UMA_RESULT_SUCCESS) { + if (ret != UMF_RESULT_SUCCESS) { delete pool; } return ret; } catch (...) { delete pool; - return UMA_RESULT_ERROR_UNKNOWN; + return UMF_RESULT_ERROR_UNKNOWN; } }; ops.finalize = [](void *obj) { delete reinterpret_cast(obj); }; - UMA_ASSIGN_OP(ops, T, malloc, ((void *)nullptr)); - UMA_ASSIGN_OP(ops, T, calloc, ((void *)nullptr)); - UMA_ASSIGN_OP(ops, T, aligned_malloc, ((void *)nullptr)); - UMA_ASSIGN_OP(ops, T, realloc, ((void *)nullptr)); - UMA_ASSIGN_OP(ops, T, malloc_usable_size, ((size_t)0)); - UMA_ASSIGN_OP_NORETURN(ops, T, free); - UMA_ASSIGN_OP(ops, T, get_last_allocation_error, UMA_RESULT_ERROR_UNKNOWN); - - uma_memory_pool_handle_t hPool = nullptr; - auto ret = umaPoolCreate(&ops, providers, numProviders, &argsTuple, &hPool); - return std::pair{ - ret, pool_unique_handle_t(hPool, &umaPoolDestroy)}; + UMF_ASSIGN_OP(ops, T, malloc, ((void *)nullptr)); + UMF_ASSIGN_OP(ops, T, calloc, ((void *)nullptr)); + UMF_ASSIGN_OP(ops, T, aligned_malloc, ((void *)nullptr)); + UMF_ASSIGN_OP(ops, T, realloc, ((void *)nullptr)); + UMF_ASSIGN_OP(ops, T, malloc_usable_size, ((size_t)0)); + UMF_ASSIGN_OP_NORETURN(ops, T, free); + UMF_ASSIGN_OP(ops, T, get_last_allocation_error, UMF_RESULT_ERROR_UNKNOWN); + + umf_memory_pool_handle_t hPool = nullptr; + auto ret = umfPoolCreate(&ops, providers, numProviders, &argsTuple, &hPool); + return std::pair{ + ret, pool_unique_handle_t(hPool, &umfPoolDestroy)}; } -template uma_result_t &getPoolLastStatusRef() { - static thread_local uma_result_t last_status = UMA_RESULT_SUCCESS; +template umf_result_t &getPoolLastStatusRef() { + static thread_local umf_result_t last_status = UMF_RESULT_SUCCESS; return last_status; } -} // namespace uma +} // namespace umf -#endif /* UMA_HELPERS_H */ +#endif /* UMF_HELPERS_H */ diff --git a/source/common/uma_pools/CMakeLists.txt b/source/common/umf_pools/CMakeLists.txt similarity index 96% rename from source/common/uma_pools/CMakeLists.txt rename to source/common/umf_pools/CMakeLists.txt index cd93cad0a9..fc511cd814 100644 --- a/source/common/uma_pools/CMakeLists.txt +++ b/source/common/umf_pools/CMakeLists.txt @@ -11,7 +11,7 @@ add_library(disjoint_pool STATIC add_library(${PROJECT_NAME}::disjoint_pool ALIAS disjoint_pool) target_link_libraries(disjoint_pool PRIVATE - unified_memory_allocation + unified_malloc_framework ${PROJECT_NAME}::headers) if (UNIX) diff --git a/source/common/uma_pools/disjoint_pool.cpp b/source/common/umf_pools/disjoint_pool.cpp similarity index 96% rename from source/common/uma_pools/disjoint_pool.cpp rename to source/common/umf_pools/disjoint_pool.cpp index 34f72a290e..e4c4c693dd 100644 --- a/source/common/uma_pools/disjoint_pool.cpp +++ b/source/common/umf_pools/disjoint_pool.cpp @@ -75,7 +75,7 @@ static size_t AlignUp(size_t Val, size_t Alignment) { } struct MemoryProviderError { - uma_result_t code; + umf_result_t code; }; DisjointPoolConfig::DisjointPoolConfig() @@ -220,7 +220,7 @@ class Bucket { // Free an allocation that is a full slab in this bucket. void freeSlab(Slab &Slab, bool &ToPool); - uma_memory_provider_handle_t getMemHandle(); + umf_memory_provider_handle_t getMemHandle(); DisjointPool::AllocImpl &getAllocCtx() { return OwnAllocCtx; } @@ -275,7 +275,7 @@ class DisjointPool::AllocImpl { std::shared_timed_mutex KnownSlabsMapLock; // Handle to the memory provider - uma_memory_provider_handle_t MemHandle; + umf_memory_provider_handle_t MemHandle; // Store as unique_ptrs since Bucket is not Movable(because of std::mutex) std::vector> Buckets; @@ -287,7 +287,7 @@ class DisjointPool::AllocImpl { size_t ProviderMinPageSize; public: - AllocImpl(uma_memory_provider_handle_t hProvider, DisjointPoolConfig params) + AllocImpl(umf_memory_provider_handle_t hProvider, DisjointPoolConfig params) : MemHandle{hProvider}, params(params) { // Generate buckets sized such as: 64, 96, 128, 192, ..., CutOff. @@ -300,9 +300,9 @@ class DisjointPool::AllocImpl { } Buckets.push_back(std::make_unique(CutOff, *this)); - auto ret = umaMemoryProviderGetMinPageSize(hProvider, nullptr, + auto ret = umfMemoryProviderGetMinPageSize(hProvider, nullptr, &ProviderMinPageSize); - if (ret != UMA_RESULT_SUCCESS) { + if (ret != UMF_RESULT_SUCCESS) { ProviderMinPageSize = 0; } } @@ -311,7 +311,7 @@ class DisjointPool::AllocImpl { void *allocate(size_t Size, bool &FromPool); void deallocate(void *Ptr, bool &ToPool); - uma_memory_provider_handle_t getMemHandle() { return MemHandle; } + umf_memory_provider_handle_t getMemHandle() { return MemHandle; } std::shared_timed_mutex &getKnownSlabsMapLock() { return KnownSlabsMapLock; @@ -331,20 +331,20 @@ class DisjointPool::AllocImpl { Bucket &findBucket(size_t Size); }; -static void *memoryProviderAlloc(uma_memory_provider_handle_t hProvider, +static void *memoryProviderAlloc(umf_memory_provider_handle_t hProvider, size_t size, size_t alignment = 0) { void *ptr; - auto ret = umaMemoryProviderAlloc(hProvider, size, alignment, &ptr); - if (ret != UMA_RESULT_SUCCESS) { + auto ret = umfMemoryProviderAlloc(hProvider, size, alignment, &ptr); + if (ret != UMF_RESULT_SUCCESS) { throw MemoryProviderError{ret}; } return ptr; } -static void memoryProviderFree(uma_memory_provider_handle_t hProvider, +static void memoryProviderFree(umf_memory_provider_handle_t hProvider, void *ptr) { - auto ret = umaMemoryProviderFree(hProvider, ptr, 0); - if (ret != UMA_RESULT_SUCCESS) { + auto ret = umfMemoryProviderFree(hProvider, ptr, 0); + if (ret != UMF_RESULT_SUCCESS) { throw MemoryProviderError{ret}; } } @@ -663,7 +663,7 @@ bool Bucket::CanPool(bool &ToPool) { return false; } -uma_memory_provider_handle_t Bucket::getMemHandle() { +umf_memory_provider_handle_t Bucket::getMemHandle() { return OwnAllocCtx.getMemHandle(); } @@ -753,7 +753,7 @@ void *DisjointPool::AllocImpl::allocate(size_t Size, bool &FromPool) try { return Ptr; } catch (MemoryProviderError &e) { - uma::getPoolLastStatusRef() = e.code; + umf::getPoolLastStatusRef() = e.code; return nullptr; } @@ -803,7 +803,7 @@ void *DisjointPool::AllocImpl::allocate(size_t Size, size_t Alignment, return AlignPtrUp(Ptr, Alignment); } catch (MemoryProviderError &e) { - uma::getPoolLastStatusRef() = e.code; + umf::getPoolLastStatusRef() = e.code; return nullptr; } @@ -863,7 +863,7 @@ void DisjointPool::AllocImpl::deallocate(void *Ptr, bool &ToPool) try { // but the range checks fail. memoryProviderFree(getMemHandle(), Ptr); } catch (MemoryProviderError &e) { - uma::getPoolLastStatusRef() = e.code; + umf::getPoolLastStatusRef() = e.code; } void DisjointPool::AllocImpl::printStats(bool &TitlePrinted, @@ -881,15 +881,15 @@ void DisjointPool::AllocImpl::printStats(bool &TitlePrinted, } } -uma_result_t DisjointPool::initialize(uma_memory_provider_handle_t *providers, +umf_result_t DisjointPool::initialize(umf_memory_provider_handle_t *providers, size_t numProviders, DisjointPoolConfig parameters) { if (numProviders != 1 || !providers[0]) { - return UMA_RESULT_ERROR_INVALID_ARGUMENT; + return UMF_RESULT_ERROR_INVALID_ARGUMENT; } impl = std::make_unique(providers[0], parameters); - return UMA_RESULT_SUCCESS; + return UMF_RESULT_SUCCESS; } void *DisjointPool::malloc(size_t size) { // For full-slab allocations indicates @@ -955,8 +955,8 @@ void DisjointPool::free(void *ptr) { return; } -enum uma_result_t DisjointPool::get_last_allocation_error() { - return uma::getPoolLastStatusRef(); +enum umf_result_t DisjointPool::get_last_allocation_error() { + return umf::getPoolLastStatusRef(); } DisjointPool::DisjointPool() {} diff --git a/source/common/uma_pools/disjoint_pool.hpp b/source/common/umf_pools/disjoint_pool.hpp similarity index 93% rename from source/common/uma_pools/disjoint_pool.hpp rename to source/common/umf_pools/disjoint_pool.hpp index fb1e34f2d7..85dd86872d 100644 --- a/source/common/uma_pools/disjoint_pool.hpp +++ b/source/common/umf_pools/disjoint_pool.hpp @@ -12,7 +12,7 @@ #include #include -#include "../uma_helpers.hpp" +#include "../umf_helpers.hpp" namespace usm { @@ -60,7 +60,7 @@ class DisjointPool { class AllocImpl; using Config = DisjointPoolConfig; - uma_result_t initialize(uma_memory_provider_handle_t *providers, + umf_result_t initialize(umf_memory_provider_handle_t *providers, size_t numProviders, DisjointPoolConfig parameters); void *malloc(size_t size); void *calloc(size_t, size_t); @@ -68,7 +68,7 @@ class DisjointPool { void *aligned_malloc(size_t size, size_t alignment); size_t malloc_usable_size(void *); void free(void *ptr); - enum uma_result_t get_last_allocation_error(); + enum umf_result_t get_last_allocation_error(); DisjointPool(); ~DisjointPool(); diff --git a/source/common/uma_pools/disjoint_pool_config_parser.cpp b/source/common/umf_pools/disjoint_pool_config_parser.cpp similarity index 100% rename from source/common/uma_pools/disjoint_pool_config_parser.cpp rename to source/common/umf_pools/disjoint_pool_config_parser.cpp diff --git a/source/common/uma_pools/disjoint_pool_config_parser.hpp b/source/common/umf_pools/disjoint_pool_config_parser.hpp similarity index 100% rename from source/common/uma_pools/disjoint_pool_config_parser.hpp rename to source/common/umf_pools/disjoint_pool_config_parser.hpp diff --git a/source/common/unified_memory_allocation/CMakeLists.txt b/source/common/unified_malloc_framework/CMakeLists.txt similarity index 55% rename from source/common/unified_memory_allocation/CMakeLists.txt rename to source/common/unified_malloc_framework/CMakeLists.txt index 7be1ab2dce..30991629cd 100644 --- a/source/common/unified_memory_allocation/CMakeLists.txt +++ b/source/common/unified_malloc_framework/CMakeLists.txt @@ -3,24 +3,24 @@ # See LICENSE.TXT # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -set(UMA_SOURCES +set(UMF_SOURCES src/memory_pool.c src/memory_provider.c src/memory_tracker.cpp src/memory_provider_get_last_failed.cpp ) -if(UMA_BUILD_SHARED_LIBRARY) - message(WARNING "Unified Memory Allocation is still an early work in progress." +if(UMF_BUILD_SHARED_LIBRARY) + message(WARNING "Unified Malloc Framework is still an early work in progress." "There are no API/ABI backward compatibility guarantees. There will be breakages." "Do not use the shared library in production software.") - add_library(unified_memory_allocation SHARED - ${UMA_SOURCES}) + add_library(unified_malloc_framework SHARED + ${UMF_SOURCES}) else() - add_library(unified_memory_allocation STATIC - ${UMA_SOURCES}) + add_library(unified_malloc_framework STATIC + ${UMF_SOURCES}) endif() -add_library(${PROJECT_NAME}::unified_memory_allocation ALIAS unified_memory_allocation) +add_library(${PROJECT_NAME}::unified_malloc_framework ALIAS unified_malloc_framework) -target_include_directories(unified_memory_allocation PUBLIC include) +target_include_directories(unified_malloc_framework PUBLIC include) diff --git a/source/common/unified_memory_allocation/include/uma.h b/source/common/unified_malloc_framework/include/umf.h similarity index 54% rename from source/common/unified_memory_allocation/include/uma.h rename to source/common/unified_malloc_framework/include/umf.h index 9b6eb1a435..c46eaa3e1f 100644 --- a/source/common/unified_memory_allocation/include/uma.h +++ b/source/common/unified_malloc_framework/include/umf.h @@ -8,10 +8,10 @@ * */ -#ifndef UMA_UNIFIED_MEMORY_ALLOCATION_H -#define UMA_UNIFIED_MEMORY_ALLOCATION_H 1 +#ifndef UMF_UNIFIED_MEMORY_ALLOCATION_H +#define UMF_UNIFIED_MEMORY_ALLOCATION_H 1 -#include -#include +#include +#include -#endif /* UMA_UNIFIED_MEMORY_ALLOCATION_H */ +#endif /* UMF_UNIFIED_MEMORY_ALLOCATION_H */ diff --git a/source/common/unified_malloc_framework/include/umf/base.h b/source/common/unified_malloc_framework/include/umf/base.h new file mode 100644 index 0000000000..6971bc0cab --- /dev/null +++ b/source/common/unified_malloc_framework/include/umf/base.h @@ -0,0 +1,54 @@ +/* + * + * Copyright (C) 2023 Intel Corporation + * + * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. + * See LICENSE.TXT + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + */ + +#ifndef UMF_BASE_H +#define UMF_BASE_H 1 + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/// \brief Generates generic 'UMF' API versions +#define UMF_MAKE_VERSION(_major, _minor) \ + ((_major << 16) | (_minor & 0x0000ffff)) + +/// \brief Extracts 'UMF' API major version +#define UMF_MAJOR_VERSION(_ver) (_ver >> 16) + +/// \brief Extracts 'UMF' API minor version +#define UMF_MINOR_VERSION(_ver) (_ver & 0x0000ffff) + +/// \brief Current version of the UMF headers +#define UMF_VERSION_CURRENT UMF_MAKE_VERSION(0, 9) + +/// \brief Operation results +enum umf_result_t { + UMF_RESULT_SUCCESS = 0, ///< Success + UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY = + 1, ///< Insufficient host memory to satisfy call, + UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC = + 2, ///< A provider specific warning/error has been reported and can be + ///< Retrieved via the umfMemoryProviderGetLastNativeError entry point. + UMF_RESULT_ERROR_INVALID_ARGUMENT = + 3, ///< Generic error code for invalid arguments + UMF_RESULT_ERROR_INVALID_ALIGNMENT = 4, /// Invalid alignment of an argument + UMF_RESULT_ERROR_NOT_SUPPORTED = 5, /// Operation not supported + + UMF_RESULT_ERROR_UNKNOWN = 0x7ffffffe ///< Unknown or internal error +}; + +#ifdef __cplusplus +} +#endif + +#endif /* UMF_BASE_H */ diff --git a/source/common/unified_memory_allocation/include/uma/memory_pool.h b/source/common/unified_malloc_framework/include/umf/memory_pool.h similarity index 72% rename from source/common/unified_memory_allocation/include/uma/memory_pool.h rename to source/common/unified_malloc_framework/include/umf/memory_pool.h index 812aa0c963..294ce6a46c 100644 --- a/source/common/unified_memory_allocation/include/uma/memory_pool.h +++ b/source/common/unified_malloc_framework/include/umf/memory_pool.h @@ -8,40 +8,40 @@ * */ -#ifndef UMA_MEMORY_POOL_H -#define UMA_MEMORY_POOL_H 1 +#ifndef UMF_MEMORY_POOL_H +#define UMF_MEMORY_POOL_H 1 -#include -#include +#include +#include #ifdef __cplusplus extern "C" { #endif -typedef struct uma_memory_pool_t *uma_memory_pool_handle_t; +typedef struct umf_memory_pool_t *umf_memory_pool_handle_t; -struct uma_memory_pool_ops_t; +struct umf_memory_pool_ops_t; /// /// \brief Creates new memory pool. -/// \param ops instance of uma_memory_pool_ops_t +/// \param ops instance of umf_memory_pool_ops_t /// \param providers array of memory providers that will be used for coarse-grain allocations. /// Should contain at least one memory provider. /// \param numProvider number of elements in the providers array /// \param params pointer to pool-specific parameters /// \param hPool [out] handle to the newly created memory pool -/// \return UMA_RESULT_SUCCESS on success or appropriate error code on failure. +/// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure. /// -enum uma_result_t umaPoolCreate(struct uma_memory_pool_ops_t *ops, - uma_memory_provider_handle_t *providers, +enum umf_result_t umfPoolCreate(struct umf_memory_pool_ops_t *ops, + umf_memory_provider_handle_t *providers, size_t numProviders, void *params, - uma_memory_pool_handle_t *hPool); + umf_memory_pool_handle_t *hPool); /// /// \brief Destroys memory pool. /// \param hPool handle to the pool /// -void umaPoolDestroy(uma_memory_pool_handle_t hPool); +void umfPoolDestroy(umf_memory_pool_handle_t hPool); /// /// \brief Allocates size bytes of uninitialized storage of the specified hPool. @@ -49,7 +49,7 @@ void umaPoolDestroy(uma_memory_pool_handle_t hPool); /// \param size number of bytes to allocate /// \return Pointer to the allocated memory. /// -void *umaPoolMalloc(uma_memory_pool_handle_t hPool, size_t size); +void *umfPoolMalloc(umf_memory_pool_handle_t hPool, size_t size); /// /// \brief Allocates size bytes of uninitialized storage of the specified hPool. @@ -59,7 +59,7 @@ void *umaPoolMalloc(uma_memory_pool_handle_t hPool, size_t size); /// \param alignment alignment of the allocation /// \return Pointer to the allocated memory. /// -void *umaPoolAlignedMalloc(uma_memory_pool_handle_t hPool, size_t size, +void *umfPoolAlignedMalloc(umf_memory_pool_handle_t hPool, size_t size, size_t alignment); /// @@ -71,7 +71,7 @@ void *umaPoolAlignedMalloc(uma_memory_pool_handle_t hPool, size_t size, /// \param size specified size of each element /// \return Pointer to the allocated memory. /// -void *umaPoolCalloc(uma_memory_pool_handle_t hPool, size_t num, size_t size); +void *umfPoolCalloc(umf_memory_pool_handle_t hPool, size_t num, size_t size); /// /// \brief Reallocates memory of the specified hPool. @@ -80,7 +80,7 @@ void *umaPoolCalloc(uma_memory_pool_handle_t hPool, size_t num, size_t size); /// \param size new size for the memory block in bytes /// \return Pointer to the allocated memory. /// -void *umaPoolRealloc(uma_memory_pool_handle_t hPool, void *ptr, size_t size); +void *umfPoolRealloc(umf_memory_pool_handle_t hPool, void *ptr, size_t size); /// /// \brief Obtains size of block of memory allocated from the pool. @@ -88,23 +88,23 @@ void *umaPoolRealloc(uma_memory_pool_handle_t hPool, void *ptr, size_t size); /// \param ptr pointer to the allocated memory /// \return Number of bytes. /// -size_t umaPoolMallocUsableSize(uma_memory_pool_handle_t hPool, void *ptr); +size_t umfPoolMallocUsableSize(umf_memory_pool_handle_t hPool, void *ptr); /// /// \brief Frees the memory space of the specified hPool pointed by ptr. /// \param hPool specified memory hPool /// \param ptr pointer to the allocated memory /// -void umaPoolFree(uma_memory_pool_handle_t hPool, void *ptr); +void umfPoolFree(umf_memory_pool_handle_t hPool, void *ptr); /// -/// \brief Frees the memory space pointed by ptr if it belongs to UMA pool, does nothing otherwise. +/// \brief Frees the memory space pointed by ptr if it belongs to UMF pool, does nothing otherwise. /// \param ptr pointer to the allocated memory /// -void umaFree(void *ptr); +void umfFree(void *ptr); /// -/// \brief Retrieve uma_result_t representing the error of the last failed allocation +/// \brief Retrieve umf_result_t representing the error of the last failed allocation /// operation in this thread (malloc, calloc, realloc, aligned_malloc). /// /// \details @@ -120,29 +120,29 @@ void umaFree(void *ptr); /// \param hPool specified memory hPool /// \return Error code desciribng the failure of the last failed allocation operation. /// The value is undefined if the previous allocation was successful. -enum uma_result_t umaPoolGetLastAllocationError(uma_memory_pool_handle_t hPool); +enum umf_result_t umfPoolGetLastAllocationError(umf_memory_pool_handle_t hPool); /// /// \brief Retrieve memory pool associated with a given ptr. /// \param ptr pointer to memory belonging to a memory pool -/// \return Handle to a memory pool that contains ptr or NULL if pointer does not belong to any UMA pool. -uma_memory_pool_handle_t umaPoolByPtr(const void *ptr); +/// \return Handle to a memory pool that contains ptr or NULL if pointer does not belong to any UMF pool. +umf_memory_pool_handle_t umfPoolByPtr(const void *ptr); /// /// \brief Retrieve memory providers associated with a given pool. /// \param hPool specified memory pool /// \param hProviders [out] pointer to an array of memory providers. If numProviders is not equal to or -/// greater than the real number of providers, UMA_RESULT_ERROR_INVALID_ARGUMENT is returned. +/// greater than the real number of providers, UMF_RESULT_ERROR_INVALID_ARGUMENT is returned. /// \param numProviders [in] number of memory providers to return /// \param numProvidersRet pointer to the actual number of memory providers -/// \return UMA_RESULT_SUCCESS on success or appropriate error code on failure. -enum uma_result_t -umaPoolGetMemoryProviders(uma_memory_pool_handle_t hPool, size_t numProviders, - uma_memory_provider_handle_t *hProviders, +/// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure. +enum umf_result_t +umfPoolGetMemoryProviders(umf_memory_pool_handle_t hPool, size_t numProviders, + umf_memory_provider_handle_t *hProviders, size_t *numProvidersRet); #ifdef __cplusplus } #endif -#endif /* UMA_MEMORY_POOL_H */ +#endif /* UMF_MEMORY_POOL_H */ diff --git a/source/common/unified_memory_allocation/include/uma/memory_pool_ops.h b/source/common/unified_malloc_framework/include/umf/memory_pool_ops.h similarity index 78% rename from source/common/unified_memory_allocation/include/uma/memory_pool_ops.h rename to source/common/unified_malloc_framework/include/umf/memory_pool_ops.h index 21fae70b27..ce7aa960d7 100644 --- a/source/common/unified_memory_allocation/include/uma/memory_pool_ops.h +++ b/source/common/unified_malloc_framework/include/umf/memory_pool_ops.h @@ -8,21 +8,21 @@ * */ -#ifndef UMA_MEMORY_POOL_OPS_H -#define UMA_MEMORY_POOL_OPS_H 1 +#ifndef UMF_MEMORY_POOL_OPS_H +#define UMF_MEMORY_POOL_OPS_H 1 -#include +#include #ifdef __cplusplus extern "C" { #endif -/// \brief This structure comprises function pointers used by corresponding umaPool* +/// \brief This structure comprises function pointers used by corresponding umfPool* /// calls. Each memory pool implementation should initialize all function /// pointers. -struct uma_memory_pool_ops_t { +struct umf_memory_pool_ops_t { /// Version of the ops structure. - /// Should be initialized using UMA_VERSION_CURRENT + /// Should be initialized using UMF_VERSION_CURRENT uint32_t version; /// @@ -32,8 +32,8 @@ struct uma_memory_pool_ops_t { /// \param numProvider number of elements in the providers array /// \param params pool-specific params /// \param pool [out] returns pointer to the pool - /// \return UMA_RESULT_SUCCESS on success or appropriate error code on failure. - enum uma_result_t (*initialize)(uma_memory_provider_handle_t *providers, + /// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure. + enum umf_result_t (*initialize)(umf_memory_provider_handle_t *providers, size_t numProviders, void *params, void **pool); @@ -49,11 +49,11 @@ struct uma_memory_pool_ops_t { void *(*aligned_malloc)(void *pool, size_t size, size_t alignment); size_t (*malloc_usable_size)(void *pool, void *ptr); void (*free)(void *pool, void *); - enum uma_result_t (*get_last_allocation_error)(void *pool); + enum umf_result_t (*get_last_allocation_error)(void *pool); }; #ifdef __cplusplus } #endif -#endif /* UMA_MEMORY_POOL_OPS_H */ +#endif /* UMF_MEMORY_POOL_OPS_H */ diff --git a/source/common/unified_memory_allocation/include/uma/memory_provider.h b/source/common/unified_malloc_framework/include/umf/memory_provider.h similarity index 68% rename from source/common/unified_memory_allocation/include/uma/memory_provider.h rename to source/common/unified_malloc_framework/include/umf/memory_provider.h index 9b65dc6419..8a911a62a3 100644 --- a/source/common/unified_memory_allocation/include/uma/memory_provider.h +++ b/source/common/unified_malloc_framework/include/umf/memory_provider.h @@ -8,34 +8,34 @@ * */ -#ifndef UMA_MEMORY_PROVIDER_H -#define UMA_MEMORY_PROVIDER_H 1 +#ifndef UMF_MEMORY_PROVIDER_H +#define UMF_MEMORY_PROVIDER_H 1 -#include -#include +#include +#include #ifdef __cplusplus extern "C" { #endif -typedef struct uma_memory_provider_t *uma_memory_provider_handle_t; +typedef struct umf_memory_provider_t *umf_memory_provider_handle_t; /// /// \brief Creates new memory provider. -/// \param ops instance of uma_memory_provider_ops_t +/// \param ops instance of umf_memory_provider_ops_t /// \param params pointer to provider-specific parameters /// \param hProvider [out] pointer to the newly created memory provider -/// \return UMA_RESULT_SUCCESS on success or appropriate error code on failure. +/// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure. /// -enum uma_result_t -umaMemoryProviderCreate(struct uma_memory_provider_ops_t *ops, void *params, - uma_memory_provider_handle_t *hProvider); +enum umf_result_t +umfMemoryProviderCreate(struct umf_memory_provider_ops_t *ops, void *params, + umf_memory_provider_handle_t *hProvider); /// /// \brief Destroys memory provider. /// \param hPool handle to the memory provider /// -void umaMemoryProviderDestroy(uma_memory_provider_handle_t hProvider); +void umfMemoryProviderDestroy(umf_memory_provider_handle_t hProvider); /// /// \brief Allocates size bytes of uninitialized storage from memory provider @@ -44,9 +44,9 @@ void umaMemoryProviderDestroy(uma_memory_provider_handle_t hProvider); /// \param size number of bytes to allocate /// \param alignment alignment of the allocation /// \param ptr [out] pointer to the allocated memory -/// \return UMA_RESULT_SUCCESS on success or appropriate error code on failure. +/// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure. /// -enum uma_result_t umaMemoryProviderAlloc(uma_memory_provider_handle_t hProvider, +enum umf_result_t umfMemoryProviderAlloc(umf_memory_provider_handle_t hProvider, size_t size, size_t alignment, void **ptr); @@ -55,23 +55,23 @@ enum uma_result_t umaMemoryProviderAlloc(uma_memory_provider_handle_t hProvider, /// \param hProvider handle to the memory provider /// \param ptr pointer to the allocated memory /// \param size size of the allocation -/// \return UMA_RESULT_SUCCESS on success or appropriate error code on failure. +/// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure. /// -enum uma_result_t umaMemoryProviderFree(uma_memory_provider_handle_t hProvider, +enum umf_result_t umfMemoryProviderFree(umf_memory_provider_handle_t hProvider, void *ptr, size_t size); /// /// \brief Retrieve string representation of the underlying provider specific /// result reported by the last API that returned -/// UMA_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC. Allows for a provider +/// UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC. Allows for a provider /// independent way to return a provider specific result. /// /// \details /// * Implementations *must* store the message and error code in thread-local -/// storage prior to returning UMA_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC. +/// storage prior to returning UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC. /// /// * The message and error code will only be valid if a previously -/// called entry-point returned UMA_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC. +/// called entry-point returned UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC. /// /// * The memory pointed to by the C string returned in `ppMessage` is owned by /// the adapter and *must* be null terminated. @@ -83,7 +83,7 @@ enum uma_result_t umaMemoryProviderFree(uma_memory_provider_handle_t hProvider, /// \param ppMessage [out] pointer to a string containing provider specific /// result in string representation /// \param pError [out] pointer to an integer where the adapter specific error code will be stored -void umaMemoryProviderGetLastNativeError(uma_memory_provider_handle_t hProvider, +void umfMemoryProviderGetLastNativeError(umf_memory_provider_handle_t hProvider, const char **ppMessage, int32_t *pError); @@ -92,9 +92,9 @@ void umaMemoryProviderGetLastNativeError(uma_memory_provider_handle_t hProvider, /// \param hProvider handle to the memory provider /// \param size allocation size /// \param pageSize [out] will be updated with recommended page size -/// \return UMA_RESULT_SUCCESS on success or appropriate error code on failure. -enum uma_result_t -umaMemoryProviderGetRecommendedPageSize(uma_memory_provider_handle_t hProvider, +/// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure. +enum umf_result_t +umfMemoryProviderGetRecommendedPageSize(umf_memory_provider_handle_t hProvider, size_t size, size_t *pageSize); /// @@ -103,9 +103,9 @@ umaMemoryProviderGetRecommendedPageSize(uma_memory_provider_handle_t hProvider, /// \param hProvider handle to the memory provider /// \param ptr [optional] pointer to memory allocated by this memory provider /// \param pageSize [out] will be updated with page size value. -/// \return UMA_RESULT_SUCCESS on success or appropriate error code on failure. -enum uma_result_t -umaMemoryProviderGetMinPageSize(uma_memory_provider_handle_t hProvider, +/// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure. +enum umf_result_t +umfMemoryProviderGetMinPageSize(umf_memory_provider_handle_t hProvider, void *ptr, size_t *pageSize); /// @@ -114,11 +114,11 @@ umaMemoryProviderGetMinPageSize(uma_memory_provider_handle_t hProvider, /// \param hProvider handle to the memory provider /// \param ptr beginning of the virtual memory range /// \param size size of the virtual memory range -/// \return UMA_RESULT_SUCCESS on success or appropriate error code on failure. -/// UMA_RESULT_ERROR_INVALID_ALIGNMENT if ptr or size is not page-aligned. -/// UMA_RESULT_ERROR_NOT_SUPPORTED if operation is not supported by this provider. -enum uma_result_t -umaMemoryProviderPurgeLazy(uma_memory_provider_handle_t hProvider, void *ptr, +/// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure. +/// UMF_RESULT_ERROR_INVALID_ALIGNMENT if ptr or size is not page-aligned. +/// UMF_RESULT_ERROR_NOT_SUPPORTED if operation is not supported by this provider. +enum umf_result_t +umfMemoryProviderPurgeLazy(umf_memory_provider_handle_t hProvider, void *ptr, size_t size); /// @@ -127,31 +127,31 @@ umaMemoryProviderPurgeLazy(uma_memory_provider_handle_t hProvider, void *ptr, /// \param hProvider handle to the memory provider /// \param ptr beginning of the virtual memory range /// \param size size of the virtual memory range -/// \return UMA_RESULT_SUCCESS on success or appropriate error code on failure -/// UMA_RESULT_ERROR_INVALID_ALIGNMENT if ptr or size is not page-aligned. -/// UMA_RESULT_ERROR_NOT_SUPPORTED if operation is not supported by this provider. -enum uma_result_t -umaMemoryProviderPurgeForce(uma_memory_provider_handle_t hProvider, void *ptr, +/// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure +/// UMF_RESULT_ERROR_INVALID_ALIGNMENT if ptr or size is not page-aligned. +/// UMF_RESULT_ERROR_NOT_SUPPORTED if operation is not supported by this provider. +enum umf_result_t +umfMemoryProviderPurgeForce(umf_memory_provider_handle_t hProvider, void *ptr, size_t size); /// /// \brief Retrive name of a given memory provider. /// \param hProvider handle to the memory provider /// \param ppName [out] pointer to a string containing name of the provider -const char *umaMemoryProviderGetName(uma_memory_provider_handle_t hProvider); +const char *umfMemoryProviderGetName(umf_memory_provider_handle_t hProvider); /// \brief Retrieve handle to the last memory provider that returned status other -/// than UMA_RESULT_SUCCESS on the calling thread. +/// than UMF_RESULT_SUCCESS on the calling thread. /// /// \details Handle to the memory provider is stored in the thread local /// storage. The handle is updated every time a memory provider -/// returns status other than UMA_RESULT_SUCCESS. +/// returns status other than UMF_RESULT_SUCCESS. /// /// \return Handle to the memory provider -uma_memory_provider_handle_t umaGetLastFailedMemoryProvider(); +umf_memory_provider_handle_t umfGetLastFailedMemoryProvider(); #ifdef __cplusplus } #endif -#endif /* UMA_MEMORY_PROVIDER_H */ +#endif /* UMF_MEMORY_PROVIDER_H */ diff --git a/source/common/unified_memory_allocation/include/uma/memory_provider_ops.h b/source/common/unified_malloc_framework/include/umf/memory_provider_ops.h similarity index 60% rename from source/common/unified_memory_allocation/include/uma/memory_provider_ops.h rename to source/common/unified_malloc_framework/include/umf/memory_provider_ops.h index 404f221cb3..74d16a72a8 100644 --- a/source/common/unified_memory_allocation/include/uma/memory_provider_ops.h +++ b/source/common/unified_malloc_framework/include/umf/memory_provider_ops.h @@ -8,29 +8,29 @@ * */ -#ifndef UMA_MEMORY_PROVIDER_OPS_H -#define UMA_MEMORY_PROVIDER_OPS_H 1 +#ifndef UMF_MEMORY_PROVIDER_OPS_H +#define UMF_MEMORY_PROVIDER_OPS_H 1 -#include +#include #ifdef __cplusplus extern "C" { #endif /// This structure comprises function pointers used by corresponding -/// umaMemoryProvider* calls. Each memory provider implementation should +/// umfMemoryProvider* calls. Each memory provider implementation should /// initialize all function pointers. -struct uma_memory_provider_ops_t { +struct umf_memory_provider_ops_t { /// Version of the ops structure. - /// Should be initialized using UMA_VERSION_CURRENT + /// Should be initialized using UMF_VERSION_CURRENT uint32_t version; /// /// \brief Intializes memory pool. /// \param params pool-specific params /// \param pool returns pointer to the pool - /// \return UMA_RESULT_SUCCESS on success or appropriate error code on failure. - enum uma_result_t (*initialize)(void *params, void **pool); + /// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure. + enum umf_result_t (*initialize)(void *params, void **pool); /// /// \brief Finalizes memory pool. @@ -38,17 +38,17 @@ struct uma_memory_provider_ops_t { void (*finalize)(void *pool); /// Refer to memory_provider.h for description of those functions - enum uma_result_t (*alloc)(void *provider, size_t size, size_t alignment, + enum umf_result_t (*alloc)(void *provider, size_t size, size_t alignment, void **ptr); - enum uma_result_t (*free)(void *provider, void *ptr, size_t size); + enum umf_result_t (*free)(void *provider, void *ptr, size_t size); void (*get_last_native_error)(void *provider, const char **ppMessage, int32_t *pError); - enum uma_result_t (*get_recommended_page_size)(void *provider, size_t size, + enum umf_result_t (*get_recommended_page_size)(void *provider, size_t size, size_t *pageSize); - enum uma_result_t (*get_min_page_size)(void *provider, void *ptr, + enum umf_result_t (*get_min_page_size)(void *provider, void *ptr, size_t *pageSize); - enum uma_result_t (*purge_lazy)(void *provider, void *ptr, size_t size); - enum uma_result_t (*purge_force)(void *provider, void *ptr, size_t size); + enum umf_result_t (*purge_lazy)(void *provider, void *ptr, size_t size); + enum umf_result_t (*purge_force)(void *provider, void *ptr, size_t size); const char *(*get_name)(void *provider); }; @@ -56,4 +56,4 @@ struct uma_memory_provider_ops_t { } #endif -#endif /* #ifndef UMA_MEMORY_PROVIDER_OPS_H */ +#endif /* #ifndef UMF_MEMORY_PROVIDER_OPS_H */ diff --git a/source/common/unified_memory_allocation/src/memory_pool.c b/source/common/unified_malloc_framework/src/memory_pool.c similarity index 54% rename from source/common/unified_memory_allocation/src/memory_pool.c rename to source/common/unified_malloc_framework/src/memory_pool.c index 13a86d8a6c..9328b3896a 100644 --- a/source/common/unified_memory_allocation/src/memory_pool.c +++ b/source/common/unified_malloc_framework/src/memory_pool.c @@ -11,53 +11,53 @@ #include "memory_provider_internal.h" #include "memory_tracker.h" -#include -#include +#include +#include #include #include -struct uma_memory_pool_t { +struct umf_memory_pool_t { void *pool_priv; - struct uma_memory_pool_ops_t ops; + struct umf_memory_pool_ops_t ops; // Holds array of memory providers. All providers are wrapped - // by memory tracking providers (owned and released by UMA). - uma_memory_provider_handle_t *providers; + // by memory tracking providers (owned and released by UMF). + umf_memory_provider_handle_t *providers; size_t numProviders; }; static void -destroyMemoryProviderWrappers(uma_memory_provider_handle_t *providers, +destroyMemoryProviderWrappers(umf_memory_provider_handle_t *providers, size_t numProviders) { for (size_t i = 0; i < numProviders; i++) { - umaMemoryProviderDestroy(providers[i]); + umfMemoryProviderDestroy(providers[i]); } free(providers); } -enum uma_result_t umaPoolCreate(struct uma_memory_pool_ops_t *ops, - uma_memory_provider_handle_t *providers, +enum umf_result_t umfPoolCreate(struct umf_memory_pool_ops_t *ops, + umf_memory_provider_handle_t *providers, size_t numProviders, void *params, - uma_memory_pool_handle_t *hPool) { + umf_memory_pool_handle_t *hPool) { if (!numProviders || !providers) { - return UMA_RESULT_ERROR_INVALID_ARGUMENT; + return UMF_RESULT_ERROR_INVALID_ARGUMENT; } - enum uma_result_t ret = UMA_RESULT_SUCCESS; - uma_memory_pool_handle_t pool = malloc(sizeof(struct uma_memory_pool_t)); + enum umf_result_t ret = UMF_RESULT_SUCCESS; + umf_memory_pool_handle_t pool = malloc(sizeof(struct umf_memory_pool_t)); if (!pool) { - return UMA_RESULT_ERROR_OUT_OF_HOST_MEMORY; + return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; } - assert(ops->version == UMA_VERSION_CURRENT); + assert(ops->version == UMF_VERSION_CURRENT); pool->providers = - calloc(numProviders, sizeof(uma_memory_provider_handle_t)); + calloc(numProviders, sizeof(umf_memory_provider_handle_t)); if (!pool->providers) { - ret = UMA_RESULT_ERROR_OUT_OF_HOST_MEMORY; + ret = UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; goto err_providers_alloc; } @@ -66,9 +66,9 @@ enum uma_result_t umaPoolCreate(struct uma_memory_pool_ops_t *ops, // Wrap each provider with memory tracking provider. for (providerInd = 0; providerInd < numProviders; providerInd++) { - ret = umaTrackingMemoryProviderCreate(providers[providerInd], pool, + ret = umfTrackingMemoryProviderCreate(providers[providerInd], pool, &pool->providers[providerInd]); - if (ret != UMA_RESULT_SUCCESS) { + if (ret != UMF_RESULT_SUCCESS) { goto err_providers_init; } } @@ -76,12 +76,12 @@ enum uma_result_t umaPoolCreate(struct uma_memory_pool_ops_t *ops, pool->ops = *ops; ret = ops->initialize(pool->providers, pool->numProviders, params, &pool->pool_priv); - if (ret != UMA_RESULT_SUCCESS) { + if (ret != UMF_RESULT_SUCCESS) { goto err_pool_init; } *hPool = pool; - return UMA_RESULT_SUCCESS; + return UMF_RESULT_SUCCESS; err_pool_init: err_providers_init: @@ -92,59 +92,59 @@ enum uma_result_t umaPoolCreate(struct uma_memory_pool_ops_t *ops, return ret; } -void umaPoolDestroy(uma_memory_pool_handle_t hPool) { +void umfPoolDestroy(umf_memory_pool_handle_t hPool) { hPool->ops.finalize(hPool->pool_priv); destroyMemoryProviderWrappers(hPool->providers, hPool->numProviders); free(hPool); } -void *umaPoolMalloc(uma_memory_pool_handle_t hPool, size_t size) { +void *umfPoolMalloc(umf_memory_pool_handle_t hPool, size_t size) { return hPool->ops.malloc(hPool->pool_priv, size); } -void *umaPoolAlignedMalloc(uma_memory_pool_handle_t hPool, size_t size, +void *umfPoolAlignedMalloc(umf_memory_pool_handle_t hPool, size_t size, size_t alignment) { return hPool->ops.aligned_malloc(hPool->pool_priv, size, alignment); } -void *umaPoolCalloc(uma_memory_pool_handle_t hPool, size_t num, size_t size) { +void *umfPoolCalloc(umf_memory_pool_handle_t hPool, size_t num, size_t size) { return hPool->ops.calloc(hPool->pool_priv, num, size); } -void *umaPoolRealloc(uma_memory_pool_handle_t hPool, void *ptr, size_t size) { +void *umfPoolRealloc(umf_memory_pool_handle_t hPool, void *ptr, size_t size) { return hPool->ops.realloc(hPool->pool_priv, ptr, size); } -size_t umaPoolMallocUsableSize(uma_memory_pool_handle_t hPool, void *ptr) { +size_t umfPoolMallocUsableSize(umf_memory_pool_handle_t hPool, void *ptr) { return hPool->ops.malloc_usable_size(hPool->pool_priv, ptr); } -void umaPoolFree(uma_memory_pool_handle_t hPool, void *ptr) { +void umfPoolFree(umf_memory_pool_handle_t hPool, void *ptr) { hPool->ops.free(hPool->pool_priv, ptr); } -void umaFree(void *ptr) { - uma_memory_pool_handle_t hPool = umaPoolByPtr(ptr); +void umfFree(void *ptr) { + umf_memory_pool_handle_t hPool = umfPoolByPtr(ptr); if (hPool) { - umaPoolFree(hPool, ptr); + umfPoolFree(hPool, ptr); } } -enum uma_result_t -umaPoolGetLastAllocationError(uma_memory_pool_handle_t hPool) { +enum umf_result_t +umfPoolGetLastAllocationError(umf_memory_pool_handle_t hPool) { return hPool->ops.get_last_allocation_error(hPool->pool_priv); } -uma_memory_pool_handle_t umaPoolByPtr(const void *ptr) { - return umaMemoryTrackerGetPool(umaMemoryTrackerGet(), ptr); +umf_memory_pool_handle_t umfPoolByPtr(const void *ptr) { + return umfMemoryTrackerGetPool(umfMemoryTrackerGet(), ptr); } -enum uma_result_t -umaPoolGetMemoryProviders(uma_memory_pool_handle_t hPool, size_t numProviders, - uma_memory_provider_handle_t *hProviders, +enum umf_result_t +umfPoolGetMemoryProviders(umf_memory_pool_handle_t hPool, size_t numProviders, + umf_memory_provider_handle_t *hProviders, size_t *numProvidersRet) { if (hProviders && numProviders < hPool->numProviders) { - return UMA_RESULT_ERROR_INVALID_ARGUMENT; + return UMF_RESULT_ERROR_INVALID_ARGUMENT; } if (numProvidersRet) { @@ -153,10 +153,10 @@ umaPoolGetMemoryProviders(uma_memory_pool_handle_t hPool, size_t numProviders, if (hProviders) { for (size_t i = 0; i < hPool->numProviders; i++) { - umaTrackingMemoryProviderGetUpstreamProvider( - umaMemoryProviderGetPriv(hPool->providers[i]), hProviders + i); + umfTrackingMemoryProviderGetUpstreamProvider( + umfMemoryProviderGetPriv(hPool->providers[i]), hProviders + i); } } - return UMA_RESULT_SUCCESS; + return UMF_RESULT_SUCCESS; } diff --git a/source/common/unified_memory_allocation/src/memory_provider.c b/source/common/unified_malloc_framework/src/memory_provider.c similarity index 56% rename from source/common/unified_memory_allocation/src/memory_provider.c rename to source/common/unified_malloc_framework/src/memory_provider.c index 103bcef88a..38e4dfbf8b 100644 --- a/source/common/unified_memory_allocation/src/memory_provider.c +++ b/source/common/unified_malloc_framework/src/memory_provider.c @@ -9,32 +9,32 @@ */ #include "memory_provider_internal.h" -#include +#include #include #include -struct uma_memory_provider_t { - struct uma_memory_provider_ops_t ops; +struct umf_memory_provider_t { + struct umf_memory_provider_ops_t ops; void *provider_priv; }; -enum uma_result_t -umaMemoryProviderCreate(struct uma_memory_provider_ops_t *ops, void *params, - uma_memory_provider_handle_t *hProvider) { - uma_memory_provider_handle_t provider = - malloc(sizeof(struct uma_memory_provider_t)); +enum umf_result_t +umfMemoryProviderCreate(struct umf_memory_provider_ops_t *ops, void *params, + umf_memory_provider_handle_t *hProvider) { + umf_memory_provider_handle_t provider = + malloc(sizeof(struct umf_memory_provider_t)); if (!provider) { - return UMA_RESULT_ERROR_OUT_OF_HOST_MEMORY; + return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; } - assert(ops->version == UMA_VERSION_CURRENT); + assert(ops->version == UMF_VERSION_CURRENT); provider->ops = *ops; void *provider_priv; - enum uma_result_t ret = ops->initialize(params, &provider_priv); - if (ret != UMA_RESULT_SUCCESS) { + enum umf_result_t ret = ops->initialize(params, &provider_priv); + if (ret != UMF_RESULT_SUCCESS) { free(provider); return ret; } @@ -43,90 +43,90 @@ umaMemoryProviderCreate(struct uma_memory_provider_ops_t *ops, void *params, *hProvider = provider; - return UMA_RESULT_SUCCESS; + return UMF_RESULT_SUCCESS; } -void umaMemoryProviderDestroy(uma_memory_provider_handle_t hProvider) { +void umfMemoryProviderDestroy(umf_memory_provider_handle_t hProvider) { hProvider->ops.finalize(hProvider->provider_priv); free(hProvider); } static void -checkErrorAndSetLastProvider(enum uma_result_t result, - uma_memory_provider_handle_t hProvider) { - if (result != UMA_RESULT_SUCCESS) { - *umaGetLastFailedMemoryProviderPtr() = hProvider; +checkErrorAndSetLastProvider(enum umf_result_t result, + umf_memory_provider_handle_t hProvider) { + if (result != UMF_RESULT_SUCCESS) { + *umfGetLastFailedMemoryProviderPtr() = hProvider; } } -enum uma_result_t umaMemoryProviderAlloc(uma_memory_provider_handle_t hProvider, +enum umf_result_t umfMemoryProviderAlloc(umf_memory_provider_handle_t hProvider, size_t size, size_t alignment, void **ptr) { - enum uma_result_t res = + enum umf_result_t res = hProvider->ops.alloc(hProvider->provider_priv, size, alignment, ptr); checkErrorAndSetLastProvider(res, hProvider); return res; } -enum uma_result_t umaMemoryProviderFree(uma_memory_provider_handle_t hProvider, +enum umf_result_t umfMemoryProviderFree(umf_memory_provider_handle_t hProvider, void *ptr, size_t size) { - enum uma_result_t res = + enum umf_result_t res = hProvider->ops.free(hProvider->provider_priv, ptr, size); checkErrorAndSetLastProvider(res, hProvider); return res; } -void umaMemoryProviderGetLastNativeError(uma_memory_provider_handle_t hProvider, +void umfMemoryProviderGetLastNativeError(umf_memory_provider_handle_t hProvider, const char **ppMessage, int32_t *pError) { hProvider->ops.get_last_native_error(hProvider->provider_priv, ppMessage, pError); } -void *umaMemoryProviderGetPriv(uma_memory_provider_handle_t hProvider) { +void *umfMemoryProviderGetPriv(umf_memory_provider_handle_t hProvider) { return hProvider->provider_priv; } -enum uma_result_t -umaMemoryProviderGetRecommendedPageSize(uma_memory_provider_handle_t hProvider, +enum umf_result_t +umfMemoryProviderGetRecommendedPageSize(umf_memory_provider_handle_t hProvider, size_t size, size_t *pageSize) { - enum uma_result_t res = hProvider->ops.get_recommended_page_size( + enum umf_result_t res = hProvider->ops.get_recommended_page_size( hProvider->provider_priv, size, pageSize); checkErrorAndSetLastProvider(res, hProvider); return res; } -enum uma_result_t -umaMemoryProviderGetMinPageSize(uma_memory_provider_handle_t hProvider, +enum umf_result_t +umfMemoryProviderGetMinPageSize(umf_memory_provider_handle_t hProvider, void *ptr, size_t *pageSize) { - enum uma_result_t res = hProvider->ops.get_min_page_size( + enum umf_result_t res = hProvider->ops.get_min_page_size( hProvider->provider_priv, ptr, pageSize); checkErrorAndSetLastProvider(res, hProvider); return res; } -enum uma_result_t -umaMemoryProviderPurgeLazy(uma_memory_provider_handle_t hProvider, void *ptr, +enum umf_result_t +umfMemoryProviderPurgeLazy(umf_memory_provider_handle_t hProvider, void *ptr, size_t size) { - enum uma_result_t res = + enum umf_result_t res = hProvider->ops.purge_lazy(hProvider->provider_priv, ptr, size); checkErrorAndSetLastProvider(res, hProvider); return res; } -enum uma_result_t -umaMemoryProviderPurgeForce(uma_memory_provider_handle_t hProvider, void *ptr, +enum umf_result_t +umfMemoryProviderPurgeForce(umf_memory_provider_handle_t hProvider, void *ptr, size_t size) { - enum uma_result_t res = + enum umf_result_t res = hProvider->ops.purge_force(hProvider->provider_priv, ptr, size); checkErrorAndSetLastProvider(res, hProvider); return res; } -const char *umaMemoryProviderGetName(uma_memory_provider_handle_t hProvider) { +const char *umfMemoryProviderGetName(umf_memory_provider_handle_t hProvider) { return hProvider->ops.get_name(hProvider->provider_priv); } -uma_memory_provider_handle_t umaGetLastFailedMemoryProvider() { - return *umaGetLastFailedMemoryProviderPtr(); +umf_memory_provider_handle_t umfGetLastFailedMemoryProvider() { + return *umfGetLastFailedMemoryProviderPtr(); } diff --git a/source/common/unified_memory_allocation/src/memory_provider_get_last_failed.cpp b/source/common/unified_malloc_framework/src/memory_provider_get_last_failed.cpp similarity index 72% rename from source/common/unified_memory_allocation/src/memory_provider_get_last_failed.cpp rename to source/common/unified_malloc_framework/src/memory_provider_get_last_failed.cpp index 52a4e6ce35..c439213a26 100644 --- a/source/common/unified_memory_allocation/src/memory_provider_get_last_failed.cpp +++ b/source/common/unified_malloc_framework/src/memory_provider_get_last_failed.cpp @@ -12,9 +12,9 @@ extern "C" { -static thread_local uma_memory_provider_handle_t lastFailedProvider = nullptr; +static thread_local umf_memory_provider_handle_t lastFailedProvider = nullptr; -uma_memory_provider_handle_t *umaGetLastFailedMemoryProviderPtr() { +umf_memory_provider_handle_t *umfGetLastFailedMemoryProviderPtr() { return &lastFailedProvider; } } diff --git a/source/common/unified_memory_allocation/src/memory_provider_internal.h b/source/common/unified_malloc_framework/src/memory_provider_internal.h similarity index 52% rename from source/common/unified_memory_allocation/src/memory_provider_internal.h rename to source/common/unified_malloc_framework/src/memory_provider_internal.h index a2b190488f..07befd4b4e 100644 --- a/source/common/unified_memory_allocation/src/memory_provider_internal.h +++ b/source/common/unified_malloc_framework/src/memory_provider_internal.h @@ -8,20 +8,20 @@ * */ -#ifndef UMA_MEMORY_PROVIDER_INTERNAL_H -#define UMA_MEMORY_PROVIDER_INTERNAL_H 1 +#ifndef UMF_MEMORY_PROVIDER_INTERNAL_H +#define UMF_MEMORY_PROVIDER_INTERNAL_H 1 -#include +#include #ifdef __cplusplus extern "C" { #endif -void *umaMemoryProviderGetPriv(uma_memory_provider_handle_t hProvider); -uma_memory_provider_handle_t *umaGetLastFailedMemoryProviderPtr(); +void *umfMemoryProviderGetPriv(umf_memory_provider_handle_t hProvider); +umf_memory_provider_handle_t *umfGetLastFailedMemoryProviderPtr(); #ifdef __cplusplus } #endif -#endif /* UMA_MEMORY_PROVIDER_INTERNAL_H */ +#endif /* UMF_MEMORY_PROVIDER_INTERNAL_H */ diff --git a/source/common/unified_malloc_framework/src/memory_tracker.cpp b/source/common/unified_malloc_framework/src/memory_tracker.cpp new file mode 100644 index 0000000000..74638579cc --- /dev/null +++ b/source/common/unified_malloc_framework/src/memory_tracker.cpp @@ -0,0 +1,247 @@ +/* + * + * Copyright (C) 2023 Intel Corporation + * + * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. + * See LICENSE.TXT + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + */ + +#include "memory_tracker.h" +#include +#include + +#include +#include +#include +#include +#include + +// TODO: reimplement in C and optimize... +struct umf_memory_tracker_t { + enum umf_result_t add(void *pool, const void *ptr, size_t size) { + std::unique_lock lock(mtx); + + if (size == 0) { + return UMF_RESULT_SUCCESS; + } + + auto ret = + map.try_emplace(reinterpret_cast(ptr), size, pool); + return ret.second ? UMF_RESULT_SUCCESS : UMF_RESULT_ERROR_UNKNOWN; + } + + enum umf_result_t remove(const void *ptr, size_t size) { + std::unique_lock lock(mtx); + + map.erase(reinterpret_cast(ptr)); + + // TODO: handle removing part of the range + (void)size; + + return UMF_RESULT_SUCCESS; + } + + void *find(const void *ptr) { + std::shared_lock lock(mtx); + + auto intptr = reinterpret_cast(ptr); + auto it = map.upper_bound(intptr); + if (it == map.begin()) { + return nullptr; + } + + --it; + + auto address = it->first; + auto size = it->second.first; + auto pool = it->second.second; + + if (intptr >= address && intptr < address + size) { + return pool; + } + + return nullptr; + } + + private: + std::shared_mutex mtx; + std::map> map; +}; + +static enum umf_result_t +umfMemoryTrackerAdd(umf_memory_tracker_handle_t hTracker, void *pool, + const void *ptr, size_t size) { + return hTracker->add(pool, ptr, size); +} + +static enum umf_result_t +umfMemoryTrackerRemove(umf_memory_tracker_handle_t hTracker, const void *ptr, + size_t size) { + return hTracker->remove(ptr, size); +} + +extern "C" { + +umf_memory_tracker_handle_t umfMemoryTrackerGet(void) { + static umf_memory_tracker_t tracker; + return &tracker; +} + +void *umfMemoryTrackerGetPool(umf_memory_tracker_handle_t hTracker, + const void *ptr) { + return hTracker->find(ptr); +} + +struct umf_tracking_memory_provider_t { + umf_memory_provider_handle_t hUpstream; + umf_memory_tracker_handle_t hTracker; + umf_memory_pool_handle_t pool; +}; + +typedef struct umf_tracking_memory_provider_t umf_tracking_memory_provider_t; + +static enum umf_result_t trackingAlloc(void *hProvider, size_t size, + size_t alignment, void **ptr) { + umf_tracking_memory_provider_t *p = + (umf_tracking_memory_provider_t *)hProvider; + enum umf_result_t ret = UMF_RESULT_SUCCESS; + + if (!p->hUpstream) { + return UMF_RESULT_ERROR_INVALID_ARGUMENT; + } + + ret = umfMemoryProviderAlloc(p->hUpstream, size, alignment, ptr); + if (ret != UMF_RESULT_SUCCESS) { + return ret; + } + + ret = umfMemoryTrackerAdd(p->hTracker, p->pool, *ptr, size); + if (ret != UMF_RESULT_SUCCESS && p->hUpstream) { + if (umfMemoryProviderFree(p->hUpstream, *ptr, size)) { + // TODO: LOG + } + } + + return ret; +} + +static enum umf_result_t trackingFree(void *hProvider, void *ptr, size_t size) { + enum umf_result_t ret; + umf_tracking_memory_provider_t *p = + (umf_tracking_memory_provider_t *)hProvider; + + // umfMemoryTrackerRemove should be called before umfMemoryProviderFree + // to avoid a race condition. If the order would be different, other thread + // could allocate the memory at address `ptr` before a call to umfMemoryTrackerRemove + // resulting in inconsistent state. + ret = umfMemoryTrackerRemove(p->hTracker, ptr, size); + if (ret != UMF_RESULT_SUCCESS) { + return ret; + } + + ret = umfMemoryProviderFree(p->hUpstream, ptr, size); + if (ret != UMF_RESULT_SUCCESS) { + if (umfMemoryTrackerAdd(p->hTracker, p->pool, ptr, size) != + UMF_RESULT_SUCCESS) { + // TODO: LOG + } + return ret; + } + + return ret; +} + +static enum umf_result_t trackingInitialize(void *params, void **ret) { + umf_tracking_memory_provider_t *provider = + (umf_tracking_memory_provider_t *)malloc( + sizeof(umf_tracking_memory_provider_t)); + if (!provider) { + return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; + } + + *provider = *((umf_tracking_memory_provider_t *)params); + *ret = provider; + return UMF_RESULT_SUCCESS; +} + +static void trackingFinalize(void *provider) { free(provider); } + +static void trackingGetLastError(void *provider, const char **msg, + int32_t *pError) { + umf_tracking_memory_provider_t *p = + (umf_tracking_memory_provider_t *)provider; + umfMemoryProviderGetLastNativeError(p->hUpstream, msg, pError); +} + +static enum umf_result_t +trackingGetRecommendedPageSize(void *provider, size_t size, size_t *pageSize) { + umf_tracking_memory_provider_t *p = + (umf_tracking_memory_provider_t *)provider; + return umfMemoryProviderGetRecommendedPageSize(p->hUpstream, size, + pageSize); +} + +static enum umf_result_t trackingGetMinPageSize(void *provider, void *ptr, + size_t *pageSize) { + umf_tracking_memory_provider_t *p = + (umf_tracking_memory_provider_t *)provider; + return umfMemoryProviderGetMinPageSize(p->hUpstream, ptr, pageSize); +} + +static enum umf_result_t trackingPurgeLazy(void *provider, void *ptr, + size_t size) { + umf_tracking_memory_provider_t *p = + (umf_tracking_memory_provider_t *)provider; + return umfMemoryProviderPurgeLazy(p->hUpstream, ptr, size); +} + +static enum umf_result_t trackingPurgeForce(void *provider, void *ptr, + size_t size) { + umf_tracking_memory_provider_t *p = + (umf_tracking_memory_provider_t *)provider; + return umfMemoryProviderPurgeForce(p->hUpstream, ptr, size); +} + +static const char *trackingName(void *provider) { + umf_tracking_memory_provider_t *p = + (umf_tracking_memory_provider_t *)provider; + return umfMemoryProviderGetName(p->hUpstream); +} + +enum umf_result_t umfTrackingMemoryProviderCreate( + umf_memory_provider_handle_t hUpstream, umf_memory_pool_handle_t hPool, + umf_memory_provider_handle_t *hTrackingProvider) { + umf_tracking_memory_provider_t params; + params.hUpstream = hUpstream; + params.hTracker = umfMemoryTrackerGet(); + params.pool = hPool; + + struct umf_memory_provider_ops_t trackingMemoryProviderOps; + trackingMemoryProviderOps.version = UMF_VERSION_CURRENT; + trackingMemoryProviderOps.initialize = trackingInitialize; + trackingMemoryProviderOps.finalize = trackingFinalize; + trackingMemoryProviderOps.alloc = trackingAlloc; + trackingMemoryProviderOps.free = trackingFree; + trackingMemoryProviderOps.get_last_native_error = trackingGetLastError; + trackingMemoryProviderOps.get_min_page_size = trackingGetMinPageSize; + trackingMemoryProviderOps.get_recommended_page_size = + trackingGetRecommendedPageSize; + trackingMemoryProviderOps.purge_force = trackingPurgeForce; + trackingMemoryProviderOps.purge_lazy = trackingPurgeLazy; + trackingMemoryProviderOps.get_name = trackingName; + + return umfMemoryProviderCreate(&trackingMemoryProviderOps, ¶ms, + hTrackingProvider); +} + +void umfTrackingMemoryProviderGetUpstreamProvider( + umf_memory_provider_handle_t hTrackingProvider, + umf_memory_provider_handle_t *hUpstream) { + assert(hUpstream); + umf_tracking_memory_provider_t *p = + (umf_tracking_memory_provider_t *)hTrackingProvider; + *hUpstream = p->hUpstream; +} +} diff --git a/source/common/unified_malloc_framework/src/memory_tracker.h b/source/common/unified_malloc_framework/src/memory_tracker.h new file mode 100644 index 0000000000..c6e620bf66 --- /dev/null +++ b/source/common/unified_malloc_framework/src/memory_tracker.h @@ -0,0 +1,42 @@ +/* + * + * Copyright (C) 2023 Intel Corporation + * + * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. + * See LICENSE.TXT + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + */ + +#ifndef UMF_MEMORY_TRACKER_INTERNAL_H +#define UMF_MEMORY_TRACKER_INTERNAL_H 1 + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct umf_memory_tracker_t *umf_memory_tracker_handle_t; + +umf_memory_tracker_handle_t umfMemoryTrackerGet(void); +void *umfMemoryTrackerGetPool(umf_memory_tracker_handle_t hTracker, + const void *ptr); + +// Creates a memory provider that tracks each allocation/deallocation through umf_memory_tracker_handle_t and +// forwards all requests to hUpstream memory Provider. hUpstream liftime should be managed by the user of this function. +enum umf_result_t umfTrackingMemoryProviderCreate( + umf_memory_provider_handle_t hUpstream, umf_memory_pool_handle_t hPool, + umf_memory_provider_handle_t *hTrackingProvider); + +void umfTrackingMemoryProviderGetUpstreamProvider( + umf_memory_provider_handle_t hTrackingProvider, + umf_memory_provider_handle_t *hUpstream); + +#ifdef __cplusplus +} +#endif + +#endif /* UMF_MEMORY_TRACKER_INTERNAL_H */ diff --git a/source/common/unified_memory_allocation/include/uma/base.h b/source/common/unified_memory_allocation/include/uma/base.h deleted file mode 100644 index bc00e2db3a..0000000000 --- a/source/common/unified_memory_allocation/include/uma/base.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * - * Copyright (C) 2023 Intel Corporation - * - * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. - * See LICENSE.TXT - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - */ - -#ifndef UMA_BASE_H -#define UMA_BASE_H 1 - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/// \brief Generates generic 'UMA' API versions -#define UMA_MAKE_VERSION(_major, _minor) \ - ((_major << 16) | (_minor & 0x0000ffff)) - -/// \brief Extracts 'UMA' API major version -#define UMA_MAJOR_VERSION(_ver) (_ver >> 16) - -/// \brief Extracts 'UMA' API minor version -#define UMA_MINOR_VERSION(_ver) (_ver & 0x0000ffff) - -/// \brief Current version of the UMA headers -#define UMA_VERSION_CURRENT UMA_MAKE_VERSION(0, 9) - -/// \brief Operation results -enum uma_result_t { - UMA_RESULT_SUCCESS = 0, ///< Success - UMA_RESULT_ERROR_OUT_OF_HOST_MEMORY = - 1, ///< Insufficient host memory to satisfy call, - UMA_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC = - 2, ///< A provider specific warning/error has been reported and can be - ///< Retrieved via the umaMemoryProviderGetLastNativeError entry point. - UMA_RESULT_ERROR_INVALID_ARGUMENT = - 3, ///< Generic error code for invalid arguments - UMA_RESULT_ERROR_INVALID_ALIGNMENT = 4, /// Invalid alignment of an argument - UMA_RESULT_ERROR_NOT_SUPPORTED = 5, /// Operation not supported - - UMA_RESULT_ERROR_UNKNOWN = 0x7ffffffe ///< Unknown or internal error -}; - -#ifdef __cplusplus -} -#endif - -#endif /* UMA_BASE_H */ diff --git a/source/common/unified_memory_allocation/src/memory_tracker.cpp b/source/common/unified_memory_allocation/src/memory_tracker.cpp deleted file mode 100644 index 32f7dff0b1..0000000000 --- a/source/common/unified_memory_allocation/src/memory_tracker.cpp +++ /dev/null @@ -1,247 +0,0 @@ -/* - * - * Copyright (C) 2023 Intel Corporation - * - * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. - * See LICENSE.TXT - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - */ - -#include "memory_tracker.h" -#include -#include - -#include -#include -#include -#include -#include - -// TODO: reimplement in C and optimize... -struct uma_memory_tracker_t { - enum uma_result_t add(void *pool, const void *ptr, size_t size) { - std::unique_lock lock(mtx); - - if (size == 0) { - return UMA_RESULT_SUCCESS; - } - - auto ret = - map.try_emplace(reinterpret_cast(ptr), size, pool); - return ret.second ? UMA_RESULT_SUCCESS : UMA_RESULT_ERROR_UNKNOWN; - } - - enum uma_result_t remove(const void *ptr, size_t size) { - std::unique_lock lock(mtx); - - map.erase(reinterpret_cast(ptr)); - - // TODO: handle removing part of the range - (void)size; - - return UMA_RESULT_SUCCESS; - } - - void *find(const void *ptr) { - std::shared_lock lock(mtx); - - auto intptr = reinterpret_cast(ptr); - auto it = map.upper_bound(intptr); - if (it == map.begin()) { - return nullptr; - } - - --it; - - auto address = it->first; - auto size = it->second.first; - auto pool = it->second.second; - - if (intptr >= address && intptr < address + size) { - return pool; - } - - return nullptr; - } - - private: - std::shared_mutex mtx; - std::map> map; -}; - -static enum uma_result_t -umaMemoryTrackerAdd(uma_memory_tracker_handle_t hTracker, void *pool, - const void *ptr, size_t size) { - return hTracker->add(pool, ptr, size); -} - -static enum uma_result_t -umaMemoryTrackerRemove(uma_memory_tracker_handle_t hTracker, const void *ptr, - size_t size) { - return hTracker->remove(ptr, size); -} - -extern "C" { - -uma_memory_tracker_handle_t umaMemoryTrackerGet(void) { - static uma_memory_tracker_t tracker; - return &tracker; -} - -void *umaMemoryTrackerGetPool(uma_memory_tracker_handle_t hTracker, - const void *ptr) { - return hTracker->find(ptr); -} - -struct uma_tracking_memory_provider_t { - uma_memory_provider_handle_t hUpstream; - uma_memory_tracker_handle_t hTracker; - uma_memory_pool_handle_t pool; -}; - -typedef struct uma_tracking_memory_provider_t uma_tracking_memory_provider_t; - -static enum uma_result_t trackingAlloc(void *hProvider, size_t size, - size_t alignment, void **ptr) { - uma_tracking_memory_provider_t *p = - (uma_tracking_memory_provider_t *)hProvider; - enum uma_result_t ret = UMA_RESULT_SUCCESS; - - if (!p->hUpstream) { - return UMA_RESULT_ERROR_INVALID_ARGUMENT; - } - - ret = umaMemoryProviderAlloc(p->hUpstream, size, alignment, ptr); - if (ret != UMA_RESULT_SUCCESS) { - return ret; - } - - ret = umaMemoryTrackerAdd(p->hTracker, p->pool, *ptr, size); - if (ret != UMA_RESULT_SUCCESS && p->hUpstream) { - if (umaMemoryProviderFree(p->hUpstream, *ptr, size)) { - // TODO: LOG - } - } - - return ret; -} - -static enum uma_result_t trackingFree(void *hProvider, void *ptr, size_t size) { - enum uma_result_t ret; - uma_tracking_memory_provider_t *p = - (uma_tracking_memory_provider_t *)hProvider; - - // umaMemoryTrackerRemove should be called before umaMemoryProviderFree - // to avoid a race condition. If the order would be different, other thread - // could allocate the memory at address `ptr` before a call to umaMemoryTrackerRemove - // resulting in inconsistent state. - ret = umaMemoryTrackerRemove(p->hTracker, ptr, size); - if (ret != UMA_RESULT_SUCCESS) { - return ret; - } - - ret = umaMemoryProviderFree(p->hUpstream, ptr, size); - if (ret != UMA_RESULT_SUCCESS) { - if (umaMemoryTrackerAdd(p->hTracker, p->pool, ptr, size) != - UMA_RESULT_SUCCESS) { - // TODO: LOG - } - return ret; - } - - return ret; -} - -static enum uma_result_t trackingInitialize(void *params, void **ret) { - uma_tracking_memory_provider_t *provider = - (uma_tracking_memory_provider_t *)malloc( - sizeof(uma_tracking_memory_provider_t)); - if (!provider) { - return UMA_RESULT_ERROR_OUT_OF_HOST_MEMORY; - } - - *provider = *((uma_tracking_memory_provider_t *)params); - *ret = provider; - return UMA_RESULT_SUCCESS; -} - -static void trackingFinalize(void *provider) { free(provider); } - -static void trackingGetLastError(void *provider, const char **msg, - int32_t *pError) { - uma_tracking_memory_provider_t *p = - (uma_tracking_memory_provider_t *)provider; - umaMemoryProviderGetLastNativeError(p->hUpstream, msg, pError); -} - -static enum uma_result_t -trackingGetRecommendedPageSize(void *provider, size_t size, size_t *pageSize) { - uma_tracking_memory_provider_t *p = - (uma_tracking_memory_provider_t *)provider; - return umaMemoryProviderGetRecommendedPageSize(p->hUpstream, size, - pageSize); -} - -static enum uma_result_t trackingGetMinPageSize(void *provider, void *ptr, - size_t *pageSize) { - uma_tracking_memory_provider_t *p = - (uma_tracking_memory_provider_t *)provider; - return umaMemoryProviderGetMinPageSize(p->hUpstream, ptr, pageSize); -} - -static enum uma_result_t trackingPurgeLazy(void *provider, void *ptr, - size_t size) { - uma_tracking_memory_provider_t *p = - (uma_tracking_memory_provider_t *)provider; - return umaMemoryProviderPurgeLazy(p->hUpstream, ptr, size); -} - -static enum uma_result_t trackingPurgeForce(void *provider, void *ptr, - size_t size) { - uma_tracking_memory_provider_t *p = - (uma_tracking_memory_provider_t *)provider; - return umaMemoryProviderPurgeForce(p->hUpstream, ptr, size); -} - -static const char *trackingName(void *provider) { - uma_tracking_memory_provider_t *p = - (uma_tracking_memory_provider_t *)provider; - return umaMemoryProviderGetName(p->hUpstream); -} - -enum uma_result_t umaTrackingMemoryProviderCreate( - uma_memory_provider_handle_t hUpstream, uma_memory_pool_handle_t hPool, - uma_memory_provider_handle_t *hTrackingProvider) { - uma_tracking_memory_provider_t params; - params.hUpstream = hUpstream; - params.hTracker = umaMemoryTrackerGet(); - params.pool = hPool; - - struct uma_memory_provider_ops_t trackingMemoryProviderOps; - trackingMemoryProviderOps.version = UMA_VERSION_CURRENT; - trackingMemoryProviderOps.initialize = trackingInitialize; - trackingMemoryProviderOps.finalize = trackingFinalize; - trackingMemoryProviderOps.alloc = trackingAlloc; - trackingMemoryProviderOps.free = trackingFree; - trackingMemoryProviderOps.get_last_native_error = trackingGetLastError; - trackingMemoryProviderOps.get_min_page_size = trackingGetMinPageSize; - trackingMemoryProviderOps.get_recommended_page_size = - trackingGetRecommendedPageSize; - trackingMemoryProviderOps.purge_force = trackingPurgeForce; - trackingMemoryProviderOps.purge_lazy = trackingPurgeLazy; - trackingMemoryProviderOps.get_name = trackingName; - - return umaMemoryProviderCreate(&trackingMemoryProviderOps, ¶ms, - hTrackingProvider); -} - -void umaTrackingMemoryProviderGetUpstreamProvider( - uma_memory_provider_handle_t hTrackingProvider, - uma_memory_provider_handle_t *hUpstream) { - assert(hUpstream); - uma_tracking_memory_provider_t *p = - (uma_tracking_memory_provider_t *)hTrackingProvider; - *hUpstream = p->hUpstream; -} -} diff --git a/source/common/unified_memory_allocation/src/memory_tracker.h b/source/common/unified_memory_allocation/src/memory_tracker.h deleted file mode 100644 index 055942174f..0000000000 --- a/source/common/unified_memory_allocation/src/memory_tracker.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * Copyright (C) 2023 Intel Corporation - * - * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. - * See LICENSE.TXT - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - */ - -#ifndef UMA_MEMORY_TRACKER_INTERNAL_H -#define UMA_MEMORY_TRACKER_INTERNAL_H 1 - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct uma_memory_tracker_t *uma_memory_tracker_handle_t; - -uma_memory_tracker_handle_t umaMemoryTrackerGet(void); -void *umaMemoryTrackerGetPool(uma_memory_tracker_handle_t hTracker, - const void *ptr); - -// Creates a memory provider that tracks each allocation/deallocation through uma_memory_tracker_handle_t and -// forwards all requests to hUpstream memory Provider. hUpstream liftime should be managed by the user of this function. -enum uma_result_t umaTrackingMemoryProviderCreate( - uma_memory_provider_handle_t hUpstream, uma_memory_pool_handle_t hPool, - uma_memory_provider_handle_t *hTrackingProvider); - -void umaTrackingMemoryProviderGetUpstreamProvider( - uma_memory_provider_handle_t hTrackingProvider, - uma_memory_provider_handle_t *hUpstream); - -#ifdef __cplusplus -} -#endif - -#endif /* UMA_MEMORY_TRACKER_INTERNAL_H */ diff --git a/source/common/ur_pool_manager.hpp b/source/common/ur_pool_manager.hpp index c4cb169fbd..c4da5d149f 100644 --- a/source/common/ur_pool_manager.hpp +++ b/source/common/ur_pool_manager.hpp @@ -128,7 +128,7 @@ inline bool pool_descriptor::equal(const pool_descriptor &lhs, // We want to share a memory pool for sub-devices and sub-sub devices. // Sub-devices and sub-sub-devices might be represented by different ur_device_handle_t but - // they share the same native_handle_t (which is used by UMA provider). + // they share the same native_handle_t (which is used by UMF provider). // Ref: https://github.com/intel/llvm/commit/86511c5dc84b5781dcfd828caadcb5cac157eae1 // TODO: is this L0 specific? auto ret = urDeviceGetNativeHandle(lhs.hDevice, &lhsNative); diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 79265fe742..79ca48236c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -17,7 +17,7 @@ enable_testing() add_subdirectory(python) add_subdirectory(loader) add_subdirectory(conformance) -add_subdirectory(unified_memory_allocation) +add_subdirectory(unified_malloc_framework) add_subdirectory(usm) add_subdirectory(layers) add_subdirectory(unit) diff --git a/test/unified_malloc_framework/CMakeLists.txt b/test/unified_malloc_framework/CMakeLists.txt new file mode 100644 index 0000000000..7636c5d26f --- /dev/null +++ b/test/unified_malloc_framework/CMakeLists.txt @@ -0,0 +1,37 @@ +# Copyright (C) 2022-2023 Intel Corporation +# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +# See LICENSE.TXT +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +set(UR_UMF_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + +add_library(umf_test_helpers STATIC + ${UR_UMF_TEST_DIR}/common/pool.c + ${UR_UMF_TEST_DIR}/common/provider.c +) + +target_link_libraries(umf_test_helpers PRIVATE ${PROJECT_NAME}::common) + +function(add_umf_test name) + set(TEST_TARGET_NAME umf_test-${name}) + add_executable(${TEST_TARGET_NAME} + ${ARGN}) + target_link_libraries(${TEST_TARGET_NAME} + PRIVATE + ${PROJECT_NAME}::unified_malloc_framework + ${PROJECT_NAME}::common + umf_test_helpers + GTest::gtest_main) + target_include_directories(${TEST_TARGET_NAME} PRIVATE + ${UR_UMF_TEST_DIR}/common) + add_test(NAME umf-${name} + COMMAND ${TEST_TARGET_NAME} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + set_tests_properties(umf-${name} PROPERTIES LABELS "umf") +endfunction() + +add_subdirectory(umf_pools) + +add_umf_test(memoryProvider memoryProviderAPI.cpp) +add_umf_test(memoryPool memoryPoolAPI.cpp) +add_umf_test(base base.cpp) diff --git a/test/unified_memory_allocation/base.cpp b/test/unified_malloc_framework/base.cpp similarity index 60% rename from test/unified_memory_allocation/base.cpp rename to test/unified_malloc_framework/base.cpp index 49ff6b425d..c9f6211f66 100644 --- a/test/unified_memory_allocation/base.cpp +++ b/test/unified_malloc_framework/base.cpp @@ -5,12 +5,12 @@ #include "base.hpp" -#include +#include -using uma_test::test; +using umf_test::test; TEST_F(test, versionEncodeDecode) { - auto encoded = UMA_MAKE_VERSION(0, 9); - ASSERT_EQ(UMA_MAJOR_VERSION(encoded), 0); - ASSERT_EQ(UMA_MINOR_VERSION(encoded), 9); + auto encoded = UMF_MAKE_VERSION(0, 9); + ASSERT_EQ(UMF_MAJOR_VERSION(encoded), 0); + ASSERT_EQ(UMF_MINOR_VERSION(encoded), 9); } diff --git a/test/unified_memory_allocation/common/base.hpp b/test/unified_malloc_framework/common/base.hpp similarity index 90% rename from test/unified_memory_allocation/common/base.hpp rename to test/unified_malloc_framework/common/base.hpp index d454b3822d..c4d6ccd129 100644 --- a/test/unified_memory_allocation/common/base.hpp +++ b/test/unified_malloc_framework/common/base.hpp @@ -8,12 +8,12 @@ * */ -#ifndef UMA_TEST_BASE_HPP -#define UMA_TEST_BASE_HPP 1 +#ifndef UMF_TEST_BASE_HPP +#define UMF_TEST_BASE_HPP 1 #include -namespace uma_test { +namespace umf_test { #define NOEXCEPT_COND(cond, val, expected_val) \ try { \ @@ -32,6 +32,6 @@ struct test : ::testing::Test { void SetUp() override { ::testing::Test::SetUp(); } void TearDown() override { ::testing::Test::TearDown(); } }; -} // namespace uma_test +} // namespace umf_test -#endif /* UMA_TEST_BASE_HPP */ +#endif /* UMF_TEST_BASE_HPP */ diff --git a/test/unified_memory_allocation/common/pool.c b/test/unified_malloc_framework/common/pool.c similarity index 71% rename from test/unified_memory_allocation/common/pool.c rename to test/unified_malloc_framework/common/pool.c index 200ed75dff..63c8a0c95f 100644 --- a/test/unified_memory_allocation/common/pool.c +++ b/test/unified_malloc_framework/common/pool.c @@ -6,12 +6,12 @@ #include "pool.h" #include "provider.h" -#include +#include #include #include -static enum uma_result_t nullInitialize(uma_memory_provider_handle_t *providers, +static enum umf_result_t nullInitialize(umf_memory_provider_handle_t *providers, size_t numProviders, void *params, void **pool) { (void)providers; @@ -19,7 +19,7 @@ static enum uma_result_t nullInitialize(uma_memory_provider_handle_t *providers, (void)params; assert(providers && numProviders); *pool = NULL; - return UMA_RESULT_SUCCESS; + return UMF_RESULT_SUCCESS; } static void nullFinalize(void *pool) { (void)pool; } @@ -62,14 +62,14 @@ static void nullFree(void *pool, void *ptr) { (void)ptr; } -enum uma_result_t nullGetLastStatus(void *pool) { +enum umf_result_t nullGetLastStatus(void *pool) { (void)pool; - return UMA_RESULT_SUCCESS; + return UMF_RESULT_SUCCESS; } -uma_memory_pool_handle_t nullPoolCreate(void) { - struct uma_memory_pool_ops_t ops = { - .version = UMA_VERSION_CURRENT, +umf_memory_pool_handle_t nullPoolCreate(void) { + struct umf_memory_pool_ops_t ops = { + .version = UMF_VERSION_CURRENT, .initialize = nullInitialize, .finalize = nullFinalize, .malloc = nullMalloc, @@ -80,17 +80,17 @@ uma_memory_pool_handle_t nullPoolCreate(void) { .free = nullFree, .get_last_allocation_error = nullGetLastStatus}; - uma_memory_provider_handle_t providerDesc = nullProviderCreate(); - uma_memory_pool_handle_t hPool; - enum uma_result_t ret = umaPoolCreate(&ops, &providerDesc, 1, NULL, &hPool); + umf_memory_provider_handle_t providerDesc = nullProviderCreate(); + umf_memory_pool_handle_t hPool; + enum umf_result_t ret = umfPoolCreate(&ops, &providerDesc, 1, NULL, &hPool); (void)ret; /* silence unused variable warning */ - assert(ret == UMA_RESULT_SUCCESS); + assert(ret == UMF_RESULT_SUCCESS); return hPool; } struct traceParams { - uma_memory_pool_handle_t hUpstreamPool; + umf_memory_pool_handle_t hUpstreamPool; void (*trace)(const char *); }; @@ -98,8 +98,8 @@ struct tracePool { struct traceParams params; }; -static enum uma_result_t -traceInitialize(uma_memory_provider_handle_t *providers, size_t numProviders, +static enum umf_result_t +traceInitialize(umf_memory_provider_handle_t *providers, size_t numProviders, void *params, void **pool) { struct tracePool *tracePool = (struct tracePool *)malloc(sizeof(struct tracePool)); @@ -110,7 +110,7 @@ traceInitialize(uma_memory_provider_handle_t *providers, size_t numProviders, assert(providers && numProviders); *pool = tracePool; - return UMA_RESULT_SUCCESS; + return UMF_RESULT_SUCCESS; } static void traceFinalize(void *pool) { free(pool); } @@ -119,28 +119,28 @@ static void *traceMalloc(void *pool, size_t size) { struct tracePool *tracePool = (struct tracePool *)pool; tracePool->params.trace("malloc"); - return umaPoolMalloc(tracePool->params.hUpstreamPool, size); + return umfPoolMalloc(tracePool->params.hUpstreamPool, size); } static void *traceCalloc(void *pool, size_t num, size_t size) { struct tracePool *tracePool = (struct tracePool *)pool; tracePool->params.trace("calloc"); - return umaPoolCalloc(tracePool->params.hUpstreamPool, num, size); + return umfPoolCalloc(tracePool->params.hUpstreamPool, num, size); } static void *traceRealloc(void *pool, void *ptr, size_t size) { struct tracePool *tracePool = (struct tracePool *)pool; tracePool->params.trace("realloc"); - return umaPoolRealloc(tracePool->params.hUpstreamPool, ptr, size); + return umfPoolRealloc(tracePool->params.hUpstreamPool, ptr, size); } static void *traceAlignedMalloc(void *pool, size_t size, size_t alignment) { struct tracePool *tracePool = (struct tracePool *)pool; tracePool->params.trace("aligned_malloc"); - return umaPoolAlignedMalloc(tracePool->params.hUpstreamPool, size, + return umfPoolAlignedMalloc(tracePool->params.hUpstreamPool, size, alignment); } @@ -148,29 +148,29 @@ static size_t traceMallocUsableSize(void *pool, void *ptr) { struct tracePool *tracePool = (struct tracePool *)pool; tracePool->params.trace("malloc_usable_size"); - return umaPoolMallocUsableSize(tracePool->params.hUpstreamPool, ptr); + return umfPoolMallocUsableSize(tracePool->params.hUpstreamPool, ptr); } static void traceFree(void *pool, void *ptr) { struct tracePool *tracePool = (struct tracePool *)pool; tracePool->params.trace("free"); - umaPoolFree(tracePool->params.hUpstreamPool, ptr); + umfPoolFree(tracePool->params.hUpstreamPool, ptr); } -enum uma_result_t traceGetLastStatus(void *pool) { +enum umf_result_t traceGetLastStatus(void *pool) { struct tracePool *tracePool = (struct tracePool *)pool; tracePool->params.trace("get_last_native_error"); - return umaPoolGetLastAllocationError(tracePool->params.hUpstreamPool); + return umfPoolGetLastAllocationError(tracePool->params.hUpstreamPool); } -uma_memory_pool_handle_t -tracePoolCreate(uma_memory_pool_handle_t hUpstreamPool, - uma_memory_provider_handle_t providerDesc, +umf_memory_pool_handle_t +tracePoolCreate(umf_memory_pool_handle_t hUpstreamPool, + umf_memory_provider_handle_t providerDesc, void (*trace)(const char *)) { - struct uma_memory_pool_ops_t ops = { - .version = UMA_VERSION_CURRENT, + struct umf_memory_pool_ops_t ops = { + .version = UMF_VERSION_CURRENT, .initialize = traceInitialize, .finalize = traceFinalize, .malloc = traceMalloc, @@ -184,11 +184,11 @@ tracePoolCreate(uma_memory_pool_handle_t hUpstreamPool, struct traceParams params = {.hUpstreamPool = hUpstreamPool, .trace = trace}; - uma_memory_pool_handle_t hPool; - enum uma_result_t ret = - umaPoolCreate(&ops, &providerDesc, 1, ¶ms, &hPool); + umf_memory_pool_handle_t hPool; + enum umf_result_t ret = + umfPoolCreate(&ops, &providerDesc, 1, ¶ms, &hPool); (void)ret; /* silence unused variable warning */ - assert(ret == UMA_RESULT_SUCCESS); + assert(ret == UMF_RESULT_SUCCESS); return hPool; } diff --git a/test/unified_memory_allocation/common/pool.h b/test/unified_malloc_framework/common/pool.h similarity index 53% rename from test/unified_memory_allocation/common/pool.h rename to test/unified_malloc_framework/common/pool.h index d9719ad458..69d4711e3e 100644 --- a/test/unified_memory_allocation/common/pool.h +++ b/test/unified_malloc_framework/common/pool.h @@ -3,23 +3,23 @@ // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#ifndef UR_UMA_TEST_POOL_H -#define UR_UMA_TEST_POOL_H +#ifndef UR_UMF_TEST_POOL_H +#define UR_UMF_TEST_POOL_H -#include +#include #if defined(__cplusplus) extern "C" { #endif -uma_memory_pool_handle_t nullPoolCreate(void); -uma_memory_pool_handle_t -tracePoolCreate(uma_memory_pool_handle_t hUpstreamPool, - uma_memory_provider_handle_t providerDesc, +umf_memory_pool_handle_t nullPoolCreate(void); +umf_memory_pool_handle_t +tracePoolCreate(umf_memory_pool_handle_t hUpstreamPool, + umf_memory_provider_handle_t providerDesc, void (*trace)(const char *)); #if defined(__cplusplus) } #endif -#endif // UR_UMA_TEST_POOL_H +#endif // UR_UMF_TEST_POOL_H diff --git a/test/unified_memory_allocation/common/pool.hpp b/test/unified_malloc_framework/common/pool.hpp similarity index 69% rename from test/unified_memory_allocation/common/pool.hpp rename to test/unified_malloc_framework/common/pool.hpp index 6e1552140d..7ec62b8741 100644 --- a/test/unified_memory_allocation/common/pool.hpp +++ b/test/unified_malloc_framework/common/pool.hpp @@ -8,28 +8,28 @@ * */ -#ifndef UMA_TEST_POOL_HPP -#define UMA_TEST_POOL_HPP 1 +#ifndef UMF_TEST_POOL_HPP +#define UMF_TEST_POOL_HPP 1 #include -#include -#include +#include +#include #include #include #include "base.hpp" -#include "uma_helpers.hpp" +#include "umf_helpers.hpp" -namespace uma_test { +namespace umf_test { -auto wrapPoolUnique(uma_memory_pool_handle_t hPool) { - return uma::pool_unique_handle_t(hPool, &umaPoolDestroy); +auto wrapPoolUnique(umf_memory_pool_handle_t hPool) { + return umf::pool_unique_handle_t(hPool, &umfPoolDestroy); } struct pool_base { - uma_result_t initialize(uma_memory_provider_handle_t *, size_t) noexcept { - return UMA_RESULT_SUCCESS; + umf_result_t initialize(umf_memory_provider_handle_t *, size_t) noexcept { + return UMF_RESULT_SUCCESS; }; void *malloc(size_t size) noexcept { return nullptr; } void *calloc(size_t, size_t) noexcept { return nullptr; } @@ -37,8 +37,8 @@ struct pool_base { void *aligned_malloc(size_t, size_t) noexcept { return nullptr; } size_t malloc_usable_size(void *) noexcept { return 0; } void free(void *) noexcept {} - enum uma_result_t get_last_allocation_error() noexcept { - return UMA_RESULT_SUCCESS; + enum umf_result_t get_last_allocation_error() noexcept { + return UMF_RESULT_SUCCESS; } }; @@ -69,20 +69,20 @@ struct malloc_pool : public pool_base { }; struct proxy_pool : public pool_base { - uma_result_t initialize(uma_memory_provider_handle_t *providers, + umf_result_t initialize(umf_memory_provider_handle_t *providers, size_t numProviders) noexcept { this->provider = providers[0]; - return UMA_RESULT_SUCCESS; + return UMF_RESULT_SUCCESS; } void *malloc(size_t size) noexcept { return aligned_malloc(size, 0); } void *calloc(size_t num, size_t size) noexcept { void *ptr; - auto ret = umaMemoryProviderAlloc(provider, num * size, 0, &ptr); + auto ret = umfMemoryProviderAlloc(provider, num * size, 0, &ptr); memset(ptr, 0, num * size); if (ptr) { - EXPECT_EQ_NOEXCEPT(ret, UMA_RESULT_SUCCESS); + EXPECT_EQ_NOEXCEPT(ret, UMF_RESULT_SUCCESS); } return ptr; } @@ -92,9 +92,9 @@ struct proxy_pool : public pool_base { } void *aligned_malloc(size_t size, size_t alignment) noexcept { void *ptr; - auto ret = umaMemoryProviderAlloc(provider, size, alignment, &ptr); + auto ret = umfMemoryProviderAlloc(provider, size, alignment, &ptr); if (ptr) { - EXPECT_EQ_NOEXCEPT(ret, UMA_RESULT_SUCCESS); + EXPECT_EQ_NOEXCEPT(ret, UMF_RESULT_SUCCESS); } return ptr; } @@ -103,12 +103,12 @@ struct proxy_pool : public pool_base { return 0; } void free(void *ptr) noexcept { - auto ret = umaMemoryProviderFree(provider, ptr, 0); - EXPECT_EQ_NOEXCEPT(ret, UMA_RESULT_SUCCESS); + auto ret = umfMemoryProviderFree(provider, ptr, 0); + EXPECT_EQ_NOEXCEPT(ret, UMF_RESULT_SUCCESS); } - uma_memory_provider_handle_t provider; + umf_memory_provider_handle_t provider; }; -} // namespace uma_test +} // namespace umf_test -#endif /* UMA_TEST_POOL_HPP */ +#endif /* UMF_TEST_POOL_HPP */ diff --git a/test/unified_memory_allocation/common/provider.c b/test/unified_malloc_framework/common/provider.c similarity index 66% rename from test/unified_memory_allocation/common/provider.c rename to test/unified_malloc_framework/common/provider.c index a180705a58..8f9e946bfc 100644 --- a/test/unified_memory_allocation/common/provider.c +++ b/test/unified_malloc_framework/common/provider.c @@ -5,33 +5,33 @@ #include "provider.h" -#include +#include #include #include -static enum uma_result_t nullInitialize(void *params, void **pool) { +static enum umf_result_t nullInitialize(void *params, void **pool) { (void)params; *pool = NULL; - return UMA_RESULT_SUCCESS; + return UMF_RESULT_SUCCESS; } static void nullFinalize(void *pool) { (void)pool; } -static enum uma_result_t nullAlloc(void *provider, size_t size, +static enum umf_result_t nullAlloc(void *provider, size_t size, size_t alignment, void **ptr) { (void)provider; (void)size; (void)alignment; (void)ptr; - return UMA_RESULT_SUCCESS; + return UMF_RESULT_SUCCESS; } -static enum uma_result_t nullFree(void *provider, void *ptr, size_t size) { +static enum umf_result_t nullFree(void *provider, void *ptr, size_t size) { (void)provider; (void)ptr; (void)size; - return UMA_RESULT_SUCCESS; + return UMF_RESULT_SUCCESS; } static void nullGetLastError(void *provider, const char **ppMsg, @@ -41,36 +41,36 @@ static void nullGetLastError(void *provider, const char **ppMsg, (void)pError; } -static enum uma_result_t nullGetRecommendedPageSize(void *provider, size_t size, +static enum umf_result_t nullGetRecommendedPageSize(void *provider, size_t size, size_t *pageSize) { (void)provider; (void)size; (void)pageSize; - return UMA_RESULT_SUCCESS; + return UMF_RESULT_SUCCESS; } -static enum uma_result_t nullGetPageSize(void *provider, void *ptr, +static enum umf_result_t nullGetPageSize(void *provider, void *ptr, size_t *pageSize) { (void)provider; (void)ptr; (void)pageSize; - return UMA_RESULT_SUCCESS; + return UMF_RESULT_SUCCESS; } -static enum uma_result_t nullPurgeLazy(void *provider, void *ptr, size_t size) { +static enum umf_result_t nullPurgeLazy(void *provider, void *ptr, size_t size) { (void)provider; (void)ptr; (void)size; - return UMA_RESULT_SUCCESS; + return UMF_RESULT_SUCCESS; } -static enum uma_result_t nullPurgeForce(void *provider, void *ptr, +static enum umf_result_t nullPurgeForce(void *provider, void *ptr, size_t size) { (void)provider; (void)ptr; (void)size; - return UMA_RESULT_SUCCESS; + return UMF_RESULT_SUCCESS; } static const char *nullName(void *provider) { @@ -78,9 +78,9 @@ static const char *nullName(void *provider) { return "null"; } -uma_memory_provider_handle_t nullProviderCreate(void) { - struct uma_memory_provider_ops_t ops = { - .version = UMA_VERSION_CURRENT, +umf_memory_provider_handle_t nullProviderCreate(void) { + struct umf_memory_provider_ops_t ops = { + .version = UMF_VERSION_CURRENT, .initialize = nullInitialize, .finalize = nullFinalize, .alloc = nullAlloc, @@ -92,44 +92,44 @@ uma_memory_provider_handle_t nullProviderCreate(void) { .purge_force = nullPurgeForce, .get_name = nullName}; - uma_memory_provider_handle_t hProvider; - enum uma_result_t ret = umaMemoryProviderCreate(&ops, NULL, &hProvider); + umf_memory_provider_handle_t hProvider; + enum umf_result_t ret = umfMemoryProviderCreate(&ops, NULL, &hProvider); (void)ret; /* silence unused variable warning */ - assert(ret == UMA_RESULT_SUCCESS); + assert(ret == UMF_RESULT_SUCCESS); return hProvider; } struct traceParams { - uma_memory_provider_handle_t hUpstreamProvider; + umf_memory_provider_handle_t hUpstreamProvider; void (*trace)(const char *); }; -static enum uma_result_t traceInitialize(void *params, void **pool) { +static enum umf_result_t traceInitialize(void *params, void **pool) { struct traceParams *tracePool = (struct traceParams *)malloc(sizeof(struct traceParams)); *tracePool = *((struct traceParams *)params); *pool = tracePool; - return UMA_RESULT_SUCCESS; + return UMF_RESULT_SUCCESS; } static void traceFinalize(void *pool) { free(pool); } -static enum uma_result_t traceAlloc(void *provider, size_t size, +static enum umf_result_t traceAlloc(void *provider, size_t size, size_t alignment, void **ptr) { struct traceParams *traceProvider = (struct traceParams *)provider; traceProvider->trace("alloc"); - return umaMemoryProviderAlloc(traceProvider->hUpstreamProvider, size, + return umfMemoryProviderAlloc(traceProvider->hUpstreamProvider, size, alignment, ptr); } -static enum uma_result_t traceFree(void *provider, void *ptr, size_t size) { +static enum umf_result_t traceFree(void *provider, void *ptr, size_t size) { struct traceParams *traceProvider = (struct traceParams *)provider; traceProvider->trace("free"); - return umaMemoryProviderFree(traceProvider->hUpstreamProvider, ptr, size); + return umfMemoryProviderFree(traceProvider->hUpstreamProvider, ptr, size); } static void traceGetLastError(void *provider, const char **ppMsg, @@ -137,44 +137,44 @@ static void traceGetLastError(void *provider, const char **ppMsg, struct traceParams *traceProvider = (struct traceParams *)provider; traceProvider->trace("get_last_native_error"); - umaMemoryProviderGetLastNativeError(traceProvider->hUpstreamProvider, ppMsg, + umfMemoryProviderGetLastNativeError(traceProvider->hUpstreamProvider, ppMsg, pError); } -static enum uma_result_t +static enum umf_result_t traceGetRecommendedPageSize(void *provider, size_t size, size_t *pageSize) { struct traceParams *traceProvider = (struct traceParams *)provider; traceProvider->trace("get_recommended_page_size"); - return umaMemoryProviderGetRecommendedPageSize( + return umfMemoryProviderGetRecommendedPageSize( traceProvider->hUpstreamProvider, size, pageSize); } -static enum uma_result_t traceGetPageSize(void *provider, void *ptr, +static enum umf_result_t traceGetPageSize(void *provider, void *ptr, size_t *pageSize) { struct traceParams *traceProvider = (struct traceParams *)provider; traceProvider->trace("get_min_page_size"); - return umaMemoryProviderGetMinPageSize(traceProvider->hUpstreamProvider, + return umfMemoryProviderGetMinPageSize(traceProvider->hUpstreamProvider, ptr, pageSize); } -static enum uma_result_t tracePurgeLazy(void *provider, void *ptr, +static enum umf_result_t tracePurgeLazy(void *provider, void *ptr, size_t size) { struct traceParams *traceProvider = (struct traceParams *)provider; traceProvider->trace("purge_lazy"); - return umaMemoryProviderPurgeLazy(traceProvider->hUpstreamProvider, ptr, + return umfMemoryProviderPurgeLazy(traceProvider->hUpstreamProvider, ptr, size); } -static enum uma_result_t tracePurgeForce(void *provider, void *ptr, +static enum umf_result_t tracePurgeForce(void *provider, void *ptr, size_t size) { struct traceParams *traceProvider = (struct traceParams *)provider; traceProvider->trace("purge_force"); - return umaMemoryProviderPurgeForce(traceProvider->hUpstreamProvider, ptr, + return umfMemoryProviderPurgeForce(traceProvider->hUpstreamProvider, ptr, size); } @@ -182,14 +182,14 @@ static const char *traceName(void *provider) { struct traceParams *traceProvider = (struct traceParams *)provider; traceProvider->trace("name"); - return umaMemoryProviderGetName(traceProvider->hUpstreamProvider); + return umfMemoryProviderGetName(traceProvider->hUpstreamProvider); } -uma_memory_provider_handle_t -traceProviderCreate(uma_memory_provider_handle_t hUpstreamProvider, +umf_memory_provider_handle_t +traceProviderCreate(umf_memory_provider_handle_t hUpstreamProvider, void (*trace)(const char *)) { - struct uma_memory_provider_ops_t ops = { - .version = UMA_VERSION_CURRENT, + struct umf_memory_provider_ops_t ops = { + .version = UMF_VERSION_CURRENT, .initialize = traceInitialize, .finalize = traceFinalize, .alloc = traceAlloc, @@ -204,10 +204,10 @@ traceProviderCreate(uma_memory_provider_handle_t hUpstreamProvider, struct traceParams params = {.hUpstreamProvider = hUpstreamProvider, .trace = trace}; - uma_memory_provider_handle_t hProvider; - enum uma_result_t ret = umaMemoryProviderCreate(&ops, ¶ms, &hProvider); + umf_memory_provider_handle_t hProvider; + enum umf_result_t ret = umfMemoryProviderCreate(&ops, ¶ms, &hProvider); (void)ret; /* silence unused variable warning */ - assert(ret == UMA_RESULT_SUCCESS); + assert(ret == UMF_RESULT_SUCCESS); return hProvider; } diff --git a/test/unified_memory_allocation/common/provider.h b/test/unified_malloc_framework/common/provider.h similarity index 55% rename from test/unified_memory_allocation/common/provider.h rename to test/unified_malloc_framework/common/provider.h index d0ffdf8069..e8451c5dde 100644 --- a/test/unified_memory_allocation/common/provider.h +++ b/test/unified_malloc_framework/common/provider.h @@ -3,22 +3,22 @@ // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#ifndef UR_UMA_TEST_PROVIDER_H -#define UR_UMA_TEST_PROVIDER_H +#ifndef UR_UMF_TEST_PROVIDER_H +#define UR_UMF_TEST_PROVIDER_H -#include +#include #if defined(__cplusplus) extern "C" { #endif -uma_memory_provider_handle_t nullProviderCreate(void); -uma_memory_provider_handle_t -traceProviderCreate(uma_memory_provider_handle_t hUpstreamProvider, +umf_memory_provider_handle_t nullProviderCreate(void); +umf_memory_provider_handle_t +traceProviderCreate(umf_memory_provider_handle_t hUpstreamProvider, void (*trace)(const char *)); #if defined(__cplusplus) } #endif -#endif // UR_UMA_TEST_PROVIDER_H +#endif // UR_UMF_TEST_PROVIDER_H diff --git a/test/unified_malloc_framework/common/provider.hpp b/test/unified_malloc_framework/common/provider.hpp new file mode 100644 index 0000000000..518b2b0528 --- /dev/null +++ b/test/unified_malloc_framework/common/provider.hpp @@ -0,0 +1,81 @@ +/* + * + * Copyright (C) 2023 Intel Corporation + * + * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. + * See LICENSE.TXT + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + */ + +#ifndef UMF_TEST_PROVIDER_HPP +#define UMF_TEST_PROVIDER_HPP 1 + +#include +#include + +#include + +#include "base.hpp" +#include "umf_helpers.hpp" + +namespace umf_test { + +auto wrapProviderUnique(umf_memory_provider_handle_t hProvider) { + return umf::provider_unique_handle_t(hProvider, &umfMemoryProviderDestroy); +} + +struct provider_base { + umf_result_t initialize() noexcept { return UMF_RESULT_SUCCESS; }; + enum umf_result_t alloc(size_t, size_t, void **) noexcept { + return UMF_RESULT_ERROR_UNKNOWN; + } + enum umf_result_t free(void *ptr, size_t size) noexcept { + return UMF_RESULT_ERROR_UNKNOWN; + } + void get_last_native_error(const char **, int32_t *) noexcept {} + enum umf_result_t get_recommended_page_size(size_t size, + size_t *pageSize) noexcept { + return UMF_RESULT_ERROR_UNKNOWN; + } + enum umf_result_t get_min_page_size(void *ptr, size_t *pageSize) noexcept { + return UMF_RESULT_ERROR_UNKNOWN; + } + enum umf_result_t purge_lazy(void *ptr, size_t size) noexcept { + return UMF_RESULT_ERROR_UNKNOWN; + } + enum umf_result_t purge_force(void *ptr, size_t size) noexcept { + return UMF_RESULT_ERROR_UNKNOWN; + } + const char *get_name() noexcept { return "base"; } +}; + +struct provider_malloc : public provider_base { + enum umf_result_t alloc(size_t size, size_t align, void **ptr) noexcept { + if (!align) { + align = 8; + } + +#ifdef _WIN32 + *ptr = _aligned_malloc(size, align); +#else + *ptr = ::aligned_alloc(align, size); +#endif + + return (*ptr) ? UMF_RESULT_SUCCESS + : UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; + } + enum umf_result_t free(void *ptr, size_t) noexcept { +#ifdef _WIN32 + _aligned_free(ptr); +#else + ::free(ptr); +#endif + return UMF_RESULT_SUCCESS; + } + const char *get_name() noexcept { return "malloc"; } +}; + +} // namespace umf_test + +#endif /* UMF_TEST_PROVIDER_HPP */ diff --git a/test/unified_memory_allocation/memoryPool.hpp b/test/unified_malloc_framework/memoryPool.hpp similarity index 70% rename from test/unified_memory_allocation/memoryPool.hpp rename to test/unified_malloc_framework/memoryPool.hpp index c242419ba1..ab9cc3661c 100644 --- a/test/unified_memory_allocation/memoryPool.hpp +++ b/test/unified_malloc_framework/memoryPool.hpp @@ -9,13 +9,13 @@ #include #include -#ifndef UMA_TEST_MEMORY_POOL_OPS_HPP -#define UMA_TEST_MEMORY_POOL_OPS_HPP +#ifndef UMF_TEST_MEMORY_POOL_OPS_HPP +#define UMF_TEST_MEMORY_POOL_OPS_HPP -struct umaPoolTest : uma_test::test, +struct umfPoolTest : umf_test::test, ::testing::WithParamInterface< - std::function> { - umaPoolTest() : pool(nullptr, nullptr) {} + std::function> { + umfPoolTest() : pool(nullptr, nullptr) {} void SetUp() override { test::SetUp(); this->pool = makePool(); @@ -23,20 +23,20 @@ struct umaPoolTest : uma_test::test, void TearDown() override { test::TearDown(); } - uma::pool_unique_handle_t makePool() { + umf::pool_unique_handle_t makePool() { auto pool = this->GetParam()(); EXPECT_NE(pool, nullptr); return pool; } - uma::pool_unique_handle_t pool; + umf::pool_unique_handle_t pool; }; -struct umaMultiPoolTest : umaPoolTest { +struct umfMultiPoolTest : umfPoolTest { static constexpr auto numPools = 16; void SetUp() override { - umaPoolTest::SetUp(); + umfPoolTest::SetUp(); pools.emplace_back(std::move(pool)); for (size_t i = 1; i < numPools; i++) { @@ -44,20 +44,20 @@ struct umaMultiPoolTest : umaPoolTest { } } - void TearDown() override { umaPoolTest::TearDown(); } + void TearDown() override { umfPoolTest::TearDown(); } - std::vector pools; + std::vector pools; }; -TEST_P(umaPoolTest, allocFree) { +TEST_P(umfPoolTest, allocFree) { static constexpr size_t allocSize = 64; - auto *ptr = umaPoolMalloc(pool.get(), allocSize); + auto *ptr = umfPoolMalloc(pool.get(), allocSize); ASSERT_NE(ptr, nullptr); std::memset(ptr, 0, allocSize); - umaPoolFree(pool.get(), ptr); + umfPoolFree(pool.get(), ptr); } -TEST_P(umaPoolTest, pow2AlignedAlloc) { +TEST_P(umfPoolTest, pow2AlignedAlloc) { #ifdef _WIN32 // TODO: implement support for windows GTEST_SKIP(); @@ -71,7 +71,7 @@ TEST_P(umaPoolTest, pow2AlignedAlloc) { std::vector allocs; for (size_t alloc = 0; alloc < numAllocs; alloc++) { - auto *ptr = umaPoolAlignedMalloc(pool.get(), alignment, alignment); + auto *ptr = umfPoolAlignedMalloc(pool.get(), alignment, alignment); ASSERT_NE(ptr, nullptr); ASSERT_TRUE(reinterpret_cast(ptr) % alignment == 0); std::memset(ptr, 0, alignment); @@ -79,14 +79,14 @@ TEST_P(umaPoolTest, pow2AlignedAlloc) { } for (auto &ptr : allocs) { - umaPoolFree(pool.get(), ptr); + umfPoolFree(pool.get(), ptr); } } } // TODO: add similar tests for realloc/aligned_alloc, etc. // TODO: add multithreaded tests -TEST_P(umaMultiPoolTest, memoryTracking) { +TEST_P(umfMultiPoolTest, memoryTracking) { static constexpr int allocSizes[] = {1, 2, 4, 8, 16, 20, 32, 40, 64, 128, 1024, 4096}; static constexpr auto nAllocs = 256; @@ -97,29 +97,29 @@ TEST_P(umaMultiPoolTest, memoryTracking) { std::uniform_int_distribution poolsDist(0, static_cast(pools.size() - 1)); - std::vector> ptrs; + std::vector> ptrs; for (size_t i = 0; i < nAllocs; i++) { auto &pool = pools[poolsDist(g)]; auto size = allocSizes[allocSizesDist(g)]; - auto *ptr = umaPoolMalloc(pool.get(), size); + auto *ptr = umfPoolMalloc(pool.get(), size); ASSERT_NE(ptr, nullptr); ptrs.emplace_back(ptr, size, pool.get()); } for (auto [ptr, size, expectedPool] : ptrs) { - auto pool = umaPoolByPtr(ptr); + auto pool = umfPoolByPtr(ptr); ASSERT_EQ(pool, expectedPool); - pool = umaPoolByPtr(reinterpret_cast( + pool = umfPoolByPtr(reinterpret_cast( reinterpret_cast(ptr) + size - 1)); ASSERT_EQ(pool, expectedPool); } for (auto p : ptrs) { - umaFree(std::get<0>(p)); + umfFree(std::get<0>(p)); } } -#endif /* UMA_TEST_MEMORY_POOL_OPS_HPP */ +#endif /* UMF_TEST_MEMORY_POOL_OPS_HPP */ diff --git a/test/unified_malloc_framework/memoryPoolAPI.cpp b/test/unified_malloc_framework/memoryPoolAPI.cpp new file mode 100644 index 0000000000..35c307866e --- /dev/null +++ b/test/unified_malloc_framework/memoryPoolAPI.cpp @@ -0,0 +1,311 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// This file contains tests for UMF pool API + +#include "pool.h" +#include "pool.hpp" +#include "provider.h" +#include "provider.hpp" + +#include "memoryPool.hpp" +#include "umf/memory_provider.h" + +#include +#include +#include +#include + +using umf_test::test; + +TEST_F(test, memoryPoolTrace) { + static std::unordered_map poolCalls; + static std::unordered_map providerCalls; + auto tracePool = [](const char *name) { poolCalls[name]++; }; + auto traceProvider = [](const char *name) { providerCalls[name]++; }; + + auto nullProvider = umf_test::wrapProviderUnique(nullProviderCreate()); + auto tracingProvider = umf_test::wrapProviderUnique( + traceProviderCreate(nullProvider.get(), traceProvider)); + auto provider = tracingProvider.get(); + + auto [ret, proxyPool] = + umf::poolMakeUnique(&provider, 1); + ASSERT_EQ(ret, UMF_RESULT_SUCCESS); + + umf_memory_provider_handle_t providerDesc = nullProviderCreate(); + auto tracingPool = umf_test::wrapPoolUnique( + tracePoolCreate(proxyPool.get(), providerDesc, tracePool)); + + size_t pool_call_count = 0; + size_t provider_call_count = 0; + + umfPoolMalloc(tracingPool.get(), 0); + ASSERT_EQ(poolCalls["malloc"], 1); + ASSERT_EQ(poolCalls.size(), ++pool_call_count); + + ASSERT_EQ(providerCalls["alloc"], 1); + ASSERT_EQ(providerCalls.size(), ++provider_call_count); + + umfPoolFree(tracingPool.get(), nullptr); + ASSERT_EQ(poolCalls["free"], 1); + ASSERT_EQ(poolCalls.size(), ++pool_call_count); + + ASSERT_EQ(providerCalls["free"], 1); + ASSERT_EQ(providerCalls.size(), ++provider_call_count); + + umfPoolCalloc(tracingPool.get(), 0, 0); + ASSERT_EQ(poolCalls["calloc"], 1); + ASSERT_EQ(poolCalls.size(), ++pool_call_count); + + ASSERT_EQ(providerCalls["alloc"], 2); + ASSERT_EQ(providerCalls.size(), provider_call_count); + + umfPoolRealloc(tracingPool.get(), nullptr, 0); + ASSERT_EQ(poolCalls["realloc"], 1); + ASSERT_EQ(poolCalls.size(), ++pool_call_count); + + ASSERT_EQ(providerCalls.size(), provider_call_count); + + umfPoolAlignedMalloc(tracingPool.get(), 0, 0); + ASSERT_EQ(poolCalls["aligned_malloc"], 1); + ASSERT_EQ(poolCalls.size(), ++pool_call_count); + + ASSERT_EQ(providerCalls["alloc"], 3); + ASSERT_EQ(providerCalls.size(), provider_call_count); + + umfPoolMallocUsableSize(tracingPool.get(), nullptr); + ASSERT_EQ(poolCalls["malloc_usable_size"], 1); + ASSERT_EQ(poolCalls.size(), ++pool_call_count); + + ASSERT_EQ(providerCalls.size(), provider_call_count); + + ret = umfPoolGetLastAllocationError(tracingPool.get()); + ASSERT_EQ(ret, UMF_RESULT_SUCCESS); + ASSERT_EQ(poolCalls["get_last_native_error"], 1); + ASSERT_EQ(poolCalls.size(), ++pool_call_count); + + umfMemoryProviderDestroy(providerDesc); +} + +TEST_F(test, memoryPoolWithCustomProviders) { + umf_memory_provider_handle_t providers[] = {nullProviderCreate(), + nullProviderCreate()}; + + struct pool : public umf_test::pool_base { + umf_result_t initialize(umf_memory_provider_handle_t *providers, + size_t numProviders) noexcept { + EXPECT_NE_NOEXCEPT(providers, nullptr); + EXPECT_EQ_NOEXCEPT(numProviders, 2); + return UMF_RESULT_SUCCESS; + } + }; + + auto ret = umf::poolMakeUnique(providers, 2); + ASSERT_EQ(ret.first, UMF_RESULT_SUCCESS); + ASSERT_NE(ret.second, nullptr); + + for (auto &provider : providers) { + umfMemoryProviderDestroy(provider); + } +} + +TEST_F(test, retrieveMemoryProviders) { + static constexpr size_t numProviders = 4; + std::array providers = { + (umf_memory_provider_handle_t)0x1, (umf_memory_provider_handle_t)0x2, + (umf_memory_provider_handle_t)0x3, (umf_memory_provider_handle_t)0x4}; + + auto [ret, pool] = umf::poolMakeUnique( + providers.data(), numProviders); + + std::array retProviders; + size_t numProvidersRet = 0; + + ret = umfPoolGetMemoryProviders(pool.get(), 0, nullptr, &numProvidersRet); + ASSERT_EQ(ret, UMF_RESULT_SUCCESS); + ASSERT_EQ(numProvidersRet, numProviders); + + ret = umfPoolGetMemoryProviders(pool.get(), numProviders, + retProviders.data(), nullptr); + ASSERT_EQ(ret, UMF_RESULT_SUCCESS); + ASSERT_EQ(retProviders, providers); +} + +template +static auto +makePool(std::function makeProvider) { + auto providerUnique = makeProvider(); + umf_memory_provider_handle_t provider = providerUnique.get(); + auto pool = umf::poolMakeUnique(&provider, 1).second; + auto dtor = [provider = + providerUnique.release()](umf_memory_pool_handle_t hPool) { + umfPoolDestroy(hPool); + umfMemoryProviderDestroy(provider); + }; + return umf::pool_unique_handle_t(pool.release(), std::move(dtor)); +} + +INSTANTIATE_TEST_SUITE_P(mallocPoolTest, umfPoolTest, ::testing::Values([] { + return makePool([] { + return umf_test::wrapProviderUnique( + nullProviderCreate()); + }); + })); + +INSTANTIATE_TEST_SUITE_P( + mallocProviderPoolTest, umfPoolTest, ::testing::Values([] { + return makePool([] { + return umf::memoryProviderMakeUnique() + .second; + }); + })); + +INSTANTIATE_TEST_SUITE_P( + mallocMultiPoolTest, umfMultiPoolTest, ::testing::Values([] { + return makePool([] { + return umf::memoryProviderMakeUnique() + .second; + }); + })); + +////////////////// Negative test cases ///////////////// + +TEST_F(test, memoryPoolInvalidProvidersNullptr) { + auto ret = umf::poolMakeUnique(nullptr, 1); + ASSERT_EQ(ret.first, UMF_RESULT_ERROR_INVALID_ARGUMENT); +} + +TEST_F(test, memoryPoolInvalidProvidersNum) { + auto nullProvider = umf_test::wrapProviderUnique(nullProviderCreate()); + umf_memory_provider_handle_t providers[] = {nullProvider.get()}; + + auto ret = umf::poolMakeUnique(providers, 0); + ASSERT_EQ(ret.first, UMF_RESULT_ERROR_INVALID_ARGUMENT); +} + +struct poolInitializeTest : umf_test::test, + ::testing::WithParamInterface {}; + +INSTANTIATE_TEST_SUITE_P( + poolInitializeTest, poolInitializeTest, + ::testing::Values(UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY, + UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC, + UMF_RESULT_ERROR_INVALID_ARGUMENT, + UMF_RESULT_ERROR_UNKNOWN)); + +TEST_P(poolInitializeTest, errorPropagation) { + auto nullProvider = umf_test::wrapProviderUnique(nullProviderCreate()); + umf_memory_provider_handle_t providers[] = {nullProvider.get()}; + + struct pool : public umf_test::pool_base { + umf_result_t initialize(umf_memory_provider_handle_t *providers, + size_t numProviders, + umf_result_t errorToReturn) noexcept { + return errorToReturn; + } + }; + auto ret = umf::poolMakeUnique(providers, 1, this->GetParam()); + ASSERT_EQ(ret.first, this->GetParam()); + ASSERT_EQ(ret.second, nullptr); +} + +TEST_F(test, retrieveMemoryProvidersError) { + static constexpr size_t numProviders = 4; + std::array providers = { + (umf_memory_provider_handle_t)0x1, (umf_memory_provider_handle_t)0x2, + (umf_memory_provider_handle_t)0x3, (umf_memory_provider_handle_t)0x4}; + + auto [ret, pool] = umf::poolMakeUnique( + providers.data(), numProviders); + + ret = umfPoolGetMemoryProviders(pool.get(), 1, providers.data(), nullptr); + ASSERT_EQ(ret, UMF_RESULT_ERROR_INVALID_ARGUMENT); +} + +// TODO: extend test for different functions (not only alloc) +TEST_F(test, getLastFailedMemoryProvider) { + static constexpr size_t allocSize = 8; + static umf_result_t allocResult = UMF_RESULT_SUCCESS; + + struct memory_provider : public umf_test::provider_base { + umf_result_t initialize(const char *name) { + this->name = name; + return UMF_RESULT_SUCCESS; + } + + enum umf_result_t alloc(size_t size, size_t, void **ptr) noexcept { + if (allocResult == UMF_RESULT_SUCCESS) { + *ptr = malloc(size); + } else { + *ptr = nullptr; + } + + return allocResult; + } + + enum umf_result_t free(void *ptr, size_t size) noexcept { + ::free(ptr); + return UMF_RESULT_SUCCESS; + } + + const char *get_name() noexcept { return this->name; } + + const char *name; + }; + + auto [ret1, providerUnique1] = + umf::memoryProviderMakeUnique("provider1"); + ASSERT_EQ(ret1, UMF_RESULT_SUCCESS); + auto [ret2, providerUnique2] = + umf::memoryProviderMakeUnique("provider2"); + ASSERT_EQ(ret2, UMF_RESULT_SUCCESS); + + auto hProvider = providerUnique1.get(); + + auto [ret, pool] = umf::poolMakeUnique(&hProvider, 1); + ASSERT_EQ(ret, UMF_RESULT_SUCCESS); + + ASSERT_EQ(umfGetLastFailedMemoryProvider(), nullptr); + auto ptr = umfPoolMalloc(pool.get(), allocSize); + ASSERT_NE(ptr, nullptr); + ASSERT_EQ(umfGetLastFailedMemoryProvider(), nullptr); + + // make provider return an error during allocation + allocResult = UMF_RESULT_ERROR_UNKNOWN; + ptr = umfPoolMalloc(pool.get(), allocSize); + ASSERT_EQ(ptr, nullptr); + ASSERT_EQ(std::string_view( + umfMemoryProviderGetName(umfGetLastFailedMemoryProvider())), + "provider1"); + + ret = umfMemoryProviderAlloc(providerUnique2.get(), allocSize, 0, &ptr); + ASSERT_EQ(ptr, nullptr); + ASSERT_EQ(std::string_view( + umfMemoryProviderGetName(umfGetLastFailedMemoryProvider())), + "provider2"); + + // succesfull provider should not be returned by umfGetLastFailedMemoryProvider + allocResult = UMF_RESULT_SUCCESS; + ptr = umfPoolMalloc(pool.get(), allocSize); + ASSERT_NE(ptr, nullptr); + ASSERT_EQ(std::string_view( + umfMemoryProviderGetName(umfGetLastFailedMemoryProvider())), + "provider2"); + + // erorr in another thread should not impact umfGetLastFailedMemoryProvider on this thread + allocResult = UMF_RESULT_ERROR_UNKNOWN; + std::thread t([&, hPool = pool.get()] { + ptr = umfPoolMalloc(hPool, allocSize); + ASSERT_EQ(ptr, nullptr); + ASSERT_EQ(std::string_view(umfMemoryProviderGetName( + umfGetLastFailedMemoryProvider())), + "provider1"); + }); + t.join(); + + ASSERT_EQ(std::string_view( + umfMemoryProviderGetName(umfGetLastFailedMemoryProvider())), + "provider2"); +} diff --git a/test/unified_memory_allocation/memoryProvider.hpp b/test/unified_malloc_framework/memoryProvider.hpp similarity index 60% rename from test/unified_memory_allocation/memoryProvider.hpp rename to test/unified_malloc_framework/memoryProvider.hpp index c7b5cc9f35..fe61ca39ae 100644 --- a/test/unified_memory_allocation/memoryProvider.hpp +++ b/test/unified_malloc_framework/memoryProvider.hpp @@ -8,23 +8,23 @@ #include #include -#ifndef UMA_TEST_MEMORY_PROVIDER_OPS_HPP -#define UMA_TEST_MEMORY_PROVIDER_OPS_HPP +#ifndef UMF_TEST_MEMORY_PROVIDER_OPS_HPP +#define UMF_TEST_MEMORY_PROVIDER_OPS_HPP -struct umaProviderTest - : uma_test::test, +struct umfProviderTest + : umf_test::test, ::testing::WithParamInterface()>> { - umaProviderTest() : provider(nullptr, nullptr) {} + std::pair()>> { + umfProviderTest() : provider(nullptr, nullptr) {} void SetUp() { test::SetUp(); auto [res, provider] = this->GetParam()(); - EXPECT_EQ(res, UMA_RESULT_SUCCESS); + EXPECT_EQ(res, UMF_RESULT_SUCCESS); EXPECT_NE(provider, nullptr); this->provider = std::move(provider); } void TearDown() override { test::TearDown(); } - uma::provider_unique_handle_t provider; + umf::provider_unique_handle_t provider; }; -#endif /* UMA_TEST_MEMORY_PROVIDER_OPS_HPP */ +#endif /* UMF_TEST_MEMORY_PROVIDER_OPS_HPP */ diff --git a/test/unified_memory_allocation/memoryProviderAPI.cpp b/test/unified_malloc_framework/memoryProviderAPI.cpp similarity index 58% rename from test/unified_memory_allocation/memoryProviderAPI.cpp rename to test/unified_malloc_framework/memoryProviderAPI.cpp index 754b86992e..fa02f9eb99 100644 --- a/test/unified_memory_allocation/memoryProviderAPI.cpp +++ b/test/unified_malloc_framework/memoryProviderAPI.cpp @@ -2,7 +2,7 @@ // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This file contains tests for UMA provider API +// This file contains tests for UMF provider API #include "pool.h" #include "provider.h" @@ -11,56 +11,56 @@ #include #include -using uma_test::test; +using umf_test::test; TEST_F(test, memoryProviderTrace) { static std::unordered_map calls; auto trace = [](const char *name) { calls[name]++; }; - auto nullProvider = uma_test::wrapProviderUnique(nullProviderCreate()); - auto tracingProvider = uma_test::wrapProviderUnique( + auto nullProvider = umf_test::wrapProviderUnique(nullProviderCreate()); + auto tracingProvider = umf_test::wrapProviderUnique( traceProviderCreate(nullProvider.get(), trace)); size_t call_count = 0; - auto ret = umaMemoryProviderAlloc(tracingProvider.get(), 0, 0, nullptr); - ASSERT_EQ(ret, UMA_RESULT_SUCCESS); + auto ret = umfMemoryProviderAlloc(tracingProvider.get(), 0, 0, nullptr); + ASSERT_EQ(ret, UMF_RESULT_SUCCESS); ASSERT_EQ(calls["alloc"], 1); ASSERT_EQ(calls.size(), ++call_count); - ret = umaMemoryProviderFree(tracingProvider.get(), nullptr, 0); - ASSERT_EQ(ret, UMA_RESULT_SUCCESS); + ret = umfMemoryProviderFree(tracingProvider.get(), nullptr, 0); + ASSERT_EQ(ret, UMF_RESULT_SUCCESS); ASSERT_EQ(calls["free"], 1); ASSERT_EQ(calls.size(), ++call_count); - umaMemoryProviderGetLastNativeError(tracingProvider.get(), nullptr, + umfMemoryProviderGetLastNativeError(tracingProvider.get(), nullptr, nullptr); ASSERT_EQ(calls["get_last_native_error"], 1); ASSERT_EQ(calls.size(), ++call_count); - ret = umaMemoryProviderGetRecommendedPageSize(tracingProvider.get(), 0, + ret = umfMemoryProviderGetRecommendedPageSize(tracingProvider.get(), 0, nullptr); - ASSERT_EQ(ret, UMA_RESULT_SUCCESS); + ASSERT_EQ(ret, UMF_RESULT_SUCCESS); ASSERT_EQ(calls["get_recommended_page_size"], 1); ASSERT_EQ(calls.size(), ++call_count); - ret = umaMemoryProviderGetMinPageSize(tracingProvider.get(), nullptr, + ret = umfMemoryProviderGetMinPageSize(tracingProvider.get(), nullptr, nullptr); - ASSERT_EQ(ret, UMA_RESULT_SUCCESS); + ASSERT_EQ(ret, UMF_RESULT_SUCCESS); ASSERT_EQ(calls["get_min_page_size"], 1); ASSERT_EQ(calls.size(), ++call_count); - ret = umaMemoryProviderPurgeLazy(tracingProvider.get(), nullptr, 0); - ASSERT_EQ(ret, UMA_RESULT_SUCCESS); + ret = umfMemoryProviderPurgeLazy(tracingProvider.get(), nullptr, 0); + ASSERT_EQ(ret, UMF_RESULT_SUCCESS); ASSERT_EQ(calls["purge_lazy"], 1); ASSERT_EQ(calls.size(), ++call_count); - ret = umaMemoryProviderPurgeForce(tracingProvider.get(), nullptr, 0); - ASSERT_EQ(ret, UMA_RESULT_SUCCESS); + ret = umfMemoryProviderPurgeForce(tracingProvider.get(), nullptr, 0); + ASSERT_EQ(ret, UMF_RESULT_SUCCESS); ASSERT_EQ(calls["purge_force"], 1); ASSERT_EQ(calls.size(), ++call_count); - const char *pName = umaMemoryProviderGetName(tracingProvider.get()); + const char *pName = umfMemoryProviderGetName(tracingProvider.get()); ASSERT_EQ(calls["name"], 1); ASSERT_EQ(calls.size(), ++call_count); ASSERT_EQ(std::string(pName), std::string("null")); @@ -69,23 +69,23 @@ TEST_F(test, memoryProviderTrace) { //////////////////////////// Negative test cases /////////////////////////////////// -struct providerInitializeTest : uma_test::test, - ::testing::WithParamInterface {}; +struct providerInitializeTest : umf_test::test, + ::testing::WithParamInterface {}; INSTANTIATE_TEST_SUITE_P( providerInitializeTest, providerInitializeTest, - ::testing::Values(UMA_RESULT_ERROR_OUT_OF_HOST_MEMORY, - UMA_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC, - UMA_RESULT_ERROR_INVALID_ARGUMENT, - UMA_RESULT_ERROR_UNKNOWN)); + ::testing::Values(UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY, + UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC, + UMF_RESULT_ERROR_INVALID_ARGUMENT, + UMF_RESULT_ERROR_UNKNOWN)); TEST_P(providerInitializeTest, errorPropagation) { - struct provider : public uma_test::provider_base { - uma_result_t initialize(uma_result_t errorToReturn) noexcept { + struct provider : public umf_test::provider_base { + umf_result_t initialize(umf_result_t errorToReturn) noexcept { return errorToReturn; } }; - auto ret = uma::memoryProviderMakeUnique(this->GetParam()); + auto ret = umf::memoryProviderMakeUnique(this->GetParam()); ASSERT_EQ(ret.first, this->GetParam()); ASSERT_EQ(ret.second, nullptr); } diff --git a/test/unified_memory_allocation/uma_pools/CMakeLists.txt b/test/unified_malloc_framework/umf_pools/CMakeLists.txt similarity index 52% rename from test/unified_memory_allocation/uma_pools/CMakeLists.txt rename to test/unified_malloc_framework/umf_pools/CMakeLists.txt index c38921d146..578059ed16 100644 --- a/test/unified_memory_allocation/uma_pools/CMakeLists.txt +++ b/test/unified_malloc_framework/umf_pools/CMakeLists.txt @@ -3,8 +3,8 @@ # See LICENSE.TXT # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -add_uma_test(disjointPool disjoint_pool.cpp) -add_uma_test(disjointPoolConfigParser disjoint_pool_config_parser.cpp) +add_umf_test(disjointPool disjoint_pool.cpp) +add_umf_test(disjointPoolConfigParser disjoint_pool_config_parser.cpp) -target_include_directories(uma_test-disjointPool PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) -target_link_libraries(uma_test-disjointPool PRIVATE ${PROJECT_NAME}::common) +target_include_directories(umf_test-disjointPool PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) +target_link_libraries(umf_test-disjointPool PRIVATE ${PROJECT_NAME}::common) diff --git a/test/unified_memory_allocation/uma_pools/disjoint_pool.cpp b/test/unified_malloc_framework/umf_pools/disjoint_pool.cpp similarity index 61% rename from test/unified_memory_allocation/uma_pools/disjoint_pool.cpp rename to test/unified_malloc_framework/umf_pools/disjoint_pool.cpp index 88b6d769d8..937c853119 100644 --- a/test/unified_memory_allocation/uma_pools/disjoint_pool.cpp +++ b/test/unified_malloc_framework/umf_pools/disjoint_pool.cpp @@ -25,21 +25,21 @@ static usm::DisjointPool::Config poolConfig() { static auto makePool() { auto [ret, providerUnique] = - uma::memoryProviderMakeUnique(); - EXPECT_EQ(ret, UMA_RESULT_SUCCESS); + umf::memoryProviderMakeUnique(); + EXPECT_EQ(ret, UMF_RESULT_SUCCESS); auto provider = providerUnique.release(); auto [retp, pool] = - uma::poolMakeUnique(&provider, 1, poolConfig()); - EXPECT_EQ(retp, UMA_RESULT_SUCCESS); - auto dtor = [provider = provider](uma_memory_pool_handle_t hPool) { - umaPoolDestroy(hPool); - umaMemoryProviderDestroy(provider); + umf::poolMakeUnique(&provider, 1, poolConfig()); + EXPECT_EQ(retp, UMF_RESULT_SUCCESS); + auto dtor = [provider = provider](umf_memory_pool_handle_t hPool) { + umfPoolDestroy(hPool); + umfMemoryProviderDestroy(provider); }; - return uma::pool_unique_handle_t(pool.release(), std::move(dtor)); + return umf::pool_unique_handle_t(pool.release(), std::move(dtor)); } -INSTANTIATE_TEST_SUITE_P(disjointPoolTests, umaPoolTest, +INSTANTIATE_TEST_SUITE_P(disjointPoolTests, umfPoolTest, ::testing::Values(makePool)); -INSTANTIATE_TEST_SUITE_P(disjointMultiPoolTests, umaMultiPoolTest, +INSTANTIATE_TEST_SUITE_P(disjointMultiPoolTests, umfMultiPoolTest, ::testing::Values(makePool)); diff --git a/test/unified_memory_allocation/uma_pools/disjoint_pool_config_parser.cpp b/test/unified_malloc_framework/umf_pools/disjoint_pool_config_parser.cpp similarity index 100% rename from test/unified_memory_allocation/uma_pools/disjoint_pool_config_parser.cpp rename to test/unified_malloc_framework/umf_pools/disjoint_pool_config_parser.cpp diff --git a/test/unified_memory_allocation/CMakeLists.txt b/test/unified_memory_allocation/CMakeLists.txt deleted file mode 100644 index 7cb5c1c8fc..0000000000 --- a/test/unified_memory_allocation/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright (C) 2022-2023 Intel Corporation -# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. -# See LICENSE.TXT -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -set(UR_UMA_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) - -add_library(uma_test_helpers STATIC - ${UR_UMA_TEST_DIR}/common/pool.c - ${UR_UMA_TEST_DIR}/common/provider.c -) - -target_link_libraries(uma_test_helpers PRIVATE ${PROJECT_NAME}::common) - -function(add_uma_test name) - set(TEST_TARGET_NAME uma_test-${name}) - add_executable(${TEST_TARGET_NAME} - ${ARGN}) - target_link_libraries(${TEST_TARGET_NAME} - PRIVATE - ${PROJECT_NAME}::unified_memory_allocation - ${PROJECT_NAME}::common - uma_test_helpers - GTest::gtest_main) - target_include_directories(${TEST_TARGET_NAME} PRIVATE - ${UR_UMA_TEST_DIR}/common) - add_test(NAME uma-${name} - COMMAND ${TEST_TARGET_NAME} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - set_tests_properties(uma-${name} PROPERTIES LABELS "uma") -endfunction() - -add_subdirectory(uma_pools) - -add_uma_test(memoryProvider memoryProviderAPI.cpp) -add_uma_test(memoryPool memoryPoolAPI.cpp) -add_uma_test(base base.cpp) diff --git a/test/unified_memory_allocation/common/provider.hpp b/test/unified_memory_allocation/common/provider.hpp deleted file mode 100644 index bca4f66872..0000000000 --- a/test/unified_memory_allocation/common/provider.hpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * - * Copyright (C) 2023 Intel Corporation - * - * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. - * See LICENSE.TXT - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - */ - -#ifndef UMA_TEST_PROVIDER_HPP -#define UMA_TEST_PROVIDER_HPP 1 - -#include -#include - -#include - -#include "base.hpp" -#include "uma_helpers.hpp" - -namespace uma_test { - -auto wrapProviderUnique(uma_memory_provider_handle_t hProvider) { - return uma::provider_unique_handle_t(hProvider, &umaMemoryProviderDestroy); -} - -struct provider_base { - uma_result_t initialize() noexcept { return UMA_RESULT_SUCCESS; }; - enum uma_result_t alloc(size_t, size_t, void **) noexcept { - return UMA_RESULT_ERROR_UNKNOWN; - } - enum uma_result_t free(void *ptr, size_t size) noexcept { - return UMA_RESULT_ERROR_UNKNOWN; - } - void get_last_native_error(const char **, int32_t *) noexcept {} - enum uma_result_t get_recommended_page_size(size_t size, - size_t *pageSize) noexcept { - return UMA_RESULT_ERROR_UNKNOWN; - } - enum uma_result_t get_min_page_size(void *ptr, size_t *pageSize) noexcept { - return UMA_RESULT_ERROR_UNKNOWN; - } - enum uma_result_t purge_lazy(void *ptr, size_t size) noexcept { - return UMA_RESULT_ERROR_UNKNOWN; - } - enum uma_result_t purge_force(void *ptr, size_t size) noexcept { - return UMA_RESULT_ERROR_UNKNOWN; - } - const char *get_name() noexcept { return "base"; } -}; - -struct provider_malloc : public provider_base { - enum uma_result_t alloc(size_t size, size_t align, void **ptr) noexcept { - if (!align) { - align = 8; - } - -#ifdef _WIN32 - *ptr = _aligned_malloc(size, align); -#else - *ptr = ::aligned_alloc(align, size); -#endif - - return (*ptr) ? UMA_RESULT_SUCCESS - : UMA_RESULT_ERROR_OUT_OF_HOST_MEMORY; - } - enum uma_result_t free(void *ptr, size_t) noexcept { -#ifdef _WIN32 - _aligned_free(ptr); -#else - ::free(ptr); -#endif - return UMA_RESULT_SUCCESS; - } - const char *get_name() noexcept { return "malloc"; } -}; - -} // namespace uma_test - -#endif /* UMA_TEST_PROVIDER_HPP */ diff --git a/test/unified_memory_allocation/memoryPoolAPI.cpp b/test/unified_memory_allocation/memoryPoolAPI.cpp deleted file mode 100644 index 015d3e1dd5..0000000000 --- a/test/unified_memory_allocation/memoryPoolAPI.cpp +++ /dev/null @@ -1,311 +0,0 @@ -// Copyright (C) 2023 Intel Corporation -// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. -// See LICENSE.TXT -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This file contains tests for UMA pool API - -#include "pool.h" -#include "pool.hpp" -#include "provider.h" -#include "provider.hpp" - -#include "memoryPool.hpp" -#include "uma/memory_provider.h" - -#include -#include -#include -#include - -using uma_test::test; - -TEST_F(test, memoryPoolTrace) { - static std::unordered_map poolCalls; - static std::unordered_map providerCalls; - auto tracePool = [](const char *name) { poolCalls[name]++; }; - auto traceProvider = [](const char *name) { providerCalls[name]++; }; - - auto nullProvider = uma_test::wrapProviderUnique(nullProviderCreate()); - auto tracingProvider = uma_test::wrapProviderUnique( - traceProviderCreate(nullProvider.get(), traceProvider)); - auto provider = tracingProvider.get(); - - auto [ret, proxyPool] = - uma::poolMakeUnique(&provider, 1); - ASSERT_EQ(ret, UMA_RESULT_SUCCESS); - - uma_memory_provider_handle_t providerDesc = nullProviderCreate(); - auto tracingPool = uma_test::wrapPoolUnique( - tracePoolCreate(proxyPool.get(), providerDesc, tracePool)); - - size_t pool_call_count = 0; - size_t provider_call_count = 0; - - umaPoolMalloc(tracingPool.get(), 0); - ASSERT_EQ(poolCalls["malloc"], 1); - ASSERT_EQ(poolCalls.size(), ++pool_call_count); - - ASSERT_EQ(providerCalls["alloc"], 1); - ASSERT_EQ(providerCalls.size(), ++provider_call_count); - - umaPoolFree(tracingPool.get(), nullptr); - ASSERT_EQ(poolCalls["free"], 1); - ASSERT_EQ(poolCalls.size(), ++pool_call_count); - - ASSERT_EQ(providerCalls["free"], 1); - ASSERT_EQ(providerCalls.size(), ++provider_call_count); - - umaPoolCalloc(tracingPool.get(), 0, 0); - ASSERT_EQ(poolCalls["calloc"], 1); - ASSERT_EQ(poolCalls.size(), ++pool_call_count); - - ASSERT_EQ(providerCalls["alloc"], 2); - ASSERT_EQ(providerCalls.size(), provider_call_count); - - umaPoolRealloc(tracingPool.get(), nullptr, 0); - ASSERT_EQ(poolCalls["realloc"], 1); - ASSERT_EQ(poolCalls.size(), ++pool_call_count); - - ASSERT_EQ(providerCalls.size(), provider_call_count); - - umaPoolAlignedMalloc(tracingPool.get(), 0, 0); - ASSERT_EQ(poolCalls["aligned_malloc"], 1); - ASSERT_EQ(poolCalls.size(), ++pool_call_count); - - ASSERT_EQ(providerCalls["alloc"], 3); - ASSERT_EQ(providerCalls.size(), provider_call_count); - - umaPoolMallocUsableSize(tracingPool.get(), nullptr); - ASSERT_EQ(poolCalls["malloc_usable_size"], 1); - ASSERT_EQ(poolCalls.size(), ++pool_call_count); - - ASSERT_EQ(providerCalls.size(), provider_call_count); - - ret = umaPoolGetLastAllocationError(tracingPool.get()); - ASSERT_EQ(ret, UMA_RESULT_SUCCESS); - ASSERT_EQ(poolCalls["get_last_native_error"], 1); - ASSERT_EQ(poolCalls.size(), ++pool_call_count); - - umaMemoryProviderDestroy(providerDesc); -} - -TEST_F(test, memoryPoolWithCustomProviders) { - uma_memory_provider_handle_t providers[] = {nullProviderCreate(), - nullProviderCreate()}; - - struct pool : public uma_test::pool_base { - uma_result_t initialize(uma_memory_provider_handle_t *providers, - size_t numProviders) noexcept { - EXPECT_NE_NOEXCEPT(providers, nullptr); - EXPECT_EQ_NOEXCEPT(numProviders, 2); - return UMA_RESULT_SUCCESS; - } - }; - - auto ret = uma::poolMakeUnique(providers, 2); - ASSERT_EQ(ret.first, UMA_RESULT_SUCCESS); - ASSERT_NE(ret.second, nullptr); - - for (auto &provider : providers) { - umaMemoryProviderDestroy(provider); - } -} - -TEST_F(test, retrieveMemoryProviders) { - static constexpr size_t numProviders = 4; - std::array providers = { - (uma_memory_provider_handle_t)0x1, (uma_memory_provider_handle_t)0x2, - (uma_memory_provider_handle_t)0x3, (uma_memory_provider_handle_t)0x4}; - - auto [ret, pool] = uma::poolMakeUnique( - providers.data(), numProviders); - - std::array retProviders; - size_t numProvidersRet = 0; - - ret = umaPoolGetMemoryProviders(pool.get(), 0, nullptr, &numProvidersRet); - ASSERT_EQ(ret, UMA_RESULT_SUCCESS); - ASSERT_EQ(numProvidersRet, numProviders); - - ret = umaPoolGetMemoryProviders(pool.get(), numProviders, - retProviders.data(), nullptr); - ASSERT_EQ(ret, UMA_RESULT_SUCCESS); - ASSERT_EQ(retProviders, providers); -} - -template -static auto -makePool(std::function makeProvider) { - auto providerUnique = makeProvider(); - uma_memory_provider_handle_t provider = providerUnique.get(); - auto pool = uma::poolMakeUnique(&provider, 1).second; - auto dtor = [provider = - providerUnique.release()](uma_memory_pool_handle_t hPool) { - umaPoolDestroy(hPool); - umaMemoryProviderDestroy(provider); - }; - return uma::pool_unique_handle_t(pool.release(), std::move(dtor)); -} - -INSTANTIATE_TEST_SUITE_P(mallocPoolTest, umaPoolTest, ::testing::Values([] { - return makePool([] { - return uma_test::wrapProviderUnique( - nullProviderCreate()); - }); - })); - -INSTANTIATE_TEST_SUITE_P( - mallocProviderPoolTest, umaPoolTest, ::testing::Values([] { - return makePool([] { - return uma::memoryProviderMakeUnique() - .second; - }); - })); - -INSTANTIATE_TEST_SUITE_P( - mallocMultiPoolTest, umaMultiPoolTest, ::testing::Values([] { - return makePool([] { - return uma::memoryProviderMakeUnique() - .second; - }); - })); - -////////////////// Negative test cases ///////////////// - -TEST_F(test, memoryPoolInvalidProvidersNullptr) { - auto ret = uma::poolMakeUnique(nullptr, 1); - ASSERT_EQ(ret.first, UMA_RESULT_ERROR_INVALID_ARGUMENT); -} - -TEST_F(test, memoryPoolInvalidProvidersNum) { - auto nullProvider = uma_test::wrapProviderUnique(nullProviderCreate()); - uma_memory_provider_handle_t providers[] = {nullProvider.get()}; - - auto ret = uma::poolMakeUnique(providers, 0); - ASSERT_EQ(ret.first, UMA_RESULT_ERROR_INVALID_ARGUMENT); -} - -struct poolInitializeTest : uma_test::test, - ::testing::WithParamInterface {}; - -INSTANTIATE_TEST_SUITE_P( - poolInitializeTest, poolInitializeTest, - ::testing::Values(UMA_RESULT_ERROR_OUT_OF_HOST_MEMORY, - UMA_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC, - UMA_RESULT_ERROR_INVALID_ARGUMENT, - UMA_RESULT_ERROR_UNKNOWN)); - -TEST_P(poolInitializeTest, errorPropagation) { - auto nullProvider = uma_test::wrapProviderUnique(nullProviderCreate()); - uma_memory_provider_handle_t providers[] = {nullProvider.get()}; - - struct pool : public uma_test::pool_base { - uma_result_t initialize(uma_memory_provider_handle_t *providers, - size_t numProviders, - uma_result_t errorToReturn) noexcept { - return errorToReturn; - } - }; - auto ret = uma::poolMakeUnique(providers, 1, this->GetParam()); - ASSERT_EQ(ret.first, this->GetParam()); - ASSERT_EQ(ret.second, nullptr); -} - -TEST_F(test, retrieveMemoryProvidersError) { - static constexpr size_t numProviders = 4; - std::array providers = { - (uma_memory_provider_handle_t)0x1, (uma_memory_provider_handle_t)0x2, - (uma_memory_provider_handle_t)0x3, (uma_memory_provider_handle_t)0x4}; - - auto [ret, pool] = uma::poolMakeUnique( - providers.data(), numProviders); - - ret = umaPoolGetMemoryProviders(pool.get(), 1, providers.data(), nullptr); - ASSERT_EQ(ret, UMA_RESULT_ERROR_INVALID_ARGUMENT); -} - -// TODO: extend test for different functions (not only alloc) -TEST_F(test, getLastFailedMemoryProvider) { - static constexpr size_t allocSize = 8; - static uma_result_t allocResult = UMA_RESULT_SUCCESS; - - struct memory_provider : public uma_test::provider_base { - uma_result_t initialize(const char *name) { - this->name = name; - return UMA_RESULT_SUCCESS; - } - - enum uma_result_t alloc(size_t size, size_t, void **ptr) noexcept { - if (allocResult == UMA_RESULT_SUCCESS) { - *ptr = malloc(size); - } else { - *ptr = nullptr; - } - - return allocResult; - } - - enum uma_result_t free(void *ptr, size_t size) noexcept { - ::free(ptr); - return UMA_RESULT_SUCCESS; - } - - const char *get_name() noexcept { return this->name; } - - const char *name; - }; - - auto [ret1, providerUnique1] = - uma::memoryProviderMakeUnique("provider1"); - ASSERT_EQ(ret1, UMA_RESULT_SUCCESS); - auto [ret2, providerUnique2] = - uma::memoryProviderMakeUnique("provider2"); - ASSERT_EQ(ret2, UMA_RESULT_SUCCESS); - - auto hProvider = providerUnique1.get(); - - auto [ret, pool] = uma::poolMakeUnique(&hProvider, 1); - ASSERT_EQ(ret, UMA_RESULT_SUCCESS); - - ASSERT_EQ(umaGetLastFailedMemoryProvider(), nullptr); - auto ptr = umaPoolMalloc(pool.get(), allocSize); - ASSERT_NE(ptr, nullptr); - ASSERT_EQ(umaGetLastFailedMemoryProvider(), nullptr); - - // make provider return an error during allocation - allocResult = UMA_RESULT_ERROR_UNKNOWN; - ptr = umaPoolMalloc(pool.get(), allocSize); - ASSERT_EQ(ptr, nullptr); - ASSERT_EQ(std::string_view( - umaMemoryProviderGetName(umaGetLastFailedMemoryProvider())), - "provider1"); - - ret = umaMemoryProviderAlloc(providerUnique2.get(), allocSize, 0, &ptr); - ASSERT_EQ(ptr, nullptr); - ASSERT_EQ(std::string_view( - umaMemoryProviderGetName(umaGetLastFailedMemoryProvider())), - "provider2"); - - // succesfull provider should not be returned by umaGetLastFailedMemoryProvider - allocResult = UMA_RESULT_SUCCESS; - ptr = umaPoolMalloc(pool.get(), allocSize); - ASSERT_NE(ptr, nullptr); - ASSERT_EQ(std::string_view( - umaMemoryProviderGetName(umaGetLastFailedMemoryProvider())), - "provider2"); - - // erorr in another thread should not impact umaGetLastFailedMemoryProvider on this thread - allocResult = UMA_RESULT_ERROR_UNKNOWN; - std::thread t([&, hPool = pool.get()] { - ptr = umaPoolMalloc(hPool, allocSize); - ASSERT_EQ(ptr, nullptr); - ASSERT_EQ(std::string_view(umaMemoryProviderGetName( - umaGetLastFailedMemoryProvider())), - "provider1"); - }); - t.join(); - - ASSERT_EQ(std::string_view( - umaMemoryProviderGetName(umaGetLastFailedMemoryProvider())), - "provider2"); -} diff --git a/test/usm/usmPoolManager.cpp b/test/usm/usmPoolManager.cpp index b244a89c83..eaf44e119d 100644 --- a/test/usm/usmPoolManager.cpp +++ b/test/usm/usmPoolManager.cpp @@ -3,8 +3,8 @@ // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#include "../unified_memory_allocation/common/pool.hpp" -#include "../unified_memory_allocation/common/provider.hpp" +#include "../unified_malloc_framework/common/pool.hpp" +#include "../unified_malloc_framework/common/provider.hpp" #include "ur_pool_manager.hpp" #include From b03c58f8571b04a72e24b48888402d9d785380d6 Mon Sep 17 00:00:00 2001 From: Nicolas Miller Date: Thu, 29 Jun 2023 18:10:44 +0100 Subject: [PATCH 016/104] Fix adapter registry test CMake Using `PROJECT_SOURCE_DIR` instead of `CMAKE_SOURCE_DIR` is more resilient as it will still resolve to the base of the unified runtime repository even if used as a sub-project. --- test/loader/adapter_registry/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/loader/adapter_registry/CMakeLists.txt b/test/loader/adapter_registry/CMakeLists.txt index 01e93b6a72..5481bd8de7 100644 --- a/test/loader/adapter_registry/CMakeLists.txt +++ b/test/loader/adapter_registry/CMakeLists.txt @@ -12,10 +12,10 @@ function(add_adapter_reg_search_test name) if(WIN32) target_sources(${TEST_TARGET_NAME} PRIVATE - ${CMAKE_SOURCE_DIR}/source/loader/windows/adapter_search.cpp) + ${PROJECT_SOURCE_DIR}/source/loader/windows/adapter_search.cpp) else() target_sources(${TEST_TARGET_NAME} PRIVATE - ${CMAKE_SOURCE_DIR}/source/loader/linux/adapter_search.cpp) + ${PROJECT_SOURCE_DIR}/source/loader/linux/adapter_search.cpp) endif() target_link_libraries(${TEST_TARGET_NAME} @@ -25,7 +25,7 @@ function(add_adapter_reg_search_test name) GTest::gtest_main) target_include_directories(${TEST_TARGET_NAME} PRIVATE - ${CMAKE_SOURCE_DIR}/source/loader) + ${PROJECT_SOURCE_DIR}/source/loader) add_test(NAME adapter-reg-${name} COMMAND ${TEST_TARGET_NAME} @@ -35,7 +35,7 @@ function(add_adapter_reg_search_test name) ENVIRONMENT "UR_ADAPTERS_SEARCH_PATH=\"${TEST_SEARCH_PATH}\"" ${TEST_ENVS}) endfunction() -set(TEST_SEARCH_PATH ${CMAKE_SOURCE_DIR}) +set(TEST_SEARCH_PATH ${PROJECT_SOURCE_DIR}) set(TEST_BIN_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) add_adapter_reg_search_test(search-with-env SEARCH_PATH ${TEST_SEARCH_PATH} From 458f62f991b6ba06c41c49f263841465153c4126 Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Tue, 27 Jun 2023 10:26:00 +0100 Subject: [PATCH 017/104] [UR] Support multi-line functions in rst files --- scripts/core/EXP-COMMAND-BUFFER.rst | 11 ++++++++--- scripts/core/PROG.rst | 24 ++++++++++++++++-------- scripts/generate_docs.py | 9 ++++++++- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/scripts/core/EXP-COMMAND-BUFFER.rst b/scripts/core/EXP-COMMAND-BUFFER.rst index 46aa160630..8a83c8a024 100644 --- a/scripts/core/EXP-COMMAND-BUFFER.rst +++ b/scripts/core/EXP-COMMAND-BUFFER.rst @@ -59,7 +59,8 @@ returned list of supported extensions. // Retrieve extension string std::unique_ptr returnedExtensions(new char[returnedSize]); - ${x}DeviceGetInfo(hDevice, ${X}_DEVICE_INFO_EXTENSIONS, returnedSize, returnedExtensions.get(), nullptr); + ${x}DeviceGetInfo(hDevice, ${X}_DEVICE_INFO_EXTENSIONS, returnedSize, + returnedExtensions.get(), nullptr); std::string_view ExtensionsString(returnedExtensions.get()); bool CmdBufferSupport = @@ -117,11 +118,15 @@ were obtained from. // Append a memcpy with no sync-point dependencies ${x}_exp_command_buffer_sync_point_t syncPoint; - ${x}CommandBufferAppendMemcpyUSMExp(hCommandBuffer, pDst, pSrc, size, 0, nullptr, &syncPoint); + ${x}CommandBufferAppendMemcpyUSMExp(hCommandBuffer, pDst, pSrc, size, 0, + nullptr, &syncPoint); // Append a kernel launch with syncPoint as a dependency, ignore returned // sync-point - ${x}CommandBufferAppendKernelLaunchExp(hCommandBuffer, hKernel, workDim, pGlobalWorkOffset, pGlobalWorkSize, pLocalWorkSize, 1, &syncPoint, nullptr); + ${x}CommandBufferAppendKernelLaunchExp(hCommandBuffer, hKernel, workDim, + pGlobalWorkOffset, pGlobalWorkSize, + pLocalWorkSize, 1, &syncPoint, + nullptr); Enqueueing Command-Buffers -------------------------------------------------------------------------------- diff --git a/scripts/core/PROG.rst b/scripts/core/PROG.rst index 280144adcd..4e573f6b27 100644 --- a/scripts/core/PROG.rst +++ b/scripts/core/PROG.rst @@ -60,11 +60,13 @@ Initialization and Discovery // Get number of total GPU devices in the platform uint32_t deviceCount = 0; - ${x}DeviceGet(platforms[0], ${X}_DEVICE_TYPE_GPU, &deviceCount, nullptr, nullptr); + ${x}DeviceGet(platforms[0], ${X}_DEVICE_TYPE_GPU, &deviceCount, nullptr, + nullptr); // Get handles of all GPU devices in the platform std::vector<${x}_device_handle_t> devices(deviceCount); - ${x}DeviceGet(platforms[0], ${X}_DEVICE_TYPE_GPU, &deviceCount, devices.data(), devices.size()); + ${x}DeviceGet(platforms[0], ${X}_DEVICE_TYPE_GPU, &deviceCount, + devices.data(), devices.size()); Device handle lifetime ---------------------- @@ -97,7 +99,8 @@ In case where the info size is only known at runtime then two calls are needed, // Size is known beforehand ${x}_device_type_t deviceType; - ${x}DeviceGetInfo(hDevice, ${X}_DEVICE_INFO_TYPE, sizeof(${x}_device_type_t), &deviceType, nullptr); + ${x}DeviceGetInfo(hDevice, ${X}_DEVICE_INFO_TYPE, + sizeof(${x}_device_type_t), &deviceType, nullptr); // Size is only known at runtime size_t infoSize; @@ -105,7 +108,8 @@ In case where the info size is only known at runtime then two calls are needed, std::string deviceName; DeviceName.resize(infoSize); - ${x}DeviceGetInfo(hDevice, ${X}_DEVICE_INFO_NAME, infoSize, deviceName.data(), nullptr); + ${x}DeviceGetInfo(hDevice, ${X}_DEVICE_INFO_NAME, infoSize, + deviceName.data(), nullptr); Device partitioning into sub-devices ------------------------------------ @@ -133,7 +137,8 @@ fixed part of the parent device, which can explicitly be programmed individually if (count > 0) { subDevices.resize(count); - ${x}DevicePartition(Device, &properties, count, &subDevices.data(), nullptr); + ${x}DevicePartition(Device, &properties, count, &subDevices.data(), + nullptr); } The returned sub-devices may be requested for further partitioning into sub-sub-devices, and so on. @@ -158,7 +163,8 @@ events, and programs are explicitly created against a context. A trivial work wi uint32_t deviceCount = 1; ${x}_device_handle_t hDevice; - ${x}DeviceGet(hPlatform, ${X}_DEVICE_TYPE_GPU, &deviceCount, &hDevice, nullptr); + ${x}DeviceGet(hPlatform, ${X}_DEVICE_TYPE_GPU, &deviceCount, &hDevice, + nullptr); // Create a context ${x}_context_handle_t hContext; @@ -234,14 +240,16 @@ queue is created. // Create an out of order queue for hDevice in hContext ${x}_queue_handle_t hQueue; - ${x}QueueCreate(hContext, hDevice, ${X}_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE, &hQueue); + ${x}QueueCreate(hContext, hDevice, + ${X}_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE, &hQueue); // Lanuch a kernel with 3D workspace partitioning const uint32_t nDim = 3; const size_t gWorkOffset = {0, 0, 0}; const size_t gWorkSize = {128, 128, 128}; const size_t lWorkSize = {1, 8, 8}; - ${x}EnqueueKernelLaunch(hQueue, hKernel, nDim, gWorkOffset, gWorkSize, lWorkSize, 0, nullptr, nullptr); + ${x}EnqueueKernelLaunch(hQueue, hKernel, nDim, gWorkOffset, gWorkSize, + lWorkSize, 0, nullptr, nullptr); Queue object lifetime --------------------- diff --git a/scripts/generate_docs.py b/scripts/generate_docs.py index 4b2ca891d3..c791630322 100644 --- a/scripts/generate_docs.py +++ b/scripts/generate_docs.py @@ -96,7 +96,8 @@ def _generate_valid_rst(fin, fout, namespace, tags, ver, rev, meta): error = False outlines = [] - for iline, line in enumerate(util.textRead(fin)): + iter = enumerate(util.textRead(fin)) + for iline, line in iter: if re.match(RE_ENABLE, line) or re.match(RE_PYCODE_BLOCK_END, line): enable = True @@ -136,6 +137,12 @@ def _generate_valid_rst(fin, fout, namespace, tags, ver, rev, meta): continue if code_block and 'function' == symbol_type: + # If function is split across multiple lines + # then join lines until a ';' is encountered. + line = line.strip() + while not line.endswith(';'): + _, n_line = next(iter) + line = line + n_line.strip() words = re.sub(RE_EXTRACT_PARAMS, r"\1", line) words = line.split(",") if len(words) != len(meta['function'][symbol]['params']): From 78641e75703446c5f63daf11bca4538d7ed29e49 Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Fri, 30 Jun 2023 11:11:18 +0100 Subject: [PATCH 018/104] [UR] Catch iterator exception --- scripts/core/PROG.rst | 2 +- scripts/generate_docs.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/scripts/core/PROG.rst b/scripts/core/PROG.rst index 4e573f6b27..9c97823be1 100644 --- a/scripts/core/PROG.rst +++ b/scripts/core/PROG.rst @@ -243,7 +243,7 @@ queue is created. ${x}QueueCreate(hContext, hDevice, ${X}_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE, &hQueue); - // Lanuch a kernel with 3D workspace partitioning + // Launch a kernel with 3D workspace partitioning const uint32_t nDim = 3; const size_t gWorkOffset = {0, 0, 0}; const size_t gWorkSize = {128, 128, 128}; diff --git a/scripts/generate_docs.py b/scripts/generate_docs.py index c791630322..a17727629e 100644 --- a/scripts/generate_docs.py +++ b/scripts/generate_docs.py @@ -139,10 +139,15 @@ def _generate_valid_rst(fin, fout, namespace, tags, ver, rev, meta): if code_block and 'function' == symbol_type: # If function is split across multiple lines # then join lines until a ';' is encountered. - line = line.strip() - while not line.endswith(';'): - _, n_line = next(iter) - line = line + n_line.strip() + try: + line = line.strip() + while not line.endswith(';'): + _, n_line = next(iter) + line = line + n_line.strip() + except StopIteration: + print(f"Function {line[:100]} was not terminated by a ';' character.") + error = True + words = re.sub(RE_EXTRACT_PARAMS, r"\1", line) words = line.split(",") if len(words) != len(meta['function'][symbol]['params']): From 886c47d1c542f7f6305e4ade8eb4fbb374a92101 Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Thu, 29 Jun 2023 08:05:22 +0100 Subject: [PATCH 019/104] [UR] Correct typos in Virtual Memory --- include/ur_api.h | 4 ++-- scripts/core/virtual_memory.yml | 4 ++-- source/adapters/null/ur_nullddi.cpp | 4 ++-- source/loader/layers/tracing/ur_trcddi.cpp | 4 ++-- source/loader/layers/validation/ur_valddi.cpp | 4 ++-- source/loader/ur_ldrddi.cpp | 4 ++-- source/loader/ur_libapi.cpp | 4 ++-- source/ur_api.cpp | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/ur_api.h b/include/ur_api.h index 5c001e9c22..f2fd31ce39 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -3212,7 +3212,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urVirtualMemSetAccess( ur_context_handle_t hContext, ///< [in] handle to the context object. const void *pStart, ///< [in] pointer to the start of the virtual memory range. - size_t size, ///< [in] size in bytes of the virutal memory range. + size_t size, ///< [in] size in bytes of the virtual memory range. ur_virtual_mem_access_flags_t flags ///< [in] access flags to set for the mapped virtual memory range. ); @@ -3295,7 +3295,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urPhysicalMemCreate( ur_context_handle_t hContext, ///< [in] handle of the context object. ur_device_handle_t hDevice, ///< [in] handle of the device object. - size_t size, ///< [in] size in bytes of phyisical memory to allocate, must be a multiple + size_t size, ///< [in] size in bytes of physical memory to allocate, must be a multiple ///< of ::UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM. const ur_physical_mem_properties_t *pProperties, ///< [in][optional] pointer to physical memory creation properties. ur_physical_mem_handle_t *phPhysicalMem ///< [out] pointer to handle of physical memory object created. diff --git a/scripts/core/virtual_memory.yml b/scripts/core/virtual_memory.yml index c6f707697d..98429ccfd6 100644 --- a/scripts/core/virtual_memory.yml +++ b/scripts/core/virtual_memory.yml @@ -187,7 +187,7 @@ params: desc: "[in] pointer to the start of the virtual memory range." - type: size_t name: size - desc: "[in] size in bytes of the virutal memory range." + desc: "[in] size in bytes of the virtual memory range." - type: $x_virtual_mem_access_flags_t name: flags desc: "[in] access flags to set for the mapped virtual memory range." @@ -273,7 +273,7 @@ params: - type: size_t name: size desc: > - [in] size in bytes of phyisical memory to allocate, must be a + [in] size in bytes of physical memory to allocate, must be a multiple of $X_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM. - type: const $x_physical_mem_properties_t* name: pProperties diff --git a/source/adapters/null/ur_nullddi.cpp b/source/adapters/null/ur_nullddi.cpp index 95b62afb0d..e2c4956c14 100644 --- a/source/adapters/null/ur_nullddi.cpp +++ b/source/adapters/null/ur_nullddi.cpp @@ -1472,7 +1472,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemSetAccess( ur_context_handle_t hContext, ///< [in] handle to the context object. const void *pStart, ///< [in] pointer to the start of the virtual memory range. - size_t size, ///< [in] size in bytes of the virutal memory range. + size_t size, ///< [in] size in bytes of the virtual memory range. ur_virtual_mem_access_flags_t flags ///< [in] access flags to set for the mapped virtual memory range. ) try { @@ -1531,7 +1531,7 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemCreate( ur_context_handle_t hContext, ///< [in] handle of the context object. ur_device_handle_t hDevice, ///< [in] handle of the device object. size_t - size, ///< [in] size in bytes of phyisical memory to allocate, must be a multiple + size, ///< [in] size in bytes of physical memory to allocate, must be a multiple ///< of ::UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM. const ur_physical_mem_properties_t * pProperties, ///< [in][optional] pointer to physical memory creation properties. diff --git a/source/loader/layers/tracing/ur_trcddi.cpp b/source/loader/layers/tracing/ur_trcddi.cpp index 9b6d6b34dc..b66101ddc6 100644 --- a/source/loader/layers/tracing/ur_trcddi.cpp +++ b/source/loader/layers/tracing/ur_trcddi.cpp @@ -1672,7 +1672,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemSetAccess( ur_context_handle_t hContext, ///< [in] handle to the context object. const void *pStart, ///< [in] pointer to the start of the virtual memory range. - size_t size, ///< [in] size in bytes of the virutal memory range. + size_t size, ///< [in] size in bytes of the virtual memory range. ur_virtual_mem_access_flags_t flags ///< [in] access flags to set for the mapped virtual memory range. ) { @@ -1740,7 +1740,7 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemCreate( ur_context_handle_t hContext, ///< [in] handle of the context object. ur_device_handle_t hDevice, ///< [in] handle of the device object. size_t - size, ///< [in] size in bytes of phyisical memory to allocate, must be a multiple + size, ///< [in] size in bytes of physical memory to allocate, must be a multiple ///< of ::UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM. const ur_physical_mem_properties_t * pProperties, ///< [in][optional] pointer to physical memory creation properties. diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index 46ba1e9379..5f7290cb24 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -2056,7 +2056,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemSetAccess( ur_context_handle_t hContext, ///< [in] handle to the context object. const void *pStart, ///< [in] pointer to the start of the virtual memory range. - size_t size, ///< [in] size in bytes of the virutal memory range. + size_t size, ///< [in] size in bytes of the virtual memory range. ur_virtual_mem_access_flags_t flags ///< [in] access flags to set for the mapped virtual memory range. ) { @@ -2135,7 +2135,7 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemCreate( ur_context_handle_t hContext, ///< [in] handle of the context object. ur_device_handle_t hDevice, ///< [in] handle of the device object. size_t - size, ///< [in] size in bytes of phyisical memory to allocate, must be a multiple + size, ///< [in] size in bytes of physical memory to allocate, must be a multiple ///< of ::UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM. const ur_physical_mem_properties_t * pProperties, ///< [in][optional] pointer to physical memory creation properties. diff --git a/source/loader/ur_ldrddi.cpp b/source/loader/ur_ldrddi.cpp index b7176acac2..049f618703 100644 --- a/source/loader/ur_ldrddi.cpp +++ b/source/loader/ur_ldrddi.cpp @@ -1939,7 +1939,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemSetAccess( ur_context_handle_t hContext, ///< [in] handle to the context object. const void *pStart, ///< [in] pointer to the start of the virtual memory range. - size_t size, ///< [in] size in bytes of the virutal memory range. + size_t size, ///< [in] size in bytes of the virtual memory range. ur_virtual_mem_access_flags_t flags ///< [in] access flags to set for the mapped virtual memory range. ) { @@ -2004,7 +2004,7 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemCreate( ur_context_handle_t hContext, ///< [in] handle of the context object. ur_device_handle_t hDevice, ///< [in] handle of the device object. size_t - size, ///< [in] size in bytes of phyisical memory to allocate, must be a multiple + size, ///< [in] size in bytes of physical memory to allocate, must be a multiple ///< of ::UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM. const ur_physical_mem_properties_t * pProperties, ///< [in][optional] pointer to physical memory creation properties. diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index 8e095d05ba..522f03f75f 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -2335,7 +2335,7 @@ ur_result_t UR_APICALL urVirtualMemSetAccess( ur_context_handle_t hContext, ///< [in] handle to the context object. const void *pStart, ///< [in] pointer to the start of the virtual memory range. - size_t size, ///< [in] size in bytes of the virutal memory range. + size_t size, ///< [in] size in bytes of the virtual memory range. ur_virtual_mem_access_flags_t flags ///< [in] access flags to set for the mapped virtual memory range. ) try { @@ -2407,7 +2407,7 @@ ur_result_t UR_APICALL urPhysicalMemCreate( ur_context_handle_t hContext, ///< [in] handle of the context object. ur_device_handle_t hDevice, ///< [in] handle of the device object. size_t - size, ///< [in] size in bytes of phyisical memory to allocate, must be a multiple + size, ///< [in] size in bytes of physical memory to allocate, must be a multiple ///< of ::UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM. const ur_physical_mem_properties_t * pProperties, ///< [in][optional] pointer to physical memory creation properties. diff --git a/source/ur_api.cpp b/source/ur_api.cpp index 89c1271a54..813eea9127 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -1965,7 +1965,7 @@ ur_result_t UR_APICALL urVirtualMemSetAccess( ur_context_handle_t hContext, ///< [in] handle to the context object. const void *pStart, ///< [in] pointer to the start of the virtual memory range. - size_t size, ///< [in] size in bytes of the virutal memory range. + size_t size, ///< [in] size in bytes of the virtual memory range. ur_virtual_mem_access_flags_t flags ///< [in] access flags to set for the mapped virtual memory range. ) { @@ -2024,7 +2024,7 @@ ur_result_t UR_APICALL urPhysicalMemCreate( ur_context_handle_t hContext, ///< [in] handle of the context object. ur_device_handle_t hDevice, ///< [in] handle of the device object. size_t - size, ///< [in] size in bytes of phyisical memory to allocate, must be a multiple + size, ///< [in] size in bytes of physical memory to allocate, must be a multiple ///< of ::UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM. const ur_physical_mem_properties_t * pProperties, ///< [in][optional] pointer to physical memory creation properties. From 1856b518dba7b765357628a86be27573b88043da Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Thu, 29 Jun 2023 08:35:40 +0100 Subject: [PATCH 020/104] [UR][CTS] Add tests for PhysicalMem entry-points --- .../testing/include/uur/fixtures.h | 30 +++++++++++ .../virtual_memory/urPhysicalMemCreate.cpp | 52 +++++++++++++++++++ .../virtual_memory/urPhysicalMemRelease.cpp | 14 +++++ .../virtual_memory/urPhysicalMemRetain.cpp | 14 +++++ 4 files changed, 110 insertions(+) diff --git a/test/conformance/testing/include/uur/fixtures.h b/test/conformance/testing/include/uur/fixtures.h index 09116c9a75..e2ff461ad4 100644 --- a/test/conformance/testing/include/uur/fixtures.h +++ b/test/conformance/testing/include/uur/fixtures.h @@ -643,6 +643,36 @@ template struct urUSMPoolTestWithParam : urContextTestWithParam { ur_usm_pool_handle_t pool; }; +struct urPhysicalMemTest : urContextTest { + + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE(urContextTest::SetUp()); + ASSERT_SUCCESS(urVirtualMemGranularityGetInfo( + context, device, UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM, + sizeof(granularity), &granularity, nullptr)); + size = granularity * 256; + ur_physical_mem_properties_t props{ + UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES, + nullptr, + 0 /*flags*/, + }; + ASSERT_SUCCESS( + urPhysicalMemCreate(context, device, size, &props, &physical_mem)); + ASSERT_NE(physical_mem, nullptr); + } + + void TearDown() { + if (physical_mem) { + EXPECT_SUCCESS(urPhysicalMemRelease(physical_mem)); + } + UUR_RETURN_ON_FATAL_FAILURE(urContextTest::TearDown()); + } + + size_t granularity = 0; + size_t size = 0; + ur_physical_mem_handle_t physical_mem = nullptr; +}; + template struct urUSMDeviceAllocTestWithParam : urQueueTestWithParam { diff --git a/test/conformance/virtual_memory/urPhysicalMemCreate.cpp b/test/conformance/virtual_memory/urPhysicalMemCreate.cpp index 281aa8badb..42396a7999 100644 --- a/test/conformance/virtual_memory/urPhysicalMemCreate.cpp +++ b/test/conformance/virtual_memory/urPhysicalMemCreate.cpp @@ -2,3 +2,55 @@ // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +using urPhysicalMemCreateTestParams = size_t; +struct urPhysicalMemCreateTest + : uur::urContextTestWithParam { + + void SetUp() { + UUR_RETURN_ON_FATAL_FAILURE(uur::urContextTestWithParam< + urPhysicalMemCreateTestParams>::SetUp()); + ASSERT_SUCCESS(urVirtualMemGranularityGetInfo( + context, device, UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM, + sizeof(granularity), &granularity, nullptr)); + ASSERT_NE(granularity, 0); + size = getParam() * granularity; + } + + size_t granularity; + size_t size; +}; + +UUR_TEST_SUITE_P( + urPhysicalMemCreateTest, + ::testing::Values(1, 2, 3, 7, 12, 44, 1024, 4000, 12345), + uur::deviceTestWithParamPrinter); + +TEST_P(urPhysicalMemCreateTest, Success) { + ur_physical_mem_handle_t physical_mem = nullptr; + ASSERT_SUCCESS( + urPhysicalMemCreate(context, device, size, nullptr, &physical_mem)); + ASSERT_NE(physical_mem, nullptr); + EXPECT_SUCCESS(urPhysicalMemRelease(physical_mem)); +} + +TEST_P(urPhysicalMemCreateTest, InvalidNullHandleContext) { + ur_physical_mem_handle_t physical_mem = nullptr; + ASSERT_EQ_RESULT( + urPhysicalMemCreate(nullptr, device, size, nullptr, &physical_mem), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urPhysicalMemCreateTest, InvalidNullHandleDevice) { + ur_physical_mem_handle_t physical_mem = nullptr; + ASSERT_EQ_RESULT( + urPhysicalMemCreate(context, nullptr, size, nullptr, &physical_mem), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urPhysicalMemCreateTest, InvalidNullPointerPhysicalMem) { + ASSERT_EQ_RESULT( + urPhysicalMemCreate(context, device, size, nullptr, nullptr), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} diff --git a/test/conformance/virtual_memory/urPhysicalMemRelease.cpp b/test/conformance/virtual_memory/urPhysicalMemRelease.cpp index 281aa8badb..834a15e50f 100644 --- a/test/conformance/virtual_memory/urPhysicalMemRelease.cpp +++ b/test/conformance/virtual_memory/urPhysicalMemRelease.cpp @@ -2,3 +2,17 @@ // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +using urPhysicalMemReleaseTest = uur::urPhysicalMemTest; +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urPhysicalMemReleaseTest); + +TEST_P(urPhysicalMemReleaseTest, Success) { + ASSERT_SUCCESS(urPhysicalMemRetain(physical_mem)); + ASSERT_SUCCESS(urPhysicalMemRelease(physical_mem)); +} + +TEST_P(urPhysicalMemReleaseTest, InvalidNullHandlePhysicalMem) { + ASSERT_EQ_RESULT(urPhysicalMemRelease(nullptr), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} diff --git a/test/conformance/virtual_memory/urPhysicalMemRetain.cpp b/test/conformance/virtual_memory/urPhysicalMemRetain.cpp index 281aa8badb..a438e1072d 100644 --- a/test/conformance/virtual_memory/urPhysicalMemRetain.cpp +++ b/test/conformance/virtual_memory/urPhysicalMemRetain.cpp @@ -2,3 +2,17 @@ // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +using urPhysicalMemRetainTest = uur::urPhysicalMemTest; +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urPhysicalMemRetainTest); + +TEST_P(urPhysicalMemRetainTest, Success) { + ASSERT_SUCCESS(urPhysicalMemRetain(physical_mem)); + ASSERT_SUCCESS(urPhysicalMemRelease(physical_mem)); +} + +TEST_P(urPhysicalMemRetainTest, InvalidNullHandlePhysicalMem) { + ASSERT_EQ_RESULT(urPhysicalMemRetain(nullptr), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} From 4ab283a99f9d098fb692a1b409b0df5b2607cebd Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Thu, 29 Jun 2023 08:41:39 +0100 Subject: [PATCH 021/104] [UR] Add invalid size check to virtual memory --- include/ur_api.h | 2 ++ scripts/core/virtual_memory.yml | 4 +++- source/loader/ur_libapi.cpp | 2 ++ source/ur_api.cpp | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/ur_api.h b/include/ur_api.h index f2fd31ce39..b6feefbc33 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -3291,6 +3291,8 @@ typedef struct ur_physical_mem_properties_t { /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phPhysicalMem` +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + If size is not a multiple of ::UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM. UR_APIEXPORT ur_result_t UR_APICALL urPhysicalMemCreate( ur_context_handle_t hContext, ///< [in] handle of the context object. diff --git a/scripts/core/virtual_memory.yml b/scripts/core/virtual_memory.yml index 98429ccfd6..ba88d4be2e 100644 --- a/scripts/core/virtual_memory.yml +++ b/scripts/core/virtual_memory.yml @@ -281,7 +281,9 @@ params: - type: $x_physical_mem_handle_t* name: phPhysicalMem desc: "[out] pointer to handle of physical memory object created." - +returns: + - $X_RESULT_ERROR_INVALID_SIZE: + - "If size is not a multiple of $X_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM." --- #-------------------------------------------------------------------------- type: function desc: "Retain a physical memory handle, increment its reference count." diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index 522f03f75f..2f796c4549 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -2403,6 +2403,8 @@ ur_result_t UR_APICALL urVirtualMemGetInfo( /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phPhysicalMem` +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + If size is not a multiple of ::UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM. ur_result_t UR_APICALL urPhysicalMemCreate( ur_context_handle_t hContext, ///< [in] handle of the context object. ur_device_handle_t hDevice, ///< [in] handle of the device object. diff --git a/source/ur_api.cpp b/source/ur_api.cpp index 813eea9127..4a9acfcba4 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -2020,6 +2020,8 @@ ur_result_t UR_APICALL urVirtualMemGetInfo( /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phPhysicalMem` +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + If size is not a multiple of ::UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM. ur_result_t UR_APICALL urPhysicalMemCreate( ur_context_handle_t hContext, ///< [in] handle of the context object. ur_device_handle_t hDevice, ///< [in] handle of the device object. From 046aa470034c6034d41387dc7a608244bfd77d72 Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Thu, 29 Jun 2023 08:46:43 +0100 Subject: [PATCH 022/104] [UR][CTS] Add invalid size test to urPhysicalMemCreate --- test/conformance/testing/include/uur/fixtures.h | 2 +- .../virtual_memory/urPhysicalMemCreate.cpp | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/test/conformance/testing/include/uur/fixtures.h b/test/conformance/testing/include/uur/fixtures.h index e2ff461ad4..54b081c620 100644 --- a/test/conformance/testing/include/uur/fixtures.h +++ b/test/conformance/testing/include/uur/fixtures.h @@ -661,7 +661,7 @@ struct urPhysicalMemTest : urContextTest { ASSERT_NE(physical_mem, nullptr); } - void TearDown() { + void TearDown() override { if (physical_mem) { EXPECT_SUCCESS(urPhysicalMemRelease(physical_mem)); } diff --git a/test/conformance/virtual_memory/urPhysicalMemCreate.cpp b/test/conformance/virtual_memory/urPhysicalMemCreate.cpp index 42396a7999..39059ae0c1 100644 --- a/test/conformance/virtual_memory/urPhysicalMemCreate.cpp +++ b/test/conformance/virtual_memory/urPhysicalMemCreate.cpp @@ -8,7 +8,7 @@ using urPhysicalMemCreateTestParams = size_t; struct urPhysicalMemCreateTest : uur::urContextTestWithParam { - void SetUp() { + void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(uur::urContextTestWithParam< urPhysicalMemCreateTestParams>::SetUp()); ASSERT_SUCCESS(urVirtualMemGranularityGetInfo( @@ -54,3 +54,15 @@ TEST_P(urPhysicalMemCreateTest, InvalidNullPointerPhysicalMem) { urPhysicalMemCreate(context, device, size, nullptr, nullptr), UR_RESULT_ERROR_INVALID_NULL_POINTER); } + +TEST_P(urPhysicalMemCreateTest, InvalidSize) { + if (granularity == 1) { + GTEST_SKIP() + << "A granularity of 1 means that any size will be accepted."; + } + ur_physical_mem_handle_t physical_mem = nullptr; + size_t invalid_size = size - 1; + ASSERT_EQ_RESULT(urPhysicalMemCreate(context, device, invalid_size, nullptr, + &physical_mem), + UR_RESULT_ERROR_INVALID_SIZE); +} From 71c3fc5425abf5c0c6b2ae3348506edb14421584 Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Fri, 30 Jun 2023 12:02:11 +0100 Subject: [PATCH 023/104] [UR] Remove newline after struct decl --- test/conformance/testing/include/uur/fixtures.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/test/conformance/testing/include/uur/fixtures.h b/test/conformance/testing/include/uur/fixtures.h index 54b081c620..dde1eb7277 100644 --- a/test/conformance/testing/include/uur/fixtures.h +++ b/test/conformance/testing/include/uur/fixtures.h @@ -54,7 +54,6 @@ inline bool hasDevicePartitionSupport(ur_device_handle_t device, } struct urAllDevicesTest : urPlatformTest { - void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urPlatformTest::SetUp()); auto devicesPair = GetDevices(platform); @@ -76,7 +75,6 @@ struct urAllDevicesTest : urPlatformTest { struct urDeviceTest : urPlatformTest, ::testing::WithParamInterface { - void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urPlatformTest::SetUp()); device = GetParam(); @@ -138,7 +136,6 @@ struct urContextTest : urDeviceTest { }; struct urSamplerTest : urContextTest { - void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urContextTest::SetUp()); sampler_desc = { @@ -161,7 +158,6 @@ struct urSamplerTest : urContextTest { }; struct urMemBufferTest : urContextTest { - void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urContextTest::SetUp()); ASSERT_SUCCESS(urMemBufferCreate(context, UR_MEM_FLAG_READ_WRITE, 4096, @@ -205,7 +201,6 @@ template struct urContextTestWithParam : urDeviceTestWithParam { }; template struct urSamplerTestWithParam : urContextTestWithParam { - void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urContextTestWithParam::SetUp()); sampler_desc = { @@ -335,7 +330,6 @@ struct urHostPipeTest : urQueueTest { }; template struct urQueueTestWithParam : urContextTestWithParam { - void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urContextTestWithParam::SetUp()); ASSERT_SUCCESS(urQueueCreate(this->context, this->device, 0, &queue)); @@ -624,7 +618,6 @@ struct urUSMPoolTest : urContextTest { }; template struct urUSMPoolTestWithParam : urContextTestWithParam { - void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urContextTestWithParam::SetUp()); ur_usm_pool_desc_t pool_desc{UR_STRUCTURE_TYPE_USM_POOL_DESC, nullptr, @@ -644,7 +637,6 @@ template struct urUSMPoolTestWithParam : urContextTestWithParam { }; struct urPhysicalMemTest : urContextTest { - void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urContextTest::SetUp()); ASSERT_SUCCESS(urVirtualMemGranularityGetInfo( From 8119585efd516702845bc02e7b73290720fefb28 Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Fri, 30 Jun 2023 15:39:33 +0100 Subject: [PATCH 024/104] [UR][UMF] Fix warning from -Wstrict-prototypes --- .../unified_malloc_framework/include/umf/memory_provider.h | 2 +- source/common/unified_malloc_framework/src/memory_provider.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/common/unified_malloc_framework/include/umf/memory_provider.h b/source/common/unified_malloc_framework/include/umf/memory_provider.h index 8a911a62a3..739252b79c 100644 --- a/source/common/unified_malloc_framework/include/umf/memory_provider.h +++ b/source/common/unified_malloc_framework/include/umf/memory_provider.h @@ -148,7 +148,7 @@ const char *umfMemoryProviderGetName(umf_memory_provider_handle_t hProvider); /// returns status other than UMF_RESULT_SUCCESS. /// /// \return Handle to the memory provider -umf_memory_provider_handle_t umfGetLastFailedMemoryProvider(); +umf_memory_provider_handle_t umfGetLastFailedMemoryProvider(void); #ifdef __cplusplus } diff --git a/source/common/unified_malloc_framework/src/memory_provider.c b/source/common/unified_malloc_framework/src/memory_provider.c index 38e4dfbf8b..54554f3f9e 100644 --- a/source/common/unified_malloc_framework/src/memory_provider.c +++ b/source/common/unified_malloc_framework/src/memory_provider.c @@ -127,6 +127,6 @@ const char *umfMemoryProviderGetName(umf_memory_provider_handle_t hProvider) { return hProvider->ops.get_name(hProvider->provider_priv); } -umf_memory_provider_handle_t umfGetLastFailedMemoryProvider() { +umf_memory_provider_handle_t umfGetLastFailedMemoryProvider(void) { return *umfGetLastFailedMemoryProviderPtr(); } From 68c1f3c41d44da79f623372da6bd0745c268acbf Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Mon, 3 Jul 2023 10:28:15 +0100 Subject: [PATCH 025/104] [UR] Fix code-block documentation rendering --- scripts/generate_docs.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/generate_docs.py b/scripts/generate_docs.py index a17727629e..3f28e1b75e 100644 --- a/scripts/generate_docs.py +++ b/scripts/generate_docs.py @@ -140,10 +140,11 @@ def _generate_valid_rst(fin, fout, namespace, tags, ver, rev, meta): # If function is split across multiple lines # then join lines until a ';' is encountered. try: - line = line.strip() + line = line.rstrip() while not line.endswith(';'): _, n_line = next(iter) line = line + n_line.strip() + line += '\n' except StopIteration: print(f"Function {line[:100]} was not terminated by a ';' character.") error = True From c9faea7a0e0e984e590b4050d366286dfcbf0b33 Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Fri, 30 Jun 2023 09:45:09 +0100 Subject: [PATCH 026/104] [UR] Test remaining Virtual Memory entry-points --- .../testing/include/uur/fixtures.h | 123 +++++++++++++++++- test/conformance/testing/include/uur/utils.h | 4 + .../virtual_memory/urPhysicalMemCreate.cpp | 19 +-- .../virtual_memory/urVirtualMemFree.cpp | 19 +++ .../virtual_memory/urVirtualMemGetInfo.cpp | 59 +++++++++ .../virtual_memory/urVirtualMemMap.cpp | 35 +++++ .../virtual_memory/urVirtualMemReserve.cpp | 58 +++++++++ .../virtual_memory/urVirtualMemSetAccess.cpp | 29 +++++ .../virtual_memory/urVirtualMemUnmap.cpp | 20 +++ 9 files changed, 350 insertions(+), 16 deletions(-) diff --git a/test/conformance/testing/include/uur/fixtures.h b/test/conformance/testing/include/uur/fixtures.h index dde1eb7277..65a91d6df7 100644 --- a/test/conformance/testing/include/uur/fixtures.h +++ b/test/conformance/testing/include/uur/fixtures.h @@ -636,12 +636,33 @@ template struct urUSMPoolTestWithParam : urContextTestWithParam { ur_usm_pool_handle_t pool; }; -struct urPhysicalMemTest : urContextTest { +struct urVirtualMemGranularityTest : urContextTest { void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urContextTest::SetUp()); ASSERT_SUCCESS(urVirtualMemGranularityGetInfo( context, device, UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM, sizeof(granularity), &granularity, nullptr)); + } + size_t granularity; +}; + +template +struct urVirtualMemGranularityTestWithParam : urContextTestWithParam { + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE(urContextTestWithParam::SetUp()); + ASSERT_SUCCESS(urVirtualMemGranularityGetInfo( + this->context, this->device, + UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM, sizeof(granularity), + &granularity, nullptr)); + ASSERT_NE(granularity, 0); + } + + size_t granularity = 0; +}; + +struct urPhysicalMemTest : urVirtualMemGranularityTest { + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE(urVirtualMemGranularityTest::SetUp()); size = granularity * 256; ur_physical_mem_properties_t props{ UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES, @@ -657,14 +678,110 @@ struct urPhysicalMemTest : urContextTest { if (physical_mem) { EXPECT_SUCCESS(urPhysicalMemRelease(physical_mem)); } - UUR_RETURN_ON_FATAL_FAILURE(urContextTest::TearDown()); + UUR_RETURN_ON_FATAL_FAILURE(urVirtualMemGranularityTest::TearDown()); + } + + size_t size = 0; + ur_physical_mem_handle_t physical_mem = nullptr; +}; + +template +struct urPhysicalMemTestWithParam : urVirtualMemGranularityTestWithParam { + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE( + urVirtualMemGranularityTestWithParam::SetUp()); + size = this->granularity * 256; + ur_physical_mem_properties_t props{ + UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES, + nullptr, + 0 /*flags*/, + }; + ASSERT_SUCCESS(urPhysicalMemCreate(this->context, this->device, size, + &props, &physical_mem)); + ASSERT_NE(physical_mem, nullptr); + } + + void TearDown() override { + if (physical_mem) { + EXPECT_SUCCESS(urPhysicalMemRelease(physical_mem)); + } + UUR_RETURN_ON_FATAL_FAILURE( + urVirtualMemGranularityTestWithParam::TearDown()); } - size_t granularity = 0; size_t size = 0; ur_physical_mem_handle_t physical_mem = nullptr; }; +struct urVirtualMemTest : urPhysicalMemTest { + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE(urPhysicalMemTest::SetUp()); + ASSERT_SUCCESS( + urVirtualMemReserve(context, nullptr, size, &virtual_ptr)); + ASSERT_NE(virtual_ptr, nullptr); + } + + void TearDown() override { + if (virtual_ptr) { + EXPECT_SUCCESS(urVirtualMemFree(context, virtual_ptr, size)); + } + UUR_RETURN_ON_FATAL_FAILURE(urPhysicalMemTest::TearDown()); + } + + void *virtual_ptr = nullptr; +}; + +template +struct urVirtualMemTestWithParam : urPhysicalMemTestWithParam { + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE(urPhysicalMemTestWithParam::SetUp()); + ASSERT_SUCCESS(urVirtualMemReserve(this->context, nullptr, this->size, + &virtual_ptr)); + } + + void TearDown() override { + if (virtual_ptr) { + EXPECT_SUCCESS( + urVirtualMemFree(this->context, virtual_ptr, this->size)); + } + UUR_RETURN_ON_FATAL_FAILURE(urPhysicalMemTestWithParam::TearDown()); + } + + void *virtual_ptr = nullptr; +}; + +struct urVirtualMemMappedTest : urVirtualMemTest { + + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE(urVirtualMemTest::SetUp()); + ASSERT_SUCCESS(urVirtualMemMap(context, virtual_ptr, size, physical_mem, + 0, + UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE)); + } + + void TearDown() override { + EXPECT_SUCCESS(urVirtualMemUnmap(context, virtual_ptr, size)); + UUR_RETURN_ON_FATAL_FAILURE(urVirtualMemTest::TearDown()); + } +}; + +template +struct urVirtualMemMappedTestWithParam : urVirtualMemTestWithParam { + + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE(urVirtualMemTestWithParam::SetUp()); + ASSERT_SUCCESS(urVirtualMemMap(this->context, this->virtual_ptr, + this->size, this->physical_mem, 0, + UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE)); + } + + void TearDown() override { + EXPECT_SUCCESS( + urVirtualMemUnmap(this->context, this->virtual_ptr, this->size)); + UUR_RETURN_ON_FATAL_FAILURE(urVirtualMemTestWithParam::TearDown()); + } +}; + template struct urUSMDeviceAllocTestWithParam : urQueueTestWithParam { diff --git a/test/conformance/testing/include/uur/utils.h b/test/conformance/testing/include/uur/utils.h index 75e1c51b9c..027e270f25 100644 --- a/test/conformance/testing/include/uur/utils.h +++ b/test/conformance/testing/include/uur/utils.h @@ -14,6 +14,10 @@ namespace uur { +inline size_t RoundUpToNearestFactor(size_t num, size_t factor) { + return ((num + factor - 1) / factor) * factor; +} + /// @brief Make a string a valid identifier for gtest. /// @param str The string to sanitize. inline std::string GTestSanitizeString(const std::string &str) { diff --git a/test/conformance/virtual_memory/urPhysicalMemCreate.cpp b/test/conformance/virtual_memory/urPhysicalMemCreate.cpp index 39059ae0c1..078b0e68db 100644 --- a/test/conformance/virtual_memory/urPhysicalMemCreate.cpp +++ b/test/conformance/virtual_memory/urPhysicalMemCreate.cpp @@ -4,28 +4,21 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include -using urPhysicalMemCreateTestParams = size_t; struct urPhysicalMemCreateTest - : uur::urContextTestWithParam { + : uur::urVirtualMemGranularityTestWithParam { void SetUp() override { - UUR_RETURN_ON_FATAL_FAILURE(uur::urContextTestWithParam< - urPhysicalMemCreateTestParams>::SetUp()); - ASSERT_SUCCESS(urVirtualMemGranularityGetInfo( - context, device, UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM, - sizeof(granularity), &granularity, nullptr)); - ASSERT_NE(granularity, 0); + UUR_RETURN_ON_FATAL_FAILURE( + uur::urVirtualMemGranularityTestWithParam::SetUp()); size = getParam() * granularity; } - size_t granularity; size_t size; }; -UUR_TEST_SUITE_P( - urPhysicalMemCreateTest, - ::testing::Values(1, 2, 3, 7, 12, 44, 1024, 4000, 12345), - uur::deviceTestWithParamPrinter); +UUR_TEST_SUITE_P(urPhysicalMemCreateTest, + ::testing::Values(1, 2, 3, 7, 12, 44, 1024, 4000, 12345), + uur::deviceTestWithParamPrinter); TEST_P(urPhysicalMemCreateTest, Success) { ur_physical_mem_handle_t physical_mem = nullptr; diff --git a/test/conformance/virtual_memory/urVirtualMemFree.cpp b/test/conformance/virtual_memory/urVirtualMemFree.cpp index 281aa8badb..6cb8795547 100644 --- a/test/conformance/virtual_memory/urVirtualMemFree.cpp +++ b/test/conformance/virtual_memory/urVirtualMemFree.cpp @@ -2,3 +2,22 @@ // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +using urVirtualMemFreeTest = uur::urVirtualMemTest; +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urVirtualMemFreeTest); + +TEST_P(urVirtualMemFreeTest, Success) { + ASSERT_SUCCESS(urVirtualMemFree(context, virtual_ptr, size)); + virtual_ptr = nullptr; // set to nullptr to prevent double-free +} + +TEST_P(urVirtualMemFreeTest, InvalidNullHandleContext) { + ASSERT_EQ_RESULT(urVirtualMemFree(nullptr, virtual_ptr, size), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urVirtualMemFreeTest, InvalidNullPointerStart) { + ASSERT_EQ_RESULT(urVirtualMemFree(context, nullptr, size), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} diff --git a/test/conformance/virtual_memory/urVirtualMemGetInfo.cpp b/test/conformance/virtual_memory/urVirtualMemGetInfo.cpp index 281aa8badb..79579e9297 100644 --- a/test/conformance/virtual_memory/urVirtualMemGetInfo.cpp +++ b/test/conformance/virtual_memory/urVirtualMemGetInfo.cpp @@ -2,3 +2,62 @@ // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +using urVirtualMemGetInfoTestWithParam = + uur::urVirtualMemMappedTestWithParam; +UUR_TEST_SUITE_P(urVirtualMemGetInfoTestWithParam, + ::testing::Values(UR_VIRTUAL_MEM_INFO_ACCESS_MODE), + uur::deviceTestWithParamPrinter); + +TEST_P(urVirtualMemGetInfoTestWithParam, Success) { + size_t info_size = 0; + ur_virtual_mem_info_t info = getParam(); + ASSERT_SUCCESS(urVirtualMemGetInfo(context, virtual_ptr, size, info, 0, + nullptr, &info_size)); + ASSERT_NE(info_size, 0); + + std::vector data(info_size); + ASSERT_SUCCESS(urVirtualMemGetInfo(context, virtual_ptr, size, info, + data.size(), data.data(), nullptr)); + + switch (info) { + case UR_VIRTUAL_MEM_INFO_ACCESS_MODE: { + ASSERT_EQ(sizeof(ur_virtual_mem_access_flags_t), data.size()); + ur_virtual_mem_access_flags_t flags = + *reinterpret_cast(data.data()); + ASSERT_TRUE(flags & UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE); + } break; + + default: + FAIL() << "Unhandled ur_virtual_mem_info_t enumeration: " << info; + break; + } +} + +using urVirtualMemGetInfoTest = uur::urVirtualMemMappedTest; +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urVirtualMemGetInfoTest); + +TEST_P(urVirtualMemGetInfoTest, InvalidNullHandleContext) { + ur_virtual_mem_access_flags_t flags = 0; + ASSERT_EQ_RESULT(urVirtualMemGetInfo(nullptr, virtual_ptr, size, + UR_VIRTUAL_MEM_INFO_ACCESS_MODE, + sizeof(flags), &flags, nullptr), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urVirtualMemGetInfoTest, InvalidNullPointerStart) { + ur_virtual_mem_access_flags_t flags = 0; + ASSERT_EQ_RESULT(urVirtualMemGetInfo(context, nullptr, size, + UR_VIRTUAL_MEM_INFO_ACCESS_MODE, + sizeof(flags), &flags, nullptr), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} + +TEST_P(urVirtualMemGetInfoTest, InvalidEnumerationInfo) { + size_t info_size = 0; + ASSERT_EQ_RESULT(urVirtualMemGetInfo(context, virtual_ptr, size, + UR_VIRTUAL_MEM_INFO_FORCE_UINT32, 0, + nullptr, &info_size), + UR_RESULT_ERROR_INVALID_ENUMERATION); +} diff --git a/test/conformance/virtual_memory/urVirtualMemMap.cpp b/test/conformance/virtual_memory/urVirtualMemMap.cpp index 281aa8badb..bed65e2018 100644 --- a/test/conformance/virtual_memory/urVirtualMemMap.cpp +++ b/test/conformance/virtual_memory/urVirtualMemMap.cpp @@ -2,3 +2,38 @@ // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +using urVirtualMemMapTest = uur::urVirtualMemTest; +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urVirtualMemMapTest); + +TEST_P(urVirtualMemMapTest, Success) { + ASSERT_SUCCESS(urVirtualMemMap(context, virtual_ptr, size, physical_mem, 0, + UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE)); + EXPECT_SUCCESS(urVirtualMemUnmap(context, virtual_ptr, size)); +} + +TEST_P(urVirtualMemMapTest, InvalidNullHandleContext) { + ASSERT_EQ_RESULT(urVirtualMemMap(nullptr, virtual_ptr, size, physical_mem, + 0, UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urVirtualMemMapTest, InvalidNullHandlePhysicalMem) { + ASSERT_EQ_RESULT(urVirtualMemMap(context, virtual_ptr, size, nullptr, 0, + UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urVirtualMemMapTest, InvalidNullPointerStart) { + ASSERT_EQ_RESULT(urVirtualMemMap(context, nullptr, size, physical_mem, 0, + UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} + +TEST_P(urVirtualMemMapTest, InvalidEnumerationFlags) { + ASSERT_EQ_RESULT(urVirtualMemMap(context, virtual_ptr, size, physical_mem, + 0, + UR_VIRTUAL_MEM_ACCESS_FLAG_FORCE_UINT32), + UR_RESULT_ERROR_INVALID_ENUMERATION); +} diff --git a/test/conformance/virtual_memory/urVirtualMemReserve.cpp b/test/conformance/virtual_memory/urVirtualMemReserve.cpp index 281aa8badb..7d870dfb05 100644 --- a/test/conformance/virtual_memory/urVirtualMemReserve.cpp +++ b/test/conformance/virtual_memory/urVirtualMemReserve.cpp @@ -2,3 +2,61 @@ // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +using urVirtualMemReserveTestWithParam = + uur::urVirtualMemGranularityTestWithParam; +UUR_TEST_SUITE_P(urVirtualMemReserveTestWithParam, + ::testing::Values(2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, + 2048, 5000, 100000), + uur::deviceTestWithParamPrinter); + +TEST_P(urVirtualMemReserveTestWithParam, SuccessNoStartPointer) { + // round up to nearest granularity + size_t virtual_mem_size = + uur::RoundUpToNearestFactor(getParam(), granularity); + void *virtual_mem_start = nullptr; + ASSERT_SUCCESS(urVirtualMemReserve(context, nullptr, virtual_mem_size, + &virtual_mem_start)); + ASSERT_NE(virtual_mem_start, nullptr); + + EXPECT_SUCCESS( + urVirtualMemFree(context, virtual_mem_start, virtual_mem_size)); +} + +TEST_P(urVirtualMemReserveTestWithParam, SuccessWithStartPointer) { + // roundup to nearest granularity + size_t page_size = uur::RoundUpToNearestFactor(getParam(), granularity); + void *origin_ptr = nullptr; + ASSERT_SUCCESS( + urVirtualMemReserve(context, nullptr, page_size, &origin_ptr)); + ASSERT_NE(origin_ptr, nullptr); + + // try to reserve at the end of origin_ptr + void *virtual_mem_ptr = nullptr; + void *pStart = (uint8_t *)origin_ptr + page_size; + ASSERT_SUCCESS( + urVirtualMemReserve(context, pStart, page_size, &virtual_mem_ptr)); + ASSERT_NE(virtual_mem_ptr, nullptr); + + // both pointers have to be freed + EXPECT_SUCCESS(urVirtualMemFree(context, origin_ptr, page_size)); + EXPECT_SUCCESS(urVirtualMemFree(context, virtual_mem_ptr, page_size)); +} + +using urVirtualMemReserveTest = uur::urVirtualMemGranularityTest; +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urVirtualMemReserveTest); + +TEST_P(urVirtualMemReserveTest, InvalidNullHandleContext) { + size_t page_size = uur::RoundUpToNearestFactor(1024, granularity); + void *virtual_ptr = nullptr; + ASSERT_EQ_RESULT( + urVirtualMemReserve(nullptr, nullptr, page_size, &virtual_ptr), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urVirtualMemReserveTest, InvalidNullPointer) { + size_t page_size = uur::RoundUpToNearestFactor(1024, granularity); + ASSERT_EQ_RESULT(urVirtualMemReserve(context, nullptr, page_size, nullptr), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} diff --git a/test/conformance/virtual_memory/urVirtualMemSetAccess.cpp b/test/conformance/virtual_memory/urVirtualMemSetAccess.cpp index 281aa8badb..7b06ffb6ba 100644 --- a/test/conformance/virtual_memory/urVirtualMemSetAccess.cpp +++ b/test/conformance/virtual_memory/urVirtualMemSetAccess.cpp @@ -2,3 +2,32 @@ // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +using urVirtualMemSetAccessTest = uur::urVirtualMemMappedTest; +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urVirtualMemSetAccessTest); + +TEST_P(urVirtualMemSetAccessTest, Success) { + ASSERT_SUCCESS(urVirtualMemSetAccess(context, virtual_ptr, size, + UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY)); + + ur_virtual_mem_access_flags_t flags = 0; + ASSERT_SUCCESS(urVirtualMemGetInfo(context, virtual_ptr, size, + UR_VIRTUAL_MEM_INFO_ACCESS_MODE, + sizeof(flags), &flags, nullptr)); + ASSERT_TRUE(flags & UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY); +} + +TEST_P(urVirtualMemSetAccessTest, InvalidNullHandleContext) { + ASSERT_EQ_RESULT( + urVirtualMemSetAccess(nullptr, virtual_ptr, size, + UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urVirtualMemSetAccessTest, InvalidNullPointerStart) { + ASSERT_EQ_RESULT( + urVirtualMemSetAccess(context, nullptr, size, + UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} diff --git a/test/conformance/virtual_memory/urVirtualMemUnmap.cpp b/test/conformance/virtual_memory/urVirtualMemUnmap.cpp index 281aa8badb..ae5bbb3050 100644 --- a/test/conformance/virtual_memory/urVirtualMemUnmap.cpp +++ b/test/conformance/virtual_memory/urVirtualMemUnmap.cpp @@ -2,3 +2,23 @@ // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +using urVirtualMemUnmapTest = uur::urVirtualMemTest; +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urVirtualMemUnmapTest); + +TEST_P(urVirtualMemUnmapTest, Success) { + ASSERT_SUCCESS(urVirtualMemMap(context, virtual_ptr, size, physical_mem, 0, + UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE)); + ASSERT_SUCCESS(urVirtualMemUnmap(context, virtual_ptr, size)); +} + +TEST_P(urVirtualMemUnmapTest, InvalidNullHandleContext) { + ASSERT_EQ_RESULT(urVirtualMemUnmap(nullptr, virtual_ptr, size), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urVirtualMemUnmapTest, InvalidNullPointerStart) { + ASSERT_EQ_RESULT(urVirtualMemUnmap(context, nullptr, size), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} From 412c6580aff5539d8a34b59f0220f350a8b64d40 Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Tue, 4 Jul 2023 10:24:42 +0100 Subject: [PATCH 027/104] [UR] Render macros in API Listing --- scripts/templates/api_listing.mako | 44 ++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/scripts/templates/api_listing.mako b/scripts/templates/api_listing.mako index 8a2f3c9833..c9e1015bfc 100644 --- a/scripts/templates/api_listing.mako +++ b/scripts/templates/api_listing.mako @@ -82,6 +82,27 @@ ${title} %endif %endfor # obj in objects +################################################################# +## ------------------------- +## Macros +## ------------------------- + <%isempty = True%> +%for obj in objects: +%if re.match(r"macro", obj['type']): +%if isempty: # only display section title if there is content. +%if needstitle: +<%needstitle = False%> +${title} +============================================================ +%endif +* Macros + +<%isempty = False%> +%endif + * :ref:`${th.make_type_name(n, tags, obj).replace("_", "-")}` +%endif +%endfor # obj in objects + ################################################################# ## Generate API documentation ################################################################# @@ -162,4 +183,27 @@ ${th.make_type_name(n, tags, obj)} %endif %endfor # obj in objects +################################################################# +## ------------------------- +## Macros +## ------------------------- + <%isempty = True%> +%for obj in objects: +%if not re.match(r"macro", obj['type']): +<% continue %> +%endif # macro +%if isempty: +${title} Macros +-------------------------------------------------------------------------------- +<%isempty = False%> +%endif # isempty +.. _${th.make_type_name(n, tags, obj).replace("_", "-")}: + +${th.make_type_name(n, tags, obj)} +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. doxygendefine:: ${th.make_type_name(n, tags, obj)} + :project: UnifiedRuntime +%endfor # obj in objects + %endfor # s in specs From f6f80b883e68b7dd6d1d33815e37e32994ed1287 Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Tue, 4 Jul 2023 10:47:14 +0100 Subject: [PATCH 028/104] [UR] Remove duplicate macro defs --- scripts/templates/api_listing.mako | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/templates/api_listing.mako b/scripts/templates/api_listing.mako index c9e1015bfc..3513f08da9 100644 --- a/scripts/templates/api_listing.mako +++ b/scripts/templates/api_listing.mako @@ -87,8 +87,14 @@ ${title} ## Macros ## ------------------------- <%isempty = True%> + <%seen = list() %> %for obj in objects: %if re.match(r"macro", obj['type']): +%if obj['name'] in seen: + <% continue %> +%else: + <% seen.append(obj['name'])%> +%endif %if isempty: # only display section title if there is content. %if needstitle: <%needstitle = False%> @@ -188,10 +194,16 @@ ${th.make_type_name(n, tags, obj)} ## Macros ## ------------------------- <%isempty = True%> + <%seen = list() %> %for obj in objects: %if not re.match(r"macro", obj['type']): <% continue %> %endif # macro +%if obj['name'] in seen: + <% continue %> +%else: + <% seen.append(obj['name']) %> +%endif %if isempty: ${title} Macros -------------------------------------------------------------------------------- From f4cea5243c146051ecec81c55b0777f3007d7d18 Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Tue, 4 Jul 2023 11:24:24 +0100 Subject: [PATCH 029/104] [UR] Add typedefs to API listings --- scripts/templates/api_listing.mako | 45 ++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/scripts/templates/api_listing.mako b/scripts/templates/api_listing.mako index 3513f08da9..929224abc0 100644 --- a/scripts/templates/api_listing.mako +++ b/scripts/templates/api_listing.mako @@ -109,6 +109,27 @@ ${title} %endif %endfor # obj in objects +################################################################# +## ------------------------- +## Typedefs +## ------------------------- + <%isempty = True%> +%for obj in objects: +%if re.match(r"typedef", obj['type']): +%if isempty: # only display section title if there is content. +%if needstitle: +<%needstitle = False%> +${title} +============================================================ +%endif +* Typedefs + +<%isempty = False%> +%endif + * :ref:`${th.make_type_name(n, tags, obj).replace("_", "-")}` +%endif +%endfor # obj in objects + ################################################################# ## Generate API documentation ################################################################# @@ -218,4 +239,28 @@ ${th.make_type_name(n, tags, obj)} :project: UnifiedRuntime %endfor # obj in objects +################################################################# +## ------------------------- +## Typedefs +## ------------------------- + <%isempty = True%> +%for obj in objects: +%if re.match(r"typedef", obj['type']): +%if isempty: # only display section title if there is content. +${title} Structures +-------------------------------------------------------------------------------- +<%isempty = False%> +%endif +.. _${th.make_type_name(n, tags, obj).replace("_", "-")}: + +${th.make_type_name(n, tags, obj)} +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. doxygentypedef:: ${th.make_type_name(n, tags, obj)} + :project: UnifiedRuntime + + +%endif +%endfor # obj in objects + %endfor # s in specs From f91aa04162574a7b2baab65e7dbdbbd2b6332e0b Mon Sep 17 00:00:00 2001 From: Weronika Lewandowska Date: Tue, 4 Jul 2023 12:49:08 +0200 Subject: [PATCH 030/104] Update sycl/xpti version --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5836eb3fd0..e7b03bb00f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,7 +85,7 @@ if(UR_ENABLE_TRACING) add_compile_definitions(UR_ENABLE_TRACING) # fetch xpti proxy library for the tracing layer - FetchContentSparse_Declare(xpti https://github.com/intel/llvm.git "sycl-nightly/20230304" "xpti") + FetchContentSparse_Declare(xpti https://github.com/intel/llvm.git "sycl-nightly/20230703" "xpti") FetchContent_MakeAvailable(xpti) # set -fPIC for xpti since we are linking it with a shared library From a8cd88a7ac6f414172b812f97dc304987e4fcf84 Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Tue, 4 Jul 2023 12:04:24 +0100 Subject: [PATCH 031/104] [UR] Fix spelling --- include/ur.py | 4 ++-- include/ur_api.h | 16 ++++++++-------- scripts/core/common.yml | 2 +- scripts/core/kernel.yml | 2 +- scripts/core/program.yml | 6 +++--- source/loader/ur_libapi.cpp | 12 ++++++------ source/ur_api.cpp | 12 ++++++------ 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/include/ur.py b/include/ur.py index 0b2ffc286a..2d4247c19a 100644 --- a/include/ur.py +++ b/include/ur.py @@ -142,7 +142,7 @@ class ur_result_v(IntEnum): ERROR_DEVICE_LOST = 20 ## Device hung, reset, was removed, or adapter update occurred ERROR_DEVICE_REQUIRES_RESET = 21 ## Device requires a reset ERROR_DEVICE_IN_LOW_POWER_STATE = 22 ## Device currently in low power state - ERROR_DEVICE_PARTITION_FAILED = 23 ## Device paritioning failed + ERROR_DEVICE_PARTITION_FAILED = 23 ## Device partitioning failed ERROR_INVALID_DEVICE_PARTITION_COUNT = 24 ## Invalid counts provided with ::UR_DEVICE_PARTITION_BY_COUNTS ERROR_INVALID_WORK_ITEM_SIZE = 25 ## Invalid work item size ERROR_INVALID_WORK_DIMENSION = 26 ## Invalid work dimension @@ -1572,7 +1572,7 @@ def __str__(self): ############################################################################### -## @brief Kernel Cache Configuartion. +## @brief Kernel Cache Configuration. class ur_kernel_cache_config_v(IntEnum): DEFAULT = 0 ## No preference for SLM or data cache. LARGE_SLM = 1 ## Large Shared Local Memory (SLM) size. diff --git a/include/ur_api.h b/include/ur_api.h index b6feefbc33..4ad70c9456 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -165,7 +165,7 @@ typedef enum ur_result_t { UR_RESULT_ERROR_DEVICE_LOST = 20, ///< Device hung, reset, was removed, or adapter update occurred UR_RESULT_ERROR_DEVICE_REQUIRES_RESET = 21, ///< Device requires a reset UR_RESULT_ERROR_DEVICE_IN_LOW_POWER_STATE = 22, ///< Device currently in low power state - UR_RESULT_ERROR_DEVICE_PARTITION_FAILED = 23, ///< Device paritioning failed + UR_RESULT_ERROR_DEVICE_PARTITION_FAILED = 23, ///< Device partitioning failed UR_RESULT_ERROR_INVALID_DEVICE_PARTITION_COUNT = 24, ///< Invalid counts provided with ::UR_DEVICE_PARTITION_BY_COUNTS UR_RESULT_ERROR_INVALID_WORK_ITEM_SIZE = 25, ///< Invalid work item size UR_RESULT_ERROR_INVALID_WORK_DIMENSION = 26, ///< Invalid work dimension @@ -3469,7 +3469,7 @@ urProgramCreateWithBinary( /// /// @details /// - The application may call this function from simultaneous threads. -/// - Following a succesful call to this entry point, the program passed +/// - Following a successful call to this entry point, the program passed /// will contain a binary of the ::UR_PROGRAM_BINARY_TYPE_EXECUTABLE type /// for each device in `hContext`. /// @@ -3501,9 +3501,9 @@ urProgramBuild( /// /// @details /// - The application may call this function from simultaneous threads. -/// - Following a succesful call to this entry point `hProgram` will contain -/// a binary of the ::UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT type for each -/// device in `hContext`. +/// - Following a successful call to this entry point `hProgram` will +/// contain a binary of the ::UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT type +/// for each device in `hContext`. /// /// @remarks /// _Analogues_ @@ -3533,8 +3533,8 @@ urProgramCompile( /// /// @details /// - The application may call this function from simultaneous threads. -/// - Following a succesful call to this entry point the program returned in -/// `phProgram` will contain a binary of the +/// - Following a successful call to this entry point the program returned +/// in `phProgram` will contain a binary of the /// ::UR_PROGRAM_BINARY_TYPE_EXECUTABLE type for each device in /// `hContext`. /// @@ -4054,7 +4054,7 @@ typedef enum ur_kernel_sub_group_info_t { } ur_kernel_sub_group_info_t; /////////////////////////////////////////////////////////////////////////////// -/// @brief Kernel Cache Configuartion. +/// @brief Kernel Cache Configuration. typedef enum ur_kernel_cache_config_t { UR_KERNEL_CACHE_CONFIG_DEFAULT = 0, ///< No preference for SLM or data cache. UR_KERNEL_CACHE_CONFIG_LARGE_SLM = 1, ///< Large Shared Local Memory (SLM) size. diff --git a/scripts/core/common.yml b/scripts/core/common.yml index 9797c18ced..c2901f7c68 100644 --- a/scripts/core/common.yml +++ b/scripts/core/common.yml @@ -171,7 +171,7 @@ etors: - name: ERROR_DEVICE_IN_LOW_POWER_STATE desc: "Device currently in low power state" - name: ERROR_DEVICE_PARTITION_FAILED - desc: "Device paritioning failed" + desc: "Device partitioning failed" - name: ERROR_INVALID_DEVICE_PARTITION_COUNT desc: "Invalid counts provided with $X_DEVICE_PARTITION_BY_COUNTS" - name: ERROR_INVALID_WORK_ITEM_SIZE diff --git a/scripts/core/kernel.yml b/scripts/core/kernel.yml index cc659a2c1d..320410926e 100644 --- a/scripts/core/kernel.yml +++ b/scripts/core/kernel.yml @@ -160,7 +160,7 @@ etors: desc: "[uint32_t] Return SubGroup size required by Intel" --- #-------------------------------------------------------------------------- type: enum -desc: "Kernel Cache Configuartion." +desc: "Kernel Cache Configuration." class: $xKernel name: $x_kernel_cache_config_t etors: diff --git a/scripts/core/program.yml b/scripts/core/program.yml index ef548ded22..3ca6764238 100644 --- a/scripts/core/program.yml +++ b/scripts/core/program.yml @@ -159,7 +159,7 @@ analogue: - "**clBuildProgram**" details: - "The application may call this function from simultaneous threads." - - "Following a succesful call to this entry point, the program passed will contain a binary of the $X_PROGRAM_BINARY_TYPE_EXECUTABLE type for each device in `hContext`." + - "Following a successful call to this entry point, the program passed will contain a binary of the $X_PROGRAM_BINARY_TYPE_EXECUTABLE type for each device in `hContext`." params: - type: $x_context_handle_t name: hContext @@ -186,7 +186,7 @@ analogue: - "**clCompileProgram**" details: - "The application may call this function from simultaneous threads." - - "Following a succesful call to this entry point `hProgram` will contain a binary of the $X_PROGRAM_BINARY_TYPE_COMPILED_OBJECT type for each device in `hContext`." + - "Following a successful call to this entry point `hProgram` will contain a binary of the $X_PROGRAM_BINARY_TYPE_COMPILED_OBJECT type for each device in `hContext`." params: - type: $x_context_handle_t name: hContext @@ -213,7 +213,7 @@ analogue: - "**clLinkProgram**" details: - "The application may call this function from simultaneous threads." - - "Following a succesful call to this entry point the program returned in `phProgram` will contain a binary of the $X_PROGRAM_BINARY_TYPE_EXECUTABLE type for each device in `hContext`." + - "Following a successful call to this entry point the program returned in `phProgram` will contain a binary of the $X_PROGRAM_BINARY_TYPE_EXECUTABLE type for each device in `hContext`." params: - type: $x_context_handle_t name: hContext diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index 2f796c4549..238079ebe7 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -2576,7 +2576,7 @@ ur_result_t UR_APICALL urProgramCreateWithBinary( /// /// @details /// - The application may call this function from simultaneous threads. -/// - Following a succesful call to this entry point, the program passed +/// - Following a successful call to this entry point, the program passed /// will contain a binary of the ::UR_PROGRAM_BINARY_TYPE_EXECUTABLE type /// for each device in `hContext`. /// @@ -2617,9 +2617,9 @@ ur_result_t UR_APICALL urProgramBuild( /// /// @details /// - The application may call this function from simultaneous threads. -/// - Following a succesful call to this entry point `hProgram` will contain -/// a binary of the ::UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT type for each -/// device in `hContext`. +/// - Following a successful call to this entry point `hProgram` will +/// contain a binary of the ::UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT type +/// for each device in `hContext`. /// /// @remarks /// _Analogues_ @@ -2659,8 +2659,8 @@ ur_result_t UR_APICALL urProgramCompile( /// /// @details /// - The application may call this function from simultaneous threads. -/// - Following a succesful call to this entry point the program returned in -/// `phProgram` will contain a binary of the +/// - Following a successful call to this entry point the program returned +/// in `phProgram` will contain a binary of the /// ::UR_PROGRAM_BINARY_TYPE_EXECUTABLE type for each device in /// `hContext`. /// diff --git a/source/ur_api.cpp b/source/ur_api.cpp index 4a9acfcba4..4a9b80695a 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -2161,7 +2161,7 @@ ur_result_t UR_APICALL urProgramCreateWithBinary( /// /// @details /// - The application may call this function from simultaneous threads. -/// - Following a succesful call to this entry point, the program passed +/// - Following a successful call to this entry point, the program passed /// will contain a binary of the ::UR_PROGRAM_BINARY_TYPE_EXECUTABLE type /// for each device in `hContext`. /// @@ -2196,9 +2196,9 @@ ur_result_t UR_APICALL urProgramBuild( /// /// @details /// - The application may call this function from simultaneous threads. -/// - Following a succesful call to this entry point `hProgram` will contain -/// a binary of the ::UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT type for each -/// device in `hContext`. +/// - Following a successful call to this entry point `hProgram` will +/// contain a binary of the ::UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT type +/// for each device in `hContext`. /// /// @remarks /// _Analogues_ @@ -2232,8 +2232,8 @@ ur_result_t UR_APICALL urProgramCompile( /// /// @details /// - The application may call this function from simultaneous threads. -/// - Following a succesful call to this entry point the program returned in -/// `phProgram` will contain a binary of the +/// - Following a successful call to this entry point the program returned +/// in `phProgram` will contain a binary of the /// ::UR_PROGRAM_BINARY_TYPE_EXECUTABLE type for each device in /// `hContext`. /// From 558a2e50bebe4adb7accbaba4b5f103c4c80443c Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Mon, 3 Jul 2023 15:04:17 +0100 Subject: [PATCH 032/104] [UR][CTS] Add tests for urEnqueueMemImageCopy Also remove image map and fill test files as they no longer exist in the API --- test/conformance/enqueue/CMakeLists.txt | 2 - .../enqueue/urEnqueueMemImageCopy.cpp | 243 ++++++++++++++++++ .../enqueue/urEnqueueMemImageFill.cpp | 4 - .../enqueue/urEnqueueMemImageMap.cpp | 4 - 4 files changed, 243 insertions(+), 10 deletions(-) delete mode 100644 test/conformance/enqueue/urEnqueueMemImageFill.cpp delete mode 100644 test/conformance/enqueue/urEnqueueMemImageMap.cpp diff --git a/test/conformance/enqueue/CMakeLists.txt b/test/conformance/enqueue/CMakeLists.txt index 48ee69d8f2..2e364b5bdb 100644 --- a/test/conformance/enqueue/CMakeLists.txt +++ b/test/conformance/enqueue/CMakeLists.txt @@ -16,8 +16,6 @@ add_conformance_test_with_kernels_environment(enqueue urEnqueueMemBufferWrite.cpp urEnqueueMemBufferWriteRect.cpp urEnqueueMemImageCopy.cpp - urEnqueueMemImageFill.cpp - urEnqueueMemImageMap.cpp urEnqueueMemImageRead.cpp urEnqueueMemImageWrite.cpp urEnqueueMemUnmap.cpp diff --git a/test/conformance/enqueue/urEnqueueMemImageCopy.cpp b/test/conformance/enqueue/urEnqueueMemImageCopy.cpp index 281aa8badb..d3cb5b566e 100644 --- a/test/conformance/enqueue/urEnqueueMemImageCopy.cpp +++ b/test/conformance/enqueue/urEnqueueMemImageCopy.cpp @@ -2,3 +2,246 @@ // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +struct urEnqueueMemImageCopyTest + : public uur::urQueueTestWithParam { + // Helper type so element offset calculations work the same as pixel offsets + struct rgba_pixel { + uint32_t data[4]; + }; + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE(urQueueTestWithParam::SetUp()); + type = getParam(); + size = (type == UR_MEM_TYPE_IMAGE1D) ? ur_rect_region_t{width, 1, 1} + : (type == UR_MEM_TYPE_IMAGE2D) + ? ur_rect_region_t{width, height, 1} + : ur_rect_region_t{width, height, depth}; + buffSize = size.width * size.height * size.depth; + // Create a region that is half the size on each dimension so we can + // test partial copies of images + partialRegion = { + size.width / 2, + size.height > 1 ? size.height / 2 : 1, + size.depth > 1 ? size.depth / 2 : 1, + }; + // Create an offset that is the centre of the image on each dimension. + // Used with the above region to test partial copies to non-zero offsets + partialRegionOffset = { + size.width / 2, + size.height > 1 ? size.height / 2 : 0, + size.depth > 1 ? size.depth / 2 : 0, + }; + + ur_image_desc_t desc = {UR_STRUCTURE_TYPE_IMAGE_DESC, // stype + nullptr, // pNext + type, // mem object type + size.width, // image width + size.height, // image height + size.depth, // image depth + 1, // array size + 0, // row pitch + 0, // slice pitch + 0, // mip levels + 0}; // num samples + ASSERT_SUCCESS(urMemImageCreate(this->context, UR_MEM_FLAG_READ_WRITE, + &format, &desc, nullptr, &srcImage)); + ASSERT_SUCCESS(urMemImageCreate(this->context, UR_MEM_FLAG_READ_WRITE, + &format, &desc, nullptr, &dstImage)); + input.assign(buffSize, inputFill); + ASSERT_SUCCESS(urEnqueueMemImageWrite(queue, srcImage, true, origin, + size, 0, 0, input.data(), 0, + nullptr, nullptr)); + // Fill the dst image with arbitrary data that is different to the + // input image so we can test partial copies + std::vector dstData(buffSize, outputFill); + ASSERT_SUCCESS(urEnqueueMemImageWrite(queue, dstImage, true, origin, + size, 0, 0, dstData.data(), 0, + nullptr, nullptr)); + } + + void TearDown() override { + if (srcImage) { + EXPECT_SUCCESS(urMemRelease(dstImage)); + } + if (dstImage) { + EXPECT_SUCCESS(urMemRelease(dstImage)); + } + UUR_RETURN_ON_FATAL_FAILURE(urQueueTestWithParam::TearDown()); + } + + const size_t width = 32; + const size_t height = 8; + const size_t depth = 4; + const ur_rect_offset_t origin{0, 0, 0}; + const ur_image_format_t format = {UR_IMAGE_CHANNEL_ORDER_RGBA, + UR_IMAGE_CHANNEL_TYPE_FLOAT}; + const rgba_pixel inputFill = {42, 42, 42, 42}; + const rgba_pixel outputFill = {21, 21, 21, 21}; + + ur_mem_type_t type; + ur_rect_region_t size; + ur_rect_region_t partialRegion; + ur_rect_offset_t partialRegionOffset; + size_t buffSize; + ur_mem_handle_t srcImage = nullptr; + ur_mem_handle_t dstImage = nullptr; + std::vector input; +}; + +bool operator==(urEnqueueMemImageCopyTest::rgba_pixel lhs, + urEnqueueMemImageCopyTest::rgba_pixel rhs) { + return lhs.data[0] == rhs.data[0] && lhs.data[1] == rhs.data[1] && + lhs.data[2] == rhs.data[2] && lhs.data[3] == rhs.data[3]; +} + +template +inline std::string printImageCopyTestString( + const testing::TestParamInfo &info) { + // ParamType will be std::tuple + const auto device_handle = std::get<0>(info.param); + const auto platform_device_name = + uur::GetPlatformAndDeviceName(device_handle); + const auto image_type = std::get<1>(info.param); + auto test_name = (image_type == UR_MEM_TYPE_IMAGE1D) ? "1D" + : (image_type == UR_MEM_TYPE_IMAGE2D) ? "2D" + : "3D"; + return platform_device_name + "__" + test_name; +} + +UUR_TEST_SUITE_P(urEnqueueMemImageCopyTest, + testing::ValuesIn({UR_MEM_TYPE_IMAGE1D, UR_MEM_TYPE_IMAGE2D, + UR_MEM_TYPE_IMAGE3D}), + printImageCopyTestString); + +TEST_P(urEnqueueMemImageCopyTest, Success) { + ASSERT_SUCCESS(urEnqueueMemImageCopy(queue, srcImage, dstImage, {0, 0, 0}, + {0, 0, 0}, size, 0, nullptr, nullptr)); + std::vector output(buffSize, {1, 1, 1, 1}); + ASSERT_SUCCESS(urEnqueueMemImageRead(queue, dstImage, true, origin, size, 0, + 0, output.data(), 0, nullptr, + nullptr)); + ASSERT_EQ(input, output); +} + +TEST_P(urEnqueueMemImageCopyTest, SuccessPartialCopy) { + ASSERT_SUCCESS(urEnqueueMemImageCopy(queue, srcImage, dstImage, {0, 0, 0}, + {0, 0, 0}, partialRegion, 0, nullptr, + nullptr)); + std::vector output(buffSize, {0, 0, 0, 0}); + ASSERT_SUCCESS(urEnqueueMemImageRead(queue, dstImage, true, origin, size, 0, + 0, output.data(), 0, nullptr, + nullptr)); + + // Perform equivalent copy of the region on the host + std::vector expectedOutput(buffSize, outputFill); + for (size_t z = 0; z < partialRegion.depth; z++) { + for (size_t y = 0; y < partialRegion.height; y++) { + for (size_t x = 0; x < partialRegion.width; x++) { + size_t index = + (z * (size.width * size.height)) + (y * size.width) + x; + expectedOutput.data()[index] = input.data()[index]; + } + } + } + + ASSERT_EQ(expectedOutput, output); +} + +TEST_P(urEnqueueMemImageCopyTest, SuccessPartialCopyWithSrcOffset) { + ASSERT_SUCCESS(urEnqueueMemImageCopy(queue, srcImage, dstImage, + partialRegionOffset, {0, 0, 0}, + partialRegion, 0, nullptr, nullptr)); + std::vector output(buffSize, {0, 0, 0, 0}); + ASSERT_SUCCESS(urEnqueueMemImageRead(queue, dstImage, true, origin, size, 0, + 0, output.data(), 0, nullptr, + nullptr)); + + // Perform equivalent copy of the region on the host + std::vector expectedOutput(buffSize, outputFill); + for (size_t z = 0; z < partialRegion.depth; z++) { + for (size_t y = 0; y < partialRegion.height; y++) { + for (size_t x = 0; x < partialRegion.width; x++) { + size_t index = + (z * (size.width * size.height)) + (y * size.width) + x; + expectedOutput.data()[index] = input.data()[index]; + } + } + } + + ASSERT_EQ(expectedOutput, output); +} + +TEST_P(urEnqueueMemImageCopyTest, SuccessPartialCopyWithDstOffset) { + ASSERT_SUCCESS(urEnqueueMemImageCopy(queue, srcImage, dstImage, {0, 0, 0}, + partialRegionOffset, partialRegion, 0, + nullptr, nullptr)); + std::vector output(buffSize, {0, 0, 0, 0}); + ASSERT_SUCCESS(urEnqueueMemImageRead(queue, dstImage, true, origin, size, 0, + 0, output.data(), 0, nullptr, + nullptr)); + + // Perform equivalent copy of the region on the host + std::vector expectedOutput(buffSize, outputFill); + for (size_t z = partialRegionOffset.z; + z < partialRegionOffset.z + partialRegion.depth; z++) { + for (size_t y = partialRegionOffset.y; + y < partialRegionOffset.y + partialRegion.height; y++) { + for (size_t x = partialRegionOffset.x; + x < partialRegionOffset.x + partialRegion.width; x++) { + size_t index = + (z * (size.width * size.height)) + (y * size.width) + x; + expectedOutput.data()[index] = input.data()[index]; + } + } + } + + ASSERT_EQ(expectedOutput, output); +} + +TEST_P(urEnqueueMemImageCopyTest, InvalidNullHandleQueue) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urEnqueueMemImageCopy(nullptr, srcImage, dstImage, + {0, 0, 0}, {0, 0, 0}, size, 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageCopyTest, InvalidNullHandleImageSrc) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urEnqueueMemImageCopy(queue, nullptr, dstImage, {0, 0, 0}, + {0, 0, 0}, size, 0, nullptr, + nullptr)); +} + +TEST_P(urEnqueueMemImageCopyTest, InvalidNullHandleImageDst) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urEnqueueMemImageCopy(queue, srcImage, nullptr, {0, 0, 0}, + {0, 0, 0}, size, 0, nullptr, + nullptr)); +} + +TEST_P(urEnqueueMemImageCopyTest, InvalidNullPtrEventWaitList) { + ASSERT_EQ_RESULT(urEnqueueMemImageCopy(queue, srcImage, dstImage, {0, 0, 0}, + {0, 0, 0}, size, 1, nullptr, + nullptr), + UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST); + + ur_event_handle_t validEvent; + ASSERT_SUCCESS(urEnqueueEventsWait(queue, 0, nullptr, &validEvent)); + + ASSERT_EQ_RESULT(urEnqueueMemImageCopy(queue, srcImage, dstImage, {0, 0, 0}, + {0, 0, 0}, size, 0, &validEvent, + nullptr), + UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST); +} + +TEST_P(urEnqueueMemImageCopyTest, InvalidSize) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urEnqueueMemImageCopy(queue, srcImage, dstImage, {1, 0, 0}, + {0, 0, 0}, size, 0, nullptr, + nullptr)); + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urEnqueueMemImageCopy(queue, srcImage, dstImage, {0, 0, 0}, + {1, 0, 0}, size, 0, nullptr, + nullptr)); +} diff --git a/test/conformance/enqueue/urEnqueueMemImageFill.cpp b/test/conformance/enqueue/urEnqueueMemImageFill.cpp deleted file mode 100644 index 281aa8badb..0000000000 --- a/test/conformance/enqueue/urEnqueueMemImageFill.cpp +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (C) 2023 Intel Corporation -// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. -// See LICENSE.TXT -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception diff --git a/test/conformance/enqueue/urEnqueueMemImageMap.cpp b/test/conformance/enqueue/urEnqueueMemImageMap.cpp deleted file mode 100644 index 281aa8badb..0000000000 --- a/test/conformance/enqueue/urEnqueueMemImageMap.cpp +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (C) 2023 Intel Corporation -// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. -// See LICENSE.TXT -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception From 27eb9ae1fe2e9aa9a5e3d65aec170fafa81bf6b9 Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Tue, 4 Jul 2023 13:04:35 +0100 Subject: [PATCH 033/104] [UR][CTS] Add tests for urPlatformGetApiVersion --- test/conformance/platform/CMakeLists.txt | 1 + .../platform/urPlatformGetApiVersion.cpp | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 test/conformance/platform/urPlatformGetApiVersion.cpp diff --git a/test/conformance/platform/CMakeLists.txt b/test/conformance/platform/CMakeLists.txt index cc87c7366a..e2af409453 100644 --- a/test/conformance/platform/CMakeLists.txt +++ b/test/conformance/platform/CMakeLists.txt @@ -6,6 +6,7 @@ add_conformance_test(platform urInit.cpp urPlatformGet.cpp + urPlatformGetApiVersion.cpp urPlatformGetBackendOption.cpp urPlatformGetInfo.cpp urTearDown.cpp) diff --git a/test/conformance/platform/urPlatformGetApiVersion.cpp b/test/conformance/platform/urPlatformGetApiVersion.cpp new file mode 100644 index 0000000000..10279d560a --- /dev/null +++ b/test/conformance/platform/urPlatformGetApiVersion.cpp @@ -0,0 +1,26 @@ +// Copyright (C) 2022-2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "fixtures.h" + +using urPlatformGetApiVersionTest = uur::platform::urPlatformTest; + +TEST_F(urPlatformGetApiVersionTest, Success) { + ur_api_version_t version; + ASSERT_EQ_RESULT(UR_RESULT_SUCCESS, + urPlatformGetApiVersion(platform, &version)); + ASSERT_GE(UR_API_VERSION_CURRENT, version); +} + +TEST_F(urPlatformGetApiVersionTest, InvalidPlatform) { + ur_api_version_t version; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urPlatformGetApiVersion(nullptr, &version)); +} + +TEST_F(urPlatformGetApiVersionTest, InvalidVersionPtr) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, + urPlatformGetApiVersion(platform, nullptr)); +} From 478f8648d88d8b79f3ef3412812a99a7ef696daa Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Mon, 3 Jul 2023 14:58:39 +0100 Subject: [PATCH 034/104] [UR] Automatically generate ur_structure_type_t --- include/ur.py | 66 ++++---- include/ur_api.h | 66 ++++---- scripts/core/common.yml | 73 --------- scripts/parse_specs.py | 33 +++- source/common/ur_params.hpp | 304 ++++++++++++++++++------------------ 5 files changed, 249 insertions(+), 293 deletions(-) diff --git a/include/ur.py b/include/ur.py index 0b2ffc286a..c19cdacca1 100644 --- a/include/ur.py +++ b/include/ur.py @@ -210,40 +210,40 @@ def __str__(self): ############################################################################### ## @brief Defines structure types class ur_structure_type_v(IntEnum): - CONTEXT_PROPERTIES = 0 ## ::ur_context_properties_t - IMAGE_DESC = 1 ## ::ur_image_desc_t - BUFFER_PROPERTIES = 2 ## ::ur_buffer_properties_t - BUFFER_REGION = 3 ## ::ur_buffer_region_t - BUFFER_CHANNEL_PROPERTIES = 4 ## ::ur_buffer_channel_properties_t - BUFFER_ALLOC_LOCATION_PROPERTIES = 5 ## ::ur_buffer_alloc_location_properties_t - PROGRAM_PROPERTIES = 6 ## ::ur_program_properties_t - USM_DESC = 7 ## ::ur_usm_desc_t - USM_HOST_DESC = 8 ## ::ur_usm_host_desc_t - USM_DEVICE_DESC = 9 ## ::ur_usm_device_desc_t - USM_POOL_DESC = 10 ## ::ur_usm_pool_desc_t - USM_POOL_LIMITS_DESC = 11 ## ::ur_usm_pool_limits_desc_t - DEVICE_BINARY = 12 ## ::ur_device_binary_t - SAMPLER_DESC = 13 ## ::ur_sampler_desc_t - QUEUE_PROPERTIES = 14 ## ::ur_queue_properties_t - QUEUE_INDEX_PROPERTIES = 15 ## ::ur_queue_properties_t - CONTEXT_NATIVE_PROPERTIES = 16 ## ::ur_context_native_properties_t - KERNEL_NATIVE_PROPERTIES = 17 ## ::ur_kernel_native_properties_t - QUEUE_NATIVE_PROPERTIES = 18 ## ::ur_queue_native_properties_t - MEM_NATIVE_PROPERTIES = 19 ## ::ur_mem_native_properties_t - EVENT_NATIVE_PROPERTIES = 20 ## ::ur_event_native_properties_t - PLATFORM_NATIVE_PROPERTIES = 21 ## ::ur_platform_native_properties_t - DEVICE_NATIVE_PROPERTIES = 22 ## ::ur_device_native_properties_t - PROGRAM_NATIVE_PROPERTIES = 23 ## ::ur_program_native_properties_t - SAMPLER_NATIVE_PROPERTIES = 24 ## ::ur_sampler_native_properties_t - QUEUE_NATIVE_DESC = 25 ## ::ur_queue_native_desc_t - DEVICE_PARTITION_PROPERTIES = 26 ## ::ur_device_partition_properties_t + PLATFORM_NATIVE_PROPERTIES = 0 ## ::ur_platform_native_properties_t + DEVICE_BINARY = 1 ## ::ur_device_binary_t + DEVICE_PARTITION_PROPERTIES = 2 ## ::ur_device_partition_properties_t + DEVICE_NATIVE_PROPERTIES = 3 ## ::ur_device_native_properties_t + CONTEXT_PROPERTIES = 4 ## ::ur_context_properties_t + CONTEXT_NATIVE_PROPERTIES = 5 ## ::ur_context_native_properties_t + IMAGE_DESC = 6 ## ::ur_image_desc_t + BUFFER_PROPERTIES = 7 ## ::ur_buffer_properties_t + BUFFER_CHANNEL_PROPERTIES = 8 ## ::ur_buffer_channel_properties_t + BUFFER_ALLOC_LOCATION_PROPERTIES = 9 ## ::ur_buffer_alloc_location_properties_t + BUFFER_REGION = 10 ## ::ur_buffer_region_t + MEM_NATIVE_PROPERTIES = 11 ## ::ur_mem_native_properties_t + SAMPLER_DESC = 12 ## ::ur_sampler_desc_t + SAMPLER_NATIVE_PROPERTIES = 13 ## ::ur_sampler_native_properties_t + USM_DESC = 14 ## ::ur_usm_desc_t + USM_HOST_DESC = 15 ## ::ur_usm_host_desc_t + USM_DEVICE_DESC = 16 ## ::ur_usm_device_desc_t + USM_POOL_DESC = 17 ## ::ur_usm_pool_desc_t + USM_POOL_LIMITS_DESC = 18 ## ::ur_usm_pool_limits_desc_t + PHYSICAL_MEM_PROPERTIES = 19 ## ::ur_physical_mem_properties_t + PROGRAM_PROPERTIES = 20 ## ::ur_program_properties_t + PROGRAM_NATIVE_PROPERTIES = 21 ## ::ur_program_native_properties_t + KERNEL_ARG_VALUE_PROPERTIES = 22 ## ::ur_kernel_arg_value_properties_t + KERNEL_ARG_LOCAL_PROPERTIES = 23 ## ::ur_kernel_arg_local_properties_t + KERNEL_ARG_POINTER_PROPERTIES = 24 ## ::ur_kernel_arg_pointer_properties_t + KERNEL_EXEC_INFO_PROPERTIES = 25 ## ::ur_kernel_exec_info_properties_t + KERNEL_ARG_SAMPLER_PROPERTIES = 26 ## ::ur_kernel_arg_sampler_properties_t KERNEL_ARG_MEM_OBJ_PROPERTIES = 27 ## ::ur_kernel_arg_mem_obj_properties_t - PHYSICAL_MEM_PROPERTIES = 28 ## ::ur_physical_mem_properties_t - KERNEL_ARG_POINTER_PROPERTIES = 29 ## ::ur_kernel_arg_pointer_properties_t - KERNEL_ARG_SAMPLER_PROPERTIES = 30 ## ::ur_kernel_arg_sampler_properties_t - KERNEL_EXEC_INFO_PROPERTIES = 31 ## ::ur_kernel_exec_info_properties_t - KERNEL_ARG_VALUE_PROPERTIES = 32 ## ::ur_kernel_arg_value_properties_t - KERNEL_ARG_LOCAL_PROPERTIES = 33 ## ::ur_kernel_arg_local_properties_t + KERNEL_NATIVE_PROPERTIES = 28 ## ::ur_kernel_native_properties_t + QUEUE_PROPERTIES = 29 ## ::ur_queue_properties_t + QUEUE_INDEX_PROPERTIES = 30 ## ::ur_queue_index_properties_t + QUEUE_NATIVE_DESC = 31 ## ::ur_queue_native_desc_t + QUEUE_NATIVE_PROPERTIES = 32 ## ::ur_queue_native_properties_t + EVENT_NATIVE_PROPERTIES = 33 ## ::ur_event_native_properties_t EXP_COMMAND_BUFFER_DESC = 0x1000 ## ::ur_exp_command_buffer_desc_t EXP_SAMPLER_MIP_PROPERTIES = 0x2000 ## ::ur_exp_sampler_mip_properties_t diff --git a/include/ur_api.h b/include/ur_api.h index b6feefbc33..b9d5290cae 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -233,40 +233,40 @@ typedef enum ur_result_t { /////////////////////////////////////////////////////////////////////////////// /// @brief Defines structure types typedef enum ur_structure_type_t { - UR_STRUCTURE_TYPE_CONTEXT_PROPERTIES = 0, ///< ::ur_context_properties_t - UR_STRUCTURE_TYPE_IMAGE_DESC = 1, ///< ::ur_image_desc_t - UR_STRUCTURE_TYPE_BUFFER_PROPERTIES = 2, ///< ::ur_buffer_properties_t - UR_STRUCTURE_TYPE_BUFFER_REGION = 3, ///< ::ur_buffer_region_t - UR_STRUCTURE_TYPE_BUFFER_CHANNEL_PROPERTIES = 4, ///< ::ur_buffer_channel_properties_t - UR_STRUCTURE_TYPE_BUFFER_ALLOC_LOCATION_PROPERTIES = 5, ///< ::ur_buffer_alloc_location_properties_t - UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES = 6, ///< ::ur_program_properties_t - UR_STRUCTURE_TYPE_USM_DESC = 7, ///< ::ur_usm_desc_t - UR_STRUCTURE_TYPE_USM_HOST_DESC = 8, ///< ::ur_usm_host_desc_t - UR_STRUCTURE_TYPE_USM_DEVICE_DESC = 9, ///< ::ur_usm_device_desc_t - UR_STRUCTURE_TYPE_USM_POOL_DESC = 10, ///< ::ur_usm_pool_desc_t - UR_STRUCTURE_TYPE_USM_POOL_LIMITS_DESC = 11, ///< ::ur_usm_pool_limits_desc_t - UR_STRUCTURE_TYPE_DEVICE_BINARY = 12, ///< ::ur_device_binary_t - UR_STRUCTURE_TYPE_SAMPLER_DESC = 13, ///< ::ur_sampler_desc_t - UR_STRUCTURE_TYPE_QUEUE_PROPERTIES = 14, ///< ::ur_queue_properties_t - UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES = 15, ///< ::ur_queue_properties_t - UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES = 16, ///< ::ur_context_native_properties_t - UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES = 17, ///< ::ur_kernel_native_properties_t - UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES = 18, ///< ::ur_queue_native_properties_t - UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES = 19, ///< ::ur_mem_native_properties_t - UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES = 20, ///< ::ur_event_native_properties_t - UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES = 21, ///< ::ur_platform_native_properties_t - UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES = 22, ///< ::ur_device_native_properties_t - UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES = 23, ///< ::ur_program_native_properties_t - UR_STRUCTURE_TYPE_SAMPLER_NATIVE_PROPERTIES = 24, ///< ::ur_sampler_native_properties_t - UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC = 25, ///< ::ur_queue_native_desc_t - UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES = 26, ///< ::ur_device_partition_properties_t + UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES = 0, ///< ::ur_platform_native_properties_t + UR_STRUCTURE_TYPE_DEVICE_BINARY = 1, ///< ::ur_device_binary_t + UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES = 2, ///< ::ur_device_partition_properties_t + UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES = 3, ///< ::ur_device_native_properties_t + UR_STRUCTURE_TYPE_CONTEXT_PROPERTIES = 4, ///< ::ur_context_properties_t + UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES = 5, ///< ::ur_context_native_properties_t + UR_STRUCTURE_TYPE_IMAGE_DESC = 6, ///< ::ur_image_desc_t + UR_STRUCTURE_TYPE_BUFFER_PROPERTIES = 7, ///< ::ur_buffer_properties_t + UR_STRUCTURE_TYPE_BUFFER_CHANNEL_PROPERTIES = 8, ///< ::ur_buffer_channel_properties_t + UR_STRUCTURE_TYPE_BUFFER_ALLOC_LOCATION_PROPERTIES = 9, ///< ::ur_buffer_alloc_location_properties_t + UR_STRUCTURE_TYPE_BUFFER_REGION = 10, ///< ::ur_buffer_region_t + UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES = 11, ///< ::ur_mem_native_properties_t + UR_STRUCTURE_TYPE_SAMPLER_DESC = 12, ///< ::ur_sampler_desc_t + UR_STRUCTURE_TYPE_SAMPLER_NATIVE_PROPERTIES = 13, ///< ::ur_sampler_native_properties_t + UR_STRUCTURE_TYPE_USM_DESC = 14, ///< ::ur_usm_desc_t + UR_STRUCTURE_TYPE_USM_HOST_DESC = 15, ///< ::ur_usm_host_desc_t + UR_STRUCTURE_TYPE_USM_DEVICE_DESC = 16, ///< ::ur_usm_device_desc_t + UR_STRUCTURE_TYPE_USM_POOL_DESC = 17, ///< ::ur_usm_pool_desc_t + UR_STRUCTURE_TYPE_USM_POOL_LIMITS_DESC = 18, ///< ::ur_usm_pool_limits_desc_t + UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES = 19, ///< ::ur_physical_mem_properties_t + UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES = 20, ///< ::ur_program_properties_t + UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES = 21, ///< ::ur_program_native_properties_t + UR_STRUCTURE_TYPE_KERNEL_ARG_VALUE_PROPERTIES = 22, ///< ::ur_kernel_arg_value_properties_t + UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES = 23, ///< ::ur_kernel_arg_local_properties_t + UR_STRUCTURE_TYPE_KERNEL_ARG_POINTER_PROPERTIES = 24, ///< ::ur_kernel_arg_pointer_properties_t + UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES = 25, ///< ::ur_kernel_exec_info_properties_t + UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES = 26, ///< ::ur_kernel_arg_sampler_properties_t UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES = 27, ///< ::ur_kernel_arg_mem_obj_properties_t - UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES = 28, ///< ::ur_physical_mem_properties_t - UR_STRUCTURE_TYPE_KERNEL_ARG_POINTER_PROPERTIES = 29, ///< ::ur_kernel_arg_pointer_properties_t - UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES = 30, ///< ::ur_kernel_arg_sampler_properties_t - UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES = 31, ///< ::ur_kernel_exec_info_properties_t - UR_STRUCTURE_TYPE_KERNEL_ARG_VALUE_PROPERTIES = 32, ///< ::ur_kernel_arg_value_properties_t - UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES = 33, ///< ::ur_kernel_arg_local_properties_t + UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES = 28, ///< ::ur_kernel_native_properties_t + UR_STRUCTURE_TYPE_QUEUE_PROPERTIES = 29, ///< ::ur_queue_properties_t + UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES = 30, ///< ::ur_queue_index_properties_t + UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC = 31, ///< ::ur_queue_native_desc_t + UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES = 32, ///< ::ur_queue_native_properties_t + UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES = 33, ///< ::ur_event_native_properties_t UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC = 0x1000, ///< ::ur_exp_command_buffer_desc_t UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES = 0x2000, ///< ::ur_exp_sampler_mip_properties_t /// @cond diff --git a/scripts/core/common.yml b/scripts/core/common.yml index 9797c18ced..c53dfb97ba 100644 --- a/scripts/core/common.yml +++ b/scripts/core/common.yml @@ -265,79 +265,6 @@ etors: value: "0x7ffffffe" desc: "Unknown or internal error" --- #-------------------------------------------------------------------------- -type: enum -desc: "Defines structure types" -name: $x_structure_type_t -etors: - - name: CONTEXT_PROPERTIES - desc: $x_context_properties_t - - name: IMAGE_DESC - desc: $x_image_desc_t - - name: BUFFER_PROPERTIES - desc: $x_buffer_properties_t - - name: BUFFER_REGION - desc: $x_buffer_region_t - - name: BUFFER_CHANNEL_PROPERTIES - desc: $x_buffer_channel_properties_t - - name: BUFFER_ALLOC_LOCATION_PROPERTIES - desc: $x_buffer_alloc_location_properties_t - - name: PROGRAM_PROPERTIES - desc: $x_program_properties_t - - name: USM_DESC - desc: $x_usm_desc_t - - name: USM_HOST_DESC - desc: $x_usm_host_desc_t - - name: USM_DEVICE_DESC - desc: $x_usm_device_desc_t - - name: USM_POOL_DESC - desc: $x_usm_pool_desc_t - - name: USM_POOL_LIMITS_DESC - desc: $x_usm_pool_limits_desc_t - - name: DEVICE_BINARY - desc: $x_device_binary_t - - name: SAMPLER_DESC - desc: $x_sampler_desc_t - - name: QUEUE_PROPERTIES - desc: $x_queue_properties_t - - name: QUEUE_INDEX_PROPERTIES - desc: $x_queue_properties_t - - name: CONTEXT_NATIVE_PROPERTIES - desc: $x_context_native_properties_t - - name: KERNEL_NATIVE_PROPERTIES - desc: $x_kernel_native_properties_t - - name: QUEUE_NATIVE_PROPERTIES - desc: $x_queue_native_properties_t - - name: MEM_NATIVE_PROPERTIES - desc: $x_mem_native_properties_t - - name: EVENT_NATIVE_PROPERTIES - desc: $x_event_native_properties_t - - name: PLATFORM_NATIVE_PROPERTIES - desc: $x_platform_native_properties_t - - name: DEVICE_NATIVE_PROPERTIES - desc: $x_device_native_properties_t - - name: PROGRAM_NATIVE_PROPERTIES - desc: $x_program_native_properties_t - - name: SAMPLER_NATIVE_PROPERTIES - desc: $x_sampler_native_properties_t - - name: QUEUE_NATIVE_DESC - desc: $x_queue_native_desc_t - - name: DEVICE_PARTITION_PROPERTIES - desc: $x_device_partition_properties_t - - name: KERNEL_ARG_MEM_OBJ_PROPERTIES - desc: $x_kernel_arg_mem_obj_properties_t - - name: PHYSICAL_MEM_PROPERTIES - desc: $x_physical_mem_properties_t - - name: KERNEL_ARG_POINTER_PROPERTIES - desc: $x_kernel_arg_pointer_properties_t - - name: KERNEL_ARG_SAMPLER_PROPERTIES - desc: $x_kernel_arg_sampler_properties_t - - name: KERNEL_EXEC_INFO_PROPERTIES - desc: $x_kernel_exec_info_properties_t - - name: KERNEL_ARG_VALUE_PROPERTIES - desc: $x_kernel_arg_value_properties_t - - name: KERNEL_ARG_LOCAL_PROPERTIES - desc: $x_kernel_arg_local_properties_t ---- #-------------------------------------------------------------------------- type: struct desc: "Base for all properties types" name: $x_base_properties_t diff --git a/scripts/parse_specs.py b/scripts/parse_specs.py index 63cce5769d..844ee44f19 100644 --- a/scripts/parse_specs.py +++ b/scripts/parse_specs.py @@ -763,6 +763,13 @@ def _append(lst, key, val): obj['returns'] = rets return obj + +def _inline_extended_structs(specs, meta): + for s in specs: + for i, obj in enumerate(s['objects']): + obj = _inline_base(obj, meta) + s['objects'][i] = obj + """ generates extra content """ @@ -770,7 +777,6 @@ def _generate_extra(specs, meta): for s in specs: for i, obj in enumerate(s['objects']): obj = _generate_hash(obj) - obj = _inline_base(obj, meta) obj = _generate_returns(obj, meta) s['objects'][i] = obj @@ -809,7 +815,8 @@ def _refresh_enum_meta(obj, meta): if obj.get('class'): meta['class'][obj['class']]['enum'].remove(obj['name']) - del meta['enum'][obj['name']] + if meta['enum'].get(obj['name']): + del meta['enum'][obj['name']] ## re-generate meta meta = _generate_meta(obj, None, meta) @@ -846,6 +853,26 @@ def sort_etors(x): return value matching_enum['etors'] = sorted(matching_enum['etors'], key=sort_etors) +def _generate_structure_type_t(specs, meta): + extended_structs = [obj for s in specs for obj in s['objects'] if re.match(r"struct|union", obj['type']) and 'base' in obj] + ur_structure_type_t = { + "type": "enum", + "desc": "Defines structure types", + "name": "$x_structure_type_t", + "etors": [] + } + for struct in extended_structs: + if struct['name'].startswith("$x_exp_"): + continue + stype = [mem for mem in struct['members'] if mem['name'] == 'stype'][0] + etor = stype['init'] + ur_structure_type_t['etors'].append({"name": etor, "desc": struct['name']}) + + common_header = [s for s in specs if s['header']['desc'].endswith("common types")][0] + result_t_index = [i for i, obj in enumerate(common_header['objects']) if obj['name'] == "$x_result_t"][0] + common_header['objects'].insert(result_t_index + 1, ur_structure_type_t) + _refresh_enum_meta(ur_structure_type_t, meta) + """ Entry-point: Reads each YML file and extracts data @@ -914,6 +941,8 @@ def parse(section, version, tags, meta, ref): }) specs = sorted(specs, key=lambda s: s['header']['ordinal']) + _inline_extended_structs(specs, meta) + _generate_structure_type_t(specs, meta) _extend_enums(enum_extensions, specs, meta) _generate_extra(specs, meta) diff --git a/source/common/ur_params.hpp b/source/common/ur_params.hpp index 15014813a1..592efb43ad 100644 --- a/source/common/ur_params.hpp +++ b/source/common/ur_params.hpp @@ -693,10 +693,30 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_structure_type_t value) { switch (value) { + case UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_DEVICE_BINARY: + os << "UR_STRUCTURE_TYPE_DEVICE_BINARY"; + break; + + case UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES: + os << "UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES"; + break; + case UR_STRUCTURE_TYPE_CONTEXT_PROPERTIES: os << "UR_STRUCTURE_TYPE_CONTEXT_PROPERTIES"; break; + case UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES"; + break; + case UR_STRUCTURE_TYPE_IMAGE_DESC: os << "UR_STRUCTURE_TYPE_IMAGE_DESC"; break; @@ -705,10 +725,6 @@ inline std::ostream &operator<<(std::ostream &os, os << "UR_STRUCTURE_TYPE_BUFFER_PROPERTIES"; break; - case UR_STRUCTURE_TYPE_BUFFER_REGION: - os << "UR_STRUCTURE_TYPE_BUFFER_REGION"; - break; - case UR_STRUCTURE_TYPE_BUFFER_CHANNEL_PROPERTIES: os << "UR_STRUCTURE_TYPE_BUFFER_CHANNEL_PROPERTIES"; break; @@ -717,8 +733,20 @@ inline std::ostream &operator<<(std::ostream &os, os << "UR_STRUCTURE_TYPE_BUFFER_ALLOC_LOCATION_PROPERTIES"; break; - case UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES: - os << "UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES"; + case UR_STRUCTURE_TYPE_BUFFER_REGION: + os << "UR_STRUCTURE_TYPE_BUFFER_REGION"; + break; + + case UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_SAMPLER_DESC: + os << "UR_STRUCTURE_TYPE_SAMPLER_DESC"; + break; + + case UR_STRUCTURE_TYPE_SAMPLER_NATIVE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_SAMPLER_NATIVE_PROPERTIES"; break; case UR_STRUCTURE_TYPE_USM_DESC: @@ -741,92 +769,64 @@ inline std::ostream &operator<<(std::ostream &os, os << "UR_STRUCTURE_TYPE_USM_POOL_LIMITS_DESC"; break; - case UR_STRUCTURE_TYPE_DEVICE_BINARY: - os << "UR_STRUCTURE_TYPE_DEVICE_BINARY"; - break; - - case UR_STRUCTURE_TYPE_SAMPLER_DESC: - os << "UR_STRUCTURE_TYPE_SAMPLER_DESC"; - break; - - case UR_STRUCTURE_TYPE_QUEUE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_QUEUE_PROPERTIES"; - break; - - case UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES: - os << "UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES"; - break; - - case UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES"; - break; - - case UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES"; - break; - - case UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES"; - break; - - case UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES"; + case UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES: + os << "UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES"; break; - case UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES"; + case UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES: + os << "UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES"; break; - case UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES"; + case UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES"; break; - case UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES"; + case UR_STRUCTURE_TYPE_KERNEL_ARG_VALUE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_KERNEL_ARG_VALUE_PROPERTIES"; break; - case UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES"; + case UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES: + os << "UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES"; break; - case UR_STRUCTURE_TYPE_SAMPLER_NATIVE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_SAMPLER_NATIVE_PROPERTIES"; + case UR_STRUCTURE_TYPE_KERNEL_ARG_POINTER_PROPERTIES: + os << "UR_STRUCTURE_TYPE_KERNEL_ARG_POINTER_PROPERTIES"; break; - case UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC: - os << "UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC"; + case UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES: + os << "UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES"; break; - case UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES: - os << "UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES"; + case UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES: + os << "UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES"; break; case UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES: os << "UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES"; break; - case UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES: - os << "UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES"; + case UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES"; break; - case UR_STRUCTURE_TYPE_KERNEL_ARG_POINTER_PROPERTIES: - os << "UR_STRUCTURE_TYPE_KERNEL_ARG_POINTER_PROPERTIES"; + case UR_STRUCTURE_TYPE_QUEUE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_QUEUE_PROPERTIES"; break; - case UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES: - os << "UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES"; + case UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES: + os << "UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES"; break; - case UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES: - os << "UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES"; + case UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC: + os << "UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC"; break; - case UR_STRUCTURE_TYPE_KERNEL_ARG_VALUE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_KERNEL_ARG_VALUE_PROPERTIES"; + case UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES"; break; - case UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES: - os << "UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES"; + case UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES"; break; case UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC: @@ -852,12 +852,41 @@ inline void serializeStruct(std::ostream &os, const void *ptr) { enum ur_structure_type_t *value = (enum ur_structure_type_t *)ptr; switch (*value) { + case UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES: { + const ur_platform_native_properties_t *pstruct = + (const ur_platform_native_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_DEVICE_BINARY: { + const ur_device_binary_t *pstruct = (const ur_device_binary_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES: { + const ur_device_partition_properties_t *pstruct = + (const ur_device_partition_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES: { + const ur_device_native_properties_t *pstruct = + (const ur_device_native_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + case UR_STRUCTURE_TYPE_CONTEXT_PROPERTIES: { const ur_context_properties_t *pstruct = (const ur_context_properties_t *)ptr; ur_params::serializePtr(os, pstruct); } break; + case UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES: { + const ur_context_native_properties_t *pstruct = + (const ur_context_native_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + case UR_STRUCTURE_TYPE_IMAGE_DESC: { const ur_image_desc_t *pstruct = (const ur_image_desc_t *)ptr; ur_params::serializePtr(os, pstruct); @@ -869,11 +898,6 @@ inline void serializeStruct(std::ostream &os, const void *ptr) { ur_params::serializePtr(os, pstruct); } break; - case UR_STRUCTURE_TYPE_BUFFER_REGION: { - const ur_buffer_region_t *pstruct = (const ur_buffer_region_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; - case UR_STRUCTURE_TYPE_BUFFER_CHANNEL_PROPERTIES: { const ur_buffer_channel_properties_t *pstruct = (const ur_buffer_channel_properties_t *)ptr; @@ -886,9 +910,25 @@ inline void serializeStruct(std::ostream &os, const void *ptr) { ur_params::serializePtr(os, pstruct); } break; - case UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES: { - const ur_program_properties_t *pstruct = - (const ur_program_properties_t *)ptr; + case UR_STRUCTURE_TYPE_BUFFER_REGION: { + const ur_buffer_region_t *pstruct = (const ur_buffer_region_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES: { + const ur_mem_native_properties_t *pstruct = + (const ur_mem_native_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_SAMPLER_DESC: { + const ur_sampler_desc_t *pstruct = (const ur_sampler_desc_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_SAMPLER_NATIVE_PROPERTIES: { + const ur_sampler_native_properties_t *pstruct = + (const ur_sampler_native_properties_t *)ptr; ur_params::serializePtr(os, pstruct); } break; @@ -918,91 +958,51 @@ inline void serializeStruct(std::ostream &os, const void *ptr) { ur_params::serializePtr(os, pstruct); } break; - case UR_STRUCTURE_TYPE_DEVICE_BINARY: { - const ur_device_binary_t *pstruct = (const ur_device_binary_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; - - case UR_STRUCTURE_TYPE_SAMPLER_DESC: { - const ur_sampler_desc_t *pstruct = (const ur_sampler_desc_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; - - case UR_STRUCTURE_TYPE_QUEUE_PROPERTIES: { - const ur_queue_properties_t *pstruct = - (const ur_queue_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; - - case UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES: { - const ur_queue_properties_t *pstruct = - (const ur_queue_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; - - case UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES: { - const ur_context_native_properties_t *pstruct = - (const ur_context_native_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; - - case UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES: { - const ur_kernel_native_properties_t *pstruct = - (const ur_kernel_native_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; - - case UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES: { - const ur_queue_native_properties_t *pstruct = - (const ur_queue_native_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; - - case UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES: { - const ur_mem_native_properties_t *pstruct = - (const ur_mem_native_properties_t *)ptr; + case UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES: { + const ur_physical_mem_properties_t *pstruct = + (const ur_physical_mem_properties_t *)ptr; ur_params::serializePtr(os, pstruct); } break; - case UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES: { - const ur_event_native_properties_t *pstruct = - (const ur_event_native_properties_t *)ptr; + case UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES: { + const ur_program_properties_t *pstruct = + (const ur_program_properties_t *)ptr; ur_params::serializePtr(os, pstruct); } break; - case UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES: { - const ur_platform_native_properties_t *pstruct = - (const ur_platform_native_properties_t *)ptr; + case UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES: { + const ur_program_native_properties_t *pstruct = + (const ur_program_native_properties_t *)ptr; ur_params::serializePtr(os, pstruct); } break; - case UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES: { - const ur_device_native_properties_t *pstruct = - (const ur_device_native_properties_t *)ptr; + case UR_STRUCTURE_TYPE_KERNEL_ARG_VALUE_PROPERTIES: { + const ur_kernel_arg_value_properties_t *pstruct = + (const ur_kernel_arg_value_properties_t *)ptr; ur_params::serializePtr(os, pstruct); } break; - case UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES: { - const ur_program_native_properties_t *pstruct = - (const ur_program_native_properties_t *)ptr; + case UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES: { + const ur_kernel_arg_local_properties_t *pstruct = + (const ur_kernel_arg_local_properties_t *)ptr; ur_params::serializePtr(os, pstruct); } break; - case UR_STRUCTURE_TYPE_SAMPLER_NATIVE_PROPERTIES: { - const ur_sampler_native_properties_t *pstruct = - (const ur_sampler_native_properties_t *)ptr; + case UR_STRUCTURE_TYPE_KERNEL_ARG_POINTER_PROPERTIES: { + const ur_kernel_arg_pointer_properties_t *pstruct = + (const ur_kernel_arg_pointer_properties_t *)ptr; ur_params::serializePtr(os, pstruct); } break; - case UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC: { - const ur_queue_native_desc_t *pstruct = - (const ur_queue_native_desc_t *)ptr; + case UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES: { + const ur_kernel_exec_info_properties_t *pstruct = + (const ur_kernel_exec_info_properties_t *)ptr; ur_params::serializePtr(os, pstruct); } break; - case UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES: { - const ur_device_partition_properties_t *pstruct = - (const ur_device_partition_properties_t *)ptr; + case UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES: { + const ur_kernel_arg_sampler_properties_t *pstruct = + (const ur_kernel_arg_sampler_properties_t *)ptr; ur_params::serializePtr(os, pstruct); } break; @@ -1012,39 +1012,39 @@ inline void serializeStruct(std::ostream &os, const void *ptr) { ur_params::serializePtr(os, pstruct); } break; - case UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES: { - const ur_physical_mem_properties_t *pstruct = - (const ur_physical_mem_properties_t *)ptr; + case UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES: { + const ur_kernel_native_properties_t *pstruct = + (const ur_kernel_native_properties_t *)ptr; ur_params::serializePtr(os, pstruct); } break; - case UR_STRUCTURE_TYPE_KERNEL_ARG_POINTER_PROPERTIES: { - const ur_kernel_arg_pointer_properties_t *pstruct = - (const ur_kernel_arg_pointer_properties_t *)ptr; + case UR_STRUCTURE_TYPE_QUEUE_PROPERTIES: { + const ur_queue_properties_t *pstruct = + (const ur_queue_properties_t *)ptr; ur_params::serializePtr(os, pstruct); } break; - case UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES: { - const ur_kernel_arg_sampler_properties_t *pstruct = - (const ur_kernel_arg_sampler_properties_t *)ptr; + case UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES: { + const ur_queue_index_properties_t *pstruct = + (const ur_queue_index_properties_t *)ptr; ur_params::serializePtr(os, pstruct); } break; - case UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES: { - const ur_kernel_exec_info_properties_t *pstruct = - (const ur_kernel_exec_info_properties_t *)ptr; + case UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC: { + const ur_queue_native_desc_t *pstruct = + (const ur_queue_native_desc_t *)ptr; ur_params::serializePtr(os, pstruct); } break; - case UR_STRUCTURE_TYPE_KERNEL_ARG_VALUE_PROPERTIES: { - const ur_kernel_arg_value_properties_t *pstruct = - (const ur_kernel_arg_value_properties_t *)ptr; + case UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES: { + const ur_queue_native_properties_t *pstruct = + (const ur_queue_native_properties_t *)ptr; ur_params::serializePtr(os, pstruct); } break; - case UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES: { - const ur_kernel_arg_local_properties_t *pstruct = - (const ur_kernel_arg_local_properties_t *)ptr; + case UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES: { + const ur_event_native_properties_t *pstruct = + (const ur_event_native_properties_t *)ptr; ur_params::serializePtr(os, pstruct); } break; From bd76766d985627aa7bb629e4e5ec835542051352 Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Mon, 3 Jul 2023 16:52:13 +0100 Subject: [PATCH 035/104] [UR] Integrate registry.yml --- include/ur.py | 438 +- include/ur_api.h | 452 +- scripts/core/registry.yml | 109 +- scripts/generate_ids.py | 24 +- scripts/parse_specs.py | 59 +- source/common/ur_params.hpp | 10944 +++++++++++++++++----------------- 6 files changed, 6085 insertions(+), 5941 deletions(-) diff --git a/include/ur.py b/include/ur.py index c19cdacca1..f37827de89 100644 --- a/include/ur.py +++ b/include/ur.py @@ -19,6 +19,225 @@ ############################################################################### __version__ = "1.0" +############################################################################### +## @brief Defines unique stable identifiers for all functions +class ur_function_v(IntEnum): + CONTEXT_CREATE = 1 ## Enumerator for ::urContextCreate + CONTEXT_RETAIN = 2 ## Enumerator for ::urContextRetain + CONTEXT_RELEASE = 3 ## Enumerator for ::urContextRelease + CONTEXT_GET_INFO = 4 ## Enumerator for ::urContextGetInfo + CONTEXT_GET_NATIVE_HANDLE = 5 ## Enumerator for ::urContextGetNativeHandle + CONTEXT_CREATE_WITH_NATIVE_HANDLE = 6 ## Enumerator for ::urContextCreateWithNativeHandle + CONTEXT_SET_EXTENDED_DELETER = 7 ## Enumerator for ::urContextSetExtendedDeleter + DEVICE_GET = 8 ## Enumerator for ::urDeviceGet + DEVICE_GET_INFO = 9 ## Enumerator for ::urDeviceGetInfo + DEVICE_RETAIN = 10 ## Enumerator for ::urDeviceRetain + DEVICE_RELEASE = 11 ## Enumerator for ::urDeviceRelease + DEVICE_PARTITION = 12 ## Enumerator for ::urDevicePartition + DEVICE_SELECT_BINARY = 13 ## Enumerator for ::urDeviceSelectBinary + DEVICE_GET_NATIVE_HANDLE = 14 ## Enumerator for ::urDeviceGetNativeHandle + DEVICE_CREATE_WITH_NATIVE_HANDLE = 15 ## Enumerator for ::urDeviceCreateWithNativeHandle + DEVICE_GET_GLOBAL_TIMESTAMPS = 16 ## Enumerator for ::urDeviceGetGlobalTimestamps + ENQUEUE_KERNEL_LAUNCH = 17 ## Enumerator for ::urEnqueueKernelLaunch + ENQUEUE_EVENTS_WAIT = 18 ## Enumerator for ::urEnqueueEventsWait + ENQUEUE_EVENTS_WAIT_WITH_BARRIER = 19 ## Enumerator for ::urEnqueueEventsWaitWithBarrier + ENQUEUE_MEM_BUFFER_READ = 20 ## Enumerator for ::urEnqueueMemBufferRead + ENQUEUE_MEM_BUFFER_WRITE = 21 ## Enumerator for ::urEnqueueMemBufferWrite + ENQUEUE_MEM_BUFFER_READ_RECT = 22 ## Enumerator for ::urEnqueueMemBufferReadRect + ENQUEUE_MEM_BUFFER_WRITE_RECT = 23 ## Enumerator for ::urEnqueueMemBufferWriteRect + ENQUEUE_MEM_BUFFER_COPY = 24 ## Enumerator for ::urEnqueueMemBufferCopy + ENQUEUE_MEM_BUFFER_COPY_RECT = 25 ## Enumerator for ::urEnqueueMemBufferCopyRect + ENQUEUE_MEM_BUFFER_FILL = 26 ## Enumerator for ::urEnqueueMemBufferFill + ENQUEUE_MEM_IMAGE_READ = 27 ## Enumerator for ::urEnqueueMemImageRead + ENQUEUE_MEM_IMAGE_WRITE = 28 ## Enumerator for ::urEnqueueMemImageWrite + ENQUEUE_MEM_IMAGE_COPY = 29 ## Enumerator for ::urEnqueueMemImageCopy + ENQUEUE_MEM_BUFFER_MAP = 30 ## Enumerator for ::urEnqueueMemBufferMap + ENQUEUE_MEM_UNMAP = 31 ## Enumerator for ::urEnqueueMemUnmap + ENQUEUE_USM_FILL = 32 ## Enumerator for ::urEnqueueUSMFill + ENQUEUE_USM_MEMCPY = 33 ## Enumerator for ::urEnqueueUSMMemcpy + ENQUEUE_USM_PREFETCH = 34 ## Enumerator for ::urEnqueueUSMPrefetch + ENQUEUE_USM_ADVISE = 35 ## Enumerator for ::urEnqueueUSMAdvise + ENQUEUE_DEVICE_GLOBAL_VARIABLE_WRITE = 38 ## Enumerator for ::urEnqueueDeviceGlobalVariableWrite + ENQUEUE_DEVICE_GLOBAL_VARIABLE_READ = 39 ## Enumerator for ::urEnqueueDeviceGlobalVariableRead + EVENT_GET_INFO = 40 ## Enumerator for ::urEventGetInfo + EVENT_GET_PROFILING_INFO = 41 ## Enumerator for ::urEventGetProfilingInfo + EVENT_WAIT = 42 ## Enumerator for ::urEventWait + EVENT_RETAIN = 43 ## Enumerator for ::urEventRetain + EVENT_RELEASE = 44 ## Enumerator for ::urEventRelease + EVENT_GET_NATIVE_HANDLE = 45 ## Enumerator for ::urEventGetNativeHandle + EVENT_CREATE_WITH_NATIVE_HANDLE = 46 ## Enumerator for ::urEventCreateWithNativeHandle + EVENT_SET_CALLBACK = 47 ## Enumerator for ::urEventSetCallback + KERNEL_CREATE = 48 ## Enumerator for ::urKernelCreate + KERNEL_SET_ARG_VALUE = 49 ## Enumerator for ::urKernelSetArgValue + KERNEL_SET_ARG_LOCAL = 50 ## Enumerator for ::urKernelSetArgLocal + KERNEL_GET_INFO = 51 ## Enumerator for ::urKernelGetInfo + KERNEL_GET_GROUP_INFO = 52 ## Enumerator for ::urKernelGetGroupInfo + KERNEL_GET_SUB_GROUP_INFO = 53 ## Enumerator for ::urKernelGetSubGroupInfo + KERNEL_RETAIN = 54 ## Enumerator for ::urKernelRetain + KERNEL_RELEASE = 55 ## Enumerator for ::urKernelRelease + KERNEL_SET_ARG_POINTER = 56 ## Enumerator for ::urKernelSetArgPointer + KERNEL_SET_EXEC_INFO = 57 ## Enumerator for ::urKernelSetExecInfo + KERNEL_SET_ARG_SAMPLER = 58 ## Enumerator for ::urKernelSetArgSampler + KERNEL_SET_ARG_MEM_OBJ = 59 ## Enumerator for ::urKernelSetArgMemObj + KERNEL_SET_SPECIALIZATION_CONSTANTS = 60 ## Enumerator for ::urKernelSetSpecializationConstants + KERNEL_GET_NATIVE_HANDLE = 61 ## Enumerator for ::urKernelGetNativeHandle + KERNEL_CREATE_WITH_NATIVE_HANDLE = 62 ## Enumerator for ::urKernelCreateWithNativeHandle + MEM_IMAGE_CREATE = 63 ## Enumerator for ::urMemImageCreate + MEM_BUFFER_CREATE = 64 ## Enumerator for ::urMemBufferCreate + MEM_RETAIN = 65 ## Enumerator for ::urMemRetain + MEM_RELEASE = 66 ## Enumerator for ::urMemRelease + MEM_BUFFER_PARTITION = 67 ## Enumerator for ::urMemBufferPartition + MEM_GET_NATIVE_HANDLE = 68 ## Enumerator for ::urMemGetNativeHandle + ENQUEUE_READ_HOST_PIPE = 69 ## Enumerator for ::urEnqueueReadHostPipe + MEM_GET_INFO = 70 ## Enumerator for ::urMemGetInfo + MEM_IMAGE_GET_INFO = 71 ## Enumerator for ::urMemImageGetInfo + PLATFORM_GET = 72 ## Enumerator for ::urPlatformGet + PLATFORM_GET_INFO = 73 ## Enumerator for ::urPlatformGetInfo + PLATFORM_GET_API_VERSION = 74 ## Enumerator for ::urPlatformGetApiVersion + PLATFORM_GET_NATIVE_HANDLE = 75 ## Enumerator for ::urPlatformGetNativeHandle + PLATFORM_CREATE_WITH_NATIVE_HANDLE = 76 ## Enumerator for ::urPlatformCreateWithNativeHandle + PROGRAM_CREATE_WITH_IL = 78 ## Enumerator for ::urProgramCreateWithIL + PROGRAM_CREATE_WITH_BINARY = 79 ## Enumerator for ::urProgramCreateWithBinary + PROGRAM_BUILD = 80 ## Enumerator for ::urProgramBuild + PROGRAM_COMPILE = 81 ## Enumerator for ::urProgramCompile + PROGRAM_LINK = 82 ## Enumerator for ::urProgramLink + PROGRAM_RETAIN = 83 ## Enumerator for ::urProgramRetain + PROGRAM_RELEASE = 84 ## Enumerator for ::urProgramRelease + PROGRAM_GET_FUNCTION_POINTER = 85 ## Enumerator for ::urProgramGetFunctionPointer + PROGRAM_GET_INFO = 86 ## Enumerator for ::urProgramGetInfo + PROGRAM_GET_BUILD_INFO = 87 ## Enumerator for ::urProgramGetBuildInfo + PROGRAM_SET_SPECIALIZATION_CONSTANTS = 88 ## Enumerator for ::urProgramSetSpecializationConstants + PROGRAM_GET_NATIVE_HANDLE = 89 ## Enumerator for ::urProgramGetNativeHandle + PROGRAM_CREATE_WITH_NATIVE_HANDLE = 90 ## Enumerator for ::urProgramCreateWithNativeHandle + QUEUE_GET_INFO = 91 ## Enumerator for ::urQueueGetInfo + QUEUE_CREATE = 92 ## Enumerator for ::urQueueCreate + QUEUE_RETAIN = 93 ## Enumerator for ::urQueueRetain + QUEUE_RELEASE = 94 ## Enumerator for ::urQueueRelease + QUEUE_GET_NATIVE_HANDLE = 95 ## Enumerator for ::urQueueGetNativeHandle + QUEUE_CREATE_WITH_NATIVE_HANDLE = 96 ## Enumerator for ::urQueueCreateWithNativeHandle + QUEUE_FINISH = 97 ## Enumerator for ::urQueueFinish + QUEUE_FLUSH = 98 ## Enumerator for ::urQueueFlush + INIT = 99 ## Enumerator for ::urInit + TEAR_DOWN = 100 ## Enumerator for ::urTearDown + SAMPLER_CREATE = 101 ## Enumerator for ::urSamplerCreate + SAMPLER_RETAIN = 102 ## Enumerator for ::urSamplerRetain + SAMPLER_RELEASE = 103 ## Enumerator for ::urSamplerRelease + SAMPLER_GET_INFO = 104 ## Enumerator for ::urSamplerGetInfo + SAMPLER_GET_NATIVE_HANDLE = 105 ## Enumerator for ::urSamplerGetNativeHandle + SAMPLER_CREATE_WITH_NATIVE_HANDLE = 106 ## Enumerator for ::urSamplerCreateWithNativeHandle + USM_HOST_ALLOC = 107 ## Enumerator for ::urUSMHostAlloc + USM_DEVICE_ALLOC = 108 ## Enumerator for ::urUSMDeviceAlloc + USM_SHARED_ALLOC = 109 ## Enumerator for ::urUSMSharedAlloc + USM_FREE = 110 ## Enumerator for ::urUSMFree + USM_GET_MEM_ALLOC_INFO = 111 ## Enumerator for ::urUSMGetMemAllocInfo + USM_POOL_CREATE = 112 ## Enumerator for ::urUSMPoolCreate + COMMAND_BUFFER_CREATE_EXP = 113 ## Enumerator for ::urCommandBufferCreateExp + PLATFORM_GET_BACKEND_OPTION = 114 ## Enumerator for ::urPlatformGetBackendOption + MEM_BUFFER_CREATE_WITH_NATIVE_HANDLE = 115 ## Enumerator for ::urMemBufferCreateWithNativeHandle + MEM_IMAGE_CREATE_WITH_NATIVE_HANDLE = 116 ## Enumerator for ::urMemImageCreateWithNativeHandle + ENQUEUE_WRITE_HOST_PIPE = 117 ## Enumerator for ::urEnqueueWriteHostPipe + USM_POOL_RETAIN = 118 ## Enumerator for ::urUSMPoolRetain + USM_POOL_RELEASE = 119 ## Enumerator for ::urUSMPoolRelease + USM_POOL_GET_INFO = 120 ## Enumerator for ::urUSMPoolGetInfo + COMMAND_BUFFER_RETAIN_EXP = 121 ## Enumerator for ::urCommandBufferRetainExp + COMMAND_BUFFER_RELEASE_EXP = 122 ## Enumerator for ::urCommandBufferReleaseExp + COMMAND_BUFFER_FINALIZE_EXP = 123 ## Enumerator for ::urCommandBufferFinalizeExp + COMMAND_BUFFER_APPEND_KERNEL_LAUNCH_EXP = 125 ## Enumerator for ::urCommandBufferAppendKernelLaunchExp + COMMAND_BUFFER_ENQUEUE_EXP = 128 ## Enumerator for ::urCommandBufferEnqueueExp + COMMAND_BUFFER_APPEND_MEMCPY_USM_EXP = 129 ## Enumerator for ::urCommandBufferAppendMemcpyUSMExp + COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_EXP = 130 ## Enumerator for ::urCommandBufferAppendMembufferCopyExp + COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_RECT_EXP = 131 ## Enumerator for ::urCommandBufferAppendMembufferCopyRectExp + USM_PITCHED_ALLOC_EXP = 132 ## Enumerator for ::urUSMPitchedAllocExp + BINDLESS_IMAGES_UNSAMPLED_IMAGE_HANDLE_DESTROY_EXP = 133## Enumerator for ::urBindlessImagesUnsampledImageHandleDestroyExp + BINDLESS_IMAGES_SAMPLED_IMAGE_HANDLE_DESTROY_EXP = 134 ## Enumerator for ::urBindlessImagesSampledImageHandleDestroyExp + BINDLESS_IMAGES_IMAGE_ALLOCATE_EXP = 135 ## Enumerator for ::urBindlessImagesImageAllocateExp + BINDLESS_IMAGES_IMAGE_FREE_EXP = 136 ## Enumerator for ::urBindlessImagesImageFreeExp + BINDLESS_IMAGES_UNSAMPLED_IMAGE_CREATE_EXP = 137## Enumerator for ::urBindlessImagesUnsampledImageCreateExp + BINDLESS_IMAGES_SAMPLED_IMAGE_CREATE_EXP = 138 ## Enumerator for ::urBindlessImagesSampledImageCreateExp + BINDLESS_IMAGES_IMAGE_COPY_EXP = 139 ## Enumerator for ::urBindlessImagesImageCopyExp + BINDLESS_IMAGES_IMAGE_GET_INFO_EXP = 140 ## Enumerator for ::urBindlessImagesImageGetInfoExp + BINDLESS_IMAGES_MIPMAP_GET_LEVEL_EXP = 141 ## Enumerator for ::urBindlessImagesMipmapGetLevelExp + BINDLESS_IMAGES_MIPMAP_FREE_EXP = 142 ## Enumerator for ::urBindlessImagesMipmapFreeExp + BINDLESS_IMAGES_IMPORT_OPAQUE_FD_EXP = 143 ## Enumerator for ::urBindlessImagesImportOpaqueFDExp + BINDLESS_IMAGES_MAP_EXTERNAL_ARRAY_EXP = 144 ## Enumerator for ::urBindlessImagesMapExternalArrayExp + BINDLESS_IMAGES_RELEASE_INTEROP_EXP = 145 ## Enumerator for ::urBindlessImagesReleaseInteropExp + BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXP = 146 ## Enumerator for ::urBindlessImagesImportExternalSemaphoreOpaqueFDExp + BINDLESS_IMAGES_DESTROY_EXTERNAL_SEMAPHORE_EXP = 147## Enumerator for ::urBindlessImagesDestroyExternalSemaphoreExp + BINDLESS_IMAGES_WAIT_EXTERNAL_SEMAPHORE_EXP = 148 ## Enumerator for ::urBindlessImagesWaitExternalSemaphoreExp + BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP = 149 ## Enumerator for ::urBindlessImagesSignalExternalSemaphoreExp + PLATFORM_GET_LAST_ERROR = 150 ## Enumerator for ::urPlatformGetLastError + ENQUEUE_USM_FILL_2D = 151 ## Enumerator for ::urEnqueueUSMFill2D + ENQUEUE_USM_MEMCPY_2D = 152 ## Enumerator for ::urEnqueueUSMMemcpy2D + VIRTUAL_MEM_GRANULARITY_GET_INFO = 153 ## Enumerator for ::urVirtualMemGranularityGetInfo + VIRTUAL_MEM_RESERVE = 154 ## Enumerator for ::urVirtualMemReserve + VIRTUAL_MEM_FREE = 155 ## Enumerator for ::urVirtualMemFree + VIRTUAL_MEM_MAP = 156 ## Enumerator for ::urVirtualMemMap + VIRTUAL_MEM_UNMAP = 157 ## Enumerator for ::urVirtualMemUnmap + VIRTUAL_MEM_SET_ACCESS = 158 ## Enumerator for ::urVirtualMemSetAccess + VIRTUAL_MEM_GET_INFO = 159 ## Enumerator for ::urVirtualMemGetInfo + PHYSICAL_MEM_CREATE = 160 ## Enumerator for ::urPhysicalMemCreate + PHYSICAL_MEM_RETAIN = 161 ## Enumerator for ::urPhysicalMemRetain + PHYSICAL_MEM_RELEASE = 162 ## Enumerator for ::urPhysicalMemRelease + USM_IMPORT_EXP = 163 ## Enumerator for ::urUSMImportExp + USM_RELEASE_EXP = 164 ## Enumerator for ::urUSMReleaseExp + USM_P2P_ENABLE_PEER_ACCESS_EXP = 165 ## Enumerator for ::urUsmP2PEnablePeerAccessExp + USM_P2P_DISABLE_PEER_ACCESS_EXP = 166 ## Enumerator for ::urUsmP2PDisablePeerAccessExp + USM_P2P_PEER_ACCESS_GET_INFO_EXP = 167 ## Enumerator for ::urUsmP2PPeerAccessGetInfoExp + COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_EXP = 168 ## Enumerator for ::urCommandBufferAppendMembufferWriteExp + COMMAND_BUFFER_APPEND_MEMBUFFER_READ_EXP = 169 ## Enumerator for ::urCommandBufferAppendMembufferReadExp + COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_RECT_EXP = 170## Enumerator for ::urCommandBufferAppendMembufferWriteRectExp + COMMAND_BUFFER_APPEND_MEMBUFFER_READ_RECT_EXP = 171 ## Enumerator for ::urCommandBufferAppendMembufferReadRectExp + +class ur_function_t(c_int): + def __str__(self): + return str(ur_function_v(self.value)) + + +############################################################################### +## @brief Defines structure types +class ur_structure_type_v(IntEnum): + CONTEXT_PROPERTIES = 0 ## ::ur_context_properties_t + IMAGE_DESC = 1 ## ::ur_image_desc_t + BUFFER_PROPERTIES = 2 ## ::ur_buffer_properties_t + BUFFER_REGION = 3 ## ::ur_buffer_region_t + BUFFER_CHANNEL_PROPERTIES = 4 ## ::ur_buffer_channel_properties_t + BUFFER_ALLOC_LOCATION_PROPERTIES = 5 ## ::ur_buffer_alloc_location_properties_t + PROGRAM_PROPERTIES = 6 ## ::ur_program_properties_t + USM_DESC = 7 ## ::ur_usm_desc_t + USM_HOST_DESC = 8 ## ::ur_usm_host_desc_t + USM_DEVICE_DESC = 9 ## ::ur_usm_device_desc_t + USM_POOL_DESC = 10 ## ::ur_usm_pool_desc_t + USM_POOL_LIMITS_DESC = 11 ## ::ur_usm_pool_limits_desc_t + DEVICE_BINARY = 12 ## ::ur_device_binary_t + SAMPLER_DESC = 13 ## ::ur_sampler_desc_t + QUEUE_PROPERTIES = 14 ## ::ur_queue_properties_t + QUEUE_INDEX_PROPERTIES = 15 ## ::ur_queue_index_properties_t + CONTEXT_NATIVE_PROPERTIES = 16 ## ::ur_context_native_properties_t + KERNEL_NATIVE_PROPERTIES = 17 ## ::ur_kernel_native_properties_t + QUEUE_NATIVE_PROPERTIES = 18 ## ::ur_queue_native_properties_t + MEM_NATIVE_PROPERTIES = 19 ## ::ur_mem_native_properties_t + EVENT_NATIVE_PROPERTIES = 20 ## ::ur_event_native_properties_t + PLATFORM_NATIVE_PROPERTIES = 21 ## ::ur_platform_native_properties_t + DEVICE_NATIVE_PROPERTIES = 22 ## ::ur_device_native_properties_t + PROGRAM_NATIVE_PROPERTIES = 23 ## ::ur_program_native_properties_t + SAMPLER_NATIVE_PROPERTIES = 24 ## ::ur_sampler_native_properties_t + QUEUE_NATIVE_DESC = 25 ## ::ur_queue_native_desc_t + DEVICE_PARTITION_PROPERTIES = 26 ## ::ur_device_partition_properties_t + KERNEL_ARG_MEM_OBJ_PROPERTIES = 27 ## ::ur_kernel_arg_mem_obj_properties_t + PHYSICAL_MEM_PROPERTIES = 28 ## ::ur_physical_mem_properties_t + KERNEL_ARG_POINTER_PROPERTIES = 29 ## ::ur_kernel_arg_pointer_properties_t + KERNEL_ARG_SAMPLER_PROPERTIES = 30 ## ::ur_kernel_arg_sampler_properties_t + KERNEL_EXEC_INFO_PROPERTIES = 31 ## ::ur_kernel_exec_info_properties_t + KERNEL_ARG_VALUE_PROPERTIES = 32 ## ::ur_kernel_arg_value_properties_t + KERNEL_ARG_LOCAL_PROPERTIES = 33 ## ::ur_kernel_arg_local_properties_t + EXP_COMMAND_BUFFER_DESC = 0x1000 ## ::ur_exp_command_buffer_desc_t + EXP_SAMPLER_MIP_PROPERTIES = 0x2000 ## ::ur_exp_sampler_mip_properties_t + +class ur_structure_type_t(c_int): + def __str__(self): + return str(ur_structure_type_v(self.value)) + + ############################################################################### ## @brief Generates generic 'oneAPI' API versions def UR_MAKE_VERSION( _major, _minor ): @@ -207,51 +426,6 @@ def __str__(self): return str(ur_result_v(self.value)) -############################################################################### -## @brief Defines structure types -class ur_structure_type_v(IntEnum): - PLATFORM_NATIVE_PROPERTIES = 0 ## ::ur_platform_native_properties_t - DEVICE_BINARY = 1 ## ::ur_device_binary_t - DEVICE_PARTITION_PROPERTIES = 2 ## ::ur_device_partition_properties_t - DEVICE_NATIVE_PROPERTIES = 3 ## ::ur_device_native_properties_t - CONTEXT_PROPERTIES = 4 ## ::ur_context_properties_t - CONTEXT_NATIVE_PROPERTIES = 5 ## ::ur_context_native_properties_t - IMAGE_DESC = 6 ## ::ur_image_desc_t - BUFFER_PROPERTIES = 7 ## ::ur_buffer_properties_t - BUFFER_CHANNEL_PROPERTIES = 8 ## ::ur_buffer_channel_properties_t - BUFFER_ALLOC_LOCATION_PROPERTIES = 9 ## ::ur_buffer_alloc_location_properties_t - BUFFER_REGION = 10 ## ::ur_buffer_region_t - MEM_NATIVE_PROPERTIES = 11 ## ::ur_mem_native_properties_t - SAMPLER_DESC = 12 ## ::ur_sampler_desc_t - SAMPLER_NATIVE_PROPERTIES = 13 ## ::ur_sampler_native_properties_t - USM_DESC = 14 ## ::ur_usm_desc_t - USM_HOST_DESC = 15 ## ::ur_usm_host_desc_t - USM_DEVICE_DESC = 16 ## ::ur_usm_device_desc_t - USM_POOL_DESC = 17 ## ::ur_usm_pool_desc_t - USM_POOL_LIMITS_DESC = 18 ## ::ur_usm_pool_limits_desc_t - PHYSICAL_MEM_PROPERTIES = 19 ## ::ur_physical_mem_properties_t - PROGRAM_PROPERTIES = 20 ## ::ur_program_properties_t - PROGRAM_NATIVE_PROPERTIES = 21 ## ::ur_program_native_properties_t - KERNEL_ARG_VALUE_PROPERTIES = 22 ## ::ur_kernel_arg_value_properties_t - KERNEL_ARG_LOCAL_PROPERTIES = 23 ## ::ur_kernel_arg_local_properties_t - KERNEL_ARG_POINTER_PROPERTIES = 24 ## ::ur_kernel_arg_pointer_properties_t - KERNEL_EXEC_INFO_PROPERTIES = 25 ## ::ur_kernel_exec_info_properties_t - KERNEL_ARG_SAMPLER_PROPERTIES = 26 ## ::ur_kernel_arg_sampler_properties_t - KERNEL_ARG_MEM_OBJ_PROPERTIES = 27 ## ::ur_kernel_arg_mem_obj_properties_t - KERNEL_NATIVE_PROPERTIES = 28 ## ::ur_kernel_native_properties_t - QUEUE_PROPERTIES = 29 ## ::ur_queue_properties_t - QUEUE_INDEX_PROPERTIES = 30 ## ::ur_queue_index_properties_t - QUEUE_NATIVE_DESC = 31 ## ::ur_queue_native_desc_t - QUEUE_NATIVE_PROPERTIES = 32 ## ::ur_queue_native_properties_t - EVENT_NATIVE_PROPERTIES = 33 ## ::ur_event_native_properties_t - EXP_COMMAND_BUFFER_DESC = 0x1000 ## ::ur_exp_command_buffer_desc_t - EXP_SAMPLER_MIP_PROPERTIES = 0x2000 ## ::ur_exp_sampler_mip_properties_t - -class ur_structure_type_t(c_int): - def __str__(self): - return str(ur_structure_type_v(self.value)) - - ############################################################################### ## @brief Base for all properties types class ur_base_properties_t(Structure): @@ -1866,180 +2040,6 @@ def ur_event_callback_t_wrapper(hEvent, execStatus, pUserData): return user_defined_callback(hEvent, execStatus, pUserData) return ur_event_callback_t_wrapper -############################################################################### -## @brief Defines unique stable identifiers for all functions -class ur_function_v(IntEnum): - CONTEXT_CREATE = 1 ## Enumerator for ::urContextCreate - CONTEXT_RETAIN = 2 ## Enumerator for ::urContextRetain - CONTEXT_RELEASE = 3 ## Enumerator for ::urContextRelease - CONTEXT_GET_INFO = 4 ## Enumerator for ::urContextGetInfo - CONTEXT_GET_NATIVE_HANDLE = 5 ## Enumerator for ::urContextGetNativeHandle - CONTEXT_CREATE_WITH_NATIVE_HANDLE = 6 ## Enumerator for ::urContextCreateWithNativeHandle - CONTEXT_SET_EXTENDED_DELETER = 7 ## Enumerator for ::urContextSetExtendedDeleter - DEVICE_GET = 8 ## Enumerator for ::urDeviceGet - DEVICE_GET_INFO = 9 ## Enumerator for ::urDeviceGetInfo - DEVICE_RETAIN = 10 ## Enumerator for ::urDeviceRetain - DEVICE_RELEASE = 11 ## Enumerator for ::urDeviceRelease - DEVICE_PARTITION = 12 ## Enumerator for ::urDevicePartition - DEVICE_SELECT_BINARY = 13 ## Enumerator for ::urDeviceSelectBinary - DEVICE_GET_NATIVE_HANDLE = 14 ## Enumerator for ::urDeviceGetNativeHandle - DEVICE_CREATE_WITH_NATIVE_HANDLE = 15 ## Enumerator for ::urDeviceCreateWithNativeHandle - DEVICE_GET_GLOBAL_TIMESTAMPS = 16 ## Enumerator for ::urDeviceGetGlobalTimestamps - ENQUEUE_KERNEL_LAUNCH = 17 ## Enumerator for ::urEnqueueKernelLaunch - ENQUEUE_EVENTS_WAIT = 18 ## Enumerator for ::urEnqueueEventsWait - ENQUEUE_EVENTS_WAIT_WITH_BARRIER = 19 ## Enumerator for ::urEnqueueEventsWaitWithBarrier - ENQUEUE_MEM_BUFFER_READ = 20 ## Enumerator for ::urEnqueueMemBufferRead - ENQUEUE_MEM_BUFFER_WRITE = 21 ## Enumerator for ::urEnqueueMemBufferWrite - ENQUEUE_MEM_BUFFER_READ_RECT = 22 ## Enumerator for ::urEnqueueMemBufferReadRect - ENQUEUE_MEM_BUFFER_WRITE_RECT = 23 ## Enumerator for ::urEnqueueMemBufferWriteRect - ENQUEUE_MEM_BUFFER_COPY = 24 ## Enumerator for ::urEnqueueMemBufferCopy - ENQUEUE_MEM_BUFFER_COPY_RECT = 25 ## Enumerator for ::urEnqueueMemBufferCopyRect - ENQUEUE_MEM_BUFFER_FILL = 26 ## Enumerator for ::urEnqueueMemBufferFill - ENQUEUE_MEM_IMAGE_READ = 27 ## Enumerator for ::urEnqueueMemImageRead - ENQUEUE_MEM_IMAGE_WRITE = 28 ## Enumerator for ::urEnqueueMemImageWrite - ENQUEUE_MEM_IMAGE_COPY = 29 ## Enumerator for ::urEnqueueMemImageCopy - ENQUEUE_MEM_BUFFER_MAP = 30 ## Enumerator for ::urEnqueueMemBufferMap - ENQUEUE_MEM_UNMAP = 31 ## Enumerator for ::urEnqueueMemUnmap - ENQUEUE_USM_FILL = 32 ## Enumerator for ::urEnqueueUSMFill - ENQUEUE_USM_MEMCPY = 33 ## Enumerator for ::urEnqueueUSMMemcpy - ENQUEUE_USM_PREFETCH = 34 ## Enumerator for ::urEnqueueUSMPrefetch - ENQUEUE_USM_ADVISE = 35 ## Enumerator for ::urEnqueueUSMAdvise - ENQUEUE_DEVICE_GLOBAL_VARIABLE_WRITE = 38 ## Enumerator for ::urEnqueueDeviceGlobalVariableWrite - ENQUEUE_DEVICE_GLOBAL_VARIABLE_READ = 39 ## Enumerator for ::urEnqueueDeviceGlobalVariableRead - EVENT_GET_INFO = 40 ## Enumerator for ::urEventGetInfo - EVENT_GET_PROFILING_INFO = 41 ## Enumerator for ::urEventGetProfilingInfo - EVENT_WAIT = 42 ## Enumerator for ::urEventWait - EVENT_RETAIN = 43 ## Enumerator for ::urEventRetain - EVENT_RELEASE = 44 ## Enumerator for ::urEventRelease - EVENT_GET_NATIVE_HANDLE = 45 ## Enumerator for ::urEventGetNativeHandle - EVENT_CREATE_WITH_NATIVE_HANDLE = 46 ## Enumerator for ::urEventCreateWithNativeHandle - EVENT_SET_CALLBACK = 47 ## Enumerator for ::urEventSetCallback - KERNEL_CREATE = 48 ## Enumerator for ::urKernelCreate - KERNEL_SET_ARG_VALUE = 49 ## Enumerator for ::urKernelSetArgValue - KERNEL_SET_ARG_LOCAL = 50 ## Enumerator for ::urKernelSetArgLocal - KERNEL_GET_INFO = 51 ## Enumerator for ::urKernelGetInfo - KERNEL_GET_GROUP_INFO = 52 ## Enumerator for ::urKernelGetGroupInfo - KERNEL_GET_SUB_GROUP_INFO = 53 ## Enumerator for ::urKernelGetSubGroupInfo - KERNEL_RETAIN = 54 ## Enumerator for ::urKernelRetain - KERNEL_RELEASE = 55 ## Enumerator for ::urKernelRelease - KERNEL_SET_ARG_POINTER = 56 ## Enumerator for ::urKernelSetArgPointer - KERNEL_SET_EXEC_INFO = 57 ## Enumerator for ::urKernelSetExecInfo - KERNEL_SET_ARG_SAMPLER = 58 ## Enumerator for ::urKernelSetArgSampler - KERNEL_SET_ARG_MEM_OBJ = 59 ## Enumerator for ::urKernelSetArgMemObj - KERNEL_SET_SPECIALIZATION_CONSTANTS = 60 ## Enumerator for ::urKernelSetSpecializationConstants - KERNEL_GET_NATIVE_HANDLE = 61 ## Enumerator for ::urKernelGetNativeHandle - KERNEL_CREATE_WITH_NATIVE_HANDLE = 62 ## Enumerator for ::urKernelCreateWithNativeHandle - MEM_IMAGE_CREATE = 63 ## Enumerator for ::urMemImageCreate - MEM_BUFFER_CREATE = 64 ## Enumerator for ::urMemBufferCreate - MEM_RETAIN = 65 ## Enumerator for ::urMemRetain - MEM_RELEASE = 66 ## Enumerator for ::urMemRelease - MEM_BUFFER_PARTITION = 67 ## Enumerator for ::urMemBufferPartition - MEM_GET_NATIVE_HANDLE = 68 ## Enumerator for ::urMemGetNativeHandle - ENQUEUE_READ_HOST_PIPE = 69 ## Enumerator for ::urEnqueueReadHostPipe - MEM_GET_INFO = 70 ## Enumerator for ::urMemGetInfo - MEM_IMAGE_GET_INFO = 71 ## Enumerator for ::urMemImageGetInfo - PLATFORM_GET = 72 ## Enumerator for ::urPlatformGet - PLATFORM_GET_INFO = 73 ## Enumerator for ::urPlatformGetInfo - PLATFORM_GET_API_VERSION = 74 ## Enumerator for ::urPlatformGetApiVersion - PLATFORM_GET_NATIVE_HANDLE = 75 ## Enumerator for ::urPlatformGetNativeHandle - PLATFORM_CREATE_WITH_NATIVE_HANDLE = 76 ## Enumerator for ::urPlatformCreateWithNativeHandle - PROGRAM_CREATE_WITH_IL = 78 ## Enumerator for ::urProgramCreateWithIL - PROGRAM_CREATE_WITH_BINARY = 79 ## Enumerator for ::urProgramCreateWithBinary - PROGRAM_BUILD = 80 ## Enumerator for ::urProgramBuild - PROGRAM_COMPILE = 81 ## Enumerator for ::urProgramCompile - PROGRAM_LINK = 82 ## Enumerator for ::urProgramLink - PROGRAM_RETAIN = 83 ## Enumerator for ::urProgramRetain - PROGRAM_RELEASE = 84 ## Enumerator for ::urProgramRelease - PROGRAM_GET_FUNCTION_POINTER = 85 ## Enumerator for ::urProgramGetFunctionPointer - PROGRAM_GET_INFO = 86 ## Enumerator for ::urProgramGetInfo - PROGRAM_GET_BUILD_INFO = 87 ## Enumerator for ::urProgramGetBuildInfo - PROGRAM_SET_SPECIALIZATION_CONSTANTS = 88 ## Enumerator for ::urProgramSetSpecializationConstants - PROGRAM_GET_NATIVE_HANDLE = 89 ## Enumerator for ::urProgramGetNativeHandle - PROGRAM_CREATE_WITH_NATIVE_HANDLE = 90 ## Enumerator for ::urProgramCreateWithNativeHandle - QUEUE_GET_INFO = 91 ## Enumerator for ::urQueueGetInfo - QUEUE_CREATE = 92 ## Enumerator for ::urQueueCreate - QUEUE_RETAIN = 93 ## Enumerator for ::urQueueRetain - QUEUE_RELEASE = 94 ## Enumerator for ::urQueueRelease - QUEUE_GET_NATIVE_HANDLE = 95 ## Enumerator for ::urQueueGetNativeHandle - QUEUE_CREATE_WITH_NATIVE_HANDLE = 96 ## Enumerator for ::urQueueCreateWithNativeHandle - QUEUE_FINISH = 97 ## Enumerator for ::urQueueFinish - QUEUE_FLUSH = 98 ## Enumerator for ::urQueueFlush - INIT = 99 ## Enumerator for ::urInit - TEAR_DOWN = 100 ## Enumerator for ::urTearDown - SAMPLER_CREATE = 101 ## Enumerator for ::urSamplerCreate - SAMPLER_RETAIN = 102 ## Enumerator for ::urSamplerRetain - SAMPLER_RELEASE = 103 ## Enumerator for ::urSamplerRelease - SAMPLER_GET_INFO = 104 ## Enumerator for ::urSamplerGetInfo - SAMPLER_GET_NATIVE_HANDLE = 105 ## Enumerator for ::urSamplerGetNativeHandle - SAMPLER_CREATE_WITH_NATIVE_HANDLE = 106 ## Enumerator for ::urSamplerCreateWithNativeHandle - USM_HOST_ALLOC = 107 ## Enumerator for ::urUSMHostAlloc - USM_DEVICE_ALLOC = 108 ## Enumerator for ::urUSMDeviceAlloc - USM_SHARED_ALLOC = 109 ## Enumerator for ::urUSMSharedAlloc - USM_FREE = 110 ## Enumerator for ::urUSMFree - USM_GET_MEM_ALLOC_INFO = 111 ## Enumerator for ::urUSMGetMemAllocInfo - USM_POOL_CREATE = 112 ## Enumerator for ::urUSMPoolCreate - COMMAND_BUFFER_CREATE_EXP = 113 ## Enumerator for ::urCommandBufferCreateExp - PLATFORM_GET_BACKEND_OPTION = 114 ## Enumerator for ::urPlatformGetBackendOption - MEM_BUFFER_CREATE_WITH_NATIVE_HANDLE = 115 ## Enumerator for ::urMemBufferCreateWithNativeHandle - MEM_IMAGE_CREATE_WITH_NATIVE_HANDLE = 116 ## Enumerator for ::urMemImageCreateWithNativeHandle - ENQUEUE_WRITE_HOST_PIPE = 117 ## Enumerator for ::urEnqueueWriteHostPipe - USM_POOL_RETAIN = 118 ## Enumerator for ::urUSMPoolRetain - USM_POOL_RELEASE = 119 ## Enumerator for ::urUSMPoolRelease - USM_POOL_GET_INFO = 120 ## Enumerator for ::urUSMPoolGetInfo - COMMAND_BUFFER_RETAIN_EXP = 121 ## Enumerator for ::urCommandBufferRetainExp - COMMAND_BUFFER_RELEASE_EXP = 122 ## Enumerator for ::urCommandBufferReleaseExp - COMMAND_BUFFER_FINALIZE_EXP = 123 ## Enumerator for ::urCommandBufferFinalizeExp - COMMAND_BUFFER_APPEND_KERNEL_LAUNCH_EXP = 125 ## Enumerator for ::urCommandBufferAppendKernelLaunchExp - COMMAND_BUFFER_ENQUEUE_EXP = 128 ## Enumerator for ::urCommandBufferEnqueueExp - COMMAND_BUFFER_APPEND_MEMCPY_USM_EXP = 129 ## Enumerator for ::urCommandBufferAppendMemcpyUSMExp - COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_EXP = 130 ## Enumerator for ::urCommandBufferAppendMembufferCopyExp - COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_RECT_EXP = 131 ## Enumerator for ::urCommandBufferAppendMembufferCopyRectExp - USM_PITCHED_ALLOC_EXP = 132 ## Enumerator for ::urUSMPitchedAllocExp - BINDLESS_IMAGES_UNSAMPLED_IMAGE_HANDLE_DESTROY_EXP = 133## Enumerator for ::urBindlessImagesUnsampledImageHandleDestroyExp - BINDLESS_IMAGES_SAMPLED_IMAGE_HANDLE_DESTROY_EXP = 134 ## Enumerator for ::urBindlessImagesSampledImageHandleDestroyExp - BINDLESS_IMAGES_IMAGE_ALLOCATE_EXP = 135 ## Enumerator for ::urBindlessImagesImageAllocateExp - BINDLESS_IMAGES_IMAGE_FREE_EXP = 136 ## Enumerator for ::urBindlessImagesImageFreeExp - BINDLESS_IMAGES_UNSAMPLED_IMAGE_CREATE_EXP = 137## Enumerator for ::urBindlessImagesUnsampledImageCreateExp - BINDLESS_IMAGES_SAMPLED_IMAGE_CREATE_EXP = 138 ## Enumerator for ::urBindlessImagesSampledImageCreateExp - BINDLESS_IMAGES_IMAGE_COPY_EXP = 139 ## Enumerator for ::urBindlessImagesImageCopyExp - BINDLESS_IMAGES_IMAGE_GET_INFO_EXP = 140 ## Enumerator for ::urBindlessImagesImageGetInfoExp - BINDLESS_IMAGES_MIPMAP_GET_LEVEL_EXP = 141 ## Enumerator for ::urBindlessImagesMipmapGetLevelExp - BINDLESS_IMAGES_MIPMAP_FREE_EXP = 142 ## Enumerator for ::urBindlessImagesMipmapFreeExp - BINDLESS_IMAGES_IMPORT_OPAQUE_FD_EXP = 143 ## Enumerator for ::urBindlessImagesImportOpaqueFDExp - BINDLESS_IMAGES_MAP_EXTERNAL_ARRAY_EXP = 144 ## Enumerator for ::urBindlessImagesMapExternalArrayExp - BINDLESS_IMAGES_RELEASE_INTEROP_EXP = 145 ## Enumerator for ::urBindlessImagesReleaseInteropExp - BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXP = 146 ## Enumerator for ::urBindlessImagesImportExternalSemaphoreOpaqueFDExp - BINDLESS_IMAGES_DESTROY_EXTERNAL_SEMAPHORE_EXP = 147## Enumerator for ::urBindlessImagesDestroyExternalSemaphoreExp - BINDLESS_IMAGES_WAIT_EXTERNAL_SEMAPHORE_EXP = 148 ## Enumerator for ::urBindlessImagesWaitExternalSemaphoreExp - BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP = 149 ## Enumerator for ::urBindlessImagesSignalExternalSemaphoreExp - PLATFORM_GET_LAST_ERROR = 150 ## Enumerator for ::urPlatformGetLastError - ENQUEUE_USM_FILL_2D = 151 ## Enumerator for ::urEnqueueUSMFill2D - ENQUEUE_USM_MEMCPY_2D = 152 ## Enumerator for ::urEnqueueUSMMemcpy2D - VIRTUAL_MEM_GRANULARITY_GET_INFO = 153 ## Enumerator for ::urVirtualMemGranularityGetInfo - VIRTUAL_MEM_RESERVE = 154 ## Enumerator for ::urVirtualMemReserve - VIRTUAL_MEM_FREE = 155 ## Enumerator for ::urVirtualMemFree - VIRTUAL_MEM_MAP = 156 ## Enumerator for ::urVirtualMemMap - VIRTUAL_MEM_UNMAP = 157 ## Enumerator for ::urVirtualMemUnmap - VIRTUAL_MEM_SET_ACCESS = 158 ## Enumerator for ::urVirtualMemSetAccess - VIRTUAL_MEM_GET_INFO = 159 ## Enumerator for ::urVirtualMemGetInfo - PHYSICAL_MEM_CREATE = 160 ## Enumerator for ::urPhysicalMemCreate - PHYSICAL_MEM_RETAIN = 161 ## Enumerator for ::urPhysicalMemRetain - PHYSICAL_MEM_RELEASE = 162 ## Enumerator for ::urPhysicalMemRelease - USM_IMPORT_EXP = 163 ## Enumerator for ::urUSMImportExp - USM_RELEASE_EXP = 164 ## Enumerator for ::urUSMReleaseExp - USM_P2P_ENABLE_PEER_ACCESS_EXP = 165 ## Enumerator for ::urUsmP2PEnablePeerAccessExp - USM_P2P_DISABLE_PEER_ACCESS_EXP = 166 ## Enumerator for ::urUsmP2PDisablePeerAccessExp - USM_P2P_PEER_ACCESS_GET_INFO_EXP = 167 ## Enumerator for ::urUsmP2PPeerAccessGetInfoExp - COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_EXP = 168 ## Enumerator for ::urCommandBufferAppendMembufferWriteExp - COMMAND_BUFFER_APPEND_MEMBUFFER_READ_EXP = 169 ## Enumerator for ::urCommandBufferAppendMembufferReadExp - COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_RECT_EXP = 170## Enumerator for ::urCommandBufferAppendMembufferWriteRectExp - COMMAND_BUFFER_APPEND_MEMBUFFER_READ_RECT_EXP = 171 ## Enumerator for ::urCommandBufferAppendMembufferReadRectExp - -class ur_function_t(c_int): - def __str__(self): - return str(ur_function_v(self.value)) - - ############################################################################### ## @brief Map flags class ur_map_flags_v(IntEnum): diff --git a/include/ur_api.h b/include/ur_api.h index b9d5290cae..03a5984256 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -24,6 +24,232 @@ extern "C" { #endif +// Intel 'oneAPI' Unified Runtime function registry +#if !defined(__GNUC__) +#pragma region registry +#endif +/////////////////////////////////////////////////////////////////////////////// +/// @brief Defines unique stable identifiers for all functions +typedef enum ur_function_t { + UR_FUNCTION_CONTEXT_CREATE = 1, ///< Enumerator for ::urContextCreate + UR_FUNCTION_CONTEXT_RETAIN = 2, ///< Enumerator for ::urContextRetain + UR_FUNCTION_CONTEXT_RELEASE = 3, ///< Enumerator for ::urContextRelease + UR_FUNCTION_CONTEXT_GET_INFO = 4, ///< Enumerator for ::urContextGetInfo + UR_FUNCTION_CONTEXT_GET_NATIVE_HANDLE = 5, ///< Enumerator for ::urContextGetNativeHandle + UR_FUNCTION_CONTEXT_CREATE_WITH_NATIVE_HANDLE = 6, ///< Enumerator for ::urContextCreateWithNativeHandle + UR_FUNCTION_CONTEXT_SET_EXTENDED_DELETER = 7, ///< Enumerator for ::urContextSetExtendedDeleter + UR_FUNCTION_DEVICE_GET = 8, ///< Enumerator for ::urDeviceGet + UR_FUNCTION_DEVICE_GET_INFO = 9, ///< Enumerator for ::urDeviceGetInfo + UR_FUNCTION_DEVICE_RETAIN = 10, ///< Enumerator for ::urDeviceRetain + UR_FUNCTION_DEVICE_RELEASE = 11, ///< Enumerator for ::urDeviceRelease + UR_FUNCTION_DEVICE_PARTITION = 12, ///< Enumerator for ::urDevicePartition + UR_FUNCTION_DEVICE_SELECT_BINARY = 13, ///< Enumerator for ::urDeviceSelectBinary + UR_FUNCTION_DEVICE_GET_NATIVE_HANDLE = 14, ///< Enumerator for ::urDeviceGetNativeHandle + UR_FUNCTION_DEVICE_CREATE_WITH_NATIVE_HANDLE = 15, ///< Enumerator for ::urDeviceCreateWithNativeHandle + UR_FUNCTION_DEVICE_GET_GLOBAL_TIMESTAMPS = 16, ///< Enumerator for ::urDeviceGetGlobalTimestamps + UR_FUNCTION_ENQUEUE_KERNEL_LAUNCH = 17, ///< Enumerator for ::urEnqueueKernelLaunch + UR_FUNCTION_ENQUEUE_EVENTS_WAIT = 18, ///< Enumerator for ::urEnqueueEventsWait + UR_FUNCTION_ENQUEUE_EVENTS_WAIT_WITH_BARRIER = 19, ///< Enumerator for ::urEnqueueEventsWaitWithBarrier + UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ = 20, ///< Enumerator for ::urEnqueueMemBufferRead + UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE = 21, ///< Enumerator for ::urEnqueueMemBufferWrite + UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ_RECT = 22, ///< Enumerator for ::urEnqueueMemBufferReadRect + UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE_RECT = 23, ///< Enumerator for ::urEnqueueMemBufferWriteRect + UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY = 24, ///< Enumerator for ::urEnqueueMemBufferCopy + UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY_RECT = 25, ///< Enumerator for ::urEnqueueMemBufferCopyRect + UR_FUNCTION_ENQUEUE_MEM_BUFFER_FILL = 26, ///< Enumerator for ::urEnqueueMemBufferFill + UR_FUNCTION_ENQUEUE_MEM_IMAGE_READ = 27, ///< Enumerator for ::urEnqueueMemImageRead + UR_FUNCTION_ENQUEUE_MEM_IMAGE_WRITE = 28, ///< Enumerator for ::urEnqueueMemImageWrite + UR_FUNCTION_ENQUEUE_MEM_IMAGE_COPY = 29, ///< Enumerator for ::urEnqueueMemImageCopy + UR_FUNCTION_ENQUEUE_MEM_BUFFER_MAP = 30, ///< Enumerator for ::urEnqueueMemBufferMap + UR_FUNCTION_ENQUEUE_MEM_UNMAP = 31, ///< Enumerator for ::urEnqueueMemUnmap + UR_FUNCTION_ENQUEUE_USM_FILL = 32, ///< Enumerator for ::urEnqueueUSMFill + UR_FUNCTION_ENQUEUE_USM_MEMCPY = 33, ///< Enumerator for ::urEnqueueUSMMemcpy + UR_FUNCTION_ENQUEUE_USM_PREFETCH = 34, ///< Enumerator for ::urEnqueueUSMPrefetch + UR_FUNCTION_ENQUEUE_USM_ADVISE = 35, ///< Enumerator for ::urEnqueueUSMAdvise + UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_WRITE = 38, ///< Enumerator for ::urEnqueueDeviceGlobalVariableWrite + UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_READ = 39, ///< Enumerator for ::urEnqueueDeviceGlobalVariableRead + UR_FUNCTION_EVENT_GET_INFO = 40, ///< Enumerator for ::urEventGetInfo + UR_FUNCTION_EVENT_GET_PROFILING_INFO = 41, ///< Enumerator for ::urEventGetProfilingInfo + UR_FUNCTION_EVENT_WAIT = 42, ///< Enumerator for ::urEventWait + UR_FUNCTION_EVENT_RETAIN = 43, ///< Enumerator for ::urEventRetain + UR_FUNCTION_EVENT_RELEASE = 44, ///< Enumerator for ::urEventRelease + UR_FUNCTION_EVENT_GET_NATIVE_HANDLE = 45, ///< Enumerator for ::urEventGetNativeHandle + UR_FUNCTION_EVENT_CREATE_WITH_NATIVE_HANDLE = 46, ///< Enumerator for ::urEventCreateWithNativeHandle + UR_FUNCTION_EVENT_SET_CALLBACK = 47, ///< Enumerator for ::urEventSetCallback + UR_FUNCTION_KERNEL_CREATE = 48, ///< Enumerator for ::urKernelCreate + UR_FUNCTION_KERNEL_SET_ARG_VALUE = 49, ///< Enumerator for ::urKernelSetArgValue + UR_FUNCTION_KERNEL_SET_ARG_LOCAL = 50, ///< Enumerator for ::urKernelSetArgLocal + UR_FUNCTION_KERNEL_GET_INFO = 51, ///< Enumerator for ::urKernelGetInfo + UR_FUNCTION_KERNEL_GET_GROUP_INFO = 52, ///< Enumerator for ::urKernelGetGroupInfo + UR_FUNCTION_KERNEL_GET_SUB_GROUP_INFO = 53, ///< Enumerator for ::urKernelGetSubGroupInfo + UR_FUNCTION_KERNEL_RETAIN = 54, ///< Enumerator for ::urKernelRetain + UR_FUNCTION_KERNEL_RELEASE = 55, ///< Enumerator for ::urKernelRelease + UR_FUNCTION_KERNEL_SET_ARG_POINTER = 56, ///< Enumerator for ::urKernelSetArgPointer + UR_FUNCTION_KERNEL_SET_EXEC_INFO = 57, ///< Enumerator for ::urKernelSetExecInfo + UR_FUNCTION_KERNEL_SET_ARG_SAMPLER = 58, ///< Enumerator for ::urKernelSetArgSampler + UR_FUNCTION_KERNEL_SET_ARG_MEM_OBJ = 59, ///< Enumerator for ::urKernelSetArgMemObj + UR_FUNCTION_KERNEL_SET_SPECIALIZATION_CONSTANTS = 60, ///< Enumerator for ::urKernelSetSpecializationConstants + UR_FUNCTION_KERNEL_GET_NATIVE_HANDLE = 61, ///< Enumerator for ::urKernelGetNativeHandle + UR_FUNCTION_KERNEL_CREATE_WITH_NATIVE_HANDLE = 62, ///< Enumerator for ::urKernelCreateWithNativeHandle + UR_FUNCTION_MEM_IMAGE_CREATE = 63, ///< Enumerator for ::urMemImageCreate + UR_FUNCTION_MEM_BUFFER_CREATE = 64, ///< Enumerator for ::urMemBufferCreate + UR_FUNCTION_MEM_RETAIN = 65, ///< Enumerator for ::urMemRetain + UR_FUNCTION_MEM_RELEASE = 66, ///< Enumerator for ::urMemRelease + UR_FUNCTION_MEM_BUFFER_PARTITION = 67, ///< Enumerator for ::urMemBufferPartition + UR_FUNCTION_MEM_GET_NATIVE_HANDLE = 68, ///< Enumerator for ::urMemGetNativeHandle + UR_FUNCTION_ENQUEUE_READ_HOST_PIPE = 69, ///< Enumerator for ::urEnqueueReadHostPipe + UR_FUNCTION_MEM_GET_INFO = 70, ///< Enumerator for ::urMemGetInfo + UR_FUNCTION_MEM_IMAGE_GET_INFO = 71, ///< Enumerator for ::urMemImageGetInfo + UR_FUNCTION_PLATFORM_GET = 72, ///< Enumerator for ::urPlatformGet + UR_FUNCTION_PLATFORM_GET_INFO = 73, ///< Enumerator for ::urPlatformGetInfo + UR_FUNCTION_PLATFORM_GET_API_VERSION = 74, ///< Enumerator for ::urPlatformGetApiVersion + UR_FUNCTION_PLATFORM_GET_NATIVE_HANDLE = 75, ///< Enumerator for ::urPlatformGetNativeHandle + UR_FUNCTION_PLATFORM_CREATE_WITH_NATIVE_HANDLE = 76, ///< Enumerator for ::urPlatformCreateWithNativeHandle + UR_FUNCTION_PROGRAM_CREATE_WITH_IL = 78, ///< Enumerator for ::urProgramCreateWithIL + UR_FUNCTION_PROGRAM_CREATE_WITH_BINARY = 79, ///< Enumerator for ::urProgramCreateWithBinary + UR_FUNCTION_PROGRAM_BUILD = 80, ///< Enumerator for ::urProgramBuild + UR_FUNCTION_PROGRAM_COMPILE = 81, ///< Enumerator for ::urProgramCompile + UR_FUNCTION_PROGRAM_LINK = 82, ///< Enumerator for ::urProgramLink + UR_FUNCTION_PROGRAM_RETAIN = 83, ///< Enumerator for ::urProgramRetain + UR_FUNCTION_PROGRAM_RELEASE = 84, ///< Enumerator for ::urProgramRelease + UR_FUNCTION_PROGRAM_GET_FUNCTION_POINTER = 85, ///< Enumerator for ::urProgramGetFunctionPointer + UR_FUNCTION_PROGRAM_GET_INFO = 86, ///< Enumerator for ::urProgramGetInfo + UR_FUNCTION_PROGRAM_GET_BUILD_INFO = 87, ///< Enumerator for ::urProgramGetBuildInfo + UR_FUNCTION_PROGRAM_SET_SPECIALIZATION_CONSTANTS = 88, ///< Enumerator for ::urProgramSetSpecializationConstants + UR_FUNCTION_PROGRAM_GET_NATIVE_HANDLE = 89, ///< Enumerator for ::urProgramGetNativeHandle + UR_FUNCTION_PROGRAM_CREATE_WITH_NATIVE_HANDLE = 90, ///< Enumerator for ::urProgramCreateWithNativeHandle + UR_FUNCTION_QUEUE_GET_INFO = 91, ///< Enumerator for ::urQueueGetInfo + UR_FUNCTION_QUEUE_CREATE = 92, ///< Enumerator for ::urQueueCreate + UR_FUNCTION_QUEUE_RETAIN = 93, ///< Enumerator for ::urQueueRetain + UR_FUNCTION_QUEUE_RELEASE = 94, ///< Enumerator for ::urQueueRelease + UR_FUNCTION_QUEUE_GET_NATIVE_HANDLE = 95, ///< Enumerator for ::urQueueGetNativeHandle + UR_FUNCTION_QUEUE_CREATE_WITH_NATIVE_HANDLE = 96, ///< Enumerator for ::urQueueCreateWithNativeHandle + UR_FUNCTION_QUEUE_FINISH = 97, ///< Enumerator for ::urQueueFinish + UR_FUNCTION_QUEUE_FLUSH = 98, ///< Enumerator for ::urQueueFlush + UR_FUNCTION_INIT = 99, ///< Enumerator for ::urInit + UR_FUNCTION_TEAR_DOWN = 100, ///< Enumerator for ::urTearDown + UR_FUNCTION_SAMPLER_CREATE = 101, ///< Enumerator for ::urSamplerCreate + UR_FUNCTION_SAMPLER_RETAIN = 102, ///< Enumerator for ::urSamplerRetain + UR_FUNCTION_SAMPLER_RELEASE = 103, ///< Enumerator for ::urSamplerRelease + UR_FUNCTION_SAMPLER_GET_INFO = 104, ///< Enumerator for ::urSamplerGetInfo + UR_FUNCTION_SAMPLER_GET_NATIVE_HANDLE = 105, ///< Enumerator for ::urSamplerGetNativeHandle + UR_FUNCTION_SAMPLER_CREATE_WITH_NATIVE_HANDLE = 106, ///< Enumerator for ::urSamplerCreateWithNativeHandle + UR_FUNCTION_USM_HOST_ALLOC = 107, ///< Enumerator for ::urUSMHostAlloc + UR_FUNCTION_USM_DEVICE_ALLOC = 108, ///< Enumerator for ::urUSMDeviceAlloc + UR_FUNCTION_USM_SHARED_ALLOC = 109, ///< Enumerator for ::urUSMSharedAlloc + UR_FUNCTION_USM_FREE = 110, ///< Enumerator for ::urUSMFree + UR_FUNCTION_USM_GET_MEM_ALLOC_INFO = 111, ///< Enumerator for ::urUSMGetMemAllocInfo + UR_FUNCTION_USM_POOL_CREATE = 112, ///< Enumerator for ::urUSMPoolCreate + UR_FUNCTION_COMMAND_BUFFER_CREATE_EXP = 113, ///< Enumerator for ::urCommandBufferCreateExp + UR_FUNCTION_PLATFORM_GET_BACKEND_OPTION = 114, ///< Enumerator for ::urPlatformGetBackendOption + UR_FUNCTION_MEM_BUFFER_CREATE_WITH_NATIVE_HANDLE = 115, ///< Enumerator for ::urMemBufferCreateWithNativeHandle + UR_FUNCTION_MEM_IMAGE_CREATE_WITH_NATIVE_HANDLE = 116, ///< Enumerator for ::urMemImageCreateWithNativeHandle + UR_FUNCTION_ENQUEUE_WRITE_HOST_PIPE = 117, ///< Enumerator for ::urEnqueueWriteHostPipe + UR_FUNCTION_USM_POOL_RETAIN = 118, ///< Enumerator for ::urUSMPoolRetain + UR_FUNCTION_USM_POOL_RELEASE = 119, ///< Enumerator for ::urUSMPoolRelease + UR_FUNCTION_USM_POOL_GET_INFO = 120, ///< Enumerator for ::urUSMPoolGetInfo + UR_FUNCTION_COMMAND_BUFFER_RETAIN_EXP = 121, ///< Enumerator for ::urCommandBufferRetainExp + UR_FUNCTION_COMMAND_BUFFER_RELEASE_EXP = 122, ///< Enumerator for ::urCommandBufferReleaseExp + UR_FUNCTION_COMMAND_BUFFER_FINALIZE_EXP = 123, ///< Enumerator for ::urCommandBufferFinalizeExp + UR_FUNCTION_COMMAND_BUFFER_APPEND_KERNEL_LAUNCH_EXP = 125, ///< Enumerator for ::urCommandBufferAppendKernelLaunchExp + UR_FUNCTION_COMMAND_BUFFER_ENQUEUE_EXP = 128, ///< Enumerator for ::urCommandBufferEnqueueExp + UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMCPY_USM_EXP = 129, ///< Enumerator for ::urCommandBufferAppendMemcpyUSMExp + UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_EXP = 130, ///< Enumerator for ::urCommandBufferAppendMembufferCopyExp + UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_RECT_EXP = 131, ///< Enumerator for ::urCommandBufferAppendMembufferCopyRectExp + UR_FUNCTION_USM_PITCHED_ALLOC_EXP = 132, ///< Enumerator for ::urUSMPitchedAllocExp + UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_HANDLE_DESTROY_EXP = 133, ///< Enumerator for ::urBindlessImagesUnsampledImageHandleDestroyExp + UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_HANDLE_DESTROY_EXP = 134, ///< Enumerator for ::urBindlessImagesSampledImageHandleDestroyExp + UR_FUNCTION_BINDLESS_IMAGES_IMAGE_ALLOCATE_EXP = 135, ///< Enumerator for ::urBindlessImagesImageAllocateExp + UR_FUNCTION_BINDLESS_IMAGES_IMAGE_FREE_EXP = 136, ///< Enumerator for ::urBindlessImagesImageFreeExp + UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_CREATE_EXP = 137, ///< Enumerator for ::urBindlessImagesUnsampledImageCreateExp + UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_CREATE_EXP = 138, ///< Enumerator for ::urBindlessImagesSampledImageCreateExp + UR_FUNCTION_BINDLESS_IMAGES_IMAGE_COPY_EXP = 139, ///< Enumerator for ::urBindlessImagesImageCopyExp + UR_FUNCTION_BINDLESS_IMAGES_IMAGE_GET_INFO_EXP = 140, ///< Enumerator for ::urBindlessImagesImageGetInfoExp + UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_GET_LEVEL_EXP = 141, ///< Enumerator for ::urBindlessImagesMipmapGetLevelExp + UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_FREE_EXP = 142, ///< Enumerator for ::urBindlessImagesMipmapFreeExp + UR_FUNCTION_BINDLESS_IMAGES_IMPORT_OPAQUE_FD_EXP = 143, ///< Enumerator for ::urBindlessImagesImportOpaqueFDExp + UR_FUNCTION_BINDLESS_IMAGES_MAP_EXTERNAL_ARRAY_EXP = 144, ///< Enumerator for ::urBindlessImagesMapExternalArrayExp + UR_FUNCTION_BINDLESS_IMAGES_RELEASE_INTEROP_EXP = 145, ///< Enumerator for ::urBindlessImagesReleaseInteropExp + UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXP = 146, ///< Enumerator for ::urBindlessImagesImportExternalSemaphoreOpaqueFDExp + UR_FUNCTION_BINDLESS_IMAGES_DESTROY_EXTERNAL_SEMAPHORE_EXP = 147, ///< Enumerator for ::urBindlessImagesDestroyExternalSemaphoreExp + UR_FUNCTION_BINDLESS_IMAGES_WAIT_EXTERNAL_SEMAPHORE_EXP = 148, ///< Enumerator for ::urBindlessImagesWaitExternalSemaphoreExp + UR_FUNCTION_BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP = 149, ///< Enumerator for ::urBindlessImagesSignalExternalSemaphoreExp + UR_FUNCTION_PLATFORM_GET_LAST_ERROR = 150, ///< Enumerator for ::urPlatformGetLastError + UR_FUNCTION_ENQUEUE_USM_FILL_2D = 151, ///< Enumerator for ::urEnqueueUSMFill2D + UR_FUNCTION_ENQUEUE_USM_MEMCPY_2D = 152, ///< Enumerator for ::urEnqueueUSMMemcpy2D + UR_FUNCTION_VIRTUAL_MEM_GRANULARITY_GET_INFO = 153, ///< Enumerator for ::urVirtualMemGranularityGetInfo + UR_FUNCTION_VIRTUAL_MEM_RESERVE = 154, ///< Enumerator for ::urVirtualMemReserve + UR_FUNCTION_VIRTUAL_MEM_FREE = 155, ///< Enumerator for ::urVirtualMemFree + UR_FUNCTION_VIRTUAL_MEM_MAP = 156, ///< Enumerator for ::urVirtualMemMap + UR_FUNCTION_VIRTUAL_MEM_UNMAP = 157, ///< Enumerator for ::urVirtualMemUnmap + UR_FUNCTION_VIRTUAL_MEM_SET_ACCESS = 158, ///< Enumerator for ::urVirtualMemSetAccess + UR_FUNCTION_VIRTUAL_MEM_GET_INFO = 159, ///< Enumerator for ::urVirtualMemGetInfo + UR_FUNCTION_PHYSICAL_MEM_CREATE = 160, ///< Enumerator for ::urPhysicalMemCreate + UR_FUNCTION_PHYSICAL_MEM_RETAIN = 161, ///< Enumerator for ::urPhysicalMemRetain + UR_FUNCTION_PHYSICAL_MEM_RELEASE = 162, ///< Enumerator for ::urPhysicalMemRelease + UR_FUNCTION_USM_IMPORT_EXP = 163, ///< Enumerator for ::urUSMImportExp + UR_FUNCTION_USM_RELEASE_EXP = 164, ///< Enumerator for ::urUSMReleaseExp + UR_FUNCTION_USM_P2P_ENABLE_PEER_ACCESS_EXP = 165, ///< Enumerator for ::urUsmP2PEnablePeerAccessExp + UR_FUNCTION_USM_P2P_DISABLE_PEER_ACCESS_EXP = 166, ///< Enumerator for ::urUsmP2PDisablePeerAccessExp + UR_FUNCTION_USM_P2P_PEER_ACCESS_GET_INFO_EXP = 167, ///< Enumerator for ::urUsmP2PPeerAccessGetInfoExp + UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_EXP = 168, ///< Enumerator for ::urCommandBufferAppendMembufferWriteExp + UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_READ_EXP = 169, ///< Enumerator for ::urCommandBufferAppendMembufferReadExp + UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_RECT_EXP = 170, ///< Enumerator for ::urCommandBufferAppendMembufferWriteRectExp + UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_READ_RECT_EXP = 171, ///< Enumerator for ::urCommandBufferAppendMembufferReadRectExp + /// @cond + UR_FUNCTION_FORCE_UINT32 = 0x7fffffff + /// @endcond + +} ur_function_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Defines structure types +typedef enum ur_structure_type_t { + UR_STRUCTURE_TYPE_CONTEXT_PROPERTIES = 0, ///< ::ur_context_properties_t + UR_STRUCTURE_TYPE_IMAGE_DESC = 1, ///< ::ur_image_desc_t + UR_STRUCTURE_TYPE_BUFFER_PROPERTIES = 2, ///< ::ur_buffer_properties_t + UR_STRUCTURE_TYPE_BUFFER_REGION = 3, ///< ::ur_buffer_region_t + UR_STRUCTURE_TYPE_BUFFER_CHANNEL_PROPERTIES = 4, ///< ::ur_buffer_channel_properties_t + UR_STRUCTURE_TYPE_BUFFER_ALLOC_LOCATION_PROPERTIES = 5, ///< ::ur_buffer_alloc_location_properties_t + UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES = 6, ///< ::ur_program_properties_t + UR_STRUCTURE_TYPE_USM_DESC = 7, ///< ::ur_usm_desc_t + UR_STRUCTURE_TYPE_USM_HOST_DESC = 8, ///< ::ur_usm_host_desc_t + UR_STRUCTURE_TYPE_USM_DEVICE_DESC = 9, ///< ::ur_usm_device_desc_t + UR_STRUCTURE_TYPE_USM_POOL_DESC = 10, ///< ::ur_usm_pool_desc_t + UR_STRUCTURE_TYPE_USM_POOL_LIMITS_DESC = 11, ///< ::ur_usm_pool_limits_desc_t + UR_STRUCTURE_TYPE_DEVICE_BINARY = 12, ///< ::ur_device_binary_t + UR_STRUCTURE_TYPE_SAMPLER_DESC = 13, ///< ::ur_sampler_desc_t + UR_STRUCTURE_TYPE_QUEUE_PROPERTIES = 14, ///< ::ur_queue_properties_t + UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES = 15, ///< ::ur_queue_index_properties_t + UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES = 16, ///< ::ur_context_native_properties_t + UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES = 17, ///< ::ur_kernel_native_properties_t + UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES = 18, ///< ::ur_queue_native_properties_t + UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES = 19, ///< ::ur_mem_native_properties_t + UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES = 20, ///< ::ur_event_native_properties_t + UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES = 21, ///< ::ur_platform_native_properties_t + UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES = 22, ///< ::ur_device_native_properties_t + UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES = 23, ///< ::ur_program_native_properties_t + UR_STRUCTURE_TYPE_SAMPLER_NATIVE_PROPERTIES = 24, ///< ::ur_sampler_native_properties_t + UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC = 25, ///< ::ur_queue_native_desc_t + UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES = 26, ///< ::ur_device_partition_properties_t + UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES = 27, ///< ::ur_kernel_arg_mem_obj_properties_t + UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES = 28, ///< ::ur_physical_mem_properties_t + UR_STRUCTURE_TYPE_KERNEL_ARG_POINTER_PROPERTIES = 29, ///< ::ur_kernel_arg_pointer_properties_t + UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES = 30, ///< ::ur_kernel_arg_sampler_properties_t + UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES = 31, ///< ::ur_kernel_exec_info_properties_t + UR_STRUCTURE_TYPE_KERNEL_ARG_VALUE_PROPERTIES = 32, ///< ::ur_kernel_arg_value_properties_t + UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES = 33, ///< ::ur_kernel_arg_local_properties_t + UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC = 0x1000, ///< ::ur_exp_command_buffer_desc_t + UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES = 0x2000, ///< ::ur_exp_sampler_mip_properties_t + /// @cond + UR_STRUCTURE_TYPE_FORCE_UINT32 = 0x7fffffff + /// @endcond + +} ur_structure_type_t; + +#if !defined(__GNUC__) +#pragma endregion +#endif // Intel 'oneAPI' Unified Runtime API common types #if !defined(__GNUC__) #pragma region common @@ -230,51 +456,6 @@ typedef enum ur_result_t { } ur_result_t; -/////////////////////////////////////////////////////////////////////////////// -/// @brief Defines structure types -typedef enum ur_structure_type_t { - UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES = 0, ///< ::ur_platform_native_properties_t - UR_STRUCTURE_TYPE_DEVICE_BINARY = 1, ///< ::ur_device_binary_t - UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES = 2, ///< ::ur_device_partition_properties_t - UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES = 3, ///< ::ur_device_native_properties_t - UR_STRUCTURE_TYPE_CONTEXT_PROPERTIES = 4, ///< ::ur_context_properties_t - UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES = 5, ///< ::ur_context_native_properties_t - UR_STRUCTURE_TYPE_IMAGE_DESC = 6, ///< ::ur_image_desc_t - UR_STRUCTURE_TYPE_BUFFER_PROPERTIES = 7, ///< ::ur_buffer_properties_t - UR_STRUCTURE_TYPE_BUFFER_CHANNEL_PROPERTIES = 8, ///< ::ur_buffer_channel_properties_t - UR_STRUCTURE_TYPE_BUFFER_ALLOC_LOCATION_PROPERTIES = 9, ///< ::ur_buffer_alloc_location_properties_t - UR_STRUCTURE_TYPE_BUFFER_REGION = 10, ///< ::ur_buffer_region_t - UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES = 11, ///< ::ur_mem_native_properties_t - UR_STRUCTURE_TYPE_SAMPLER_DESC = 12, ///< ::ur_sampler_desc_t - UR_STRUCTURE_TYPE_SAMPLER_NATIVE_PROPERTIES = 13, ///< ::ur_sampler_native_properties_t - UR_STRUCTURE_TYPE_USM_DESC = 14, ///< ::ur_usm_desc_t - UR_STRUCTURE_TYPE_USM_HOST_DESC = 15, ///< ::ur_usm_host_desc_t - UR_STRUCTURE_TYPE_USM_DEVICE_DESC = 16, ///< ::ur_usm_device_desc_t - UR_STRUCTURE_TYPE_USM_POOL_DESC = 17, ///< ::ur_usm_pool_desc_t - UR_STRUCTURE_TYPE_USM_POOL_LIMITS_DESC = 18, ///< ::ur_usm_pool_limits_desc_t - UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES = 19, ///< ::ur_physical_mem_properties_t - UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES = 20, ///< ::ur_program_properties_t - UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES = 21, ///< ::ur_program_native_properties_t - UR_STRUCTURE_TYPE_KERNEL_ARG_VALUE_PROPERTIES = 22, ///< ::ur_kernel_arg_value_properties_t - UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES = 23, ///< ::ur_kernel_arg_local_properties_t - UR_STRUCTURE_TYPE_KERNEL_ARG_POINTER_PROPERTIES = 24, ///< ::ur_kernel_arg_pointer_properties_t - UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES = 25, ///< ::ur_kernel_exec_info_properties_t - UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES = 26, ///< ::ur_kernel_arg_sampler_properties_t - UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES = 27, ///< ::ur_kernel_arg_mem_obj_properties_t - UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES = 28, ///< ::ur_kernel_native_properties_t - UR_STRUCTURE_TYPE_QUEUE_PROPERTIES = 29, ///< ::ur_queue_properties_t - UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES = 30, ///< ::ur_queue_index_properties_t - UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC = 31, ///< ::ur_queue_native_desc_t - UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES = 32, ///< ::ur_queue_native_properties_t - UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES = 33, ///< ::ur_event_native_properties_t - UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC = 0x1000, ///< ::ur_exp_command_buffer_desc_t - UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES = 0x2000, ///< ::ur_exp_sampler_mip_properties_t - /// @cond - UR_STRUCTURE_TYPE_FORCE_UINT32 = 0x7fffffff - /// @endcond - -} ur_structure_type_t; - /////////////////////////////////////////////////////////////////////////////// /// @brief Base for all properties types typedef struct ur_base_properties_t { @@ -5185,187 +5366,6 @@ urEventSetCallback( void *pUserData ///< [in][out][optional] pointer to data to be passed to callback. ); -#if !defined(__GNUC__) -#pragma endregion -#endif -// Intel 'oneAPI' Unified Runtime function registry -#if !defined(__GNUC__) -#pragma region registry -#endif -/////////////////////////////////////////////////////////////////////////////// -/// @brief Defines unique stable identifiers for all functions -typedef enum ur_function_t { - UR_FUNCTION_CONTEXT_CREATE = 1, ///< Enumerator for ::urContextCreate - UR_FUNCTION_CONTEXT_RETAIN = 2, ///< Enumerator for ::urContextRetain - UR_FUNCTION_CONTEXT_RELEASE = 3, ///< Enumerator for ::urContextRelease - UR_FUNCTION_CONTEXT_GET_INFO = 4, ///< Enumerator for ::urContextGetInfo - UR_FUNCTION_CONTEXT_GET_NATIVE_HANDLE = 5, ///< Enumerator for ::urContextGetNativeHandle - UR_FUNCTION_CONTEXT_CREATE_WITH_NATIVE_HANDLE = 6, ///< Enumerator for ::urContextCreateWithNativeHandle - UR_FUNCTION_CONTEXT_SET_EXTENDED_DELETER = 7, ///< Enumerator for ::urContextSetExtendedDeleter - UR_FUNCTION_DEVICE_GET = 8, ///< Enumerator for ::urDeviceGet - UR_FUNCTION_DEVICE_GET_INFO = 9, ///< Enumerator for ::urDeviceGetInfo - UR_FUNCTION_DEVICE_RETAIN = 10, ///< Enumerator for ::urDeviceRetain - UR_FUNCTION_DEVICE_RELEASE = 11, ///< Enumerator for ::urDeviceRelease - UR_FUNCTION_DEVICE_PARTITION = 12, ///< Enumerator for ::urDevicePartition - UR_FUNCTION_DEVICE_SELECT_BINARY = 13, ///< Enumerator for ::urDeviceSelectBinary - UR_FUNCTION_DEVICE_GET_NATIVE_HANDLE = 14, ///< Enumerator for ::urDeviceGetNativeHandle - UR_FUNCTION_DEVICE_CREATE_WITH_NATIVE_HANDLE = 15, ///< Enumerator for ::urDeviceCreateWithNativeHandle - UR_FUNCTION_DEVICE_GET_GLOBAL_TIMESTAMPS = 16, ///< Enumerator for ::urDeviceGetGlobalTimestamps - UR_FUNCTION_ENQUEUE_KERNEL_LAUNCH = 17, ///< Enumerator for ::urEnqueueKernelLaunch - UR_FUNCTION_ENQUEUE_EVENTS_WAIT = 18, ///< Enumerator for ::urEnqueueEventsWait - UR_FUNCTION_ENQUEUE_EVENTS_WAIT_WITH_BARRIER = 19, ///< Enumerator for ::urEnqueueEventsWaitWithBarrier - UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ = 20, ///< Enumerator for ::urEnqueueMemBufferRead - UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE = 21, ///< Enumerator for ::urEnqueueMemBufferWrite - UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ_RECT = 22, ///< Enumerator for ::urEnqueueMemBufferReadRect - UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE_RECT = 23, ///< Enumerator for ::urEnqueueMemBufferWriteRect - UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY = 24, ///< Enumerator for ::urEnqueueMemBufferCopy - UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY_RECT = 25, ///< Enumerator for ::urEnqueueMemBufferCopyRect - UR_FUNCTION_ENQUEUE_MEM_BUFFER_FILL = 26, ///< Enumerator for ::urEnqueueMemBufferFill - UR_FUNCTION_ENQUEUE_MEM_IMAGE_READ = 27, ///< Enumerator for ::urEnqueueMemImageRead - UR_FUNCTION_ENQUEUE_MEM_IMAGE_WRITE = 28, ///< Enumerator for ::urEnqueueMemImageWrite - UR_FUNCTION_ENQUEUE_MEM_IMAGE_COPY = 29, ///< Enumerator for ::urEnqueueMemImageCopy - UR_FUNCTION_ENQUEUE_MEM_BUFFER_MAP = 30, ///< Enumerator for ::urEnqueueMemBufferMap - UR_FUNCTION_ENQUEUE_MEM_UNMAP = 31, ///< Enumerator for ::urEnqueueMemUnmap - UR_FUNCTION_ENQUEUE_USM_FILL = 32, ///< Enumerator for ::urEnqueueUSMFill - UR_FUNCTION_ENQUEUE_USM_MEMCPY = 33, ///< Enumerator for ::urEnqueueUSMMemcpy - UR_FUNCTION_ENQUEUE_USM_PREFETCH = 34, ///< Enumerator for ::urEnqueueUSMPrefetch - UR_FUNCTION_ENQUEUE_USM_ADVISE = 35, ///< Enumerator for ::urEnqueueUSMAdvise - UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_WRITE = 38, ///< Enumerator for ::urEnqueueDeviceGlobalVariableWrite - UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_READ = 39, ///< Enumerator for ::urEnqueueDeviceGlobalVariableRead - UR_FUNCTION_EVENT_GET_INFO = 40, ///< Enumerator for ::urEventGetInfo - UR_FUNCTION_EVENT_GET_PROFILING_INFO = 41, ///< Enumerator for ::urEventGetProfilingInfo - UR_FUNCTION_EVENT_WAIT = 42, ///< Enumerator for ::urEventWait - UR_FUNCTION_EVENT_RETAIN = 43, ///< Enumerator for ::urEventRetain - UR_FUNCTION_EVENT_RELEASE = 44, ///< Enumerator for ::urEventRelease - UR_FUNCTION_EVENT_GET_NATIVE_HANDLE = 45, ///< Enumerator for ::urEventGetNativeHandle - UR_FUNCTION_EVENT_CREATE_WITH_NATIVE_HANDLE = 46, ///< Enumerator for ::urEventCreateWithNativeHandle - UR_FUNCTION_EVENT_SET_CALLBACK = 47, ///< Enumerator for ::urEventSetCallback - UR_FUNCTION_KERNEL_CREATE = 48, ///< Enumerator for ::urKernelCreate - UR_FUNCTION_KERNEL_SET_ARG_VALUE = 49, ///< Enumerator for ::urKernelSetArgValue - UR_FUNCTION_KERNEL_SET_ARG_LOCAL = 50, ///< Enumerator for ::urKernelSetArgLocal - UR_FUNCTION_KERNEL_GET_INFO = 51, ///< Enumerator for ::urKernelGetInfo - UR_FUNCTION_KERNEL_GET_GROUP_INFO = 52, ///< Enumerator for ::urKernelGetGroupInfo - UR_FUNCTION_KERNEL_GET_SUB_GROUP_INFO = 53, ///< Enumerator for ::urKernelGetSubGroupInfo - UR_FUNCTION_KERNEL_RETAIN = 54, ///< Enumerator for ::urKernelRetain - UR_FUNCTION_KERNEL_RELEASE = 55, ///< Enumerator for ::urKernelRelease - UR_FUNCTION_KERNEL_SET_ARG_POINTER = 56, ///< Enumerator for ::urKernelSetArgPointer - UR_FUNCTION_KERNEL_SET_EXEC_INFO = 57, ///< Enumerator for ::urKernelSetExecInfo - UR_FUNCTION_KERNEL_SET_ARG_SAMPLER = 58, ///< Enumerator for ::urKernelSetArgSampler - UR_FUNCTION_KERNEL_SET_ARG_MEM_OBJ = 59, ///< Enumerator for ::urKernelSetArgMemObj - UR_FUNCTION_KERNEL_SET_SPECIALIZATION_CONSTANTS = 60, ///< Enumerator for ::urKernelSetSpecializationConstants - UR_FUNCTION_KERNEL_GET_NATIVE_HANDLE = 61, ///< Enumerator for ::urKernelGetNativeHandle - UR_FUNCTION_KERNEL_CREATE_WITH_NATIVE_HANDLE = 62, ///< Enumerator for ::urKernelCreateWithNativeHandle - UR_FUNCTION_MEM_IMAGE_CREATE = 63, ///< Enumerator for ::urMemImageCreate - UR_FUNCTION_MEM_BUFFER_CREATE = 64, ///< Enumerator for ::urMemBufferCreate - UR_FUNCTION_MEM_RETAIN = 65, ///< Enumerator for ::urMemRetain - UR_FUNCTION_MEM_RELEASE = 66, ///< Enumerator for ::urMemRelease - UR_FUNCTION_MEM_BUFFER_PARTITION = 67, ///< Enumerator for ::urMemBufferPartition - UR_FUNCTION_MEM_GET_NATIVE_HANDLE = 68, ///< Enumerator for ::urMemGetNativeHandle - UR_FUNCTION_ENQUEUE_READ_HOST_PIPE = 69, ///< Enumerator for ::urEnqueueReadHostPipe - UR_FUNCTION_MEM_GET_INFO = 70, ///< Enumerator for ::urMemGetInfo - UR_FUNCTION_MEM_IMAGE_GET_INFO = 71, ///< Enumerator for ::urMemImageGetInfo - UR_FUNCTION_PLATFORM_GET = 72, ///< Enumerator for ::urPlatformGet - UR_FUNCTION_PLATFORM_GET_INFO = 73, ///< Enumerator for ::urPlatformGetInfo - UR_FUNCTION_PLATFORM_GET_API_VERSION = 74, ///< Enumerator for ::urPlatformGetApiVersion - UR_FUNCTION_PLATFORM_GET_NATIVE_HANDLE = 75, ///< Enumerator for ::urPlatformGetNativeHandle - UR_FUNCTION_PLATFORM_CREATE_WITH_NATIVE_HANDLE = 76, ///< Enumerator for ::urPlatformCreateWithNativeHandle - UR_FUNCTION_PROGRAM_CREATE_WITH_IL = 78, ///< Enumerator for ::urProgramCreateWithIL - UR_FUNCTION_PROGRAM_CREATE_WITH_BINARY = 79, ///< Enumerator for ::urProgramCreateWithBinary - UR_FUNCTION_PROGRAM_BUILD = 80, ///< Enumerator for ::urProgramBuild - UR_FUNCTION_PROGRAM_COMPILE = 81, ///< Enumerator for ::urProgramCompile - UR_FUNCTION_PROGRAM_LINK = 82, ///< Enumerator for ::urProgramLink - UR_FUNCTION_PROGRAM_RETAIN = 83, ///< Enumerator for ::urProgramRetain - UR_FUNCTION_PROGRAM_RELEASE = 84, ///< Enumerator for ::urProgramRelease - UR_FUNCTION_PROGRAM_GET_FUNCTION_POINTER = 85, ///< Enumerator for ::urProgramGetFunctionPointer - UR_FUNCTION_PROGRAM_GET_INFO = 86, ///< Enumerator for ::urProgramGetInfo - UR_FUNCTION_PROGRAM_GET_BUILD_INFO = 87, ///< Enumerator for ::urProgramGetBuildInfo - UR_FUNCTION_PROGRAM_SET_SPECIALIZATION_CONSTANTS = 88, ///< Enumerator for ::urProgramSetSpecializationConstants - UR_FUNCTION_PROGRAM_GET_NATIVE_HANDLE = 89, ///< Enumerator for ::urProgramGetNativeHandle - UR_FUNCTION_PROGRAM_CREATE_WITH_NATIVE_HANDLE = 90, ///< Enumerator for ::urProgramCreateWithNativeHandle - UR_FUNCTION_QUEUE_GET_INFO = 91, ///< Enumerator for ::urQueueGetInfo - UR_FUNCTION_QUEUE_CREATE = 92, ///< Enumerator for ::urQueueCreate - UR_FUNCTION_QUEUE_RETAIN = 93, ///< Enumerator for ::urQueueRetain - UR_FUNCTION_QUEUE_RELEASE = 94, ///< Enumerator for ::urQueueRelease - UR_FUNCTION_QUEUE_GET_NATIVE_HANDLE = 95, ///< Enumerator for ::urQueueGetNativeHandle - UR_FUNCTION_QUEUE_CREATE_WITH_NATIVE_HANDLE = 96, ///< Enumerator for ::urQueueCreateWithNativeHandle - UR_FUNCTION_QUEUE_FINISH = 97, ///< Enumerator for ::urQueueFinish - UR_FUNCTION_QUEUE_FLUSH = 98, ///< Enumerator for ::urQueueFlush - UR_FUNCTION_INIT = 99, ///< Enumerator for ::urInit - UR_FUNCTION_TEAR_DOWN = 100, ///< Enumerator for ::urTearDown - UR_FUNCTION_SAMPLER_CREATE = 101, ///< Enumerator for ::urSamplerCreate - UR_FUNCTION_SAMPLER_RETAIN = 102, ///< Enumerator for ::urSamplerRetain - UR_FUNCTION_SAMPLER_RELEASE = 103, ///< Enumerator for ::urSamplerRelease - UR_FUNCTION_SAMPLER_GET_INFO = 104, ///< Enumerator for ::urSamplerGetInfo - UR_FUNCTION_SAMPLER_GET_NATIVE_HANDLE = 105, ///< Enumerator for ::urSamplerGetNativeHandle - UR_FUNCTION_SAMPLER_CREATE_WITH_NATIVE_HANDLE = 106, ///< Enumerator for ::urSamplerCreateWithNativeHandle - UR_FUNCTION_USM_HOST_ALLOC = 107, ///< Enumerator for ::urUSMHostAlloc - UR_FUNCTION_USM_DEVICE_ALLOC = 108, ///< Enumerator for ::urUSMDeviceAlloc - UR_FUNCTION_USM_SHARED_ALLOC = 109, ///< Enumerator for ::urUSMSharedAlloc - UR_FUNCTION_USM_FREE = 110, ///< Enumerator for ::urUSMFree - UR_FUNCTION_USM_GET_MEM_ALLOC_INFO = 111, ///< Enumerator for ::urUSMGetMemAllocInfo - UR_FUNCTION_USM_POOL_CREATE = 112, ///< Enumerator for ::urUSMPoolCreate - UR_FUNCTION_COMMAND_BUFFER_CREATE_EXP = 113, ///< Enumerator for ::urCommandBufferCreateExp - UR_FUNCTION_PLATFORM_GET_BACKEND_OPTION = 114, ///< Enumerator for ::urPlatformGetBackendOption - UR_FUNCTION_MEM_BUFFER_CREATE_WITH_NATIVE_HANDLE = 115, ///< Enumerator for ::urMemBufferCreateWithNativeHandle - UR_FUNCTION_MEM_IMAGE_CREATE_WITH_NATIVE_HANDLE = 116, ///< Enumerator for ::urMemImageCreateWithNativeHandle - UR_FUNCTION_ENQUEUE_WRITE_HOST_PIPE = 117, ///< Enumerator for ::urEnqueueWriteHostPipe - UR_FUNCTION_USM_POOL_RETAIN = 118, ///< Enumerator for ::urUSMPoolRetain - UR_FUNCTION_USM_POOL_RELEASE = 119, ///< Enumerator for ::urUSMPoolRelease - UR_FUNCTION_USM_POOL_GET_INFO = 120, ///< Enumerator for ::urUSMPoolGetInfo - UR_FUNCTION_COMMAND_BUFFER_RETAIN_EXP = 121, ///< Enumerator for ::urCommandBufferRetainExp - UR_FUNCTION_COMMAND_BUFFER_RELEASE_EXP = 122, ///< Enumerator for ::urCommandBufferReleaseExp - UR_FUNCTION_COMMAND_BUFFER_FINALIZE_EXP = 123, ///< Enumerator for ::urCommandBufferFinalizeExp - UR_FUNCTION_COMMAND_BUFFER_APPEND_KERNEL_LAUNCH_EXP = 125, ///< Enumerator for ::urCommandBufferAppendKernelLaunchExp - UR_FUNCTION_COMMAND_BUFFER_ENQUEUE_EXP = 128, ///< Enumerator for ::urCommandBufferEnqueueExp - UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMCPY_USM_EXP = 129, ///< Enumerator for ::urCommandBufferAppendMemcpyUSMExp - UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_EXP = 130, ///< Enumerator for ::urCommandBufferAppendMembufferCopyExp - UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_RECT_EXP = 131, ///< Enumerator for ::urCommandBufferAppendMembufferCopyRectExp - UR_FUNCTION_USM_PITCHED_ALLOC_EXP = 132, ///< Enumerator for ::urUSMPitchedAllocExp - UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_HANDLE_DESTROY_EXP = 133, ///< Enumerator for ::urBindlessImagesUnsampledImageHandleDestroyExp - UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_HANDLE_DESTROY_EXP = 134, ///< Enumerator for ::urBindlessImagesSampledImageHandleDestroyExp - UR_FUNCTION_BINDLESS_IMAGES_IMAGE_ALLOCATE_EXP = 135, ///< Enumerator for ::urBindlessImagesImageAllocateExp - UR_FUNCTION_BINDLESS_IMAGES_IMAGE_FREE_EXP = 136, ///< Enumerator for ::urBindlessImagesImageFreeExp - UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_CREATE_EXP = 137, ///< Enumerator for ::urBindlessImagesUnsampledImageCreateExp - UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_CREATE_EXP = 138, ///< Enumerator for ::urBindlessImagesSampledImageCreateExp - UR_FUNCTION_BINDLESS_IMAGES_IMAGE_COPY_EXP = 139, ///< Enumerator for ::urBindlessImagesImageCopyExp - UR_FUNCTION_BINDLESS_IMAGES_IMAGE_GET_INFO_EXP = 140, ///< Enumerator for ::urBindlessImagesImageGetInfoExp - UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_GET_LEVEL_EXP = 141, ///< Enumerator for ::urBindlessImagesMipmapGetLevelExp - UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_FREE_EXP = 142, ///< Enumerator for ::urBindlessImagesMipmapFreeExp - UR_FUNCTION_BINDLESS_IMAGES_IMPORT_OPAQUE_FD_EXP = 143, ///< Enumerator for ::urBindlessImagesImportOpaqueFDExp - UR_FUNCTION_BINDLESS_IMAGES_MAP_EXTERNAL_ARRAY_EXP = 144, ///< Enumerator for ::urBindlessImagesMapExternalArrayExp - UR_FUNCTION_BINDLESS_IMAGES_RELEASE_INTEROP_EXP = 145, ///< Enumerator for ::urBindlessImagesReleaseInteropExp - UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXP = 146, ///< Enumerator for ::urBindlessImagesImportExternalSemaphoreOpaqueFDExp - UR_FUNCTION_BINDLESS_IMAGES_DESTROY_EXTERNAL_SEMAPHORE_EXP = 147, ///< Enumerator for ::urBindlessImagesDestroyExternalSemaphoreExp - UR_FUNCTION_BINDLESS_IMAGES_WAIT_EXTERNAL_SEMAPHORE_EXP = 148, ///< Enumerator for ::urBindlessImagesWaitExternalSemaphoreExp - UR_FUNCTION_BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP = 149, ///< Enumerator for ::urBindlessImagesSignalExternalSemaphoreExp - UR_FUNCTION_PLATFORM_GET_LAST_ERROR = 150, ///< Enumerator for ::urPlatformGetLastError - UR_FUNCTION_ENQUEUE_USM_FILL_2D = 151, ///< Enumerator for ::urEnqueueUSMFill2D - UR_FUNCTION_ENQUEUE_USM_MEMCPY_2D = 152, ///< Enumerator for ::urEnqueueUSMMemcpy2D - UR_FUNCTION_VIRTUAL_MEM_GRANULARITY_GET_INFO = 153, ///< Enumerator for ::urVirtualMemGranularityGetInfo - UR_FUNCTION_VIRTUAL_MEM_RESERVE = 154, ///< Enumerator for ::urVirtualMemReserve - UR_FUNCTION_VIRTUAL_MEM_FREE = 155, ///< Enumerator for ::urVirtualMemFree - UR_FUNCTION_VIRTUAL_MEM_MAP = 156, ///< Enumerator for ::urVirtualMemMap - UR_FUNCTION_VIRTUAL_MEM_UNMAP = 157, ///< Enumerator for ::urVirtualMemUnmap - UR_FUNCTION_VIRTUAL_MEM_SET_ACCESS = 158, ///< Enumerator for ::urVirtualMemSetAccess - UR_FUNCTION_VIRTUAL_MEM_GET_INFO = 159, ///< Enumerator for ::urVirtualMemGetInfo - UR_FUNCTION_PHYSICAL_MEM_CREATE = 160, ///< Enumerator for ::urPhysicalMemCreate - UR_FUNCTION_PHYSICAL_MEM_RETAIN = 161, ///< Enumerator for ::urPhysicalMemRetain - UR_FUNCTION_PHYSICAL_MEM_RELEASE = 162, ///< Enumerator for ::urPhysicalMemRelease - UR_FUNCTION_USM_IMPORT_EXP = 163, ///< Enumerator for ::urUSMImportExp - UR_FUNCTION_USM_RELEASE_EXP = 164, ///< Enumerator for ::urUSMReleaseExp - UR_FUNCTION_USM_P2P_ENABLE_PEER_ACCESS_EXP = 165, ///< Enumerator for ::urUsmP2PEnablePeerAccessExp - UR_FUNCTION_USM_P2P_DISABLE_PEER_ACCESS_EXP = 166, ///< Enumerator for ::urUsmP2PDisablePeerAccessExp - UR_FUNCTION_USM_P2P_PEER_ACCESS_GET_INFO_EXP = 167, ///< Enumerator for ::urUsmP2PPeerAccessGetInfoExp - UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_EXP = 168, ///< Enumerator for ::urCommandBufferAppendMembufferWriteExp - UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_READ_EXP = 169, ///< Enumerator for ::urCommandBufferAppendMembufferReadExp - UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_RECT_EXP = 170, ///< Enumerator for ::urCommandBufferAppendMembufferWriteRectExp - UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_READ_RECT_EXP = 171, ///< Enumerator for ::urCommandBufferAppendMembufferReadRectExp - /// @cond - UR_FUNCTION_FORCE_UINT32 = 0x7fffffff - /// @endcond - -} ur_function_t; - #if !defined(__GNUC__) #pragma endregion #endif diff --git a/scripts/core/registry.yml b/scripts/core/registry.yml index e29203afdc..00096044ce 100644 --- a/scripts/core/registry.yml +++ b/scripts/core/registry.yml @@ -1,7 +1,7 @@ --- type: header desc: "Intel $OneApi Unified Runtime function registry" -ordinal: "9" +ordinal: "-1" --- name: $x_function_t type: enum @@ -502,3 +502,110 @@ etors: - name: COMMAND_BUFFER_APPEND_MEMBUFFER_READ_RECT_EXP desc: Enumerator for $xCommandBufferAppendMembufferReadRectExp value: '171' +--- +type: enum +desc: Defines structure types +name: $x_structure_type_t +etors: +- name: CONTEXT_PROPERTIES + desc: $x_context_properties_t + value: '0' +- name: IMAGE_DESC + desc: $x_image_desc_t + value: '1' +- name: BUFFER_PROPERTIES + desc: $x_buffer_properties_t + value: '2' +- name: BUFFER_REGION + desc: $x_buffer_region_t + value: '3' +- name: BUFFER_CHANNEL_PROPERTIES + desc: $x_buffer_channel_properties_t + value: '4' +- name: BUFFER_ALLOC_LOCATION_PROPERTIES + desc: $x_buffer_alloc_location_properties_t + value: '5' +- name: PROGRAM_PROPERTIES + desc: $x_program_properties_t + value: '6' +- name: USM_DESC + desc: $x_usm_desc_t + value: '7' +- name: USM_HOST_DESC + desc: $x_usm_host_desc_t + value: '8' +- name: USM_DEVICE_DESC + desc: $x_usm_device_desc_t + value: '9' +- name: USM_POOL_DESC + desc: $x_usm_pool_desc_t + value: '10' +- name: USM_POOL_LIMITS_DESC + desc: $x_usm_pool_limits_desc_t + value: '11' +- name: DEVICE_BINARY + desc: $x_device_binary_t + value: '12' +- name: SAMPLER_DESC + desc: $x_sampler_desc_t + value: '13' +- name: QUEUE_PROPERTIES + desc: $x_queue_properties_t + value: '14' +- name: QUEUE_INDEX_PROPERTIES + desc: $x_queue_index_properties_t + value: '15' +- name: CONTEXT_NATIVE_PROPERTIES + desc: $x_context_native_properties_t + value: '16' +- name: KERNEL_NATIVE_PROPERTIES + desc: $x_kernel_native_properties_t + value: '17' +- name: QUEUE_NATIVE_PROPERTIES + desc: $x_queue_native_properties_t + value: '18' +- name: MEM_NATIVE_PROPERTIES + desc: $x_mem_native_properties_t + value: '19' +- name: EVENT_NATIVE_PROPERTIES + desc: $x_event_native_properties_t + value: '20' +- name: PLATFORM_NATIVE_PROPERTIES + desc: $x_platform_native_properties_t + value: '21' +- name: DEVICE_NATIVE_PROPERTIES + desc: $x_device_native_properties_t + value: '22' +- name: PROGRAM_NATIVE_PROPERTIES + desc: $x_program_native_properties_t + value: '23' +- name: SAMPLER_NATIVE_PROPERTIES + desc: $x_sampler_native_properties_t + value: '24' +- name: QUEUE_NATIVE_DESC + desc: $x_queue_native_desc_t + value: '25' +- name: DEVICE_PARTITION_PROPERTIES + desc: $x_device_partition_properties_t + value: '26' +- name: KERNEL_ARG_MEM_OBJ_PROPERTIES + desc: $x_kernel_arg_mem_obj_properties_t + value: '27' +- name: PHYSICAL_MEM_PROPERTIES + desc: $x_physical_mem_properties_t + value: '28' +- name: KERNEL_ARG_POINTER_PROPERTIES + desc: $x_kernel_arg_pointer_properties_t + value: '29' +- name: KERNEL_ARG_SAMPLER_PROPERTIES + desc: $x_kernel_arg_sampler_properties_t + value: '30' +- name: KERNEL_EXEC_INFO_PROPERTIES + desc: $x_kernel_exec_info_properties_t + value: '31' +- name: KERNEL_ARG_VALUE_PROPERTIES + desc: $x_kernel_arg_value_properties_t + value: '32' +- name: KERNEL_ARG_LOCAL_PROPERTIES + desc: $x_kernel_arg_local_properties_t + value: '33' diff --git a/scripts/generate_ids.py b/scripts/generate_ids.py index 26dfd89fb7..c015c25dac 100644 --- a/scripts/generate_ids.py +++ b/scripts/generate_ids.py @@ -18,9 +18,21 @@ class quoted(str): def quoted_presenter(dumper, data): return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='"') +def write_registry(data, path): + header = {'type': 'header', 'desc': quoted('Intel $OneApi Unified Runtime function registry'), 'ordinal': quoted(-1)} + data.insert(0, header) + with open(path, 'w') as fout: + yaml.add_representer(quoted, quoted_presenter) + yaml.dump_all(data, fout, + default_flow_style=False, + sort_keys=False, + explicit_start=True) + + def generate_registry(path, specs): try: - existing_registry = list(util.yamlRead(path))[1]['etors'] + contents = list(util.yamlRead(path)) + existing_registry = contents[1]['etors'] existing_etors = {etor["name"]: etor["value"] for etor in existing_registry} max_etor = int(max(existing_registry, key = lambda x : int(x["value"]))["value"]) functions = [obj['class'][len('$x'):] + obj['name'] for s in specs for obj in s['objects'] if obj['type'] == 'function'] @@ -34,13 +46,9 @@ def generate_registry(path, specs): registry.append({'name': util.to_snake_case(fname).upper(), 'desc': 'Enumerator for $x'+fname, 'value': str(id)}) registry = sorted(registry, key=lambda x: int(x['value'])) wrapper = { 'name': ENUM_NAME, 'type': 'enum', 'desc': 'Defines unique stable identifiers for all functions' , 'etors': registry} - header = {'type': 'header', 'desc': quoted('Intel $OneApi Unified Runtime function registry'), 'ordinal': quoted(9)} - with open(path, 'w') as fout: - yaml.add_representer(quoted, quoted_presenter) - yaml.dump_all([header, wrapper], fout, - default_flow_style=False, - sort_keys=False, - explicit_start=True) + contents[1] = wrapper + write_registry(contents[1:], path) + except BaseException as e: print("Failed to generate registry.yml... %s", e) raise e diff --git a/scripts/parse_specs.py b/scripts/parse_specs.py index 844ee44f19..3f5d23a501 100644 --- a/scripts/parse_specs.py +++ b/scripts/parse_specs.py @@ -853,26 +853,54 @@ def sort_etors(x): return value matching_enum['etors'] = sorted(matching_enum['etors'], key=sort_etors) -def _generate_structure_type_t(specs, meta): +def _generate_structure_type_t(specs, meta, registry): extended_structs = [obj for s in specs for obj in s['objects'] if re.match(r"struct|union", obj['type']) and 'base' in obj] - ur_structure_type_t = { - "type": "enum", - "desc": "Defines structure types", - "name": "$x_structure_type_t", - "etors": [] - } + ur_structure_type_t = [obj for s in specs for obj in s['objects'] if obj['name'] == "$x_structure_type_t"][0] + existing_etors = ur_structure_type_t['etors'] + max_enum = int(max(ur_structure_type_t['etors'], key= lambda x : int(x['value']))['value']) + + out_etors = [] for struct in extended_structs: + # skip experimental enumerations if struct['name'].startswith("$x_exp_"): continue - stype = [mem for mem in struct['members'] if mem['name'] == 'stype'][0] - etor = stype['init'] - ur_structure_type_t['etors'].append({"name": etor, "desc": struct['name']}) - - common_header = [s for s in specs if s['header']['desc'].endswith("common types")][0] - result_t_index = [i for i, obj in enumerate(common_header['objects']) if obj['name'] == "$x_result_t"][0] - common_header['objects'].insert(result_t_index + 1, ur_structure_type_t) + + # name of the etor + etor = [mem for mem in struct['members'] if mem['name'] == 'stype'][0]['init'] + + # try and match the etor + matched_etor = [e for e in existing_etors if e['name'] == etor] + + # if no match exists then we have to add it + if len(matched_etor) == 0: + max_enum += 1 + out_etors.append({ + "name": etor, + "desc": struct['name'], + "value": str(max_enum) + }) + else: + out_etors.append({ + "name": etor, + "desc": struct['name'], + "value": matched_etor[0]['value'] + }) + + out_etors = sorted(out_etors, key = lambda x : int(x['value'])) + ur_structure_type_t['etors'] = out_etors _refresh_enum_meta(ur_structure_type_t, meta) + ## write the result out to the yml file + try: + contents = list(util.yamlRead(registry)) + cpy = copy.deepcopy(ur_structure_type_t) + for e in cpy['etors']: + e['name'] = e['name'][len("$X_STRUCTURE_TYPE_"):] + contents[2] = cpy + generate_ids.write_registry(contents[1:], registry) + except: + raise + """ Entry-point: Reads each YML file and extracts data @@ -942,7 +970,8 @@ def parse(section, version, tags, meta, ref): specs = sorted(specs, key=lambda s: s['header']['ordinal']) _inline_extended_structs(specs, meta) - _generate_structure_type_t(specs, meta) + registry = [f for f in files if f.endswith('registry.yml')][0] + _generate_structure_type_t(specs, meta, registry) _extend_enums(enum_extensions, specs, meta) _generate_extra(specs, meta) diff --git a/source/common/ur_params.hpp b/source/common/ur_params.hpp index 592efb43ad..02fc6d8e5e 100644 --- a/source/common/ur_params.hpp +++ b/source/common/ur_params.hpp @@ -181,9 +181,10 @@ inline void serializeTagged(std::ostream &os, const void *ptr, } // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, enum ur_result_t value); +inline std::ostream &operator<<(std::ostream &os, enum ur_function_t value); inline std::ostream &operator<<(std::ostream &os, enum ur_structure_type_t value); +inline std::ostream &operator<<(std::ostream &os, enum ur_result_t value); inline std::ostream &operator<<(std::ostream &os, const struct ur_base_properties_t params); inline std::ostream &operator<<(std::ostream &os, @@ -379,7 +380,6 @@ inline std::ostream & operator<<(std::ostream &os, const struct ur_event_native_properties_t params); inline std::ostream &operator<<(std::ostream &os, enum ur_execution_info_t value); -inline std::ostream &operator<<(std::ostream &os, enum ur_function_t value); inline std::ostream &operator<<(std::ostream &os, enum ur_map_flag_t value); inline std::ostream &operator<<(std::ostream &os, enum ur_usm_migration_flag_t value); @@ -393,1572 +393,1545 @@ operator<<(std::ostream &os, const struct ur_exp_command_buffer_desc_t params); inline std::ostream &operator<<(std::ostream &os, enum ur_exp_peer_info_t value); -inline std::ostream &operator<<(std::ostream &os, enum ur_result_t value) { +inline std::ostream &operator<<(std::ostream &os, enum ur_function_t value) { switch (value) { - case UR_RESULT_SUCCESS: - os << "UR_RESULT_SUCCESS"; + case UR_FUNCTION_CONTEXT_CREATE: + os << "UR_FUNCTION_CONTEXT_CREATE"; break; - case UR_RESULT_ERROR_INVALID_OPERATION: - os << "UR_RESULT_ERROR_INVALID_OPERATION"; + case UR_FUNCTION_CONTEXT_RETAIN: + os << "UR_FUNCTION_CONTEXT_RETAIN"; break; - case UR_RESULT_ERROR_INVALID_QUEUE_PROPERTIES: - os << "UR_RESULT_ERROR_INVALID_QUEUE_PROPERTIES"; + case UR_FUNCTION_CONTEXT_RELEASE: + os << "UR_FUNCTION_CONTEXT_RELEASE"; break; - case UR_RESULT_ERROR_INVALID_QUEUE: - os << "UR_RESULT_ERROR_INVALID_QUEUE"; + case UR_FUNCTION_CONTEXT_GET_INFO: + os << "UR_FUNCTION_CONTEXT_GET_INFO"; break; - case UR_RESULT_ERROR_INVALID_VALUE: - os << "UR_RESULT_ERROR_INVALID_VALUE"; + case UR_FUNCTION_CONTEXT_GET_NATIVE_HANDLE: + os << "UR_FUNCTION_CONTEXT_GET_NATIVE_HANDLE"; break; - case UR_RESULT_ERROR_INVALID_CONTEXT: - os << "UR_RESULT_ERROR_INVALID_CONTEXT"; + case UR_FUNCTION_CONTEXT_CREATE_WITH_NATIVE_HANDLE: + os << "UR_FUNCTION_CONTEXT_CREATE_WITH_NATIVE_HANDLE"; break; - case UR_RESULT_ERROR_INVALID_PLATFORM: - os << "UR_RESULT_ERROR_INVALID_PLATFORM"; + case UR_FUNCTION_CONTEXT_SET_EXTENDED_DELETER: + os << "UR_FUNCTION_CONTEXT_SET_EXTENDED_DELETER"; break; - case UR_RESULT_ERROR_INVALID_BINARY: - os << "UR_RESULT_ERROR_INVALID_BINARY"; + case UR_FUNCTION_DEVICE_GET: + os << "UR_FUNCTION_DEVICE_GET"; break; - case UR_RESULT_ERROR_INVALID_PROGRAM: - os << "UR_RESULT_ERROR_INVALID_PROGRAM"; + case UR_FUNCTION_DEVICE_GET_INFO: + os << "UR_FUNCTION_DEVICE_GET_INFO"; break; - case UR_RESULT_ERROR_INVALID_SAMPLER: - os << "UR_RESULT_ERROR_INVALID_SAMPLER"; + case UR_FUNCTION_DEVICE_RETAIN: + os << "UR_FUNCTION_DEVICE_RETAIN"; break; - case UR_RESULT_ERROR_INVALID_BUFFER_SIZE: - os << "UR_RESULT_ERROR_INVALID_BUFFER_SIZE"; + case UR_FUNCTION_DEVICE_RELEASE: + os << "UR_FUNCTION_DEVICE_RELEASE"; break; - case UR_RESULT_ERROR_INVALID_MEM_OBJECT: - os << "UR_RESULT_ERROR_INVALID_MEM_OBJECT"; + case UR_FUNCTION_DEVICE_PARTITION: + os << "UR_FUNCTION_DEVICE_PARTITION"; break; - case UR_RESULT_ERROR_INVALID_EVENT: - os << "UR_RESULT_ERROR_INVALID_EVENT"; + case UR_FUNCTION_DEVICE_SELECT_BINARY: + os << "UR_FUNCTION_DEVICE_SELECT_BINARY"; break; - case UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST: - os << "UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST"; + case UR_FUNCTION_DEVICE_GET_NATIVE_HANDLE: + os << "UR_FUNCTION_DEVICE_GET_NATIVE_HANDLE"; break; - case UR_RESULT_ERROR_MISALIGNED_SUB_BUFFER_OFFSET: - os << "UR_RESULT_ERROR_MISALIGNED_SUB_BUFFER_OFFSET"; + case UR_FUNCTION_DEVICE_CREATE_WITH_NATIVE_HANDLE: + os << "UR_FUNCTION_DEVICE_CREATE_WITH_NATIVE_HANDLE"; break; - case UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE: - os << "UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE"; + case UR_FUNCTION_DEVICE_GET_GLOBAL_TIMESTAMPS: + os << "UR_FUNCTION_DEVICE_GET_GLOBAL_TIMESTAMPS"; break; - case UR_RESULT_ERROR_COMPILER_NOT_AVAILABLE: - os << "UR_RESULT_ERROR_COMPILER_NOT_AVAILABLE"; + case UR_FUNCTION_ENQUEUE_KERNEL_LAUNCH: + os << "UR_FUNCTION_ENQUEUE_KERNEL_LAUNCH"; break; - case UR_RESULT_ERROR_PROFILING_INFO_NOT_AVAILABLE: - os << "UR_RESULT_ERROR_PROFILING_INFO_NOT_AVAILABLE"; + case UR_FUNCTION_ENQUEUE_EVENTS_WAIT: + os << "UR_FUNCTION_ENQUEUE_EVENTS_WAIT"; break; - case UR_RESULT_ERROR_DEVICE_NOT_FOUND: - os << "UR_RESULT_ERROR_DEVICE_NOT_FOUND"; + case UR_FUNCTION_ENQUEUE_EVENTS_WAIT_WITH_BARRIER: + os << "UR_FUNCTION_ENQUEUE_EVENTS_WAIT_WITH_BARRIER"; break; - case UR_RESULT_ERROR_INVALID_DEVICE: - os << "UR_RESULT_ERROR_INVALID_DEVICE"; + case UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ: + os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ"; break; - case UR_RESULT_ERROR_DEVICE_LOST: - os << "UR_RESULT_ERROR_DEVICE_LOST"; + case UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE: + os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE"; break; - case UR_RESULT_ERROR_DEVICE_REQUIRES_RESET: - os << "UR_RESULT_ERROR_DEVICE_REQUIRES_RESET"; + case UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ_RECT: + os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ_RECT"; break; - case UR_RESULT_ERROR_DEVICE_IN_LOW_POWER_STATE: - os << "UR_RESULT_ERROR_DEVICE_IN_LOW_POWER_STATE"; + case UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE_RECT: + os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE_RECT"; break; - case UR_RESULT_ERROR_DEVICE_PARTITION_FAILED: - os << "UR_RESULT_ERROR_DEVICE_PARTITION_FAILED"; + case UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY: + os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY"; break; - case UR_RESULT_ERROR_INVALID_DEVICE_PARTITION_COUNT: - os << "UR_RESULT_ERROR_INVALID_DEVICE_PARTITION_COUNT"; + case UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY_RECT: + os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY_RECT"; break; - case UR_RESULT_ERROR_INVALID_WORK_ITEM_SIZE: - os << "UR_RESULT_ERROR_INVALID_WORK_ITEM_SIZE"; + case UR_FUNCTION_ENQUEUE_MEM_BUFFER_FILL: + os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_FILL"; break; - case UR_RESULT_ERROR_INVALID_WORK_DIMENSION: - os << "UR_RESULT_ERROR_INVALID_WORK_DIMENSION"; + case UR_FUNCTION_ENQUEUE_MEM_IMAGE_READ: + os << "UR_FUNCTION_ENQUEUE_MEM_IMAGE_READ"; break; - case UR_RESULT_ERROR_INVALID_KERNEL_ARGS: - os << "UR_RESULT_ERROR_INVALID_KERNEL_ARGS"; + case UR_FUNCTION_ENQUEUE_MEM_IMAGE_WRITE: + os << "UR_FUNCTION_ENQUEUE_MEM_IMAGE_WRITE"; break; - case UR_RESULT_ERROR_INVALID_KERNEL: - os << "UR_RESULT_ERROR_INVALID_KERNEL"; + case UR_FUNCTION_ENQUEUE_MEM_IMAGE_COPY: + os << "UR_FUNCTION_ENQUEUE_MEM_IMAGE_COPY"; break; - case UR_RESULT_ERROR_INVALID_KERNEL_NAME: - os << "UR_RESULT_ERROR_INVALID_KERNEL_NAME"; + case UR_FUNCTION_ENQUEUE_MEM_BUFFER_MAP: + os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_MAP"; break; - case UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_INDEX: - os << "UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_INDEX"; + case UR_FUNCTION_ENQUEUE_MEM_UNMAP: + os << "UR_FUNCTION_ENQUEUE_MEM_UNMAP"; break; - case UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE: - os << "UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE"; + case UR_FUNCTION_ENQUEUE_USM_FILL: + os << "UR_FUNCTION_ENQUEUE_USM_FILL"; break; - case UR_RESULT_ERROR_INVALID_KERNEL_ATTRIBUTE_VALUE: - os << "UR_RESULT_ERROR_INVALID_KERNEL_ATTRIBUTE_VALUE"; + case UR_FUNCTION_ENQUEUE_USM_MEMCPY: + os << "UR_FUNCTION_ENQUEUE_USM_MEMCPY"; break; - case UR_RESULT_ERROR_INVALID_IMAGE_SIZE: - os << "UR_RESULT_ERROR_INVALID_IMAGE_SIZE"; + case UR_FUNCTION_ENQUEUE_USM_PREFETCH: + os << "UR_FUNCTION_ENQUEUE_USM_PREFETCH"; break; - case UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR: - os << "UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR"; + case UR_FUNCTION_ENQUEUE_USM_ADVISE: + os << "UR_FUNCTION_ENQUEUE_USM_ADVISE"; break; - case UR_RESULT_ERROR_IMAGE_FORMAT_NOT_SUPPORTED: - os << "UR_RESULT_ERROR_IMAGE_FORMAT_NOT_SUPPORTED"; + case UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_WRITE: + os << "UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_WRITE"; break; - case UR_RESULT_ERROR_MEM_OBJECT_ALLOCATION_FAILURE: - os << "UR_RESULT_ERROR_MEM_OBJECT_ALLOCATION_FAILURE"; + case UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_READ: + os << "UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_READ"; break; - case UR_RESULT_ERROR_INVALID_PROGRAM_EXECUTABLE: - os << "UR_RESULT_ERROR_INVALID_PROGRAM_EXECUTABLE"; + case UR_FUNCTION_EVENT_GET_INFO: + os << "UR_FUNCTION_EVENT_GET_INFO"; break; - case UR_RESULT_ERROR_UNINITIALIZED: - os << "UR_RESULT_ERROR_UNINITIALIZED"; + case UR_FUNCTION_EVENT_GET_PROFILING_INFO: + os << "UR_FUNCTION_EVENT_GET_PROFILING_INFO"; break; - case UR_RESULT_ERROR_OUT_OF_HOST_MEMORY: - os << "UR_RESULT_ERROR_OUT_OF_HOST_MEMORY"; + case UR_FUNCTION_EVENT_WAIT: + os << "UR_FUNCTION_EVENT_WAIT"; break; - case UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY: - os << "UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY"; + case UR_FUNCTION_EVENT_RETAIN: + os << "UR_FUNCTION_EVENT_RETAIN"; break; - case UR_RESULT_ERROR_OUT_OF_RESOURCES: - os << "UR_RESULT_ERROR_OUT_OF_RESOURCES"; + case UR_FUNCTION_EVENT_RELEASE: + os << "UR_FUNCTION_EVENT_RELEASE"; break; - case UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE: - os << "UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE"; + case UR_FUNCTION_EVENT_GET_NATIVE_HANDLE: + os << "UR_FUNCTION_EVENT_GET_NATIVE_HANDLE"; break; - case UR_RESULT_ERROR_PROGRAM_LINK_FAILURE: - os << "UR_RESULT_ERROR_PROGRAM_LINK_FAILURE"; + case UR_FUNCTION_EVENT_CREATE_WITH_NATIVE_HANDLE: + os << "UR_FUNCTION_EVENT_CREATE_WITH_NATIVE_HANDLE"; break; - case UR_RESULT_ERROR_UNSUPPORTED_VERSION: - os << "UR_RESULT_ERROR_UNSUPPORTED_VERSION"; + case UR_FUNCTION_EVENT_SET_CALLBACK: + os << "UR_FUNCTION_EVENT_SET_CALLBACK"; break; - case UR_RESULT_ERROR_UNSUPPORTED_FEATURE: - os << "UR_RESULT_ERROR_UNSUPPORTED_FEATURE"; + case UR_FUNCTION_KERNEL_CREATE: + os << "UR_FUNCTION_KERNEL_CREATE"; break; - case UR_RESULT_ERROR_INVALID_ARGUMENT: - os << "UR_RESULT_ERROR_INVALID_ARGUMENT"; + case UR_FUNCTION_KERNEL_SET_ARG_VALUE: + os << "UR_FUNCTION_KERNEL_SET_ARG_VALUE"; break; - case UR_RESULT_ERROR_INVALID_NULL_HANDLE: - os << "UR_RESULT_ERROR_INVALID_NULL_HANDLE"; + case UR_FUNCTION_KERNEL_SET_ARG_LOCAL: + os << "UR_FUNCTION_KERNEL_SET_ARG_LOCAL"; break; - case UR_RESULT_ERROR_HANDLE_OBJECT_IN_USE: - os << "UR_RESULT_ERROR_HANDLE_OBJECT_IN_USE"; + case UR_FUNCTION_KERNEL_GET_INFO: + os << "UR_FUNCTION_KERNEL_GET_INFO"; break; - case UR_RESULT_ERROR_INVALID_NULL_POINTER: - os << "UR_RESULT_ERROR_INVALID_NULL_POINTER"; + case UR_FUNCTION_KERNEL_GET_GROUP_INFO: + os << "UR_FUNCTION_KERNEL_GET_GROUP_INFO"; break; - case UR_RESULT_ERROR_INVALID_SIZE: - os << "UR_RESULT_ERROR_INVALID_SIZE"; + case UR_FUNCTION_KERNEL_GET_SUB_GROUP_INFO: + os << "UR_FUNCTION_KERNEL_GET_SUB_GROUP_INFO"; break; - case UR_RESULT_ERROR_UNSUPPORTED_SIZE: - os << "UR_RESULT_ERROR_UNSUPPORTED_SIZE"; + case UR_FUNCTION_KERNEL_RETAIN: + os << "UR_FUNCTION_KERNEL_RETAIN"; break; - case UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT: - os << "UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT"; + case UR_FUNCTION_KERNEL_RELEASE: + os << "UR_FUNCTION_KERNEL_RELEASE"; break; - case UR_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT: - os << "UR_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT"; + case UR_FUNCTION_KERNEL_SET_ARG_POINTER: + os << "UR_FUNCTION_KERNEL_SET_ARG_POINTER"; break; - case UR_RESULT_ERROR_INVALID_ENUMERATION: - os << "UR_RESULT_ERROR_INVALID_ENUMERATION"; + case UR_FUNCTION_KERNEL_SET_EXEC_INFO: + os << "UR_FUNCTION_KERNEL_SET_EXEC_INFO"; break; - case UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION: - os << "UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION"; + case UR_FUNCTION_KERNEL_SET_ARG_SAMPLER: + os << "UR_FUNCTION_KERNEL_SET_ARG_SAMPLER"; break; - case UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT: - os << "UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT"; + case UR_FUNCTION_KERNEL_SET_ARG_MEM_OBJ: + os << "UR_FUNCTION_KERNEL_SET_ARG_MEM_OBJ"; break; - case UR_RESULT_ERROR_INVALID_NATIVE_BINARY: - os << "UR_RESULT_ERROR_INVALID_NATIVE_BINARY"; + case UR_FUNCTION_KERNEL_SET_SPECIALIZATION_CONSTANTS: + os << "UR_FUNCTION_KERNEL_SET_SPECIALIZATION_CONSTANTS"; break; - case UR_RESULT_ERROR_INVALID_GLOBAL_NAME: - os << "UR_RESULT_ERROR_INVALID_GLOBAL_NAME"; + case UR_FUNCTION_KERNEL_GET_NATIVE_HANDLE: + os << "UR_FUNCTION_KERNEL_GET_NATIVE_HANDLE"; break; - case UR_RESULT_ERROR_INVALID_FUNCTION_NAME: - os << "UR_RESULT_ERROR_INVALID_FUNCTION_NAME"; + case UR_FUNCTION_KERNEL_CREATE_WITH_NATIVE_HANDLE: + os << "UR_FUNCTION_KERNEL_CREATE_WITH_NATIVE_HANDLE"; break; - case UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION: - os << "UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION"; + case UR_FUNCTION_MEM_IMAGE_CREATE: + os << "UR_FUNCTION_MEM_IMAGE_CREATE"; break; - case UR_RESULT_ERROR_INVALID_GLOBAL_WIDTH_DIMENSION: - os << "UR_RESULT_ERROR_INVALID_GLOBAL_WIDTH_DIMENSION"; + case UR_FUNCTION_MEM_BUFFER_CREATE: + os << "UR_FUNCTION_MEM_BUFFER_CREATE"; break; - case UR_RESULT_ERROR_PROGRAM_UNLINKED: - os << "UR_RESULT_ERROR_PROGRAM_UNLINKED"; + case UR_FUNCTION_MEM_RETAIN: + os << "UR_FUNCTION_MEM_RETAIN"; break; - case UR_RESULT_ERROR_OVERLAPPING_REGIONS: - os << "UR_RESULT_ERROR_OVERLAPPING_REGIONS"; + case UR_FUNCTION_MEM_RELEASE: + os << "UR_FUNCTION_MEM_RELEASE"; break; - case UR_RESULT_ERROR_INVALID_HOST_PTR: - os << "UR_RESULT_ERROR_INVALID_HOST_PTR"; + case UR_FUNCTION_MEM_BUFFER_PARTITION: + os << "UR_FUNCTION_MEM_BUFFER_PARTITION"; break; - case UR_RESULT_ERROR_INVALID_USM_SIZE: - os << "UR_RESULT_ERROR_INVALID_USM_SIZE"; + case UR_FUNCTION_MEM_GET_NATIVE_HANDLE: + os << "UR_FUNCTION_MEM_GET_NATIVE_HANDLE"; break; - case UR_RESULT_ERROR_OBJECT_ALLOCATION_FAILURE: - os << "UR_RESULT_ERROR_OBJECT_ALLOCATION_FAILURE"; + case UR_FUNCTION_ENQUEUE_READ_HOST_PIPE: + os << "UR_FUNCTION_ENQUEUE_READ_HOST_PIPE"; break; - case UR_RESULT_ERROR_ADAPTER_SPECIFIC: - os << "UR_RESULT_ERROR_ADAPTER_SPECIFIC"; + case UR_FUNCTION_MEM_GET_INFO: + os << "UR_FUNCTION_MEM_GET_INFO"; break; - case UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_EXP: - os << "UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_EXP"; + case UR_FUNCTION_MEM_IMAGE_GET_INFO: + os << "UR_FUNCTION_MEM_IMAGE_GET_INFO"; break; - case UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_EXP: - os << "UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_EXP"; + case UR_FUNCTION_PLATFORM_GET: + os << "UR_FUNCTION_PLATFORM_GET"; break; - case UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_WAIT_LIST_EXP: - os << "UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_WAIT_LIST_EXP"; + case UR_FUNCTION_PLATFORM_GET_INFO: + os << "UR_FUNCTION_PLATFORM_GET_INFO"; break; - case UR_RESULT_ERROR_UNKNOWN: - os << "UR_RESULT_ERROR_UNKNOWN"; + case UR_FUNCTION_PLATFORM_GET_API_VERSION: + os << "UR_FUNCTION_PLATFORM_GET_API_VERSION"; break; - default: - os << "unknown enumerator"; + + case UR_FUNCTION_PLATFORM_GET_NATIVE_HANDLE: + os << "UR_FUNCTION_PLATFORM_GET_NATIVE_HANDLE"; break; - } - return os; -} -inline std::ostream &operator<<(std::ostream &os, - enum ur_structure_type_t value) { - switch (value) { - case UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES"; + case UR_FUNCTION_PLATFORM_CREATE_WITH_NATIVE_HANDLE: + os << "UR_FUNCTION_PLATFORM_CREATE_WITH_NATIVE_HANDLE"; break; - case UR_STRUCTURE_TYPE_DEVICE_BINARY: - os << "UR_STRUCTURE_TYPE_DEVICE_BINARY"; + case UR_FUNCTION_PROGRAM_CREATE_WITH_IL: + os << "UR_FUNCTION_PROGRAM_CREATE_WITH_IL"; break; - case UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES: - os << "UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES"; + case UR_FUNCTION_PROGRAM_CREATE_WITH_BINARY: + os << "UR_FUNCTION_PROGRAM_CREATE_WITH_BINARY"; break; - case UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES"; + case UR_FUNCTION_PROGRAM_BUILD: + os << "UR_FUNCTION_PROGRAM_BUILD"; break; - case UR_STRUCTURE_TYPE_CONTEXT_PROPERTIES: - os << "UR_STRUCTURE_TYPE_CONTEXT_PROPERTIES"; + case UR_FUNCTION_PROGRAM_COMPILE: + os << "UR_FUNCTION_PROGRAM_COMPILE"; break; - case UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES"; + case UR_FUNCTION_PROGRAM_LINK: + os << "UR_FUNCTION_PROGRAM_LINK"; break; - case UR_STRUCTURE_TYPE_IMAGE_DESC: - os << "UR_STRUCTURE_TYPE_IMAGE_DESC"; + case UR_FUNCTION_PROGRAM_RETAIN: + os << "UR_FUNCTION_PROGRAM_RETAIN"; break; - case UR_STRUCTURE_TYPE_BUFFER_PROPERTIES: - os << "UR_STRUCTURE_TYPE_BUFFER_PROPERTIES"; + case UR_FUNCTION_PROGRAM_RELEASE: + os << "UR_FUNCTION_PROGRAM_RELEASE"; break; - case UR_STRUCTURE_TYPE_BUFFER_CHANNEL_PROPERTIES: - os << "UR_STRUCTURE_TYPE_BUFFER_CHANNEL_PROPERTIES"; + case UR_FUNCTION_PROGRAM_GET_FUNCTION_POINTER: + os << "UR_FUNCTION_PROGRAM_GET_FUNCTION_POINTER"; break; - case UR_STRUCTURE_TYPE_BUFFER_ALLOC_LOCATION_PROPERTIES: - os << "UR_STRUCTURE_TYPE_BUFFER_ALLOC_LOCATION_PROPERTIES"; + case UR_FUNCTION_PROGRAM_GET_INFO: + os << "UR_FUNCTION_PROGRAM_GET_INFO"; break; - case UR_STRUCTURE_TYPE_BUFFER_REGION: - os << "UR_STRUCTURE_TYPE_BUFFER_REGION"; + case UR_FUNCTION_PROGRAM_GET_BUILD_INFO: + os << "UR_FUNCTION_PROGRAM_GET_BUILD_INFO"; break; - case UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES"; + case UR_FUNCTION_PROGRAM_SET_SPECIALIZATION_CONSTANTS: + os << "UR_FUNCTION_PROGRAM_SET_SPECIALIZATION_CONSTANTS"; break; - case UR_STRUCTURE_TYPE_SAMPLER_DESC: - os << "UR_STRUCTURE_TYPE_SAMPLER_DESC"; + case UR_FUNCTION_PROGRAM_GET_NATIVE_HANDLE: + os << "UR_FUNCTION_PROGRAM_GET_NATIVE_HANDLE"; break; - case UR_STRUCTURE_TYPE_SAMPLER_NATIVE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_SAMPLER_NATIVE_PROPERTIES"; + case UR_FUNCTION_PROGRAM_CREATE_WITH_NATIVE_HANDLE: + os << "UR_FUNCTION_PROGRAM_CREATE_WITH_NATIVE_HANDLE"; break; - case UR_STRUCTURE_TYPE_USM_DESC: - os << "UR_STRUCTURE_TYPE_USM_DESC"; + case UR_FUNCTION_QUEUE_GET_INFO: + os << "UR_FUNCTION_QUEUE_GET_INFO"; break; - case UR_STRUCTURE_TYPE_USM_HOST_DESC: - os << "UR_STRUCTURE_TYPE_USM_HOST_DESC"; + case UR_FUNCTION_QUEUE_CREATE: + os << "UR_FUNCTION_QUEUE_CREATE"; break; - case UR_STRUCTURE_TYPE_USM_DEVICE_DESC: - os << "UR_STRUCTURE_TYPE_USM_DEVICE_DESC"; + case UR_FUNCTION_QUEUE_RETAIN: + os << "UR_FUNCTION_QUEUE_RETAIN"; break; - case UR_STRUCTURE_TYPE_USM_POOL_DESC: - os << "UR_STRUCTURE_TYPE_USM_POOL_DESC"; + case UR_FUNCTION_QUEUE_RELEASE: + os << "UR_FUNCTION_QUEUE_RELEASE"; break; - case UR_STRUCTURE_TYPE_USM_POOL_LIMITS_DESC: - os << "UR_STRUCTURE_TYPE_USM_POOL_LIMITS_DESC"; + case UR_FUNCTION_QUEUE_GET_NATIVE_HANDLE: + os << "UR_FUNCTION_QUEUE_GET_NATIVE_HANDLE"; break; - case UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES: - os << "UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES"; + case UR_FUNCTION_QUEUE_CREATE_WITH_NATIVE_HANDLE: + os << "UR_FUNCTION_QUEUE_CREATE_WITH_NATIVE_HANDLE"; break; - case UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES: - os << "UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES"; + case UR_FUNCTION_QUEUE_FINISH: + os << "UR_FUNCTION_QUEUE_FINISH"; break; - case UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES"; + case UR_FUNCTION_QUEUE_FLUSH: + os << "UR_FUNCTION_QUEUE_FLUSH"; break; - case UR_STRUCTURE_TYPE_KERNEL_ARG_VALUE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_KERNEL_ARG_VALUE_PROPERTIES"; + case UR_FUNCTION_INIT: + os << "UR_FUNCTION_INIT"; break; - case UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES: - os << "UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES"; + case UR_FUNCTION_TEAR_DOWN: + os << "UR_FUNCTION_TEAR_DOWN"; break; - case UR_STRUCTURE_TYPE_KERNEL_ARG_POINTER_PROPERTIES: - os << "UR_STRUCTURE_TYPE_KERNEL_ARG_POINTER_PROPERTIES"; + case UR_FUNCTION_SAMPLER_CREATE: + os << "UR_FUNCTION_SAMPLER_CREATE"; break; - case UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES: - os << "UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES"; + case UR_FUNCTION_SAMPLER_RETAIN: + os << "UR_FUNCTION_SAMPLER_RETAIN"; break; - case UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES: - os << "UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES"; + case UR_FUNCTION_SAMPLER_RELEASE: + os << "UR_FUNCTION_SAMPLER_RELEASE"; break; - case UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES: - os << "UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES"; + case UR_FUNCTION_SAMPLER_GET_INFO: + os << "UR_FUNCTION_SAMPLER_GET_INFO"; break; - case UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES"; + case UR_FUNCTION_SAMPLER_GET_NATIVE_HANDLE: + os << "UR_FUNCTION_SAMPLER_GET_NATIVE_HANDLE"; break; - case UR_STRUCTURE_TYPE_QUEUE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_QUEUE_PROPERTIES"; + case UR_FUNCTION_SAMPLER_CREATE_WITH_NATIVE_HANDLE: + os << "UR_FUNCTION_SAMPLER_CREATE_WITH_NATIVE_HANDLE"; break; - case UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES: - os << "UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES"; + case UR_FUNCTION_USM_HOST_ALLOC: + os << "UR_FUNCTION_USM_HOST_ALLOC"; break; - case UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC: - os << "UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC"; + case UR_FUNCTION_USM_DEVICE_ALLOC: + os << "UR_FUNCTION_USM_DEVICE_ALLOC"; break; - case UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES"; + case UR_FUNCTION_USM_SHARED_ALLOC: + os << "UR_FUNCTION_USM_SHARED_ALLOC"; break; - case UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES"; + case UR_FUNCTION_USM_FREE: + os << "UR_FUNCTION_USM_FREE"; break; - case UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC: - os << "UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC"; + case UR_FUNCTION_USM_GET_MEM_ALLOC_INFO: + os << "UR_FUNCTION_USM_GET_MEM_ALLOC_INFO"; break; - case UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES: - os << "UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES"; + case UR_FUNCTION_USM_POOL_CREATE: + os << "UR_FUNCTION_USM_POOL_CREATE"; break; - default: - os << "unknown enumerator"; + + case UR_FUNCTION_COMMAND_BUFFER_CREATE_EXP: + os << "UR_FUNCTION_COMMAND_BUFFER_CREATE_EXP"; break; - } - return os; -} -namespace ur_params { -inline void serializeStruct(std::ostream &os, const void *ptr) { - if (ptr == NULL) { - ur_params::serializePtr(os, ptr); - return; - } - enum ur_structure_type_t *value = (enum ur_structure_type_t *)ptr; - switch (*value) { + case UR_FUNCTION_PLATFORM_GET_BACKEND_OPTION: + os << "UR_FUNCTION_PLATFORM_GET_BACKEND_OPTION"; + break; - case UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES: { - const ur_platform_native_properties_t *pstruct = - (const ur_platform_native_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_MEM_BUFFER_CREATE_WITH_NATIVE_HANDLE: + os << "UR_FUNCTION_MEM_BUFFER_CREATE_WITH_NATIVE_HANDLE"; + break; - case UR_STRUCTURE_TYPE_DEVICE_BINARY: { - const ur_device_binary_t *pstruct = (const ur_device_binary_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_MEM_IMAGE_CREATE_WITH_NATIVE_HANDLE: + os << "UR_FUNCTION_MEM_IMAGE_CREATE_WITH_NATIVE_HANDLE"; + break; - case UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES: { - const ur_device_partition_properties_t *pstruct = - (const ur_device_partition_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_ENQUEUE_WRITE_HOST_PIPE: + os << "UR_FUNCTION_ENQUEUE_WRITE_HOST_PIPE"; + break; - case UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES: { - const ur_device_native_properties_t *pstruct = - (const ur_device_native_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_USM_POOL_RETAIN: + os << "UR_FUNCTION_USM_POOL_RETAIN"; + break; - case UR_STRUCTURE_TYPE_CONTEXT_PROPERTIES: { - const ur_context_properties_t *pstruct = - (const ur_context_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_USM_POOL_RELEASE: + os << "UR_FUNCTION_USM_POOL_RELEASE"; + break; - case UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES: { - const ur_context_native_properties_t *pstruct = - (const ur_context_native_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; - - case UR_STRUCTURE_TYPE_IMAGE_DESC: { - const ur_image_desc_t *pstruct = (const ur_image_desc_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_USM_POOL_GET_INFO: + os << "UR_FUNCTION_USM_POOL_GET_INFO"; + break; - case UR_STRUCTURE_TYPE_BUFFER_PROPERTIES: { - const ur_buffer_properties_t *pstruct = - (const ur_buffer_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_COMMAND_BUFFER_RETAIN_EXP: + os << "UR_FUNCTION_COMMAND_BUFFER_RETAIN_EXP"; + break; - case UR_STRUCTURE_TYPE_BUFFER_CHANNEL_PROPERTIES: { - const ur_buffer_channel_properties_t *pstruct = - (const ur_buffer_channel_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_COMMAND_BUFFER_RELEASE_EXP: + os << "UR_FUNCTION_COMMAND_BUFFER_RELEASE_EXP"; + break; - case UR_STRUCTURE_TYPE_BUFFER_ALLOC_LOCATION_PROPERTIES: { - const ur_buffer_alloc_location_properties_t *pstruct = - (const ur_buffer_alloc_location_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_COMMAND_BUFFER_FINALIZE_EXP: + os << "UR_FUNCTION_COMMAND_BUFFER_FINALIZE_EXP"; + break; - case UR_STRUCTURE_TYPE_BUFFER_REGION: { - const ur_buffer_region_t *pstruct = (const ur_buffer_region_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_COMMAND_BUFFER_APPEND_KERNEL_LAUNCH_EXP: + os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_KERNEL_LAUNCH_EXP"; + break; - case UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES: { - const ur_mem_native_properties_t *pstruct = - (const ur_mem_native_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_COMMAND_BUFFER_ENQUEUE_EXP: + os << "UR_FUNCTION_COMMAND_BUFFER_ENQUEUE_EXP"; + break; - case UR_STRUCTURE_TYPE_SAMPLER_DESC: { - const ur_sampler_desc_t *pstruct = (const ur_sampler_desc_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMCPY_USM_EXP: + os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMCPY_USM_EXP"; + break; - case UR_STRUCTURE_TYPE_SAMPLER_NATIVE_PROPERTIES: { - const ur_sampler_native_properties_t *pstruct = - (const ur_sampler_native_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_EXP: + os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_EXP"; + break; - case UR_STRUCTURE_TYPE_USM_DESC: { - const ur_usm_desc_t *pstruct = (const ur_usm_desc_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_RECT_EXP: + os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_RECT_EXP"; + break; - case UR_STRUCTURE_TYPE_USM_HOST_DESC: { - const ur_usm_host_desc_t *pstruct = (const ur_usm_host_desc_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_USM_PITCHED_ALLOC_EXP: + os << "UR_FUNCTION_USM_PITCHED_ALLOC_EXP"; + break; - case UR_STRUCTURE_TYPE_USM_DEVICE_DESC: { - const ur_usm_device_desc_t *pstruct = (const ur_usm_device_desc_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_HANDLE_DESTROY_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_HANDLE_DESTROY_EXP"; + break; - case UR_STRUCTURE_TYPE_USM_POOL_DESC: { - const ur_usm_pool_desc_t *pstruct = (const ur_usm_pool_desc_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_HANDLE_DESTROY_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_HANDLE_DESTROY_EXP"; + break; - case UR_STRUCTURE_TYPE_USM_POOL_LIMITS_DESC: { - const ur_usm_pool_limits_desc_t *pstruct = - (const ur_usm_pool_limits_desc_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_BINDLESS_IMAGES_IMAGE_ALLOCATE_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_IMAGE_ALLOCATE_EXP"; + break; - case UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES: { - const ur_physical_mem_properties_t *pstruct = - (const ur_physical_mem_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_BINDLESS_IMAGES_IMAGE_FREE_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_IMAGE_FREE_EXP"; + break; - case UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES: { - const ur_program_properties_t *pstruct = - (const ur_program_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_CREATE_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_CREATE_EXP"; + break; - case UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES: { - const ur_program_native_properties_t *pstruct = - (const ur_program_native_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_CREATE_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_CREATE_EXP"; + break; - case UR_STRUCTURE_TYPE_KERNEL_ARG_VALUE_PROPERTIES: { - const ur_kernel_arg_value_properties_t *pstruct = - (const ur_kernel_arg_value_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_BINDLESS_IMAGES_IMAGE_COPY_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_IMAGE_COPY_EXP"; + break; - case UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES: { - const ur_kernel_arg_local_properties_t *pstruct = - (const ur_kernel_arg_local_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_BINDLESS_IMAGES_IMAGE_GET_INFO_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_IMAGE_GET_INFO_EXP"; + break; - case UR_STRUCTURE_TYPE_KERNEL_ARG_POINTER_PROPERTIES: { - const ur_kernel_arg_pointer_properties_t *pstruct = - (const ur_kernel_arg_pointer_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_GET_LEVEL_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_GET_LEVEL_EXP"; + break; - case UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES: { - const ur_kernel_exec_info_properties_t *pstruct = - (const ur_kernel_exec_info_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_FREE_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_FREE_EXP"; + break; - case UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES: { - const ur_kernel_arg_sampler_properties_t *pstruct = - (const ur_kernel_arg_sampler_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_BINDLESS_IMAGES_IMPORT_OPAQUE_FD_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_IMPORT_OPAQUE_FD_EXP"; + break; - case UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES: { - const ur_kernel_arg_mem_obj_properties_t *pstruct = - (const ur_kernel_arg_mem_obj_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_BINDLESS_IMAGES_MAP_EXTERNAL_ARRAY_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_MAP_EXTERNAL_ARRAY_EXP"; + break; - case UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES: { - const ur_kernel_native_properties_t *pstruct = - (const ur_kernel_native_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_BINDLESS_IMAGES_RELEASE_INTEROP_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_RELEASE_INTEROP_EXP"; + break; - case UR_STRUCTURE_TYPE_QUEUE_PROPERTIES: { - const ur_queue_properties_t *pstruct = - (const ur_queue_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_OPAQUE_FD_" + "EXP"; + break; - case UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES: { - const ur_queue_index_properties_t *pstruct = - (const ur_queue_index_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_BINDLESS_IMAGES_DESTROY_EXTERNAL_SEMAPHORE_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_DESTROY_EXTERNAL_SEMAPHORE_EXP"; + break; - case UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC: { - const ur_queue_native_desc_t *pstruct = - (const ur_queue_native_desc_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_BINDLESS_IMAGES_WAIT_EXTERNAL_SEMAPHORE_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_WAIT_EXTERNAL_SEMAPHORE_EXP"; + break; - case UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES: { - const ur_queue_native_properties_t *pstruct = - (const ur_queue_native_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP"; + break; - case UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES: { - const ur_event_native_properties_t *pstruct = - (const ur_event_native_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_PLATFORM_GET_LAST_ERROR: + os << "UR_FUNCTION_PLATFORM_GET_LAST_ERROR"; + break; - case UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC: { - const ur_exp_command_buffer_desc_t *pstruct = - (const ur_exp_command_buffer_desc_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_ENQUEUE_USM_FILL_2D: + os << "UR_FUNCTION_ENQUEUE_USM_FILL_2D"; + break; - case UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES: { - const ur_exp_sampler_mip_properties_t *pstruct = - (const ur_exp_sampler_mip_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; - default: - os << "unknown enumerator"; + case UR_FUNCTION_ENQUEUE_USM_MEMCPY_2D: + os << "UR_FUNCTION_ENQUEUE_USM_MEMCPY_2D"; break; - } -} -} // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, - const struct ur_base_properties_t params) { - os << "(struct ur_base_properties_t){"; - os << ".stype = "; + case UR_FUNCTION_VIRTUAL_MEM_GRANULARITY_GET_INFO: + os << "UR_FUNCTION_VIRTUAL_MEM_GRANULARITY_GET_INFO"; + break; - os << (params.stype); + case UR_FUNCTION_VIRTUAL_MEM_RESERVE: + os << "UR_FUNCTION_VIRTUAL_MEM_RESERVE"; + break; - os << ", "; - os << ".pNext = "; + case UR_FUNCTION_VIRTUAL_MEM_FREE: + os << "UR_FUNCTION_VIRTUAL_MEM_FREE"; + break; - ur_params::serializeStruct(os, (params.pNext)); + case UR_FUNCTION_VIRTUAL_MEM_MAP: + os << "UR_FUNCTION_VIRTUAL_MEM_MAP"; + break; - os << "}"; - return os; -} -inline std::ostream &operator<<(std::ostream &os, - const struct ur_base_desc_t params) { - os << "(struct ur_base_desc_t){"; + case UR_FUNCTION_VIRTUAL_MEM_UNMAP: + os << "UR_FUNCTION_VIRTUAL_MEM_UNMAP"; + break; - os << ".stype = "; + case UR_FUNCTION_VIRTUAL_MEM_SET_ACCESS: + os << "UR_FUNCTION_VIRTUAL_MEM_SET_ACCESS"; + break; - os << (params.stype); + case UR_FUNCTION_VIRTUAL_MEM_GET_INFO: + os << "UR_FUNCTION_VIRTUAL_MEM_GET_INFO"; + break; - os << ", "; - os << ".pNext = "; + case UR_FUNCTION_PHYSICAL_MEM_CREATE: + os << "UR_FUNCTION_PHYSICAL_MEM_CREATE"; + break; - ur_params::serializeStruct(os, (params.pNext)); + case UR_FUNCTION_PHYSICAL_MEM_RETAIN: + os << "UR_FUNCTION_PHYSICAL_MEM_RETAIN"; + break; - os << "}"; - return os; -} -inline std::ostream &operator<<(std::ostream &os, - const struct ur_rect_offset_t params) { - os << "(struct ur_rect_offset_t){"; + case UR_FUNCTION_PHYSICAL_MEM_RELEASE: + os << "UR_FUNCTION_PHYSICAL_MEM_RELEASE"; + break; - os << ".x = "; + case UR_FUNCTION_USM_IMPORT_EXP: + os << "UR_FUNCTION_USM_IMPORT_EXP"; + break; - os << (params.x); + case UR_FUNCTION_USM_RELEASE_EXP: + os << "UR_FUNCTION_USM_RELEASE_EXP"; + break; - os << ", "; - os << ".y = "; + case UR_FUNCTION_USM_P2P_ENABLE_PEER_ACCESS_EXP: + os << "UR_FUNCTION_USM_P2P_ENABLE_PEER_ACCESS_EXP"; + break; - os << (params.y); + case UR_FUNCTION_USM_P2P_DISABLE_PEER_ACCESS_EXP: + os << "UR_FUNCTION_USM_P2P_DISABLE_PEER_ACCESS_EXP"; + break; - os << ", "; - os << ".z = "; + case UR_FUNCTION_USM_P2P_PEER_ACCESS_GET_INFO_EXP: + os << "UR_FUNCTION_USM_P2P_PEER_ACCESS_GET_INFO_EXP"; + break; - os << (params.z); + case UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_EXP: + os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_EXP"; + break; - os << "}"; + case UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_READ_EXP: + os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_READ_EXP"; + break; + + case UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_RECT_EXP: + os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_RECT_EXP"; + break; + + case UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_READ_RECT_EXP: + os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_READ_RECT_EXP"; + break; + default: + os << "unknown enumerator"; + break; + } return os; } inline std::ostream &operator<<(std::ostream &os, - const struct ur_rect_region_t params) { - os << "(struct ur_rect_region_t){"; + enum ur_structure_type_t value) { + switch (value) { - os << ".width = "; + case UR_STRUCTURE_TYPE_CONTEXT_PROPERTIES: + os << "UR_STRUCTURE_TYPE_CONTEXT_PROPERTIES"; + break; - os << (params.width); + case UR_STRUCTURE_TYPE_IMAGE_DESC: + os << "UR_STRUCTURE_TYPE_IMAGE_DESC"; + break; - os << ", "; - os << ".height = "; + case UR_STRUCTURE_TYPE_BUFFER_PROPERTIES: + os << "UR_STRUCTURE_TYPE_BUFFER_PROPERTIES"; + break; - os << (params.height); + case UR_STRUCTURE_TYPE_BUFFER_REGION: + os << "UR_STRUCTURE_TYPE_BUFFER_REGION"; + break; - os << ", "; - os << ".depth = "; + case UR_STRUCTURE_TYPE_BUFFER_CHANNEL_PROPERTIES: + os << "UR_STRUCTURE_TYPE_BUFFER_CHANNEL_PROPERTIES"; + break; - os << (params.depth); + case UR_STRUCTURE_TYPE_BUFFER_ALLOC_LOCATION_PROPERTIES: + os << "UR_STRUCTURE_TYPE_BUFFER_ALLOC_LOCATION_PROPERTIES"; + break; - os << "}"; - return os; -} -inline std::ostream &operator<<(std::ostream &os, - enum ur_device_init_flag_t value) { - switch (value) { + case UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES: + os << "UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES"; + break; - case UR_DEVICE_INIT_FLAG_GPU: - os << "UR_DEVICE_INIT_FLAG_GPU"; + case UR_STRUCTURE_TYPE_USM_DESC: + os << "UR_STRUCTURE_TYPE_USM_DESC"; break; - case UR_DEVICE_INIT_FLAG_CPU: - os << "UR_DEVICE_INIT_FLAG_CPU"; + case UR_STRUCTURE_TYPE_USM_HOST_DESC: + os << "UR_STRUCTURE_TYPE_USM_HOST_DESC"; break; - case UR_DEVICE_INIT_FLAG_FPGA: - os << "UR_DEVICE_INIT_FLAG_FPGA"; + case UR_STRUCTURE_TYPE_USM_DEVICE_DESC: + os << "UR_STRUCTURE_TYPE_USM_DEVICE_DESC"; break; - case UR_DEVICE_INIT_FLAG_MCA: - os << "UR_DEVICE_INIT_FLAG_MCA"; + case UR_STRUCTURE_TYPE_USM_POOL_DESC: + os << "UR_STRUCTURE_TYPE_USM_POOL_DESC"; break; - case UR_DEVICE_INIT_FLAG_VPU: - os << "UR_DEVICE_INIT_FLAG_VPU"; + case UR_STRUCTURE_TYPE_USM_POOL_LIMITS_DESC: + os << "UR_STRUCTURE_TYPE_USM_POOL_LIMITS_DESC"; break; - default: - os << "unknown enumerator"; + + case UR_STRUCTURE_TYPE_DEVICE_BINARY: + os << "UR_STRUCTURE_TYPE_DEVICE_BINARY"; break; - } - return os; -} -namespace ur_params { -template <> -inline void serializeFlag(std::ostream &os, - uint32_t flag) { - uint32_t val = flag; - bool first = true; + case UR_STRUCTURE_TYPE_SAMPLER_DESC: + os << "UR_STRUCTURE_TYPE_SAMPLER_DESC"; + break; - if ((val & UR_DEVICE_INIT_FLAG_GPU) == (uint32_t)UR_DEVICE_INIT_FLAG_GPU) { - val ^= (uint32_t)UR_DEVICE_INIT_FLAG_GPU; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_DEVICE_INIT_FLAG_GPU; - } + case UR_STRUCTURE_TYPE_QUEUE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_QUEUE_PROPERTIES"; + break; - if ((val & UR_DEVICE_INIT_FLAG_CPU) == (uint32_t)UR_DEVICE_INIT_FLAG_CPU) { - val ^= (uint32_t)UR_DEVICE_INIT_FLAG_CPU; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_DEVICE_INIT_FLAG_CPU; - } + case UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES: + os << "UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES"; + break; - if ((val & UR_DEVICE_INIT_FLAG_FPGA) == - (uint32_t)UR_DEVICE_INIT_FLAG_FPGA) { - val ^= (uint32_t)UR_DEVICE_INIT_FLAG_FPGA; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_DEVICE_INIT_FLAG_FPGA; - } + case UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES"; + break; - if ((val & UR_DEVICE_INIT_FLAG_MCA) == (uint32_t)UR_DEVICE_INIT_FLAG_MCA) { - val ^= (uint32_t)UR_DEVICE_INIT_FLAG_MCA; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_DEVICE_INIT_FLAG_MCA; - } + case UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES"; + break; - if ((val & UR_DEVICE_INIT_FLAG_VPU) == (uint32_t)UR_DEVICE_INIT_FLAG_VPU) { - val ^= (uint32_t)UR_DEVICE_INIT_FLAG_VPU; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_DEVICE_INIT_FLAG_VPU; - } - if (val != 0) { - std::bitset<32> bits(val); - if (!first) { - os << " | "; - } - os << "unknown bit flags " << bits; - } else if (first) { - os << "0"; - } -} -} // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, - enum ur_platform_info_t value) { - switch (value) { + case UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES"; + break; - case UR_PLATFORM_INFO_NAME: - os << "UR_PLATFORM_INFO_NAME"; + case UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES"; break; - case UR_PLATFORM_INFO_VENDOR_NAME: - os << "UR_PLATFORM_INFO_VENDOR_NAME"; + case UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES"; break; - case UR_PLATFORM_INFO_VERSION: - os << "UR_PLATFORM_INFO_VERSION"; + case UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES"; break; - case UR_PLATFORM_INFO_EXTENSIONS: - os << "UR_PLATFORM_INFO_EXTENSIONS"; + case UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES"; break; - case UR_PLATFORM_INFO_PROFILE: - os << "UR_PLATFORM_INFO_PROFILE"; + case UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES"; break; - case UR_PLATFORM_INFO_BACKEND: - os << "UR_PLATFORM_INFO_BACKEND"; + case UR_STRUCTURE_TYPE_SAMPLER_NATIVE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_SAMPLER_NATIVE_PROPERTIES"; break; - default: + + case UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC: + os << "UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC"; + break; + + case UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES: + os << "UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES: + os << "UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES: + os << "UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_KERNEL_ARG_POINTER_PROPERTIES: + os << "UR_STRUCTURE_TYPE_KERNEL_ARG_POINTER_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES: + os << "UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES: + os << "UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_KERNEL_ARG_VALUE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_KERNEL_ARG_VALUE_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES: + os << "UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC: + os << "UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC"; + break; + + case UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES: + os << "UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES"; + break; + default: os << "unknown enumerator"; break; } return os; } namespace ur_params { -template <> -inline void serializeTagged(std::ostream &os, const void *ptr, - ur_platform_info_t value, size_t size) { +inline void serializeStruct(std::ostream &os, const void *ptr) { if (ptr == NULL) { - serializePtr(os, ptr); + ur_params::serializePtr(os, ptr); return; } - switch (value) { + enum ur_structure_type_t *value = (enum ur_structure_type_t *)ptr; + switch (*value) { - case UR_PLATFORM_INFO_NAME: { + case UR_STRUCTURE_TYPE_CONTEXT_PROPERTIES: { + const ur_context_properties_t *pstruct = + (const ur_context_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; - const char *tptr = (const char *)ptr; - serializePtr(os, tptr); + case UR_STRUCTURE_TYPE_IMAGE_DESC: { + const ur_image_desc_t *pstruct = (const ur_image_desc_t *)ptr; + ur_params::serializePtr(os, pstruct); } break; - case UR_PLATFORM_INFO_VENDOR_NAME: { + case UR_STRUCTURE_TYPE_BUFFER_PROPERTIES: { + const ur_buffer_properties_t *pstruct = + (const ur_buffer_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; - const char *tptr = (const char *)ptr; - serializePtr(os, tptr); + case UR_STRUCTURE_TYPE_BUFFER_REGION: { + const ur_buffer_region_t *pstruct = (const ur_buffer_region_t *)ptr; + ur_params::serializePtr(os, pstruct); } break; - case UR_PLATFORM_INFO_VERSION: { + case UR_STRUCTURE_TYPE_BUFFER_CHANNEL_PROPERTIES: { + const ur_buffer_channel_properties_t *pstruct = + (const ur_buffer_channel_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; - const char *tptr = (const char *)ptr; - serializePtr(os, tptr); + case UR_STRUCTURE_TYPE_BUFFER_ALLOC_LOCATION_PROPERTIES: { + const ur_buffer_alloc_location_properties_t *pstruct = + (const ur_buffer_alloc_location_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); } break; - case UR_PLATFORM_INFO_EXTENSIONS: { + case UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES: { + const ur_program_properties_t *pstruct = + (const ur_program_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; - const char *tptr = (const char *)ptr; - serializePtr(os, tptr); + case UR_STRUCTURE_TYPE_USM_DESC: { + const ur_usm_desc_t *pstruct = (const ur_usm_desc_t *)ptr; + ur_params::serializePtr(os, pstruct); } break; - case UR_PLATFORM_INFO_PROFILE: { + case UR_STRUCTURE_TYPE_USM_HOST_DESC: { + const ur_usm_host_desc_t *pstruct = (const ur_usm_host_desc_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; - const char *tptr = (const char *)ptr; - serializePtr(os, tptr); + case UR_STRUCTURE_TYPE_USM_DEVICE_DESC: { + const ur_usm_device_desc_t *pstruct = (const ur_usm_device_desc_t *)ptr; + ur_params::serializePtr(os, pstruct); } break; - case UR_PLATFORM_INFO_BACKEND: { - const ur_platform_backend_t *tptr = (const ur_platform_backend_t *)ptr; - if (sizeof(ur_platform_backend_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_platform_backend_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_STRUCTURE_TYPE_USM_POOL_DESC: { + const ur_usm_pool_desc_t *pstruct = (const ur_usm_pool_desc_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; - os << *tptr; + case UR_STRUCTURE_TYPE_USM_POOL_LIMITS_DESC: { + const ur_usm_pool_limits_desc_t *pstruct = + (const ur_usm_pool_limits_desc_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; - os << ")"; + case UR_STRUCTURE_TYPE_DEVICE_BINARY: { + const ur_device_binary_t *pstruct = (const ur_device_binary_t *)ptr; + ur_params::serializePtr(os, pstruct); } break; - default: - os << "unknown enumerator"; - break; - } -} -} // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, enum ur_api_version_t value) { - os << UR_MAJOR_VERSION(value) << "." << UR_MINOR_VERSION(value); - return os; -} -inline std::ostream & -operator<<(std::ostream &os, - const struct ur_platform_native_properties_t params) { - os << "(struct ur_platform_native_properties_t){"; - os << ".stype = "; + case UR_STRUCTURE_TYPE_SAMPLER_DESC: { + const ur_sampler_desc_t *pstruct = (const ur_sampler_desc_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; - os << (params.stype); + case UR_STRUCTURE_TYPE_QUEUE_PROPERTIES: { + const ur_queue_properties_t *pstruct = + (const ur_queue_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; - os << ", "; - os << ".pNext = "; + case UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES: { + const ur_queue_index_properties_t *pstruct = + (const ur_queue_index_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; - ur_params::serializeStruct(os, (params.pNext)); + case UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES: { + const ur_context_native_properties_t *pstruct = + (const ur_context_native_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; - os << ", "; - os << ".isNativeHandleOwned = "; + case UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES: { + const ur_kernel_native_properties_t *pstruct = + (const ur_kernel_native_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; - os << (params.isNativeHandleOwned); + case UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES: { + const ur_queue_native_properties_t *pstruct = + (const ur_queue_native_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; - os << "}"; - return os; -} -inline std::ostream &operator<<(std::ostream &os, - enum ur_platform_backend_t value) { - switch (value) { + case UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES: { + const ur_mem_native_properties_t *pstruct = + (const ur_mem_native_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; - case UR_PLATFORM_BACKEND_UNKNOWN: - os << "UR_PLATFORM_BACKEND_UNKNOWN"; - break; + case UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES: { + const ur_event_native_properties_t *pstruct = + (const ur_event_native_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; - case UR_PLATFORM_BACKEND_LEVEL_ZERO: - os << "UR_PLATFORM_BACKEND_LEVEL_ZERO"; - break; + case UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES: { + const ur_platform_native_properties_t *pstruct = + (const ur_platform_native_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; - case UR_PLATFORM_BACKEND_OPENCL: - os << "UR_PLATFORM_BACKEND_OPENCL"; - break; + case UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES: { + const ur_device_native_properties_t *pstruct = + (const ur_device_native_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; - case UR_PLATFORM_BACKEND_CUDA: - os << "UR_PLATFORM_BACKEND_CUDA"; - break; + case UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES: { + const ur_program_native_properties_t *pstruct = + (const ur_program_native_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; - case UR_PLATFORM_BACKEND_HIP: - os << "UR_PLATFORM_BACKEND_HIP"; - break; - default: - os << "unknown enumerator"; - break; - } - return os; -} -inline std::ostream &operator<<(std::ostream &os, - const struct ur_device_binary_t params) { - os << "(struct ur_device_binary_t){"; + case UR_STRUCTURE_TYPE_SAMPLER_NATIVE_PROPERTIES: { + const ur_sampler_native_properties_t *pstruct = + (const ur_sampler_native_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; - os << ".stype = "; + case UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC: { + const ur_queue_native_desc_t *pstruct = + (const ur_queue_native_desc_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; - os << (params.stype); + case UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES: { + const ur_device_partition_properties_t *pstruct = + (const ur_device_partition_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; - os << ", "; - os << ".pNext = "; - - ur_params::serializeStruct(os, (params.pNext)); - - os << ", "; - os << ".pDeviceTargetSpec = "; - - ur_params::serializePtr(os, (params.pDeviceTargetSpec)); + case UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES: { + const ur_kernel_arg_mem_obj_properties_t *pstruct = + (const ur_kernel_arg_mem_obj_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; - os << "}"; - return os; -} -inline std::ostream &operator<<(std::ostream &os, enum ur_device_type_t value) { - switch (value) { + case UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES: { + const ur_physical_mem_properties_t *pstruct = + (const ur_physical_mem_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; - case UR_DEVICE_TYPE_DEFAULT: - os << "UR_DEVICE_TYPE_DEFAULT"; - break; + case UR_STRUCTURE_TYPE_KERNEL_ARG_POINTER_PROPERTIES: { + const ur_kernel_arg_pointer_properties_t *pstruct = + (const ur_kernel_arg_pointer_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; - case UR_DEVICE_TYPE_ALL: - os << "UR_DEVICE_TYPE_ALL"; - break; + case UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES: { + const ur_kernel_arg_sampler_properties_t *pstruct = + (const ur_kernel_arg_sampler_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; - case UR_DEVICE_TYPE_GPU: - os << "UR_DEVICE_TYPE_GPU"; - break; + case UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES: { + const ur_kernel_exec_info_properties_t *pstruct = + (const ur_kernel_exec_info_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; - case UR_DEVICE_TYPE_CPU: - os << "UR_DEVICE_TYPE_CPU"; - break; + case UR_STRUCTURE_TYPE_KERNEL_ARG_VALUE_PROPERTIES: { + const ur_kernel_arg_value_properties_t *pstruct = + (const ur_kernel_arg_value_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; - case UR_DEVICE_TYPE_FPGA: - os << "UR_DEVICE_TYPE_FPGA"; - break; + case UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES: { + const ur_kernel_arg_local_properties_t *pstruct = + (const ur_kernel_arg_local_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; - case UR_DEVICE_TYPE_MCA: - os << "UR_DEVICE_TYPE_MCA"; - break; + case UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC: { + const ur_exp_command_buffer_desc_t *pstruct = + (const ur_exp_command_buffer_desc_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; - case UR_DEVICE_TYPE_VPU: - os << "UR_DEVICE_TYPE_VPU"; - break; + case UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES: { + const ur_exp_sampler_mip_properties_t *pstruct = + (const ur_exp_sampler_mip_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; default: os << "unknown enumerator"; break; } - return os; } -inline std::ostream &operator<<(std::ostream &os, enum ur_device_info_t value) { +} // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, enum ur_result_t value) { switch (value) { - case UR_DEVICE_INFO_TYPE: - os << "UR_DEVICE_INFO_TYPE"; + case UR_RESULT_SUCCESS: + os << "UR_RESULT_SUCCESS"; break; - case UR_DEVICE_INFO_VENDOR_ID: - os << "UR_DEVICE_INFO_VENDOR_ID"; + case UR_RESULT_ERROR_INVALID_OPERATION: + os << "UR_RESULT_ERROR_INVALID_OPERATION"; break; - case UR_DEVICE_INFO_DEVICE_ID: - os << "UR_DEVICE_INFO_DEVICE_ID"; + case UR_RESULT_ERROR_INVALID_QUEUE_PROPERTIES: + os << "UR_RESULT_ERROR_INVALID_QUEUE_PROPERTIES"; break; - case UR_DEVICE_INFO_MAX_COMPUTE_UNITS: - os << "UR_DEVICE_INFO_MAX_COMPUTE_UNITS"; + case UR_RESULT_ERROR_INVALID_QUEUE: + os << "UR_RESULT_ERROR_INVALID_QUEUE"; break; - case UR_DEVICE_INFO_MAX_WORK_ITEM_DIMENSIONS: - os << "UR_DEVICE_INFO_MAX_WORK_ITEM_DIMENSIONS"; + case UR_RESULT_ERROR_INVALID_VALUE: + os << "UR_RESULT_ERROR_INVALID_VALUE"; break; - case UR_DEVICE_INFO_MAX_WORK_ITEM_SIZES: - os << "UR_DEVICE_INFO_MAX_WORK_ITEM_SIZES"; + case UR_RESULT_ERROR_INVALID_CONTEXT: + os << "UR_RESULT_ERROR_INVALID_CONTEXT"; break; - case UR_DEVICE_INFO_MAX_WORK_GROUP_SIZE: - os << "UR_DEVICE_INFO_MAX_WORK_GROUP_SIZE"; + case UR_RESULT_ERROR_INVALID_PLATFORM: + os << "UR_RESULT_ERROR_INVALID_PLATFORM"; break; - case UR_DEVICE_INFO_SINGLE_FP_CONFIG: - os << "UR_DEVICE_INFO_SINGLE_FP_CONFIG"; + case UR_RESULT_ERROR_INVALID_BINARY: + os << "UR_RESULT_ERROR_INVALID_BINARY"; break; - case UR_DEVICE_INFO_HALF_FP_CONFIG: - os << "UR_DEVICE_INFO_HALF_FP_CONFIG"; + case UR_RESULT_ERROR_INVALID_PROGRAM: + os << "UR_RESULT_ERROR_INVALID_PROGRAM"; break; - case UR_DEVICE_INFO_DOUBLE_FP_CONFIG: - os << "UR_DEVICE_INFO_DOUBLE_FP_CONFIG"; + case UR_RESULT_ERROR_INVALID_SAMPLER: + os << "UR_RESULT_ERROR_INVALID_SAMPLER"; break; - case UR_DEVICE_INFO_QUEUE_PROPERTIES: - os << "UR_DEVICE_INFO_QUEUE_PROPERTIES"; + case UR_RESULT_ERROR_INVALID_BUFFER_SIZE: + os << "UR_RESULT_ERROR_INVALID_BUFFER_SIZE"; break; - case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_CHAR: - os << "UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_CHAR"; + case UR_RESULT_ERROR_INVALID_MEM_OBJECT: + os << "UR_RESULT_ERROR_INVALID_MEM_OBJECT"; break; - case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_SHORT: - os << "UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_SHORT"; + case UR_RESULT_ERROR_INVALID_EVENT: + os << "UR_RESULT_ERROR_INVALID_EVENT"; break; - case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_INT: - os << "UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_INT"; + case UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST: + os << "UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST"; break; - case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_LONG: - os << "UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_LONG"; + case UR_RESULT_ERROR_MISALIGNED_SUB_BUFFER_OFFSET: + os << "UR_RESULT_ERROR_MISALIGNED_SUB_BUFFER_OFFSET"; break; - case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_FLOAT: - os << "UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_FLOAT"; + case UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE: + os << "UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE"; break; - case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_DOUBLE: - os << "UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_DOUBLE"; + case UR_RESULT_ERROR_COMPILER_NOT_AVAILABLE: + os << "UR_RESULT_ERROR_COMPILER_NOT_AVAILABLE"; break; - case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_HALF: - os << "UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_HALF"; + case UR_RESULT_ERROR_PROFILING_INFO_NOT_AVAILABLE: + os << "UR_RESULT_ERROR_PROFILING_INFO_NOT_AVAILABLE"; break; - case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_CHAR: - os << "UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_CHAR"; + case UR_RESULT_ERROR_DEVICE_NOT_FOUND: + os << "UR_RESULT_ERROR_DEVICE_NOT_FOUND"; break; - case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_SHORT: - os << "UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_SHORT"; + case UR_RESULT_ERROR_INVALID_DEVICE: + os << "UR_RESULT_ERROR_INVALID_DEVICE"; break; - case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_INT: - os << "UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_INT"; + case UR_RESULT_ERROR_DEVICE_LOST: + os << "UR_RESULT_ERROR_DEVICE_LOST"; break; - case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_LONG: - os << "UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_LONG"; + case UR_RESULT_ERROR_DEVICE_REQUIRES_RESET: + os << "UR_RESULT_ERROR_DEVICE_REQUIRES_RESET"; break; - case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_FLOAT: - os << "UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_FLOAT"; + case UR_RESULT_ERROR_DEVICE_IN_LOW_POWER_STATE: + os << "UR_RESULT_ERROR_DEVICE_IN_LOW_POWER_STATE"; break; - case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_DOUBLE: - os << "UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_DOUBLE"; + case UR_RESULT_ERROR_DEVICE_PARTITION_FAILED: + os << "UR_RESULT_ERROR_DEVICE_PARTITION_FAILED"; break; - case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_HALF: - os << "UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_HALF"; + case UR_RESULT_ERROR_INVALID_DEVICE_PARTITION_COUNT: + os << "UR_RESULT_ERROR_INVALID_DEVICE_PARTITION_COUNT"; break; - case UR_DEVICE_INFO_MAX_CLOCK_FREQUENCY: - os << "UR_DEVICE_INFO_MAX_CLOCK_FREQUENCY"; + case UR_RESULT_ERROR_INVALID_WORK_ITEM_SIZE: + os << "UR_RESULT_ERROR_INVALID_WORK_ITEM_SIZE"; break; - case UR_DEVICE_INFO_MEMORY_CLOCK_RATE: - os << "UR_DEVICE_INFO_MEMORY_CLOCK_RATE"; + case UR_RESULT_ERROR_INVALID_WORK_DIMENSION: + os << "UR_RESULT_ERROR_INVALID_WORK_DIMENSION"; break; - case UR_DEVICE_INFO_ADDRESS_BITS: - os << "UR_DEVICE_INFO_ADDRESS_BITS"; + case UR_RESULT_ERROR_INVALID_KERNEL_ARGS: + os << "UR_RESULT_ERROR_INVALID_KERNEL_ARGS"; break; - case UR_DEVICE_INFO_MAX_MEM_ALLOC_SIZE: - os << "UR_DEVICE_INFO_MAX_MEM_ALLOC_SIZE"; + case UR_RESULT_ERROR_INVALID_KERNEL: + os << "UR_RESULT_ERROR_INVALID_KERNEL"; break; - case UR_DEVICE_INFO_IMAGE_SUPPORTED: - os << "UR_DEVICE_INFO_IMAGE_SUPPORTED"; + case UR_RESULT_ERROR_INVALID_KERNEL_NAME: + os << "UR_RESULT_ERROR_INVALID_KERNEL_NAME"; break; - case UR_DEVICE_INFO_MAX_READ_IMAGE_ARGS: - os << "UR_DEVICE_INFO_MAX_READ_IMAGE_ARGS"; + case UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_INDEX: + os << "UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_INDEX"; break; - case UR_DEVICE_INFO_MAX_WRITE_IMAGE_ARGS: - os << "UR_DEVICE_INFO_MAX_WRITE_IMAGE_ARGS"; + case UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE: + os << "UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE"; break; - case UR_DEVICE_INFO_MAX_READ_WRITE_IMAGE_ARGS: - os << "UR_DEVICE_INFO_MAX_READ_WRITE_IMAGE_ARGS"; + case UR_RESULT_ERROR_INVALID_KERNEL_ATTRIBUTE_VALUE: + os << "UR_RESULT_ERROR_INVALID_KERNEL_ATTRIBUTE_VALUE"; break; - case UR_DEVICE_INFO_IMAGE2D_MAX_WIDTH: - os << "UR_DEVICE_INFO_IMAGE2D_MAX_WIDTH"; + case UR_RESULT_ERROR_INVALID_IMAGE_SIZE: + os << "UR_RESULT_ERROR_INVALID_IMAGE_SIZE"; break; - case UR_DEVICE_INFO_IMAGE2D_MAX_HEIGHT: - os << "UR_DEVICE_INFO_IMAGE2D_MAX_HEIGHT"; + case UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR: + os << "UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR"; break; - case UR_DEVICE_INFO_IMAGE3D_MAX_WIDTH: - os << "UR_DEVICE_INFO_IMAGE3D_MAX_WIDTH"; + case UR_RESULT_ERROR_IMAGE_FORMAT_NOT_SUPPORTED: + os << "UR_RESULT_ERROR_IMAGE_FORMAT_NOT_SUPPORTED"; break; - case UR_DEVICE_INFO_IMAGE3D_MAX_HEIGHT: - os << "UR_DEVICE_INFO_IMAGE3D_MAX_HEIGHT"; + case UR_RESULT_ERROR_MEM_OBJECT_ALLOCATION_FAILURE: + os << "UR_RESULT_ERROR_MEM_OBJECT_ALLOCATION_FAILURE"; break; - case UR_DEVICE_INFO_IMAGE3D_MAX_DEPTH: - os << "UR_DEVICE_INFO_IMAGE3D_MAX_DEPTH"; + case UR_RESULT_ERROR_INVALID_PROGRAM_EXECUTABLE: + os << "UR_RESULT_ERROR_INVALID_PROGRAM_EXECUTABLE"; break; - case UR_DEVICE_INFO_IMAGE_MAX_BUFFER_SIZE: - os << "UR_DEVICE_INFO_IMAGE_MAX_BUFFER_SIZE"; + case UR_RESULT_ERROR_UNINITIALIZED: + os << "UR_RESULT_ERROR_UNINITIALIZED"; break; - case UR_DEVICE_INFO_IMAGE_MAX_ARRAY_SIZE: - os << "UR_DEVICE_INFO_IMAGE_MAX_ARRAY_SIZE"; + case UR_RESULT_ERROR_OUT_OF_HOST_MEMORY: + os << "UR_RESULT_ERROR_OUT_OF_HOST_MEMORY"; break; - case UR_DEVICE_INFO_MAX_SAMPLERS: - os << "UR_DEVICE_INFO_MAX_SAMPLERS"; + case UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY: + os << "UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY"; break; - case UR_DEVICE_INFO_MAX_PARAMETER_SIZE: - os << "UR_DEVICE_INFO_MAX_PARAMETER_SIZE"; + case UR_RESULT_ERROR_OUT_OF_RESOURCES: + os << "UR_RESULT_ERROR_OUT_OF_RESOURCES"; break; - case UR_DEVICE_INFO_MEM_BASE_ADDR_ALIGN: - os << "UR_DEVICE_INFO_MEM_BASE_ADDR_ALIGN"; + case UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE: + os << "UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE"; break; - case UR_DEVICE_INFO_GLOBAL_MEM_CACHE_TYPE: - os << "UR_DEVICE_INFO_GLOBAL_MEM_CACHE_TYPE"; + case UR_RESULT_ERROR_PROGRAM_LINK_FAILURE: + os << "UR_RESULT_ERROR_PROGRAM_LINK_FAILURE"; break; - case UR_DEVICE_INFO_GLOBAL_MEM_CACHELINE_SIZE: - os << "UR_DEVICE_INFO_GLOBAL_MEM_CACHELINE_SIZE"; + case UR_RESULT_ERROR_UNSUPPORTED_VERSION: + os << "UR_RESULT_ERROR_UNSUPPORTED_VERSION"; break; - case UR_DEVICE_INFO_GLOBAL_MEM_CACHE_SIZE: - os << "UR_DEVICE_INFO_GLOBAL_MEM_CACHE_SIZE"; + case UR_RESULT_ERROR_UNSUPPORTED_FEATURE: + os << "UR_RESULT_ERROR_UNSUPPORTED_FEATURE"; break; - case UR_DEVICE_INFO_GLOBAL_MEM_SIZE: - os << "UR_DEVICE_INFO_GLOBAL_MEM_SIZE"; + case UR_RESULT_ERROR_INVALID_ARGUMENT: + os << "UR_RESULT_ERROR_INVALID_ARGUMENT"; break; - case UR_DEVICE_INFO_GLOBAL_MEM_FREE: - os << "UR_DEVICE_INFO_GLOBAL_MEM_FREE"; + case UR_RESULT_ERROR_INVALID_NULL_HANDLE: + os << "UR_RESULT_ERROR_INVALID_NULL_HANDLE"; break; - case UR_DEVICE_INFO_MAX_CONSTANT_BUFFER_SIZE: - os << "UR_DEVICE_INFO_MAX_CONSTANT_BUFFER_SIZE"; + case UR_RESULT_ERROR_HANDLE_OBJECT_IN_USE: + os << "UR_RESULT_ERROR_HANDLE_OBJECT_IN_USE"; break; - case UR_DEVICE_INFO_MAX_CONSTANT_ARGS: - os << "UR_DEVICE_INFO_MAX_CONSTANT_ARGS"; + case UR_RESULT_ERROR_INVALID_NULL_POINTER: + os << "UR_RESULT_ERROR_INVALID_NULL_POINTER"; break; - case UR_DEVICE_INFO_LOCAL_MEM_TYPE: - os << "UR_DEVICE_INFO_LOCAL_MEM_TYPE"; + case UR_RESULT_ERROR_INVALID_SIZE: + os << "UR_RESULT_ERROR_INVALID_SIZE"; break; - case UR_DEVICE_INFO_LOCAL_MEM_SIZE: - os << "UR_DEVICE_INFO_LOCAL_MEM_SIZE"; + case UR_RESULT_ERROR_UNSUPPORTED_SIZE: + os << "UR_RESULT_ERROR_UNSUPPORTED_SIZE"; break; - case UR_DEVICE_INFO_ERROR_CORRECTION_SUPPORT: - os << "UR_DEVICE_INFO_ERROR_CORRECTION_SUPPORT"; + case UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT: + os << "UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT"; break; - case UR_DEVICE_INFO_HOST_UNIFIED_MEMORY: - os << "UR_DEVICE_INFO_HOST_UNIFIED_MEMORY"; + case UR_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT: + os << "UR_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT"; break; - case UR_DEVICE_INFO_PROFILING_TIMER_RESOLUTION: - os << "UR_DEVICE_INFO_PROFILING_TIMER_RESOLUTION"; + case UR_RESULT_ERROR_INVALID_ENUMERATION: + os << "UR_RESULT_ERROR_INVALID_ENUMERATION"; break; - case UR_DEVICE_INFO_ENDIAN_LITTLE: - os << "UR_DEVICE_INFO_ENDIAN_LITTLE"; + case UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION: + os << "UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION"; break; - case UR_DEVICE_INFO_AVAILABLE: - os << "UR_DEVICE_INFO_AVAILABLE"; + case UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT: + os << "UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT"; break; - case UR_DEVICE_INFO_COMPILER_AVAILABLE: - os << "UR_DEVICE_INFO_COMPILER_AVAILABLE"; + case UR_RESULT_ERROR_INVALID_NATIVE_BINARY: + os << "UR_RESULT_ERROR_INVALID_NATIVE_BINARY"; break; - case UR_DEVICE_INFO_LINKER_AVAILABLE: - os << "UR_DEVICE_INFO_LINKER_AVAILABLE"; + case UR_RESULT_ERROR_INVALID_GLOBAL_NAME: + os << "UR_RESULT_ERROR_INVALID_GLOBAL_NAME"; break; - case UR_DEVICE_INFO_EXECUTION_CAPABILITIES: - os << "UR_DEVICE_INFO_EXECUTION_CAPABILITIES"; + case UR_RESULT_ERROR_INVALID_FUNCTION_NAME: + os << "UR_RESULT_ERROR_INVALID_FUNCTION_NAME"; break; - case UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES: - os << "UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES"; + case UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION: + os << "UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION"; break; - case UR_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES: - os << "UR_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES"; + case UR_RESULT_ERROR_INVALID_GLOBAL_WIDTH_DIMENSION: + os << "UR_RESULT_ERROR_INVALID_GLOBAL_WIDTH_DIMENSION"; break; - case UR_DEVICE_INFO_BUILT_IN_KERNELS: - os << "UR_DEVICE_INFO_BUILT_IN_KERNELS"; + case UR_RESULT_ERROR_PROGRAM_UNLINKED: + os << "UR_RESULT_ERROR_PROGRAM_UNLINKED"; break; - case UR_DEVICE_INFO_PLATFORM: - os << "UR_DEVICE_INFO_PLATFORM"; + case UR_RESULT_ERROR_OVERLAPPING_REGIONS: + os << "UR_RESULT_ERROR_OVERLAPPING_REGIONS"; break; - case UR_DEVICE_INFO_REFERENCE_COUNT: - os << "UR_DEVICE_INFO_REFERENCE_COUNT"; + case UR_RESULT_ERROR_INVALID_HOST_PTR: + os << "UR_RESULT_ERROR_INVALID_HOST_PTR"; break; - case UR_DEVICE_INFO_IL_VERSION: - os << "UR_DEVICE_INFO_IL_VERSION"; + case UR_RESULT_ERROR_INVALID_USM_SIZE: + os << "UR_RESULT_ERROR_INVALID_USM_SIZE"; break; - case UR_DEVICE_INFO_NAME: - os << "UR_DEVICE_INFO_NAME"; + case UR_RESULT_ERROR_OBJECT_ALLOCATION_FAILURE: + os << "UR_RESULT_ERROR_OBJECT_ALLOCATION_FAILURE"; break; - case UR_DEVICE_INFO_VENDOR: - os << "UR_DEVICE_INFO_VENDOR"; + case UR_RESULT_ERROR_ADAPTER_SPECIFIC: + os << "UR_RESULT_ERROR_ADAPTER_SPECIFIC"; break; - case UR_DEVICE_INFO_DRIVER_VERSION: - os << "UR_DEVICE_INFO_DRIVER_VERSION"; + case UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_EXP: + os << "UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_EXP"; break; - case UR_DEVICE_INFO_PROFILE: - os << "UR_DEVICE_INFO_PROFILE"; + case UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_EXP: + os << "UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_EXP"; break; - case UR_DEVICE_INFO_VERSION: - os << "UR_DEVICE_INFO_VERSION"; + case UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_WAIT_LIST_EXP: + os << "UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_WAIT_LIST_EXP"; break; - case UR_DEVICE_INFO_BACKEND_RUNTIME_VERSION: - os << "UR_DEVICE_INFO_BACKEND_RUNTIME_VERSION"; + case UR_RESULT_ERROR_UNKNOWN: + os << "UR_RESULT_ERROR_UNKNOWN"; break; - - case UR_DEVICE_INFO_EXTENSIONS: - os << "UR_DEVICE_INFO_EXTENSIONS"; + default: + os << "unknown enumerator"; break; + } + return os; +} +inline std::ostream &operator<<(std::ostream &os, + const struct ur_base_properties_t params) { + os << "(struct ur_base_properties_t){"; - case UR_DEVICE_INFO_PRINTF_BUFFER_SIZE: - os << "UR_DEVICE_INFO_PRINTF_BUFFER_SIZE"; - break; + os << ".stype = "; - case UR_DEVICE_INFO_PREFERRED_INTEROP_USER_SYNC: - os << "UR_DEVICE_INFO_PREFERRED_INTEROP_USER_SYNC"; - break; + os << (params.stype); - case UR_DEVICE_INFO_PARENT_DEVICE: - os << "UR_DEVICE_INFO_PARENT_DEVICE"; - break; + os << ", "; + os << ".pNext = "; - case UR_DEVICE_INFO_SUPPORTED_PARTITIONS: - os << "UR_DEVICE_INFO_SUPPORTED_PARTITIONS"; - break; + ur_params::serializeStruct(os, (params.pNext)); - case UR_DEVICE_INFO_PARTITION_MAX_SUB_DEVICES: - os << "UR_DEVICE_INFO_PARTITION_MAX_SUB_DEVICES"; - break; + os << "}"; + return os; +} +inline std::ostream &operator<<(std::ostream &os, + const struct ur_base_desc_t params) { + os << "(struct ur_base_desc_t){"; - case UR_DEVICE_INFO_PARTITION_AFFINITY_DOMAIN: - os << "UR_DEVICE_INFO_PARTITION_AFFINITY_DOMAIN"; - break; + os << ".stype = "; - case UR_DEVICE_INFO_PARTITION_TYPE: - os << "UR_DEVICE_INFO_PARTITION_TYPE"; - break; + os << (params.stype); - case UR_DEVICE_INFO_MAX_NUM_SUB_GROUPS: - os << "UR_DEVICE_INFO_MAX_NUM_SUB_GROUPS"; - break; + os << ", "; + os << ".pNext = "; - case UR_DEVICE_INFO_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS: - os << "UR_DEVICE_INFO_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS"; - break; + ur_params::serializeStruct(os, (params.pNext)); - case UR_DEVICE_INFO_SUB_GROUP_SIZES_INTEL: - os << "UR_DEVICE_INFO_SUB_GROUP_SIZES_INTEL"; - break; + os << "}"; + return os; +} +inline std::ostream &operator<<(std::ostream &os, + const struct ur_rect_offset_t params) { + os << "(struct ur_rect_offset_t){"; - case UR_DEVICE_INFO_USM_HOST_SUPPORT: - os << "UR_DEVICE_INFO_USM_HOST_SUPPORT"; - break; + os << ".x = "; - case UR_DEVICE_INFO_USM_DEVICE_SUPPORT: - os << "UR_DEVICE_INFO_USM_DEVICE_SUPPORT"; - break; + os << (params.x); - case UR_DEVICE_INFO_USM_SINGLE_SHARED_SUPPORT: - os << "UR_DEVICE_INFO_USM_SINGLE_SHARED_SUPPORT"; - break; + os << ", "; + os << ".y = "; - case UR_DEVICE_INFO_USM_CROSS_SHARED_SUPPORT: - os << "UR_DEVICE_INFO_USM_CROSS_SHARED_SUPPORT"; - break; + os << (params.y); - case UR_DEVICE_INFO_USM_SYSTEM_SHARED_SUPPORT: - os << "UR_DEVICE_INFO_USM_SYSTEM_SHARED_SUPPORT"; - break; + os << ", "; + os << ".z = "; - case UR_DEVICE_INFO_UUID: - os << "UR_DEVICE_INFO_UUID"; - break; + os << (params.z); - case UR_DEVICE_INFO_PCI_ADDRESS: - os << "UR_DEVICE_INFO_PCI_ADDRESS"; - break; + os << "}"; + return os; +} +inline std::ostream &operator<<(std::ostream &os, + const struct ur_rect_region_t params) { + os << "(struct ur_rect_region_t){"; - case UR_DEVICE_INFO_GPU_EU_COUNT: - os << "UR_DEVICE_INFO_GPU_EU_COUNT"; - break; + os << ".width = "; - case UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH: - os << "UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH"; - break; + os << (params.width); - case UR_DEVICE_INFO_GPU_EU_SLICES: - os << "UR_DEVICE_INFO_GPU_EU_SLICES"; - break; + os << ", "; + os << ".height = "; - case UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE: - os << "UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE"; - break; + os << (params.height); - case UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE: - os << "UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE"; - break; + os << ", "; + os << ".depth = "; - case UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU: - os << "UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU"; - break; + os << (params.depth); - case UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH: - os << "UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH"; - break; + os << "}"; + return os; +} +inline std::ostream &operator<<(std::ostream &os, + enum ur_device_init_flag_t value) { + switch (value) { - case UR_DEVICE_INFO_IMAGE_SRGB: - os << "UR_DEVICE_INFO_IMAGE_SRGB"; + case UR_DEVICE_INIT_FLAG_GPU: + os << "UR_DEVICE_INIT_FLAG_GPU"; break; - case UR_DEVICE_INFO_BUILD_ON_SUBDEVICE: - os << "UR_DEVICE_INFO_BUILD_ON_SUBDEVICE"; + case UR_DEVICE_INIT_FLAG_CPU: + os << "UR_DEVICE_INIT_FLAG_CPU"; break; - case UR_DEVICE_INFO_ATOMIC_64: - os << "UR_DEVICE_INFO_ATOMIC_64"; - break; - - case UR_DEVICE_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES: - os << "UR_DEVICE_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES"; - break; - - case UR_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES: - os << "UR_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES"; - break; - - case UR_DEVICE_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES: - os << "UR_DEVICE_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES"; - break; - - case UR_DEVICE_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES: - os << "UR_DEVICE_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES"; - break; - - case UR_DEVICE_INFO_BFLOAT16: - os << "UR_DEVICE_INFO_BFLOAT16"; - break; - - case UR_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES: - os << "UR_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES"; - break; - - case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS: - os << "UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS"; - break; - - case UR_DEVICE_INFO_MEMORY_BUS_WIDTH: - os << "UR_DEVICE_INFO_MEMORY_BUS_WIDTH"; - break; - - case UR_DEVICE_INFO_MAX_WORK_GROUPS_3D: - os << "UR_DEVICE_INFO_MAX_WORK_GROUPS_3D"; - break; - - case UR_DEVICE_INFO_ASYNC_BARRIER: - os << "UR_DEVICE_INFO_ASYNC_BARRIER"; - break; - - case UR_DEVICE_INFO_MEM_CHANNEL_SUPPORT: - os << "UR_DEVICE_INFO_MEM_CHANNEL_SUPPORT"; - break; - - case UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED: - os << "UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED"; - break; - - case UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP: - os << "UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP"; - break; - - case UR_DEVICE_INFO_IP_VERSION: - os << "UR_DEVICE_INFO_IP_VERSION"; + case UR_DEVICE_INIT_FLAG_FPGA: + os << "UR_DEVICE_INIT_FLAG_FPGA"; break; - case UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP: - os << "UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP"; + case UR_DEVICE_INIT_FLAG_MCA: + os << "UR_DEVICE_INIT_FLAG_MCA"; break; - case UR_DEVICE_INFO_BINDLESS_IMAGES_1D_USM_SUPPORT_EXP: - os << "UR_DEVICE_INFO_BINDLESS_IMAGES_1D_USM_SUPPORT_EXP"; + case UR_DEVICE_INIT_FLAG_VPU: + os << "UR_DEVICE_INIT_FLAG_VPU"; break; - - case UR_DEVICE_INFO_BINDLESS_IMAGES_2D_USM_SUPPORT_EXP: - os << "UR_DEVICE_INFO_BINDLESS_IMAGES_2D_USM_SUPPORT_EXP"; + default: + os << "unknown enumerator"; break; + } + return os; +} +namespace ur_params { - case UR_DEVICE_INFO_IMAGE_PITCH_ALIGN_EXP: - os << "UR_DEVICE_INFO_IMAGE_PITCH_ALIGN_EXP"; - break; +template <> +inline void serializeFlag(std::ostream &os, + uint32_t flag) { + uint32_t val = flag; + bool first = true; - case UR_DEVICE_INFO_MAX_IMAGE_LINEAR_WIDTH_EXP: - os << "UR_DEVICE_INFO_MAX_IMAGE_LINEAR_WIDTH_EXP"; - break; + if ((val & UR_DEVICE_INIT_FLAG_GPU) == (uint32_t)UR_DEVICE_INIT_FLAG_GPU) { + val ^= (uint32_t)UR_DEVICE_INIT_FLAG_GPU; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_DEVICE_INIT_FLAG_GPU; + } - case UR_DEVICE_INFO_MAX_IMAGE_LINEAR_HEIGHT_EXP: - os << "UR_DEVICE_INFO_MAX_IMAGE_LINEAR_HEIGHT_EXP"; - break; + if ((val & UR_DEVICE_INIT_FLAG_CPU) == (uint32_t)UR_DEVICE_INIT_FLAG_CPU) { + val ^= (uint32_t)UR_DEVICE_INIT_FLAG_CPU; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_DEVICE_INIT_FLAG_CPU; + } - case UR_DEVICE_INFO_MAX_IMAGE_LINEAR_PITCH_EXP: - os << "UR_DEVICE_INFO_MAX_IMAGE_LINEAR_PITCH_EXP"; - break; + if ((val & UR_DEVICE_INIT_FLAG_FPGA) == + (uint32_t)UR_DEVICE_INIT_FLAG_FPGA) { + val ^= (uint32_t)UR_DEVICE_INIT_FLAG_FPGA; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_DEVICE_INIT_FLAG_FPGA; + } - case UR_DEVICE_INFO_MIPMAP_SUPPORT_EXP: - os << "UR_DEVICE_INFO_MIPMAP_SUPPORT_EXP"; - break; + if ((val & UR_DEVICE_INIT_FLAG_MCA) == (uint32_t)UR_DEVICE_INIT_FLAG_MCA) { + val ^= (uint32_t)UR_DEVICE_INIT_FLAG_MCA; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_DEVICE_INIT_FLAG_MCA; + } - case UR_DEVICE_INFO_MIPMAP_ANISOTROPY_SUPPORT_EXP: - os << "UR_DEVICE_INFO_MIPMAP_ANISOTROPY_SUPPORT_EXP"; - break; + if ((val & UR_DEVICE_INIT_FLAG_VPU) == (uint32_t)UR_DEVICE_INIT_FLAG_VPU) { + val ^= (uint32_t)UR_DEVICE_INIT_FLAG_VPU; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_DEVICE_INIT_FLAG_VPU; + } + if (val != 0) { + std::bitset<32> bits(val); + if (!first) { + os << " | "; + } + os << "unknown bit flags " << bits; + } else if (first) { + os << "0"; + } +} +} // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, + enum ur_platform_info_t value) { + switch (value) { - case UR_DEVICE_INFO_MIPMAP_MAX_ANISOTROPY_EXP: - os << "UR_DEVICE_INFO_MIPMAP_MAX_ANISOTROPY_EXP"; + case UR_PLATFORM_INFO_NAME: + os << "UR_PLATFORM_INFO_NAME"; break; - case UR_DEVICE_INFO_MIPMAP_LEVEL_REFERENCE_SUPPORT_EXP: - os << "UR_DEVICE_INFO_MIPMAP_LEVEL_REFERENCE_SUPPORT_EXP"; + case UR_PLATFORM_INFO_VENDOR_NAME: + os << "UR_PLATFORM_INFO_VENDOR_NAME"; break; - case UR_DEVICE_INFO_INTEROP_MEMORY_IMPORT_SUPPORT_EXP: - os << "UR_DEVICE_INFO_INTEROP_MEMORY_IMPORT_SUPPORT_EXP"; + case UR_PLATFORM_INFO_VERSION: + os << "UR_PLATFORM_INFO_VERSION"; break; - case UR_DEVICE_INFO_INTEROP_MEMORY_EXPORT_SUPPORT_EXP: - os << "UR_DEVICE_INFO_INTEROP_MEMORY_EXPORT_SUPPORT_EXP"; + case UR_PLATFORM_INFO_EXTENSIONS: + os << "UR_PLATFORM_INFO_EXTENSIONS"; break; - case UR_DEVICE_INFO_INTEROP_SEMAPHORE_IMPORT_SUPPORT_EXP: - os << "UR_DEVICE_INFO_INTEROP_SEMAPHORE_IMPORT_SUPPORT_EXP"; + case UR_PLATFORM_INFO_PROFILE: + os << "UR_PLATFORM_INFO_PROFILE"; break; - case UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP: - os << "UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP"; + case UR_PLATFORM_INFO_BACKEND: + os << "UR_PLATFORM_INFO_BACKEND"; break; default: os << "unknown enumerator"; @@ -1969,7 +1942,7 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_device_info_t value) { namespace ur_params { template <> inline void serializeTagged(std::ostream &os, const void *ptr, - ur_device_info_t value, size_t size) { + ur_platform_info_t value, size_t size) { if (ptr == NULL) { serializePtr(os, ptr); return; @@ -1977,67 +1950,41 @@ inline void serializeTagged(std::ostream &os, const void *ptr, switch (value) { - case UR_DEVICE_INFO_TYPE: { - const ur_device_type_t *tptr = (const ur_device_type_t *)ptr; - if (sizeof(ur_device_type_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_device_type_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; + case UR_PLATFORM_INFO_NAME: { - os << ")"; + const char *tptr = (const char *)ptr; + serializePtr(os, tptr); } break; - case UR_DEVICE_INFO_VENDOR_ID: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; + case UR_PLATFORM_INFO_VENDOR_NAME: { - os << ")"; + const char *tptr = (const char *)ptr; + serializePtr(os, tptr); } break; - case UR_DEVICE_INFO_DEVICE_ID: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; + case UR_PLATFORM_INFO_VERSION: { - os << ")"; + const char *tptr = (const char *)ptr; + serializePtr(os, tptr); } break; - case UR_DEVICE_INFO_MAX_COMPUTE_UNITS: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_PLATFORM_INFO_EXTENSIONS: { - os << *tptr; + const char *tptr = (const char *)ptr; + serializePtr(os, tptr); + } break; - os << ")"; + case UR_PLATFORM_INFO_PROFILE: { + + const char *tptr = (const char *)ptr; + serializePtr(os, tptr); } break; - case UR_DEVICE_INFO_MAX_WORK_ITEM_DIMENSIONS: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { + case UR_PLATFORM_INFO_BACKEND: { + const ur_platform_backend_t *tptr = (const ur_platform_backend_t *)ptr; + if (sizeof(ur_platform_backend_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; + << ", expected: >=" << sizeof(ur_platform_backend_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -2046,552 +1993,664 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; + default: + os << "unknown enumerator"; + break; + } +} +} // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, enum ur_api_version_t value) { + os << UR_MAJOR_VERSION(value) << "." << UR_MINOR_VERSION(value); + return os; +} +inline std::ostream & +operator<<(std::ostream &os, + const struct ur_platform_native_properties_t params) { + os << "(struct ur_platform_native_properties_t){"; - case UR_DEVICE_INFO_MAX_WORK_ITEM_SIZES: { - - const size_t *tptr = (const size_t *)ptr; - os << "{"; - size_t nelems = size / sizeof(size_t); - for (size_t i = 0; i < nelems; ++i) { - if (i != 0) { - os << ", "; - } - - os << tptr[i]; - } - os << "}"; - } break; + os << ".stype = "; - case UR_DEVICE_INFO_MAX_WORK_GROUP_SIZE: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + os << (params.stype); - os << *tptr; + os << ", "; + os << ".pNext = "; - os << ")"; - } break; + ur_params::serializeStruct(os, (params.pNext)); - case UR_DEVICE_INFO_SINGLE_FP_CONFIG: { - const ur_device_fp_capability_flags_t *tptr = - (const ur_device_fp_capability_flags_t *)ptr; - if (sizeof(ur_device_fp_capability_flags_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_device_fp_capability_flags_t) - << ")"; - return; - } - os << (void *)(tptr) << " ("; + os << ", "; + os << ".isNativeHandleOwned = "; - ur_params::serializeFlag(os, *tptr); + os << (params.isNativeHandleOwned); - os << ")"; - } break; + os << "}"; + return os; +} +inline std::ostream &operator<<(std::ostream &os, + enum ur_platform_backend_t value) { + switch (value) { - case UR_DEVICE_INFO_HALF_FP_CONFIG: { - const ur_device_fp_capability_flags_t *tptr = - (const ur_device_fp_capability_flags_t *)ptr; - if (sizeof(ur_device_fp_capability_flags_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_device_fp_capability_flags_t) - << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_PLATFORM_BACKEND_UNKNOWN: + os << "UR_PLATFORM_BACKEND_UNKNOWN"; + break; - ur_params::serializeFlag(os, *tptr); + case UR_PLATFORM_BACKEND_LEVEL_ZERO: + os << "UR_PLATFORM_BACKEND_LEVEL_ZERO"; + break; - os << ")"; - } break; + case UR_PLATFORM_BACKEND_OPENCL: + os << "UR_PLATFORM_BACKEND_OPENCL"; + break; - case UR_DEVICE_INFO_DOUBLE_FP_CONFIG: { - const ur_device_fp_capability_flags_t *tptr = - (const ur_device_fp_capability_flags_t *)ptr; - if (sizeof(ur_device_fp_capability_flags_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_device_fp_capability_flags_t) - << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_PLATFORM_BACKEND_CUDA: + os << "UR_PLATFORM_BACKEND_CUDA"; + break; - ur_params::serializeFlag(os, *tptr); + case UR_PLATFORM_BACKEND_HIP: + os << "UR_PLATFORM_BACKEND_HIP"; + break; + default: + os << "unknown enumerator"; + break; + } + return os; +} +inline std::ostream &operator<<(std::ostream &os, + const struct ur_device_binary_t params) { + os << "(struct ur_device_binary_t){"; - os << ")"; - } break; + os << ".stype = "; - case UR_DEVICE_INFO_QUEUE_PROPERTIES: { - const ur_queue_flags_t *tptr = (const ur_queue_flags_t *)ptr; - if (sizeof(ur_queue_flags_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_queue_flags_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + os << (params.stype); - ur_params::serializeFlag(os, *tptr); + os << ", "; + os << ".pNext = "; - os << ")"; - } break; + ur_params::serializeStruct(os, (params.pNext)); - case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_CHAR: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + os << ", "; + os << ".pDeviceTargetSpec = "; - os << *tptr; + ur_params::serializePtr(os, (params.pDeviceTargetSpec)); - os << ")"; - } break; + os << "}"; + return os; +} +inline std::ostream &operator<<(std::ostream &os, enum ur_device_type_t value) { + switch (value) { - case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_SHORT: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_TYPE_DEFAULT: + os << "UR_DEVICE_TYPE_DEFAULT"; + break; - os << *tptr; + case UR_DEVICE_TYPE_ALL: + os << "UR_DEVICE_TYPE_ALL"; + break; - os << ")"; - } break; + case UR_DEVICE_TYPE_GPU: + os << "UR_DEVICE_TYPE_GPU"; + break; - case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_INT: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_TYPE_CPU: + os << "UR_DEVICE_TYPE_CPU"; + break; - os << *tptr; + case UR_DEVICE_TYPE_FPGA: + os << "UR_DEVICE_TYPE_FPGA"; + break; - os << ")"; - } break; + case UR_DEVICE_TYPE_MCA: + os << "UR_DEVICE_TYPE_MCA"; + break; - case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_LONG: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_TYPE_VPU: + os << "UR_DEVICE_TYPE_VPU"; + break; + default: + os << "unknown enumerator"; + break; + } + return os; +} +inline std::ostream &operator<<(std::ostream &os, enum ur_device_info_t value) { + switch (value) { - os << *tptr; + case UR_DEVICE_INFO_TYPE: + os << "UR_DEVICE_INFO_TYPE"; + break; - os << ")"; - } break; + case UR_DEVICE_INFO_VENDOR_ID: + os << "UR_DEVICE_INFO_VENDOR_ID"; + break; - case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_FLOAT: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_DEVICE_ID: + os << "UR_DEVICE_INFO_DEVICE_ID"; + break; - os << *tptr; + case UR_DEVICE_INFO_MAX_COMPUTE_UNITS: + os << "UR_DEVICE_INFO_MAX_COMPUTE_UNITS"; + break; - os << ")"; - } break; + case UR_DEVICE_INFO_MAX_WORK_ITEM_DIMENSIONS: + os << "UR_DEVICE_INFO_MAX_WORK_ITEM_DIMENSIONS"; + break; - case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_DOUBLE: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_MAX_WORK_ITEM_SIZES: + os << "UR_DEVICE_INFO_MAX_WORK_ITEM_SIZES"; + break; - os << *tptr; + case UR_DEVICE_INFO_MAX_WORK_GROUP_SIZE: + os << "UR_DEVICE_INFO_MAX_WORK_GROUP_SIZE"; + break; - os << ")"; - } break; + case UR_DEVICE_INFO_SINGLE_FP_CONFIG: + os << "UR_DEVICE_INFO_SINGLE_FP_CONFIG"; + break; - case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_HALF: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_HALF_FP_CONFIG: + os << "UR_DEVICE_INFO_HALF_FP_CONFIG"; + break; - os << *tptr; + case UR_DEVICE_INFO_DOUBLE_FP_CONFIG: + os << "UR_DEVICE_INFO_DOUBLE_FP_CONFIG"; + break; - os << ")"; - } break; + case UR_DEVICE_INFO_QUEUE_PROPERTIES: + os << "UR_DEVICE_INFO_QUEUE_PROPERTIES"; + break; - case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_CHAR: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_CHAR: + os << "UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_CHAR"; + break; - os << *tptr; + case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_SHORT: + os << "UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_SHORT"; + break; - os << ")"; - } break; + case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_INT: + os << "UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_INT"; + break; - case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_SHORT: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_LONG: + os << "UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_LONG"; + break; - os << *tptr; + case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_FLOAT: + os << "UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_FLOAT"; + break; - os << ")"; - } break; + case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_DOUBLE: + os << "UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_DOUBLE"; + break; - case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_INT: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_HALF: + os << "UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_HALF"; + break; - os << *tptr; + case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_CHAR: + os << "UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_CHAR"; + break; - os << ")"; - } break; + case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_SHORT: + os << "UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_SHORT"; + break; - case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_LONG: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_INT: + os << "UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_INT"; + break; - os << *tptr; + case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_LONG: + os << "UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_LONG"; + break; - os << ")"; - } break; + case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_FLOAT: + os << "UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_FLOAT"; + break; - case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_FLOAT: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_DOUBLE: + os << "UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_DOUBLE"; + break; - os << *tptr; + case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_HALF: + os << "UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_HALF"; + break; - os << ")"; - } break; + case UR_DEVICE_INFO_MAX_CLOCK_FREQUENCY: + os << "UR_DEVICE_INFO_MAX_CLOCK_FREQUENCY"; + break; - case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_DOUBLE: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_MEMORY_CLOCK_RATE: + os << "UR_DEVICE_INFO_MEMORY_CLOCK_RATE"; + break; - os << *tptr; + case UR_DEVICE_INFO_ADDRESS_BITS: + os << "UR_DEVICE_INFO_ADDRESS_BITS"; + break; - os << ")"; - } break; + case UR_DEVICE_INFO_MAX_MEM_ALLOC_SIZE: + os << "UR_DEVICE_INFO_MAX_MEM_ALLOC_SIZE"; + break; - case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_HALF: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_IMAGE_SUPPORTED: + os << "UR_DEVICE_INFO_IMAGE_SUPPORTED"; + break; - os << *tptr; + case UR_DEVICE_INFO_MAX_READ_IMAGE_ARGS: + os << "UR_DEVICE_INFO_MAX_READ_IMAGE_ARGS"; + break; - os << ")"; - } break; + case UR_DEVICE_INFO_MAX_WRITE_IMAGE_ARGS: + os << "UR_DEVICE_INFO_MAX_WRITE_IMAGE_ARGS"; + break; - case UR_DEVICE_INFO_MAX_CLOCK_FREQUENCY: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_MAX_READ_WRITE_IMAGE_ARGS: + os << "UR_DEVICE_INFO_MAX_READ_WRITE_IMAGE_ARGS"; + break; - os << *tptr; + case UR_DEVICE_INFO_IMAGE2D_MAX_WIDTH: + os << "UR_DEVICE_INFO_IMAGE2D_MAX_WIDTH"; + break; - os << ")"; - } break; + case UR_DEVICE_INFO_IMAGE2D_MAX_HEIGHT: + os << "UR_DEVICE_INFO_IMAGE2D_MAX_HEIGHT"; + break; - case UR_DEVICE_INFO_MEMORY_CLOCK_RATE: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_IMAGE3D_MAX_WIDTH: + os << "UR_DEVICE_INFO_IMAGE3D_MAX_WIDTH"; + break; - os << *tptr; + case UR_DEVICE_INFO_IMAGE3D_MAX_HEIGHT: + os << "UR_DEVICE_INFO_IMAGE3D_MAX_HEIGHT"; + break; - os << ")"; - } break; + case UR_DEVICE_INFO_IMAGE3D_MAX_DEPTH: + os << "UR_DEVICE_INFO_IMAGE3D_MAX_DEPTH"; + break; - case UR_DEVICE_INFO_ADDRESS_BITS: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_IMAGE_MAX_BUFFER_SIZE: + os << "UR_DEVICE_INFO_IMAGE_MAX_BUFFER_SIZE"; + break; - os << *tptr; + case UR_DEVICE_INFO_IMAGE_MAX_ARRAY_SIZE: + os << "UR_DEVICE_INFO_IMAGE_MAX_ARRAY_SIZE"; + break; - os << ")"; - } break; + case UR_DEVICE_INFO_MAX_SAMPLERS: + os << "UR_DEVICE_INFO_MAX_SAMPLERS"; + break; - case UR_DEVICE_INFO_MAX_MEM_ALLOC_SIZE: { - const uint64_t *tptr = (const uint64_t *)ptr; - if (sizeof(uint64_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint64_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_MAX_PARAMETER_SIZE: + os << "UR_DEVICE_INFO_MAX_PARAMETER_SIZE"; + break; - os << *tptr; + case UR_DEVICE_INFO_MEM_BASE_ADDR_ALIGN: + os << "UR_DEVICE_INFO_MEM_BASE_ADDR_ALIGN"; + break; - os << ")"; - } break; + case UR_DEVICE_INFO_GLOBAL_MEM_CACHE_TYPE: + os << "UR_DEVICE_INFO_GLOBAL_MEM_CACHE_TYPE"; + break; - case UR_DEVICE_INFO_IMAGE_SUPPORTED: { - const ur_bool_t *tptr = (const ur_bool_t *)ptr; - if (sizeof(ur_bool_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_bool_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_GLOBAL_MEM_CACHELINE_SIZE: + os << "UR_DEVICE_INFO_GLOBAL_MEM_CACHELINE_SIZE"; + break; - os << *tptr; + case UR_DEVICE_INFO_GLOBAL_MEM_CACHE_SIZE: + os << "UR_DEVICE_INFO_GLOBAL_MEM_CACHE_SIZE"; + break; - os << ")"; - } break; + case UR_DEVICE_INFO_GLOBAL_MEM_SIZE: + os << "UR_DEVICE_INFO_GLOBAL_MEM_SIZE"; + break; - case UR_DEVICE_INFO_MAX_READ_IMAGE_ARGS: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_GLOBAL_MEM_FREE: + os << "UR_DEVICE_INFO_GLOBAL_MEM_FREE"; + break; - os << *tptr; + case UR_DEVICE_INFO_MAX_CONSTANT_BUFFER_SIZE: + os << "UR_DEVICE_INFO_MAX_CONSTANT_BUFFER_SIZE"; + break; - os << ")"; - } break; + case UR_DEVICE_INFO_MAX_CONSTANT_ARGS: + os << "UR_DEVICE_INFO_MAX_CONSTANT_ARGS"; + break; - case UR_DEVICE_INFO_MAX_WRITE_IMAGE_ARGS: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_LOCAL_MEM_TYPE: + os << "UR_DEVICE_INFO_LOCAL_MEM_TYPE"; + break; - os << *tptr; + case UR_DEVICE_INFO_LOCAL_MEM_SIZE: + os << "UR_DEVICE_INFO_LOCAL_MEM_SIZE"; + break; - os << ")"; - } break; + case UR_DEVICE_INFO_ERROR_CORRECTION_SUPPORT: + os << "UR_DEVICE_INFO_ERROR_CORRECTION_SUPPORT"; + break; - case UR_DEVICE_INFO_MAX_READ_WRITE_IMAGE_ARGS: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_HOST_UNIFIED_MEMORY: + os << "UR_DEVICE_INFO_HOST_UNIFIED_MEMORY"; + break; - os << *tptr; + case UR_DEVICE_INFO_PROFILING_TIMER_RESOLUTION: + os << "UR_DEVICE_INFO_PROFILING_TIMER_RESOLUTION"; + break; - os << ")"; - } break; + case UR_DEVICE_INFO_ENDIAN_LITTLE: + os << "UR_DEVICE_INFO_ENDIAN_LITTLE"; + break; - case UR_DEVICE_INFO_IMAGE2D_MAX_WIDTH: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_AVAILABLE: + os << "UR_DEVICE_INFO_AVAILABLE"; + break; - os << *tptr; + case UR_DEVICE_INFO_COMPILER_AVAILABLE: + os << "UR_DEVICE_INFO_COMPILER_AVAILABLE"; + break; - os << ")"; - } break; + case UR_DEVICE_INFO_LINKER_AVAILABLE: + os << "UR_DEVICE_INFO_LINKER_AVAILABLE"; + break; - case UR_DEVICE_INFO_IMAGE2D_MAX_HEIGHT: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_EXECUTION_CAPABILITIES: + os << "UR_DEVICE_INFO_EXECUTION_CAPABILITIES"; + break; - os << *tptr; + case UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES: + os << "UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES"; + break; - os << ")"; - } break; + case UR_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES: + os << "UR_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES"; + break; - case UR_DEVICE_INFO_IMAGE3D_MAX_WIDTH: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_BUILT_IN_KERNELS: + os << "UR_DEVICE_INFO_BUILT_IN_KERNELS"; + break; - os << *tptr; + case UR_DEVICE_INFO_PLATFORM: + os << "UR_DEVICE_INFO_PLATFORM"; + break; - os << ")"; - } break; + case UR_DEVICE_INFO_REFERENCE_COUNT: + os << "UR_DEVICE_INFO_REFERENCE_COUNT"; + break; - case UR_DEVICE_INFO_IMAGE3D_MAX_HEIGHT: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_IL_VERSION: + os << "UR_DEVICE_INFO_IL_VERSION"; + break; - os << *tptr; + case UR_DEVICE_INFO_NAME: + os << "UR_DEVICE_INFO_NAME"; + break; - os << ")"; - } break; + case UR_DEVICE_INFO_VENDOR: + os << "UR_DEVICE_INFO_VENDOR"; + break; - case UR_DEVICE_INFO_IMAGE3D_MAX_DEPTH: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_DRIVER_VERSION: + os << "UR_DEVICE_INFO_DRIVER_VERSION"; + break; - os << *tptr; + case UR_DEVICE_INFO_PROFILE: + os << "UR_DEVICE_INFO_PROFILE"; + break; - os << ")"; - } break; + case UR_DEVICE_INFO_VERSION: + os << "UR_DEVICE_INFO_VERSION"; + break; - case UR_DEVICE_INFO_IMAGE_MAX_BUFFER_SIZE: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_BACKEND_RUNTIME_VERSION: + os << "UR_DEVICE_INFO_BACKEND_RUNTIME_VERSION"; + break; - os << *tptr; + case UR_DEVICE_INFO_EXTENSIONS: + os << "UR_DEVICE_INFO_EXTENSIONS"; + break; - os << ")"; - } break; + case UR_DEVICE_INFO_PRINTF_BUFFER_SIZE: + os << "UR_DEVICE_INFO_PRINTF_BUFFER_SIZE"; + break; - case UR_DEVICE_INFO_IMAGE_MAX_ARRAY_SIZE: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_PREFERRED_INTEROP_USER_SYNC: + os << "UR_DEVICE_INFO_PREFERRED_INTEROP_USER_SYNC"; + break; - os << *tptr; + case UR_DEVICE_INFO_PARENT_DEVICE: + os << "UR_DEVICE_INFO_PARENT_DEVICE"; + break; - os << ")"; - } break; + case UR_DEVICE_INFO_SUPPORTED_PARTITIONS: + os << "UR_DEVICE_INFO_SUPPORTED_PARTITIONS"; + break; - case UR_DEVICE_INFO_MAX_SAMPLERS: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_PARTITION_MAX_SUB_DEVICES: + os << "UR_DEVICE_INFO_PARTITION_MAX_SUB_DEVICES"; + break; - os << *tptr; + case UR_DEVICE_INFO_PARTITION_AFFINITY_DOMAIN: + os << "UR_DEVICE_INFO_PARTITION_AFFINITY_DOMAIN"; + break; - os << ")"; - } break; + case UR_DEVICE_INFO_PARTITION_TYPE: + os << "UR_DEVICE_INFO_PARTITION_TYPE"; + break; - case UR_DEVICE_INFO_MAX_PARAMETER_SIZE: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_MAX_NUM_SUB_GROUPS: + os << "UR_DEVICE_INFO_MAX_NUM_SUB_GROUPS"; + break; - os << *tptr; + case UR_DEVICE_INFO_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS: + os << "UR_DEVICE_INFO_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS"; + break; - os << ")"; - } break; + case UR_DEVICE_INFO_SUB_GROUP_SIZES_INTEL: + os << "UR_DEVICE_INFO_SUB_GROUP_SIZES_INTEL"; + break; - case UR_DEVICE_INFO_MEM_BASE_ADDR_ALIGN: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_USM_HOST_SUPPORT: + os << "UR_DEVICE_INFO_USM_HOST_SUPPORT"; + break; - os << *tptr; + case UR_DEVICE_INFO_USM_DEVICE_SUPPORT: + os << "UR_DEVICE_INFO_USM_DEVICE_SUPPORT"; + break; - os << ")"; - } break; + case UR_DEVICE_INFO_USM_SINGLE_SHARED_SUPPORT: + os << "UR_DEVICE_INFO_USM_SINGLE_SHARED_SUPPORT"; + break; - case UR_DEVICE_INFO_GLOBAL_MEM_CACHE_TYPE: { - const ur_device_mem_cache_type_t *tptr = - (const ur_device_mem_cache_type_t *)ptr; - if (sizeof(ur_device_mem_cache_type_t) > size) { + case UR_DEVICE_INFO_USM_CROSS_SHARED_SUPPORT: + os << "UR_DEVICE_INFO_USM_CROSS_SHARED_SUPPORT"; + break; + + case UR_DEVICE_INFO_USM_SYSTEM_SHARED_SUPPORT: + os << "UR_DEVICE_INFO_USM_SYSTEM_SHARED_SUPPORT"; + break; + + case UR_DEVICE_INFO_UUID: + os << "UR_DEVICE_INFO_UUID"; + break; + + case UR_DEVICE_INFO_PCI_ADDRESS: + os << "UR_DEVICE_INFO_PCI_ADDRESS"; + break; + + case UR_DEVICE_INFO_GPU_EU_COUNT: + os << "UR_DEVICE_INFO_GPU_EU_COUNT"; + break; + + case UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH: + os << "UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH"; + break; + + case UR_DEVICE_INFO_GPU_EU_SLICES: + os << "UR_DEVICE_INFO_GPU_EU_SLICES"; + break; + + case UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE: + os << "UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE"; + break; + + case UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE: + os << "UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE"; + break; + + case UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU: + os << "UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU"; + break; + + case UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH: + os << "UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH"; + break; + + case UR_DEVICE_INFO_IMAGE_SRGB: + os << "UR_DEVICE_INFO_IMAGE_SRGB"; + break; + + case UR_DEVICE_INFO_BUILD_ON_SUBDEVICE: + os << "UR_DEVICE_INFO_BUILD_ON_SUBDEVICE"; + break; + + case UR_DEVICE_INFO_ATOMIC_64: + os << "UR_DEVICE_INFO_ATOMIC_64"; + break; + + case UR_DEVICE_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES: + os << "UR_DEVICE_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES"; + break; + + case UR_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES: + os << "UR_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES"; + break; + + case UR_DEVICE_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES: + os << "UR_DEVICE_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES"; + break; + + case UR_DEVICE_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES: + os << "UR_DEVICE_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES"; + break; + + case UR_DEVICE_INFO_BFLOAT16: + os << "UR_DEVICE_INFO_BFLOAT16"; + break; + + case UR_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES: + os << "UR_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES"; + break; + + case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS: + os << "UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS"; + break; + + case UR_DEVICE_INFO_MEMORY_BUS_WIDTH: + os << "UR_DEVICE_INFO_MEMORY_BUS_WIDTH"; + break; + + case UR_DEVICE_INFO_MAX_WORK_GROUPS_3D: + os << "UR_DEVICE_INFO_MAX_WORK_GROUPS_3D"; + break; + + case UR_DEVICE_INFO_ASYNC_BARRIER: + os << "UR_DEVICE_INFO_ASYNC_BARRIER"; + break; + + case UR_DEVICE_INFO_MEM_CHANNEL_SUPPORT: + os << "UR_DEVICE_INFO_MEM_CHANNEL_SUPPORT"; + break; + + case UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED: + os << "UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED"; + break; + + case UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP: + os << "UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP"; + break; + + case UR_DEVICE_INFO_IP_VERSION: + os << "UR_DEVICE_INFO_IP_VERSION"; + break; + + case UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP: + os << "UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP"; + break; + + case UR_DEVICE_INFO_BINDLESS_IMAGES_1D_USM_SUPPORT_EXP: + os << "UR_DEVICE_INFO_BINDLESS_IMAGES_1D_USM_SUPPORT_EXP"; + break; + + case UR_DEVICE_INFO_BINDLESS_IMAGES_2D_USM_SUPPORT_EXP: + os << "UR_DEVICE_INFO_BINDLESS_IMAGES_2D_USM_SUPPORT_EXP"; + break; + + case UR_DEVICE_INFO_IMAGE_PITCH_ALIGN_EXP: + os << "UR_DEVICE_INFO_IMAGE_PITCH_ALIGN_EXP"; + break; + + case UR_DEVICE_INFO_MAX_IMAGE_LINEAR_WIDTH_EXP: + os << "UR_DEVICE_INFO_MAX_IMAGE_LINEAR_WIDTH_EXP"; + break; + + case UR_DEVICE_INFO_MAX_IMAGE_LINEAR_HEIGHT_EXP: + os << "UR_DEVICE_INFO_MAX_IMAGE_LINEAR_HEIGHT_EXP"; + break; + + case UR_DEVICE_INFO_MAX_IMAGE_LINEAR_PITCH_EXP: + os << "UR_DEVICE_INFO_MAX_IMAGE_LINEAR_PITCH_EXP"; + break; + + case UR_DEVICE_INFO_MIPMAP_SUPPORT_EXP: + os << "UR_DEVICE_INFO_MIPMAP_SUPPORT_EXP"; + break; + + case UR_DEVICE_INFO_MIPMAP_ANISOTROPY_SUPPORT_EXP: + os << "UR_DEVICE_INFO_MIPMAP_ANISOTROPY_SUPPORT_EXP"; + break; + + case UR_DEVICE_INFO_MIPMAP_MAX_ANISOTROPY_EXP: + os << "UR_DEVICE_INFO_MIPMAP_MAX_ANISOTROPY_EXP"; + break; + + case UR_DEVICE_INFO_MIPMAP_LEVEL_REFERENCE_SUPPORT_EXP: + os << "UR_DEVICE_INFO_MIPMAP_LEVEL_REFERENCE_SUPPORT_EXP"; + break; + + case UR_DEVICE_INFO_INTEROP_MEMORY_IMPORT_SUPPORT_EXP: + os << "UR_DEVICE_INFO_INTEROP_MEMORY_IMPORT_SUPPORT_EXP"; + break; + + case UR_DEVICE_INFO_INTEROP_MEMORY_EXPORT_SUPPORT_EXP: + os << "UR_DEVICE_INFO_INTEROP_MEMORY_EXPORT_SUPPORT_EXP"; + break; + + case UR_DEVICE_INFO_INTEROP_SEMAPHORE_IMPORT_SUPPORT_EXP: + os << "UR_DEVICE_INFO_INTEROP_SEMAPHORE_IMPORT_SUPPORT_EXP"; + break; + + case UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP: + os << "UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP"; + break; + default: + os << "unknown enumerator"; + break; + } + return os; +} +namespace ur_params { +template <> +inline void serializeTagged(std::ostream &os, const void *ptr, + ur_device_info_t value, size_t size) { + if (ptr == NULL) { + serializePtr(os, ptr); + return; + } + + switch (value) { + + case UR_DEVICE_INFO_TYPE: { + const ur_device_type_t *tptr = (const ur_device_type_t *)ptr; + if (sizeof(ur_device_type_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_device_mem_cache_type_t) << ")"; + << ", expected: >=" << sizeof(ur_device_type_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -2601,7 +2660,7 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_GLOBAL_MEM_CACHELINE_SIZE: { + case UR_DEVICE_INFO_VENDOR_ID: { const uint32_t *tptr = (const uint32_t *)ptr; if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size @@ -2615,11 +2674,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_GLOBAL_MEM_CACHE_SIZE: { - const uint64_t *tptr = (const uint64_t *)ptr; - if (sizeof(uint64_t) > size) { + case UR_DEVICE_INFO_DEVICE_ID: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint64_t) << ")"; + << ", expected: >=" << sizeof(uint32_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -2629,11 +2688,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_GLOBAL_MEM_SIZE: { - const uint64_t *tptr = (const uint64_t *)ptr; - if (sizeof(uint64_t) > size) { + case UR_DEVICE_INFO_MAX_COMPUTE_UNITS: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint64_t) << ")"; + << ", expected: >=" << sizeof(uint32_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -2643,11 +2702,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_GLOBAL_MEM_FREE: { - const uint64_t *tptr = (const uint64_t *)ptr; - if (sizeof(uint64_t) > size) { + case UR_DEVICE_INFO_MAX_WORK_ITEM_DIMENSIONS: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint64_t) << ")"; + << ", expected: >=" << sizeof(uint32_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -2657,11 +2716,26 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_MAX_CONSTANT_BUFFER_SIZE: { - const uint64_t *tptr = (const uint64_t *)ptr; - if (sizeof(uint64_t) > size) { + case UR_DEVICE_INFO_MAX_WORK_ITEM_SIZES: { + + const size_t *tptr = (const size_t *)ptr; + os << "{"; + size_t nelems = size / sizeof(size_t); + for (size_t i = 0; i < nelems; ++i) { + if (i != 0) { + os << ", "; + } + + os << tptr[i]; + } + os << "}"; + } break; + + case UR_DEVICE_INFO_MAX_WORK_GROUP_SIZE: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint64_t) << ")"; + << ", expected: >=" << sizeof(size_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -2671,68 +2745,73 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_MAX_CONSTANT_ARGS: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { + case UR_DEVICE_INFO_SINGLE_FP_CONFIG: { + const ur_device_fp_capability_flags_t *tptr = + (const ur_device_fp_capability_flags_t *)ptr; + if (sizeof(ur_device_fp_capability_flags_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; + << ", expected: >=" << sizeof(ur_device_fp_capability_flags_t) + << ")"; return; } os << (void *)(tptr) << " ("; - os << *tptr; + ur_params::serializeFlag(os, *tptr); os << ")"; } break; - case UR_DEVICE_INFO_LOCAL_MEM_TYPE: { - const ur_device_local_mem_type_t *tptr = - (const ur_device_local_mem_type_t *)ptr; - if (sizeof(ur_device_local_mem_type_t) > size) { + case UR_DEVICE_INFO_HALF_FP_CONFIG: { + const ur_device_fp_capability_flags_t *tptr = + (const ur_device_fp_capability_flags_t *)ptr; + if (sizeof(ur_device_fp_capability_flags_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_device_local_mem_type_t) << ")"; + << ", expected: >=" << sizeof(ur_device_fp_capability_flags_t) + << ")"; return; } os << (void *)(tptr) << " ("; - os << *tptr; + ur_params::serializeFlag(os, *tptr); os << ")"; } break; - case UR_DEVICE_INFO_LOCAL_MEM_SIZE: { - const uint64_t *tptr = (const uint64_t *)ptr; - if (sizeof(uint64_t) > size) { + case UR_DEVICE_INFO_DOUBLE_FP_CONFIG: { + const ur_device_fp_capability_flags_t *tptr = + (const ur_device_fp_capability_flags_t *)ptr; + if (sizeof(ur_device_fp_capability_flags_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint64_t) << ")"; + << ", expected: >=" << sizeof(ur_device_fp_capability_flags_t) + << ")"; return; } os << (void *)(tptr) << " ("; - os << *tptr; + ur_params::serializeFlag(os, *tptr); os << ")"; } break; - case UR_DEVICE_INFO_ERROR_CORRECTION_SUPPORT: { - const ur_bool_t *tptr = (const ur_bool_t *)ptr; - if (sizeof(ur_bool_t) > size) { + case UR_DEVICE_INFO_QUEUE_PROPERTIES: { + const ur_queue_flags_t *tptr = (const ur_queue_flags_t *)ptr; + if (sizeof(ur_queue_flags_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_bool_t) << ")"; + << ", expected: >=" << sizeof(ur_queue_flags_t) << ")"; return; } os << (void *)(tptr) << " ("; - os << *tptr; + ur_params::serializeFlag(os, *tptr); os << ")"; } break; - case UR_DEVICE_INFO_HOST_UNIFIED_MEMORY: { - const ur_bool_t *tptr = (const ur_bool_t *)ptr; - if (sizeof(ur_bool_t) > size) { + case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_CHAR: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_bool_t) << ")"; + << ", expected: >=" << sizeof(uint32_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -2742,11 +2821,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_PROFILING_TIMER_RESOLUTION: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { + case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_SHORT: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; + << ", expected: >=" << sizeof(uint32_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -2756,11 +2835,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_ENDIAN_LITTLE: { - const ur_bool_t *tptr = (const ur_bool_t *)ptr; - if (sizeof(ur_bool_t) > size) { + case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_INT: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_bool_t) << ")"; + << ", expected: >=" << sizeof(uint32_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -2770,11 +2849,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_AVAILABLE: { - const ur_bool_t *tptr = (const ur_bool_t *)ptr; - if (sizeof(ur_bool_t) > size) { + case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_LONG: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_bool_t) << ")"; + << ", expected: >=" << sizeof(uint32_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -2784,11 +2863,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_COMPILER_AVAILABLE: { - const ur_bool_t *tptr = (const ur_bool_t *)ptr; - if (sizeof(ur_bool_t) > size) { + case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_FLOAT: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_bool_t) << ")"; + << ", expected: >=" << sizeof(uint32_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -2798,11 +2877,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_LINKER_AVAILABLE: { - const ur_bool_t *tptr = (const ur_bool_t *)ptr; - if (sizeof(ur_bool_t) > size) { + case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_DOUBLE: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_bool_t) << ")"; + << ", expected: >=" << sizeof(uint32_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -2812,71 +2891,63 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_EXECUTION_CAPABILITIES: { - const ur_device_exec_capability_flags_t *tptr = - (const ur_device_exec_capability_flags_t *)ptr; - if (sizeof(ur_device_exec_capability_flags_t) > size) { + case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_HALF: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_device_exec_capability_flags_t) - << ")"; + << ", expected: >=" << sizeof(uint32_t) << ")"; return; } os << (void *)(tptr) << " ("; - ur_params::serializeFlag(os, *tptr); + os << *tptr; os << ")"; } break; - case UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES: { - const ur_queue_flags_t *tptr = (const ur_queue_flags_t *)ptr; - if (sizeof(ur_queue_flags_t) > size) { + case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_CHAR: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_queue_flags_t) << ")"; + << ", expected: >=" << sizeof(uint32_t) << ")"; return; } os << (void *)(tptr) << " ("; - ur_params::serializeFlag(os, *tptr); + os << *tptr; os << ")"; } break; - case UR_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES: { - const ur_queue_flags_t *tptr = (const ur_queue_flags_t *)ptr; - if (sizeof(ur_queue_flags_t) > size) { + case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_SHORT: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_queue_flags_t) << ")"; + << ", expected: >=" << sizeof(uint32_t) << ")"; return; } os << (void *)(tptr) << " ("; - ur_params::serializeFlag(os, *tptr); + os << *tptr; os << ")"; } break; - case UR_DEVICE_INFO_BUILT_IN_KERNELS: { - - const char *tptr = (const char *)ptr; - serializePtr(os, tptr); - } break; - - case UR_DEVICE_INFO_PLATFORM: { - const ur_platform_handle_t *tptr = (const ur_platform_handle_t *)ptr; - if (sizeof(ur_platform_handle_t) > size) { + case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_INT: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_platform_handle_t) << ")"; + << ", expected: >=" << sizeof(uint32_t) << ")"; return; } os << (void *)(tptr) << " ("; - ur_params::serializePtr(os, *tptr); + os << *tptr; os << ")"; } break; - case UR_DEVICE_INFO_REFERENCE_COUNT: { + case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_LONG: { const uint32_t *tptr = (const uint32_t *)ptr; if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size @@ -2890,59 +2961,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_IL_VERSION: { - - const char *tptr = (const char *)ptr; - serializePtr(os, tptr); - } break; - - case UR_DEVICE_INFO_NAME: { - - const char *tptr = (const char *)ptr; - serializePtr(os, tptr); - } break; - - case UR_DEVICE_INFO_VENDOR: { - - const char *tptr = (const char *)ptr; - serializePtr(os, tptr); - } break; - - case UR_DEVICE_INFO_DRIVER_VERSION: { - - const char *tptr = (const char *)ptr; - serializePtr(os, tptr); - } break; - - case UR_DEVICE_INFO_PROFILE: { - - const char *tptr = (const char *)ptr; - serializePtr(os, tptr); - } break; - - case UR_DEVICE_INFO_VERSION: { - - const char *tptr = (const char *)ptr; - serializePtr(os, tptr); - } break; - - case UR_DEVICE_INFO_BACKEND_RUNTIME_VERSION: { - - const char *tptr = (const char *)ptr; - serializePtr(os, tptr); - } break; - - case UR_DEVICE_INFO_EXTENSIONS: { - - const char *tptr = (const char *)ptr; - serializePtr(os, tptr); - } break; - - case UR_DEVICE_INFO_PRINTF_BUFFER_SIZE: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { + case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_FLOAT: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; + << ", expected: >=" << sizeof(uint32_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -2952,11 +2975,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_PREFERRED_INTEROP_USER_SYNC: { - const ur_bool_t *tptr = (const ur_bool_t *)ptr; - if (sizeof(ur_bool_t) > size) { + case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_DOUBLE: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_bool_t) << ")"; + << ", expected: >=" << sizeof(uint32_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -2966,36 +2989,35 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_PARENT_DEVICE: { - const ur_device_handle_t *tptr = (const ur_device_handle_t *)ptr; - if (sizeof(ur_device_handle_t) > size) { + case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_HALF: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_device_handle_t) << ")"; + << ", expected: >=" << sizeof(uint32_t) << ")"; return; } os << (void *)(tptr) << " ("; - ur_params::serializePtr(os, *tptr); + os << *tptr; os << ")"; } break; - case UR_DEVICE_INFO_SUPPORTED_PARTITIONS: { + case UR_DEVICE_INFO_MAX_CLOCK_FREQUENCY: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - const ur_device_partition_t *tptr = (const ur_device_partition_t *)ptr; - os << "{"; - size_t nelems = size / sizeof(ur_device_partition_t); - for (size_t i = 0; i < nelems; ++i) { - if (i != 0) { - os << ", "; - } + os << *tptr; - os << tptr[i]; - } - os << "}"; + os << ")"; } break; - case UR_DEVICE_INFO_PARTITION_MAX_SUB_DEVICES: { + case UR_DEVICE_INFO_MEMORY_CLOCK_RATE: { const uint32_t *tptr = (const uint32_t *)ptr; if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size @@ -3009,43 +3031,25 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_PARTITION_AFFINITY_DOMAIN: { - const ur_device_affinity_domain_flags_t *tptr = - (const ur_device_affinity_domain_flags_t *)ptr; - if (sizeof(ur_device_affinity_domain_flags_t) > size) { + case UR_DEVICE_INFO_ADDRESS_BITS: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_device_affinity_domain_flags_t) - << ")"; + << ", expected: >=" << sizeof(uint32_t) << ")"; return; } os << (void *)(tptr) << " ("; - ur_params::serializeFlag(os, *tptr); + os << *tptr; os << ")"; } break; - case UR_DEVICE_INFO_PARTITION_TYPE: { - - const ur_device_partition_property_t *tptr = - (const ur_device_partition_property_t *)ptr; - os << "{"; - size_t nelems = size / sizeof(ur_device_partition_property_t); - for (size_t i = 0; i < nelems; ++i) { - if (i != 0) { - os << ", "; - } - - os << tptr[i]; - } - os << "}"; - } break; - - case UR_DEVICE_INFO_MAX_NUM_SUB_GROUPS: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { + case UR_DEVICE_INFO_MAX_MEM_ALLOC_SIZE: { + const uint64_t *tptr = (const uint64_t *)ptr; + if (sizeof(uint64_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; + << ", expected: >=" << sizeof(uint64_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -3055,7 +3059,7 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS: { + case UR_DEVICE_INFO_IMAGE_SUPPORTED: { const ur_bool_t *tptr = (const ur_bool_t *)ptr; if (sizeof(ur_bool_t) > size) { os << "invalid size (is: " << size @@ -3069,118 +3073,123 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_SUB_GROUP_SIZES_INTEL: { - + case UR_DEVICE_INFO_MAX_READ_IMAGE_ARGS: { const uint32_t *tptr = (const uint32_t *)ptr; - os << "{"; - size_t nelems = size / sizeof(uint32_t); - for (size_t i = 0; i < nelems; ++i) { - if (i != 0) { - os << ", "; - } - - os << tptr[i]; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; } - os << "}"; + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; } break; - case UR_DEVICE_INFO_USM_HOST_SUPPORT: { - const ur_device_usm_access_capability_flags_t *tptr = - (const ur_device_usm_access_capability_flags_t *)ptr; - if (sizeof(ur_device_usm_access_capability_flags_t) > size) { - os << "invalid size (is: " << size << ", expected: >=" - << sizeof(ur_device_usm_access_capability_flags_t) << ")"; + case UR_DEVICE_INFO_MAX_WRITE_IMAGE_ARGS: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; return; } os << (void *)(tptr) << " ("; - ur_params::serializeFlag(os, - *tptr); + os << *tptr; os << ")"; } break; - case UR_DEVICE_INFO_USM_DEVICE_SUPPORT: { - const ur_device_usm_access_capability_flags_t *tptr = - (const ur_device_usm_access_capability_flags_t *)ptr; - if (sizeof(ur_device_usm_access_capability_flags_t) > size) { - os << "invalid size (is: " << size << ", expected: >=" - << sizeof(ur_device_usm_access_capability_flags_t) << ")"; + case UR_DEVICE_INFO_MAX_READ_WRITE_IMAGE_ARGS: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; return; } os << (void *)(tptr) << " ("; - ur_params::serializeFlag(os, - *tptr); + os << *tptr; os << ")"; } break; - case UR_DEVICE_INFO_USM_SINGLE_SHARED_SUPPORT: { - const ur_device_usm_access_capability_flags_t *tptr = - (const ur_device_usm_access_capability_flags_t *)ptr; - if (sizeof(ur_device_usm_access_capability_flags_t) > size) { - os << "invalid size (is: " << size << ", expected: >=" - << sizeof(ur_device_usm_access_capability_flags_t) << ")"; + case UR_DEVICE_INFO_IMAGE2D_MAX_WIDTH: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(size_t) << ")"; return; } os << (void *)(tptr) << " ("; - ur_params::serializeFlag(os, - *tptr); + os << *tptr; os << ")"; } break; - case UR_DEVICE_INFO_USM_CROSS_SHARED_SUPPORT: { - const ur_device_usm_access_capability_flags_t *tptr = - (const ur_device_usm_access_capability_flags_t *)ptr; - if (sizeof(ur_device_usm_access_capability_flags_t) > size) { - os << "invalid size (is: " << size << ", expected: >=" - << sizeof(ur_device_usm_access_capability_flags_t) << ")"; + case UR_DEVICE_INFO_IMAGE2D_MAX_HEIGHT: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(size_t) << ")"; return; } os << (void *)(tptr) << " ("; - ur_params::serializeFlag(os, - *tptr); + os << *tptr; os << ")"; } break; - case UR_DEVICE_INFO_USM_SYSTEM_SHARED_SUPPORT: { - const ur_device_usm_access_capability_flags_t *tptr = - (const ur_device_usm_access_capability_flags_t *)ptr; - if (sizeof(ur_device_usm_access_capability_flags_t) > size) { - os << "invalid size (is: " << size << ", expected: >=" - << sizeof(ur_device_usm_access_capability_flags_t) << ")"; + case UR_DEVICE_INFO_IMAGE3D_MAX_WIDTH: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(size_t) << ")"; return; } os << (void *)(tptr) << " ("; - ur_params::serializeFlag(os, - *tptr); + os << *tptr; os << ")"; } break; - case UR_DEVICE_INFO_UUID: { + case UR_DEVICE_INFO_IMAGE3D_MAX_HEIGHT: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(size_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - const char *tptr = (const char *)ptr; - serializePtr(os, tptr); + os << *tptr; + + os << ")"; } break; - case UR_DEVICE_INFO_PCI_ADDRESS: { + case UR_DEVICE_INFO_IMAGE3D_MAX_DEPTH: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(size_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - const char *tptr = (const char *)ptr; - serializePtr(os, tptr); + os << *tptr; + + os << ")"; } break; - case UR_DEVICE_INFO_GPU_EU_COUNT: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { + case UR_DEVICE_INFO_IMAGE_MAX_BUFFER_SIZE: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; + << ", expected: >=" << sizeof(size_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -3190,11 +3199,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { + case UR_DEVICE_INFO_IMAGE_MAX_ARRAY_SIZE: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; + << ", expected: >=" << sizeof(size_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -3204,7 +3213,7 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_GPU_EU_SLICES: { + case UR_DEVICE_INFO_MAX_SAMPLERS: { const uint32_t *tptr = (const uint32_t *)ptr; if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size @@ -3218,11 +3227,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { + case UR_DEVICE_INFO_MAX_PARAMETER_SIZE: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; + << ", expected: >=" << sizeof(size_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -3232,7 +3241,7 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE: { + case UR_DEVICE_INFO_MEM_BASE_ADDR_ALIGN: { const uint32_t *tptr = (const uint32_t *)ptr; if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size @@ -3246,11 +3255,12 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { + case UR_DEVICE_INFO_GLOBAL_MEM_CACHE_TYPE: { + const ur_device_mem_cache_type_t *tptr = + (const ur_device_mem_cache_type_t *)ptr; + if (sizeof(ur_device_mem_cache_type_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; + << ", expected: >=" << sizeof(ur_device_mem_cache_type_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -3260,7 +3270,7 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH: { + case UR_DEVICE_INFO_GLOBAL_MEM_CACHELINE_SIZE: { const uint32_t *tptr = (const uint32_t *)ptr; if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size @@ -3274,11 +3284,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_IMAGE_SRGB: { - const ur_bool_t *tptr = (const ur_bool_t *)ptr; - if (sizeof(ur_bool_t) > size) { + case UR_DEVICE_INFO_GLOBAL_MEM_CACHE_SIZE: { + const uint64_t *tptr = (const uint64_t *)ptr; + if (sizeof(uint64_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_bool_t) << ")"; + << ", expected: >=" << sizeof(uint64_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -3288,11 +3298,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_BUILD_ON_SUBDEVICE: { - const ur_bool_t *tptr = (const ur_bool_t *)ptr; - if (sizeof(ur_bool_t) > size) { + case UR_DEVICE_INFO_GLOBAL_MEM_SIZE: { + const uint64_t *tptr = (const uint64_t *)ptr; + if (sizeof(uint64_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_bool_t) << ")"; + << ", expected: >=" << sizeof(uint64_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -3302,11 +3312,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_ATOMIC_64: { - const ur_bool_t *tptr = (const ur_bool_t *)ptr; - if (sizeof(ur_bool_t) > size) { + case UR_DEVICE_INFO_GLOBAL_MEM_FREE: { + const uint64_t *tptr = (const uint64_t *)ptr; + if (sizeof(uint64_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_bool_t) << ")"; + << ", expected: >=" << sizeof(uint64_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -3316,71 +3326,64 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES: { - const ur_memory_order_capability_flags_t *tptr = - (const ur_memory_order_capability_flags_t *)ptr; - if (sizeof(ur_memory_order_capability_flags_t) > size) { + case UR_DEVICE_INFO_MAX_CONSTANT_BUFFER_SIZE: { + const uint64_t *tptr = (const uint64_t *)ptr; + if (sizeof(uint64_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_memory_order_capability_flags_t) - << ")"; + << ", expected: >=" << sizeof(uint64_t) << ")"; return; } os << (void *)(tptr) << " ("; - ur_params::serializeFlag(os, *tptr); + os << *tptr; os << ")"; } break; - case UR_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES: { - const ur_memory_scope_capability_flags_t *tptr = - (const ur_memory_scope_capability_flags_t *)ptr; - if (sizeof(ur_memory_scope_capability_flags_t) > size) { + case UR_DEVICE_INFO_MAX_CONSTANT_ARGS: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_memory_scope_capability_flags_t) - << ")"; + << ", expected: >=" << sizeof(uint32_t) << ")"; return; } os << (void *)(tptr) << " ("; - ur_params::serializeFlag(os, *tptr); + os << *tptr; os << ")"; } break; - case UR_DEVICE_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES: { - const ur_memory_order_capability_flags_t *tptr = - (const ur_memory_order_capability_flags_t *)ptr; - if (sizeof(ur_memory_order_capability_flags_t) > size) { + case UR_DEVICE_INFO_LOCAL_MEM_TYPE: { + const ur_device_local_mem_type_t *tptr = + (const ur_device_local_mem_type_t *)ptr; + if (sizeof(ur_device_local_mem_type_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_memory_order_capability_flags_t) - << ")"; + << ", expected: >=" << sizeof(ur_device_local_mem_type_t) << ")"; return; } os << (void *)(tptr) << " ("; - ur_params::serializeFlag(os, *tptr); + os << *tptr; os << ")"; } break; - case UR_DEVICE_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES: { - const ur_memory_scope_capability_flags_t *tptr = - (const ur_memory_scope_capability_flags_t *)ptr; - if (sizeof(ur_memory_scope_capability_flags_t) > size) { + case UR_DEVICE_INFO_LOCAL_MEM_SIZE: { + const uint64_t *tptr = (const uint64_t *)ptr; + if (sizeof(uint64_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_memory_scope_capability_flags_t) - << ")"; + << ", expected: >=" << sizeof(uint64_t) << ")"; return; } os << (void *)(tptr) << " ("; - ur_params::serializeFlag(os, *tptr); + os << *tptr; os << ")"; } break; - case UR_DEVICE_INFO_BFLOAT16: { + case UR_DEVICE_INFO_ERROR_CORRECTION_SUPPORT: { const ur_bool_t *tptr = (const ur_bool_t *)ptr; if (sizeof(ur_bool_t) > size) { os << "invalid size (is: " << size @@ -3394,21 +3397,7 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; - - case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS: { + case UR_DEVICE_INFO_HOST_UNIFIED_MEMORY: { const ur_bool_t *tptr = (const ur_bool_t *)ptr; if (sizeof(ur_bool_t) > size) { os << "invalid size (is: " << size @@ -3422,11 +3411,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_MEMORY_BUS_WIDTH: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { + case UR_DEVICE_INFO_PROFILING_TIMER_RESOLUTION: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; + << ", expected: >=" << sizeof(size_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -3436,22 +3425,7 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_MAX_WORK_GROUPS_3D: { - - const size_t *tptr = (const size_t *)ptr; - os << "{"; - size_t nelems = size / sizeof(size_t); - for (size_t i = 0; i < nelems; ++i) { - if (i != 0) { - os << ", "; - } - - os << tptr[i]; - } - os << "}"; - } break; - - case UR_DEVICE_INFO_ASYNC_BARRIER: { + case UR_DEVICE_INFO_ENDIAN_LITTLE: { const ur_bool_t *tptr = (const ur_bool_t *)ptr; if (sizeof(ur_bool_t) > size) { os << "invalid size (is: " << size @@ -3465,7 +3439,7 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_MEM_CHANNEL_SUPPORT: { + case UR_DEVICE_INFO_AVAILABLE: { const ur_bool_t *tptr = (const ur_bool_t *)ptr; if (sizeof(ur_bool_t) > size) { os << "invalid size (is: " << size @@ -3479,7 +3453,7 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED: { + case UR_DEVICE_INFO_COMPILER_AVAILABLE: { const ur_bool_t *tptr = (const ur_bool_t *)ptr; if (sizeof(ur_bool_t) > size) { os << "invalid size (is: " << size @@ -3493,11 +3467,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { + case UR_DEVICE_INFO_LINKER_AVAILABLE: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; + << ", expected: >=" << sizeof(ur_bool_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -3507,63 +3481,71 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_IP_VERSION: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { + case UR_DEVICE_INFO_EXECUTION_CAPABILITIES: { + const ur_device_exec_capability_flags_t *tptr = + (const ur_device_exec_capability_flags_t *)ptr; + if (sizeof(ur_device_exec_capability_flags_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; + << ", expected: >=" << sizeof(ur_device_exec_capability_flags_t) + << ")"; return; } os << (void *)(tptr) << " ("; - os << *tptr; + ur_params::serializeFlag(os, *tptr); os << ")"; } break; - case UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP: { - const ur_bool_t *tptr = (const ur_bool_t *)ptr; - if (sizeof(ur_bool_t) > size) { + case UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES: { + const ur_queue_flags_t *tptr = (const ur_queue_flags_t *)ptr; + if (sizeof(ur_queue_flags_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_bool_t) << ")"; + << ", expected: >=" << sizeof(ur_queue_flags_t) << ")"; return; } os << (void *)(tptr) << " ("; - os << *tptr; + ur_params::serializeFlag(os, *tptr); os << ")"; } break; - case UR_DEVICE_INFO_BINDLESS_IMAGES_1D_USM_SUPPORT_EXP: { - const ur_bool_t *tptr = (const ur_bool_t *)ptr; - if (sizeof(ur_bool_t) > size) { + case UR_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES: { + const ur_queue_flags_t *tptr = (const ur_queue_flags_t *)ptr; + if (sizeof(ur_queue_flags_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_bool_t) << ")"; + << ", expected: >=" << sizeof(ur_queue_flags_t) << ")"; return; } os << (void *)(tptr) << " ("; - os << *tptr; + ur_params::serializeFlag(os, *tptr); os << ")"; } break; - case UR_DEVICE_INFO_BINDLESS_IMAGES_2D_USM_SUPPORT_EXP: { - const ur_bool_t *tptr = (const ur_bool_t *)ptr; - if (sizeof(ur_bool_t) > size) { + case UR_DEVICE_INFO_BUILT_IN_KERNELS: { + + const char *tptr = (const char *)ptr; + serializePtr(os, tptr); + } break; + + case UR_DEVICE_INFO_PLATFORM: { + const ur_platform_handle_t *tptr = (const ur_platform_handle_t *)ptr; + if (sizeof(ur_platform_handle_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_bool_t) << ")"; + << ", expected: >=" << sizeof(ur_platform_handle_t) << ")"; return; } os << (void *)(tptr) << " ("; - os << *tptr; + ur_params::serializePtr(os, *tptr); os << ")"; } break; - case UR_DEVICE_INFO_IMAGE_PITCH_ALIGN_EXP: { + case UR_DEVICE_INFO_REFERENCE_COUNT: { const uint32_t *tptr = (const uint32_t *)ptr; if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size @@ -3577,35 +3559,55 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_MAX_IMAGE_LINEAR_WIDTH_EXP: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_IL_VERSION: { - os << *tptr; + const char *tptr = (const char *)ptr; + serializePtr(os, tptr); + } break; - os << ")"; + case UR_DEVICE_INFO_NAME: { + + const char *tptr = (const char *)ptr; + serializePtr(os, tptr); } break; - case UR_DEVICE_INFO_MAX_IMAGE_LINEAR_HEIGHT_EXP: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_VENDOR: { - os << *tptr; + const char *tptr = (const char *)ptr; + serializePtr(os, tptr); + } break; - os << ")"; + case UR_DEVICE_INFO_DRIVER_VERSION: { + + const char *tptr = (const char *)ptr; + serializePtr(os, tptr); } break; - case UR_DEVICE_INFO_MAX_IMAGE_LINEAR_PITCH_EXP: { + case UR_DEVICE_INFO_PROFILE: { + + const char *tptr = (const char *)ptr; + serializePtr(os, tptr); + } break; + + case UR_DEVICE_INFO_VERSION: { + + const char *tptr = (const char *)ptr; + serializePtr(os, tptr); + } break; + + case UR_DEVICE_INFO_BACKEND_RUNTIME_VERSION: { + + const char *tptr = (const char *)ptr; + serializePtr(os, tptr); + } break; + + case UR_DEVICE_INFO_EXTENSIONS: { + + const char *tptr = (const char *)ptr; + serializePtr(os, tptr); + } break; + + case UR_DEVICE_INFO_PRINTF_BUFFER_SIZE: { const size_t *tptr = (const size_t *)ptr; if (sizeof(size_t) > size) { os << "invalid size (is: " << size @@ -3619,7 +3621,7 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_MIPMAP_SUPPORT_EXP: { + case UR_DEVICE_INFO_PREFERRED_INTEROP_USER_SYNC: { const ur_bool_t *tptr = (const ur_bool_t *)ptr; if (sizeof(ur_bool_t) > size) { os << "invalid size (is: " << size @@ -3633,21 +3635,36 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_MIPMAP_ANISOTROPY_SUPPORT_EXP: { - const ur_bool_t *tptr = (const ur_bool_t *)ptr; - if (sizeof(ur_bool_t) > size) { + case UR_DEVICE_INFO_PARENT_DEVICE: { + const ur_device_handle_t *tptr = (const ur_device_handle_t *)ptr; + if (sizeof(ur_device_handle_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_bool_t) << ")"; + << ", expected: >=" << sizeof(ur_device_handle_t) << ")"; return; } os << (void *)(tptr) << " ("; - os << *tptr; + ur_params::serializePtr(os, *tptr); os << ")"; } break; - case UR_DEVICE_INFO_MIPMAP_MAX_ANISOTROPY_EXP: { + case UR_DEVICE_INFO_SUPPORTED_PARTITIONS: { + + const ur_device_partition_t *tptr = (const ur_device_partition_t *)ptr; + os << "{"; + size_t nelems = size / sizeof(ur_device_partition_t); + for (size_t i = 0; i < nelems; ++i) { + if (i != 0) { + os << ", "; + } + + os << tptr[i]; + } + os << "}"; + } break; + + case UR_DEVICE_INFO_PARTITION_MAX_SUB_DEVICES: { const uint32_t *tptr = (const uint32_t *)ptr; if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size @@ -3661,39 +3678,43 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_MIPMAP_LEVEL_REFERENCE_SUPPORT_EXP: { - const ur_bool_t *tptr = (const ur_bool_t *)ptr; - if (sizeof(ur_bool_t) > size) { + case UR_DEVICE_INFO_PARTITION_AFFINITY_DOMAIN: { + const ur_device_affinity_domain_flags_t *tptr = + (const ur_device_affinity_domain_flags_t *)ptr; + if (sizeof(ur_device_affinity_domain_flags_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_bool_t) << ")"; + << ", expected: >=" << sizeof(ur_device_affinity_domain_flags_t) + << ")"; return; } os << (void *)(tptr) << " ("; - os << *tptr; + ur_params::serializeFlag(os, *tptr); os << ")"; } break; - case UR_DEVICE_INFO_INTEROP_MEMORY_IMPORT_SUPPORT_EXP: { - const ur_bool_t *tptr = (const ur_bool_t *)ptr; - if (sizeof(ur_bool_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_bool_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_PARTITION_TYPE: { - os << *tptr; + const ur_device_partition_property_t *tptr = + (const ur_device_partition_property_t *)ptr; + os << "{"; + size_t nelems = size / sizeof(ur_device_partition_property_t); + for (size_t i = 0; i < nelems; ++i) { + if (i != 0) { + os << ", "; + } - os << ")"; + os << tptr[i]; + } + os << "}"; } break; - case UR_DEVICE_INFO_INTEROP_MEMORY_EXPORT_SUPPORT_EXP: { - const ur_bool_t *tptr = (const ur_bool_t *)ptr; - if (sizeof(ur_bool_t) > size) { + case UR_DEVICE_INFO_MAX_NUM_SUB_GROUPS: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_bool_t) << ")"; + << ", expected: >=" << sizeof(uint32_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -3703,7 +3724,7 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_INTEROP_SEMAPHORE_IMPORT_SUPPORT_EXP: { + case UR_DEVICE_INFO_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS: { const ur_bool_t *tptr = (const ur_bool_t *)ptr; if (sizeof(ur_bool_t) > size) { os << "invalid size (is: " << size @@ -3717,416 +3738,699 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP: { - const ur_bool_t *tptr = (const ur_bool_t *)ptr; - if (sizeof(ur_bool_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_bool_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_DEVICE_INFO_SUB_GROUP_SIZES_INTEL: { - os << *tptr; + const uint32_t *tptr = (const uint32_t *)ptr; + os << "{"; + size_t nelems = size / sizeof(uint32_t); + for (size_t i = 0; i < nelems; ++i) { + if (i != 0) { + os << ", "; + } - os << ")"; - } break; - default: - os << "unknown enumerator"; - break; - } -} -} // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, - enum ur_device_affinity_domain_flag_t value) { - switch (value) { - - case UR_DEVICE_AFFINITY_DOMAIN_FLAG_NUMA: - os << "UR_DEVICE_AFFINITY_DOMAIN_FLAG_NUMA"; - break; + os << tptr[i]; + } + os << "}"; + } break; - case UR_DEVICE_AFFINITY_DOMAIN_FLAG_L4_CACHE: - os << "UR_DEVICE_AFFINITY_DOMAIN_FLAG_L4_CACHE"; - break; + case UR_DEVICE_INFO_USM_HOST_SUPPORT: { + const ur_device_usm_access_capability_flags_t *tptr = + (const ur_device_usm_access_capability_flags_t *)ptr; + if (sizeof(ur_device_usm_access_capability_flags_t) > size) { + os << "invalid size (is: " << size << ", expected: >=" + << sizeof(ur_device_usm_access_capability_flags_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_DEVICE_AFFINITY_DOMAIN_FLAG_L3_CACHE: - os << "UR_DEVICE_AFFINITY_DOMAIN_FLAG_L3_CACHE"; - break; + ur_params::serializeFlag(os, + *tptr); - case UR_DEVICE_AFFINITY_DOMAIN_FLAG_L2_CACHE: - os << "UR_DEVICE_AFFINITY_DOMAIN_FLAG_L2_CACHE"; - break; + os << ")"; + } break; - case UR_DEVICE_AFFINITY_DOMAIN_FLAG_L1_CACHE: - os << "UR_DEVICE_AFFINITY_DOMAIN_FLAG_L1_CACHE"; - break; + case UR_DEVICE_INFO_USM_DEVICE_SUPPORT: { + const ur_device_usm_access_capability_flags_t *tptr = + (const ur_device_usm_access_capability_flags_t *)ptr; + if (sizeof(ur_device_usm_access_capability_flags_t) > size) { + os << "invalid size (is: " << size << ", expected: >=" + << sizeof(ur_device_usm_access_capability_flags_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_DEVICE_AFFINITY_DOMAIN_FLAG_NEXT_PARTITIONABLE: - os << "UR_DEVICE_AFFINITY_DOMAIN_FLAG_NEXT_PARTITIONABLE"; - break; - default: - os << "unknown enumerator"; - break; - } - return os; -} -namespace ur_params { + ur_params::serializeFlag(os, + *tptr); -template <> -inline void serializeFlag(std::ostream &os, - uint32_t flag) { - uint32_t val = flag; - bool first = true; + os << ")"; + } break; - if ((val & UR_DEVICE_AFFINITY_DOMAIN_FLAG_NUMA) == - (uint32_t)UR_DEVICE_AFFINITY_DOMAIN_FLAG_NUMA) { - val ^= (uint32_t)UR_DEVICE_AFFINITY_DOMAIN_FLAG_NUMA; - if (!first) { - os << " | "; - } else { - first = false; + case UR_DEVICE_INFO_USM_SINGLE_SHARED_SUPPORT: { + const ur_device_usm_access_capability_flags_t *tptr = + (const ur_device_usm_access_capability_flags_t *)ptr; + if (sizeof(ur_device_usm_access_capability_flags_t) > size) { + os << "invalid size (is: " << size << ", expected: >=" + << sizeof(ur_device_usm_access_capability_flags_t) << ")"; + return; } - os << UR_DEVICE_AFFINITY_DOMAIN_FLAG_NUMA; - } + os << (void *)(tptr) << " ("; - if ((val & UR_DEVICE_AFFINITY_DOMAIN_FLAG_L4_CACHE) == - (uint32_t)UR_DEVICE_AFFINITY_DOMAIN_FLAG_L4_CACHE) { - val ^= (uint32_t)UR_DEVICE_AFFINITY_DOMAIN_FLAG_L4_CACHE; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_DEVICE_AFFINITY_DOMAIN_FLAG_L4_CACHE; - } + ur_params::serializeFlag(os, + *tptr); - if ((val & UR_DEVICE_AFFINITY_DOMAIN_FLAG_L3_CACHE) == - (uint32_t)UR_DEVICE_AFFINITY_DOMAIN_FLAG_L3_CACHE) { - val ^= (uint32_t)UR_DEVICE_AFFINITY_DOMAIN_FLAG_L3_CACHE; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_DEVICE_AFFINITY_DOMAIN_FLAG_L3_CACHE; - } + os << ")"; + } break; - if ((val & UR_DEVICE_AFFINITY_DOMAIN_FLAG_L2_CACHE) == - (uint32_t)UR_DEVICE_AFFINITY_DOMAIN_FLAG_L2_CACHE) { - val ^= (uint32_t)UR_DEVICE_AFFINITY_DOMAIN_FLAG_L2_CACHE; - if (!first) { - os << " | "; - } else { - first = false; + case UR_DEVICE_INFO_USM_CROSS_SHARED_SUPPORT: { + const ur_device_usm_access_capability_flags_t *tptr = + (const ur_device_usm_access_capability_flags_t *)ptr; + if (sizeof(ur_device_usm_access_capability_flags_t) > size) { + os << "invalid size (is: " << size << ", expected: >=" + << sizeof(ur_device_usm_access_capability_flags_t) << ")"; + return; } - os << UR_DEVICE_AFFINITY_DOMAIN_FLAG_L2_CACHE; - } + os << (void *)(tptr) << " ("; - if ((val & UR_DEVICE_AFFINITY_DOMAIN_FLAG_L1_CACHE) == - (uint32_t)UR_DEVICE_AFFINITY_DOMAIN_FLAG_L1_CACHE) { - val ^= (uint32_t)UR_DEVICE_AFFINITY_DOMAIN_FLAG_L1_CACHE; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_DEVICE_AFFINITY_DOMAIN_FLAG_L1_CACHE; - } + ur_params::serializeFlag(os, + *tptr); - if ((val & UR_DEVICE_AFFINITY_DOMAIN_FLAG_NEXT_PARTITIONABLE) == - (uint32_t)UR_DEVICE_AFFINITY_DOMAIN_FLAG_NEXT_PARTITIONABLE) { - val ^= (uint32_t)UR_DEVICE_AFFINITY_DOMAIN_FLAG_NEXT_PARTITIONABLE; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_DEVICE_AFFINITY_DOMAIN_FLAG_NEXT_PARTITIONABLE; - } - if (val != 0) { - std::bitset<32> bits(val); - if (!first) { - os << " | "; + os << ")"; + } break; + + case UR_DEVICE_INFO_USM_SYSTEM_SHARED_SUPPORT: { + const ur_device_usm_access_capability_flags_t *tptr = + (const ur_device_usm_access_capability_flags_t *)ptr; + if (sizeof(ur_device_usm_access_capability_flags_t) > size) { + os << "invalid size (is: " << size << ", expected: >=" + << sizeof(ur_device_usm_access_capability_flags_t) << ")"; + return; } - os << "unknown bit flags " << bits; - } else if (first) { - os << "0"; - } -} -} // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, - enum ur_device_partition_t value) { - switch (value) { + os << (void *)(tptr) << " ("; - case UR_DEVICE_PARTITION_EQUALLY: - os << "UR_DEVICE_PARTITION_EQUALLY"; - break; + ur_params::serializeFlag(os, + *tptr); - case UR_DEVICE_PARTITION_BY_COUNTS: - os << "UR_DEVICE_PARTITION_BY_COUNTS"; - break; + os << ")"; + } break; - case UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN: - os << "UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN"; - break; + case UR_DEVICE_INFO_UUID: { - case UR_DEVICE_PARTITION_BY_CSLICE: - os << "UR_DEVICE_PARTITION_BY_CSLICE"; - break; - default: - os << "unknown enumerator"; - break; - } - return os; -} -inline std::ostream & -operator<<(std::ostream &os, const union ur_device_partition_value_t params) { - os << "(union ur_device_partition_value_t){"; + const char *tptr = (const char *)ptr; + serializePtr(os, tptr); + } break; - os << ".equally = "; + case UR_DEVICE_INFO_PCI_ADDRESS: { - os << (params.equally); + const char *tptr = (const char *)ptr; + serializePtr(os, tptr); + } break; - os << ", "; - os << ".count = "; + case UR_DEVICE_INFO_GPU_EU_COUNT: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - os << (params.count); + os << *tptr; - os << ", "; - os << ".affinity_domain = "; + os << ")"; + } break; - ur_params::serializeFlag( - os, (params.affinity_domain)); + case UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - os << "}"; - return os; -} -inline std::ostream & -operator<<(std::ostream &os, - const struct ur_device_partition_property_t params) { - os << "(struct ur_device_partition_property_t){"; + os << *tptr; - os << ".type = "; + os << ")"; + } break; - os << (params.type); + case UR_DEVICE_INFO_GPU_EU_SLICES: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - os << ", "; - os << ".value = "; - - os << (params.value); + os << *tptr; - os << "}"; - return os; -} -inline std::ostream & -operator<<(std::ostream &os, - const struct ur_device_partition_properties_t params) { - os << "(struct ur_device_partition_properties_t){"; + os << ")"; + } break; - os << ".stype = "; + case UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - os << (params.stype); + os << *tptr; - os << ", "; - os << ".pNext = "; + os << ")"; + } break; - ur_params::serializeStruct(os, (params.pNext)); + case UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - os << ", "; - os << ".pProperties = "; + os << *tptr; - ur_params::serializePtr(os, (params.pProperties)); + os << ")"; + } break; - os << ", "; - os << ".PropCount = "; + case UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - os << (params.PropCount); + os << *tptr; - os << "}"; - return os; -} -inline std::ostream &operator<<(std::ostream &os, - enum ur_device_fp_capability_flag_t value) { - switch (value) { + os << ")"; + } break; - case UR_DEVICE_FP_CAPABILITY_FLAG_CORRECTLY_ROUNDED_DIVIDE_SQRT: - os << "UR_DEVICE_FP_CAPABILITY_FLAG_CORRECTLY_ROUNDED_DIVIDE_SQRT"; - break; + case UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_NEAREST: - os << "UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_NEAREST"; - break; + os << *tptr; - case UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_ZERO: - os << "UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_ZERO"; - break; + os << ")"; + } break; - case UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_INF: - os << "UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_INF"; - break; + case UR_DEVICE_INFO_IMAGE_SRGB: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_bool_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_DEVICE_FP_CAPABILITY_FLAG_INF_NAN: - os << "UR_DEVICE_FP_CAPABILITY_FLAG_INF_NAN"; - break; + os << *tptr; - case UR_DEVICE_FP_CAPABILITY_FLAG_DENORM: - os << "UR_DEVICE_FP_CAPABILITY_FLAG_DENORM"; - break; + os << ")"; + } break; - case UR_DEVICE_FP_CAPABILITY_FLAG_FMA: - os << "UR_DEVICE_FP_CAPABILITY_FLAG_FMA"; - break; + case UR_DEVICE_INFO_BUILD_ON_SUBDEVICE: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_bool_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_DEVICE_FP_CAPABILITY_FLAG_SOFT_FLOAT: - os << "UR_DEVICE_FP_CAPABILITY_FLAG_SOFT_FLOAT"; - break; - default: - os << "unknown enumerator"; - break; - } - return os; -} -namespace ur_params { + os << *tptr; -template <> -inline void serializeFlag(std::ostream &os, - uint32_t flag) { - uint32_t val = flag; - bool first = true; + os << ")"; + } break; - if ((val & UR_DEVICE_FP_CAPABILITY_FLAG_CORRECTLY_ROUNDED_DIVIDE_SQRT) == - (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_CORRECTLY_ROUNDED_DIVIDE_SQRT) { - val ^= (uint32_t) - UR_DEVICE_FP_CAPABILITY_FLAG_CORRECTLY_ROUNDED_DIVIDE_SQRT; - if (!first) { - os << " | "; - } else { - first = false; + case UR_DEVICE_INFO_ATOMIC_64: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_bool_t) << ")"; + return; } - os << UR_DEVICE_FP_CAPABILITY_FLAG_CORRECTLY_ROUNDED_DIVIDE_SQRT; - } + os << (void *)(tptr) << " ("; - if ((val & UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_NEAREST) == - (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_NEAREST) { - val ^= (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_NEAREST; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_NEAREST; - } + os << *tptr; - if ((val & UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_ZERO) == - (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_ZERO) { - val ^= (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_ZERO; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_ZERO; - } + os << ")"; + } break; - if ((val & UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_INF) == - (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_INF) { - val ^= (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_INF; - if (!first) { - os << " | "; - } else { - first = false; + case UR_DEVICE_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES: { + const ur_memory_order_capability_flags_t *tptr = + (const ur_memory_order_capability_flags_t *)ptr; + if (sizeof(ur_memory_order_capability_flags_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_memory_order_capability_flags_t) + << ")"; + return; } - os << UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_INF; - } + os << (void *)(tptr) << " ("; - if ((val & UR_DEVICE_FP_CAPABILITY_FLAG_INF_NAN) == - (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_INF_NAN) { - val ^= (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_INF_NAN; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_DEVICE_FP_CAPABILITY_FLAG_INF_NAN; - } + ur_params::serializeFlag(os, *tptr); - if ((val & UR_DEVICE_FP_CAPABILITY_FLAG_DENORM) == - (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_DENORM) { - val ^= (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_DENORM; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_DEVICE_FP_CAPABILITY_FLAG_DENORM; - } + os << ")"; + } break; - if ((val & UR_DEVICE_FP_CAPABILITY_FLAG_FMA) == - (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_FMA) { - val ^= (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_FMA; - if (!first) { - os << " | "; - } else { - first = false; + case UR_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES: { + const ur_memory_scope_capability_flags_t *tptr = + (const ur_memory_scope_capability_flags_t *)ptr; + if (sizeof(ur_memory_scope_capability_flags_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_memory_scope_capability_flags_t) + << ")"; + return; } - os << UR_DEVICE_FP_CAPABILITY_FLAG_FMA; - } + os << (void *)(tptr) << " ("; - if ((val & UR_DEVICE_FP_CAPABILITY_FLAG_SOFT_FLOAT) == - (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_SOFT_FLOAT) { - val ^= (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_SOFT_FLOAT; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_DEVICE_FP_CAPABILITY_FLAG_SOFT_FLOAT; - } - if (val != 0) { - std::bitset<32> bits(val); - if (!first) { - os << " | "; - } - os << "unknown bit flags " << bits; - } else if (first) { - os << "0"; - } -} -} // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, - enum ur_device_mem_cache_type_t value) { - switch (value) { + ur_params::serializeFlag(os, *tptr); - case UR_DEVICE_MEM_CACHE_TYPE_NONE: - os << "UR_DEVICE_MEM_CACHE_TYPE_NONE"; - break; + os << ")"; + } break; - case UR_DEVICE_MEM_CACHE_TYPE_READ_ONLY_CACHE: - os << "UR_DEVICE_MEM_CACHE_TYPE_READ_ONLY_CACHE"; - break; + case UR_DEVICE_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES: { + const ur_memory_order_capability_flags_t *tptr = + (const ur_memory_order_capability_flags_t *)ptr; + if (sizeof(ur_memory_order_capability_flags_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_memory_order_capability_flags_t) + << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_DEVICE_MEM_CACHE_TYPE_READ_WRITE_CACHE: - os << "UR_DEVICE_MEM_CACHE_TYPE_READ_WRITE_CACHE"; - break; + ur_params::serializeFlag(os, *tptr); + + os << ")"; + } break; + + case UR_DEVICE_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES: { + const ur_memory_scope_capability_flags_t *tptr = + (const ur_memory_scope_capability_flags_t *)ptr; + if (sizeof(ur_memory_scope_capability_flags_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_memory_scope_capability_flags_t) + << ")"; + return; + } + os << (void *)(tptr) << " ("; + + ur_params::serializeFlag(os, *tptr); + + os << ")"; + } break; + + case UR_DEVICE_INFO_BFLOAT16: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_bool_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_bool_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_DEVICE_INFO_MEMORY_BUS_WIDTH: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_DEVICE_INFO_MAX_WORK_GROUPS_3D: { + + const size_t *tptr = (const size_t *)ptr; + os << "{"; + size_t nelems = size / sizeof(size_t); + for (size_t i = 0; i < nelems; ++i) { + if (i != 0) { + os << ", "; + } + + os << tptr[i]; + } + os << "}"; + } break; + + case UR_DEVICE_INFO_ASYNC_BARRIER: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_bool_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_DEVICE_INFO_MEM_CHANNEL_SUPPORT: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_bool_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_bool_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_DEVICE_INFO_IP_VERSION: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_bool_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_DEVICE_INFO_BINDLESS_IMAGES_1D_USM_SUPPORT_EXP: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_bool_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_DEVICE_INFO_BINDLESS_IMAGES_2D_USM_SUPPORT_EXP: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_bool_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_DEVICE_INFO_IMAGE_PITCH_ALIGN_EXP: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_DEVICE_INFO_MAX_IMAGE_LINEAR_WIDTH_EXP: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(size_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_DEVICE_INFO_MAX_IMAGE_LINEAR_HEIGHT_EXP: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(size_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_DEVICE_INFO_MAX_IMAGE_LINEAR_PITCH_EXP: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(size_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_DEVICE_INFO_MIPMAP_SUPPORT_EXP: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_bool_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_DEVICE_INFO_MIPMAP_ANISOTROPY_SUPPORT_EXP: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_bool_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_DEVICE_INFO_MIPMAP_MAX_ANISOTROPY_EXP: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_DEVICE_INFO_MIPMAP_LEVEL_REFERENCE_SUPPORT_EXP: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_bool_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_DEVICE_INFO_INTEROP_MEMORY_IMPORT_SUPPORT_EXP: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_bool_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_DEVICE_INFO_INTEROP_MEMORY_EXPORT_SUPPORT_EXP: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_bool_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_DEVICE_INFO_INTEROP_SEMAPHORE_IMPORT_SUPPORT_EXP: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_bool_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_bool_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; default: os << "unknown enumerator"; break; } - return os; } +} // namespace ur_params inline std::ostream &operator<<(std::ostream &os, - enum ur_device_local_mem_type_t value) { + enum ur_device_affinity_domain_flag_t value) { switch (value) { - case UR_DEVICE_LOCAL_MEM_TYPE_NONE: - os << "UR_DEVICE_LOCAL_MEM_TYPE_NONE"; + case UR_DEVICE_AFFINITY_DOMAIN_FLAG_NUMA: + os << "UR_DEVICE_AFFINITY_DOMAIN_FLAG_NUMA"; break; - case UR_DEVICE_LOCAL_MEM_TYPE_LOCAL: - os << "UR_DEVICE_LOCAL_MEM_TYPE_LOCAL"; + case UR_DEVICE_AFFINITY_DOMAIN_FLAG_L4_CACHE: + os << "UR_DEVICE_AFFINITY_DOMAIN_FLAG_L4_CACHE"; break; - case UR_DEVICE_LOCAL_MEM_TYPE_GLOBAL: - os << "UR_DEVICE_LOCAL_MEM_TYPE_GLOBAL"; + case UR_DEVICE_AFFINITY_DOMAIN_FLAG_L3_CACHE: + os << "UR_DEVICE_AFFINITY_DOMAIN_FLAG_L3_CACHE"; + break; + + case UR_DEVICE_AFFINITY_DOMAIN_FLAG_L2_CACHE: + os << "UR_DEVICE_AFFINITY_DOMAIN_FLAG_L2_CACHE"; + break; + + case UR_DEVICE_AFFINITY_DOMAIN_FLAG_L1_CACHE: + os << "UR_DEVICE_AFFINITY_DOMAIN_FLAG_L1_CACHE"; + break; + + case UR_DEVICE_AFFINITY_DOMAIN_FLAG_NEXT_PARTITIONABLE: + os << "UR_DEVICE_AFFINITY_DOMAIN_FLAG_NEXT_PARTITIONABLE"; break; default: os << "unknown enumerator"; @@ -4134,51 +4438,78 @@ inline std::ostream &operator<<(std::ostream &os, } return os; } -inline std::ostream &operator<<(std::ostream &os, - enum ur_device_exec_capability_flag_t value) { - switch (value) { +namespace ur_params { - case UR_DEVICE_EXEC_CAPABILITY_FLAG_KERNEL: - os << "UR_DEVICE_EXEC_CAPABILITY_FLAG_KERNEL"; - break; +template <> +inline void serializeFlag(std::ostream &os, + uint32_t flag) { + uint32_t val = flag; + bool first = true; + + if ((val & UR_DEVICE_AFFINITY_DOMAIN_FLAG_NUMA) == + (uint32_t)UR_DEVICE_AFFINITY_DOMAIN_FLAG_NUMA) { + val ^= (uint32_t)UR_DEVICE_AFFINITY_DOMAIN_FLAG_NUMA; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_DEVICE_AFFINITY_DOMAIN_FLAG_NUMA; + } + + if ((val & UR_DEVICE_AFFINITY_DOMAIN_FLAG_L4_CACHE) == + (uint32_t)UR_DEVICE_AFFINITY_DOMAIN_FLAG_L4_CACHE) { + val ^= (uint32_t)UR_DEVICE_AFFINITY_DOMAIN_FLAG_L4_CACHE; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_DEVICE_AFFINITY_DOMAIN_FLAG_L4_CACHE; + } - case UR_DEVICE_EXEC_CAPABILITY_FLAG_NATIVE_KERNEL: - os << "UR_DEVICE_EXEC_CAPABILITY_FLAG_NATIVE_KERNEL"; - break; - default: - os << "unknown enumerator"; - break; + if ((val & UR_DEVICE_AFFINITY_DOMAIN_FLAG_L3_CACHE) == + (uint32_t)UR_DEVICE_AFFINITY_DOMAIN_FLAG_L3_CACHE) { + val ^= (uint32_t)UR_DEVICE_AFFINITY_DOMAIN_FLAG_L3_CACHE; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_DEVICE_AFFINITY_DOMAIN_FLAG_L3_CACHE; } - return os; -} -namespace ur_params { -template <> -inline void serializeFlag(std::ostream &os, - uint32_t flag) { - uint32_t val = flag; - bool first = true; + if ((val & UR_DEVICE_AFFINITY_DOMAIN_FLAG_L2_CACHE) == + (uint32_t)UR_DEVICE_AFFINITY_DOMAIN_FLAG_L2_CACHE) { + val ^= (uint32_t)UR_DEVICE_AFFINITY_DOMAIN_FLAG_L2_CACHE; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_DEVICE_AFFINITY_DOMAIN_FLAG_L2_CACHE; + } - if ((val & UR_DEVICE_EXEC_CAPABILITY_FLAG_KERNEL) == - (uint32_t)UR_DEVICE_EXEC_CAPABILITY_FLAG_KERNEL) { - val ^= (uint32_t)UR_DEVICE_EXEC_CAPABILITY_FLAG_KERNEL; + if ((val & UR_DEVICE_AFFINITY_DOMAIN_FLAG_L1_CACHE) == + (uint32_t)UR_DEVICE_AFFINITY_DOMAIN_FLAG_L1_CACHE) { + val ^= (uint32_t)UR_DEVICE_AFFINITY_DOMAIN_FLAG_L1_CACHE; if (!first) { os << " | "; } else { first = false; } - os << UR_DEVICE_EXEC_CAPABILITY_FLAG_KERNEL; + os << UR_DEVICE_AFFINITY_DOMAIN_FLAG_L1_CACHE; } - if ((val & UR_DEVICE_EXEC_CAPABILITY_FLAG_NATIVE_KERNEL) == - (uint32_t)UR_DEVICE_EXEC_CAPABILITY_FLAG_NATIVE_KERNEL) { - val ^= (uint32_t)UR_DEVICE_EXEC_CAPABILITY_FLAG_NATIVE_KERNEL; + if ((val & UR_DEVICE_AFFINITY_DOMAIN_FLAG_NEXT_PARTITIONABLE) == + (uint32_t)UR_DEVICE_AFFINITY_DOMAIN_FLAG_NEXT_PARTITIONABLE) { + val ^= (uint32_t)UR_DEVICE_AFFINITY_DOMAIN_FLAG_NEXT_PARTITIONABLE; if (!first) { os << " | "; } else { first = false; } - os << UR_DEVICE_EXEC_CAPABILITY_FLAG_NATIVE_KERNEL; + os << UR_DEVICE_AFFINITY_DOMAIN_FLAG_NEXT_PARTITIONABLE; } if (val != 0) { std::bitset<32> bits(val); @@ -4191,10 +4522,74 @@ inline void serializeFlag(std::ostream &os, } } } // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, + enum ur_device_partition_t value) { + switch (value) { + + case UR_DEVICE_PARTITION_EQUALLY: + os << "UR_DEVICE_PARTITION_EQUALLY"; + break; + + case UR_DEVICE_PARTITION_BY_COUNTS: + os << "UR_DEVICE_PARTITION_BY_COUNTS"; + break; + + case UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN: + os << "UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN"; + break; + + case UR_DEVICE_PARTITION_BY_CSLICE: + os << "UR_DEVICE_PARTITION_BY_CSLICE"; + break; + default: + os << "unknown enumerator"; + break; + } + return os; +} +inline std::ostream & +operator<<(std::ostream &os, const union ur_device_partition_value_t params) { + os << "(union ur_device_partition_value_t){"; + + os << ".equally = "; + + os << (params.equally); + + os << ", "; + os << ".count = "; + + os << (params.count); + + os << ", "; + os << ".affinity_domain = "; + + ur_params::serializeFlag( + os, (params.affinity_domain)); + + os << "}"; + return os; +} inline std::ostream & operator<<(std::ostream &os, - const struct ur_device_native_properties_t params) { - os << "(struct ur_device_native_properties_t){"; + const struct ur_device_partition_property_t params) { + os << "(struct ur_device_partition_property_t){"; + + os << ".type = "; + + os << (params.type); + + os << ", "; + os << ".value = "; + + os << (params.value); + + os << "}"; + return os; +} +inline std::ostream & +operator<<(std::ostream &os, + const struct ur_device_partition_properties_t params) { + os << "(struct ur_device_partition_properties_t){"; os << ".stype = "; @@ -4206,35 +4601,52 @@ operator<<(std::ostream &os, ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".isNativeHandleOwned = "; + os << ".pProperties = "; - os << (params.isNativeHandleOwned); + ur_params::serializePtr(os, (params.pProperties)); + + os << ", "; + os << ".PropCount = "; + + os << (params.PropCount); os << "}"; return os; } inline std::ostream &operator<<(std::ostream &os, - enum ur_memory_order_capability_flag_t value) { + enum ur_device_fp_capability_flag_t value) { switch (value) { - case UR_MEMORY_ORDER_CAPABILITY_FLAG_RELAXED: - os << "UR_MEMORY_ORDER_CAPABILITY_FLAG_RELAXED"; + case UR_DEVICE_FP_CAPABILITY_FLAG_CORRECTLY_ROUNDED_DIVIDE_SQRT: + os << "UR_DEVICE_FP_CAPABILITY_FLAG_CORRECTLY_ROUNDED_DIVIDE_SQRT"; break; - case UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQUIRE: - os << "UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQUIRE"; + case UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_NEAREST: + os << "UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_NEAREST"; break; - case UR_MEMORY_ORDER_CAPABILITY_FLAG_RELEASE: - os << "UR_MEMORY_ORDER_CAPABILITY_FLAG_RELEASE"; + case UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_ZERO: + os << "UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_ZERO"; break; - case UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQ_REL: - os << "UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQ_REL"; + case UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_INF: + os << "UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_INF"; break; - case UR_MEMORY_ORDER_CAPABILITY_FLAG_SEQ_CST: - os << "UR_MEMORY_ORDER_CAPABILITY_FLAG_SEQ_CST"; + case UR_DEVICE_FP_CAPABILITY_FLAG_INF_NAN: + os << "UR_DEVICE_FP_CAPABILITY_FLAG_INF_NAN"; + break; + + case UR_DEVICE_FP_CAPABILITY_FLAG_DENORM: + os << "UR_DEVICE_FP_CAPABILITY_FLAG_DENORM"; + break; + + case UR_DEVICE_FP_CAPABILITY_FLAG_FMA: + os << "UR_DEVICE_FP_CAPABILITY_FLAG_FMA"; + break; + + case UR_DEVICE_FP_CAPABILITY_FLAG_SOFT_FLOAT: + os << "UR_DEVICE_FP_CAPABILITY_FLAG_SOFT_FLOAT"; break; default: os << "unknown enumerator"; @@ -4245,64 +4657,98 @@ inline std::ostream &operator<<(std::ostream &os, namespace ur_params { template <> -inline void serializeFlag(std::ostream &os, - uint32_t flag) { +inline void serializeFlag(std::ostream &os, + uint32_t flag) { uint32_t val = flag; bool first = true; - if ((val & UR_MEMORY_ORDER_CAPABILITY_FLAG_RELAXED) == - (uint32_t)UR_MEMORY_ORDER_CAPABILITY_FLAG_RELAXED) { - val ^= (uint32_t)UR_MEMORY_ORDER_CAPABILITY_FLAG_RELAXED; + if ((val & UR_DEVICE_FP_CAPABILITY_FLAG_CORRECTLY_ROUNDED_DIVIDE_SQRT) == + (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_CORRECTLY_ROUNDED_DIVIDE_SQRT) { + val ^= (uint32_t) + UR_DEVICE_FP_CAPABILITY_FLAG_CORRECTLY_ROUNDED_DIVIDE_SQRT; if (!first) { os << " | "; } else { first = false; } - os << UR_MEMORY_ORDER_CAPABILITY_FLAG_RELAXED; + os << UR_DEVICE_FP_CAPABILITY_FLAG_CORRECTLY_ROUNDED_DIVIDE_SQRT; } - if ((val & UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQUIRE) == - (uint32_t)UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQUIRE) { - val ^= (uint32_t)UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQUIRE; + if ((val & UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_NEAREST) == + (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_NEAREST) { + val ^= (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_NEAREST; if (!first) { os << " | "; } else { first = false; } - os << UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQUIRE; + os << UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_NEAREST; } - if ((val & UR_MEMORY_ORDER_CAPABILITY_FLAG_RELEASE) == - (uint32_t)UR_MEMORY_ORDER_CAPABILITY_FLAG_RELEASE) { - val ^= (uint32_t)UR_MEMORY_ORDER_CAPABILITY_FLAG_RELEASE; + if ((val & UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_ZERO) == + (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_ZERO) { + val ^= (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_ZERO; if (!first) { os << " | "; } else { first = false; } - os << UR_MEMORY_ORDER_CAPABILITY_FLAG_RELEASE; + os << UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_ZERO; } - if ((val & UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQ_REL) == - (uint32_t)UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQ_REL) { - val ^= (uint32_t)UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQ_REL; + if ((val & UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_INF) == + (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_INF) { + val ^= (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_INF; if (!first) { os << " | "; } else { first = false; } - os << UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQ_REL; + os << UR_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_INF; } - if ((val & UR_MEMORY_ORDER_CAPABILITY_FLAG_SEQ_CST) == - (uint32_t)UR_MEMORY_ORDER_CAPABILITY_FLAG_SEQ_CST) { - val ^= (uint32_t)UR_MEMORY_ORDER_CAPABILITY_FLAG_SEQ_CST; + if ((val & UR_DEVICE_FP_CAPABILITY_FLAG_INF_NAN) == + (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_INF_NAN) { + val ^= (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_INF_NAN; if (!first) { os << " | "; } else { first = false; } - os << UR_MEMORY_ORDER_CAPABILITY_FLAG_SEQ_CST; + os << UR_DEVICE_FP_CAPABILITY_FLAG_INF_NAN; + } + + if ((val & UR_DEVICE_FP_CAPABILITY_FLAG_DENORM) == + (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_DENORM) { + val ^= (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_DENORM; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_DEVICE_FP_CAPABILITY_FLAG_DENORM; + } + + if ((val & UR_DEVICE_FP_CAPABILITY_FLAG_FMA) == + (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_FMA) { + val ^= (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_FMA; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_DEVICE_FP_CAPABILITY_FLAG_FMA; + } + + if ((val & UR_DEVICE_FP_CAPABILITY_FLAG_SOFT_FLOAT) == + (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_SOFT_FLOAT) { + val ^= (uint32_t)UR_DEVICE_FP_CAPABILITY_FLAG_SOFT_FLOAT; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_DEVICE_FP_CAPABILITY_FLAG_SOFT_FLOAT; } if (val != 0) { std::bitset<32> bits(val); @@ -4314,29 +4760,59 @@ inline void serializeFlag(std::ostream &os, os << "0"; } } -} // namespace ur_params +} // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, + enum ur_device_mem_cache_type_t value) { + switch (value) { + + case UR_DEVICE_MEM_CACHE_TYPE_NONE: + os << "UR_DEVICE_MEM_CACHE_TYPE_NONE"; + break; + + case UR_DEVICE_MEM_CACHE_TYPE_READ_ONLY_CACHE: + os << "UR_DEVICE_MEM_CACHE_TYPE_READ_ONLY_CACHE"; + break; + + case UR_DEVICE_MEM_CACHE_TYPE_READ_WRITE_CACHE: + os << "UR_DEVICE_MEM_CACHE_TYPE_READ_WRITE_CACHE"; + break; + default: + os << "unknown enumerator"; + break; + } + return os; +} inline std::ostream &operator<<(std::ostream &os, - enum ur_memory_scope_capability_flag_t value) { + enum ur_device_local_mem_type_t value) { switch (value) { - case UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_ITEM: - os << "UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_ITEM"; + case UR_DEVICE_LOCAL_MEM_TYPE_NONE: + os << "UR_DEVICE_LOCAL_MEM_TYPE_NONE"; break; - case UR_MEMORY_SCOPE_CAPABILITY_FLAG_SUB_GROUP: - os << "UR_MEMORY_SCOPE_CAPABILITY_FLAG_SUB_GROUP"; + case UR_DEVICE_LOCAL_MEM_TYPE_LOCAL: + os << "UR_DEVICE_LOCAL_MEM_TYPE_LOCAL"; break; - case UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP: - os << "UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP"; + case UR_DEVICE_LOCAL_MEM_TYPE_GLOBAL: + os << "UR_DEVICE_LOCAL_MEM_TYPE_GLOBAL"; + break; + default: + os << "unknown enumerator"; break; + } + return os; +} +inline std::ostream &operator<<(std::ostream &os, + enum ur_device_exec_capability_flag_t value) { + switch (value) { - case UR_MEMORY_SCOPE_CAPABILITY_FLAG_DEVICE: - os << "UR_MEMORY_SCOPE_CAPABILITY_FLAG_DEVICE"; + case UR_DEVICE_EXEC_CAPABILITY_FLAG_KERNEL: + os << "UR_DEVICE_EXEC_CAPABILITY_FLAG_KERNEL"; break; - case UR_MEMORY_SCOPE_CAPABILITY_FLAG_SYSTEM: - os << "UR_MEMORY_SCOPE_CAPABILITY_FLAG_SYSTEM"; + case UR_DEVICE_EXEC_CAPABILITY_FLAG_NATIVE_KERNEL: + os << "UR_DEVICE_EXEC_CAPABILITY_FLAG_NATIVE_KERNEL"; break; default: os << "unknown enumerator"; @@ -4347,64 +4823,31 @@ inline std::ostream &operator<<(std::ostream &os, namespace ur_params { template <> -inline void serializeFlag(std::ostream &os, - uint32_t flag) { +inline void serializeFlag(std::ostream &os, + uint32_t flag) { uint32_t val = flag; bool first = true; - if ((val & UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_ITEM) == - (uint32_t)UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_ITEM) { - val ^= (uint32_t)UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_ITEM; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_ITEM; - } - - if ((val & UR_MEMORY_SCOPE_CAPABILITY_FLAG_SUB_GROUP) == - (uint32_t)UR_MEMORY_SCOPE_CAPABILITY_FLAG_SUB_GROUP) { - val ^= (uint32_t)UR_MEMORY_SCOPE_CAPABILITY_FLAG_SUB_GROUP; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_MEMORY_SCOPE_CAPABILITY_FLAG_SUB_GROUP; - } - - if ((val & UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP) == - (uint32_t)UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP) { - val ^= (uint32_t)UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP; - } - - if ((val & UR_MEMORY_SCOPE_CAPABILITY_FLAG_DEVICE) == - (uint32_t)UR_MEMORY_SCOPE_CAPABILITY_FLAG_DEVICE) { - val ^= (uint32_t)UR_MEMORY_SCOPE_CAPABILITY_FLAG_DEVICE; + if ((val & UR_DEVICE_EXEC_CAPABILITY_FLAG_KERNEL) == + (uint32_t)UR_DEVICE_EXEC_CAPABILITY_FLAG_KERNEL) { + val ^= (uint32_t)UR_DEVICE_EXEC_CAPABILITY_FLAG_KERNEL; if (!first) { os << " | "; } else { first = false; } - os << UR_MEMORY_SCOPE_CAPABILITY_FLAG_DEVICE; + os << UR_DEVICE_EXEC_CAPABILITY_FLAG_KERNEL; } - if ((val & UR_MEMORY_SCOPE_CAPABILITY_FLAG_SYSTEM) == - (uint32_t)UR_MEMORY_SCOPE_CAPABILITY_FLAG_SYSTEM) { - val ^= (uint32_t)UR_MEMORY_SCOPE_CAPABILITY_FLAG_SYSTEM; + if ((val & UR_DEVICE_EXEC_CAPABILITY_FLAG_NATIVE_KERNEL) == + (uint32_t)UR_DEVICE_EXEC_CAPABILITY_FLAG_NATIVE_KERNEL) { + val ^= (uint32_t)UR_DEVICE_EXEC_CAPABILITY_FLAG_NATIVE_KERNEL; if (!first) { os << " | "; } else { first = false; } - os << UR_MEMORY_SCOPE_CAPABILITY_FLAG_SYSTEM; + os << UR_DEVICE_EXEC_CAPABILITY_FLAG_NATIVE_KERNEL; } if (val != 0) { std::bitset<32> bits(val); @@ -4419,23 +4862,48 @@ inline void serializeFlag(std::ostream &os, } // namespace ur_params inline std::ostream & operator<<(std::ostream &os, - enum ur_device_usm_access_capability_flag_t value) { + const struct ur_device_native_properties_t params) { + os << "(struct ur_device_native_properties_t){"; + + os << ".stype = "; + + os << (params.stype); + + os << ", "; + os << ".pNext = "; + + ur_params::serializeStruct(os, (params.pNext)); + + os << ", "; + os << ".isNativeHandleOwned = "; + + os << (params.isNativeHandleOwned); + + os << "}"; + return os; +} +inline std::ostream &operator<<(std::ostream &os, + enum ur_memory_order_capability_flag_t value) { switch (value) { - case UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ACCESS: - os << "UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ACCESS"; + case UR_MEMORY_ORDER_CAPABILITY_FLAG_RELAXED: + os << "UR_MEMORY_ORDER_CAPABILITY_FLAG_RELAXED"; break; - case UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ATOMIC_ACCESS: - os << "UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ATOMIC_ACCESS"; + case UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQUIRE: + os << "UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQUIRE"; break; - case UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_CONCURRENT_ACCESS: - os << "UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_CONCURRENT_ACCESS"; + case UR_MEMORY_ORDER_CAPABILITY_FLAG_RELEASE: + os << "UR_MEMORY_ORDER_CAPABILITY_FLAG_RELEASE"; break; - case UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ATOMIC_CONCURRENT_ACCESS: - os << "UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ATOMIC_CONCURRENT_ACCESS"; + case UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQ_REL: + os << "UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQ_REL"; + break; + + case UR_MEMORY_ORDER_CAPABILITY_FLAG_SEQ_CST: + os << "UR_MEMORY_ORDER_CAPABILITY_FLAG_SEQ_CST"; break; default: os << "unknown enumerator"; @@ -4446,96 +4914,64 @@ operator<<(std::ostream &os, namespace ur_params { template <> -inline void -serializeFlag(std::ostream &os, - uint32_t flag) { +inline void serializeFlag(std::ostream &os, + uint32_t flag) { uint32_t val = flag; bool first = true; - if ((val & UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ACCESS) == - (uint32_t)UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ACCESS) { - val ^= (uint32_t)UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ACCESS; + if ((val & UR_MEMORY_ORDER_CAPABILITY_FLAG_RELAXED) == + (uint32_t)UR_MEMORY_ORDER_CAPABILITY_FLAG_RELAXED) { + val ^= (uint32_t)UR_MEMORY_ORDER_CAPABILITY_FLAG_RELAXED; if (!first) { os << " | "; } else { first = false; } - os << UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ACCESS; + os << UR_MEMORY_ORDER_CAPABILITY_FLAG_RELAXED; } - if ((val & UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ATOMIC_ACCESS) == - (uint32_t)UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ATOMIC_ACCESS) { - val ^= (uint32_t)UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ATOMIC_ACCESS; + if ((val & UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQUIRE) == + (uint32_t)UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQUIRE) { + val ^= (uint32_t)UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQUIRE; if (!first) { os << " | "; } else { first = false; } - os << UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ATOMIC_ACCESS; + os << UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQUIRE; } - if ((val & UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_CONCURRENT_ACCESS) == - (uint32_t)UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_CONCURRENT_ACCESS) { - val ^= (uint32_t)UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_CONCURRENT_ACCESS; + if ((val & UR_MEMORY_ORDER_CAPABILITY_FLAG_RELEASE) == + (uint32_t)UR_MEMORY_ORDER_CAPABILITY_FLAG_RELEASE) { + val ^= (uint32_t)UR_MEMORY_ORDER_CAPABILITY_FLAG_RELEASE; if (!first) { os << " | "; } else { first = false; } - os << UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_CONCURRENT_ACCESS; + os << UR_MEMORY_ORDER_CAPABILITY_FLAG_RELEASE; } - if ((val & UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ATOMIC_CONCURRENT_ACCESS) == - (uint32_t) - UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ATOMIC_CONCURRENT_ACCESS) { - val ^= (uint32_t) - UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ATOMIC_CONCURRENT_ACCESS; + if ((val & UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQ_REL) == + (uint32_t)UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQ_REL) { + val ^= (uint32_t)UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQ_REL; if (!first) { os << " | "; } else { first = false; } - os << UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ATOMIC_CONCURRENT_ACCESS; - } - if (val != 0) { - std::bitset<32> bits(val); - if (!first) { - os << " | "; - } - os << "unknown bit flags " << bits; - } else if (first) { - os << "0"; - } -} -} // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, - enum ur_context_flag_t value) { - switch (value) { - - case UR_CONTEXT_FLAG_TBD: - os << "UR_CONTEXT_FLAG_TBD"; - break; - default: - os << "unknown enumerator"; - break; + os << UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQ_REL; } - return os; -} -namespace ur_params { - -template <> -inline void serializeFlag(std::ostream &os, uint32_t flag) { - uint32_t val = flag; - bool first = true; - if ((val & UR_CONTEXT_FLAG_TBD) == (uint32_t)UR_CONTEXT_FLAG_TBD) { - val ^= (uint32_t)UR_CONTEXT_FLAG_TBD; + if ((val & UR_MEMORY_ORDER_CAPABILITY_FLAG_SEQ_CST) == + (uint32_t)UR_MEMORY_ORDER_CAPABILITY_FLAG_SEQ_CST) { + val ^= (uint32_t)UR_MEMORY_ORDER_CAPABILITY_FLAG_SEQ_CST; if (!first) { os << " | "; } else { first = false; } - os << UR_CONTEXT_FLAG_TBD; + os << UR_MEMORY_ORDER_CAPABILITY_FLAG_SEQ_CST; } if (val != 0) { std::bitset<32> bits(val); @@ -4549,64 +4985,27 @@ inline void serializeFlag(std::ostream &os, uint32_t flag) { } } // namespace ur_params inline std::ostream &operator<<(std::ostream &os, - const struct ur_context_properties_t params) { - os << "(struct ur_context_properties_t){"; - - os << ".stype = "; - - os << (params.stype); - - os << ", "; - os << ".pNext = "; - - ur_params::serializeStruct(os, (params.pNext)); - - os << ", "; - os << ".flags = "; - - ur_params::serializeFlag(os, (params.flags)); - - os << "}"; - return os; -} -inline std::ostream &operator<<(std::ostream &os, - enum ur_context_info_t value) { + enum ur_memory_scope_capability_flag_t value) { switch (value) { - - case UR_CONTEXT_INFO_NUM_DEVICES: - os << "UR_CONTEXT_INFO_NUM_DEVICES"; - break; - - case UR_CONTEXT_INFO_DEVICES: - os << "UR_CONTEXT_INFO_DEVICES"; - break; - - case UR_CONTEXT_INFO_REFERENCE_COUNT: - os << "UR_CONTEXT_INFO_REFERENCE_COUNT"; - break; - - case UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT: - os << "UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT"; - break; - - case UR_CONTEXT_INFO_USM_FILL2D_SUPPORT: - os << "UR_CONTEXT_INFO_USM_FILL2D_SUPPORT"; + + case UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_ITEM: + os << "UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_ITEM"; break; - case UR_CONTEXT_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES: - os << "UR_CONTEXT_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES"; + case UR_MEMORY_SCOPE_CAPABILITY_FLAG_SUB_GROUP: + os << "UR_MEMORY_SCOPE_CAPABILITY_FLAG_SUB_GROUP"; break; - case UR_CONTEXT_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES: - os << "UR_CONTEXT_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES"; + case UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP: + os << "UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP"; break; - case UR_CONTEXT_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES: - os << "UR_CONTEXT_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES"; + case UR_MEMORY_SCOPE_CAPABILITY_FLAG_DEVICE: + os << "UR_MEMORY_SCOPE_CAPABILITY_FLAG_DEVICE"; break; - case UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES: - os << "UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES"; + case UR_MEMORY_SCOPE_CAPABILITY_FLAG_SYSTEM: + os << "UR_MEMORY_SCOPE_CAPABILITY_FLAG_SYSTEM"; break; default: os << "unknown enumerator"; @@ -4615,203 +5014,97 @@ inline std::ostream &operator<<(std::ostream &os, return os; } namespace ur_params { -template <> -inline void serializeTagged(std::ostream &os, const void *ptr, - ur_context_info_t value, size_t size) { - if (ptr == NULL) { - serializePtr(os, ptr); - return; - } - - switch (value) { - - case UR_CONTEXT_INFO_NUM_DEVICES: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; - - case UR_CONTEXT_INFO_DEVICES: { - - const ur_device_handle_t *tptr = (const ur_device_handle_t *)ptr; - os << "{"; - size_t nelems = size / sizeof(ur_device_handle_t); - for (size_t i = 0; i < nelems; ++i) { - if (i != 0) { - os << ", "; - } - - ur_params::serializePtr(os, tptr[i]); - } - os << "}"; - } break; - - case UR_CONTEXT_INFO_REFERENCE_COUNT: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - os << ")"; - } break; +template <> +inline void serializeFlag(std::ostream &os, + uint32_t flag) { + uint32_t val = flag; + bool first = true; - case UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT: { - const ur_bool_t *tptr = (const ur_bool_t *)ptr; - if (sizeof(ur_bool_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_bool_t) << ")"; - return; + if ((val & UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_ITEM) == + (uint32_t)UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_ITEM) { + val ^= (uint32_t)UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_ITEM; + if (!first) { + os << " | "; + } else { + first = false; } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; + os << UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_ITEM; + } - case UR_CONTEXT_INFO_USM_FILL2D_SUPPORT: { - const ur_bool_t *tptr = (const ur_bool_t *)ptr; - if (sizeof(ur_bool_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_bool_t) << ")"; - return; + if ((val & UR_MEMORY_SCOPE_CAPABILITY_FLAG_SUB_GROUP) == + (uint32_t)UR_MEMORY_SCOPE_CAPABILITY_FLAG_SUB_GROUP) { + val ^= (uint32_t)UR_MEMORY_SCOPE_CAPABILITY_FLAG_SUB_GROUP; + if (!first) { + os << " | "; + } else { + first = false; } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; + os << UR_MEMORY_SCOPE_CAPABILITY_FLAG_SUB_GROUP; + } - case UR_CONTEXT_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES: { - const ur_memory_order_capability_flags_t *tptr = - (const ur_memory_order_capability_flags_t *)ptr; - if (sizeof(ur_memory_order_capability_flags_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_memory_order_capability_flags_t) - << ")"; - return; + if ((val & UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP) == + (uint32_t)UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP) { + val ^= (uint32_t)UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP; + if (!first) { + os << " | "; + } else { + first = false; } - os << (void *)(tptr) << " ("; - - ur_params::serializeFlag(os, *tptr); - - os << ")"; - } break; + os << UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP; + } - case UR_CONTEXT_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES: { - const ur_memory_scope_capability_flags_t *tptr = - (const ur_memory_scope_capability_flags_t *)ptr; - if (sizeof(ur_memory_scope_capability_flags_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_memory_scope_capability_flags_t) - << ")"; - return; + if ((val & UR_MEMORY_SCOPE_CAPABILITY_FLAG_DEVICE) == + (uint32_t)UR_MEMORY_SCOPE_CAPABILITY_FLAG_DEVICE) { + val ^= (uint32_t)UR_MEMORY_SCOPE_CAPABILITY_FLAG_DEVICE; + if (!first) { + os << " | "; + } else { + first = false; } - os << (void *)(tptr) << " ("; - - ur_params::serializeFlag(os, *tptr); - - os << ")"; - } break; + os << UR_MEMORY_SCOPE_CAPABILITY_FLAG_DEVICE; + } - case UR_CONTEXT_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES: { - const ur_memory_order_capability_flags_t *tptr = - (const ur_memory_order_capability_flags_t *)ptr; - if (sizeof(ur_memory_order_capability_flags_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_memory_order_capability_flags_t) - << ")"; - return; + if ((val & UR_MEMORY_SCOPE_CAPABILITY_FLAG_SYSTEM) == + (uint32_t)UR_MEMORY_SCOPE_CAPABILITY_FLAG_SYSTEM) { + val ^= (uint32_t)UR_MEMORY_SCOPE_CAPABILITY_FLAG_SYSTEM; + if (!first) { + os << " | "; + } else { + first = false; } - os << (void *)(tptr) << " ("; - - ur_params::serializeFlag(os, *tptr); - - os << ")"; - } break; - - case UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES: { - const ur_memory_scope_capability_flags_t *tptr = - (const ur_memory_scope_capability_flags_t *)ptr; - if (sizeof(ur_memory_scope_capability_flags_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_memory_scope_capability_flags_t) - << ")"; - return; + os << UR_MEMORY_SCOPE_CAPABILITY_FLAG_SYSTEM; + } + if (val != 0) { + std::bitset<32> bits(val); + if (!first) { + os << " | "; } - os << (void *)(tptr) << " ("; - - ur_params::serializeFlag(os, *tptr); - - os << ")"; - } break; - default: - os << "unknown enumerator"; - break; + os << "unknown bit flags " << bits; + } else if (first) { + os << "0"; } } } // namespace ur_params inline std::ostream & operator<<(std::ostream &os, - const struct ur_context_native_properties_t params) { - os << "(struct ur_context_native_properties_t){"; - - os << ".stype = "; - - os << (params.stype); - - os << ", "; - os << ".pNext = "; - - ur_params::serializeStruct(os, (params.pNext)); - - os << ", "; - os << ".isNativeHandleOwned = "; - - os << (params.isNativeHandleOwned); - - os << "}"; - return os; -} -inline std::ostream &operator<<(std::ostream &os, enum ur_mem_flag_t value) { + enum ur_device_usm_access_capability_flag_t value) { switch (value) { - case UR_MEM_FLAG_READ_WRITE: - os << "UR_MEM_FLAG_READ_WRITE"; - break; - - case UR_MEM_FLAG_WRITE_ONLY: - os << "UR_MEM_FLAG_WRITE_ONLY"; - break; - - case UR_MEM_FLAG_READ_ONLY: - os << "UR_MEM_FLAG_READ_ONLY"; + case UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ACCESS: + os << "UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ACCESS"; break; - case UR_MEM_FLAG_USE_HOST_POINTER: - os << "UR_MEM_FLAG_USE_HOST_POINTER"; + case UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ATOMIC_ACCESS: + os << "UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ATOMIC_ACCESS"; break; - case UR_MEM_FLAG_ALLOC_HOST_POINTER: - os << "UR_MEM_FLAG_ALLOC_HOST_POINTER"; + case UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_CONCURRENT_ACCESS: + os << "UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_CONCURRENT_ACCESS"; break; - case UR_MEM_FLAG_ALLOC_COPY_HOST_POINTER: - os << "UR_MEM_FLAG_ALLOC_COPY_HOST_POINTER"; + case UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ATOMIC_CONCURRENT_ACCESS: + os << "UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ATOMIC_CONCURRENT_ACCESS"; break; default: os << "unknown enumerator"; @@ -4822,71 +5115,56 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_mem_flag_t value) { namespace ur_params { template <> -inline void serializeFlag(std::ostream &os, uint32_t flag) { +inline void +serializeFlag(std::ostream &os, + uint32_t flag) { uint32_t val = flag; bool first = true; - if ((val & UR_MEM_FLAG_READ_WRITE) == (uint32_t)UR_MEM_FLAG_READ_WRITE) { - val ^= (uint32_t)UR_MEM_FLAG_READ_WRITE; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_MEM_FLAG_READ_WRITE; - } - - if ((val & UR_MEM_FLAG_WRITE_ONLY) == (uint32_t)UR_MEM_FLAG_WRITE_ONLY) { - val ^= (uint32_t)UR_MEM_FLAG_WRITE_ONLY; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_MEM_FLAG_WRITE_ONLY; - } - - if ((val & UR_MEM_FLAG_READ_ONLY) == (uint32_t)UR_MEM_FLAG_READ_ONLY) { - val ^= (uint32_t)UR_MEM_FLAG_READ_ONLY; + if ((val & UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ACCESS) == + (uint32_t)UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ACCESS) { + val ^= (uint32_t)UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ACCESS; if (!first) { os << " | "; } else { first = false; } - os << UR_MEM_FLAG_READ_ONLY; + os << UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ACCESS; } - if ((val & UR_MEM_FLAG_USE_HOST_POINTER) == - (uint32_t)UR_MEM_FLAG_USE_HOST_POINTER) { - val ^= (uint32_t)UR_MEM_FLAG_USE_HOST_POINTER; + if ((val & UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ATOMIC_ACCESS) == + (uint32_t)UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ATOMIC_ACCESS) { + val ^= (uint32_t)UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ATOMIC_ACCESS; if (!first) { os << " | "; } else { first = false; } - os << UR_MEM_FLAG_USE_HOST_POINTER; + os << UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ATOMIC_ACCESS; } - if ((val & UR_MEM_FLAG_ALLOC_HOST_POINTER) == - (uint32_t)UR_MEM_FLAG_ALLOC_HOST_POINTER) { - val ^= (uint32_t)UR_MEM_FLAG_ALLOC_HOST_POINTER; + if ((val & UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_CONCURRENT_ACCESS) == + (uint32_t)UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_CONCURRENT_ACCESS) { + val ^= (uint32_t)UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_CONCURRENT_ACCESS; if (!first) { os << " | "; } else { first = false; } - os << UR_MEM_FLAG_ALLOC_HOST_POINTER; + os << UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_CONCURRENT_ACCESS; } - if ((val & UR_MEM_FLAG_ALLOC_COPY_HOST_POINTER) == - (uint32_t)UR_MEM_FLAG_ALLOC_COPY_HOST_POINTER) { - val ^= (uint32_t)UR_MEM_FLAG_ALLOC_COPY_HOST_POINTER; + if ((val & UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ATOMIC_CONCURRENT_ACCESS) == + (uint32_t) + UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ATOMIC_CONCURRENT_ACCESS) { + val ^= (uint32_t) + UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ATOMIC_CONCURRENT_ACCESS; if (!first) { os << " | "; } else { first = false; } - os << UR_MEM_FLAG_ALLOC_COPY_HOST_POINTER; + os << UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ATOMIC_CONCURRENT_ACCESS; } if (val != 0) { std::bitset<32> bits(val); @@ -4899,51 +5177,12 @@ inline void serializeFlag(std::ostream &os, uint32_t flag) { } } } // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, enum ur_mem_type_t value) { - switch (value) { - - case UR_MEM_TYPE_BUFFER: - os << "UR_MEM_TYPE_BUFFER"; - break; - - case UR_MEM_TYPE_IMAGE2D: - os << "UR_MEM_TYPE_IMAGE2D"; - break; - - case UR_MEM_TYPE_IMAGE3D: - os << "UR_MEM_TYPE_IMAGE3D"; - break; - - case UR_MEM_TYPE_IMAGE2D_ARRAY: - os << "UR_MEM_TYPE_IMAGE2D_ARRAY"; - break; - - case UR_MEM_TYPE_IMAGE1D: - os << "UR_MEM_TYPE_IMAGE1D"; - break; - - case UR_MEM_TYPE_IMAGE1D_ARRAY: - os << "UR_MEM_TYPE_IMAGE1D_ARRAY"; - break; - - case UR_MEM_TYPE_IMAGE1D_BUFFER: - os << "UR_MEM_TYPE_IMAGE1D_BUFFER"; - break; - default: - os << "unknown enumerator"; - break; - } - return os; -} -inline std::ostream &operator<<(std::ostream &os, enum ur_mem_info_t value) { +inline std::ostream &operator<<(std::ostream &os, + enum ur_context_flag_t value) { switch (value) { - case UR_MEM_INFO_SIZE: - os << "UR_MEM_INFO_SIZE"; - break; - - case UR_MEM_INFO_CONTEXT: - os << "UR_MEM_INFO_CONTEXT"; + case UR_CONTEXT_FLAG_TBD: + os << "UR_CONTEXT_FLAG_TBD"; break; default: os << "unknown enumerator"; @@ -4952,216 +5191,91 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_mem_info_t value) { return os; } namespace ur_params { -template <> -inline void serializeTagged(std::ostream &os, const void *ptr, - ur_mem_info_t value, size_t size) { - if (ptr == NULL) { - serializePtr(os, ptr); - return; - } - switch (value) { - - case UR_MEM_INFO_SIZE: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; +template <> +inline void serializeFlag(std::ostream &os, uint32_t flag) { + uint32_t val = flag; + bool first = true; - case UR_MEM_INFO_CONTEXT: { - const ur_context_handle_t *tptr = (const ur_context_handle_t *)ptr; - if (sizeof(ur_context_handle_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_context_handle_t) << ")"; - return; + if ((val & UR_CONTEXT_FLAG_TBD) == (uint32_t)UR_CONTEXT_FLAG_TBD) { + val ^= (uint32_t)UR_CONTEXT_FLAG_TBD; + if (!first) { + os << " | "; + } else { + first = false; } - os << (void *)(tptr) << " ("; - - ur_params::serializePtr(os, *tptr); - - os << ")"; - } break; - default: - os << "unknown enumerator"; - break; - } -} -} // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, - enum ur_image_channel_order_t value) { - switch (value) { - - case UR_IMAGE_CHANNEL_ORDER_A: - os << "UR_IMAGE_CHANNEL_ORDER_A"; - break; - - case UR_IMAGE_CHANNEL_ORDER_R: - os << "UR_IMAGE_CHANNEL_ORDER_R"; - break; - - case UR_IMAGE_CHANNEL_ORDER_RG: - os << "UR_IMAGE_CHANNEL_ORDER_RG"; - break; - - case UR_IMAGE_CHANNEL_ORDER_RA: - os << "UR_IMAGE_CHANNEL_ORDER_RA"; - break; - - case UR_IMAGE_CHANNEL_ORDER_RGB: - os << "UR_IMAGE_CHANNEL_ORDER_RGB"; - break; - - case UR_IMAGE_CHANNEL_ORDER_RGBA: - os << "UR_IMAGE_CHANNEL_ORDER_RGBA"; - break; - - case UR_IMAGE_CHANNEL_ORDER_BGRA: - os << "UR_IMAGE_CHANNEL_ORDER_BGRA"; - break; - - case UR_IMAGE_CHANNEL_ORDER_ARGB: - os << "UR_IMAGE_CHANNEL_ORDER_ARGB"; - break; - - case UR_IMAGE_CHANNEL_ORDER_ABGR: - os << "UR_IMAGE_CHANNEL_ORDER_ABGR"; - break; - - case UR_IMAGE_CHANNEL_ORDER_INTENSITY: - os << "UR_IMAGE_CHANNEL_ORDER_INTENSITY"; - break; - - case UR_IMAGE_CHANNEL_ORDER_LUMINANCE: - os << "UR_IMAGE_CHANNEL_ORDER_LUMINANCE"; - break; - - case UR_IMAGE_CHANNEL_ORDER_RX: - os << "UR_IMAGE_CHANNEL_ORDER_RX"; - break; - - case UR_IMAGE_CHANNEL_ORDER_RGX: - os << "UR_IMAGE_CHANNEL_ORDER_RGX"; - break; - - case UR_IMAGE_CHANNEL_ORDER_RGBX: - os << "UR_IMAGE_CHANNEL_ORDER_RGBX"; - break; - - case UR_IMAGE_CHANNEL_ORDER_SRGBA: - os << "UR_IMAGE_CHANNEL_ORDER_SRGBA"; - break; - default: - os << "unknown enumerator"; - break; + os << UR_CONTEXT_FLAG_TBD; } - return os; -} -inline std::ostream &operator<<(std::ostream &os, - enum ur_image_channel_type_t value) { - switch (value) { - - case UR_IMAGE_CHANNEL_TYPE_SNORM_INT8: - os << "UR_IMAGE_CHANNEL_TYPE_SNORM_INT8"; - break; - - case UR_IMAGE_CHANNEL_TYPE_SNORM_INT16: - os << "UR_IMAGE_CHANNEL_TYPE_SNORM_INT16"; - break; - - case UR_IMAGE_CHANNEL_TYPE_UNORM_INT8: - os << "UR_IMAGE_CHANNEL_TYPE_UNORM_INT8"; - break; - - case UR_IMAGE_CHANNEL_TYPE_UNORM_INT16: - os << "UR_IMAGE_CHANNEL_TYPE_UNORM_INT16"; - break; - - case UR_IMAGE_CHANNEL_TYPE_UNORM_SHORT_565: - os << "UR_IMAGE_CHANNEL_TYPE_UNORM_SHORT_565"; - break; - - case UR_IMAGE_CHANNEL_TYPE_UNORM_SHORT_555: - os << "UR_IMAGE_CHANNEL_TYPE_UNORM_SHORT_555"; - break; + if (val != 0) { + std::bitset<32> bits(val); + if (!first) { + os << " | "; + } + os << "unknown bit flags " << bits; + } else if (first) { + os << "0"; + } +} +} // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, + const struct ur_context_properties_t params) { + os << "(struct ur_context_properties_t){"; - case UR_IMAGE_CHANNEL_TYPE_INT_101010: - os << "UR_IMAGE_CHANNEL_TYPE_INT_101010"; - break; + os << ".stype = "; - case UR_IMAGE_CHANNEL_TYPE_SIGNED_INT8: - os << "UR_IMAGE_CHANNEL_TYPE_SIGNED_INT8"; - break; + os << (params.stype); - case UR_IMAGE_CHANNEL_TYPE_SIGNED_INT16: - os << "UR_IMAGE_CHANNEL_TYPE_SIGNED_INT16"; - break; + os << ", "; + os << ".pNext = "; - case UR_IMAGE_CHANNEL_TYPE_SIGNED_INT32: - os << "UR_IMAGE_CHANNEL_TYPE_SIGNED_INT32"; - break; + ur_params::serializeStruct(os, (params.pNext)); - case UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT8: - os << "UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT8"; - break; + os << ", "; + os << ".flags = "; - case UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT16: - os << "UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT16"; - break; + ur_params::serializeFlag(os, (params.flags)); - case UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT32: - os << "UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT32"; - break; + os << "}"; + return os; +} +inline std::ostream &operator<<(std::ostream &os, + enum ur_context_info_t value) { + switch (value) { - case UR_IMAGE_CHANNEL_TYPE_HALF_FLOAT: - os << "UR_IMAGE_CHANNEL_TYPE_HALF_FLOAT"; + case UR_CONTEXT_INFO_NUM_DEVICES: + os << "UR_CONTEXT_INFO_NUM_DEVICES"; break; - case UR_IMAGE_CHANNEL_TYPE_FLOAT: - os << "UR_IMAGE_CHANNEL_TYPE_FLOAT"; - break; - default: - os << "unknown enumerator"; + case UR_CONTEXT_INFO_DEVICES: + os << "UR_CONTEXT_INFO_DEVICES"; break; - } - return os; -} -inline std::ostream &operator<<(std::ostream &os, enum ur_image_info_t value) { - switch (value) { - case UR_IMAGE_INFO_FORMAT: - os << "UR_IMAGE_INFO_FORMAT"; + case UR_CONTEXT_INFO_REFERENCE_COUNT: + os << "UR_CONTEXT_INFO_REFERENCE_COUNT"; break; - case UR_IMAGE_INFO_ELEMENT_SIZE: - os << "UR_IMAGE_INFO_ELEMENT_SIZE"; + case UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT: + os << "UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT"; break; - case UR_IMAGE_INFO_ROW_PITCH: - os << "UR_IMAGE_INFO_ROW_PITCH"; + case UR_CONTEXT_INFO_USM_FILL2D_SUPPORT: + os << "UR_CONTEXT_INFO_USM_FILL2D_SUPPORT"; break; - case UR_IMAGE_INFO_SLICE_PITCH: - os << "UR_IMAGE_INFO_SLICE_PITCH"; + case UR_CONTEXT_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES: + os << "UR_CONTEXT_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES"; break; - case UR_IMAGE_INFO_WIDTH: - os << "UR_IMAGE_INFO_WIDTH"; + case UR_CONTEXT_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES: + os << "UR_CONTEXT_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES"; break; - case UR_IMAGE_INFO_HEIGHT: - os << "UR_IMAGE_INFO_HEIGHT"; + case UR_CONTEXT_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES: + os << "UR_CONTEXT_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES"; break; - case UR_IMAGE_INFO_DEPTH: - os << "UR_IMAGE_INFO_DEPTH"; + case UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES: + os << "UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES"; break; default: os << "unknown enumerator"; @@ -5172,7 +5286,7 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_image_info_t value) { namespace ur_params { template <> inline void serializeTagged(std::ostream &os, const void *ptr, - ur_image_info_t value, size_t size) { + ur_context_info_t value, size_t size) { if (ptr == NULL) { serializePtr(os, ptr); return; @@ -5180,67 +5294,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, switch (value) { - case UR_IMAGE_INFO_FORMAT: { - const ur_image_format_t *tptr = (const ur_image_format_t *)ptr; - if (sizeof(ur_image_format_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_image_format_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; - - case UR_IMAGE_INFO_ELEMENT_SIZE: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; - - case UR_IMAGE_INFO_ROW_PITCH: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; - - case UR_IMAGE_INFO_SLICE_PITCH: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; - - case UR_IMAGE_INFO_WIDTH: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { + case UR_CONTEXT_INFO_NUM_DEVICES: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; + << ", expected: >=" << sizeof(uint32_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -5250,163 +5308,136 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_IMAGE_INFO_HEIGHT: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; + case UR_CONTEXT_INFO_DEVICES: { - os << ")"; - } break; + const ur_device_handle_t *tptr = (const ur_device_handle_t *)ptr; + os << "{"; + size_t nelems = size / sizeof(ur_device_handle_t); + for (size_t i = 0; i < nelems; ++i) { + if (i != 0) { + os << ", "; + } - case UR_IMAGE_INFO_DEPTH: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; + ur_params::serializePtr(os, tptr[i]); } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; + os << "}"; } break; - default: - os << "unknown enumerator"; - break; - } -} -} // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, - const struct ur_image_format_t params) { - os << "(struct ur_image_format_t){"; - - os << ".channelOrder = "; - - os << (params.channelOrder); - - os << ", "; - os << ".channelType = "; - - os << (params.channelType); - - os << "}"; - return os; -} -inline std::ostream &operator<<(std::ostream &os, - const struct ur_image_desc_t params) { - os << "(struct ur_image_desc_t){"; - - os << ".stype = "; - - os << (params.stype); - - os << ", "; - os << ".pNext = "; - - ur_params::serializeStruct(os, (params.pNext)); - - os << ", "; - os << ".type = "; - os << (params.type); - - os << ", "; - os << ".width = "; - - os << (params.width); - - os << ", "; - os << ".height = "; - - os << (params.height); - - os << ", "; - os << ".depth = "; - - os << (params.depth); - - os << ", "; - os << ".arraySize = "; - - os << (params.arraySize); - - os << ", "; - os << ".rowPitch = "; - - os << (params.rowPitch); - - os << ", "; - os << ".slicePitch = "; + case UR_CONTEXT_INFO_REFERENCE_COUNT: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - os << (params.slicePitch); + os << *tptr; - os << ", "; - os << ".numMipLevel = "; + os << ")"; + } break; - os << (params.numMipLevel); + case UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_bool_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - os << ", "; - os << ".numSamples = "; + os << *tptr; - os << (params.numSamples); + os << ")"; + } break; - os << "}"; - return os; -} -inline std::ostream &operator<<(std::ostream &os, - const struct ur_buffer_properties_t params) { - os << "(struct ur_buffer_properties_t){"; + case UR_CONTEXT_INFO_USM_FILL2D_SUPPORT: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_bool_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - os << ".stype = "; + os << *tptr; - os << (params.stype); + os << ")"; + } break; - os << ", "; - os << ".pNext = "; + case UR_CONTEXT_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES: { + const ur_memory_order_capability_flags_t *tptr = + (const ur_memory_order_capability_flags_t *)ptr; + if (sizeof(ur_memory_order_capability_flags_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_memory_order_capability_flags_t) + << ")"; + return; + } + os << (void *)(tptr) << " ("; - ur_params::serializeStruct(os, (params.pNext)); + ur_params::serializeFlag(os, *tptr); - os << ", "; - os << ".pHost = "; + os << ")"; + } break; - ur_params::serializePtr(os, (params.pHost)); + case UR_CONTEXT_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES: { + const ur_memory_scope_capability_flags_t *tptr = + (const ur_memory_scope_capability_flags_t *)ptr; + if (sizeof(ur_memory_scope_capability_flags_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_memory_scope_capability_flags_t) + << ")"; + return; + } + os << (void *)(tptr) << " ("; - os << "}"; - return os; -} -inline std::ostream & -operator<<(std::ostream &os, - const struct ur_buffer_channel_properties_t params) { - os << "(struct ur_buffer_channel_properties_t){"; + ur_params::serializeFlag(os, *tptr); - os << ".stype = "; + os << ")"; + } break; - os << (params.stype); + case UR_CONTEXT_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES: { + const ur_memory_order_capability_flags_t *tptr = + (const ur_memory_order_capability_flags_t *)ptr; + if (sizeof(ur_memory_order_capability_flags_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_memory_order_capability_flags_t) + << ")"; + return; + } + os << (void *)(tptr) << " ("; - os << ", "; - os << ".pNext = "; + ur_params::serializeFlag(os, *tptr); - ur_params::serializeStruct(os, (params.pNext)); + os << ")"; + } break; - os << ", "; - os << ".channel = "; + case UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES: { + const ur_memory_scope_capability_flags_t *tptr = + (const ur_memory_scope_capability_flags_t *)ptr; + if (sizeof(ur_memory_scope_capability_flags_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_memory_scope_capability_flags_t) + << ")"; + return; + } + os << (void *)(tptr) << " ("; - os << (params.channel); + ur_params::serializeFlag(os, *tptr); - os << "}"; - return os; + os << ")"; + } break; + default: + os << "unknown enumerator"; + break; + } } +} // namespace ur_params inline std::ostream & operator<<(std::ostream &os, - const struct ur_buffer_alloc_location_properties_t params) { - os << "(struct ur_buffer_alloc_location_properties_t){"; + const struct ur_context_native_properties_t params) { + os << "(struct ur_context_native_properties_t){"; os << ".stype = "; @@ -5418,45 +5449,38 @@ operator<<(std::ostream &os, ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".location = "; + os << ".isNativeHandleOwned = "; - os << (params.location); + os << (params.isNativeHandleOwned); os << "}"; return os; } -inline std::ostream &operator<<(std::ostream &os, - const struct ur_buffer_region_t params) { - os << "(struct ur_buffer_region_t){"; - - os << ".stype = "; - - os << (params.stype); - - os << ", "; - os << ".pNext = "; - - ur_params::serializeStruct(os, (params.pNext)); +inline std::ostream &operator<<(std::ostream &os, enum ur_mem_flag_t value) { + switch (value) { - os << ", "; - os << ".origin = "; + case UR_MEM_FLAG_READ_WRITE: + os << "UR_MEM_FLAG_READ_WRITE"; + break; - os << (params.origin); + case UR_MEM_FLAG_WRITE_ONLY: + os << "UR_MEM_FLAG_WRITE_ONLY"; + break; - os << ", "; - os << ".size = "; + case UR_MEM_FLAG_READ_ONLY: + os << "UR_MEM_FLAG_READ_ONLY"; + break; - os << (params.size); + case UR_MEM_FLAG_USE_HOST_POINTER: + os << "UR_MEM_FLAG_USE_HOST_POINTER"; + break; - os << "}"; - return os; -} -inline std::ostream &operator<<(std::ostream &os, - enum ur_buffer_create_type_t value) { - switch (value) { + case UR_MEM_FLAG_ALLOC_HOST_POINTER: + os << "UR_MEM_FLAG_ALLOC_HOST_POINTER"; + break; - case UR_BUFFER_CREATE_TYPE_REGION: - os << "UR_BUFFER_CREATE_TYPE_REGION"; + case UR_MEM_FLAG_ALLOC_COPY_HOST_POINTER: + os << "UR_MEM_FLAG_ALLOC_COPY_HOST_POINTER"; break; default: os << "unknown enumerator"; @@ -5464,66 +5488,115 @@ inline std::ostream &operator<<(std::ostream &os, } return os; } -inline std::ostream & -operator<<(std::ostream &os, const struct ur_mem_native_properties_t params) { - os << "(struct ur_mem_native_properties_t){"; +namespace ur_params { - os << ".stype = "; +template <> +inline void serializeFlag(std::ostream &os, uint32_t flag) { + uint32_t val = flag; + bool first = true; - os << (params.stype); + if ((val & UR_MEM_FLAG_READ_WRITE) == (uint32_t)UR_MEM_FLAG_READ_WRITE) { + val ^= (uint32_t)UR_MEM_FLAG_READ_WRITE; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_MEM_FLAG_READ_WRITE; + } - os << ", "; - os << ".pNext = "; + if ((val & UR_MEM_FLAG_WRITE_ONLY) == (uint32_t)UR_MEM_FLAG_WRITE_ONLY) { + val ^= (uint32_t)UR_MEM_FLAG_WRITE_ONLY; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_MEM_FLAG_WRITE_ONLY; + } - ur_params::serializeStruct(os, (params.pNext)); + if ((val & UR_MEM_FLAG_READ_ONLY) == (uint32_t)UR_MEM_FLAG_READ_ONLY) { + val ^= (uint32_t)UR_MEM_FLAG_READ_ONLY; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_MEM_FLAG_READ_ONLY; + } - os << ", "; - os << ".isNativeHandleOwned = "; + if ((val & UR_MEM_FLAG_USE_HOST_POINTER) == + (uint32_t)UR_MEM_FLAG_USE_HOST_POINTER) { + val ^= (uint32_t)UR_MEM_FLAG_USE_HOST_POINTER; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_MEM_FLAG_USE_HOST_POINTER; + } - os << (params.isNativeHandleOwned); + if ((val & UR_MEM_FLAG_ALLOC_HOST_POINTER) == + (uint32_t)UR_MEM_FLAG_ALLOC_HOST_POINTER) { + val ^= (uint32_t)UR_MEM_FLAG_ALLOC_HOST_POINTER; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_MEM_FLAG_ALLOC_HOST_POINTER; + } - os << "}"; - return os; + if ((val & UR_MEM_FLAG_ALLOC_COPY_HOST_POINTER) == + (uint32_t)UR_MEM_FLAG_ALLOC_COPY_HOST_POINTER) { + val ^= (uint32_t)UR_MEM_FLAG_ALLOC_COPY_HOST_POINTER; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_MEM_FLAG_ALLOC_COPY_HOST_POINTER; + } + if (val != 0) { + std::bitset<32> bits(val); + if (!first) { + os << " | "; + } + os << "unknown bit flags " << bits; + } else if (first) { + os << "0"; + } } -inline std::ostream &operator<<(std::ostream &os, - enum ur_sampler_filter_mode_t value) { +} // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, enum ur_mem_type_t value) { switch (value) { - case UR_SAMPLER_FILTER_MODE_NEAREST: - os << "UR_SAMPLER_FILTER_MODE_NEAREST"; + case UR_MEM_TYPE_BUFFER: + os << "UR_MEM_TYPE_BUFFER"; break; - case UR_SAMPLER_FILTER_MODE_LINEAR: - os << "UR_SAMPLER_FILTER_MODE_LINEAR"; - break; - default: - os << "unknown enumerator"; + case UR_MEM_TYPE_IMAGE2D: + os << "UR_MEM_TYPE_IMAGE2D"; break; - } - return os; -} -inline std::ostream &operator<<(std::ostream &os, - enum ur_sampler_addressing_mode_t value) { - switch (value) { - case UR_SAMPLER_ADDRESSING_MODE_NONE: - os << "UR_SAMPLER_ADDRESSING_MODE_NONE"; + case UR_MEM_TYPE_IMAGE3D: + os << "UR_MEM_TYPE_IMAGE3D"; break; - case UR_SAMPLER_ADDRESSING_MODE_CLAMP_TO_EDGE: - os << "UR_SAMPLER_ADDRESSING_MODE_CLAMP_TO_EDGE"; + case UR_MEM_TYPE_IMAGE2D_ARRAY: + os << "UR_MEM_TYPE_IMAGE2D_ARRAY"; break; - case UR_SAMPLER_ADDRESSING_MODE_CLAMP: - os << "UR_SAMPLER_ADDRESSING_MODE_CLAMP"; + case UR_MEM_TYPE_IMAGE1D: + os << "UR_MEM_TYPE_IMAGE1D"; break; - case UR_SAMPLER_ADDRESSING_MODE_REPEAT: - os << "UR_SAMPLER_ADDRESSING_MODE_REPEAT"; + case UR_MEM_TYPE_IMAGE1D_ARRAY: + os << "UR_MEM_TYPE_IMAGE1D_ARRAY"; break; - case UR_SAMPLER_ADDRESSING_MODE_MIRRORED_REPEAT: - os << "UR_SAMPLER_ADDRESSING_MODE_MIRRORED_REPEAT"; + case UR_MEM_TYPE_IMAGE1D_BUFFER: + os << "UR_MEM_TYPE_IMAGE1D_BUFFER"; break; default: os << "unknown enumerator"; @@ -5531,28 +5604,15 @@ inline std::ostream &operator<<(std::ostream &os, } return os; } -inline std::ostream &operator<<(std::ostream &os, - enum ur_sampler_info_t value) { +inline std::ostream &operator<<(std::ostream &os, enum ur_mem_info_t value) { switch (value) { - case UR_SAMPLER_INFO_REFERENCE_COUNT: - os << "UR_SAMPLER_INFO_REFERENCE_COUNT"; - break; - - case UR_SAMPLER_INFO_CONTEXT: - os << "UR_SAMPLER_INFO_CONTEXT"; - break; - - case UR_SAMPLER_INFO_NORMALIZED_COORDS: - os << "UR_SAMPLER_INFO_NORMALIZED_COORDS"; - break; - - case UR_SAMPLER_INFO_ADDRESSING_MODE: - os << "UR_SAMPLER_INFO_ADDRESSING_MODE"; + case UR_MEM_INFO_SIZE: + os << "UR_MEM_INFO_SIZE"; break; - case UR_SAMPLER_INFO_FILTER_MODE: - os << "UR_SAMPLER_INFO_FILTER_MODE"; + case UR_MEM_INFO_CONTEXT: + os << "UR_MEM_INFO_CONTEXT"; break; default: os << "unknown enumerator"; @@ -5563,7 +5623,7 @@ inline std::ostream &operator<<(std::ostream &os, namespace ur_params { template <> inline void serializeTagged(std::ostream &os, const void *ptr, - ur_sampler_info_t value, size_t size) { + ur_mem_info_t value, size_t size) { if (ptr == NULL) { serializePtr(os, ptr); return; @@ -5571,11 +5631,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, switch (value) { - case UR_SAMPLER_INFO_REFERENCE_COUNT: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { + case UR_MEM_INFO_SIZE: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; + << ", expected: >=" << sizeof(size_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -5585,7 +5645,7 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_SAMPLER_INFO_CONTEXT: { + case UR_MEM_INFO_CONTEXT: { const ur_context_handle_t *tptr = (const ur_context_handle_t *)ptr; if (sizeof(ur_context_handle_t) > size) { os << "invalid size (is: " << size @@ -5598,51 +5658,6 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - - case UR_SAMPLER_INFO_NORMALIZED_COORDS: { - const ur_bool_t *tptr = (const ur_bool_t *)ptr; - if (sizeof(ur_bool_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_bool_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; - - case UR_SAMPLER_INFO_ADDRESSING_MODE: { - const ur_sampler_addressing_mode_t *tptr = - (const ur_sampler_addressing_mode_t *)ptr; - if (sizeof(ur_sampler_addressing_mode_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_sampler_addressing_mode_t) - << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; - - case UR_SAMPLER_INFO_FILTER_MODE: { - const ur_sampler_filter_mode_t *tptr = - (const ur_sampler_filter_mode_t *)ptr; - if (sizeof(ur_sampler_filter_mode_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_sampler_filter_mode_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; default: os << "unknown enumerator"; break; @@ -5650,114 +5665,67 @@ inline void serializeTagged(std::ostream &os, const void *ptr, } } // namespace ur_params inline std::ostream &operator<<(std::ostream &os, - const struct ur_sampler_desc_t params) { - os << "(struct ur_sampler_desc_t){"; - - os << ".stype = "; - - os << (params.stype); - - os << ", "; - os << ".pNext = "; - - ur_params::serializeStruct(os, (params.pNext)); - - os << ", "; - os << ".normalizedCoords = "; - - os << (params.normalizedCoords); - - os << ", "; - os << ".addressingMode = "; - - os << (params.addressingMode); - - os << ", "; - os << ".filterMode = "; - - os << (params.filterMode); + enum ur_image_channel_order_t value) { + switch (value) { - os << "}"; - return os; -} -inline std::ostream & -operator<<(std::ostream &os, - const struct ur_sampler_native_properties_t params) { - os << "(struct ur_sampler_native_properties_t){"; + case UR_IMAGE_CHANNEL_ORDER_A: + os << "UR_IMAGE_CHANNEL_ORDER_A"; + break; - os << ".stype = "; + case UR_IMAGE_CHANNEL_ORDER_R: + os << "UR_IMAGE_CHANNEL_ORDER_R"; + break; - os << (params.stype); + case UR_IMAGE_CHANNEL_ORDER_RG: + os << "UR_IMAGE_CHANNEL_ORDER_RG"; + break; - os << ", "; - os << ".pNext = "; + case UR_IMAGE_CHANNEL_ORDER_RA: + os << "UR_IMAGE_CHANNEL_ORDER_RA"; + break; - ur_params::serializeStruct(os, (params.pNext)); + case UR_IMAGE_CHANNEL_ORDER_RGB: + os << "UR_IMAGE_CHANNEL_ORDER_RGB"; + break; - os << ", "; - os << ".isNativeHandleOwned = "; + case UR_IMAGE_CHANNEL_ORDER_RGBA: + os << "UR_IMAGE_CHANNEL_ORDER_RGBA"; + break; - os << (params.isNativeHandleOwned); + case UR_IMAGE_CHANNEL_ORDER_BGRA: + os << "UR_IMAGE_CHANNEL_ORDER_BGRA"; + break; - os << "}"; - return os; -} -inline std::ostream &operator<<(std::ostream &os, - enum ur_usm_host_mem_flag_t value) { - switch (value) { + case UR_IMAGE_CHANNEL_ORDER_ARGB: + os << "UR_IMAGE_CHANNEL_ORDER_ARGB"; + break; - case UR_USM_HOST_MEM_FLAG_INITIAL_PLACEMENT: - os << "UR_USM_HOST_MEM_FLAG_INITIAL_PLACEMENT"; + case UR_IMAGE_CHANNEL_ORDER_ABGR: + os << "UR_IMAGE_CHANNEL_ORDER_ABGR"; break; - default: - os << "unknown enumerator"; + + case UR_IMAGE_CHANNEL_ORDER_INTENSITY: + os << "UR_IMAGE_CHANNEL_ORDER_INTENSITY"; break; - } - return os; -} -namespace ur_params { -template <> -inline void serializeFlag(std::ostream &os, - uint32_t flag) { - uint32_t val = flag; - bool first = true; + case UR_IMAGE_CHANNEL_ORDER_LUMINANCE: + os << "UR_IMAGE_CHANNEL_ORDER_LUMINANCE"; + break; - if ((val & UR_USM_HOST_MEM_FLAG_INITIAL_PLACEMENT) == - (uint32_t)UR_USM_HOST_MEM_FLAG_INITIAL_PLACEMENT) { - val ^= (uint32_t)UR_USM_HOST_MEM_FLAG_INITIAL_PLACEMENT; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_HOST_MEM_FLAG_INITIAL_PLACEMENT; - } - if (val != 0) { - std::bitset<32> bits(val); - if (!first) { - os << " | "; - } - os << "unknown bit flags " << bits; - } else if (first) { - os << "0"; - } -} -} // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, - enum ur_usm_device_mem_flag_t value) { - switch (value) { + case UR_IMAGE_CHANNEL_ORDER_RX: + os << "UR_IMAGE_CHANNEL_ORDER_RX"; + break; - case UR_USM_DEVICE_MEM_FLAG_WRITE_COMBINED: - os << "UR_USM_DEVICE_MEM_FLAG_WRITE_COMBINED"; + case UR_IMAGE_CHANNEL_ORDER_RGX: + os << "UR_IMAGE_CHANNEL_ORDER_RGX"; break; - case UR_USM_DEVICE_MEM_FLAG_INITIAL_PLACEMENT: - os << "UR_USM_DEVICE_MEM_FLAG_INITIAL_PLACEMENT"; + case UR_IMAGE_CHANNEL_ORDER_RGBX: + os << "UR_IMAGE_CHANNEL_ORDER_RGBX"; break; - case UR_USM_DEVICE_MEM_FLAG_DEVICE_READ_ONLY: - os << "UR_USM_DEVICE_MEM_FLAG_DEVICE_READ_ONLY"; + case UR_IMAGE_CHANNEL_ORDER_SRGBA: + os << "UR_IMAGE_CHANNEL_ORDER_SRGBA"; break; default: os << "unknown enumerator"; @@ -5765,115 +5733,68 @@ inline std::ostream &operator<<(std::ostream &os, } return os; } -namespace ur_params { +inline std::ostream &operator<<(std::ostream &os, + enum ur_image_channel_type_t value) { + switch (value) { -template <> -inline void serializeFlag(std::ostream &os, - uint32_t flag) { - uint32_t val = flag; - bool first = true; + case UR_IMAGE_CHANNEL_TYPE_SNORM_INT8: + os << "UR_IMAGE_CHANNEL_TYPE_SNORM_INT8"; + break; - if ((val & UR_USM_DEVICE_MEM_FLAG_WRITE_COMBINED) == - (uint32_t)UR_USM_DEVICE_MEM_FLAG_WRITE_COMBINED) { - val ^= (uint32_t)UR_USM_DEVICE_MEM_FLAG_WRITE_COMBINED; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_DEVICE_MEM_FLAG_WRITE_COMBINED; - } + case UR_IMAGE_CHANNEL_TYPE_SNORM_INT16: + os << "UR_IMAGE_CHANNEL_TYPE_SNORM_INT16"; + break; - if ((val & UR_USM_DEVICE_MEM_FLAG_INITIAL_PLACEMENT) == - (uint32_t)UR_USM_DEVICE_MEM_FLAG_INITIAL_PLACEMENT) { - val ^= (uint32_t)UR_USM_DEVICE_MEM_FLAG_INITIAL_PLACEMENT; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_DEVICE_MEM_FLAG_INITIAL_PLACEMENT; - } + case UR_IMAGE_CHANNEL_TYPE_UNORM_INT8: + os << "UR_IMAGE_CHANNEL_TYPE_UNORM_INT8"; + break; - if ((val & UR_USM_DEVICE_MEM_FLAG_DEVICE_READ_ONLY) == - (uint32_t)UR_USM_DEVICE_MEM_FLAG_DEVICE_READ_ONLY) { - val ^= (uint32_t)UR_USM_DEVICE_MEM_FLAG_DEVICE_READ_ONLY; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_DEVICE_MEM_FLAG_DEVICE_READ_ONLY; - } - if (val != 0) { - std::bitset<32> bits(val); - if (!first) { - os << " | "; - } - os << "unknown bit flags " << bits; - } else if (first) { - os << "0"; - } -} -} // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, - enum ur_usm_pool_flag_t value) { - switch (value) { + case UR_IMAGE_CHANNEL_TYPE_UNORM_INT16: + os << "UR_IMAGE_CHANNEL_TYPE_UNORM_INT16"; + break; - case UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK: - os << "UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK"; + case UR_IMAGE_CHANNEL_TYPE_UNORM_SHORT_565: + os << "UR_IMAGE_CHANNEL_TYPE_UNORM_SHORT_565"; break; - default: - os << "unknown enumerator"; + + case UR_IMAGE_CHANNEL_TYPE_UNORM_SHORT_555: + os << "UR_IMAGE_CHANNEL_TYPE_UNORM_SHORT_555"; break; - } - return os; -} -namespace ur_params { -template <> -inline void serializeFlag(std::ostream &os, uint32_t flag) { - uint32_t val = flag; - bool first = true; + case UR_IMAGE_CHANNEL_TYPE_INT_101010: + os << "UR_IMAGE_CHANNEL_TYPE_INT_101010"; + break; - if ((val & UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK) == - (uint32_t)UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK) { - val ^= (uint32_t)UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK; - } - if (val != 0) { - std::bitset<32> bits(val); - if (!first) { - os << " | "; - } - os << "unknown bit flags " << bits; - } else if (first) { - os << "0"; - } -} -} // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, enum ur_usm_type_t value) { - switch (value) { + case UR_IMAGE_CHANNEL_TYPE_SIGNED_INT8: + os << "UR_IMAGE_CHANNEL_TYPE_SIGNED_INT8"; + break; - case UR_USM_TYPE_UNKNOWN: - os << "UR_USM_TYPE_UNKNOWN"; + case UR_IMAGE_CHANNEL_TYPE_SIGNED_INT16: + os << "UR_IMAGE_CHANNEL_TYPE_SIGNED_INT16"; break; - case UR_USM_TYPE_HOST: - os << "UR_USM_TYPE_HOST"; + case UR_IMAGE_CHANNEL_TYPE_SIGNED_INT32: + os << "UR_IMAGE_CHANNEL_TYPE_SIGNED_INT32"; break; - case UR_USM_TYPE_DEVICE: - os << "UR_USM_TYPE_DEVICE"; + case UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT8: + os << "UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT8"; break; - case UR_USM_TYPE_SHARED: - os << "UR_USM_TYPE_SHARED"; + case UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT16: + os << "UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT16"; + break; + + case UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT32: + os << "UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT32"; + break; + + case UR_IMAGE_CHANNEL_TYPE_HALF_FLOAT: + os << "UR_IMAGE_CHANNEL_TYPE_HALF_FLOAT"; + break; + + case UR_IMAGE_CHANNEL_TYPE_FLOAT: + os << "UR_IMAGE_CHANNEL_TYPE_FLOAT"; break; default: os << "unknown enumerator"; @@ -5881,28 +5802,35 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_usm_type_t value) { } return os; } -inline std::ostream &operator<<(std::ostream &os, - enum ur_usm_alloc_info_t value) { +inline std::ostream &operator<<(std::ostream &os, enum ur_image_info_t value) { switch (value) { - case UR_USM_ALLOC_INFO_TYPE: - os << "UR_USM_ALLOC_INFO_TYPE"; + case UR_IMAGE_INFO_FORMAT: + os << "UR_IMAGE_INFO_FORMAT"; break; - case UR_USM_ALLOC_INFO_BASE_PTR: - os << "UR_USM_ALLOC_INFO_BASE_PTR"; + case UR_IMAGE_INFO_ELEMENT_SIZE: + os << "UR_IMAGE_INFO_ELEMENT_SIZE"; break; - case UR_USM_ALLOC_INFO_SIZE: - os << "UR_USM_ALLOC_INFO_SIZE"; + case UR_IMAGE_INFO_ROW_PITCH: + os << "UR_IMAGE_INFO_ROW_PITCH"; break; - case UR_USM_ALLOC_INFO_DEVICE: - os << "UR_USM_ALLOC_INFO_DEVICE"; + case UR_IMAGE_INFO_SLICE_PITCH: + os << "UR_IMAGE_INFO_SLICE_PITCH"; break; - case UR_USM_ALLOC_INFO_POOL: - os << "UR_USM_ALLOC_INFO_POOL"; + case UR_IMAGE_INFO_WIDTH: + os << "UR_IMAGE_INFO_WIDTH"; + break; + + case UR_IMAGE_INFO_HEIGHT: + os << "UR_IMAGE_INFO_HEIGHT"; + break; + + case UR_IMAGE_INFO_DEPTH: + os << "UR_IMAGE_INFO_DEPTH"; break; default: os << "unknown enumerator"; @@ -5913,7 +5841,7 @@ inline std::ostream &operator<<(std::ostream &os, namespace ur_params { template <> inline void serializeTagged(std::ostream &os, const void *ptr, - ur_usm_alloc_info_t value, size_t size) { + ur_image_info_t value, size_t size) { if (ptr == NULL) { serializePtr(os, ptr); return; @@ -5921,11 +5849,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, switch (value) { - case UR_USM_ALLOC_INFO_TYPE: { - const ur_usm_type_t *tptr = (const ur_usm_type_t *)ptr; - if (sizeof(ur_usm_type_t) > size) { + case UR_IMAGE_INFO_FORMAT: { + const ur_image_format_t *tptr = (const ur_image_format_t *)ptr; + if (sizeof(ur_image_format_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_usm_type_t) << ")"; + << ", expected: >=" << sizeof(ur_image_format_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -5935,11 +5863,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_USM_ALLOC_INFO_BASE_PTR: { - const void **tptr = (const void **)ptr; - if (sizeof(void *) > size) { + case UR_IMAGE_INFO_ELEMENT_SIZE: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(void *) << ")"; + << ", expected: >=" << sizeof(size_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -5949,7 +5877,7 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_USM_ALLOC_INFO_SIZE: { + case UR_IMAGE_INFO_ROW_PITCH: { const size_t *tptr = (const size_t *)ptr; if (sizeof(size_t) > size) { os << "invalid size (is: " << size @@ -5963,294 +5891,147 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_USM_ALLOC_INFO_DEVICE: { - const ur_device_handle_t *tptr = (const ur_device_handle_t *)ptr; - if (sizeof(ur_device_handle_t) > size) { + case UR_IMAGE_INFO_SLICE_PITCH: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_device_handle_t) << ")"; + << ", expected: >=" << sizeof(size_t) << ")"; return; } os << (void *)(tptr) << " ("; - ur_params::serializePtr(os, *tptr); + os << *tptr; os << ")"; } break; - case UR_USM_ALLOC_INFO_POOL: { - const ur_usm_pool_handle_t *tptr = (const ur_usm_pool_handle_t *)ptr; - if (sizeof(ur_usm_pool_handle_t) > size) { + case UR_IMAGE_INFO_WIDTH: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_usm_pool_handle_t) << ")"; + << ", expected: >=" << sizeof(size_t) << ")"; return; } os << (void *)(tptr) << " ("; - ur_params::serializePtr(os, *tptr); + os << *tptr; os << ")"; } break; - default: - os << "unknown enumerator"; - break; - } -} -} // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, - enum ur_usm_advice_flag_t value) { - switch (value) { - case UR_USM_ADVICE_FLAG_DEFAULT: - os << "UR_USM_ADVICE_FLAG_DEFAULT"; - break; + case UR_IMAGE_INFO_HEIGHT: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(size_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_USM_ADVICE_FLAG_SET_READ_MOSTLY: - os << "UR_USM_ADVICE_FLAG_SET_READ_MOSTLY"; - break; + os << *tptr; - case UR_USM_ADVICE_FLAG_CLEAR_READ_MOSTLY: - os << "UR_USM_ADVICE_FLAG_CLEAR_READ_MOSTLY"; - break; + os << ")"; + } break; - case UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION: - os << "UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION"; - break; + case UR_IMAGE_INFO_DEPTH: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(size_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; - case UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION: - os << "UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION"; + os << ")"; + } break; + default: + os << "unknown enumerator"; break; + } +} +} // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, + const struct ur_image_format_t params) { + os << "(struct ur_image_format_t){"; - case UR_USM_ADVICE_FLAG_SET_NON_ATOMIC_MOSTLY: - os << "UR_USM_ADVICE_FLAG_SET_NON_ATOMIC_MOSTLY"; - break; + os << ".channelOrder = "; - case UR_USM_ADVICE_FLAG_CLEAR_NON_ATOMIC_MOSTLY: - os << "UR_USM_ADVICE_FLAG_CLEAR_NON_ATOMIC_MOSTLY"; - break; + os << (params.channelOrder); - case UR_USM_ADVICE_FLAG_BIAS_CACHED: - os << "UR_USM_ADVICE_FLAG_BIAS_CACHED"; - break; + os << ", "; + os << ".channelType = "; - case UR_USM_ADVICE_FLAG_BIAS_UNCACHED: - os << "UR_USM_ADVICE_FLAG_BIAS_UNCACHED"; - break; + os << (params.channelType); - case UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_DEVICE: - os << "UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_DEVICE"; - break; + os << "}"; + return os; +} +inline std::ostream &operator<<(std::ostream &os, + const struct ur_image_desc_t params) { + os << "(struct ur_image_desc_t){"; - case UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_DEVICE: - os << "UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_DEVICE"; - break; + os << ".stype = "; - case UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_HOST: - os << "UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_HOST"; - break; + os << (params.stype); - case UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_HOST: - os << "UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_HOST"; - break; + os << ", "; + os << ".pNext = "; - case UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION_HOST: - os << "UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION_HOST"; - break; + ur_params::serializeStruct(os, (params.pNext)); - case UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION_HOST: - os << "UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION_HOST"; - break; - default: - os << "unknown enumerator"; - break; - } - return os; -} -namespace ur_params { + os << ", "; + os << ".type = "; -template <> -inline void serializeFlag(std::ostream &os, - uint32_t flag) { - uint32_t val = flag; - bool first = true; + os << (params.type); - if ((val & UR_USM_ADVICE_FLAG_DEFAULT) == - (uint32_t)UR_USM_ADVICE_FLAG_DEFAULT) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_DEFAULT; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_ADVICE_FLAG_DEFAULT; - } + os << ", "; + os << ".width = "; - if ((val & UR_USM_ADVICE_FLAG_SET_READ_MOSTLY) == - (uint32_t)UR_USM_ADVICE_FLAG_SET_READ_MOSTLY) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_SET_READ_MOSTLY; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_ADVICE_FLAG_SET_READ_MOSTLY; - } + os << (params.width); - if ((val & UR_USM_ADVICE_FLAG_CLEAR_READ_MOSTLY) == - (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_READ_MOSTLY) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_READ_MOSTLY; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_ADVICE_FLAG_CLEAR_READ_MOSTLY; - } + os << ", "; + os << ".height = "; - if ((val & UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION) == - (uint32_t)UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION; - } + os << (params.height); - if ((val & UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION) == - (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION; - } + os << ", "; + os << ".depth = "; - if ((val & UR_USM_ADVICE_FLAG_SET_NON_ATOMIC_MOSTLY) == - (uint32_t)UR_USM_ADVICE_FLAG_SET_NON_ATOMIC_MOSTLY) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_SET_NON_ATOMIC_MOSTLY; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_ADVICE_FLAG_SET_NON_ATOMIC_MOSTLY; - } + os << (params.depth); - if ((val & UR_USM_ADVICE_FLAG_CLEAR_NON_ATOMIC_MOSTLY) == - (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_NON_ATOMIC_MOSTLY) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_NON_ATOMIC_MOSTLY; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_ADVICE_FLAG_CLEAR_NON_ATOMIC_MOSTLY; - } + os << ", "; + os << ".arraySize = "; - if ((val & UR_USM_ADVICE_FLAG_BIAS_CACHED) == - (uint32_t)UR_USM_ADVICE_FLAG_BIAS_CACHED) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_BIAS_CACHED; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_ADVICE_FLAG_BIAS_CACHED; - } + os << (params.arraySize); - if ((val & UR_USM_ADVICE_FLAG_BIAS_UNCACHED) == - (uint32_t)UR_USM_ADVICE_FLAG_BIAS_UNCACHED) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_BIAS_UNCACHED; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_ADVICE_FLAG_BIAS_UNCACHED; - } + os << ", "; + os << ".rowPitch = "; - if ((val & UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_DEVICE) == - (uint32_t)UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_DEVICE) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_DEVICE; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_DEVICE; - } + os << (params.rowPitch); - if ((val & UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_DEVICE) == - (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_DEVICE) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_DEVICE; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_DEVICE; - } + os << ", "; + os << ".slicePitch = "; - if ((val & UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_HOST) == - (uint32_t)UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_HOST) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_HOST; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_HOST; - } + os << (params.slicePitch); - if ((val & UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_HOST) == - (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_HOST) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_HOST; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_HOST; - } + os << ", "; + os << ".numMipLevel = "; - if ((val & UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION_HOST) == - (uint32_t)UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION_HOST) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION_HOST; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION_HOST; - } + os << (params.numMipLevel); - if ((val & UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION_HOST) == - (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION_HOST) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION_HOST; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION_HOST; - } - if (val != 0) { - std::bitset<32> bits(val); - if (!first) { - os << " | "; - } - os << "unknown bit flags " << bits; - } else if (first) { - os << "0"; - } + os << ", "; + os << ".numSamples = "; + + os << (params.numSamples); + + os << "}"; + return os; } -} // namespace ur_params inline std::ostream &operator<<(std::ostream &os, - const struct ur_usm_desc_t params) { - os << "(struct ur_usm_desc_t){"; + const struct ur_buffer_properties_t params) { + os << "(struct ur_buffer_properties_t){"; os << ".stype = "; @@ -6262,21 +6043,17 @@ inline std::ostream &operator<<(std::ostream &os, ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".hints = "; - - ur_params::serializeFlag(os, (params.hints)); - - os << ", "; - os << ".align = "; + os << ".pHost = "; - os << (params.align); + ur_params::serializePtr(os, (params.pHost)); os << "}"; return os; } -inline std::ostream &operator<<(std::ostream &os, - const struct ur_usm_host_desc_t params) { - os << "(struct ur_usm_host_desc_t){"; +inline std::ostream & +operator<<(std::ostream &os, + const struct ur_buffer_channel_properties_t params) { + os << "(struct ur_buffer_channel_properties_t){"; os << ".stype = "; @@ -6288,16 +6065,17 @@ inline std::ostream &operator<<(std::ostream &os, ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".flags = "; + os << ".channel = "; - ur_params::serializeFlag(os, (params.flags)); + os << (params.channel); os << "}"; return os; } -inline std::ostream &operator<<(std::ostream &os, - const struct ur_usm_device_desc_t params) { - os << "(struct ur_usm_device_desc_t){"; +inline std::ostream & +operator<<(std::ostream &os, + const struct ur_buffer_alloc_location_properties_t params) { + os << "(struct ur_buffer_alloc_location_properties_t){"; os << ".stype = "; @@ -6309,16 +6087,16 @@ inline std::ostream &operator<<(std::ostream &os, ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".flags = "; + os << ".location = "; - ur_params::serializeFlag(os, (params.flags)); + os << (params.location); os << "}"; return os; } inline std::ostream &operator<<(std::ostream &os, - const struct ur_usm_pool_desc_t params) { - os << "(struct ur_usm_pool_desc_t){"; + const struct ur_buffer_region_t params) { + os << "(struct ur_buffer_region_t){"; os << ".stype = "; @@ -6330,16 +6108,34 @@ inline std::ostream &operator<<(std::ostream &os, ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".flags = "; + os << ".origin = "; - ur_params::serializeFlag(os, (params.flags)); + os << (params.origin); + + os << ", "; + os << ".size = "; + + os << (params.size); os << "}"; return os; } inline std::ostream &operator<<(std::ostream &os, - const struct ur_usm_pool_limits_desc_t params) { - os << "(struct ur_usm_pool_limits_desc_t){"; + enum ur_buffer_create_type_t value) { + switch (value) { + + case UR_BUFFER_CREATE_TYPE_REGION: + os << "UR_BUFFER_CREATE_TYPE_REGION"; + break; + default: + os << "unknown enumerator"; + break; + } + return os; +} +inline std::ostream & +operator<<(std::ostream &os, const struct ur_mem_native_properties_t params) { + os << "(struct ur_mem_native_properties_t){"; os << ".stype = "; @@ -6351,28 +6147,23 @@ inline std::ostream &operator<<(std::ostream &os, ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".maxPoolableSize = "; - - os << (params.maxPoolableSize); - - os << ", "; - os << ".minDriverAllocSize = "; + os << ".isNativeHandleOwned = "; - os << (params.minDriverAllocSize); + os << (params.isNativeHandleOwned); os << "}"; return os; } inline std::ostream &operator<<(std::ostream &os, - enum ur_usm_pool_info_t value) { + enum ur_sampler_filter_mode_t value) { switch (value) { - case UR_USM_POOL_INFO_REFERENCE_COUNT: - os << "UR_USM_POOL_INFO_REFERENCE_COUNT"; + case UR_SAMPLER_FILTER_MODE_NEAREST: + os << "UR_SAMPLER_FILTER_MODE_NEAREST"; break; - case UR_USM_POOL_INFO_CONTEXT: - os << "UR_USM_POOL_INFO_CONTEXT"; + case UR_SAMPLER_FILTER_MODE_LINEAR: + os << "UR_SAMPLER_FILTER_MODE_LINEAR"; break; default: os << "unknown enumerator"; @@ -6380,60 +6171,57 @@ inline std::ostream &operator<<(std::ostream &os, } return os; } -namespace ur_params { -template <> -inline void serializeTagged(std::ostream &os, const void *ptr, - ur_usm_pool_info_t value, size_t size) { - if (ptr == NULL) { - serializePtr(os, ptr); - return; - } - +inline std::ostream &operator<<(std::ostream &os, + enum ur_sampler_addressing_mode_t value) { switch (value) { - case UR_USM_POOL_INFO_REFERENCE_COUNT: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; + case UR_SAMPLER_ADDRESSING_MODE_NONE: + os << "UR_SAMPLER_ADDRESSING_MODE_NONE"; + break; - os << ")"; - } break; + case UR_SAMPLER_ADDRESSING_MODE_CLAMP_TO_EDGE: + os << "UR_SAMPLER_ADDRESSING_MODE_CLAMP_TO_EDGE"; + break; - case UR_USM_POOL_INFO_CONTEXT: { - const ur_context_handle_t *tptr = (const ur_context_handle_t *)ptr; - if (sizeof(ur_context_handle_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_context_handle_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_SAMPLER_ADDRESSING_MODE_CLAMP: + os << "UR_SAMPLER_ADDRESSING_MODE_CLAMP"; + break; - ur_params::serializePtr(os, *tptr); + case UR_SAMPLER_ADDRESSING_MODE_REPEAT: + os << "UR_SAMPLER_ADDRESSING_MODE_REPEAT"; + break; - os << ")"; - } break; + case UR_SAMPLER_ADDRESSING_MODE_MIRRORED_REPEAT: + os << "UR_SAMPLER_ADDRESSING_MODE_MIRRORED_REPEAT"; + break; default: os << "unknown enumerator"; break; } + return os; } -} // namespace ur_params inline std::ostream &operator<<(std::ostream &os, - enum ur_virtual_mem_granularity_info_t value) { + enum ur_sampler_info_t value) { switch (value) { - case UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM: - os << "UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM"; + case UR_SAMPLER_INFO_REFERENCE_COUNT: + os << "UR_SAMPLER_INFO_REFERENCE_COUNT"; break; - case UR_VIRTUAL_MEM_GRANULARITY_INFO_RECOMMENDED: - os << "UR_VIRTUAL_MEM_GRANULARITY_INFO_RECOMMENDED"; + case UR_SAMPLER_INFO_CONTEXT: + os << "UR_SAMPLER_INFO_CONTEXT"; + break; + + case UR_SAMPLER_INFO_NORMALIZED_COORDS: + os << "UR_SAMPLER_INFO_NORMALIZED_COORDS"; + break; + + case UR_SAMPLER_INFO_ADDRESSING_MODE: + os << "UR_SAMPLER_INFO_ADDRESSING_MODE"; + break; + + case UR_SAMPLER_INFO_FILTER_MODE: + os << "UR_SAMPLER_INFO_FILTER_MODE"; break; default: os << "unknown enumerator"; @@ -6444,8 +6232,7 @@ inline std::ostream &operator<<(std::ostream &os, namespace ur_params { template <> inline void serializeTagged(std::ostream &os, const void *ptr, - ur_virtual_mem_granularity_info_t value, - size_t size) { + ur_sampler_info_t value, size_t size) { if (ptr == NULL) { serializePtr(os, ptr); return; @@ -6453,11 +6240,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, switch (value) { - case UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { + case UR_SAMPLER_INFO_REFERENCE_COUNT: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; + << ", expected: >=" << sizeof(uint32_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -6467,133 +6254,61 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_VIRTUAL_MEM_GRANULARITY_INFO_RECOMMENDED: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { + case UR_SAMPLER_INFO_CONTEXT: { + const ur_context_handle_t *tptr = (const ur_context_handle_t *)ptr; + if (sizeof(ur_context_handle_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; + << ", expected: >=" << sizeof(ur_context_handle_t) << ")"; return; } os << (void *)(tptr) << " ("; - os << *tptr; - - os << ")"; - } break; - default: - os << "unknown enumerator"; - break; - } -} -} // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, - enum ur_virtual_mem_access_flag_t value) { - switch (value) { - - case UR_VIRTUAL_MEM_ACCESS_FLAG_NONE: - os << "UR_VIRTUAL_MEM_ACCESS_FLAG_NONE"; - break; - - case UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE: - os << "UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE"; - break; - - case UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY: - os << "UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY"; - break; - default: - os << "unknown enumerator"; - break; - } - return os; -} -namespace ur_params { - -template <> -inline void serializeFlag(std::ostream &os, - uint32_t flag) { - uint32_t val = flag; - bool first = true; - - if ((val & UR_VIRTUAL_MEM_ACCESS_FLAG_NONE) == - (uint32_t)UR_VIRTUAL_MEM_ACCESS_FLAG_NONE) { - val ^= (uint32_t)UR_VIRTUAL_MEM_ACCESS_FLAG_NONE; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_VIRTUAL_MEM_ACCESS_FLAG_NONE; - } - - if ((val & UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE) == - (uint32_t)UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE) { - val ^= (uint32_t)UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE; - } + ur_params::serializePtr(os, *tptr); - if ((val & UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY) == - (uint32_t)UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY) { - val ^= (uint32_t)UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY; - } - if (val != 0) { - std::bitset<32> bits(val); - if (!first) { - os << " | "; + os << ")"; + } break; + + case UR_SAMPLER_INFO_NORMALIZED_COORDS: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_bool_t) << ")"; + return; } - os << "unknown bit flags " << bits; - } else if (first) { - os << "0"; - } -} -} // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, - enum ur_virtual_mem_info_t value) { - switch (value) { + os << (void *)(tptr) << " ("; - case UR_VIRTUAL_MEM_INFO_ACCESS_MODE: - os << "UR_VIRTUAL_MEM_INFO_ACCESS_MODE"; - break; - default: - os << "unknown enumerator"; - break; - } - return os; -} -namespace ur_params { -template <> -inline void serializeTagged(std::ostream &os, const void *ptr, - ur_virtual_mem_info_t value, size_t size) { - if (ptr == NULL) { - serializePtr(os, ptr); - return; - } + os << *tptr; - switch (value) { + os << ")"; + } break; - case UR_VIRTUAL_MEM_INFO_ACCESS_MODE: { - const ur_virtual_mem_access_flags_t *tptr = - (const ur_virtual_mem_access_flags_t *)ptr; - if (sizeof(ur_virtual_mem_access_flags_t) > size) { + case UR_SAMPLER_INFO_ADDRESSING_MODE: { + const ur_sampler_addressing_mode_t *tptr = + (const ur_sampler_addressing_mode_t *)ptr; + if (sizeof(ur_sampler_addressing_mode_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_virtual_mem_access_flags_t) + << ", expected: >=" << sizeof(ur_sampler_addressing_mode_t) << ")"; return; } os << (void *)(tptr) << " ("; - ur_params::serializeFlag(os, *tptr); + os << *tptr; + + os << ")"; + } break; + + case UR_SAMPLER_INFO_FILTER_MODE: { + const ur_sampler_filter_mode_t *tptr = + (const ur_sampler_filter_mode_t *)ptr; + if (sizeof(ur_sampler_filter_mode_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_sampler_filter_mode_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; os << ")"; } break; @@ -6604,11 +6319,64 @@ inline void serializeTagged(std::ostream &os, const void *ptr, } } // namespace ur_params inline std::ostream &operator<<(std::ostream &os, - enum ur_physical_mem_flag_t value) { + const struct ur_sampler_desc_t params) { + os << "(struct ur_sampler_desc_t){"; + + os << ".stype = "; + + os << (params.stype); + + os << ", "; + os << ".pNext = "; + + ur_params::serializeStruct(os, (params.pNext)); + + os << ", "; + os << ".normalizedCoords = "; + + os << (params.normalizedCoords); + + os << ", "; + os << ".addressingMode = "; + + os << (params.addressingMode); + + os << ", "; + os << ".filterMode = "; + + os << (params.filterMode); + + os << "}"; + return os; +} +inline std::ostream & +operator<<(std::ostream &os, + const struct ur_sampler_native_properties_t params) { + os << "(struct ur_sampler_native_properties_t){"; + + os << ".stype = "; + + os << (params.stype); + + os << ", "; + os << ".pNext = "; + + ur_params::serializeStruct(os, (params.pNext)); + + os << ", "; + os << ".isNativeHandleOwned = "; + + os << (params.isNativeHandleOwned); + + os << "}"; + return os; +} +inline std::ostream &operator<<(std::ostream &os, + enum ur_usm_host_mem_flag_t value) { switch (value) { - case UR_PHYSICAL_MEM_FLAG_TBD: - os << "UR_PHYSICAL_MEM_FLAG_TBD"; + case UR_USM_HOST_MEM_FLAG_INITIAL_PLACEMENT: + os << "UR_USM_HOST_MEM_FLAG_INITIAL_PLACEMENT"; break; default: os << "unknown enumerator"; @@ -6619,20 +6387,20 @@ inline std::ostream &operator<<(std::ostream &os, namespace ur_params { template <> -inline void serializeFlag(std::ostream &os, +inline void serializeFlag(std::ostream &os, uint32_t flag) { uint32_t val = flag; bool first = true; - if ((val & UR_PHYSICAL_MEM_FLAG_TBD) == - (uint32_t)UR_PHYSICAL_MEM_FLAG_TBD) { - val ^= (uint32_t)UR_PHYSICAL_MEM_FLAG_TBD; + if ((val & UR_USM_HOST_MEM_FLAG_INITIAL_PLACEMENT) == + (uint32_t)UR_USM_HOST_MEM_FLAG_INITIAL_PLACEMENT) { + val ^= (uint32_t)UR_USM_HOST_MEM_FLAG_INITIAL_PLACEMENT; if (!first) { os << " | "; } else { first = false; } - os << UR_PHYSICAL_MEM_FLAG_TBD; + os << UR_USM_HOST_MEM_FLAG_INITIAL_PLACEMENT; } if (val != 0) { std::bitset<32> bits(val); @@ -6645,45 +6413,20 @@ inline void serializeFlag(std::ostream &os, } } } // namespace ur_params -inline std::ostream & -operator<<(std::ostream &os, const struct ur_physical_mem_properties_t params) { - os << "(struct ur_physical_mem_properties_t){"; - - os << ".stype = "; - - os << (params.stype); - - os << ", "; - os << ".pNext = "; - - ur_params::serializeStruct(os, (params.pNext)); - - os << ", "; - os << ".flags = "; - - ur_params::serializeFlag(os, (params.flags)); - - os << "}"; - return os; -} inline std::ostream &operator<<(std::ostream &os, - enum ur_program_metadata_type_t value) { + enum ur_usm_device_mem_flag_t value) { switch (value) { - case UR_PROGRAM_METADATA_TYPE_UINT32: - os << "UR_PROGRAM_METADATA_TYPE_UINT32"; - break; - - case UR_PROGRAM_METADATA_TYPE_UINT64: - os << "UR_PROGRAM_METADATA_TYPE_UINT64"; + case UR_USM_DEVICE_MEM_FLAG_WRITE_COMBINED: + os << "UR_USM_DEVICE_MEM_FLAG_WRITE_COMBINED"; break; - case UR_PROGRAM_METADATA_TYPE_BYTE_ARRAY: - os << "UR_PROGRAM_METADATA_TYPE_BYTE_ARRAY"; + case UR_USM_DEVICE_MEM_FLAG_INITIAL_PLACEMENT: + os << "UR_USM_DEVICE_MEM_FLAG_INITIAL_PLACEMENT"; break; - case UR_PROGRAM_METADATA_TYPE_STRING: - os << "UR_PROGRAM_METADATA_TYPE_STRING"; + case UR_USM_DEVICE_MEM_FLAG_DEVICE_READ_ONLY: + os << "UR_USM_DEVICE_MEM_FLAG_DEVICE_READ_ONLY"; break; default: os << "unknown enumerator"; @@ -6691,128 +6434,144 @@ inline std::ostream &operator<<(std::ostream &os, } return os; } -inline std::ostream & -operator<<(std::ostream &os, const union ur_program_metadata_value_t params) { - os << "(union ur_program_metadata_value_t){"; - - os << ".data32 = "; - - os << (params.data32); - - os << ", "; - os << ".data64 = "; - - os << (params.data64); - - os << ", "; - os << ".pString = "; - - ur_params::serializePtr(os, (params.pString)); - - os << ", "; - os << ".pData = "; - - ur_params::serializePtr(os, (params.pData)); - - os << "}"; - return os; -} -inline std::ostream &operator<<(std::ostream &os, - const struct ur_program_metadata_t params) { - os << "(struct ur_program_metadata_t){"; - - os << ".pName = "; - - ur_params::serializePtr(os, (params.pName)); - - os << ", "; - os << ".type = "; - - os << (params.type); - - os << ", "; - os << ".size = "; +namespace ur_params { - os << (params.size); +template <> +inline void serializeFlag(std::ostream &os, + uint32_t flag) { + uint32_t val = flag; + bool first = true; - os << ", "; - os << ".value = "; + if ((val & UR_USM_DEVICE_MEM_FLAG_WRITE_COMBINED) == + (uint32_t)UR_USM_DEVICE_MEM_FLAG_WRITE_COMBINED) { + val ^= (uint32_t)UR_USM_DEVICE_MEM_FLAG_WRITE_COMBINED; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_USM_DEVICE_MEM_FLAG_WRITE_COMBINED; + } - os << (params.value); + if ((val & UR_USM_DEVICE_MEM_FLAG_INITIAL_PLACEMENT) == + (uint32_t)UR_USM_DEVICE_MEM_FLAG_INITIAL_PLACEMENT) { + val ^= (uint32_t)UR_USM_DEVICE_MEM_FLAG_INITIAL_PLACEMENT; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_USM_DEVICE_MEM_FLAG_INITIAL_PLACEMENT; + } - os << "}"; - return os; + if ((val & UR_USM_DEVICE_MEM_FLAG_DEVICE_READ_ONLY) == + (uint32_t)UR_USM_DEVICE_MEM_FLAG_DEVICE_READ_ONLY) { + val ^= (uint32_t)UR_USM_DEVICE_MEM_FLAG_DEVICE_READ_ONLY; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_USM_DEVICE_MEM_FLAG_DEVICE_READ_ONLY; + } + if (val != 0) { + std::bitset<32> bits(val); + if (!first) { + os << " | "; + } + os << "unknown bit flags " << bits; + } else if (first) { + os << "0"; + } } +} // namespace ur_params inline std::ostream &operator<<(std::ostream &os, - const struct ur_program_properties_t params) { - os << "(struct ur_program_properties_t){"; - - os << ".stype = "; - - os << (params.stype); - - os << ", "; - os << ".pNext = "; - - ur_params::serializeStruct(os, (params.pNext)); + enum ur_usm_pool_flag_t value) { + switch (value) { - os << ", "; - os << ".count = "; + case UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK: + os << "UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK"; + break; + default: + os << "unknown enumerator"; + break; + } + return os; +} +namespace ur_params { - os << (params.count); +template <> +inline void serializeFlag(std::ostream &os, uint32_t flag) { + uint32_t val = flag; + bool first = true; - os << ", "; - os << ".pMetadatas = {"; - for (size_t i = 0; (params.pMetadatas) != NULL && i < params.count; ++i) { - if (i != 0) { - os << ", "; + if ((val & UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK) == + (uint32_t)UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK) { + val ^= (uint32_t)UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK; + if (!first) { + os << " | "; + } else { + first = false; } - - os << ((params.pMetadatas))[i]; + os << UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK; + } + if (val != 0) { + std::bitset<32> bits(val); + if (!first) { + os << " | "; + } + os << "unknown bit flags " << bits; + } else if (first) { + os << "0"; } - os << "}"; - - os << "}"; - return os; } -inline std::ostream &operator<<(std::ostream &os, - enum ur_program_info_t value) { +} // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, enum ur_usm_type_t value) { switch (value) { - case UR_PROGRAM_INFO_REFERENCE_COUNT: - os << "UR_PROGRAM_INFO_REFERENCE_COUNT"; + case UR_USM_TYPE_UNKNOWN: + os << "UR_USM_TYPE_UNKNOWN"; break; - case UR_PROGRAM_INFO_CONTEXT: - os << "UR_PROGRAM_INFO_CONTEXT"; + case UR_USM_TYPE_HOST: + os << "UR_USM_TYPE_HOST"; break; - case UR_PROGRAM_INFO_NUM_DEVICES: - os << "UR_PROGRAM_INFO_NUM_DEVICES"; + case UR_USM_TYPE_DEVICE: + os << "UR_USM_TYPE_DEVICE"; break; - case UR_PROGRAM_INFO_DEVICES: - os << "UR_PROGRAM_INFO_DEVICES"; + case UR_USM_TYPE_SHARED: + os << "UR_USM_TYPE_SHARED"; + break; + default: + os << "unknown enumerator"; break; + } + return os; +} +inline std::ostream &operator<<(std::ostream &os, + enum ur_usm_alloc_info_t value) { + switch (value) { - case UR_PROGRAM_INFO_SOURCE: - os << "UR_PROGRAM_INFO_SOURCE"; + case UR_USM_ALLOC_INFO_TYPE: + os << "UR_USM_ALLOC_INFO_TYPE"; break; - case UR_PROGRAM_INFO_BINARY_SIZES: - os << "UR_PROGRAM_INFO_BINARY_SIZES"; + case UR_USM_ALLOC_INFO_BASE_PTR: + os << "UR_USM_ALLOC_INFO_BASE_PTR"; break; - case UR_PROGRAM_INFO_BINARIES: - os << "UR_PROGRAM_INFO_BINARIES"; + case UR_USM_ALLOC_INFO_SIZE: + os << "UR_USM_ALLOC_INFO_SIZE"; break; - case UR_PROGRAM_INFO_NUM_KERNELS: - os << "UR_PROGRAM_INFO_NUM_KERNELS"; + case UR_USM_ALLOC_INFO_DEVICE: + os << "UR_USM_ALLOC_INFO_DEVICE"; break; - case UR_PROGRAM_INFO_KERNEL_NAMES: - os << "UR_PROGRAM_INFO_KERNEL_NAMES"; + case UR_USM_ALLOC_INFO_POOL: + os << "UR_USM_ALLOC_INFO_POOL"; break; default: os << "unknown enumerator"; @@ -6823,7 +6582,7 @@ inline std::ostream &operator<<(std::ostream &os, namespace ur_params { template <> inline void serializeTagged(std::ostream &os, const void *ptr, - ur_program_info_t value, size_t size) { + ur_usm_alloc_info_t value, size_t size) { if (ptr == NULL) { serializePtr(os, ptr); return; @@ -6831,11 +6590,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, switch (value) { - case UR_PROGRAM_INFO_REFERENCE_COUNT: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { + case UR_USM_ALLOC_INFO_TYPE: { + const ur_usm_type_t *tptr = (const ur_usm_type_t *)ptr; + if (sizeof(ur_usm_type_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; + << ", expected: >=" << sizeof(ur_usm_type_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -6845,25 +6604,25 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_PROGRAM_INFO_CONTEXT: { - const ur_context_handle_t *tptr = (const ur_context_handle_t *)ptr; - if (sizeof(ur_context_handle_t) > size) { + case UR_USM_ALLOC_INFO_BASE_PTR: { + const void **tptr = (const void **)ptr; + if (sizeof(void *) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_context_handle_t) << ")"; + << ", expected: >=" << sizeof(void *) << ")"; return; } os << (void *)(tptr) << " ("; - ur_params::serializePtr(os, *tptr); + os << *tptr; os << ")"; } break; - case UR_PROGRAM_INFO_NUM_DEVICES: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { + case UR_USM_ALLOC_INFO_SIZE: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; + << ", expected: >=" << sizeof(size_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -6873,67 +6632,33 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_PROGRAM_INFO_DEVICES: { - + case UR_USM_ALLOC_INFO_DEVICE: { const ur_device_handle_t *tptr = (const ur_device_handle_t *)ptr; - os << "{"; - size_t nelems = size / sizeof(ur_device_handle_t); - for (size_t i = 0; i < nelems; ++i) { - if (i != 0) { - os << ", "; - } - - ur_params::serializePtr(os, tptr[i]); - } - os << "}"; - } break; - - case UR_PROGRAM_INFO_SOURCE: { - - const char *tptr = (const char *)ptr; - serializePtr(os, tptr); - } break; - - case UR_PROGRAM_INFO_BINARY_SIZES: { - - const size_t *tptr = (const size_t *)ptr; - os << "{"; - size_t nelems = size / sizeof(size_t); - for (size_t i = 0; i < nelems; ++i) { - if (i != 0) { - os << ", "; - } - - os << tptr[i]; + if (sizeof(ur_device_handle_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_device_handle_t) << ")"; + return; } - os << "}"; - } break; + os << (void *)(tptr) << " ("; - case UR_PROGRAM_INFO_BINARIES: { + ur_params::serializePtr(os, *tptr); - const unsigned char *tptr = (const unsigned char *)ptr; - serializePtr(os, tptr); + os << ")"; } break; - case UR_PROGRAM_INFO_NUM_KERNELS: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { + case UR_USM_ALLOC_INFO_POOL: { + const ur_usm_pool_handle_t *tptr = (const ur_usm_pool_handle_t *)ptr; + if (sizeof(ur_usm_pool_handle_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; + << ", expected: >=" << sizeof(ur_usm_pool_handle_t) << ")"; return; } os << (void *)(tptr) << " ("; - os << *tptr; + ur_params::serializePtr(os, *tptr); os << ")"; } break; - - case UR_PROGRAM_INFO_KERNEL_NAMES: { - - const char *tptr = (const char *)ptr; - serializePtr(os, tptr); - } break; default: os << "unknown enumerator"; break; @@ -6941,73 +6666,67 @@ inline void serializeTagged(std::ostream &os, const void *ptr, } } // namespace ur_params inline std::ostream &operator<<(std::ostream &os, - enum ur_program_build_status_t value) { + enum ur_usm_advice_flag_t value) { switch (value) { - case UR_PROGRAM_BUILD_STATUS_NONE: - os << "UR_PROGRAM_BUILD_STATUS_NONE"; + case UR_USM_ADVICE_FLAG_DEFAULT: + os << "UR_USM_ADVICE_FLAG_DEFAULT"; break; - case UR_PROGRAM_BUILD_STATUS_ERROR: - os << "UR_PROGRAM_BUILD_STATUS_ERROR"; + case UR_USM_ADVICE_FLAG_SET_READ_MOSTLY: + os << "UR_USM_ADVICE_FLAG_SET_READ_MOSTLY"; break; - case UR_PROGRAM_BUILD_STATUS_SUCCESS: - os << "UR_PROGRAM_BUILD_STATUS_SUCCESS"; + case UR_USM_ADVICE_FLAG_CLEAR_READ_MOSTLY: + os << "UR_USM_ADVICE_FLAG_CLEAR_READ_MOSTLY"; break; - case UR_PROGRAM_BUILD_STATUS_IN_PROGRESS: - os << "UR_PROGRAM_BUILD_STATUS_IN_PROGRESS"; + case UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION: + os << "UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION"; break; - default: - os << "unknown enumerator"; + + case UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION: + os << "UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION"; break; - } - return os; -} -inline std::ostream &operator<<(std::ostream &os, - enum ur_program_binary_type_t value) { - switch (value) { - case UR_PROGRAM_BINARY_TYPE_NONE: - os << "UR_PROGRAM_BINARY_TYPE_NONE"; + case UR_USM_ADVICE_FLAG_SET_NON_ATOMIC_MOSTLY: + os << "UR_USM_ADVICE_FLAG_SET_NON_ATOMIC_MOSTLY"; break; - case UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT: - os << "UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT"; + case UR_USM_ADVICE_FLAG_CLEAR_NON_ATOMIC_MOSTLY: + os << "UR_USM_ADVICE_FLAG_CLEAR_NON_ATOMIC_MOSTLY"; break; - case UR_PROGRAM_BINARY_TYPE_LIBRARY: - os << "UR_PROGRAM_BINARY_TYPE_LIBRARY"; + case UR_USM_ADVICE_FLAG_BIAS_CACHED: + os << "UR_USM_ADVICE_FLAG_BIAS_CACHED"; + break; + + case UR_USM_ADVICE_FLAG_BIAS_UNCACHED: + os << "UR_USM_ADVICE_FLAG_BIAS_UNCACHED"; + break; + + case UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_DEVICE: + os << "UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_DEVICE"; break; - case UR_PROGRAM_BINARY_TYPE_EXECUTABLE: - os << "UR_PROGRAM_BINARY_TYPE_EXECUTABLE"; - break; - default: - os << "unknown enumerator"; + case UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_DEVICE: + os << "UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_DEVICE"; break; - } - return os; -} -inline std::ostream &operator<<(std::ostream &os, - enum ur_program_build_info_t value) { - switch (value) { - case UR_PROGRAM_BUILD_INFO_STATUS: - os << "UR_PROGRAM_BUILD_INFO_STATUS"; + case UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_HOST: + os << "UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_HOST"; break; - case UR_PROGRAM_BUILD_INFO_OPTIONS: - os << "UR_PROGRAM_BUILD_INFO_OPTIONS"; + case UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_HOST: + os << "UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_HOST"; break; - case UR_PROGRAM_BUILD_INFO_LOG: - os << "UR_PROGRAM_BUILD_INFO_LOG"; + case UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION_HOST: + os << "UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION_HOST"; break; - case UR_PROGRAM_BUILD_INFO_BINARY_TYPE: - os << "UR_PROGRAM_BUILD_INFO_BINARY_TYPE"; + case UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION_HOST: + os << "UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION_HOST"; break; default: os << "unknown enumerator"; @@ -7016,89 +6735,191 @@ inline std::ostream &operator<<(std::ostream &os, return os; } namespace ur_params { -template <> -inline void serializeTagged(std::ostream &os, const void *ptr, - ur_program_build_info_t value, size_t size) { - if (ptr == NULL) { - serializePtr(os, ptr); - return; - } - switch (value) { +template <> +inline void serializeFlag(std::ostream &os, + uint32_t flag) { + uint32_t val = flag; + bool first = true; - case UR_PROGRAM_BUILD_INFO_STATUS: { - const ur_program_build_status_t *tptr = - (const ur_program_build_status_t *)ptr; - if (sizeof(ur_program_build_status_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_program_build_status_t) << ")"; - return; + if ((val & UR_USM_ADVICE_FLAG_DEFAULT) == + (uint32_t)UR_USM_ADVICE_FLAG_DEFAULT) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_DEFAULT; + if (!first) { + os << " | "; + } else { + first = false; } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; + os << UR_USM_ADVICE_FLAG_DEFAULT; + } - case UR_PROGRAM_BUILD_INFO_OPTIONS: { + if ((val & UR_USM_ADVICE_FLAG_SET_READ_MOSTLY) == + (uint32_t)UR_USM_ADVICE_FLAG_SET_READ_MOSTLY) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_SET_READ_MOSTLY; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_USM_ADVICE_FLAG_SET_READ_MOSTLY; + } - const char *tptr = (const char *)ptr; - serializePtr(os, tptr); - } break; + if ((val & UR_USM_ADVICE_FLAG_CLEAR_READ_MOSTLY) == + (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_READ_MOSTLY) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_READ_MOSTLY; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_USM_ADVICE_FLAG_CLEAR_READ_MOSTLY; + } - case UR_PROGRAM_BUILD_INFO_LOG: { + if ((val & UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION) == + (uint32_t)UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION; + } - const char *tptr = (const char *)ptr; - serializePtr(os, tptr); - } break; + if ((val & UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION) == + (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION; + } - case UR_PROGRAM_BUILD_INFO_BINARY_TYPE: { - const ur_program_binary_type_t *tptr = - (const ur_program_binary_type_t *)ptr; - if (sizeof(ur_program_binary_type_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_program_binary_type_t) << ")"; - return; + if ((val & UR_USM_ADVICE_FLAG_SET_NON_ATOMIC_MOSTLY) == + (uint32_t)UR_USM_ADVICE_FLAG_SET_NON_ATOMIC_MOSTLY) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_SET_NON_ATOMIC_MOSTLY; + if (!first) { + os << " | "; + } else { + first = false; } - os << (void *)(tptr) << " ("; + os << UR_USM_ADVICE_FLAG_SET_NON_ATOMIC_MOSTLY; + } - os << *tptr; + if ((val & UR_USM_ADVICE_FLAG_CLEAR_NON_ATOMIC_MOSTLY) == + (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_NON_ATOMIC_MOSTLY) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_NON_ATOMIC_MOSTLY; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_USM_ADVICE_FLAG_CLEAR_NON_ATOMIC_MOSTLY; + } - os << ")"; - } break; - default: - os << "unknown enumerator"; - break; + if ((val & UR_USM_ADVICE_FLAG_BIAS_CACHED) == + (uint32_t)UR_USM_ADVICE_FLAG_BIAS_CACHED) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_BIAS_CACHED; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_USM_ADVICE_FLAG_BIAS_CACHED; } -} -} // namespace ur_params -inline std::ostream & -operator<<(std::ostream &os, - const struct ur_specialization_constant_info_t params) { - os << "(struct ur_specialization_constant_info_t){"; - os << ".id = "; + if ((val & UR_USM_ADVICE_FLAG_BIAS_UNCACHED) == + (uint32_t)UR_USM_ADVICE_FLAG_BIAS_UNCACHED) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_BIAS_UNCACHED; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_USM_ADVICE_FLAG_BIAS_UNCACHED; + } - os << (params.id); + if ((val & UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_DEVICE) == + (uint32_t)UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_DEVICE) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_DEVICE; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_DEVICE; + } - os << ", "; - os << ".size = "; + if ((val & UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_DEVICE) == + (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_DEVICE) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_DEVICE; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_DEVICE; + } - os << (params.size); + if ((val & UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_HOST) == + (uint32_t)UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_HOST) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_HOST; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_HOST; + } - os << ", "; - os << ".pValue = "; + if ((val & UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_HOST) == + (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_HOST) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_HOST; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_HOST; + } - ur_params::serializePtr(os, (params.pValue)); + if ((val & UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION_HOST) == + (uint32_t)UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION_HOST) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION_HOST; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION_HOST; + } - os << "}"; - return os; + if ((val & UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION_HOST) == + (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION_HOST) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION_HOST; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION_HOST; + } + if (val != 0) { + std::bitset<32> bits(val); + if (!first) { + os << " | "; + } + os << "unknown bit flags " << bits; + } else if (first) { + os << "0"; + } } -inline std::ostream & -operator<<(std::ostream &os, - const struct ur_program_native_properties_t params) { - os << "(struct ur_program_native_properties_t){"; +} // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, + const struct ur_usm_desc_t params) { + os << "(struct ur_usm_desc_t){"; os << ".stype = "; @@ -7110,17 +6931,21 @@ operator<<(std::ostream &os, ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".isNativeHandleOwned = "; + os << ".hints = "; - os << (params.isNativeHandleOwned); + ur_params::serializeFlag(os, (params.hints)); + + os << ", "; + os << ".align = "; + + os << (params.align); os << "}"; return os; } -inline std::ostream & -operator<<(std::ostream &os, - const struct ur_kernel_arg_value_properties_t params) { - os << "(struct ur_kernel_arg_value_properties_t){"; +inline std::ostream &operator<<(std::ostream &os, + const struct ur_usm_host_desc_t params) { + os << "(struct ur_usm_host_desc_t){"; os << ".stype = "; @@ -7131,13 +6956,17 @@ operator<<(std::ostream &os, ur_params::serializeStruct(os, (params.pNext)); + os << ", "; + os << ".flags = "; + + ur_params::serializeFlag(os, (params.flags)); + os << "}"; return os; } -inline std::ostream & -operator<<(std::ostream &os, - const struct ur_kernel_arg_local_properties_t params) { - os << "(struct ur_kernel_arg_local_properties_t){"; +inline std::ostream &operator<<(std::ostream &os, + const struct ur_usm_device_desc_t params) { + os << "(struct ur_usm_device_desc_t){"; os << ".stype = "; @@ -7148,296 +6977,71 @@ operator<<(std::ostream &os, ur_params::serializeStruct(os, (params.pNext)); - os << "}"; - return os; -} -inline std::ostream &operator<<(std::ostream &os, enum ur_kernel_info_t value) { - switch (value) { - - case UR_KERNEL_INFO_FUNCTION_NAME: - os << "UR_KERNEL_INFO_FUNCTION_NAME"; - break; - - case UR_KERNEL_INFO_NUM_ARGS: - os << "UR_KERNEL_INFO_NUM_ARGS"; - break; - - case UR_KERNEL_INFO_REFERENCE_COUNT: - os << "UR_KERNEL_INFO_REFERENCE_COUNT"; - break; - - case UR_KERNEL_INFO_CONTEXT: - os << "UR_KERNEL_INFO_CONTEXT"; - break; - - case UR_KERNEL_INFO_PROGRAM: - os << "UR_KERNEL_INFO_PROGRAM"; - break; + os << ", "; + os << ".flags = "; - case UR_KERNEL_INFO_ATTRIBUTES: - os << "UR_KERNEL_INFO_ATTRIBUTES"; - break; + ur_params::serializeFlag(os, (params.flags)); - case UR_KERNEL_INFO_NUM_REGS: - os << "UR_KERNEL_INFO_NUM_REGS"; - break; - default: - os << "unknown enumerator"; - break; - } + os << "}"; return os; } -namespace ur_params { -template <> -inline void serializeTagged(std::ostream &os, const void *ptr, - ur_kernel_info_t value, size_t size) { - if (ptr == NULL) { - serializePtr(os, ptr); - return; - } - - switch (value) { - - case UR_KERNEL_INFO_FUNCTION_NAME: { - - const char *tptr = (const char *)ptr; - serializePtr(os, tptr); - } break; - - case UR_KERNEL_INFO_NUM_ARGS: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; - - case UR_KERNEL_INFO_REFERENCE_COUNT: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; - - case UR_KERNEL_INFO_CONTEXT: { - const ur_context_handle_t *tptr = (const ur_context_handle_t *)ptr; - if (sizeof(ur_context_handle_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_context_handle_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - ur_params::serializePtr(os, *tptr); - - os << ")"; - } break; - - case UR_KERNEL_INFO_PROGRAM: { - const ur_program_handle_t *tptr = (const ur_program_handle_t *)ptr; - if (sizeof(ur_program_handle_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_program_handle_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - ur_params::serializePtr(os, *tptr); - - os << ")"; - } break; - - case UR_KERNEL_INFO_ATTRIBUTES: { - - const char *tptr = (const char *)ptr; - serializePtr(os, tptr); - } break; - - case UR_KERNEL_INFO_NUM_REGS: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; - default: - os << "unknown enumerator"; - break; - } -} -} // namespace ur_params inline std::ostream &operator<<(std::ostream &os, - enum ur_kernel_group_info_t value) { - switch (value) { + const struct ur_usm_pool_desc_t params) { + os << "(struct ur_usm_pool_desc_t){"; - case UR_KERNEL_GROUP_INFO_GLOBAL_WORK_SIZE: - os << "UR_KERNEL_GROUP_INFO_GLOBAL_WORK_SIZE"; - break; + os << ".stype = "; - case UR_KERNEL_GROUP_INFO_WORK_GROUP_SIZE: - os << "UR_KERNEL_GROUP_INFO_WORK_GROUP_SIZE"; - break; + os << (params.stype); - case UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE: - os << "UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE"; - break; + os << ", "; + os << ".pNext = "; - case UR_KERNEL_GROUP_INFO_LOCAL_MEM_SIZE: - os << "UR_KERNEL_GROUP_INFO_LOCAL_MEM_SIZE"; - break; + ur_params::serializeStruct(os, (params.pNext)); - case UR_KERNEL_GROUP_INFO_PREFERRED_WORK_GROUP_SIZE_MULTIPLE: - os << "UR_KERNEL_GROUP_INFO_PREFERRED_WORK_GROUP_SIZE_MULTIPLE"; - break; + os << ", "; + os << ".flags = "; - case UR_KERNEL_GROUP_INFO_PRIVATE_MEM_SIZE: - os << "UR_KERNEL_GROUP_INFO_PRIVATE_MEM_SIZE"; - break; - default: - os << "unknown enumerator"; - break; - } + ur_params::serializeFlag(os, (params.flags)); + + os << "}"; return os; } -namespace ur_params { -template <> -inline void serializeTagged(std::ostream &os, const void *ptr, - ur_kernel_group_info_t value, size_t size) { - if (ptr == NULL) { - serializePtr(os, ptr); - return; - } - - switch (value) { - - case UR_KERNEL_GROUP_INFO_GLOBAL_WORK_SIZE: { - - const size_t *tptr = (const size_t *)ptr; - os << "{"; - size_t nelems = size / sizeof(size_t); - for (size_t i = 0; i < nelems; ++i) { - if (i != 0) { - os << ", "; - } - - os << tptr[i]; - } - os << "}"; - } break; - - case UR_KERNEL_GROUP_INFO_WORK_GROUP_SIZE: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; - - case UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE: { - - const size_t *tptr = (const size_t *)ptr; - os << "{"; - size_t nelems = size / sizeof(size_t); - for (size_t i = 0; i < nelems; ++i) { - if (i != 0) { - os << ", "; - } - - os << tptr[i]; - } - os << "}"; - } break; +inline std::ostream &operator<<(std::ostream &os, + const struct ur_usm_pool_limits_desc_t params) { + os << "(struct ur_usm_pool_limits_desc_t){"; - case UR_KERNEL_GROUP_INFO_LOCAL_MEM_SIZE: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + os << ".stype = "; - os << *tptr; + os << (params.stype); - os << ")"; - } break; + os << ", "; + os << ".pNext = "; - case UR_KERNEL_GROUP_INFO_PREFERRED_WORK_GROUP_SIZE_MULTIPLE: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + ur_params::serializeStruct(os, (params.pNext)); - os << *tptr; + os << ", "; + os << ".maxPoolableSize = "; - os << ")"; - } break; + os << (params.maxPoolableSize); - case UR_KERNEL_GROUP_INFO_PRIVATE_MEM_SIZE: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + os << ", "; + os << ".minDriverAllocSize = "; - os << *tptr; + os << (params.minDriverAllocSize); - os << ")"; - } break; - default: - os << "unknown enumerator"; - break; - } + os << "}"; + return os; } -} // namespace ur_params inline std::ostream &operator<<(std::ostream &os, - enum ur_kernel_sub_group_info_t value) { + enum ur_usm_pool_info_t value) { switch (value) { - case UR_KERNEL_SUB_GROUP_INFO_MAX_SUB_GROUP_SIZE: - os << "UR_KERNEL_SUB_GROUP_INFO_MAX_SUB_GROUP_SIZE"; - break; - - case UR_KERNEL_SUB_GROUP_INFO_MAX_NUM_SUB_GROUPS: - os << "UR_KERNEL_SUB_GROUP_INFO_MAX_NUM_SUB_GROUPS"; - break; - - case UR_KERNEL_SUB_GROUP_INFO_COMPILE_NUM_SUB_GROUPS: - os << "UR_KERNEL_SUB_GROUP_INFO_COMPILE_NUM_SUB_GROUPS"; + case UR_USM_POOL_INFO_REFERENCE_COUNT: + os << "UR_USM_POOL_INFO_REFERENCE_COUNT"; break; - case UR_KERNEL_SUB_GROUP_INFO_SUB_GROUP_SIZE_INTEL: - os << "UR_KERNEL_SUB_GROUP_INFO_SUB_GROUP_SIZE_INTEL"; + case UR_USM_POOL_INFO_CONTEXT: + os << "UR_USM_POOL_INFO_CONTEXT"; break; default: os << "unknown enumerator"; @@ -7448,7 +7052,7 @@ inline std::ostream &operator<<(std::ostream &os, namespace ur_params { template <> inline void serializeTagged(std::ostream &os, const void *ptr, - ur_kernel_sub_group_info_t value, size_t size) { + ur_usm_pool_info_t value, size_t size) { if (ptr == NULL) { serializePtr(os, ptr); return; @@ -7456,7 +7060,7 @@ inline void serializeTagged(std::ostream &os, const void *ptr, switch (value) { - case UR_KERNEL_SUB_GROUP_INFO_MAX_SUB_GROUP_SIZE: { + case UR_USM_POOL_INFO_REFERENCE_COUNT: { const uint32_t *tptr = (const uint32_t *)ptr; if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size @@ -7470,25 +7074,59 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_KERNEL_SUB_GROUP_INFO_MAX_NUM_SUB_GROUPS: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { + case UR_USM_POOL_INFO_CONTEXT: { + const ur_context_handle_t *tptr = (const ur_context_handle_t *)ptr; + if (sizeof(ur_context_handle_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; + << ", expected: >=" << sizeof(ur_context_handle_t) << ")"; return; } os << (void *)(tptr) << " ("; - os << *tptr; + ur_params::serializePtr(os, *tptr); os << ")"; } break; + default: + os << "unknown enumerator"; + break; + } +} +} // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, + enum ur_virtual_mem_granularity_info_t value) { + switch (value) { - case UR_KERNEL_SUB_GROUP_INFO_COMPILE_NUM_SUB_GROUPS: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { + case UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM: + os << "UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM"; + break; + + case UR_VIRTUAL_MEM_GRANULARITY_INFO_RECOMMENDED: + os << "UR_VIRTUAL_MEM_GRANULARITY_INFO_RECOMMENDED"; + break; + default: + os << "unknown enumerator"; + break; + } + return os; +} +namespace ur_params { +template <> +inline void serializeTagged(std::ostream &os, const void *ptr, + ur_virtual_mem_granularity_info_t value, + size_t size) { + if (ptr == NULL) { + serializePtr(os, ptr); + return; + } + + switch (value) { + + case UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; + << ", expected: >=" << sizeof(size_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -7498,11 +7136,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_KERNEL_SUB_GROUP_INFO_SUB_GROUP_SIZE_INTEL: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { + case UR_VIRTUAL_MEM_GRANULARITY_INFO_RECOMMENDED: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; + << ", expected: >=" << sizeof(size_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -7518,19 +7156,19 @@ inline void serializeTagged(std::ostream &os, const void *ptr, } } // namespace ur_params inline std::ostream &operator<<(std::ostream &os, - enum ur_kernel_cache_config_t value) { + enum ur_virtual_mem_access_flag_t value) { switch (value) { - case UR_KERNEL_CACHE_CONFIG_DEFAULT: - os << "UR_KERNEL_CACHE_CONFIG_DEFAULT"; + case UR_VIRTUAL_MEM_ACCESS_FLAG_NONE: + os << "UR_VIRTUAL_MEM_ACCESS_FLAG_NONE"; break; - case UR_KERNEL_CACHE_CONFIG_LARGE_SLM: - os << "UR_KERNEL_CACHE_CONFIG_LARGE_SLM"; + case UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE: + os << "UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE"; break; - case UR_KERNEL_CACHE_CONFIG_LARGE_DATA: - os << "UR_KERNEL_CACHE_CONFIG_LARGE_DATA"; + case UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY: + os << "UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY"; break; default: os << "unknown enumerator"; @@ -7538,20 +7176,63 @@ inline std::ostream &operator<<(std::ostream &os, } return os; } -inline std::ostream &operator<<(std::ostream &os, - enum ur_kernel_exec_info_t value) { - switch (value) { +namespace ur_params { - case UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS: - os << "UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS"; - break; +template <> +inline void serializeFlag(std::ostream &os, + uint32_t flag) { + uint32_t val = flag; + bool first = true; - case UR_KERNEL_EXEC_INFO_USM_PTRS: - os << "UR_KERNEL_EXEC_INFO_USM_PTRS"; - break; + if ((val & UR_VIRTUAL_MEM_ACCESS_FLAG_NONE) == + (uint32_t)UR_VIRTUAL_MEM_ACCESS_FLAG_NONE) { + val ^= (uint32_t)UR_VIRTUAL_MEM_ACCESS_FLAG_NONE; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_VIRTUAL_MEM_ACCESS_FLAG_NONE; + } - case UR_KERNEL_EXEC_INFO_CACHE_CONFIG: - os << "UR_KERNEL_EXEC_INFO_CACHE_CONFIG"; + if ((val & UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE) == + (uint32_t)UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE) { + val ^= (uint32_t)UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE; + } + + if ((val & UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY) == + (uint32_t)UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY) { + val ^= (uint32_t)UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY; + } + if (val != 0) { + std::bitset<32> bits(val); + if (!first) { + os << " | "; + } + os << "unknown bit flags " << bits; + } else if (first) { + os << "0"; + } +} +} // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, + enum ur_virtual_mem_info_t value) { + switch (value) { + + case UR_VIRTUAL_MEM_INFO_ACCESS_MODE: + os << "UR_VIRTUAL_MEM_INFO_ACCESS_MODE"; break; default: os << "unknown enumerator"; @@ -7562,7 +7243,7 @@ inline std::ostream &operator<<(std::ostream &os, namespace ur_params { template <> inline void serializeTagged(std::ostream &os, const void *ptr, - ur_kernel_exec_info_t value, size_t size) { + ur_virtual_mem_info_t value, size_t size) { if (ptr == NULL) { serializePtr(os, ptr); return; @@ -7570,46 +7251,18 @@ inline void serializeTagged(std::ostream &os, const void *ptr, switch (value) { - case UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS: { - const ur_bool_t *tptr = (const ur_bool_t *)ptr; - if (sizeof(ur_bool_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_bool_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; - - case UR_KERNEL_EXEC_INFO_USM_PTRS: { - - const void **tptr = (const void **)ptr; - os << "{"; - size_t nelems = size / sizeof(void *); - for (size_t i = 0; i < nelems; ++i) { - if (i != 0) { - os << ", "; - } - - os << tptr[i]; - } - os << "}"; - } break; - - case UR_KERNEL_EXEC_INFO_CACHE_CONFIG: { - const ur_kernel_cache_config_t *tptr = - (const ur_kernel_cache_config_t *)ptr; - if (sizeof(ur_kernel_cache_config_t) > size) { + case UR_VIRTUAL_MEM_INFO_ACCESS_MODE: { + const ur_virtual_mem_access_flags_t *tptr = + (const ur_virtual_mem_access_flags_t *)ptr; + if (sizeof(ur_virtual_mem_access_flags_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_kernel_cache_config_t) << ")"; + << ", expected: >=" << sizeof(ur_virtual_mem_access_flags_t) + << ")"; return; } os << (void *)(tptr) << " ("; - os << *tptr; + ur_params::serializeFlag(os, *tptr); os << ")"; } break; @@ -7619,10 +7272,51 @@ inline void serializeTagged(std::ostream &os, const void *ptr, } } } // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, + enum ur_physical_mem_flag_t value) { + switch (value) { + + case UR_PHYSICAL_MEM_FLAG_TBD: + os << "UR_PHYSICAL_MEM_FLAG_TBD"; + break; + default: + os << "unknown enumerator"; + break; + } + return os; +} +namespace ur_params { + +template <> +inline void serializeFlag(std::ostream &os, + uint32_t flag) { + uint32_t val = flag; + bool first = true; + + if ((val & UR_PHYSICAL_MEM_FLAG_TBD) == + (uint32_t)UR_PHYSICAL_MEM_FLAG_TBD) { + val ^= (uint32_t)UR_PHYSICAL_MEM_FLAG_TBD; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_PHYSICAL_MEM_FLAG_TBD; + } + if (val != 0) { + std::bitset<32> bits(val); + if (!first) { + os << " | "; + } + os << "unknown bit flags " << bits; + } else if (first) { + os << "0"; + } +} +} // namespace ur_params inline std::ostream & -operator<<(std::ostream &os, - const struct ur_kernel_arg_pointer_properties_t params) { - os << "(struct ur_kernel_arg_pointer_properties_t){"; +operator<<(std::ostream &os, const struct ur_physical_mem_properties_t params) { + os << "(struct ur_physical_mem_properties_t){"; os << ".stype = "; @@ -7633,69 +7327,94 @@ operator<<(std::ostream &os, ur_params::serializeStruct(os, (params.pNext)); + os << ", "; + os << ".flags = "; + + ur_params::serializeFlag(os, (params.flags)); + os << "}"; return os; } -inline std::ostream & -operator<<(std::ostream &os, - const struct ur_kernel_exec_info_properties_t params) { - os << "(struct ur_kernel_exec_info_properties_t){"; - - os << ".stype = "; +inline std::ostream &operator<<(std::ostream &os, + enum ur_program_metadata_type_t value) { + switch (value) { - os << (params.stype); + case UR_PROGRAM_METADATA_TYPE_UINT32: + os << "UR_PROGRAM_METADATA_TYPE_UINT32"; + break; - os << ", "; - os << ".pNext = "; + case UR_PROGRAM_METADATA_TYPE_UINT64: + os << "UR_PROGRAM_METADATA_TYPE_UINT64"; + break; - ur_params::serializeStruct(os, (params.pNext)); + case UR_PROGRAM_METADATA_TYPE_BYTE_ARRAY: + os << "UR_PROGRAM_METADATA_TYPE_BYTE_ARRAY"; + break; - os << "}"; + case UR_PROGRAM_METADATA_TYPE_STRING: + os << "UR_PROGRAM_METADATA_TYPE_STRING"; + break; + default: + os << "unknown enumerator"; + break; + } return os; } inline std::ostream & -operator<<(std::ostream &os, - const struct ur_kernel_arg_sampler_properties_t params) { - os << "(struct ur_kernel_arg_sampler_properties_t){"; +operator<<(std::ostream &os, const union ur_program_metadata_value_t params) { + os << "(union ur_program_metadata_value_t){"; - os << ".stype = "; + os << ".data32 = "; - os << (params.stype); + os << (params.data32); os << ", "; - os << ".pNext = "; + os << ".data64 = "; - ur_params::serializeStruct(os, (params.pNext)); + os << (params.data64); + + os << ", "; + os << ".pString = "; + + ur_params::serializePtr(os, (params.pString)); + + os << ", "; + os << ".pData = "; + + ur_params::serializePtr(os, (params.pData)); os << "}"; return os; } -inline std::ostream & -operator<<(std::ostream &os, - const struct ur_kernel_arg_mem_obj_properties_t params) { - os << "(struct ur_kernel_arg_mem_obj_properties_t){"; +inline std::ostream &operator<<(std::ostream &os, + const struct ur_program_metadata_t params) { + os << "(struct ur_program_metadata_t){"; - os << ".stype = "; + os << ".pName = "; - os << (params.stype); + ur_params::serializePtr(os, (params.pName)); os << ", "; - os << ".pNext = "; + os << ".type = "; - ur_params::serializeStruct(os, (params.pNext)); + os << (params.type); os << ", "; - os << ".memoryAccess = "; + os << ".size = "; - ur_params::serializeFlag(os, (params.memoryAccess)); + os << (params.size); + + os << ", "; + os << ".value = "; + + os << (params.value); os << "}"; return os; } -inline std::ostream & -operator<<(std::ostream &os, - const struct ur_kernel_native_properties_t params) { - os << "(struct ur_kernel_native_properties_t){"; +inline std::ostream &operator<<(std::ostream &os, + const struct ur_program_properties_t params) { + os << "(struct ur_program_properties_t){"; os << ".stype = "; @@ -7707,42 +7426,62 @@ operator<<(std::ostream &os, ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".isNativeHandleOwned = "; + os << ".count = "; - os << (params.isNativeHandleOwned); + os << (params.count); + + os << ", "; + os << ".pMetadatas = {"; + for (size_t i = 0; (params.pMetadatas) != NULL && i < params.count; ++i) { + if (i != 0) { + os << ", "; + } + + os << ((params.pMetadatas))[i]; + } + os << "}"; os << "}"; return os; } -inline std::ostream &operator<<(std::ostream &os, enum ur_queue_info_t value) { +inline std::ostream &operator<<(std::ostream &os, + enum ur_program_info_t value) { switch (value) { - case UR_QUEUE_INFO_CONTEXT: - os << "UR_QUEUE_INFO_CONTEXT"; + case UR_PROGRAM_INFO_REFERENCE_COUNT: + os << "UR_PROGRAM_INFO_REFERENCE_COUNT"; break; - case UR_QUEUE_INFO_DEVICE: - os << "UR_QUEUE_INFO_DEVICE"; + case UR_PROGRAM_INFO_CONTEXT: + os << "UR_PROGRAM_INFO_CONTEXT"; break; - case UR_QUEUE_INFO_DEVICE_DEFAULT: - os << "UR_QUEUE_INFO_DEVICE_DEFAULT"; + case UR_PROGRAM_INFO_NUM_DEVICES: + os << "UR_PROGRAM_INFO_NUM_DEVICES"; break; - case UR_QUEUE_INFO_FLAGS: - os << "UR_QUEUE_INFO_FLAGS"; + case UR_PROGRAM_INFO_DEVICES: + os << "UR_PROGRAM_INFO_DEVICES"; break; - case UR_QUEUE_INFO_REFERENCE_COUNT: - os << "UR_QUEUE_INFO_REFERENCE_COUNT"; + case UR_PROGRAM_INFO_SOURCE: + os << "UR_PROGRAM_INFO_SOURCE"; break; - case UR_QUEUE_INFO_SIZE: - os << "UR_QUEUE_INFO_SIZE"; + case UR_PROGRAM_INFO_BINARY_SIZES: + os << "UR_PROGRAM_INFO_BINARY_SIZES"; break; - case UR_QUEUE_INFO_EMPTY: - os << "UR_QUEUE_INFO_EMPTY"; + case UR_PROGRAM_INFO_BINARIES: + os << "UR_PROGRAM_INFO_BINARIES"; + break; + + case UR_PROGRAM_INFO_NUM_KERNELS: + os << "UR_PROGRAM_INFO_NUM_KERNELS"; + break; + + case UR_PROGRAM_INFO_KERNEL_NAMES: + os << "UR_PROGRAM_INFO_KERNEL_NAMES"; break; default: os << "unknown enumerator"; @@ -7753,7 +7492,7 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_queue_info_t value) { namespace ur_params { template <> inline void serializeTagged(std::ostream &os, const void *ptr, - ur_queue_info_t value, size_t size) { + ur_program_info_t value, size_t size) { if (ptr == NULL) { serializePtr(os, ptr); return; @@ -7761,25 +7500,25 @@ inline void serializeTagged(std::ostream &os, const void *ptr, switch (value) { - case UR_QUEUE_INFO_CONTEXT: { - const ur_queue_handle_t *tptr = (const ur_queue_handle_t *)ptr; - if (sizeof(ur_queue_handle_t) > size) { + case UR_PROGRAM_INFO_REFERENCE_COUNT: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_queue_handle_t) << ")"; + << ", expected: >=" << sizeof(uint32_t) << ")"; return; } os << (void *)(tptr) << " ("; - ur_params::serializePtr(os, *tptr); + os << *tptr; os << ")"; } break; - case UR_QUEUE_INFO_DEVICE: { - const ur_device_handle_t *tptr = (const ur_device_handle_t *)ptr; - if (sizeof(ur_device_handle_t) > size) { + case UR_PROGRAM_INFO_CONTEXT: { + const ur_context_handle_t *tptr = (const ur_context_handle_t *)ptr; + if (sizeof(ur_context_handle_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_device_handle_t) << ")"; + << ", expected: >=" << sizeof(ur_context_handle_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -7789,53 +7528,67 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_QUEUE_INFO_DEVICE_DEFAULT: { - const ur_queue_handle_t *tptr = (const ur_queue_handle_t *)ptr; - if (sizeof(ur_queue_handle_t) > size) { + case UR_PROGRAM_INFO_NUM_DEVICES: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_queue_handle_t) << ")"; + << ", expected: >=" << sizeof(uint32_t) << ")"; return; } os << (void *)(tptr) << " ("; - ur_params::serializePtr(os, *tptr); + os << *tptr; os << ")"; } break; - case UR_QUEUE_INFO_FLAGS: { - const ur_queue_flags_t *tptr = (const ur_queue_flags_t *)ptr; - if (sizeof(ur_queue_flags_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_queue_flags_t) << ")"; - return; + case UR_PROGRAM_INFO_DEVICES: { + + const ur_device_handle_t *tptr = (const ur_device_handle_t *)ptr; + os << "{"; + size_t nelems = size / sizeof(ur_device_handle_t); + for (size_t i = 0; i < nelems; ++i) { + if (i != 0) { + os << ", "; + } + + ur_params::serializePtr(os, tptr[i]); } - os << (void *)(tptr) << " ("; + os << "}"; + } break; - ur_params::serializeFlag(os, *tptr); + case UR_PROGRAM_INFO_SOURCE: { - os << ")"; + const char *tptr = (const char *)ptr; + serializePtr(os, tptr); } break; - case UR_QUEUE_INFO_REFERENCE_COUNT: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; + case UR_PROGRAM_INFO_BINARY_SIZES: { + + const size_t *tptr = (const size_t *)ptr; + os << "{"; + size_t nelems = size / sizeof(size_t); + for (size_t i = 0; i < nelems; ++i) { + if (i != 0) { + os << ", "; + } + + os << tptr[i]; } - os << (void *)(tptr) << " ("; + os << "}"; + } break; - os << *tptr; + case UR_PROGRAM_INFO_BINARIES: { - os << ")"; + const unsigned char *tptr = (const unsigned char *)ptr; + serializePtr(os, tptr); } break; - case UR_QUEUE_INFO_SIZE: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { + case UR_PROGRAM_INFO_NUM_KERNELS: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; + << ", expected: >=" << sizeof(size_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -7845,18 +7598,10 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_QUEUE_INFO_EMPTY: { - const ur_bool_t *tptr = (const ur_bool_t *)ptr; - if (sizeof(ur_bool_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_bool_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; + case UR_PROGRAM_INFO_KERNEL_NAMES: { - os << ")"; + const char *tptr = (const char *)ptr; + serializePtr(os, tptr); } break; default: os << "unknown enumerator"; @@ -7864,51 +7609,74 @@ inline void serializeTagged(std::ostream &os, const void *ptr, } } } // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, enum ur_queue_flag_t value) { +inline std::ostream &operator<<(std::ostream &os, + enum ur_program_build_status_t value) { switch (value) { - case UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE: - os << "UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE"; + case UR_PROGRAM_BUILD_STATUS_NONE: + os << "UR_PROGRAM_BUILD_STATUS_NONE"; break; - case UR_QUEUE_FLAG_PROFILING_ENABLE: - os << "UR_QUEUE_FLAG_PROFILING_ENABLE"; + case UR_PROGRAM_BUILD_STATUS_ERROR: + os << "UR_PROGRAM_BUILD_STATUS_ERROR"; break; - case UR_QUEUE_FLAG_ON_DEVICE: - os << "UR_QUEUE_FLAG_ON_DEVICE"; + case UR_PROGRAM_BUILD_STATUS_SUCCESS: + os << "UR_PROGRAM_BUILD_STATUS_SUCCESS"; break; - case UR_QUEUE_FLAG_ON_DEVICE_DEFAULT: - os << "UR_QUEUE_FLAG_ON_DEVICE_DEFAULT"; + case UR_PROGRAM_BUILD_STATUS_IN_PROGRESS: + os << "UR_PROGRAM_BUILD_STATUS_IN_PROGRESS"; + break; + default: + os << "unknown enumerator"; + break; + } + return os; +} +inline std::ostream &operator<<(std::ostream &os, + enum ur_program_binary_type_t value) { + switch (value) { + + case UR_PROGRAM_BINARY_TYPE_NONE: + os << "UR_PROGRAM_BINARY_TYPE_NONE"; break; - case UR_QUEUE_FLAG_DISCARD_EVENTS: - os << "UR_QUEUE_FLAG_DISCARD_EVENTS"; + case UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT: + os << "UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT"; break; - case UR_QUEUE_FLAG_PRIORITY_LOW: - os << "UR_QUEUE_FLAG_PRIORITY_LOW"; + case UR_PROGRAM_BINARY_TYPE_LIBRARY: + os << "UR_PROGRAM_BINARY_TYPE_LIBRARY"; break; - case UR_QUEUE_FLAG_PRIORITY_HIGH: - os << "UR_QUEUE_FLAG_PRIORITY_HIGH"; + case UR_PROGRAM_BINARY_TYPE_EXECUTABLE: + os << "UR_PROGRAM_BINARY_TYPE_EXECUTABLE"; + break; + default: + os << "unknown enumerator"; break; + } + return os; +} +inline std::ostream &operator<<(std::ostream &os, + enum ur_program_build_info_t value) { + switch (value) { - case UR_QUEUE_FLAG_SUBMISSION_BATCHED: - os << "UR_QUEUE_FLAG_SUBMISSION_BATCHED"; + case UR_PROGRAM_BUILD_INFO_STATUS: + os << "UR_PROGRAM_BUILD_INFO_STATUS"; break; - case UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE: - os << "UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE"; + case UR_PROGRAM_BUILD_INFO_OPTIONS: + os << "UR_PROGRAM_BUILD_INFO_OPTIONS"; break; - case UR_QUEUE_FLAG_USE_DEFAULT_STREAM: - os << "UR_QUEUE_FLAG_USE_DEFAULT_STREAM"; + case UR_PROGRAM_BUILD_INFO_LOG: + os << "UR_PROGRAM_BUILD_INFO_LOG"; break; - case UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM: - os << "UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM"; + case UR_PROGRAM_BUILD_INFO_BINARY_TYPE: + os << "UR_PROGRAM_BUILD_INFO_BINARY_TYPE"; break; default: os << "unknown enumerator"; @@ -7917,166 +7685,89 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_queue_flag_t value) { return os; } namespace ur_params { - template <> -inline void serializeFlag(std::ostream &os, uint32_t flag) { - uint32_t val = flag; - bool first = true; - - if ((val & UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE) == - (uint32_t)UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE) { - val ^= (uint32_t)UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE; - } - - if ((val & UR_QUEUE_FLAG_PROFILING_ENABLE) == - (uint32_t)UR_QUEUE_FLAG_PROFILING_ENABLE) { - val ^= (uint32_t)UR_QUEUE_FLAG_PROFILING_ENABLE; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_QUEUE_FLAG_PROFILING_ENABLE; +inline void serializeTagged(std::ostream &os, const void *ptr, + ur_program_build_info_t value, size_t size) { + if (ptr == NULL) { + serializePtr(os, ptr); + return; } - if ((val & UR_QUEUE_FLAG_ON_DEVICE) == (uint32_t)UR_QUEUE_FLAG_ON_DEVICE) { - val ^= (uint32_t)UR_QUEUE_FLAG_ON_DEVICE; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_QUEUE_FLAG_ON_DEVICE; - } + switch (value) { - if ((val & UR_QUEUE_FLAG_ON_DEVICE_DEFAULT) == - (uint32_t)UR_QUEUE_FLAG_ON_DEVICE_DEFAULT) { - val ^= (uint32_t)UR_QUEUE_FLAG_ON_DEVICE_DEFAULT; - if (!first) { - os << " | "; - } else { - first = false; + case UR_PROGRAM_BUILD_INFO_STATUS: { + const ur_program_build_status_t *tptr = + (const ur_program_build_status_t *)ptr; + if (sizeof(ur_program_build_status_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_program_build_status_t) << ")"; + return; } - os << UR_QUEUE_FLAG_ON_DEVICE_DEFAULT; - } + os << (void *)(tptr) << " ("; - if ((val & UR_QUEUE_FLAG_DISCARD_EVENTS) == - (uint32_t)UR_QUEUE_FLAG_DISCARD_EVENTS) { - val ^= (uint32_t)UR_QUEUE_FLAG_DISCARD_EVENTS; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_QUEUE_FLAG_DISCARD_EVENTS; - } + os << *tptr; - if ((val & UR_QUEUE_FLAG_PRIORITY_LOW) == - (uint32_t)UR_QUEUE_FLAG_PRIORITY_LOW) { - val ^= (uint32_t)UR_QUEUE_FLAG_PRIORITY_LOW; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_QUEUE_FLAG_PRIORITY_LOW; - } + os << ")"; + } break; - if ((val & UR_QUEUE_FLAG_PRIORITY_HIGH) == - (uint32_t)UR_QUEUE_FLAG_PRIORITY_HIGH) { - val ^= (uint32_t)UR_QUEUE_FLAG_PRIORITY_HIGH; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_QUEUE_FLAG_PRIORITY_HIGH; - } + case UR_PROGRAM_BUILD_INFO_OPTIONS: { - if ((val & UR_QUEUE_FLAG_SUBMISSION_BATCHED) == - (uint32_t)UR_QUEUE_FLAG_SUBMISSION_BATCHED) { - val ^= (uint32_t)UR_QUEUE_FLAG_SUBMISSION_BATCHED; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_QUEUE_FLAG_SUBMISSION_BATCHED; - } + const char *tptr = (const char *)ptr; + serializePtr(os, tptr); + } break; - if ((val & UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE) == - (uint32_t)UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE) { - val ^= (uint32_t)UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE; - } + case UR_PROGRAM_BUILD_INFO_LOG: { - if ((val & UR_QUEUE_FLAG_USE_DEFAULT_STREAM) == - (uint32_t)UR_QUEUE_FLAG_USE_DEFAULT_STREAM) { - val ^= (uint32_t)UR_QUEUE_FLAG_USE_DEFAULT_STREAM; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_QUEUE_FLAG_USE_DEFAULT_STREAM; - } + const char *tptr = (const char *)ptr; + serializePtr(os, tptr); + } break; - if ((val & UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM) == - (uint32_t)UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM) { - val ^= (uint32_t)UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM; - } - if (val != 0) { - std::bitset<32> bits(val); - if (!first) { - os << " | "; + case UR_PROGRAM_BUILD_INFO_BINARY_TYPE: { + const ur_program_binary_type_t *tptr = + (const ur_program_binary_type_t *)ptr; + if (sizeof(ur_program_binary_type_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_program_binary_type_t) << ")"; + return; } - os << "unknown bit flags " << bits; - } else if (first) { - os << "0"; + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + default: + os << "unknown enumerator"; + break; } } } // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, - const struct ur_queue_properties_t params) { - os << "(struct ur_queue_properties_t){"; +inline std::ostream & +operator<<(std::ostream &os, + const struct ur_specialization_constant_info_t params) { + os << "(struct ur_specialization_constant_info_t){"; - os << ".stype = "; + os << ".id = "; - os << (params.stype); + os << (params.id); os << ", "; - os << ".pNext = "; + os << ".size = "; - ur_params::serializeStruct(os, (params.pNext)); + os << (params.size); os << ", "; - os << ".flags = "; + os << ".pValue = "; - ur_params::serializeFlag(os, (params.flags)); + ur_params::serializePtr(os, (params.pValue)); os << "}"; return os; } inline std::ostream & -operator<<(std::ostream &os, const struct ur_queue_index_properties_t params) { - os << "(struct ur_queue_index_properties_t){"; +operator<<(std::ostream &os, + const struct ur_program_native_properties_t params) { + os << "(struct ur_program_native_properties_t){"; os << ".stype = "; @@ -8088,16 +7779,17 @@ operator<<(std::ostream &os, const struct ur_queue_index_properties_t params) { ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".computeIndex = "; + os << ".isNativeHandleOwned = "; - os << (params.computeIndex); + os << (params.isNativeHandleOwned); os << "}"; return os; } -inline std::ostream &operator<<(std::ostream &os, - const struct ur_queue_native_desc_t params) { - os << "(struct ur_queue_native_desc_t){"; +inline std::ostream & +operator<<(std::ostream &os, + const struct ur_kernel_arg_value_properties_t params) { + os << "(struct ur_kernel_arg_value_properties_t){"; os << ".stype = "; @@ -8108,201 +7800,427 @@ inline std::ostream &operator<<(std::ostream &os, ur_params::serializeStruct(os, (params.pNext)); - os << ", "; - os << ".pNativeData = "; - - ur_params::serializePtr(os, (params.pNativeData)); - os << "}"; return os; } inline std::ostream & -operator<<(std::ostream &os, const struct ur_queue_native_properties_t params) { - os << "(struct ur_queue_native_properties_t){"; +operator<<(std::ostream &os, + const struct ur_kernel_arg_local_properties_t params) { + os << "(struct ur_kernel_arg_local_properties_t){"; os << ".stype = "; os << (params.stype); - os << ", "; - os << ".pNext = "; + os << ", "; + os << ".pNext = "; + + ur_params::serializeStruct(os, (params.pNext)); + + os << "}"; + return os; +} +inline std::ostream &operator<<(std::ostream &os, enum ur_kernel_info_t value) { + switch (value) { + + case UR_KERNEL_INFO_FUNCTION_NAME: + os << "UR_KERNEL_INFO_FUNCTION_NAME"; + break; + + case UR_KERNEL_INFO_NUM_ARGS: + os << "UR_KERNEL_INFO_NUM_ARGS"; + break; + + case UR_KERNEL_INFO_REFERENCE_COUNT: + os << "UR_KERNEL_INFO_REFERENCE_COUNT"; + break; + + case UR_KERNEL_INFO_CONTEXT: + os << "UR_KERNEL_INFO_CONTEXT"; + break; + + case UR_KERNEL_INFO_PROGRAM: + os << "UR_KERNEL_INFO_PROGRAM"; + break; + + case UR_KERNEL_INFO_ATTRIBUTES: + os << "UR_KERNEL_INFO_ATTRIBUTES"; + break; + + case UR_KERNEL_INFO_NUM_REGS: + os << "UR_KERNEL_INFO_NUM_REGS"; + break; + default: + os << "unknown enumerator"; + break; + } + return os; +} +namespace ur_params { +template <> +inline void serializeTagged(std::ostream &os, const void *ptr, + ur_kernel_info_t value, size_t size) { + if (ptr == NULL) { + serializePtr(os, ptr); + return; + } + + switch (value) { + + case UR_KERNEL_INFO_FUNCTION_NAME: { + + const char *tptr = (const char *)ptr; + serializePtr(os, tptr); + } break; + + case UR_KERNEL_INFO_NUM_ARGS: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(size_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_KERNEL_INFO_REFERENCE_COUNT: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_KERNEL_INFO_CONTEXT: { + const ur_context_handle_t *tptr = (const ur_context_handle_t *)ptr; + if (sizeof(ur_context_handle_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_context_handle_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + ur_params::serializePtr(os, *tptr); + + os << ")"; + } break; + + case UR_KERNEL_INFO_PROGRAM: { + const ur_program_handle_t *tptr = (const ur_program_handle_t *)ptr; + if (sizeof(ur_program_handle_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_program_handle_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + ur_params::serializePtr(os, *tptr); + + os << ")"; + } break; + + case UR_KERNEL_INFO_ATTRIBUTES: { + + const char *tptr = (const char *)ptr; + serializePtr(os, tptr); + } break; + + case UR_KERNEL_INFO_NUM_REGS: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + default: + os << "unknown enumerator"; + break; + } +} +} // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, + enum ur_kernel_group_info_t value) { + switch (value) { + + case UR_KERNEL_GROUP_INFO_GLOBAL_WORK_SIZE: + os << "UR_KERNEL_GROUP_INFO_GLOBAL_WORK_SIZE"; + break; + + case UR_KERNEL_GROUP_INFO_WORK_GROUP_SIZE: + os << "UR_KERNEL_GROUP_INFO_WORK_GROUP_SIZE"; + break; + + case UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE: + os << "UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE"; + break; + + case UR_KERNEL_GROUP_INFO_LOCAL_MEM_SIZE: + os << "UR_KERNEL_GROUP_INFO_LOCAL_MEM_SIZE"; + break; + + case UR_KERNEL_GROUP_INFO_PREFERRED_WORK_GROUP_SIZE_MULTIPLE: + os << "UR_KERNEL_GROUP_INFO_PREFERRED_WORK_GROUP_SIZE_MULTIPLE"; + break; + + case UR_KERNEL_GROUP_INFO_PRIVATE_MEM_SIZE: + os << "UR_KERNEL_GROUP_INFO_PRIVATE_MEM_SIZE"; + break; + default: + os << "unknown enumerator"; + break; + } + return os; +} +namespace ur_params { +template <> +inline void serializeTagged(std::ostream &os, const void *ptr, + ur_kernel_group_info_t value, size_t size) { + if (ptr == NULL) { + serializePtr(os, ptr); + return; + } + + switch (value) { + + case UR_KERNEL_GROUP_INFO_GLOBAL_WORK_SIZE: { + + const size_t *tptr = (const size_t *)ptr; + os << "{"; + size_t nelems = size / sizeof(size_t); + for (size_t i = 0; i < nelems; ++i) { + if (i != 0) { + os << ", "; + } + + os << tptr[i]; + } + os << "}"; + } break; + + case UR_KERNEL_GROUP_INFO_WORK_GROUP_SIZE: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(size_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - ur_params::serializeStruct(os, (params.pNext)); + os << *tptr; - os << ", "; - os << ".isNativeHandleOwned = "; + os << ")"; + } break; - os << (params.isNativeHandleOwned); + case UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE: { - os << "}"; - return os; -} -inline std::ostream &operator<<(std::ostream &os, enum ur_command_t value) { - switch (value) { + const size_t *tptr = (const size_t *)ptr; + os << "{"; + size_t nelems = size / sizeof(size_t); + for (size_t i = 0; i < nelems; ++i) { + if (i != 0) { + os << ", "; + } - case UR_COMMAND_KERNEL_LAUNCH: - os << "UR_COMMAND_KERNEL_LAUNCH"; - break; + os << tptr[i]; + } + os << "}"; + } break; - case UR_COMMAND_EVENTS_WAIT: - os << "UR_COMMAND_EVENTS_WAIT"; - break; + case UR_KERNEL_GROUP_INFO_LOCAL_MEM_SIZE: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(size_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_COMMAND_EVENTS_WAIT_WITH_BARRIER: - os << "UR_COMMAND_EVENTS_WAIT_WITH_BARRIER"; - break; + os << *tptr; - case UR_COMMAND_MEM_BUFFER_READ: - os << "UR_COMMAND_MEM_BUFFER_READ"; - break; + os << ")"; + } break; - case UR_COMMAND_MEM_BUFFER_WRITE: - os << "UR_COMMAND_MEM_BUFFER_WRITE"; - break; + case UR_KERNEL_GROUP_INFO_PREFERRED_WORK_GROUP_SIZE_MULTIPLE: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(size_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_COMMAND_MEM_BUFFER_READ_RECT: - os << "UR_COMMAND_MEM_BUFFER_READ_RECT"; - break; + os << *tptr; - case UR_COMMAND_MEM_BUFFER_WRITE_RECT: - os << "UR_COMMAND_MEM_BUFFER_WRITE_RECT"; - break; + os << ")"; + } break; - case UR_COMMAND_MEM_BUFFER_COPY: - os << "UR_COMMAND_MEM_BUFFER_COPY"; - break; + case UR_KERNEL_GROUP_INFO_PRIVATE_MEM_SIZE: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(size_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_COMMAND_MEM_BUFFER_COPY_RECT: - os << "UR_COMMAND_MEM_BUFFER_COPY_RECT"; - break; + os << *tptr; - case UR_COMMAND_MEM_BUFFER_FILL: - os << "UR_COMMAND_MEM_BUFFER_FILL"; + os << ")"; + } break; + default: + os << "unknown enumerator"; break; + } +} +} // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, + enum ur_kernel_sub_group_info_t value) { + switch (value) { - case UR_COMMAND_MEM_IMAGE_READ: - os << "UR_COMMAND_MEM_IMAGE_READ"; + case UR_KERNEL_SUB_GROUP_INFO_MAX_SUB_GROUP_SIZE: + os << "UR_KERNEL_SUB_GROUP_INFO_MAX_SUB_GROUP_SIZE"; break; - case UR_COMMAND_MEM_IMAGE_WRITE: - os << "UR_COMMAND_MEM_IMAGE_WRITE"; + case UR_KERNEL_SUB_GROUP_INFO_MAX_NUM_SUB_GROUPS: + os << "UR_KERNEL_SUB_GROUP_INFO_MAX_NUM_SUB_GROUPS"; break; - case UR_COMMAND_MEM_IMAGE_COPY: - os << "UR_COMMAND_MEM_IMAGE_COPY"; + case UR_KERNEL_SUB_GROUP_INFO_COMPILE_NUM_SUB_GROUPS: + os << "UR_KERNEL_SUB_GROUP_INFO_COMPILE_NUM_SUB_GROUPS"; break; - case UR_COMMAND_MEM_BUFFER_MAP: - os << "UR_COMMAND_MEM_BUFFER_MAP"; + case UR_KERNEL_SUB_GROUP_INFO_SUB_GROUP_SIZE_INTEL: + os << "UR_KERNEL_SUB_GROUP_INFO_SUB_GROUP_SIZE_INTEL"; break; - - case UR_COMMAND_MEM_UNMAP: - os << "UR_COMMAND_MEM_UNMAP"; + default: + os << "unknown enumerator"; break; + } + return os; +} +namespace ur_params { +template <> +inline void serializeTagged(std::ostream &os, const void *ptr, + ur_kernel_sub_group_info_t value, size_t size) { + if (ptr == NULL) { + serializePtr(os, ptr); + return; + } - case UR_COMMAND_USM_FILL: - os << "UR_COMMAND_USM_FILL"; - break; + switch (value) { - case UR_COMMAND_USM_MEMCPY: - os << "UR_COMMAND_USM_MEMCPY"; - break; + case UR_KERNEL_SUB_GROUP_INFO_MAX_SUB_GROUP_SIZE: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_COMMAND_USM_PREFETCH: - os << "UR_COMMAND_USM_PREFETCH"; - break; + os << *tptr; - case UR_COMMAND_USM_ADVISE: - os << "UR_COMMAND_USM_ADVISE"; - break; + os << ")"; + } break; - case UR_COMMAND_USM_FILL_2D: - os << "UR_COMMAND_USM_FILL_2D"; - break; + case UR_KERNEL_SUB_GROUP_INFO_MAX_NUM_SUB_GROUPS: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_COMMAND_USM_MEMCPY_2D: - os << "UR_COMMAND_USM_MEMCPY_2D"; - break; + os << *tptr; - case UR_COMMAND_DEVICE_GLOBAL_VARIABLE_WRITE: - os << "UR_COMMAND_DEVICE_GLOBAL_VARIABLE_WRITE"; - break; + os << ")"; + } break; - case UR_COMMAND_DEVICE_GLOBAL_VARIABLE_READ: - os << "UR_COMMAND_DEVICE_GLOBAL_VARIABLE_READ"; - break; + case UR_KERNEL_SUB_GROUP_INFO_COMPILE_NUM_SUB_GROUPS: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_COMMAND_READ_HOST_PIPE: - os << "UR_COMMAND_READ_HOST_PIPE"; - break; + os << *tptr; - case UR_COMMAND_WRITE_HOST_PIPE: - os << "UR_COMMAND_WRITE_HOST_PIPE"; - break; + os << ")"; + } break; - case UR_COMMAND_COMMAND_BUFFER_ENQUEUE_EXP: - os << "UR_COMMAND_COMMAND_BUFFER_ENQUEUE_EXP"; - break; + case UR_KERNEL_SUB_GROUP_INFO_SUB_GROUP_SIZE_INTEL: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_COMMAND_INTEROP_SEMAPHORE_WAIT_EXP: - os << "UR_COMMAND_INTEROP_SEMAPHORE_WAIT_EXP"; - break; + os << *tptr; - case UR_COMMAND_INTEROP_SEMAPHORE_SIGNAL_EXP: - os << "UR_COMMAND_INTEROP_SEMAPHORE_SIGNAL_EXP"; - break; + os << ")"; + } break; default: os << "unknown enumerator"; break; } - return os; } +} // namespace ur_params inline std::ostream &operator<<(std::ostream &os, - enum ur_event_status_t value) { + enum ur_kernel_cache_config_t value) { switch (value) { - case UR_EVENT_STATUS_COMPLETE: - os << "UR_EVENT_STATUS_COMPLETE"; - break; - - case UR_EVENT_STATUS_RUNNING: - os << "UR_EVENT_STATUS_RUNNING"; + case UR_KERNEL_CACHE_CONFIG_DEFAULT: + os << "UR_KERNEL_CACHE_CONFIG_DEFAULT"; break; - case UR_EVENT_STATUS_SUBMITTED: - os << "UR_EVENT_STATUS_SUBMITTED"; + case UR_KERNEL_CACHE_CONFIG_LARGE_SLM: + os << "UR_KERNEL_CACHE_CONFIG_LARGE_SLM"; break; - case UR_EVENT_STATUS_QUEUED: - os << "UR_EVENT_STATUS_QUEUED"; + case UR_KERNEL_CACHE_CONFIG_LARGE_DATA: + os << "UR_KERNEL_CACHE_CONFIG_LARGE_DATA"; break; default: os << "unknown enumerator"; break; - } - return os; -} -inline std::ostream &operator<<(std::ostream &os, enum ur_event_info_t value) { - switch (value) { - - case UR_EVENT_INFO_COMMAND_QUEUE: - os << "UR_EVENT_INFO_COMMAND_QUEUE"; - break; - - case UR_EVENT_INFO_CONTEXT: - os << "UR_EVENT_INFO_CONTEXT"; - break; + } + return os; +} +inline std::ostream &operator<<(std::ostream &os, + enum ur_kernel_exec_info_t value) { + switch (value) { - case UR_EVENT_INFO_COMMAND_TYPE: - os << "UR_EVENT_INFO_COMMAND_TYPE"; + case UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS: + os << "UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS"; break; - case UR_EVENT_INFO_COMMAND_EXECUTION_STATUS: - os << "UR_EVENT_INFO_COMMAND_EXECUTION_STATUS"; + case UR_KERNEL_EXEC_INFO_USM_PTRS: + os << "UR_KERNEL_EXEC_INFO_USM_PTRS"; break; - case UR_EVENT_INFO_REFERENCE_COUNT: - os << "UR_EVENT_INFO_REFERENCE_COUNT"; + case UR_KERNEL_EXEC_INFO_CACHE_CONFIG: + os << "UR_KERNEL_EXEC_INFO_CACHE_CONFIG"; break; default: os << "unknown enumerator"; @@ -8313,7 +8231,7 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_event_info_t value) { namespace ur_params { template <> inline void serializeTagged(std::ostream &os, const void *ptr, - ur_event_info_t value, size_t size) { + ur_kernel_exec_info_t value, size_t size) { if (ptr == NULL) { serializePtr(os, ptr); return; @@ -8321,39 +8239,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, switch (value) { - case UR_EVENT_INFO_COMMAND_QUEUE: { - const ur_queue_handle_t *tptr = (const ur_queue_handle_t *)ptr; - if (sizeof(ur_queue_handle_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_queue_handle_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - ur_params::serializePtr(os, *tptr); - - os << ")"; - } break; - - case UR_EVENT_INFO_CONTEXT: { - const ur_context_handle_t *tptr = (const ur_context_handle_t *)ptr; - if (sizeof(ur_context_handle_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_context_handle_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - ur_params::serializePtr(os, *tptr); - - os << ")"; - } break; - - case UR_EVENT_INFO_COMMAND_TYPE: { - const ur_command_t *tptr = (const ur_command_t *)ptr; - if (sizeof(ur_command_t) > size) { + case UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_command_t) << ")"; + << ", expected: >=" << sizeof(ur_bool_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -8363,25 +8253,27 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_EVENT_INFO_COMMAND_EXECUTION_STATUS: { - const ur_event_status_t *tptr = (const ur_event_status_t *)ptr; - if (sizeof(ur_event_status_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_event_status_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_KERNEL_EXEC_INFO_USM_PTRS: { - os << *tptr; + const void **tptr = (const void **)ptr; + os << "{"; + size_t nelems = size / sizeof(void *); + for (size_t i = 0; i < nelems; ++i) { + if (i != 0) { + os << ", "; + } - os << ")"; + os << tptr[i]; + } + os << "}"; } break; - case UR_EVENT_INFO_REFERENCE_COUNT: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { + case UR_KERNEL_EXEC_INFO_CACHE_CONFIG: { + const ur_kernel_cache_config_t *tptr = + (const ur_kernel_cache_config_t *)ptr; + if (sizeof(ur_kernel_cache_config_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; + << ", expected: >=" << sizeof(ur_kernel_cache_config_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -8396,28 +8288,130 @@ inline void serializeTagged(std::ostream &os, const void *ptr, } } } // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, - enum ur_profiling_info_t value) { +inline std::ostream & +operator<<(std::ostream &os, + const struct ur_kernel_arg_pointer_properties_t params) { + os << "(struct ur_kernel_arg_pointer_properties_t){"; + + os << ".stype = "; + + os << (params.stype); + + os << ", "; + os << ".pNext = "; + + ur_params::serializeStruct(os, (params.pNext)); + + os << "}"; + return os; +} +inline std::ostream & +operator<<(std::ostream &os, + const struct ur_kernel_exec_info_properties_t params) { + os << "(struct ur_kernel_exec_info_properties_t){"; + + os << ".stype = "; + + os << (params.stype); + + os << ", "; + os << ".pNext = "; + + ur_params::serializeStruct(os, (params.pNext)); + + os << "}"; + return os; +} +inline std::ostream & +operator<<(std::ostream &os, + const struct ur_kernel_arg_sampler_properties_t params) { + os << "(struct ur_kernel_arg_sampler_properties_t){"; + + os << ".stype = "; + + os << (params.stype); + + os << ", "; + os << ".pNext = "; + + ur_params::serializeStruct(os, (params.pNext)); + + os << "}"; + return os; +} +inline std::ostream & +operator<<(std::ostream &os, + const struct ur_kernel_arg_mem_obj_properties_t params) { + os << "(struct ur_kernel_arg_mem_obj_properties_t){"; + + os << ".stype = "; + + os << (params.stype); + + os << ", "; + os << ".pNext = "; + + ur_params::serializeStruct(os, (params.pNext)); + + os << ", "; + os << ".memoryAccess = "; + + ur_params::serializeFlag(os, (params.memoryAccess)); + + os << "}"; + return os; +} +inline std::ostream & +operator<<(std::ostream &os, + const struct ur_kernel_native_properties_t params) { + os << "(struct ur_kernel_native_properties_t){"; + + os << ".stype = "; + + os << (params.stype); + + os << ", "; + os << ".pNext = "; + + ur_params::serializeStruct(os, (params.pNext)); + + os << ", "; + os << ".isNativeHandleOwned = "; + + os << (params.isNativeHandleOwned); + + os << "}"; + return os; +} +inline std::ostream &operator<<(std::ostream &os, enum ur_queue_info_t value) { switch (value) { - case UR_PROFILING_INFO_COMMAND_QUEUED: - os << "UR_PROFILING_INFO_COMMAND_QUEUED"; + case UR_QUEUE_INFO_CONTEXT: + os << "UR_QUEUE_INFO_CONTEXT"; break; - case UR_PROFILING_INFO_COMMAND_SUBMIT: - os << "UR_PROFILING_INFO_COMMAND_SUBMIT"; + case UR_QUEUE_INFO_DEVICE: + os << "UR_QUEUE_INFO_DEVICE"; break; - case UR_PROFILING_INFO_COMMAND_START: - os << "UR_PROFILING_INFO_COMMAND_START"; + case UR_QUEUE_INFO_DEVICE_DEFAULT: + os << "UR_QUEUE_INFO_DEVICE_DEFAULT"; break; - case UR_PROFILING_INFO_COMMAND_END: - os << "UR_PROFILING_INFO_COMMAND_END"; + case UR_QUEUE_INFO_FLAGS: + os << "UR_QUEUE_INFO_FLAGS"; break; - case UR_PROFILING_INFO_COMMAND_COMPLETE: - os << "UR_PROFILING_INFO_COMMAND_COMPLETE"; + case UR_QUEUE_INFO_REFERENCE_COUNT: + os << "UR_QUEUE_INFO_REFERENCE_COUNT"; + break; + + case UR_QUEUE_INFO_SIZE: + os << "UR_QUEUE_INFO_SIZE"; + break; + + case UR_QUEUE_INFO_EMPTY: + os << "UR_QUEUE_INFO_EMPTY"; break; default: os << "unknown enumerator"; @@ -8428,7 +8422,7 @@ inline std::ostream &operator<<(std::ostream &os, namespace ur_params { template <> inline void serializeTagged(std::ostream &os, const void *ptr, - ur_profiling_info_t value, size_t size) { + ur_queue_info_t value, size_t size) { if (ptr == NULL) { serializePtr(os, ptr); return; @@ -8436,39 +8430,67 @@ inline void serializeTagged(std::ostream &os, const void *ptr, switch (value) { - case UR_PROFILING_INFO_COMMAND_QUEUED: { - const uint64_t *tptr = (const uint64_t *)ptr; - if (sizeof(uint64_t) > size) { + case UR_QUEUE_INFO_CONTEXT: { + const ur_queue_handle_t *tptr = (const ur_queue_handle_t *)ptr; + if (sizeof(ur_queue_handle_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint64_t) << ")"; + << ", expected: >=" << sizeof(ur_queue_handle_t) << ")"; return; } os << (void *)(tptr) << " ("; - os << *tptr; + ur_params::serializePtr(os, *tptr); os << ")"; } break; - case UR_PROFILING_INFO_COMMAND_SUBMIT: { - const uint64_t *tptr = (const uint64_t *)ptr; - if (sizeof(uint64_t) > size) { + case UR_QUEUE_INFO_DEVICE: { + const ur_device_handle_t *tptr = (const ur_device_handle_t *)ptr; + if (sizeof(ur_device_handle_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_device_handle_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + ur_params::serializePtr(os, *tptr); + + os << ")"; + } break; + + case UR_QUEUE_INFO_DEVICE_DEFAULT: { + const ur_queue_handle_t *tptr = (const ur_queue_handle_t *)ptr; + if (sizeof(ur_queue_handle_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_queue_handle_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + ur_params::serializePtr(os, *tptr); + + os << ")"; + } break; + + case UR_QUEUE_INFO_FLAGS: { + const ur_queue_flags_t *tptr = (const ur_queue_flags_t *)ptr; + if (sizeof(ur_queue_flags_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint64_t) << ")"; + << ", expected: >=" << sizeof(ur_queue_flags_t) << ")"; return; } os << (void *)(tptr) << " ("; - os << *tptr; + ur_params::serializeFlag(os, *tptr); os << ")"; } break; - case UR_PROFILING_INFO_COMMAND_START: { - const uint64_t *tptr = (const uint64_t *)ptr; - if (sizeof(uint64_t) > size) { + case UR_QUEUE_INFO_REFERENCE_COUNT: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint64_t) << ")"; + << ", expected: >=" << sizeof(uint32_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -8478,11 +8500,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_PROFILING_INFO_COMMAND_END: { - const uint64_t *tptr = (const uint64_t *)ptr; - if (sizeof(uint64_t) > size) { + case UR_QUEUE_INFO_SIZE: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint64_t) << ")"; + << ", expected: >=" << sizeof(uint32_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -8492,11 +8514,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_PROFILING_INFO_COMMAND_COMPLETE: { - const uint64_t *tptr = (const uint64_t *)ptr; - if (sizeof(uint64_t) > size) { + case UR_QUEUE_INFO_EMPTY: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint64_t) << ")"; + << ", expected: >=" << sizeof(ur_bool_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -8511,714 +8533,692 @@ inline void serializeTagged(std::ostream &os, const void *ptr, } } } // namespace ur_params -inline std::ostream & -operator<<(std::ostream &os, const struct ur_event_native_properties_t params) { - os << "(struct ur_event_native_properties_t){"; - - os << ".stype = "; - - os << (params.stype); - - os << ", "; - os << ".pNext = "; - - ur_params::serializeStruct(os, (params.pNext)); - - os << ", "; - os << ".isNativeHandleOwned = "; - - os << (params.isNativeHandleOwned); - - os << "}"; - return os; -} -inline std::ostream &operator<<(std::ostream &os, - enum ur_execution_info_t value) { - switch (value) { - - case UR_EXECUTION_INFO_EXECUTION_INFO_COMPLETE: - os << "UR_EXECUTION_INFO_EXECUTION_INFO_COMPLETE"; - break; - - case UR_EXECUTION_INFO_EXECUTION_INFO_RUNNING: - os << "UR_EXECUTION_INFO_EXECUTION_INFO_RUNNING"; - break; - - case UR_EXECUTION_INFO_EXECUTION_INFO_SUBMITTED: - os << "UR_EXECUTION_INFO_EXECUTION_INFO_SUBMITTED"; - break; - - case UR_EXECUTION_INFO_EXECUTION_INFO_QUEUED: - os << "UR_EXECUTION_INFO_EXECUTION_INFO_QUEUED"; - break; - default: - os << "unknown enumerator"; - break; - } - return os; -} -inline std::ostream &operator<<(std::ostream &os, enum ur_function_t value) { +inline std::ostream &operator<<(std::ostream &os, enum ur_queue_flag_t value) { switch (value) { - case UR_FUNCTION_CONTEXT_CREATE: - os << "UR_FUNCTION_CONTEXT_CREATE"; - break; - - case UR_FUNCTION_CONTEXT_RETAIN: - os << "UR_FUNCTION_CONTEXT_RETAIN"; - break; - - case UR_FUNCTION_CONTEXT_RELEASE: - os << "UR_FUNCTION_CONTEXT_RELEASE"; - break; - - case UR_FUNCTION_CONTEXT_GET_INFO: - os << "UR_FUNCTION_CONTEXT_GET_INFO"; - break; - - case UR_FUNCTION_CONTEXT_GET_NATIVE_HANDLE: - os << "UR_FUNCTION_CONTEXT_GET_NATIVE_HANDLE"; - break; - - case UR_FUNCTION_CONTEXT_CREATE_WITH_NATIVE_HANDLE: - os << "UR_FUNCTION_CONTEXT_CREATE_WITH_NATIVE_HANDLE"; - break; - - case UR_FUNCTION_CONTEXT_SET_EXTENDED_DELETER: - os << "UR_FUNCTION_CONTEXT_SET_EXTENDED_DELETER"; - break; - - case UR_FUNCTION_DEVICE_GET: - os << "UR_FUNCTION_DEVICE_GET"; - break; - - case UR_FUNCTION_DEVICE_GET_INFO: - os << "UR_FUNCTION_DEVICE_GET_INFO"; - break; - - case UR_FUNCTION_DEVICE_RETAIN: - os << "UR_FUNCTION_DEVICE_RETAIN"; - break; - - case UR_FUNCTION_DEVICE_RELEASE: - os << "UR_FUNCTION_DEVICE_RELEASE"; - break; - - case UR_FUNCTION_DEVICE_PARTITION: - os << "UR_FUNCTION_DEVICE_PARTITION"; - break; - - case UR_FUNCTION_DEVICE_SELECT_BINARY: - os << "UR_FUNCTION_DEVICE_SELECT_BINARY"; - break; - - case UR_FUNCTION_DEVICE_GET_NATIVE_HANDLE: - os << "UR_FUNCTION_DEVICE_GET_NATIVE_HANDLE"; - break; - - case UR_FUNCTION_DEVICE_CREATE_WITH_NATIVE_HANDLE: - os << "UR_FUNCTION_DEVICE_CREATE_WITH_NATIVE_HANDLE"; - break; - - case UR_FUNCTION_DEVICE_GET_GLOBAL_TIMESTAMPS: - os << "UR_FUNCTION_DEVICE_GET_GLOBAL_TIMESTAMPS"; - break; - - case UR_FUNCTION_ENQUEUE_KERNEL_LAUNCH: - os << "UR_FUNCTION_ENQUEUE_KERNEL_LAUNCH"; - break; - - case UR_FUNCTION_ENQUEUE_EVENTS_WAIT: - os << "UR_FUNCTION_ENQUEUE_EVENTS_WAIT"; - break; - - case UR_FUNCTION_ENQUEUE_EVENTS_WAIT_WITH_BARRIER: - os << "UR_FUNCTION_ENQUEUE_EVENTS_WAIT_WITH_BARRIER"; - break; - - case UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ: - os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ"; - break; - - case UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE: - os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE"; - break; - - case UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ_RECT: - os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ_RECT"; - break; - - case UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE_RECT: - os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE_RECT"; - break; - - case UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY: - os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY"; - break; - - case UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY_RECT: - os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY_RECT"; + case UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE: + os << "UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE"; break; - case UR_FUNCTION_ENQUEUE_MEM_BUFFER_FILL: - os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_FILL"; + case UR_QUEUE_FLAG_PROFILING_ENABLE: + os << "UR_QUEUE_FLAG_PROFILING_ENABLE"; break; - case UR_FUNCTION_ENQUEUE_MEM_IMAGE_READ: - os << "UR_FUNCTION_ENQUEUE_MEM_IMAGE_READ"; + case UR_QUEUE_FLAG_ON_DEVICE: + os << "UR_QUEUE_FLAG_ON_DEVICE"; break; - case UR_FUNCTION_ENQUEUE_MEM_IMAGE_WRITE: - os << "UR_FUNCTION_ENQUEUE_MEM_IMAGE_WRITE"; + case UR_QUEUE_FLAG_ON_DEVICE_DEFAULT: + os << "UR_QUEUE_FLAG_ON_DEVICE_DEFAULT"; break; - case UR_FUNCTION_ENQUEUE_MEM_IMAGE_COPY: - os << "UR_FUNCTION_ENQUEUE_MEM_IMAGE_COPY"; + case UR_QUEUE_FLAG_DISCARD_EVENTS: + os << "UR_QUEUE_FLAG_DISCARD_EVENTS"; break; - case UR_FUNCTION_ENQUEUE_MEM_BUFFER_MAP: - os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_MAP"; + case UR_QUEUE_FLAG_PRIORITY_LOW: + os << "UR_QUEUE_FLAG_PRIORITY_LOW"; break; - case UR_FUNCTION_ENQUEUE_MEM_UNMAP: - os << "UR_FUNCTION_ENQUEUE_MEM_UNMAP"; + case UR_QUEUE_FLAG_PRIORITY_HIGH: + os << "UR_QUEUE_FLAG_PRIORITY_HIGH"; break; - case UR_FUNCTION_ENQUEUE_USM_FILL: - os << "UR_FUNCTION_ENQUEUE_USM_FILL"; + case UR_QUEUE_FLAG_SUBMISSION_BATCHED: + os << "UR_QUEUE_FLAG_SUBMISSION_BATCHED"; break; - case UR_FUNCTION_ENQUEUE_USM_MEMCPY: - os << "UR_FUNCTION_ENQUEUE_USM_MEMCPY"; + case UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE: + os << "UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE"; break; - case UR_FUNCTION_ENQUEUE_USM_PREFETCH: - os << "UR_FUNCTION_ENQUEUE_USM_PREFETCH"; + case UR_QUEUE_FLAG_USE_DEFAULT_STREAM: + os << "UR_QUEUE_FLAG_USE_DEFAULT_STREAM"; break; - case UR_FUNCTION_ENQUEUE_USM_ADVISE: - os << "UR_FUNCTION_ENQUEUE_USM_ADVISE"; + case UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM: + os << "UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM"; break; - - case UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_WRITE: - os << "UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_WRITE"; + default: + os << "unknown enumerator"; break; + } + return os; +} +namespace ur_params { - case UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_READ: - os << "UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_READ"; - break; +template <> +inline void serializeFlag(std::ostream &os, uint32_t flag) { + uint32_t val = flag; + bool first = true; - case UR_FUNCTION_EVENT_GET_INFO: - os << "UR_FUNCTION_EVENT_GET_INFO"; - break; + if ((val & UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE) == + (uint32_t)UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE) { + val ^= (uint32_t)UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE; + } - case UR_FUNCTION_EVENT_GET_PROFILING_INFO: - os << "UR_FUNCTION_EVENT_GET_PROFILING_INFO"; - break; + if ((val & UR_QUEUE_FLAG_PROFILING_ENABLE) == + (uint32_t)UR_QUEUE_FLAG_PROFILING_ENABLE) { + val ^= (uint32_t)UR_QUEUE_FLAG_PROFILING_ENABLE; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_QUEUE_FLAG_PROFILING_ENABLE; + } - case UR_FUNCTION_EVENT_WAIT: - os << "UR_FUNCTION_EVENT_WAIT"; - break; + if ((val & UR_QUEUE_FLAG_ON_DEVICE) == (uint32_t)UR_QUEUE_FLAG_ON_DEVICE) { + val ^= (uint32_t)UR_QUEUE_FLAG_ON_DEVICE; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_QUEUE_FLAG_ON_DEVICE; + } - case UR_FUNCTION_EVENT_RETAIN: - os << "UR_FUNCTION_EVENT_RETAIN"; - break; + if ((val & UR_QUEUE_FLAG_ON_DEVICE_DEFAULT) == + (uint32_t)UR_QUEUE_FLAG_ON_DEVICE_DEFAULT) { + val ^= (uint32_t)UR_QUEUE_FLAG_ON_DEVICE_DEFAULT; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_QUEUE_FLAG_ON_DEVICE_DEFAULT; + } - case UR_FUNCTION_EVENT_RELEASE: - os << "UR_FUNCTION_EVENT_RELEASE"; - break; + if ((val & UR_QUEUE_FLAG_DISCARD_EVENTS) == + (uint32_t)UR_QUEUE_FLAG_DISCARD_EVENTS) { + val ^= (uint32_t)UR_QUEUE_FLAG_DISCARD_EVENTS; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_QUEUE_FLAG_DISCARD_EVENTS; + } - case UR_FUNCTION_EVENT_GET_NATIVE_HANDLE: - os << "UR_FUNCTION_EVENT_GET_NATIVE_HANDLE"; - break; + if ((val & UR_QUEUE_FLAG_PRIORITY_LOW) == + (uint32_t)UR_QUEUE_FLAG_PRIORITY_LOW) { + val ^= (uint32_t)UR_QUEUE_FLAG_PRIORITY_LOW; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_QUEUE_FLAG_PRIORITY_LOW; + } - case UR_FUNCTION_EVENT_CREATE_WITH_NATIVE_HANDLE: - os << "UR_FUNCTION_EVENT_CREATE_WITH_NATIVE_HANDLE"; - break; + if ((val & UR_QUEUE_FLAG_PRIORITY_HIGH) == + (uint32_t)UR_QUEUE_FLAG_PRIORITY_HIGH) { + val ^= (uint32_t)UR_QUEUE_FLAG_PRIORITY_HIGH; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_QUEUE_FLAG_PRIORITY_HIGH; + } - case UR_FUNCTION_EVENT_SET_CALLBACK: - os << "UR_FUNCTION_EVENT_SET_CALLBACK"; - break; + if ((val & UR_QUEUE_FLAG_SUBMISSION_BATCHED) == + (uint32_t)UR_QUEUE_FLAG_SUBMISSION_BATCHED) { + val ^= (uint32_t)UR_QUEUE_FLAG_SUBMISSION_BATCHED; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_QUEUE_FLAG_SUBMISSION_BATCHED; + } - case UR_FUNCTION_KERNEL_CREATE: - os << "UR_FUNCTION_KERNEL_CREATE"; - break; + if ((val & UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE) == + (uint32_t)UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE) { + val ^= (uint32_t)UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE; + } - case UR_FUNCTION_KERNEL_SET_ARG_VALUE: - os << "UR_FUNCTION_KERNEL_SET_ARG_VALUE"; - break; + if ((val & UR_QUEUE_FLAG_USE_DEFAULT_STREAM) == + (uint32_t)UR_QUEUE_FLAG_USE_DEFAULT_STREAM) { + val ^= (uint32_t)UR_QUEUE_FLAG_USE_DEFAULT_STREAM; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_QUEUE_FLAG_USE_DEFAULT_STREAM; + } - case UR_FUNCTION_KERNEL_SET_ARG_LOCAL: - os << "UR_FUNCTION_KERNEL_SET_ARG_LOCAL"; - break; + if ((val & UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM) == + (uint32_t)UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM) { + val ^= (uint32_t)UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM; + } + if (val != 0) { + std::bitset<32> bits(val); + if (!first) { + os << " | "; + } + os << "unknown bit flags " << bits; + } else if (first) { + os << "0"; + } +} +} // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, + const struct ur_queue_properties_t params) { + os << "(struct ur_queue_properties_t){"; - case UR_FUNCTION_KERNEL_GET_INFO: - os << "UR_FUNCTION_KERNEL_GET_INFO"; - break; + os << ".stype = "; - case UR_FUNCTION_KERNEL_GET_GROUP_INFO: - os << "UR_FUNCTION_KERNEL_GET_GROUP_INFO"; - break; + os << (params.stype); - case UR_FUNCTION_KERNEL_GET_SUB_GROUP_INFO: - os << "UR_FUNCTION_KERNEL_GET_SUB_GROUP_INFO"; - break; + os << ", "; + os << ".pNext = "; - case UR_FUNCTION_KERNEL_RETAIN: - os << "UR_FUNCTION_KERNEL_RETAIN"; - break; + ur_params::serializeStruct(os, (params.pNext)); - case UR_FUNCTION_KERNEL_RELEASE: - os << "UR_FUNCTION_KERNEL_RELEASE"; - break; + os << ", "; + os << ".flags = "; - case UR_FUNCTION_KERNEL_SET_ARG_POINTER: - os << "UR_FUNCTION_KERNEL_SET_ARG_POINTER"; - break; + ur_params::serializeFlag(os, (params.flags)); - case UR_FUNCTION_KERNEL_SET_EXEC_INFO: - os << "UR_FUNCTION_KERNEL_SET_EXEC_INFO"; - break; + os << "}"; + return os; +} +inline std::ostream & +operator<<(std::ostream &os, const struct ur_queue_index_properties_t params) { + os << "(struct ur_queue_index_properties_t){"; - case UR_FUNCTION_KERNEL_SET_ARG_SAMPLER: - os << "UR_FUNCTION_KERNEL_SET_ARG_SAMPLER"; - break; + os << ".stype = "; - case UR_FUNCTION_KERNEL_SET_ARG_MEM_OBJ: - os << "UR_FUNCTION_KERNEL_SET_ARG_MEM_OBJ"; - break; + os << (params.stype); - case UR_FUNCTION_KERNEL_SET_SPECIALIZATION_CONSTANTS: - os << "UR_FUNCTION_KERNEL_SET_SPECIALIZATION_CONSTANTS"; - break; + os << ", "; + os << ".pNext = "; - case UR_FUNCTION_KERNEL_GET_NATIVE_HANDLE: - os << "UR_FUNCTION_KERNEL_GET_NATIVE_HANDLE"; - break; + ur_params::serializeStruct(os, (params.pNext)); - case UR_FUNCTION_KERNEL_CREATE_WITH_NATIVE_HANDLE: - os << "UR_FUNCTION_KERNEL_CREATE_WITH_NATIVE_HANDLE"; - break; + os << ", "; + os << ".computeIndex = "; - case UR_FUNCTION_MEM_IMAGE_CREATE: - os << "UR_FUNCTION_MEM_IMAGE_CREATE"; - break; + os << (params.computeIndex); - case UR_FUNCTION_MEM_BUFFER_CREATE: - os << "UR_FUNCTION_MEM_BUFFER_CREATE"; - break; + os << "}"; + return os; +} +inline std::ostream &operator<<(std::ostream &os, + const struct ur_queue_native_desc_t params) { + os << "(struct ur_queue_native_desc_t){"; - case UR_FUNCTION_MEM_RETAIN: - os << "UR_FUNCTION_MEM_RETAIN"; - break; + os << ".stype = "; - case UR_FUNCTION_MEM_RELEASE: - os << "UR_FUNCTION_MEM_RELEASE"; - break; + os << (params.stype); - case UR_FUNCTION_MEM_BUFFER_PARTITION: - os << "UR_FUNCTION_MEM_BUFFER_PARTITION"; - break; + os << ", "; + os << ".pNext = "; - case UR_FUNCTION_MEM_GET_NATIVE_HANDLE: - os << "UR_FUNCTION_MEM_GET_NATIVE_HANDLE"; - break; + ur_params::serializeStruct(os, (params.pNext)); - case UR_FUNCTION_ENQUEUE_READ_HOST_PIPE: - os << "UR_FUNCTION_ENQUEUE_READ_HOST_PIPE"; - break; + os << ", "; + os << ".pNativeData = "; - case UR_FUNCTION_MEM_GET_INFO: - os << "UR_FUNCTION_MEM_GET_INFO"; - break; + ur_params::serializePtr(os, (params.pNativeData)); - case UR_FUNCTION_MEM_IMAGE_GET_INFO: - os << "UR_FUNCTION_MEM_IMAGE_GET_INFO"; - break; + os << "}"; + return os; +} +inline std::ostream & +operator<<(std::ostream &os, const struct ur_queue_native_properties_t params) { + os << "(struct ur_queue_native_properties_t){"; - case UR_FUNCTION_PLATFORM_GET: - os << "UR_FUNCTION_PLATFORM_GET"; - break; + os << ".stype = "; - case UR_FUNCTION_PLATFORM_GET_INFO: - os << "UR_FUNCTION_PLATFORM_GET_INFO"; - break; + os << (params.stype); - case UR_FUNCTION_PLATFORM_GET_API_VERSION: - os << "UR_FUNCTION_PLATFORM_GET_API_VERSION"; - break; + os << ", "; + os << ".pNext = "; - case UR_FUNCTION_PLATFORM_GET_NATIVE_HANDLE: - os << "UR_FUNCTION_PLATFORM_GET_NATIVE_HANDLE"; - break; + ur_params::serializeStruct(os, (params.pNext)); - case UR_FUNCTION_PLATFORM_CREATE_WITH_NATIVE_HANDLE: - os << "UR_FUNCTION_PLATFORM_CREATE_WITH_NATIVE_HANDLE"; - break; + os << ", "; + os << ".isNativeHandleOwned = "; - case UR_FUNCTION_PROGRAM_CREATE_WITH_IL: - os << "UR_FUNCTION_PROGRAM_CREATE_WITH_IL"; - break; + os << (params.isNativeHandleOwned); - case UR_FUNCTION_PROGRAM_CREATE_WITH_BINARY: - os << "UR_FUNCTION_PROGRAM_CREATE_WITH_BINARY"; - break; + os << "}"; + return os; +} +inline std::ostream &operator<<(std::ostream &os, enum ur_command_t value) { + switch (value) { - case UR_FUNCTION_PROGRAM_BUILD: - os << "UR_FUNCTION_PROGRAM_BUILD"; + case UR_COMMAND_KERNEL_LAUNCH: + os << "UR_COMMAND_KERNEL_LAUNCH"; break; - case UR_FUNCTION_PROGRAM_COMPILE: - os << "UR_FUNCTION_PROGRAM_COMPILE"; + case UR_COMMAND_EVENTS_WAIT: + os << "UR_COMMAND_EVENTS_WAIT"; break; - case UR_FUNCTION_PROGRAM_LINK: - os << "UR_FUNCTION_PROGRAM_LINK"; + case UR_COMMAND_EVENTS_WAIT_WITH_BARRIER: + os << "UR_COMMAND_EVENTS_WAIT_WITH_BARRIER"; break; - case UR_FUNCTION_PROGRAM_RETAIN: - os << "UR_FUNCTION_PROGRAM_RETAIN"; + case UR_COMMAND_MEM_BUFFER_READ: + os << "UR_COMMAND_MEM_BUFFER_READ"; break; - case UR_FUNCTION_PROGRAM_RELEASE: - os << "UR_FUNCTION_PROGRAM_RELEASE"; + case UR_COMMAND_MEM_BUFFER_WRITE: + os << "UR_COMMAND_MEM_BUFFER_WRITE"; break; - case UR_FUNCTION_PROGRAM_GET_FUNCTION_POINTER: - os << "UR_FUNCTION_PROGRAM_GET_FUNCTION_POINTER"; + case UR_COMMAND_MEM_BUFFER_READ_RECT: + os << "UR_COMMAND_MEM_BUFFER_READ_RECT"; break; - case UR_FUNCTION_PROGRAM_GET_INFO: - os << "UR_FUNCTION_PROGRAM_GET_INFO"; + case UR_COMMAND_MEM_BUFFER_WRITE_RECT: + os << "UR_COMMAND_MEM_BUFFER_WRITE_RECT"; break; - case UR_FUNCTION_PROGRAM_GET_BUILD_INFO: - os << "UR_FUNCTION_PROGRAM_GET_BUILD_INFO"; + case UR_COMMAND_MEM_BUFFER_COPY: + os << "UR_COMMAND_MEM_BUFFER_COPY"; break; - case UR_FUNCTION_PROGRAM_SET_SPECIALIZATION_CONSTANTS: - os << "UR_FUNCTION_PROGRAM_SET_SPECIALIZATION_CONSTANTS"; + case UR_COMMAND_MEM_BUFFER_COPY_RECT: + os << "UR_COMMAND_MEM_BUFFER_COPY_RECT"; break; - case UR_FUNCTION_PROGRAM_GET_NATIVE_HANDLE: - os << "UR_FUNCTION_PROGRAM_GET_NATIVE_HANDLE"; + case UR_COMMAND_MEM_BUFFER_FILL: + os << "UR_COMMAND_MEM_BUFFER_FILL"; break; - case UR_FUNCTION_PROGRAM_CREATE_WITH_NATIVE_HANDLE: - os << "UR_FUNCTION_PROGRAM_CREATE_WITH_NATIVE_HANDLE"; + case UR_COMMAND_MEM_IMAGE_READ: + os << "UR_COMMAND_MEM_IMAGE_READ"; break; - case UR_FUNCTION_QUEUE_GET_INFO: - os << "UR_FUNCTION_QUEUE_GET_INFO"; + case UR_COMMAND_MEM_IMAGE_WRITE: + os << "UR_COMMAND_MEM_IMAGE_WRITE"; break; - case UR_FUNCTION_QUEUE_CREATE: - os << "UR_FUNCTION_QUEUE_CREATE"; + case UR_COMMAND_MEM_IMAGE_COPY: + os << "UR_COMMAND_MEM_IMAGE_COPY"; break; - case UR_FUNCTION_QUEUE_RETAIN: - os << "UR_FUNCTION_QUEUE_RETAIN"; + case UR_COMMAND_MEM_BUFFER_MAP: + os << "UR_COMMAND_MEM_BUFFER_MAP"; break; - case UR_FUNCTION_QUEUE_RELEASE: - os << "UR_FUNCTION_QUEUE_RELEASE"; + case UR_COMMAND_MEM_UNMAP: + os << "UR_COMMAND_MEM_UNMAP"; break; - case UR_FUNCTION_QUEUE_GET_NATIVE_HANDLE: - os << "UR_FUNCTION_QUEUE_GET_NATIVE_HANDLE"; + case UR_COMMAND_USM_FILL: + os << "UR_COMMAND_USM_FILL"; break; - case UR_FUNCTION_QUEUE_CREATE_WITH_NATIVE_HANDLE: - os << "UR_FUNCTION_QUEUE_CREATE_WITH_NATIVE_HANDLE"; + case UR_COMMAND_USM_MEMCPY: + os << "UR_COMMAND_USM_MEMCPY"; break; - case UR_FUNCTION_QUEUE_FINISH: - os << "UR_FUNCTION_QUEUE_FINISH"; + case UR_COMMAND_USM_PREFETCH: + os << "UR_COMMAND_USM_PREFETCH"; break; - case UR_FUNCTION_QUEUE_FLUSH: - os << "UR_FUNCTION_QUEUE_FLUSH"; + case UR_COMMAND_USM_ADVISE: + os << "UR_COMMAND_USM_ADVISE"; break; - case UR_FUNCTION_INIT: - os << "UR_FUNCTION_INIT"; + case UR_COMMAND_USM_FILL_2D: + os << "UR_COMMAND_USM_FILL_2D"; break; - case UR_FUNCTION_TEAR_DOWN: - os << "UR_FUNCTION_TEAR_DOWN"; + case UR_COMMAND_USM_MEMCPY_2D: + os << "UR_COMMAND_USM_MEMCPY_2D"; break; - case UR_FUNCTION_SAMPLER_CREATE: - os << "UR_FUNCTION_SAMPLER_CREATE"; + case UR_COMMAND_DEVICE_GLOBAL_VARIABLE_WRITE: + os << "UR_COMMAND_DEVICE_GLOBAL_VARIABLE_WRITE"; break; - case UR_FUNCTION_SAMPLER_RETAIN: - os << "UR_FUNCTION_SAMPLER_RETAIN"; + case UR_COMMAND_DEVICE_GLOBAL_VARIABLE_READ: + os << "UR_COMMAND_DEVICE_GLOBAL_VARIABLE_READ"; break; - case UR_FUNCTION_SAMPLER_RELEASE: - os << "UR_FUNCTION_SAMPLER_RELEASE"; + case UR_COMMAND_READ_HOST_PIPE: + os << "UR_COMMAND_READ_HOST_PIPE"; break; - case UR_FUNCTION_SAMPLER_GET_INFO: - os << "UR_FUNCTION_SAMPLER_GET_INFO"; + case UR_COMMAND_WRITE_HOST_PIPE: + os << "UR_COMMAND_WRITE_HOST_PIPE"; break; - case UR_FUNCTION_SAMPLER_GET_NATIVE_HANDLE: - os << "UR_FUNCTION_SAMPLER_GET_NATIVE_HANDLE"; + case UR_COMMAND_COMMAND_BUFFER_ENQUEUE_EXP: + os << "UR_COMMAND_COMMAND_BUFFER_ENQUEUE_EXP"; break; - case UR_FUNCTION_SAMPLER_CREATE_WITH_NATIVE_HANDLE: - os << "UR_FUNCTION_SAMPLER_CREATE_WITH_NATIVE_HANDLE"; + case UR_COMMAND_INTEROP_SEMAPHORE_WAIT_EXP: + os << "UR_COMMAND_INTEROP_SEMAPHORE_WAIT_EXP"; break; - case UR_FUNCTION_USM_HOST_ALLOC: - os << "UR_FUNCTION_USM_HOST_ALLOC"; + case UR_COMMAND_INTEROP_SEMAPHORE_SIGNAL_EXP: + os << "UR_COMMAND_INTEROP_SEMAPHORE_SIGNAL_EXP"; break; - - case UR_FUNCTION_USM_DEVICE_ALLOC: - os << "UR_FUNCTION_USM_DEVICE_ALLOC"; + default: + os << "unknown enumerator"; break; + } + return os; +} +inline std::ostream &operator<<(std::ostream &os, + enum ur_event_status_t value) { + switch (value) { - case UR_FUNCTION_USM_SHARED_ALLOC: - os << "UR_FUNCTION_USM_SHARED_ALLOC"; + case UR_EVENT_STATUS_COMPLETE: + os << "UR_EVENT_STATUS_COMPLETE"; break; - case UR_FUNCTION_USM_FREE: - os << "UR_FUNCTION_USM_FREE"; + case UR_EVENT_STATUS_RUNNING: + os << "UR_EVENT_STATUS_RUNNING"; break; - case UR_FUNCTION_USM_GET_MEM_ALLOC_INFO: - os << "UR_FUNCTION_USM_GET_MEM_ALLOC_INFO"; + case UR_EVENT_STATUS_SUBMITTED: + os << "UR_EVENT_STATUS_SUBMITTED"; break; - case UR_FUNCTION_USM_POOL_CREATE: - os << "UR_FUNCTION_USM_POOL_CREATE"; + case UR_EVENT_STATUS_QUEUED: + os << "UR_EVENT_STATUS_QUEUED"; break; - - case UR_FUNCTION_COMMAND_BUFFER_CREATE_EXP: - os << "UR_FUNCTION_COMMAND_BUFFER_CREATE_EXP"; + default: + os << "unknown enumerator"; break; + } + return os; +} +inline std::ostream &operator<<(std::ostream &os, enum ur_event_info_t value) { + switch (value) { - case UR_FUNCTION_PLATFORM_GET_BACKEND_OPTION: - os << "UR_FUNCTION_PLATFORM_GET_BACKEND_OPTION"; + case UR_EVENT_INFO_COMMAND_QUEUE: + os << "UR_EVENT_INFO_COMMAND_QUEUE"; break; - case UR_FUNCTION_MEM_BUFFER_CREATE_WITH_NATIVE_HANDLE: - os << "UR_FUNCTION_MEM_BUFFER_CREATE_WITH_NATIVE_HANDLE"; + case UR_EVENT_INFO_CONTEXT: + os << "UR_EVENT_INFO_CONTEXT"; break; - case UR_FUNCTION_MEM_IMAGE_CREATE_WITH_NATIVE_HANDLE: - os << "UR_FUNCTION_MEM_IMAGE_CREATE_WITH_NATIVE_HANDLE"; + case UR_EVENT_INFO_COMMAND_TYPE: + os << "UR_EVENT_INFO_COMMAND_TYPE"; break; - case UR_FUNCTION_ENQUEUE_WRITE_HOST_PIPE: - os << "UR_FUNCTION_ENQUEUE_WRITE_HOST_PIPE"; + case UR_EVENT_INFO_COMMAND_EXECUTION_STATUS: + os << "UR_EVENT_INFO_COMMAND_EXECUTION_STATUS"; break; - case UR_FUNCTION_USM_POOL_RETAIN: - os << "UR_FUNCTION_USM_POOL_RETAIN"; + case UR_EVENT_INFO_REFERENCE_COUNT: + os << "UR_EVENT_INFO_REFERENCE_COUNT"; break; - - case UR_FUNCTION_USM_POOL_RELEASE: - os << "UR_FUNCTION_USM_POOL_RELEASE"; + default: + os << "unknown enumerator"; break; + } + return os; +} +namespace ur_params { +template <> +inline void serializeTagged(std::ostream &os, const void *ptr, + ur_event_info_t value, size_t size) { + if (ptr == NULL) { + serializePtr(os, ptr); + return; + } - case UR_FUNCTION_USM_POOL_GET_INFO: - os << "UR_FUNCTION_USM_POOL_GET_INFO"; - break; + switch (value) { - case UR_FUNCTION_COMMAND_BUFFER_RETAIN_EXP: - os << "UR_FUNCTION_COMMAND_BUFFER_RETAIN_EXP"; - break; + case UR_EVENT_INFO_COMMAND_QUEUE: { + const ur_queue_handle_t *tptr = (const ur_queue_handle_t *)ptr; + if (sizeof(ur_queue_handle_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_queue_handle_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_FUNCTION_COMMAND_BUFFER_RELEASE_EXP: - os << "UR_FUNCTION_COMMAND_BUFFER_RELEASE_EXP"; - break; + ur_params::serializePtr(os, *tptr); - case UR_FUNCTION_COMMAND_BUFFER_FINALIZE_EXP: - os << "UR_FUNCTION_COMMAND_BUFFER_FINALIZE_EXP"; - break; + os << ")"; + } break; - case UR_FUNCTION_COMMAND_BUFFER_APPEND_KERNEL_LAUNCH_EXP: - os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_KERNEL_LAUNCH_EXP"; - break; + case UR_EVENT_INFO_CONTEXT: { + const ur_context_handle_t *tptr = (const ur_context_handle_t *)ptr; + if (sizeof(ur_context_handle_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_context_handle_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_FUNCTION_COMMAND_BUFFER_ENQUEUE_EXP: - os << "UR_FUNCTION_COMMAND_BUFFER_ENQUEUE_EXP"; - break; + ur_params::serializePtr(os, *tptr); - case UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMCPY_USM_EXP: - os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMCPY_USM_EXP"; - break; + os << ")"; + } break; - case UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_EXP: - os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_EXP"; - break; + case UR_EVENT_INFO_COMMAND_TYPE: { + const ur_command_t *tptr = (const ur_command_t *)ptr; + if (sizeof(ur_command_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_command_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_RECT_EXP: - os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_RECT_EXP"; - break; + os << *tptr; - case UR_FUNCTION_USM_PITCHED_ALLOC_EXP: - os << "UR_FUNCTION_USM_PITCHED_ALLOC_EXP"; - break; + os << ")"; + } break; - case UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_HANDLE_DESTROY_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_HANDLE_DESTROY_EXP"; - break; + case UR_EVENT_INFO_COMMAND_EXECUTION_STATUS: { + const ur_event_status_t *tptr = (const ur_event_status_t *)ptr; + if (sizeof(ur_event_status_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_event_status_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_HANDLE_DESTROY_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_HANDLE_DESTROY_EXP"; - break; + os << *tptr; - case UR_FUNCTION_BINDLESS_IMAGES_IMAGE_ALLOCATE_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_IMAGE_ALLOCATE_EXP"; - break; + os << ")"; + } break; - case UR_FUNCTION_BINDLESS_IMAGES_IMAGE_FREE_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_IMAGE_FREE_EXP"; - break; + case UR_EVENT_INFO_REFERENCE_COUNT: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_CREATE_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_CREATE_EXP"; - break; + os << *tptr; - case UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_CREATE_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_CREATE_EXP"; + os << ")"; + } break; + default: + os << "unknown enumerator"; break; + } +} +} // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, + enum ur_profiling_info_t value) { + switch (value) { - case UR_FUNCTION_BINDLESS_IMAGES_IMAGE_COPY_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_IMAGE_COPY_EXP"; + case UR_PROFILING_INFO_COMMAND_QUEUED: + os << "UR_PROFILING_INFO_COMMAND_QUEUED"; break; - case UR_FUNCTION_BINDLESS_IMAGES_IMAGE_GET_INFO_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_IMAGE_GET_INFO_EXP"; + case UR_PROFILING_INFO_COMMAND_SUBMIT: + os << "UR_PROFILING_INFO_COMMAND_SUBMIT"; break; - case UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_GET_LEVEL_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_GET_LEVEL_EXP"; + case UR_PROFILING_INFO_COMMAND_START: + os << "UR_PROFILING_INFO_COMMAND_START"; break; - case UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_FREE_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_FREE_EXP"; + case UR_PROFILING_INFO_COMMAND_END: + os << "UR_PROFILING_INFO_COMMAND_END"; break; - case UR_FUNCTION_BINDLESS_IMAGES_IMPORT_OPAQUE_FD_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_IMPORT_OPAQUE_FD_EXP"; + case UR_PROFILING_INFO_COMMAND_COMPLETE: + os << "UR_PROFILING_INFO_COMMAND_COMPLETE"; break; - - case UR_FUNCTION_BINDLESS_IMAGES_MAP_EXTERNAL_ARRAY_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_MAP_EXTERNAL_ARRAY_EXP"; + default: + os << "unknown enumerator"; break; + } + return os; +} +namespace ur_params { +template <> +inline void serializeTagged(std::ostream &os, const void *ptr, + ur_profiling_info_t value, size_t size) { + if (ptr == NULL) { + serializePtr(os, ptr); + return; + } - case UR_FUNCTION_BINDLESS_IMAGES_RELEASE_INTEROP_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_RELEASE_INTEROP_EXP"; - break; + switch (value) { - case UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_OPAQUE_FD_" - "EXP"; - break; + case UR_PROFILING_INFO_COMMAND_QUEUED: { + const uint64_t *tptr = (const uint64_t *)ptr; + if (sizeof(uint64_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint64_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_FUNCTION_BINDLESS_IMAGES_DESTROY_EXTERNAL_SEMAPHORE_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_DESTROY_EXTERNAL_SEMAPHORE_EXP"; - break; + os << *tptr; - case UR_FUNCTION_BINDLESS_IMAGES_WAIT_EXTERNAL_SEMAPHORE_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_WAIT_EXTERNAL_SEMAPHORE_EXP"; - break; + os << ")"; + } break; - case UR_FUNCTION_BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP"; - break; + case UR_PROFILING_INFO_COMMAND_SUBMIT: { + const uint64_t *tptr = (const uint64_t *)ptr; + if (sizeof(uint64_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint64_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_FUNCTION_PLATFORM_GET_LAST_ERROR: - os << "UR_FUNCTION_PLATFORM_GET_LAST_ERROR"; - break; + os << *tptr; - case UR_FUNCTION_ENQUEUE_USM_FILL_2D: - os << "UR_FUNCTION_ENQUEUE_USM_FILL_2D"; - break; + os << ")"; + } break; - case UR_FUNCTION_ENQUEUE_USM_MEMCPY_2D: - os << "UR_FUNCTION_ENQUEUE_USM_MEMCPY_2D"; - break; + case UR_PROFILING_INFO_COMMAND_START: { + const uint64_t *tptr = (const uint64_t *)ptr; + if (sizeof(uint64_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint64_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_FUNCTION_VIRTUAL_MEM_GRANULARITY_GET_INFO: - os << "UR_FUNCTION_VIRTUAL_MEM_GRANULARITY_GET_INFO"; - break; + os << *tptr; - case UR_FUNCTION_VIRTUAL_MEM_RESERVE: - os << "UR_FUNCTION_VIRTUAL_MEM_RESERVE"; - break; + os << ")"; + } break; - case UR_FUNCTION_VIRTUAL_MEM_FREE: - os << "UR_FUNCTION_VIRTUAL_MEM_FREE"; - break; + case UR_PROFILING_INFO_COMMAND_END: { + const uint64_t *tptr = (const uint64_t *)ptr; + if (sizeof(uint64_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint64_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_FUNCTION_VIRTUAL_MEM_MAP: - os << "UR_FUNCTION_VIRTUAL_MEM_MAP"; - break; + os << *tptr; - case UR_FUNCTION_VIRTUAL_MEM_UNMAP: - os << "UR_FUNCTION_VIRTUAL_MEM_UNMAP"; - break; + os << ")"; + } break; - case UR_FUNCTION_VIRTUAL_MEM_SET_ACCESS: - os << "UR_FUNCTION_VIRTUAL_MEM_SET_ACCESS"; - break; + case UR_PROFILING_INFO_COMMAND_COMPLETE: { + const uint64_t *tptr = (const uint64_t *)ptr; + if (sizeof(uint64_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint64_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_FUNCTION_VIRTUAL_MEM_GET_INFO: - os << "UR_FUNCTION_VIRTUAL_MEM_GET_INFO"; - break; + os << *tptr; - case UR_FUNCTION_PHYSICAL_MEM_CREATE: - os << "UR_FUNCTION_PHYSICAL_MEM_CREATE"; + os << ")"; + } break; + default: + os << "unknown enumerator"; break; + } +} +} // namespace ur_params +inline std::ostream & +operator<<(std::ostream &os, const struct ur_event_native_properties_t params) { + os << "(struct ur_event_native_properties_t){"; - case UR_FUNCTION_PHYSICAL_MEM_RETAIN: - os << "UR_FUNCTION_PHYSICAL_MEM_RETAIN"; - break; + os << ".stype = "; - case UR_FUNCTION_PHYSICAL_MEM_RELEASE: - os << "UR_FUNCTION_PHYSICAL_MEM_RELEASE"; - break; + os << (params.stype); - case UR_FUNCTION_USM_IMPORT_EXP: - os << "UR_FUNCTION_USM_IMPORT_EXP"; - break; + os << ", "; + os << ".pNext = "; - case UR_FUNCTION_USM_RELEASE_EXP: - os << "UR_FUNCTION_USM_RELEASE_EXP"; - break; + ur_params::serializeStruct(os, (params.pNext)); - case UR_FUNCTION_USM_P2P_ENABLE_PEER_ACCESS_EXP: - os << "UR_FUNCTION_USM_P2P_ENABLE_PEER_ACCESS_EXP"; - break; + os << ", "; + os << ".isNativeHandleOwned = "; - case UR_FUNCTION_USM_P2P_DISABLE_PEER_ACCESS_EXP: - os << "UR_FUNCTION_USM_P2P_DISABLE_PEER_ACCESS_EXP"; - break; + os << (params.isNativeHandleOwned); - case UR_FUNCTION_USM_P2P_PEER_ACCESS_GET_INFO_EXP: - os << "UR_FUNCTION_USM_P2P_PEER_ACCESS_GET_INFO_EXP"; - break; + os << "}"; + return os; +} +inline std::ostream &operator<<(std::ostream &os, + enum ur_execution_info_t value) { + switch (value) { - case UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_EXP: - os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_EXP"; + case UR_EXECUTION_INFO_EXECUTION_INFO_COMPLETE: + os << "UR_EXECUTION_INFO_EXECUTION_INFO_COMPLETE"; break; - case UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_READ_EXP: - os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_READ_EXP"; + case UR_EXECUTION_INFO_EXECUTION_INFO_RUNNING: + os << "UR_EXECUTION_INFO_EXECUTION_INFO_RUNNING"; break; - case UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_RECT_EXP: - os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_RECT_EXP"; + case UR_EXECUTION_INFO_EXECUTION_INFO_SUBMITTED: + os << "UR_EXECUTION_INFO_EXECUTION_INFO_SUBMITTED"; break; - case UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_READ_RECT_EXP: - os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_READ_RECT_EXP"; + case UR_EXECUTION_INFO_EXECUTION_INFO_QUEUED: + os << "UR_EXECUTION_INFO_EXECUTION_INFO_QUEUED"; break; default: os << "unknown enumerator"; From 2f73f774017b4c9ec003ae302dcab38b2751b89f Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Tue, 4 Jul 2023 13:48:53 +0100 Subject: [PATCH 036/104] [UR] Generate structure type along with function type --- scripts/generate_ids.py | 105 ++++++++++++++++++++++++++++++++-------- scripts/parse_specs.py | 56 +-------------------- 2 files changed, 87 insertions(+), 74 deletions(-) diff --git a/scripts/generate_ids.py b/scripts/generate_ids.py index c015c25dac..0b26b8407d 100644 --- a/scripts/generate_ids.py +++ b/scripts/generate_ids.py @@ -9,6 +9,8 @@ from fileinput import FileInput import util import yaml +import re +import copy ENUM_NAME = '$x_function_t' @@ -18,9 +20,10 @@ class quoted(str): def quoted_presenter(dumper, data): return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='"') +def get_registry_header(): + return {'type': 'header', 'desc': quoted('Intel $OneApi Unified Runtime function registry'), 'ordinal': quoted(-1)} + def write_registry(data, path): - header = {'type': 'header', 'desc': quoted('Intel $OneApi Unified Runtime function registry'), 'ordinal': quoted(-1)} - data.insert(0, header) with open(path, 'w') as fout: yaml.add_representer(quoted, quoted_presenter) yaml.dump_all(data, fout, @@ -28,26 +31,88 @@ def write_registry(data, path): sort_keys=False, explicit_start=True) +def find_type_in_specs(specs, type): + return [obj for s in specs for obj in s['objects'] if obj['name'] == type][0] + +def get_max_enum(enum): + return int(max(enum['etors'], key=lambda x : int(x['value']))['value']) + +def copy_and_strip_prefix_from_enums(enum, prefix): + cpy = copy.deepcopy(enum) + for etor in cpy['etors']: + etor['name'] = etor['name'][len(prefix):] + return cpy + + +def generate_function_type(specs, meta, update_fn) -> dict: + existing_function_type = find_type_in_specs(specs, '$x_function_t') + existing_etors = {etor['name'] : etor['value'] for etor in existing_function_type['etors']} + max_etor = get_max_enum(existing_function_type) + functions = [obj['class'][len('$x'):] + obj['name'] for s in specs for obj in s['objects'] if obj['type'] == 'function'] + registry = list() + for fname in functions: + etor_name = "$X_FUNCTION_" + util.to_snake_case(fname).upper() + id = existing_etors.get(etor_name) + if id is None: + max_etor += 1 + id = max_etor + registry.append({ + 'name': etor_name, + 'desc': f'Enumerator for $x{fname}', + 'value': str(id)} + ) + registry = sorted(registry, key=lambda x : int(x['value'])) + existing_function_type['etors'] = registry + update_fn(existing_function_type, meta) + + ## create a copy to write back to registry.yml + return copy_and_strip_prefix_from_enums(existing_function_type, '$X_FUNCTION_') + + +def generate_structure_type(specs, meta, refresh_fn) -> dict: + structure_type = find_type_in_specs(specs, '$x_structure_type_t') + extended_structs = [obj for s in specs for obj in s['objects'] if re.match(r"struct|union", obj['type']) and 'base' in obj] + max_enum = get_max_enum(structure_type) + + structure_type_etors = list() + for struct in extended_structs: + # skip experimental enumerations + if struct['name'].startswith('$x_exp_'): + continue + + etor = [mem for mem in struct['members'] if mem['name'] == 'stype'][0]['init'] + + # try and match the etor + matched_etor = [e for e in structure_type['etors'] if e['name'] == etor] + + out_etor = { + 'name': etor, + 'desc': struct['name'] + } + + # if no match exists we assign it a new value + if len(matched_etor) == 0: + max_enum += 1 + out_etor['value'] = str(max_enum) + else: + out_etor['value'] = matched_etor[0]['value'] + + structure_type_etors.append(out_etor) + + structure_type_etors = sorted(structure_type_etors, key = lambda x : int(x['value'])) + structure_type['etors'] = structure_type_etors + refresh_fn(structure_type, meta) + + ## create a copy to write back to registry.yml + return copy_and_strip_prefix_from_enums(structure_type, '$X_STRUCTURE_TYPE_') -def generate_registry(path, specs): +def generate_registry(path, specs, meta, update_fn): try: - contents = list(util.yamlRead(path)) - existing_registry = contents[1]['etors'] - existing_etors = {etor["name"]: etor["value"] for etor in existing_registry} - max_etor = int(max(existing_registry, key = lambda x : int(x["value"]))["value"]) - functions = [obj['class'][len('$x'):] + obj['name'] for s in specs for obj in s['objects'] if obj['type'] == 'function'] - registry = list() - for fname in functions: - etor_name = util.to_snake_case(fname).upper() - id = existing_etors.get(etor_name) - if id is None: - max_etor += 1 - id = max_etor - registry.append({'name': util.to_snake_case(fname).upper(), 'desc': 'Enumerator for $x'+fname, 'value': str(id)}) - registry = sorted(registry, key=lambda x: int(x['value'])) - wrapper = { 'name': ENUM_NAME, 'type': 'enum', 'desc': 'Defines unique stable identifiers for all functions' , 'etors': registry} - contents[1] = wrapper - write_registry(contents[1:], path) + write_registry([ + get_registry_header(), + generate_function_type(specs, meta, update_fn), + generate_structure_type(specs, meta, update_fn) + ], path) except BaseException as e: print("Failed to generate registry.yml... %s", e) diff --git a/scripts/parse_specs.py b/scripts/parse_specs.py index 3f5d23a501..e7b99381fd 100644 --- a/scripts/parse_specs.py +++ b/scripts/parse_specs.py @@ -853,54 +853,6 @@ def sort_etors(x): return value matching_enum['etors'] = sorted(matching_enum['etors'], key=sort_etors) -def _generate_structure_type_t(specs, meta, registry): - extended_structs = [obj for s in specs for obj in s['objects'] if re.match(r"struct|union", obj['type']) and 'base' in obj] - ur_structure_type_t = [obj for s in specs for obj in s['objects'] if obj['name'] == "$x_structure_type_t"][0] - existing_etors = ur_structure_type_t['etors'] - max_enum = int(max(ur_structure_type_t['etors'], key= lambda x : int(x['value']))['value']) - - out_etors = [] - for struct in extended_structs: - # skip experimental enumerations - if struct['name'].startswith("$x_exp_"): - continue - - # name of the etor - etor = [mem for mem in struct['members'] if mem['name'] == 'stype'][0]['init'] - - # try and match the etor - matched_etor = [e for e in existing_etors if e['name'] == etor] - - # if no match exists then we have to add it - if len(matched_etor) == 0: - max_enum += 1 - out_etors.append({ - "name": etor, - "desc": struct['name'], - "value": str(max_enum) - }) - else: - out_etors.append({ - "name": etor, - "desc": struct['name'], - "value": matched_etor[0]['value'] - }) - - out_etors = sorted(out_etors, key = lambda x : int(x['value'])) - ur_structure_type_t['etors'] = out_etors - _refresh_enum_meta(ur_structure_type_t, meta) - - ## write the result out to the yml file - try: - contents = list(util.yamlRead(registry)) - cpy = copy.deepcopy(ur_structure_type_t) - for e in cpy['etors']: - e['name'] = e['name'][len("$X_STRUCTURE_TYPE_"):] - contents[2] = cpy - generate_ids.write_registry(contents[1:], registry) - except: - raise - """ Entry-point: Reads each YML file and extracts data @@ -911,13 +863,10 @@ def parse(section, version, tags, meta, ref): specs = [] files = util.findFiles(path, "*.yml") - # make sure registry is last, because it's autogenerated based on the rest of the spec - files = sorted(files, key=lambda f: 1 if f.endswith('registry.yml') else 0) + registry = [f for f in files if f.endswith('registry.yml')][0] enum_extensions = [] for f in files: - if f.endswith('registry.yml'): - generate_ids.generate_registry(f, specs) print("Parsing %s..."%f) docs = util.yamlRead(f) @@ -970,8 +919,7 @@ def parse(section, version, tags, meta, ref): specs = sorted(specs, key=lambda s: s['header']['ordinal']) _inline_extended_structs(specs, meta) - registry = [f for f in files if f.endswith('registry.yml')][0] - _generate_structure_type_t(specs, meta, registry) + generate_ids.generate_registry(registry, specs, meta, _refresh_enum_meta) _extend_enums(enum_extensions, specs, meta) _generate_extra(specs, meta) From be12f156ba0b39649a7f6070d3c734c30284fb11 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Tue, 4 Jul 2023 14:07:55 +0100 Subject: [PATCH 037/104] [ur] Sort experimental feature toctree order Change the order of experimental features in the reStructuredText `.. toctree::` to be alphabetically sorted. This align the order experimental features are displayed in the *Experimental Features* section with the *API Documentation* section. --- scripts/templates/exp-features.rst.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/templates/exp-features.rst.mako b/scripts/templates/exp-features.rst.mako index 8358298047..5e90f9fa79 100644 --- a/scripts/templates/exp-features.rst.mako +++ b/scripts/templates/exp-features.rst.mako @@ -5,7 +5,7 @@ import glob expdocs = [] for section in sections: foundDocs = glob.glob(section + "/EXP-*.rst") - for found in foundDocs: + for found in sorted(foundDocs): expdocs.append(found) %> ===================== From 54ce16252c2d3de4a4a55debca3cafcb55638e3b Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Tue, 4 Jul 2023 12:11:54 +0100 Subject: [PATCH 038/104] [UR][CTS] Add CTS tests for urPlatformGetLastError --- test/conformance/platform/CMakeLists.txt | 1 + .../platform/urPlatformGetLastError.cpp | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 test/conformance/platform/urPlatformGetLastError.cpp diff --git a/test/conformance/platform/CMakeLists.txt b/test/conformance/platform/CMakeLists.txt index cc87c7366a..dff3cbebf7 100644 --- a/test/conformance/platform/CMakeLists.txt +++ b/test/conformance/platform/CMakeLists.txt @@ -8,4 +8,5 @@ add_conformance_test(platform urPlatformGet.cpp urPlatformGetBackendOption.cpp urPlatformGetInfo.cpp + urPlatformGetLastError.cpp urTearDown.cpp) diff --git a/test/conformance/platform/urPlatformGetLastError.cpp b/test/conformance/platform/urPlatformGetLastError.cpp new file mode 100644 index 0000000000..e4fbc38b21 --- /dev/null +++ b/test/conformance/platform/urPlatformGetLastError.cpp @@ -0,0 +1,35 @@ +// Copyright (C) 2022-2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "fixtures.h" + +struct urPlatformGetLastErrorTest : uur::platform::urPlatformTest { + int32_t error; + const char *message = nullptr; +}; + +TEST_F(urPlatformGetLastErrorTest, Success) { + // We can't reliably generate a UR_RESULT_ERROR_ADAPTER_SPECIFIC error to + // test the full functionality of this entry point, so instead do a minimal + // smoke test and check that the call returns successfully, even if no + // actual error was set. + ASSERT_EQ_RESULT(UR_RESULT_SUCCESS, + urPlatformGetLastError(platform, &message, &error)); +} + +TEST_F(urPlatformGetLastErrorTest, InvalidHandle) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urPlatformGetLastError(nullptr, &message, &error)); +} + +TEST_F(urPlatformGetLastErrorTest, InvalidMessagePtr) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, + urPlatformGetLastError(platform, nullptr, &error)); +} + +TEST_F(urPlatformGetLastErrorTest, InvalidErrorPtr) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, + urPlatformGetLastError(platform, &message, nullptr)); +} From d520e247ac7f4290dc906dfc6dcfc45657afd7ef Mon Sep 17 00:00:00 2001 From: Aaron Greig Date: Tue, 4 Jul 2023 14:13:06 +0100 Subject: [PATCH 039/104] Add the cuda adapter to the list of known adapter libraries. --- source/loader/ur_adapter_registry.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/loader/ur_adapter_registry.hpp b/source/loader/ur_adapter_registry.hpp index 33cf4e130e..744d988336 100644 --- a/source/loader/ur_adapter_registry.hpp +++ b/source/loader/ur_adapter_registry.hpp @@ -106,8 +106,9 @@ class AdapterRegistry { // to load the adapter. std::vector> adaptersLoadPaths; - static constexpr std::array knownAdapterNames{ - MAKE_LIBRARY_NAME("ur_adapter_level_zero", "0")}; + static constexpr std::array knownAdapterNames{ + MAKE_LIBRARY_NAME("ur_adapter_level_zero", "0"), + MAKE_LIBRARY_NAME("ur_adapter_cuda", "0")}; std::optional> getEnvAdapterSearchPaths() { std::optional> pathStringsOpt; From fbb9b18316a6db129ab6e11ebce4def288f89c75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Stolarczuk?= Date: Thu, 22 Jun 2023 15:54:50 +0200 Subject: [PATCH 040/104] Fix random spelling issues Mostly found by codespell. --- REQUIREMENTS.md | 4 ++-- ci/pyenv.cmd | 2 +- include/ur.py | 4 ++-- include/ur_api.h | 4 ++-- scripts/YaML.md | 4 ++-- scripts/core/EXP-BINDLESS-IMAGES.rst | 20 +++++++++---------- scripts/core/device.yml | 6 +++--- scripts/parse_specs.py | 4 ++-- scripts/templates/exp_feat.rst.mako | 2 +- scripts/templates/helper.py | 4 ++-- source/common/umf_pools/disjoint_pool.cpp | 2 +- .../include/umf/memory_pool_ops.h | 2 +- .../include/umf/memory_provider.h | 4 ++-- .../include/umf/memory_provider_ops.h | 2 +- .../src/memory_tracker.h | 2 +- .../memoryPoolAPI.cpp | 4 ++-- tools/urtrace/collector.cpp | 2 +- 17 files changed, 36 insertions(+), 36 deletions(-) diff --git a/REQUIREMENTS.md b/REQUIREMENTS.md index f9014ec79a..0dcacc9948 100644 --- a/REQUIREMENTS.md +++ b/REQUIREMENTS.md @@ -28,9 +28,9 @@ ### Library Language Binding Requirements * DPC++ Language binding requirements - + Performance Libraries that execute on multiple Intel IP’s shall support the DPCP++ language binding as the primary mechanism for programing on multiple Intel Hardware IP’s + + Performance Libraries that execute on multiple Intel IP’s shall support the DPCP++ language binding as the primary mechanism for programming on multiple Intel Hardware IP’s + If the library supports DPC++ for a only a subset of functions for offload to an accelerator (e.g. ATS), all CPU functions should all support DPC++ Language bindings so that application developers can write their entire application in DPC++ - + If a Library only supports only the CPU, but is likey to be used with another library the supports DPC++ on CPU and ATS, the library shall also support DPC++ + + If a Library only supports only the CPU, but is likely to be used with another library the supports DPC++ on CPU and ATS, the library shall also support DPC++ * Libraries may support other language bindings (C/C++/FORTRAN/JAVA/PYTHON, etc.) to support existing user base and use cases required by the developer domain ### Library API Deprecation Management diff --git a/ci/pyenv.cmd b/ci/pyenv.cmd index 2540657150..a90a33509f 100644 --- a/ci/pyenv.cmd +++ b/ci/pyenv.cmd @@ -112,7 +112,7 @@ goto :eof ::=============================================================== :: Deletes existing python virtual env. :reset_python -echo Reseting python... +echo Resetting python... set VDIR_ACTIVE= if exist "%VDIR%" ( call "%VDIR%\Scripts\deactivate.bat" diff --git a/include/ur.py b/include/ur.py index 2d4247c19a..cb092af4ce 100644 --- a/include/ur.py +++ b/include/ur.py @@ -476,7 +476,7 @@ class ur_device_info_v(IntEnum): MAX_READ_WRITE_IMAGE_ARGS = 32 ## [uint32_t] max number of image objects arguments of a kernel declared ## with the read_write qualifier IMAGE2D_MAX_WIDTH = 33 ## [size_t] max width of Image2D object - IMAGE2D_MAX_HEIGHT = 34 ## [size_t] max heigh of Image2D object + IMAGE2D_MAX_HEIGHT = 34 ## [size_t] max height of Image2D object IMAGE3D_MAX_WIDTH = 35 ## [size_t] max width of Image3D object IMAGE3D_MAX_HEIGHT = 36 ## [size_t] max height of Image3D object IMAGE3D_MAX_DEPTH = 37 ## [size_t] max depth of Image3D object @@ -680,7 +680,7 @@ class ur_device_partition_value_t(Structure): class ur_device_partition_property_t(Structure): _fields_ = [ ("type", ur_device_partition_t), ## [in] The partitioning type to be used. - ("value", ur_device_partition_value_t) ## [in] The paritioning value. + ("value", ur_device_partition_value_t) ## [in] The partitioning value. ] ############################################################################### diff --git a/include/ur_api.h b/include/ur_api.h index 4ad70c9456..67cd0d8beb 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -863,7 +863,7 @@ typedef enum ur_device_info_t { UR_DEVICE_INFO_MAX_READ_WRITE_IMAGE_ARGS = 32, ///< [uint32_t] max number of image objects arguments of a kernel declared ///< with the read_write qualifier UR_DEVICE_INFO_IMAGE2D_MAX_WIDTH = 33, ///< [size_t] max width of Image2D object - UR_DEVICE_INFO_IMAGE2D_MAX_HEIGHT = 34, ///< [size_t] max heigh of Image2D object + UR_DEVICE_INFO_IMAGE2D_MAX_HEIGHT = 34, ///< [size_t] max height of Image2D object UR_DEVICE_INFO_IMAGE3D_MAX_WIDTH = 35, ///< [size_t] max width of Image3D object UR_DEVICE_INFO_IMAGE3D_MAX_HEIGHT = 36, ///< [size_t] max height of Image3D object UR_DEVICE_INFO_IMAGE3D_MAX_DEPTH = 37, ///< [size_t] max depth of Image3D object @@ -1173,7 +1173,7 @@ typedef union ur_device_partition_value_t { /// @brief Device partition property typedef struct ur_device_partition_property_t { ur_device_partition_t type; ///< [in] The partitioning type to be used. - ur_device_partition_value_t value; ///< [in] The paritioning value. + ur_device_partition_value_t value; ///< [in] The partitioning value. } ur_device_partition_property_t; diff --git a/scripts/YaML.md b/scripts/YaML.md index bbd1e76e0d..c6a8895d48 100644 --- a/scripts/YaML.md +++ b/scripts/YaML.md @@ -20,7 +20,7 @@ This document describes the YaML format used by the scripts for the API specific * A header requires the following scalar fields: {`desc`} - `desc` will be used as the region description comment * A header may take the following optional scalar fields: {`ordinal`, `version`} - - `ordinal` will be used to override the default order (alphebetical) in which regions appear in the specification; `default="1000"`. Multiple regions with the same ordinal will be ordered alphebetically. + - `ordinal` will be used to override the default order (alphabetical) in which regions appear in the specification; `default="1000"`. Multiple regions with the same ordinal will be ordered alphabetically. - `version` can be used to define the minimum API version for all documents in the yml file; `default="1.0"` @@ -325,7 +325,7 @@ class ur_name_handle_t(c_void_p): - `version` will be used to define the minimum API version in which the enum will appear; `default="1.0"` This will also affect the order in which the enum appears within its section and class. - `extend` will be used to extend an existing enum with additional `etors`, usually used to implement experimental features. `type` *must* refer to an - exiting enum and each `etor` must include a unique `value`. + existing enum and each `etor` must include a unique `value`. - `typed_etors` boolean value that will be used to determine whether the enum's values have associated types. * An enum requires the following sequence of mappings: {`etors`} - An etor requires the following scalar fields: {`name`, `desc`} diff --git a/scripts/core/EXP-BINDLESS-IMAGES.rst b/scripts/core/EXP-BINDLESS-IMAGES.rst index f1b4d94309..86a2d42f9c 100644 --- a/scripts/core/EXP-BINDLESS-IMAGES.rst +++ b/scripts/core/EXP-BINDLESS-IMAGES.rst @@ -148,16 +148,16 @@ Functions Changelog -------------------------------------------------------------------------------- -+----------+---------------------------------------------------------+ -| Revision | Changes | -+==========+=========================================================+ -| 1.0 | Initial Draft | -+----------+---------------------------------------------------------+ -| 2.0 || Added device parameters to UR functions. | -| || Added sub-region copy paramters to image copy function.| -| || Removed 3D USM capabilities. | -| || Added mip filter mode. | -+----------+---------------------------------------------------------+ ++----------+----------------------------------------------------------+ +| Revision | Changes | ++==========+==========================================================+ +| 1.0 | Initial Draft | ++----------+----------------------------------------------------------+ +| 2.0 || Added device parameters to UR functions. | +| || Added sub-region copy parameters to image copy function.| +| || Removed 3D USM capabilities. | +| || Added mip filter mode. | ++----------+----------------------------------------------------------+ Contributors -------------------------------------------------------------------------------- diff --git a/scripts/core/device.yml b/scripts/core/device.yml index 5e8fa6e727..ed404865ad 100644 --- a/scripts/core/device.yml +++ b/scripts/core/device.yml @@ -1,5 +1,5 @@ # -# Copyright (C) 2022 Intel Corporation +# Copyright (C) 2022-2023 Intel Corporation # # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. # See LICENSE.TXT @@ -216,7 +216,7 @@ etors: - name: IMAGE2D_MAX_WIDTH desc: "[size_t] max width of Image2D object" - name: IMAGE2D_MAX_HEIGHT - desc: "[size_t] max heigh of Image2D object" + desc: "[size_t] max height of Image2D object" - name: IMAGE3D_MAX_WIDTH desc: "[size_t] max width of Image3D object" - name: IMAGE3D_MAX_HEIGHT @@ -539,7 +539,7 @@ members: desc: "[in] The partitioning type to be used." - type: $x_device_partition_value_t name: value - desc: "[in] The paritioning value." + desc: "[in] The partitioning value." --- #-------------------------------------------------------------------------- type: struct desc: "Device Partition Properties" diff --git a/scripts/parse_specs.py b/scripts/parse_specs.py index 63cce5769d..9a26b0d30a 100644 --- a/scripts/parse_specs.py +++ b/scripts/parse_specs.py @@ -1,5 +1,5 @@ """ - Copyright (C) 2022 Intel Corporation + Copyright (C) 2022-2023 Intel Corporation Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT @@ -231,7 +231,7 @@ def __validate_etors(d, tags): raise Exception(prefix+"typed etor " + item['name'] + " must begin with a type identifier: [type]") type_name = _subt(type, tags) if not is_iso(type_name): - raise Exception(prefix+"type " + str(type) + " in a typed etor " + item['name'] + " must be a valid ISO C identifer") + raise Exception(prefix+"type " + str(type) + " in a typed etor " + item['name'] + " must be a valid ISO C identifier") __validate_name(item, 'name', tags, case='upper', prefix=prefix) diff --git a/scripts/templates/exp_feat.rst.mako b/scripts/templates/exp_feat.rst.mako index 628e9f8c50..8c8de46e6a 100644 --- a/scripts/templates/exp_feat.rst.mako +++ b/scripts/templates/exp_feat.rst.mako @@ -76,7 +76,7 @@ Support Adapters which support this experimental feature *must* return the valid string defined in ``${"${X}"}_${"_".join(name.split("-")).upper()}_EXTENSION_STRING_EXP`` as one of the options from ${"${x}"}DeviceGetInfo when querying for -${"${X}"}_DEVICE_INFO_EXTENSIONS. Conversly, before using any of the +${"${X}"}_DEVICE_INFO_EXTENSIONS. Conversely, before using any of the functionality defined in this experimental feature the user *must* use the device query to determine if the adapter supports this feature. diff --git a/scripts/templates/helper.py b/scripts/templates/helper.py index cbb612e29b..2a70c1c326 100644 --- a/scripts/templates/helper.py +++ b/scripts/templates/helper.py @@ -1,5 +1,5 @@ """ - Copyright (C) 2022 Intel Corporation + Copyright (C) 2022-2023 Intel Corporation Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT @@ -427,7 +427,7 @@ def is_global(item, tags): """ Public: - substitues each tag['key'] with tag['value'] + substitutes each tag['key'] with tag['value'] if comment, then insert doxygen '::' notation at beginning (for autogen links) """ def subt(namespace, tags, string, comment=False, remove_namespace=False): diff --git a/source/common/umf_pools/disjoint_pool.cpp b/source/common/umf_pools/disjoint_pool.cpp index e4c4c693dd..0a5622588e 100644 --- a/source/common/umf_pools/disjoint_pool.cpp +++ b/source/common/umf_pools/disjoint_pool.cpp @@ -113,7 +113,7 @@ class Slab { // Hints where to start search for free chunk in a slab size_t FirstFreeChunkIdx = 0; - // Return the index of the first available chunk, SIZE_MAX otherwize + // Return the index of the first available chunk, SIZE_MAX otherwise size_t FindFirstAvailableChunkIdx() const; // Register/Unregister the slab in the global slab address map. diff --git a/source/common/unified_malloc_framework/include/umf/memory_pool_ops.h b/source/common/unified_malloc_framework/include/umf/memory_pool_ops.h index ce7aa960d7..16a7d1252e 100644 --- a/source/common/unified_malloc_framework/include/umf/memory_pool_ops.h +++ b/source/common/unified_malloc_framework/include/umf/memory_pool_ops.h @@ -26,7 +26,7 @@ struct umf_memory_pool_ops_t { uint32_t version; /// - /// \brief Intializes memory pool. + /// \brief Initializes memory pool. /// \param providers array of memory providers that will be used for coarse-grain allocations. /// Should contain at least one memory provider. /// \param numProvider number of elements in the providers array diff --git a/source/common/unified_malloc_framework/include/umf/memory_provider.h b/source/common/unified_malloc_framework/include/umf/memory_provider.h index 739252b79c..dd4489d5a9 100644 --- a/source/common/unified_malloc_framework/include/umf/memory_provider.h +++ b/source/common/unified_malloc_framework/include/umf/memory_provider.h @@ -123,7 +123,7 @@ umfMemoryProviderPurgeLazy(umf_memory_provider_handle_t hProvider, void *ptr, /// /// \brief Discard physical pages within the virtual memory mapping associated at given addr and size. -/// This call is synchronous and if it suceeds, pages are guaranteed to be zero-filled on the next access. +/// This call is synchronous and if it succeeds, pages are guaranteed to be zero-filled on the next access. /// \param hProvider handle to the memory provider /// \param ptr beginning of the virtual memory range /// \param size size of the virtual memory range @@ -135,7 +135,7 @@ umfMemoryProviderPurgeForce(umf_memory_provider_handle_t hProvider, void *ptr, size_t size); /// -/// \brief Retrive name of a given memory provider. +/// \brief Retrieve name of a given memory provider. /// \param hProvider handle to the memory provider /// \param ppName [out] pointer to a string containing name of the provider const char *umfMemoryProviderGetName(umf_memory_provider_handle_t hProvider); diff --git a/source/common/unified_malloc_framework/include/umf/memory_provider_ops.h b/source/common/unified_malloc_framework/include/umf/memory_provider_ops.h index 74d16a72a8..1b795cbad8 100644 --- a/source/common/unified_malloc_framework/include/umf/memory_provider_ops.h +++ b/source/common/unified_malloc_framework/include/umf/memory_provider_ops.h @@ -26,7 +26,7 @@ struct umf_memory_provider_ops_t { uint32_t version; /// - /// \brief Intializes memory pool. + /// \brief Initializes memory pool. /// \param params pool-specific params /// \param pool returns pointer to the pool /// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure. diff --git a/source/common/unified_malloc_framework/src/memory_tracker.h b/source/common/unified_malloc_framework/src/memory_tracker.h index c6e620bf66..43a95cf0cd 100644 --- a/source/common/unified_malloc_framework/src/memory_tracker.h +++ b/source/common/unified_malloc_framework/src/memory_tracker.h @@ -26,7 +26,7 @@ void *umfMemoryTrackerGetPool(umf_memory_tracker_handle_t hTracker, const void *ptr); // Creates a memory provider that tracks each allocation/deallocation through umf_memory_tracker_handle_t and -// forwards all requests to hUpstream memory Provider. hUpstream liftime should be managed by the user of this function. +// forwards all requests to hUpstream memory Provider. hUpstream lifetime should be managed by the user of this function. enum umf_result_t umfTrackingMemoryProviderCreate( umf_memory_provider_handle_t hUpstream, umf_memory_pool_handle_t hPool, umf_memory_provider_handle_t *hTrackingProvider); diff --git a/test/unified_malloc_framework/memoryPoolAPI.cpp b/test/unified_malloc_framework/memoryPoolAPI.cpp index 35c307866e..1b3157bc39 100644 --- a/test/unified_malloc_framework/memoryPoolAPI.cpp +++ b/test/unified_malloc_framework/memoryPoolAPI.cpp @@ -286,7 +286,7 @@ TEST_F(test, getLastFailedMemoryProvider) { umfMemoryProviderGetName(umfGetLastFailedMemoryProvider())), "provider2"); - // succesfull provider should not be returned by umfGetLastFailedMemoryProvider + // successful provider should not be returned by umfGetLastFailedMemoryProvider allocResult = UMF_RESULT_SUCCESS; ptr = umfPoolMalloc(pool.get(), allocSize); ASSERT_NE(ptr, nullptr); @@ -294,7 +294,7 @@ TEST_F(test, getLastFailedMemoryProvider) { umfMemoryProviderGetName(umfGetLastFailedMemoryProvider())), "provider2"); - // erorr in another thread should not impact umfGetLastFailedMemoryProvider on this thread + // error in another thread should not impact umfGetLastFailedMemoryProvider on this thread allocResult = UMF_RESULT_ERROR_UNKNOWN; std::thread t([&, hPool = pool.get()] { ptr = umfPoolMalloc(hPool, allocSize); diff --git a/tools/urtrace/collector.cpp b/tools/urtrace/collector.cpp index 3655cbe3c8..b502f0d802 100644 --- a/tools/urtrace/collector.cpp +++ b/tools/urtrace/collector.cpp @@ -181,7 +181,7 @@ static class cli_args { bool no_args; enum output_format output_format; std::optional - filter_str; //the filter_str is kept primarly for printing. + filter_str; //the filter_str is kept primarily for printing. std::optional filter; } cli_args; From b495e39aef548d55bfa92186b3e87e01e86861f9 Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Wed, 5 Jul 2023 09:49:25 +0100 Subject: [PATCH 041/104] [UR] fix api listing heading title --- scripts/templates/api_listing.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/templates/api_listing.mako b/scripts/templates/api_listing.mako index 929224abc0..722a803915 100644 --- a/scripts/templates/api_listing.mako +++ b/scripts/templates/api_listing.mako @@ -247,7 +247,7 @@ ${th.make_type_name(n, tags, obj)} %for obj in objects: %if re.match(r"typedef", obj['type']): %if isempty: # only display section title if there is content. -${title} Structures +${title} Typedefs -------------------------------------------------------------------------------- <%isempty = False%> %endif From 3fc357c46d339ab0eb42c4640c3a79918e42355c Mon Sep 17 00:00:00 2001 From: Isaac Ault Date: Wed, 5 Jul 2023 09:55:47 +0100 Subject: [PATCH 042/104] Add UR_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT to ur_device_info_t --- include/ur.py | 30 ++++++++++++++------------- include/ur_api.h | 30 ++++++++++++++------------- scripts/core/EXP-BINDLESS-IMAGES.rst | 1 + scripts/core/exp-bindless-images.yml | 31 +++++++++++++++------------- source/common/ur_params.hpp | 18 ++++++++++++++++ 5 files changed, 68 insertions(+), 42 deletions(-) diff --git a/include/ur.py b/include/ur.py index 80ecc08f3a..2e219c332e 100644 --- a/include/ur.py +++ b/include/ur.py @@ -761,33 +761,35 @@ class ur_device_info_v(IntEnum): ## version than older devices. BINDLESS_IMAGES_SUPPORT_EXP = 0x2000 ## [::ur_bool_t] returns true if the device supports the creation of ## bindless images - BINDLESS_IMAGES_1D_USM_SUPPORT_EXP = 0x2001 ## [::ur_bool_t] returns true if the device supports the creation of 1D + BINDLESS_IMAGES_SHARED_USM_SUPPORT = 0x2001 ## [::ur_bool_t] returns true if the device supports the creation of + ## bindless images backed by shared USM + BINDLESS_IMAGES_1D_USM_SUPPORT_EXP = 0x2002 ## [::ur_bool_t] returns true if the device supports the creation of 1D ## bindless images backed by USM - BINDLESS_IMAGES_2D_USM_SUPPORT_EXP = 0x2002 ## [::ur_bool_t] returns true if the device supports the creation of 2D + BINDLESS_IMAGES_2D_USM_SUPPORT_EXP = 0x2003 ## [::ur_bool_t] returns true if the device supports the creation of 2D ## bindless images backed by USM - IMAGE_PITCH_ALIGN_EXP = 0x2003 ## [uint32_t] returns the required alignment of the pitch between two + IMAGE_PITCH_ALIGN_EXP = 0x2004 ## [uint32_t] returns the required alignment of the pitch between two ## rows of an image in bytes - MAX_IMAGE_LINEAR_WIDTH_EXP = 0x2004 ## [size_t] returns the maximum linear width allowed for images allocated + MAX_IMAGE_LINEAR_WIDTH_EXP = 0x2005 ## [size_t] returns the maximum linear width allowed for images allocated ## using USM - MAX_IMAGE_LINEAR_HEIGHT_EXP = 0x2005 ## [size_t] returns the maximum linear height allowed for images + MAX_IMAGE_LINEAR_HEIGHT_EXP = 0x2006 ## [size_t] returns the maximum linear height allowed for images ## allocated using USM - MAX_IMAGE_LINEAR_PITCH_EXP = 0x2006 ## [size_t] returns the maximum linear pitch allowed for images allocated + MAX_IMAGE_LINEAR_PITCH_EXP = 0x2007 ## [size_t] returns the maximum linear pitch allowed for images allocated ## using USM - MIPMAP_SUPPORT_EXP = 0x2007 ## [::ur_bool_t] returns true if the device supports allocating mipmap + MIPMAP_SUPPORT_EXP = 0x2008 ## [::ur_bool_t] returns true if the device supports allocating mipmap ## resources - MIPMAP_ANISOTROPY_SUPPORT_EXP = 0x2008 ## [::ur_bool_t] returns true if the device supports sampling mipmap + MIPMAP_ANISOTROPY_SUPPORT_EXP = 0x2009 ## [::ur_bool_t] returns true if the device supports sampling mipmap ## images with anisotropic filtering - MIPMAP_MAX_ANISOTROPY_EXP = 0x2009 ## [uint32_t] returns the maximum anisotropic ratio supported by the + MIPMAP_MAX_ANISOTROPY_EXP = 0x200A ## [uint32_t] returns the maximum anisotropic ratio supported by the ## device - MIPMAP_LEVEL_REFERENCE_SUPPORT_EXP = 0x200A ## [::ur_bool_t] returns true if the device supports using images created + MIPMAP_LEVEL_REFERENCE_SUPPORT_EXP = 0x200B ## [::ur_bool_t] returns true if the device supports using images created ## from individual mipmap levels - INTEROP_MEMORY_IMPORT_SUPPORT_EXP = 0x200B ## [::ur_bool_t] returns true if the device supports importing external + INTEROP_MEMORY_IMPORT_SUPPORT_EXP = 0x200C ## [::ur_bool_t] returns true if the device supports importing external ## memory resources - INTEROP_MEMORY_EXPORT_SUPPORT_EXP = 0x200C ## [::ur_bool_t] returns true if the device supports exporting internal + INTEROP_MEMORY_EXPORT_SUPPORT_EXP = 0x200D ## [::ur_bool_t] returns true if the device supports exporting internal ## memory resources - INTEROP_SEMAPHORE_IMPORT_SUPPORT_EXP = 0x200D ## [::ur_bool_t] returns true if the device supports importing external + INTEROP_SEMAPHORE_IMPORT_SUPPORT_EXP = 0x200E ## [::ur_bool_t] returns true if the device supports importing external ## semaphore resources - INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP = 0x200E ## [::ur_bool_t] returns true if the device supports exporting internal + INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP = 0x200F ## [::ur_bool_t] returns true if the device supports exporting internal ## event resources class ur_device_info_t(c_int): diff --git a/include/ur_api.h b/include/ur_api.h index 6f88c7870a..89d80f9ced 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -1155,33 +1155,35 @@ typedef enum ur_device_info_t { ///< version than older devices. UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP = 0x2000, ///< [::ur_bool_t] returns true if the device supports the creation of ///< bindless images - UR_DEVICE_INFO_BINDLESS_IMAGES_1D_USM_SUPPORT_EXP = 0x2001, ///< [::ur_bool_t] returns true if the device supports the creation of 1D + UR_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT = 0x2001, ///< [::ur_bool_t] returns true if the device supports the creation of + ///< bindless images backed by shared USM + UR_DEVICE_INFO_BINDLESS_IMAGES_1D_USM_SUPPORT_EXP = 0x2002, ///< [::ur_bool_t] returns true if the device supports the creation of 1D ///< bindless images backed by USM - UR_DEVICE_INFO_BINDLESS_IMAGES_2D_USM_SUPPORT_EXP = 0x2002, ///< [::ur_bool_t] returns true if the device supports the creation of 2D + UR_DEVICE_INFO_BINDLESS_IMAGES_2D_USM_SUPPORT_EXP = 0x2003, ///< [::ur_bool_t] returns true if the device supports the creation of 2D ///< bindless images backed by USM - UR_DEVICE_INFO_IMAGE_PITCH_ALIGN_EXP = 0x2003, ///< [uint32_t] returns the required alignment of the pitch between two + UR_DEVICE_INFO_IMAGE_PITCH_ALIGN_EXP = 0x2004, ///< [uint32_t] returns the required alignment of the pitch between two ///< rows of an image in bytes - UR_DEVICE_INFO_MAX_IMAGE_LINEAR_WIDTH_EXP = 0x2004, ///< [size_t] returns the maximum linear width allowed for images allocated + UR_DEVICE_INFO_MAX_IMAGE_LINEAR_WIDTH_EXP = 0x2005, ///< [size_t] returns the maximum linear width allowed for images allocated ///< using USM - UR_DEVICE_INFO_MAX_IMAGE_LINEAR_HEIGHT_EXP = 0x2005, ///< [size_t] returns the maximum linear height allowed for images + UR_DEVICE_INFO_MAX_IMAGE_LINEAR_HEIGHT_EXP = 0x2006, ///< [size_t] returns the maximum linear height allowed for images ///< allocated using USM - UR_DEVICE_INFO_MAX_IMAGE_LINEAR_PITCH_EXP = 0x2006, ///< [size_t] returns the maximum linear pitch allowed for images allocated + UR_DEVICE_INFO_MAX_IMAGE_LINEAR_PITCH_EXP = 0x2007, ///< [size_t] returns the maximum linear pitch allowed for images allocated ///< using USM - UR_DEVICE_INFO_MIPMAP_SUPPORT_EXP = 0x2007, ///< [::ur_bool_t] returns true if the device supports allocating mipmap + UR_DEVICE_INFO_MIPMAP_SUPPORT_EXP = 0x2008, ///< [::ur_bool_t] returns true if the device supports allocating mipmap ///< resources - UR_DEVICE_INFO_MIPMAP_ANISOTROPY_SUPPORT_EXP = 0x2008, ///< [::ur_bool_t] returns true if the device supports sampling mipmap + UR_DEVICE_INFO_MIPMAP_ANISOTROPY_SUPPORT_EXP = 0x2009, ///< [::ur_bool_t] returns true if the device supports sampling mipmap ///< images with anisotropic filtering - UR_DEVICE_INFO_MIPMAP_MAX_ANISOTROPY_EXP = 0x2009, ///< [uint32_t] returns the maximum anisotropic ratio supported by the + UR_DEVICE_INFO_MIPMAP_MAX_ANISOTROPY_EXP = 0x200A, ///< [uint32_t] returns the maximum anisotropic ratio supported by the ///< device - UR_DEVICE_INFO_MIPMAP_LEVEL_REFERENCE_SUPPORT_EXP = 0x200A, ///< [::ur_bool_t] returns true if the device supports using images created + UR_DEVICE_INFO_MIPMAP_LEVEL_REFERENCE_SUPPORT_EXP = 0x200B, ///< [::ur_bool_t] returns true if the device supports using images created ///< from individual mipmap levels - UR_DEVICE_INFO_INTEROP_MEMORY_IMPORT_SUPPORT_EXP = 0x200B, ///< [::ur_bool_t] returns true if the device supports importing external + UR_DEVICE_INFO_INTEROP_MEMORY_IMPORT_SUPPORT_EXP = 0x200C, ///< [::ur_bool_t] returns true if the device supports importing external ///< memory resources - UR_DEVICE_INFO_INTEROP_MEMORY_EXPORT_SUPPORT_EXP = 0x200C, ///< [::ur_bool_t] returns true if the device supports exporting internal + UR_DEVICE_INFO_INTEROP_MEMORY_EXPORT_SUPPORT_EXP = 0x200D, ///< [::ur_bool_t] returns true if the device supports exporting internal ///< memory resources - UR_DEVICE_INFO_INTEROP_SEMAPHORE_IMPORT_SUPPORT_EXP = 0x200D, ///< [::ur_bool_t] returns true if the device supports importing external + UR_DEVICE_INFO_INTEROP_SEMAPHORE_IMPORT_SUPPORT_EXP = 0x200E, ///< [::ur_bool_t] returns true if the device supports importing external ///< semaphore resources - UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP = 0x200E, ///< [::ur_bool_t] returns true if the device supports exporting internal + UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP = 0x200F, ///< [::ur_bool_t] returns true if the device supports exporting internal ///< event resources /// @cond UR_DEVICE_INFO_FORCE_UINT32 = 0x7fffffff diff --git a/scripts/core/EXP-BINDLESS-IMAGES.rst b/scripts/core/EXP-BINDLESS-IMAGES.rst index 86a2d42f9c..37ad8f6bdd 100644 --- a/scripts/core/EXP-BINDLESS-IMAGES.rst +++ b/scripts/core/EXP-BINDLESS-IMAGES.rst @@ -67,6 +67,7 @@ Enums * ${x}_device_info_t * ${X}_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP + * ${X}_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT * ${X}_DEVICE_INFO_BINDLESS_IMAGES_1D_USM_SUPPORT_EXP * ${X}_DEVICE_INFO_BINDLESS_IMAGES_2D_USM_SUPPORT_EXP * ${X}_DEVICE_INFO_IMAGE_PITCH_ALIGN_EXP diff --git a/scripts/core/exp-bindless-images.yml b/scripts/core/exp-bindless-images.yml index b499d8d8c3..e9b72246d0 100644 --- a/scripts/core/exp-bindless-images.yml +++ b/scripts/core/exp-bindless-images.yml @@ -32,47 +32,50 @@ etors: - name: BINDLESS_IMAGES_SUPPORT_EXP value: "0x2000" desc: "[$x_bool_t] returns true if the device supports the creation of bindless images" - - name: BINDLESS_IMAGES_1D_USM_SUPPORT_EXP + - name: BINDLESS_IMAGES_SHARED_USM_SUPPORT value: "0x2001" + desc: "[$x_bool_t] returns true if the device supports the creation of bindless images backed by shared USM" + - name: BINDLESS_IMAGES_1D_USM_SUPPORT_EXP + value: "0x2002" desc: "[$x_bool_t] returns true if the device supports the creation of 1D bindless images backed by USM" - name: BINDLESS_IMAGES_2D_USM_SUPPORT_EXP - value: "0x2002" + value: "0x2003" desc: "[$x_bool_t] returns true if the device supports the creation of 2D bindless images backed by USM" - name: IMAGE_PITCH_ALIGN_EXP - value: "0x2003" + value: "0x2004" desc: "[uint32_t] returns the required alignment of the pitch between two rows of an image in bytes" - name: MAX_IMAGE_LINEAR_WIDTH_EXP - value: "0x2004" + value: "0x2005" desc: "[size_t] returns the maximum linear width allowed for images allocated using USM" - name: MAX_IMAGE_LINEAR_HEIGHT_EXP - value: "0x2005" + value: "0x2006" desc: "[size_t] returns the maximum linear height allowed for images allocated using USM" - name: MAX_IMAGE_LINEAR_PITCH_EXP - value: "0x2006" + value: "0x2007" desc: "[size_t] returns the maximum linear pitch allowed for images allocated using USM" - name: MIPMAP_SUPPORT_EXP - value: "0x2007" + value: "0x2008" desc: "[$x_bool_t] returns true if the device supports allocating mipmap resources" - name: MIPMAP_ANISOTROPY_SUPPORT_EXP - value: "0x2008" + value: "0x2009" desc: "[$x_bool_t] returns true if the device supports sampling mipmap images with anisotropic filtering" - name: MIPMAP_MAX_ANISOTROPY_EXP - value: "0x2009" + value: "0x200A" desc: "[uint32_t] returns the maximum anisotropic ratio supported by the device" - name: MIPMAP_LEVEL_REFERENCE_SUPPORT_EXP - value: "0x200A" + value: "0x200B" desc: "[$x_bool_t] returns true if the device supports using images created from individual mipmap levels" - name: INTEROP_MEMORY_IMPORT_SUPPORT_EXP - value: "0x200B" + value: "0x200C" desc: "[$x_bool_t] returns true if the device supports importing external memory resources" - name: INTEROP_MEMORY_EXPORT_SUPPORT_EXP - value: "0x200C" + value: "0x200D" desc: "[$x_bool_t] returns true if the device supports exporting internal memory resources" - name: INTEROP_SEMAPHORE_IMPORT_SUPPORT_EXP - value: "0x200D" + value: "0x200E" desc: "[$x_bool_t] returns true if the device supports importing external semaphore resources" - name: INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP - value: "0x200E" + value: "0x200F" desc: "[$x_bool_t] returns true if the device supports exporting internal event resources" --- #-------------------------------------------------------------------------- type: enum diff --git a/source/common/ur_params.hpp b/source/common/ur_params.hpp index 02fc6d8e5e..4616071874 100644 --- a/source/common/ur_params.hpp +++ b/source/common/ur_params.hpp @@ -2574,6 +2574,10 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_device_info_t value) { os << "UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP"; break; + case UR_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT: + os << "UR_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT"; + break; + case UR_DEVICE_INFO_BINDLESS_IMAGES_1D_USM_SUPPORT_EXP: os << "UR_DEVICE_INFO_BINDLESS_IMAGES_1D_USM_SUPPORT_EXP"; break; @@ -4204,6 +4208,20 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; + case UR_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_bool_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + case UR_DEVICE_INFO_BINDLESS_IMAGES_1D_USM_SUPPORT_EXP: { const ur_bool_t *tptr = (const ur_bool_t *)ptr; if (sizeof(ur_bool_t) > size) { From c9ed0caaf4ea013d03ee313174b5fdc649429839 Mon Sep 17 00:00:00 2001 From: Isaac Ault Date: Wed, 5 Jul 2023 10:30:09 +0100 Subject: [PATCH 043/104] Add _EXP --- include/ur.py | 4 +- include/ur_api.h | 362 +++++++++++++-------------- scripts/core/EXP-BINDLESS-IMAGES.rst | 2 +- scripts/core/exp-bindless-images.yml | 4 +- source/common/ur_params.hpp | 6 +- 5 files changed, 189 insertions(+), 189 deletions(-) diff --git a/include/ur.py b/include/ur.py index 2e219c332e..fcbca4e31d 100644 --- a/include/ur.py +++ b/include/ur.py @@ -761,7 +761,7 @@ class ur_device_info_v(IntEnum): ## version than older devices. BINDLESS_IMAGES_SUPPORT_EXP = 0x2000 ## [::ur_bool_t] returns true if the device supports the creation of ## bindless images - BINDLESS_IMAGES_SHARED_USM_SUPPORT = 0x2001 ## [::ur_bool_t] returns true if the device supports the creation of + BINDLESS_IMAGES_SHARED_USM_SUPPORT_EXP = 0x2001 ## [::ur_bool_t] returns true if the device supports the creation of ## bindless images backed by shared USM BINDLESS_IMAGES_1D_USM_SUPPORT_EXP = 0x2002 ## [::ur_bool_t] returns true if the device supports the creation of 1D ## bindless images backed by USM @@ -789,7 +789,7 @@ class ur_device_info_v(IntEnum): ## memory resources INTEROP_SEMAPHORE_IMPORT_SUPPORT_EXP = 0x200E ## [::ur_bool_t] returns true if the device supports importing external ## semaphore resources - INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP = 0x200F ## [::ur_bool_t] returns true if the device supports exporting internal + INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP = 0x2010 ## [::ur_bool_t] returns true if the device supports exporting internal ## event resources class ur_device_info_t(c_int): diff --git a/include/ur_api.h b/include/ur_api.h index 89d80f9ced..6c9235de11 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -1004,187 +1004,187 @@ urDeviceGet( /////////////////////////////////////////////////////////////////////////////// /// @brief Supported device info typedef enum ur_device_info_t { - UR_DEVICE_INFO_TYPE = 0, ///< [::ur_device_type_t] type of the device - UR_DEVICE_INFO_VENDOR_ID = 1, ///< [uint32_t] vendor Id of the device - UR_DEVICE_INFO_DEVICE_ID = 2, ///< [uint32_t] Id of the device - UR_DEVICE_INFO_MAX_COMPUTE_UNITS = 3, ///< [uint32_t] the number of compute units - UR_DEVICE_INFO_MAX_WORK_ITEM_DIMENSIONS = 4, ///< [uint32_t] max work item dimensions - UR_DEVICE_INFO_MAX_WORK_ITEM_SIZES = 5, ///< [size_t[]] return an array of max work item sizes - UR_DEVICE_INFO_MAX_WORK_GROUP_SIZE = 6, ///< [size_t] max work group size - UR_DEVICE_INFO_SINGLE_FP_CONFIG = 7, ///< [::ur_device_fp_capability_flags_t] single precision floating point - ///< capability - UR_DEVICE_INFO_HALF_FP_CONFIG = 8, ///< [::ur_device_fp_capability_flags_t] half precision floating point - ///< capability - UR_DEVICE_INFO_DOUBLE_FP_CONFIG = 9, ///< [::ur_device_fp_capability_flags_t] double precision floating point - ///< capability - UR_DEVICE_INFO_QUEUE_PROPERTIES = 10, ///< [::ur_queue_flags_t] command queue properties supported by the device - UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_CHAR = 11, ///< [uint32_t] preferred vector width for char - UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_SHORT = 12, ///< [uint32_t] preferred vector width for short - UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_INT = 13, ///< [uint32_t] preferred vector width for int - UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_LONG = 14, ///< [uint32_t] preferred vector width for long - UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_FLOAT = 15, ///< [uint32_t] preferred vector width for float - UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_DOUBLE = 16, ///< [uint32_t] preferred vector width for double - UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_HALF = 17, ///< [uint32_t] preferred vector width for half float - UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_CHAR = 18, ///< [uint32_t] native vector width for char - UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_SHORT = 19, ///< [uint32_t] native vector width for short - UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_INT = 20, ///< [uint32_t] native vector width for int - UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_LONG = 21, ///< [uint32_t] native vector width for long - UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_FLOAT = 22, ///< [uint32_t] native vector width for float - UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_DOUBLE = 23, ///< [uint32_t] native vector width for double - UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_HALF = 24, ///< [uint32_t] native vector width for half float - UR_DEVICE_INFO_MAX_CLOCK_FREQUENCY = 25, ///< [uint32_t] max clock frequency in MHz - UR_DEVICE_INFO_MEMORY_CLOCK_RATE = 26, ///< [uint32_t] memory clock frequency in MHz - UR_DEVICE_INFO_ADDRESS_BITS = 27, ///< [uint32_t] address bits - UR_DEVICE_INFO_MAX_MEM_ALLOC_SIZE = 28, ///< [uint64_t] max memory allocation size - UR_DEVICE_INFO_IMAGE_SUPPORTED = 29, ///< [::ur_bool_t] images are supported - UR_DEVICE_INFO_MAX_READ_IMAGE_ARGS = 30, ///< [uint32_t] max number of image objects arguments of a kernel declared - ///< with the read_only qualifier - UR_DEVICE_INFO_MAX_WRITE_IMAGE_ARGS = 31, ///< [uint32_t] max number of image objects arguments of a kernel declared - ///< with the write_only qualifier - UR_DEVICE_INFO_MAX_READ_WRITE_IMAGE_ARGS = 32, ///< [uint32_t] max number of image objects arguments of a kernel declared - ///< with the read_write qualifier - UR_DEVICE_INFO_IMAGE2D_MAX_WIDTH = 33, ///< [size_t] max width of Image2D object - UR_DEVICE_INFO_IMAGE2D_MAX_HEIGHT = 34, ///< [size_t] max height of Image2D object - UR_DEVICE_INFO_IMAGE3D_MAX_WIDTH = 35, ///< [size_t] max width of Image3D object - UR_DEVICE_INFO_IMAGE3D_MAX_HEIGHT = 36, ///< [size_t] max height of Image3D object - UR_DEVICE_INFO_IMAGE3D_MAX_DEPTH = 37, ///< [size_t] max depth of Image3D object - UR_DEVICE_INFO_IMAGE_MAX_BUFFER_SIZE = 38, ///< [size_t] max image buffer size - UR_DEVICE_INFO_IMAGE_MAX_ARRAY_SIZE = 39, ///< [size_t] max image array size - UR_DEVICE_INFO_MAX_SAMPLERS = 40, ///< [uint32_t] max number of samplers that can be used in a kernel - UR_DEVICE_INFO_MAX_PARAMETER_SIZE = 41, ///< [size_t] max size in bytes of all arguments passed to a kernel - UR_DEVICE_INFO_MEM_BASE_ADDR_ALIGN = 42, ///< [uint32_t] memory base address alignment - UR_DEVICE_INFO_GLOBAL_MEM_CACHE_TYPE = 43, ///< [::ur_device_mem_cache_type_t] global memory cache type - UR_DEVICE_INFO_GLOBAL_MEM_CACHELINE_SIZE = 44, ///< [uint32_t] global memory cache line size in bytes - UR_DEVICE_INFO_GLOBAL_MEM_CACHE_SIZE = 45, ///< [uint64_t] size of global memory cache in bytes - UR_DEVICE_INFO_GLOBAL_MEM_SIZE = 46, ///< [uint64_t] size of global memory in bytes - UR_DEVICE_INFO_GLOBAL_MEM_FREE = 47, ///< [uint64_t] size of global memory which is free in bytes - UR_DEVICE_INFO_MAX_CONSTANT_BUFFER_SIZE = 48, ///< [uint64_t] max constant buffer size in bytes - UR_DEVICE_INFO_MAX_CONSTANT_ARGS = 49, ///< [uint32_t] max number of __const declared arguments in a kernel - UR_DEVICE_INFO_LOCAL_MEM_TYPE = 50, ///< [::ur_device_local_mem_type_t] local memory type - UR_DEVICE_INFO_LOCAL_MEM_SIZE = 51, ///< [uint64_t] local memory size in bytes - UR_DEVICE_INFO_ERROR_CORRECTION_SUPPORT = 52, ///< [::ur_bool_t] support error correction to global and local memory - UR_DEVICE_INFO_HOST_UNIFIED_MEMORY = 53, ///< [::ur_bool_t] unified host device memory - UR_DEVICE_INFO_PROFILING_TIMER_RESOLUTION = 54, ///< [size_t] profiling timer resolution in nanoseconds - UR_DEVICE_INFO_ENDIAN_LITTLE = 55, ///< [::ur_bool_t] little endian byte order - UR_DEVICE_INFO_AVAILABLE = 56, ///< [::ur_bool_t] device is available - UR_DEVICE_INFO_COMPILER_AVAILABLE = 57, ///< [::ur_bool_t] device compiler is available - UR_DEVICE_INFO_LINKER_AVAILABLE = 58, ///< [::ur_bool_t] device linker is available - UR_DEVICE_INFO_EXECUTION_CAPABILITIES = 59, ///< [::ur_device_exec_capability_flags_t] device kernel execution - ///< capability bit-field - UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES = 60, ///< [::ur_queue_flags_t] device command queue property bit-field - UR_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES = 61, ///< [::ur_queue_flags_t] host queue property bit-field - UR_DEVICE_INFO_BUILT_IN_KERNELS = 62, ///< [char[]] a semi-colon separated list of built-in kernels - UR_DEVICE_INFO_PLATFORM = 63, ///< [::ur_platform_handle_t] the platform associated with the device - UR_DEVICE_INFO_REFERENCE_COUNT = 64, ///< [uint32_t] Reference count of the device object. - ///< The reference count returned should be considered immediately stale. - ///< It is unsuitable for general use in applications. This feature is - ///< provided for identifying memory leaks. - UR_DEVICE_INFO_IL_VERSION = 65, ///< [char[]] IL version - UR_DEVICE_INFO_NAME = 66, ///< [char[]] Device name - UR_DEVICE_INFO_VENDOR = 67, ///< [char[]] Device vendor - UR_DEVICE_INFO_DRIVER_VERSION = 68, ///< [char[]] Driver version - UR_DEVICE_INFO_PROFILE = 69, ///< [char[]] Device profile - UR_DEVICE_INFO_VERSION = 70, ///< [char[]] Device version - UR_DEVICE_INFO_BACKEND_RUNTIME_VERSION = 71, ///< [char[]] Version of backend runtime - UR_DEVICE_INFO_EXTENSIONS = 72, ///< [char[]] Return a space separated list of extension names - UR_DEVICE_INFO_PRINTF_BUFFER_SIZE = 73, ///< [size_t] Maximum size in bytes of internal printf buffer - UR_DEVICE_INFO_PREFERRED_INTEROP_USER_SYNC = 74, ///< [::ur_bool_t] prefer user synchronization when sharing object with - ///< other API - UR_DEVICE_INFO_PARENT_DEVICE = 75, ///< [::ur_device_handle_t] return parent device handle - UR_DEVICE_INFO_SUPPORTED_PARTITIONS = 76, ///< [::ur_device_partition_t[]] Returns an array of partition types - ///< supported by the device - UR_DEVICE_INFO_PARTITION_MAX_SUB_DEVICES = 77, ///< [uint32_t] maximum number of sub-devices when the device is - ///< partitioned - UR_DEVICE_INFO_PARTITION_AFFINITY_DOMAIN = 78, ///< [::ur_device_affinity_domain_flags_t] Returns a bit-field of the - ///< supported affinity domains for partitioning. - ///< If the device does not support any affinity domains, then 0 will be returned. - UR_DEVICE_INFO_PARTITION_TYPE = 79, ///< [::ur_device_partition_property_t[]] return an array of - ///< ::ur_device_partition_property_t for properties specified in - ///< ::urDevicePartition - UR_DEVICE_INFO_MAX_NUM_SUB_GROUPS = 80, ///< [uint32_t] max number of sub groups - UR_DEVICE_INFO_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS = 81, ///< [::ur_bool_t] support sub group independent forward progress - UR_DEVICE_INFO_SUB_GROUP_SIZES_INTEL = 82, ///< [uint32_t[]] return an array of sub group sizes supported on Intel - ///< device - UR_DEVICE_INFO_USM_HOST_SUPPORT = 83, ///< [::ur_device_usm_access_capability_flags_t] support USM host memory - ///< access - UR_DEVICE_INFO_USM_DEVICE_SUPPORT = 84, ///< [::ur_device_usm_access_capability_flags_t] support USM device memory - ///< access - UR_DEVICE_INFO_USM_SINGLE_SHARED_SUPPORT = 85, ///< [::ur_device_usm_access_capability_flags_t] support USM single device - ///< shared memory access - UR_DEVICE_INFO_USM_CROSS_SHARED_SUPPORT = 86, ///< [::ur_device_usm_access_capability_flags_t] support USM cross device - ///< shared memory access - UR_DEVICE_INFO_USM_SYSTEM_SHARED_SUPPORT = 87, ///< [::ur_device_usm_access_capability_flags_t] support USM system wide - ///< shared memory access - UR_DEVICE_INFO_UUID = 88, ///< [char[]] return device UUID - UR_DEVICE_INFO_PCI_ADDRESS = 89, ///< [char[]] return device PCI address - UR_DEVICE_INFO_GPU_EU_COUNT = 90, ///< [uint32_t] return Intel GPU EU count - UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH = 91, ///< [uint32_t] return Intel GPU EU SIMD width - UR_DEVICE_INFO_GPU_EU_SLICES = 92, ///< [uint32_t] return Intel GPU number of slices - UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE = 93, ///< [uint32_t] return Intel GPU EU count per subslice - UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE = 94, ///< [uint32_t] return Intel GPU number of subslices per slice - UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU = 95, ///< [uint32_t] return Intel GPU number of threads per EU - UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH = 96, ///< [uint32_t] return max memory bandwidth in Mb/s - UR_DEVICE_INFO_IMAGE_SRGB = 97, ///< [::ur_bool_t] device supports sRGB images - UR_DEVICE_INFO_BUILD_ON_SUBDEVICE = 98, ///< [::ur_bool_t] Return true if sub-device should do its own program - ///< build - UR_DEVICE_INFO_ATOMIC_64 = 99, ///< [::ur_bool_t] support 64 bit atomics - UR_DEVICE_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES = 100, ///< [::ur_memory_order_capability_flags_t] return a bit-field of atomic - ///< memory order capabilities - UR_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES = 101, ///< [::ur_memory_scope_capability_flags_t] return a bit-field of atomic - ///< memory scope capabilities - UR_DEVICE_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES = 102, ///< [::ur_memory_order_capability_flags_t] return a bit-field of atomic - ///< memory fence order capabilities - UR_DEVICE_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES = 103, ///< [::ur_memory_scope_capability_flags_t] return a bit-field of atomic - ///< memory fence scope capabilities - UR_DEVICE_INFO_BFLOAT16 = 104, ///< [::ur_bool_t] support for bfloat16 - UR_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES = 105, ///< [uint32_t] Returns 1 if the device doesn't have a notion of a - ///< queue index. Otherwise, returns the number of queue indices that are - ///< available for this device. - UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS = 106, ///< [::ur_bool_t] support the ::urKernelSetSpecializationConstants entry - ///< point - UR_DEVICE_INFO_MEMORY_BUS_WIDTH = 107, ///< [uint32_t] return the width in bits of the memory bus interface of the - ///< device. - UR_DEVICE_INFO_MAX_WORK_GROUPS_3D = 108, ///< [size_t[3]] return max 3D work groups - UR_DEVICE_INFO_ASYNC_BARRIER = 109, ///< [::ur_bool_t] return true if Async Barrier is supported - UR_DEVICE_INFO_MEM_CHANNEL_SUPPORT = 110, ///< [::ur_bool_t] return true if specifying memory channels is supported - UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED = 111, ///< [::ur_bool_t] Return true if the device supports enqueueing commands - ///< to read and write pipes from the host. - UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP = 112, ///< [uint32_t] The maximum number of registers available per block. - UR_DEVICE_INFO_IP_VERSION = 113, ///< [uint32_t] The device IP version. The meaning of the device IP version - ///< is implementation-defined, but newer devices should have a higher - ///< version than older devices. - UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP = 0x2000, ///< [::ur_bool_t] returns true if the device supports the creation of - ///< bindless images - UR_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT = 0x2001, ///< [::ur_bool_t] returns true if the device supports the creation of - ///< bindless images backed by shared USM - UR_DEVICE_INFO_BINDLESS_IMAGES_1D_USM_SUPPORT_EXP = 0x2002, ///< [::ur_bool_t] returns true if the device supports the creation of 1D - ///< bindless images backed by USM - UR_DEVICE_INFO_BINDLESS_IMAGES_2D_USM_SUPPORT_EXP = 0x2003, ///< [::ur_bool_t] returns true if the device supports the creation of 2D - ///< bindless images backed by USM - UR_DEVICE_INFO_IMAGE_PITCH_ALIGN_EXP = 0x2004, ///< [uint32_t] returns the required alignment of the pitch between two - ///< rows of an image in bytes - UR_DEVICE_INFO_MAX_IMAGE_LINEAR_WIDTH_EXP = 0x2005, ///< [size_t] returns the maximum linear width allowed for images allocated - ///< using USM - UR_DEVICE_INFO_MAX_IMAGE_LINEAR_HEIGHT_EXP = 0x2006, ///< [size_t] returns the maximum linear height allowed for images - ///< allocated using USM - UR_DEVICE_INFO_MAX_IMAGE_LINEAR_PITCH_EXP = 0x2007, ///< [size_t] returns the maximum linear pitch allowed for images allocated - ///< using USM - UR_DEVICE_INFO_MIPMAP_SUPPORT_EXP = 0x2008, ///< [::ur_bool_t] returns true if the device supports allocating mipmap - ///< resources - UR_DEVICE_INFO_MIPMAP_ANISOTROPY_SUPPORT_EXP = 0x2009, ///< [::ur_bool_t] returns true if the device supports sampling mipmap - ///< images with anisotropic filtering - UR_DEVICE_INFO_MIPMAP_MAX_ANISOTROPY_EXP = 0x200A, ///< [uint32_t] returns the maximum anisotropic ratio supported by the - ///< device - UR_DEVICE_INFO_MIPMAP_LEVEL_REFERENCE_SUPPORT_EXP = 0x200B, ///< [::ur_bool_t] returns true if the device supports using images created - ///< from individual mipmap levels - UR_DEVICE_INFO_INTEROP_MEMORY_IMPORT_SUPPORT_EXP = 0x200C, ///< [::ur_bool_t] returns true if the device supports importing external - ///< memory resources - UR_DEVICE_INFO_INTEROP_MEMORY_EXPORT_SUPPORT_EXP = 0x200D, ///< [::ur_bool_t] returns true if the device supports exporting internal - ///< memory resources - UR_DEVICE_INFO_INTEROP_SEMAPHORE_IMPORT_SUPPORT_EXP = 0x200E, ///< [::ur_bool_t] returns true if the device supports importing external - ///< semaphore resources - UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP = 0x200F, ///< [::ur_bool_t] returns true if the device supports exporting internal - ///< event resources + UR_DEVICE_INFO_TYPE = 0, ///< [::ur_device_type_t] type of the device + UR_DEVICE_INFO_VENDOR_ID = 1, ///< [uint32_t] vendor Id of the device + UR_DEVICE_INFO_DEVICE_ID = 2, ///< [uint32_t] Id of the device + UR_DEVICE_INFO_MAX_COMPUTE_UNITS = 3, ///< [uint32_t] the number of compute units + UR_DEVICE_INFO_MAX_WORK_ITEM_DIMENSIONS = 4, ///< [uint32_t] max work item dimensions + UR_DEVICE_INFO_MAX_WORK_ITEM_SIZES = 5, ///< [size_t[]] return an array of max work item sizes + UR_DEVICE_INFO_MAX_WORK_GROUP_SIZE = 6, ///< [size_t] max work group size + UR_DEVICE_INFO_SINGLE_FP_CONFIG = 7, ///< [::ur_device_fp_capability_flags_t] single precision floating point + ///< capability + UR_DEVICE_INFO_HALF_FP_CONFIG = 8, ///< [::ur_device_fp_capability_flags_t] half precision floating point + ///< capability + UR_DEVICE_INFO_DOUBLE_FP_CONFIG = 9, ///< [::ur_device_fp_capability_flags_t] double precision floating point + ///< capability + UR_DEVICE_INFO_QUEUE_PROPERTIES = 10, ///< [::ur_queue_flags_t] command queue properties supported by the device + UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_CHAR = 11, ///< [uint32_t] preferred vector width for char + UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_SHORT = 12, ///< [uint32_t] preferred vector width for short + UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_INT = 13, ///< [uint32_t] preferred vector width for int + UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_LONG = 14, ///< [uint32_t] preferred vector width for long + UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_FLOAT = 15, ///< [uint32_t] preferred vector width for float + UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_DOUBLE = 16, ///< [uint32_t] preferred vector width for double + UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_HALF = 17, ///< [uint32_t] preferred vector width for half float + UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_CHAR = 18, ///< [uint32_t] native vector width for char + UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_SHORT = 19, ///< [uint32_t] native vector width for short + UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_INT = 20, ///< [uint32_t] native vector width for int + UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_LONG = 21, ///< [uint32_t] native vector width for long + UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_FLOAT = 22, ///< [uint32_t] native vector width for float + UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_DOUBLE = 23, ///< [uint32_t] native vector width for double + UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_HALF = 24, ///< [uint32_t] native vector width for half float + UR_DEVICE_INFO_MAX_CLOCK_FREQUENCY = 25, ///< [uint32_t] max clock frequency in MHz + UR_DEVICE_INFO_MEMORY_CLOCK_RATE = 26, ///< [uint32_t] memory clock frequency in MHz + UR_DEVICE_INFO_ADDRESS_BITS = 27, ///< [uint32_t] address bits + UR_DEVICE_INFO_MAX_MEM_ALLOC_SIZE = 28, ///< [uint64_t] max memory allocation size + UR_DEVICE_INFO_IMAGE_SUPPORTED = 29, ///< [::ur_bool_t] images are supported + UR_DEVICE_INFO_MAX_READ_IMAGE_ARGS = 30, ///< [uint32_t] max number of image objects arguments of a kernel declared + ///< with the read_only qualifier + UR_DEVICE_INFO_MAX_WRITE_IMAGE_ARGS = 31, ///< [uint32_t] max number of image objects arguments of a kernel declared + ///< with the write_only qualifier + UR_DEVICE_INFO_MAX_READ_WRITE_IMAGE_ARGS = 32, ///< [uint32_t] max number of image objects arguments of a kernel declared + ///< with the read_write qualifier + UR_DEVICE_INFO_IMAGE2D_MAX_WIDTH = 33, ///< [size_t] max width of Image2D object + UR_DEVICE_INFO_IMAGE2D_MAX_HEIGHT = 34, ///< [size_t] max height of Image2D object + UR_DEVICE_INFO_IMAGE3D_MAX_WIDTH = 35, ///< [size_t] max width of Image3D object + UR_DEVICE_INFO_IMAGE3D_MAX_HEIGHT = 36, ///< [size_t] max height of Image3D object + UR_DEVICE_INFO_IMAGE3D_MAX_DEPTH = 37, ///< [size_t] max depth of Image3D object + UR_DEVICE_INFO_IMAGE_MAX_BUFFER_SIZE = 38, ///< [size_t] max image buffer size + UR_DEVICE_INFO_IMAGE_MAX_ARRAY_SIZE = 39, ///< [size_t] max image array size + UR_DEVICE_INFO_MAX_SAMPLERS = 40, ///< [uint32_t] max number of samplers that can be used in a kernel + UR_DEVICE_INFO_MAX_PARAMETER_SIZE = 41, ///< [size_t] max size in bytes of all arguments passed to a kernel + UR_DEVICE_INFO_MEM_BASE_ADDR_ALIGN = 42, ///< [uint32_t] memory base address alignment + UR_DEVICE_INFO_GLOBAL_MEM_CACHE_TYPE = 43, ///< [::ur_device_mem_cache_type_t] global memory cache type + UR_DEVICE_INFO_GLOBAL_MEM_CACHELINE_SIZE = 44, ///< [uint32_t] global memory cache line size in bytes + UR_DEVICE_INFO_GLOBAL_MEM_CACHE_SIZE = 45, ///< [uint64_t] size of global memory cache in bytes + UR_DEVICE_INFO_GLOBAL_MEM_SIZE = 46, ///< [uint64_t] size of global memory in bytes + UR_DEVICE_INFO_GLOBAL_MEM_FREE = 47, ///< [uint64_t] size of global memory which is free in bytes + UR_DEVICE_INFO_MAX_CONSTANT_BUFFER_SIZE = 48, ///< [uint64_t] max constant buffer size in bytes + UR_DEVICE_INFO_MAX_CONSTANT_ARGS = 49, ///< [uint32_t] max number of __const declared arguments in a kernel + UR_DEVICE_INFO_LOCAL_MEM_TYPE = 50, ///< [::ur_device_local_mem_type_t] local memory type + UR_DEVICE_INFO_LOCAL_MEM_SIZE = 51, ///< [uint64_t] local memory size in bytes + UR_DEVICE_INFO_ERROR_CORRECTION_SUPPORT = 52, ///< [::ur_bool_t] support error correction to global and local memory + UR_DEVICE_INFO_HOST_UNIFIED_MEMORY = 53, ///< [::ur_bool_t] unified host device memory + UR_DEVICE_INFO_PROFILING_TIMER_RESOLUTION = 54, ///< [size_t] profiling timer resolution in nanoseconds + UR_DEVICE_INFO_ENDIAN_LITTLE = 55, ///< [::ur_bool_t] little endian byte order + UR_DEVICE_INFO_AVAILABLE = 56, ///< [::ur_bool_t] device is available + UR_DEVICE_INFO_COMPILER_AVAILABLE = 57, ///< [::ur_bool_t] device compiler is available + UR_DEVICE_INFO_LINKER_AVAILABLE = 58, ///< [::ur_bool_t] device linker is available + UR_DEVICE_INFO_EXECUTION_CAPABILITIES = 59, ///< [::ur_device_exec_capability_flags_t] device kernel execution + ///< capability bit-field + UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES = 60, ///< [::ur_queue_flags_t] device command queue property bit-field + UR_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES = 61, ///< [::ur_queue_flags_t] host queue property bit-field + UR_DEVICE_INFO_BUILT_IN_KERNELS = 62, ///< [char[]] a semi-colon separated list of built-in kernels + UR_DEVICE_INFO_PLATFORM = 63, ///< [::ur_platform_handle_t] the platform associated with the device + UR_DEVICE_INFO_REFERENCE_COUNT = 64, ///< [uint32_t] Reference count of the device object. + ///< The reference count returned should be considered immediately stale. + ///< It is unsuitable for general use in applications. This feature is + ///< provided for identifying memory leaks. + UR_DEVICE_INFO_IL_VERSION = 65, ///< [char[]] IL version + UR_DEVICE_INFO_NAME = 66, ///< [char[]] Device name + UR_DEVICE_INFO_VENDOR = 67, ///< [char[]] Device vendor + UR_DEVICE_INFO_DRIVER_VERSION = 68, ///< [char[]] Driver version + UR_DEVICE_INFO_PROFILE = 69, ///< [char[]] Device profile + UR_DEVICE_INFO_VERSION = 70, ///< [char[]] Device version + UR_DEVICE_INFO_BACKEND_RUNTIME_VERSION = 71, ///< [char[]] Version of backend runtime + UR_DEVICE_INFO_EXTENSIONS = 72, ///< [char[]] Return a space separated list of extension names + UR_DEVICE_INFO_PRINTF_BUFFER_SIZE = 73, ///< [size_t] Maximum size in bytes of internal printf buffer + UR_DEVICE_INFO_PREFERRED_INTEROP_USER_SYNC = 74, ///< [::ur_bool_t] prefer user synchronization when sharing object with + ///< other API + UR_DEVICE_INFO_PARENT_DEVICE = 75, ///< [::ur_device_handle_t] return parent device handle + UR_DEVICE_INFO_SUPPORTED_PARTITIONS = 76, ///< [::ur_device_partition_t[]] Returns an array of partition types + ///< supported by the device + UR_DEVICE_INFO_PARTITION_MAX_SUB_DEVICES = 77, ///< [uint32_t] maximum number of sub-devices when the device is + ///< partitioned + UR_DEVICE_INFO_PARTITION_AFFINITY_DOMAIN = 78, ///< [::ur_device_affinity_domain_flags_t] Returns a bit-field of the + ///< supported affinity domains for partitioning. + ///< If the device does not support any affinity domains, then 0 will be returned. + UR_DEVICE_INFO_PARTITION_TYPE = 79, ///< [::ur_device_partition_property_t[]] return an array of + ///< ::ur_device_partition_property_t for properties specified in + ///< ::urDevicePartition + UR_DEVICE_INFO_MAX_NUM_SUB_GROUPS = 80, ///< [uint32_t] max number of sub groups + UR_DEVICE_INFO_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS = 81, ///< [::ur_bool_t] support sub group independent forward progress + UR_DEVICE_INFO_SUB_GROUP_SIZES_INTEL = 82, ///< [uint32_t[]] return an array of sub group sizes supported on Intel + ///< device + UR_DEVICE_INFO_USM_HOST_SUPPORT = 83, ///< [::ur_device_usm_access_capability_flags_t] support USM host memory + ///< access + UR_DEVICE_INFO_USM_DEVICE_SUPPORT = 84, ///< [::ur_device_usm_access_capability_flags_t] support USM device memory + ///< access + UR_DEVICE_INFO_USM_SINGLE_SHARED_SUPPORT = 85, ///< [::ur_device_usm_access_capability_flags_t] support USM single device + ///< shared memory access + UR_DEVICE_INFO_USM_CROSS_SHARED_SUPPORT = 86, ///< [::ur_device_usm_access_capability_flags_t] support USM cross device + ///< shared memory access + UR_DEVICE_INFO_USM_SYSTEM_SHARED_SUPPORT = 87, ///< [::ur_device_usm_access_capability_flags_t] support USM system wide + ///< shared memory access + UR_DEVICE_INFO_UUID = 88, ///< [char[]] return device UUID + UR_DEVICE_INFO_PCI_ADDRESS = 89, ///< [char[]] return device PCI address + UR_DEVICE_INFO_GPU_EU_COUNT = 90, ///< [uint32_t] return Intel GPU EU count + UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH = 91, ///< [uint32_t] return Intel GPU EU SIMD width + UR_DEVICE_INFO_GPU_EU_SLICES = 92, ///< [uint32_t] return Intel GPU number of slices + UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE = 93, ///< [uint32_t] return Intel GPU EU count per subslice + UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE = 94, ///< [uint32_t] return Intel GPU number of subslices per slice + UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU = 95, ///< [uint32_t] return Intel GPU number of threads per EU + UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH = 96, ///< [uint32_t] return max memory bandwidth in Mb/s + UR_DEVICE_INFO_IMAGE_SRGB = 97, ///< [::ur_bool_t] device supports sRGB images + UR_DEVICE_INFO_BUILD_ON_SUBDEVICE = 98, ///< [::ur_bool_t] Return true if sub-device should do its own program + ///< build + UR_DEVICE_INFO_ATOMIC_64 = 99, ///< [::ur_bool_t] support 64 bit atomics + UR_DEVICE_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES = 100, ///< [::ur_memory_order_capability_flags_t] return a bit-field of atomic + ///< memory order capabilities + UR_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES = 101, ///< [::ur_memory_scope_capability_flags_t] return a bit-field of atomic + ///< memory scope capabilities + UR_DEVICE_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES = 102, ///< [::ur_memory_order_capability_flags_t] return a bit-field of atomic + ///< memory fence order capabilities + UR_DEVICE_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES = 103, ///< [::ur_memory_scope_capability_flags_t] return a bit-field of atomic + ///< memory fence scope capabilities + UR_DEVICE_INFO_BFLOAT16 = 104, ///< [::ur_bool_t] support for bfloat16 + UR_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES = 105, ///< [uint32_t] Returns 1 if the device doesn't have a notion of a + ///< queue index. Otherwise, returns the number of queue indices that are + ///< available for this device. + UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS = 106, ///< [::ur_bool_t] support the ::urKernelSetSpecializationConstants entry + ///< point + UR_DEVICE_INFO_MEMORY_BUS_WIDTH = 107, ///< [uint32_t] return the width in bits of the memory bus interface of the + ///< device. + UR_DEVICE_INFO_MAX_WORK_GROUPS_3D = 108, ///< [size_t[3]] return max 3D work groups + UR_DEVICE_INFO_ASYNC_BARRIER = 109, ///< [::ur_bool_t] return true if Async Barrier is supported + UR_DEVICE_INFO_MEM_CHANNEL_SUPPORT = 110, ///< [::ur_bool_t] return true if specifying memory channels is supported + UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED = 111, ///< [::ur_bool_t] Return true if the device supports enqueueing commands + ///< to read and write pipes from the host. + UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP = 112, ///< [uint32_t] The maximum number of registers available per block. + UR_DEVICE_INFO_IP_VERSION = 113, ///< [uint32_t] The device IP version. The meaning of the device IP version + ///< is implementation-defined, but newer devices should have a higher + ///< version than older devices. + UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP = 0x2000, ///< [::ur_bool_t] returns true if the device supports the creation of + ///< bindless images + UR_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT_EXP = 0x2001, ///< [::ur_bool_t] returns true if the device supports the creation of + ///< bindless images backed by shared USM + UR_DEVICE_INFO_BINDLESS_IMAGES_1D_USM_SUPPORT_EXP = 0x2002, ///< [::ur_bool_t] returns true if the device supports the creation of 1D + ///< bindless images backed by USM + UR_DEVICE_INFO_BINDLESS_IMAGES_2D_USM_SUPPORT_EXP = 0x2003, ///< [::ur_bool_t] returns true if the device supports the creation of 2D + ///< bindless images backed by USM + UR_DEVICE_INFO_IMAGE_PITCH_ALIGN_EXP = 0x2004, ///< [uint32_t] returns the required alignment of the pitch between two + ///< rows of an image in bytes + UR_DEVICE_INFO_MAX_IMAGE_LINEAR_WIDTH_EXP = 0x2005, ///< [size_t] returns the maximum linear width allowed for images allocated + ///< using USM + UR_DEVICE_INFO_MAX_IMAGE_LINEAR_HEIGHT_EXP = 0x2006, ///< [size_t] returns the maximum linear height allowed for images + ///< allocated using USM + UR_DEVICE_INFO_MAX_IMAGE_LINEAR_PITCH_EXP = 0x2007, ///< [size_t] returns the maximum linear pitch allowed for images allocated + ///< using USM + UR_DEVICE_INFO_MIPMAP_SUPPORT_EXP = 0x2008, ///< [::ur_bool_t] returns true if the device supports allocating mipmap + ///< resources + UR_DEVICE_INFO_MIPMAP_ANISOTROPY_SUPPORT_EXP = 0x2009, ///< [::ur_bool_t] returns true if the device supports sampling mipmap + ///< images with anisotropic filtering + UR_DEVICE_INFO_MIPMAP_MAX_ANISOTROPY_EXP = 0x200A, ///< [uint32_t] returns the maximum anisotropic ratio supported by the + ///< device + UR_DEVICE_INFO_MIPMAP_LEVEL_REFERENCE_SUPPORT_EXP = 0x200B, ///< [::ur_bool_t] returns true if the device supports using images created + ///< from individual mipmap levels + UR_DEVICE_INFO_INTEROP_MEMORY_IMPORT_SUPPORT_EXP = 0x200C, ///< [::ur_bool_t] returns true if the device supports importing external + ///< memory resources + UR_DEVICE_INFO_INTEROP_MEMORY_EXPORT_SUPPORT_EXP = 0x200D, ///< [::ur_bool_t] returns true if the device supports exporting internal + ///< memory resources + UR_DEVICE_INFO_INTEROP_SEMAPHORE_IMPORT_SUPPORT_EXP = 0x200E, ///< [::ur_bool_t] returns true if the device supports importing external + ///< semaphore resources + UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP = 0x2010, ///< [::ur_bool_t] returns true if the device supports exporting internal + ///< event resources /// @cond UR_DEVICE_INFO_FORCE_UINT32 = 0x7fffffff /// @endcond diff --git a/scripts/core/EXP-BINDLESS-IMAGES.rst b/scripts/core/EXP-BINDLESS-IMAGES.rst index 37ad8f6bdd..c79003ac06 100644 --- a/scripts/core/EXP-BINDLESS-IMAGES.rst +++ b/scripts/core/EXP-BINDLESS-IMAGES.rst @@ -67,7 +67,7 @@ Enums * ${x}_device_info_t * ${X}_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP - * ${X}_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT + * ${X}_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT_EXP * ${X}_DEVICE_INFO_BINDLESS_IMAGES_1D_USM_SUPPORT_EXP * ${X}_DEVICE_INFO_BINDLESS_IMAGES_2D_USM_SUPPORT_EXP * ${X}_DEVICE_INFO_IMAGE_PITCH_ALIGN_EXP diff --git a/scripts/core/exp-bindless-images.yml b/scripts/core/exp-bindless-images.yml index e9b72246d0..14386cb950 100644 --- a/scripts/core/exp-bindless-images.yml +++ b/scripts/core/exp-bindless-images.yml @@ -32,7 +32,7 @@ etors: - name: BINDLESS_IMAGES_SUPPORT_EXP value: "0x2000" desc: "[$x_bool_t] returns true if the device supports the creation of bindless images" - - name: BINDLESS_IMAGES_SHARED_USM_SUPPORT + - name: BINDLESS_IMAGES_SHARED_USM_SUPPORT_EXP value: "0x2001" desc: "[$x_bool_t] returns true if the device supports the creation of bindless images backed by shared USM" - name: BINDLESS_IMAGES_1D_USM_SUPPORT_EXP @@ -75,7 +75,7 @@ etors: value: "0x200E" desc: "[$x_bool_t] returns true if the device supports importing external semaphore resources" - name: INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP - value: "0x200F" + value: "0x2010" desc: "[$x_bool_t] returns true if the device supports exporting internal event resources" --- #-------------------------------------------------------------------------- type: enum diff --git a/source/common/ur_params.hpp b/source/common/ur_params.hpp index 4616071874..e24401c3f6 100644 --- a/source/common/ur_params.hpp +++ b/source/common/ur_params.hpp @@ -2574,8 +2574,8 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_device_info_t value) { os << "UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP"; break; - case UR_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT: - os << "UR_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT"; + case UR_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT_EXP: + os << "UR_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT_EXP"; break; case UR_DEVICE_INFO_BINDLESS_IMAGES_1D_USM_SUPPORT_EXP: @@ -4208,7 +4208,7 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT: { + case UR_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT_EXP: { const ur_bool_t *tptr = (const ur_bool_t *)ptr; if (sizeof(ur_bool_t) > size) { os << "invalid size (is: " << size From 5372d3bc786db33662e24c7ce555bfe510e750d8 Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Tue, 4 Jul 2023 15:29:28 +0100 Subject: [PATCH 044/104] [UR][CTS] Add tests for urPlatformGetNaitiveHandle and urPlatformCreateWithNativeHandle --- test/conformance/platform/CMakeLists.txt | 2 + .../urPlatformCreateWithNativeHandle.cpp | 16 +++++++ .../platform/urPlatformGetNativeHandle.cpp | 42 +++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 test/conformance/platform/urPlatformCreateWithNativeHandle.cpp create mode 100644 test/conformance/platform/urPlatformGetNativeHandle.cpp diff --git a/test/conformance/platform/CMakeLists.txt b/test/conformance/platform/CMakeLists.txt index dff3cbebf7..0bc2d46b6a 100644 --- a/test/conformance/platform/CMakeLists.txt +++ b/test/conformance/platform/CMakeLists.txt @@ -5,8 +5,10 @@ add_conformance_test(platform urInit.cpp + urPlatformCreateWithNativeHandle.cpp urPlatformGet.cpp urPlatformGetBackendOption.cpp urPlatformGetInfo.cpp urPlatformGetLastError.cpp + urPlatformGetNativeHandle.cpp urTearDown.cpp) diff --git a/test/conformance/platform/urPlatformCreateWithNativeHandle.cpp b/test/conformance/platform/urPlatformCreateWithNativeHandle.cpp new file mode 100644 index 0000000000..00d8ce78ea --- /dev/null +++ b/test/conformance/platform/urPlatformCreateWithNativeHandle.cpp @@ -0,0 +1,16 @@ +// Copyright (C) 2022-2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "fixtures.h" + +using urPlatformCreateWithNativeHandleTest = uur::platform::urPlatformTest; + +TEST_F(urPlatformCreateWithNativeHandleTest, InvalidNullPointerPlatform) { + ur_native_handle_t native_handle = nullptr; + ASSERT_SUCCESS(urPlatformGetNativeHandle(platform, &native_handle)); + ASSERT_EQ_RESULT( + UR_RESULT_ERROR_INVALID_NULL_POINTER, + urPlatformCreateWithNativeHandle(native_handle, nullptr, nullptr)); +} diff --git a/test/conformance/platform/urPlatformGetNativeHandle.cpp b/test/conformance/platform/urPlatformGetNativeHandle.cpp new file mode 100644 index 0000000000..77ae08bc78 --- /dev/null +++ b/test/conformance/platform/urPlatformGetNativeHandle.cpp @@ -0,0 +1,42 @@ +// Copyright (C) 2022-2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "fixtures.h" + +using urPlatformGetNativeHandleTest = uur::platform::urPlatformsTest; + +TEST_F(urPlatformGetNativeHandleTest, Success) { + for (auto platform : platforms) { + ur_native_handle_t native_handle = nullptr; + ASSERT_SUCCESS(urPlatformGetNativeHandle(platform, &native_handle)); + + // We cannot assume anything about a native_handle, not even if it's + // `nullptr` since this could be a valid representation within a backend. + // We can however convert the native_handle back into a unified-runtime + // handle and perform some query on it to verify that it works. + ur_platform_handle_t plat = nullptr; + ASSERT_SUCCESS( + urPlatformCreateWithNativeHandle(native_handle, nullptr, &plat)); + ASSERT_NE(plat, nullptr); + + ur_platform_backend_t backend; + ASSERT_SUCCESS(urPlatformGetInfo(plat, UR_PLATFORM_INFO_BACKEND, + sizeof(ur_platform_backend_t), + &backend, nullptr)); + } +} + +TEST_F(urPlatformGetNativeHandleTest, InvalidNullHandlePlatform) { + ur_native_handle_t native_handle = nullptr; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urPlatformGetNativeHandle(nullptr, &native_handle)); +} + +TEST_F(urPlatformGetNativeHandleTest, InvalidNullPointerNativePlatform) { + for (auto platform : platforms) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, + urPlatformGetNativeHandle(platform, nullptr)); + } +} From a096f11ba124948a5561f579780f654bfa8e2fa8 Mon Sep 17 00:00:00 2001 From: Isaac Ault Date: Wed, 5 Jul 2023 11:27:43 +0100 Subject: [PATCH 045/104] Fix enumeration typo --- include/ur.py | 2 +- include/ur_api.h | 2 +- scripts/core/exp-bindless-images.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/ur.py b/include/ur.py index fcbca4e31d..f1a1b48b2a 100644 --- a/include/ur.py +++ b/include/ur.py @@ -789,7 +789,7 @@ class ur_device_info_v(IntEnum): ## memory resources INTEROP_SEMAPHORE_IMPORT_SUPPORT_EXP = 0x200E ## [::ur_bool_t] returns true if the device supports importing external ## semaphore resources - INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP = 0x2010 ## [::ur_bool_t] returns true if the device supports exporting internal + INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP = 0x200F ## [::ur_bool_t] returns true if the device supports exporting internal ## event resources class ur_device_info_t(c_int): diff --git a/include/ur_api.h b/include/ur_api.h index 6c9235de11..aab6a9c50b 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -1183,7 +1183,7 @@ typedef enum ur_device_info_t { ///< memory resources UR_DEVICE_INFO_INTEROP_SEMAPHORE_IMPORT_SUPPORT_EXP = 0x200E, ///< [::ur_bool_t] returns true if the device supports importing external ///< semaphore resources - UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP = 0x2010, ///< [::ur_bool_t] returns true if the device supports exporting internal + UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP = 0x200F, ///< [::ur_bool_t] returns true if the device supports exporting internal ///< event resources /// @cond UR_DEVICE_INFO_FORCE_UINT32 = 0x7fffffff diff --git a/scripts/core/exp-bindless-images.yml b/scripts/core/exp-bindless-images.yml index 14386cb950..800808f6f0 100644 --- a/scripts/core/exp-bindless-images.yml +++ b/scripts/core/exp-bindless-images.yml @@ -75,7 +75,7 @@ etors: value: "0x200E" desc: "[$x_bool_t] returns true if the device supports importing external semaphore resources" - name: INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP - value: "0x2010" + value: "0x200F" desc: "[$x_bool_t] returns true if the device supports exporting internal event resources" --- #-------------------------------------------------------------------------- type: enum From d367c68c73580467fcb340b9f37b51c1b58bf0da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Stolarczuk?= Date: Tue, 4 Jul 2023 17:14:52 +0200 Subject: [PATCH 046/104] [UR] Revamp README file a little - add TOC to the top-level README file, - order sections and group them together (incl. new Contrib section), - clean and unify Markdown syntax a little, - add new badges for CodeQL and Bandit, - fix main GHA badge to point to a specific ('cmake') workflow. --- README.md | 100 +++++++++++++++++++++++++++------------------- scripts/README.md | 10 ++--- 2 files changed, 63 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index b295f3c314..634bcc6ca9 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,29 @@ # Unified Runtime -[![GHA build status](https://github.com/oneapi-src/unified-runtime/actions/workflows/cmake.yml/badge.svg?branch=main)](https://github.com/oneapi-src/unified-runtime/actions) +[![Build and test](https://github.com/oneapi-src/unified-runtime/actions/workflows/cmake.yml/badge.svg)](https://github.com/oneapi-src/unified-runtime/actions/workflows/cmake.yml) +[![CodeQL](https://github.com/oneapi-src/unified-runtime/actions/workflows/codeql.yml/badge.svg)](https://github.com/oneapi-src/unified-runtime/actions/workflows/codeql.yml) +[![Bandit](https://github.com/oneapi-src/unified-runtime/actions/workflows/bandit.yml/badge.svg)](https://github.com/oneapi-src/unified-runtime/actions/workflows/bandit.yml) -> **Note** -> -> For those who intend to make a contribution to the project please read our -> [Contribution Guide](https://oneapi-src.github.io/unified-runtime/core/CONTRIB.html) -> for more information. + -## Contents +## Table of contents + +1. [Contents of the repo](#contents-of-the-repo) +2. [Integration](#integration) + - [Weekly tags](#weekly-tags) +3. [Third-Party tools](#third-party-tools) +4. [Building](#building) + - [Windows](#windows) + - [Linux](#linux) + - [CMake standard options](#cmake-standard-options) + - [Additional make targets](#additional-make-targets) +5. [Contributions](#contributions) + - [Adapter naming convention](#adapter-naming-convention) + - [Source code generation](#source-code-generation) + - [Documentation](#documentation) + + +## Contents of the repo This repo contains the following: @@ -41,7 +56,7 @@ add_executable(example example.cpp) target_link_libraries(example PUBLIC unified-runtime::headers) ``` -### Weekly Tags +### Weekly tags Each Friday at 23:00 UTC time a [prerelease tag](https://github.com/oneapi-src/unified-runtime/releases) is created which @@ -49,15 +64,7 @@ takes the form `weekly-YYYY-MM-DD`. These tags should be used by downstream projects which intend to track development closely but maintain a fixed point in history to avoid pulling potentially breaking changes from the `main` branch. -## Source Code Generation - -Code is generated using included [Python scripts](/scripts/README.md). - -## Documentation - -Documentation is generated from source code using Sphinx. - -## Third-Party Tools +## Third-Party tools Tools can be acquired via instructions in [third_party](/third_party/README.md). @@ -65,31 +72,29 @@ Tools can be acquired via instructions in [third_party](/third_party/README.md). Requirements: - C++ compiler with C++17 support -- cmake >= 3.14.0 +- [CMake](https://cmake.org/) >= 3.14.0 - clang-format-15.0 (can be installed with `python -m pip install clang-format==15.0.7`) -Project is defined using [CMake](https://cmake.org/). - -**Windows**: +### Windows -Generating Visual Studio Project. EXE and binaries will be in **build/bin/{build_config}** +Generating Visual Studio Project. EXE and binaries will be in **build/bin/{build_config}** -~~~~ +```bash $ mkdir build $ cd build $ cmake {path_to_source_dir} -G "Visual Studio 15 2017 Win64" -~~~~ +``` -**Linux**: +### Linux Executable and binaries will be in **build/bin** -~~~~ +```bash $ mkdir build $ cd build $ cmake {path_to_source_dir} $ make -~~~~ +``` ### CMake standard options @@ -98,32 +103,36 @@ List of options provided by CMake: | Name | Description | Values | Default | | - | - | - | - | | UR_BUILD_TESTS | Build the tests | ON/OFF | ON | +| UR_BUILD_TOOLS | Build tools | ON/OFF | ON | | UR_FORMAT_CPP_STYLE | Format code style | ON/OFF | OFF | | UR_DEVELOPER_MODE | Treat warnings as errors and enables additional checks | ON/OFF | OFF | | UR_USE_ASAN | Enable AddressSanitizer | ON/OFF | OFF | | UR_USE_UBSAN | Enable UndefinedBehavior Sanitizer | ON/OFF | OFF | | UR_USE_MSAN | Enable MemorySanitizer (clang only) | ON/OFF | OFF | | UR_ENABLE_TRACING | Enable XPTI-based tracing layer | ON/OFF | OFF | -| UR_BUILD_TOOLS | Build tools | ON/OFF | ON | -**General**: +### Additional make targets + +To run automated code formatting, configure CMake with `UR_FORMAT_CPP_STYLE` option +and then run a custom `cppformat` target: -To run automated code formatting build with option `UR_FORMAT_CPP_STYLE` and then run a custom `cppformat` target: -~~~~ +```bash $ make cppformat -~~~~ +``` -If you've made modifications to the specification, you can also run a custom `generate-code` or `generate` target prior to building. -This call will generate the source code: -~~~~ -$ make generate-code -~~~~ +If you've made modifications to the specification, you can also run +a custom `generate` target prior to building. +It will generate the source code **and** run automated code formatting: -This call will generate the source code and run automated code formatting: -~~~~ +```bash $ make generate -~~~~ -Note: `generate` target requires `UR_FORMAT_CPP_STYLE` to bet set. +``` + +## Contributions + +For those who intend to make a contribution to the project please read our +[Contribution Guide](https://oneapi-src.github.io/unified-runtime/core/CONTRIB.html) +for more information. ### Adapter naming convention @@ -132,3 +141,12 @@ to use the following naming convention: * On Linux platforms, use `libur_adapter_[name].so`. * On Windows platforms, use `ur_adapter_[name].dll`. + +### Source code generation + +Code is generated using included [Python scripts](/scripts/README.md). + +### Documentation + +Documentation is generated from source code using Sphinx - +see [scripts dir](/scripts/README.md) for details. diff --git a/scripts/README.md b/scripts/README.md index f7c41b445a..c51008a120 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -4,12 +4,10 @@ Python dependencies: * [PyYAML](https://pyyaml.org/) v3.13 * [Sphinx](https://www.sphinx-doc.org/en/master/) v2.2.2 -Installing Python dependencies: - ~~~~ - * Install all python requirements. - ~~~~ - python -m pip install -r ../third_party/requirements.txt - ~~~~ +To install all Python dependencies, execute: +```bash +$ python -m pip install -r ../third_party/requirements.txt +``` Documentation is generated from source code using Doxygen. * [Doxygen](http://www.doxygen.nl/) v1.8.15 From 9744b2515ab4362ce765fe610f4e612f11f7a82f Mon Sep 17 00:00:00 2001 From: Isaac Ault Date: Wed, 5 Jul 2023 12:52:59 +0100 Subject: [PATCH 047/104] Update changelog. --- scripts/core/EXP-BINDLESS-IMAGES.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/core/EXP-BINDLESS-IMAGES.rst b/scripts/core/EXP-BINDLESS-IMAGES.rst index c79003ac06..7bd1445871 100644 --- a/scripts/core/EXP-BINDLESS-IMAGES.rst +++ b/scripts/core/EXP-BINDLESS-IMAGES.rst @@ -159,6 +159,8 @@ Changelog | || Removed 3D USM capabilities. | | || Added mip filter mode. | +----------+----------------------------------------------------------+ +| 3.0 | Added device query for bindless images on shared USM | ++----------+---------------------------------------------------------+ Contributors -------------------------------------------------------------------------------- From 2f1df3f5992523b2c3a6a4e6df05d710d313d394 Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Tue, 4 Jul 2023 16:00:37 +0100 Subject: [PATCH 048/104] [UR][CTS] Add tests for urEnqueueDeviceGlobalRead/Write --- test/conformance/device_code/CMakeLists.txt | 1 + .../conformance/device_code/device_global.cpp | 23 +++++ test/conformance/enqueue/CMakeLists.txt | 2 + .../urEnqueueDeviceGlobalVariableRead.cpp | 91 +++++++++++++++++++ .../urEnqueueDeviceGlobalVariableWrite.cpp | 68 ++++++++++++++ .../testing/include/uur/fixtures.h | 16 ++++ 6 files changed, 201 insertions(+) create mode 100644 test/conformance/device_code/device_global.cpp create mode 100644 test/conformance/enqueue/urEnqueueDeviceGlobalVariableRead.cpp create mode 100644 test/conformance/enqueue/urEnqueueDeviceGlobalVariableWrite.cpp diff --git a/test/conformance/device_code/CMakeLists.txt b/test/conformance/device_code/CMakeLists.txt index e834d414fb..1d3f28df7f 100644 --- a/test/conformance/device_code/CMakeLists.txt +++ b/test/conformance/device_code/CMakeLists.txt @@ -24,6 +24,7 @@ macro(add_device_binary SOURCE_FILE) endmacro() add_device_binary(${CMAKE_CURRENT_SOURCE_DIR}/bar.cpp) +add_device_binary(${CMAKE_CURRENT_SOURCE_DIR}/device_global.cpp) add_device_binary(${CMAKE_CURRENT_SOURCE_DIR}/fill.cpp) add_device_binary(${CMAKE_CURRENT_SOURCE_DIR}/fill_2d.cpp) add_device_binary(${CMAKE_CURRENT_SOURCE_DIR}/fill_3d.cpp) diff --git a/test/conformance/device_code/device_global.cpp b/test/conformance/device_code/device_global.cpp new file mode 100644 index 0000000000..3ead86bbf5 --- /dev/null +++ b/test/conformance/device_code/device_global.cpp @@ -0,0 +1,23 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include + +sycl::ext::oneapi::experimental::device_global dev_var; + +int main() { + + sycl::queue deviceQueue; + sycl::range<1> numOfItems{1}; + deviceQueue.submit([&](sycl::handler &cgh) { + auto kern = [=](sycl::id<1>) { + // just increment + dev_var = dev_var + 1; + }; + cgh.parallel_for(numOfItems, kern); + }); + + return 0; +} diff --git a/test/conformance/enqueue/CMakeLists.txt b/test/conformance/enqueue/CMakeLists.txt index 2e364b5bdb..532cab1b85 100644 --- a/test/conformance/enqueue/CMakeLists.txt +++ b/test/conformance/enqueue/CMakeLists.txt @@ -4,6 +4,8 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception add_conformance_test_with_kernels_environment(enqueue + urEnqueueDeviceGlobalVariableRead.cpp + urEnqueueDeviceGlobalVariableWrite.cpp urEnqueueEventsWait.cpp urEnqueueEventsWaitWithBarrier.cpp urEnqueueKernelLaunch.cpp diff --git a/test/conformance/enqueue/urEnqueueDeviceGlobalVariableRead.cpp b/test/conformance/enqueue/urEnqueueDeviceGlobalVariableRead.cpp new file mode 100644 index 0000000000..df1e70b2b3 --- /dev/null +++ b/test/conformance/enqueue/urEnqueueDeviceGlobalVariableRead.cpp @@ -0,0 +1,91 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +using urEnqueueDeviceGetGlobalVariableReadTest = uur::urGlobalVariableTest; +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urEnqueueDeviceGetGlobalVariableReadTest); + +TEST_P(urEnqueueDeviceGetGlobalVariableReadTest, Success) { + + ASSERT_SUCCESS(urEnqueueDeviceGlobalVariableWrite( + queue, program, global_var.name.c_str(), true, sizeof(global_var.value), + 0, &global_var.value, 0, nullptr, nullptr)); + + size_t global_offset = 0; + size_t n_dimensions = 1; + size_t global_size = 1; + + // execute the kernel + ASSERT_SUCCESS(urEnqueueKernelLaunch(queue, kernel, n_dimensions, + &global_offset, &global_size, nullptr, + 1, nullptr, nullptr)); + ASSERT_SUCCESS(urQueueFinish(queue)); + + // read global var back to host + ASSERT_SUCCESS(urEnqueueDeviceGlobalVariableRead( + queue, program, global_var.name.c_str(), true, sizeof(global_var.value), + 0, &global_var.value, 0, nullptr, nullptr)); + + // kernel should increment value + ASSERT_EQ(global_var.value, 1); +} + +TEST_P(urEnqueueDeviceGetGlobalVariableReadTest, InvalidNullHandleQueue) { + ASSERT_EQ_RESULT(urEnqueueDeviceGlobalVariableRead( + nullptr, program, global_var.name.c_str(), true, + sizeof(global_var.value), 0, &global_var.value, 0, + nullptr, nullptr), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urEnqueueDeviceGetGlobalVariableReadTest, InvalidNullHandleProgram) { + ASSERT_EQ_RESULT(urEnqueueDeviceGlobalVariableRead( + queue, nullptr, global_var.name.c_str(), true, + sizeof(global_var.value), 0, &global_var.value, 0, + nullptr, nullptr), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urEnqueueDeviceGetGlobalVariableReadTest, InvalidNullPointerName) { + ASSERT_EQ_RESULT(urEnqueueDeviceGlobalVariableRead( + queue, program, nullptr, true, + sizeof(global_var.value), 0, &global_var.value, 0, + nullptr, nullptr), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} + +TEST_P(urEnqueueDeviceGetGlobalVariableReadTest, InvalidNullPointerDst) { + ASSERT_EQ_RESULT(urEnqueueDeviceGlobalVariableRead( + queue, program, global_var.name.c_str(), true, + sizeof(global_var.value), 0, nullptr, 0, nullptr, + nullptr), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} + +TEST_P(urEnqueueDeviceGetGlobalVariableReadTest, + InvalidEventWaitListNullEvents) { + ASSERT_EQ_RESULT(urEnqueueDeviceGlobalVariableRead( + queue, program, global_var.name.c_str(), true, + sizeof(global_var.value), 0, &global_var.value, 1, + nullptr, nullptr), + UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST); +} + +TEST_P(urEnqueueDeviceGetGlobalVariableReadTest, InvalidEventWaitListZeroSize) { + ur_event_handle_t evt = nullptr; + ASSERT_EQ_RESULT(urEnqueueDeviceGlobalVariableRead( + queue, program, global_var.name.c_str(), true, + sizeof(global_var.value), 0, &global_var.value, 0, + &evt, nullptr), + UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST); +} +TEST_P(urEnqueueDeviceGetGlobalVariableReadTest, InvalidEventWaitInvalidEvent) { + ur_event_handle_t inv_evt = nullptr; + ASSERT_EQ_RESULT(urEnqueueDeviceGlobalVariableRead( + queue, program, global_var.name.c_str(), true, + sizeof(global_var.value), 0, &global_var.value, 1, + &inv_evt, nullptr), + UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST); +} diff --git a/test/conformance/enqueue/urEnqueueDeviceGlobalVariableWrite.cpp b/test/conformance/enqueue/urEnqueueDeviceGlobalVariableWrite.cpp new file mode 100644 index 0000000000..b665314b48 --- /dev/null +++ b/test/conformance/enqueue/urEnqueueDeviceGlobalVariableWrite.cpp @@ -0,0 +1,68 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +using urEnqueueDeviceGetGlobalVariableWriteTest = uur::urGlobalVariableTest; +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urEnqueueDeviceGetGlobalVariableWriteTest); + +TEST_P(urEnqueueDeviceGetGlobalVariableWriteTest, InvalidNullHandleQueue) { + ASSERT_EQ_RESULT(urEnqueueDeviceGlobalVariableWrite( + nullptr, program, global_var.name.c_str(), true, + sizeof(global_var.value), 0, &global_var.value, 0, + nullptr, nullptr), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urEnqueueDeviceGetGlobalVariableWriteTest, InvalidNullHandleProgram) { + ASSERT_EQ_RESULT(urEnqueueDeviceGlobalVariableWrite( + queue, nullptr, global_var.name.c_str(), true, + sizeof(global_var.value), 0, &global_var.value, 0, + nullptr, nullptr), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urEnqueueDeviceGetGlobalVariableWriteTest, InvalidNullPointerName) { + ASSERT_EQ_RESULT(urEnqueueDeviceGlobalVariableWrite( + queue, program, nullptr, true, + sizeof(global_var.value), 0, &global_var.value, 0, + nullptr, nullptr), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} + +TEST_P(urEnqueueDeviceGetGlobalVariableWriteTest, InvalidNullPointerSrc) { + ASSERT_EQ_RESULT(urEnqueueDeviceGlobalVariableWrite( + queue, program, global_var.name.c_str(), true, + sizeof(global_var.value), 0, nullptr, 0, nullptr, + nullptr), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} + +TEST_P(urEnqueueDeviceGetGlobalVariableWriteTest, + InvalidEventWaitListNullEvents) { + ASSERT_EQ_RESULT(urEnqueueDeviceGlobalVariableWrite( + queue, program, global_var.name.c_str(), true, + sizeof(global_var.value), 0, &global_var.value, 1, + nullptr, nullptr), + UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST); +} + +TEST_P(urEnqueueDeviceGetGlobalVariableWriteTest, + InvalidEventWaitListZeroSize) { + ur_event_handle_t evt = nullptr; + ASSERT_EQ_RESULT(urEnqueueDeviceGlobalVariableWrite( + queue, program, global_var.name.c_str(), true, + sizeof(global_var.value), 0, &global_var.value, 0, + &evt, nullptr), + UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST); +} +TEST_P(urEnqueueDeviceGetGlobalVariableWriteTest, + InvalidEventWaitInvalidEvent) { + ur_event_handle_t inv_evt = nullptr; + ASSERT_EQ_RESULT(urEnqueueDeviceGlobalVariableWrite( + queue, program, global_var.name.c_str(), true, + sizeof(global_var.value), 0, &global_var.value, 1, + &inv_evt, nullptr), + UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST); +} diff --git a/test/conformance/testing/include/uur/fixtures.h b/test/conformance/testing/include/uur/fixtures.h index 65a91d6df7..4112cd9174 100644 --- a/test/conformance/testing/include/uur/fixtures.h +++ b/test/conformance/testing/include/uur/fixtures.h @@ -993,6 +993,22 @@ struct urKernelExecutionTest : urKernelTest { std::vector buffer_args; uint32_t current_arg_index = 0; }; + +template struct GlobalVar { + std::string name; + T value; +}; + +struct urGlobalVariableTest : uur::urKernelExecutionTest { + void SetUp() override { + program_name = "device_global"; + global_var = {"_Z7dev_var", 0}; + UUR_RETURN_ON_FATAL_FAILURE(uur::urKernelExecutionTest::SetUp()); + } + + GlobalVar global_var; +}; + } // namespace uur #endif // UR_CONFORMANCE_INCLUDE_FIXTURES_H_INCLUDED From ae2c4031956cdc1e3b2ff27e6bfbc548de41acc2 Mon Sep 17 00:00:00 2001 From: Aaron Greig Date: Thu, 6 Jul 2023 16:36:56 +0100 Subject: [PATCH 049/104] Correct size of UR_DEVICE_INFO_MEMORY_BUS_WIDTH in CTS test. --- test/conformance/device/urDeviceGetInfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/conformance/device/urDeviceGetInfo.cpp b/test/conformance/device/urDeviceGetInfo.cpp index eb8321b7b4..3eb73cb53c 100644 --- a/test/conformance/device/urDeviceGetInfo.cpp +++ b/test/conformance/device/urDeviceGetInfo.cpp @@ -106,7 +106,7 @@ static std::unordered_map device_info_size_map = { {UR_DEVICE_INFO_BFLOAT16, sizeof(ur_bool_t)}, {UR_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES, sizeof(uint32_t)}, {UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS, sizeof(ur_bool_t)}, - {UR_DEVICE_INFO_MEMORY_BUS_WIDTH, sizeof(ur_bool_t)}, + {UR_DEVICE_INFO_MEMORY_BUS_WIDTH, sizeof(uint32_t)}, {UR_DEVICE_INFO_MAX_WORK_GROUPS_3D, sizeof(size_t[3])}, {UR_DEVICE_INFO_ASYNC_BARRIER, sizeof(ur_bool_t)}, {UR_DEVICE_INFO_MEM_CHANNEL_SUPPORT, sizeof(ur_bool_t)}, From 07b763351588c37ea542bee555661fe66287e096 Mon Sep 17 00:00:00 2001 From: Igor Chorazewicz Date: Wed, 5 Jul 2023 21:02:22 +0000 Subject: [PATCH 050/104] [umf] create/destroy memory tracker in lib ctor/dtor instead of relying on global variable init/destruction on linux and on windows (when building UMF as a shared lib). In C++ no guarantee is made for initialization order of static variables across translation units. This is problematic when an application (e.g. SYCL) wants to do some cleanup in it's library destructor. Such application might want to specify priority for it's destructor (to make sure it's executed before any other library desturctor) but it doesn't seem to work for static variables. Memory tracker is still created as a global object when building UMF as a static lib on Windows - there is no __attribute__((destructor)) equivalent that would work for static library. --- .../unified_malloc_framework/CMakeLists.txt | 1 + .../src/memory_tracker.cpp | 29 +++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/source/common/unified_malloc_framework/CMakeLists.txt b/source/common/unified_malloc_framework/CMakeLists.txt index 30991629cd..86d19f3099 100644 --- a/source/common/unified_malloc_framework/CMakeLists.txt +++ b/source/common/unified_malloc_framework/CMakeLists.txt @@ -16,6 +16,7 @@ if(UMF_BUILD_SHARED_LIBRARY) "Do not use the shared library in production software.") add_library(unified_malloc_framework SHARED ${UMF_SOURCES}) + target_compile_definitions(unified_malloc_framework PUBLIC UMF_SHARED_LIBRARY) else() add_library(unified_malloc_framework STATIC ${UMF_SOURCES}) diff --git a/source/common/unified_malloc_framework/src/memory_tracker.cpp b/source/common/unified_malloc_framework/src/memory_tracker.cpp index 74638579cc..adbe2aa5e9 100644 --- a/source/common/unified_malloc_framework/src/memory_tracker.cpp +++ b/source/common/unified_malloc_framework/src/memory_tracker.cpp @@ -18,6 +18,10 @@ #include #include +#ifdef _WIN32 +#include +#endif + // TODO: reimplement in C and optimize... struct umf_memory_tracker_t { enum umf_result_t add(void *pool, const void *ptr, size_t size) { @@ -84,11 +88,30 @@ umfMemoryTrackerRemove(umf_memory_tracker_handle_t hTracker, const void *ptr, extern "C" { -umf_memory_tracker_handle_t umfMemoryTrackerGet(void) { - static umf_memory_tracker_t tracker; - return &tracker; +#if defined(_WIN32) && defined(UMF_SHARED_LIBRARY) +umf_memory_tracker_t *tracker = nullptr; +BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { + if (fdwReason == DLL_PROCESS_DETACH) { + delete tracker; + } else if (fdwReason == DLL_PROCESS_ATTACH) { + tracker = new umf_memory_tracker_t; + } + return TRUE; +} +#elif defined(_WIN32) +umf_memory_tracker_t trackerInstance; +umf_memory_tracker_t *tracker = &trackerInstance; +#else +umf_memory_tracker_t *tracker = nullptr; +void __attribute__((constructor)) createLibTracker() { + tracker = new umf_memory_tracker_t; } +void __attribute__((destructor)) deleteLibTracker() { delete tracker; } +#endif + +umf_memory_tracker_handle_t umfMemoryTrackerGet(void) { return tracker; } + void *umfMemoryTrackerGetPool(umf_memory_tracker_handle_t hTracker, const void *ptr) { return hTracker->find(ptr); From 4af97e7fd8e00a52f84c6b03dde4ba3702c291e3 Mon Sep 17 00:00:00 2001 From: initial Date: Fri, 19 May 2023 11:18:37 +0100 Subject: [PATCH 051/104] [UR] Allow compilation on apple --- examples/hello_world/CMakeLists.txt | 5 +---- source/common/linux/ur_lib_loader.cpp | 2 +- source/common/umf_pools/disjoint_pool.hpp | 1 + test/unified_malloc_framework/common/pool.hpp | 6 ++++++ 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/examples/hello_world/CMakeLists.txt b/examples/hello_world/CMakeLists.txt index b1723ae605..bde1fd9cf5 100644 --- a/examples/hello_world/CMakeLists.txt +++ b/examples/hello_world/CMakeLists.txt @@ -9,10 +9,6 @@ add_executable(${TARGET_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/hello_world.cpp ) -target_include_directories(${TARGET_NAME} PRIVATE - ${CMAKE_SOURCE_DIR}/include -) - if(MSVC) set_target_properties(${TARGET_NAME} PROPERTIES @@ -24,4 +20,5 @@ endif() target_link_libraries(${TARGET_NAME} PRIVATE ${PROJECT_NAME}::loader ${CMAKE_DL_LIBS} + ${PROJECT_NAME}::headers ) diff --git a/source/common/linux/ur_lib_loader.cpp b/source/common/linux/ur_lib_loader.cpp index 445de6f2eb..1c5e0af89b 100644 --- a/source/common/linux/ur_lib_loader.cpp +++ b/source/common/linux/ur_lib_loader.cpp @@ -12,7 +12,7 @@ #include "logger/ur_logger.hpp" #include "ur_lib_loader.hpp" -#if defined(SANITIZER_ANY) +#if defined(SANITIZER_ANY) || defined(__APPLE__) #define LOAD_DRIVER_LIBRARY(NAME) dlopen(NAME, RTLD_LAZY | RTLD_LOCAL) #else #define LOAD_DRIVER_LIBRARY(NAME) \ diff --git a/source/common/umf_pools/disjoint_pool.hpp b/source/common/umf_pools/disjoint_pool.hpp index 85dd86872d..48d0ecf51b 100644 --- a/source/common/umf_pools/disjoint_pool.hpp +++ b/source/common/umf_pools/disjoint_pool.hpp @@ -11,6 +11,7 @@ #include #include +#include #include "../umf_helpers.hpp" diff --git a/test/unified_malloc_framework/common/pool.hpp b/test/unified_malloc_framework/common/pool.hpp index 7ec62b8741..5be080ef33 100644 --- a/test/unified_malloc_framework/common/pool.hpp +++ b/test/unified_malloc_framework/common/pool.hpp @@ -11,7 +11,11 @@ #ifndef UMF_TEST_POOL_HPP #define UMF_TEST_POOL_HPP 1 +#if defined(__APPLE__) +#include +#else #include +#endif #include #include @@ -61,6 +65,8 @@ struct malloc_pool : public pool_base { size_t malloc_usable_size(void *ptr) noexcept { #ifdef _WIN32 return _msize(ptr); +#elif __APPLE__ + return ::malloc_size(ptr); #else return ::malloc_usable_size(ptr); #endif From 70459f4c04ac0d0e2d352590a953aef92fdd02e7 Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Fri, 7 Jul 2023 14:39:49 +0100 Subject: [PATCH 052/104] [UR] Add simple macos action --- .github/workflows/cmake.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index fdfaf6cc1f..d3fd0e3e5e 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -125,3 +125,33 @@ jobs: - name: Test working-directory: ${{github.workspace}}/build run: ctest -C ${{matrix.build_type}} --output-on-failure -L "python|umf|loader|validation|tracing|unit|urtrace" + + + macos-build: + name: Build - MacOS + strategy: + matrix: + os: ['macos-12', 'macos-13'] + runs-on: ${{matrix.os}} + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + with: + python-version: 3.9 + + - name: Install prerequisites + run: python3 -m pip install -r third_party/requirements.txt + + - name: Configure CMake + run: > + cmake + -B${{github.workspace}}/build + -DUR_ENABLE_TRACING=ON + -DUR_DEVELOPER_MODE=ON + -DCMAKE_BUILD_TYPE=Release + -DUR_BUILD_TESTS=ON + -DUR_FORMAT_CPP_STYLE=ON + - name: Build + run: cmake --build ${{github.workspace}}/build -j $(nproc) From 8653be6311919cbc620b94e3390de577b55d4230 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Thu, 16 Mar 2023 16:34:43 +0000 Subject: [PATCH 053/104] [ur] macOS fix dylib version & enable color diagnostics Update the `MAKE_LIBRARY_NAME` macro to match the library naming scheme CMake uses when `VERSION` is specified on macOS, taking the form `lib..dylib`. Enable color diagnostics for AppleClang. And disable the `CMAKE_FIND_FRAMEWORK` option so that in-tree dylibs are correctly loaded. --- CMakeLists.txt | 6 +++++- source/common/ur_util.hpp | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e7b03bb00f..f19ea5618b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,10 @@ include(CTest) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include(helpers) +if(CMAKE_SYSTEM_NAME STREQUAL Darwin) + set(CMAKE_FIND_FRAMEWORK NEVER) +endif() + find_package(Python3 COMPONENTS Interpreter) set(CMAKE_CXX_STANDARD 17) @@ -52,7 +56,7 @@ endif() if(NOT MSVC) add_compile_options(-fPIC -Wall -Wpedantic $<$:-fdiagnostics-color=always> - $<$:-fcolor-diagnostics>) + $<$:-fcolor-diagnostics>) if(UR_DEVELOPER_MODE) add_compile_options(-Werror -fno-omit-frame-pointer) endif() diff --git a/source/common/ur_util.hpp b/source/common/ur_util.hpp index 5bf556dda6..e77d439275 100644 --- a/source/common/ur_util.hpp +++ b/source/common/ur_util.hpp @@ -57,8 +57,12 @@ inline int ur_getpid(void) { return static_cast(getpid()); } #define MAKE_LIBRARY_NAME(NAME, VERSION) NAME ".dll" #else #define HMODULE void * +#if defined(__APPLE__) +#define MAKE_LIBRARY_NAME(NAME, VERSION) "lib" NAME "." VERSION ".dylib" +#else #define MAKE_LIBRARY_NAME(NAME, VERSION) "lib" NAME ".so." VERSION #endif +#endif inline std::string create_library_path(const char *name, const char *path) { std::string library_path; From e29d495798d3e432066178d7df6b00c5ff4f02f9 Mon Sep 17 00:00:00 2001 From: Piotr Balcer Date: Mon, 10 Jul 2023 08:30:18 +0200 Subject: [PATCH 054/104] Add coverity badge to README Coverity finally started working correctly. Thanks @wlemkows. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 634bcc6ca9..534a198573 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![Build and test](https://github.com/oneapi-src/unified-runtime/actions/workflows/cmake.yml/badge.svg)](https://github.com/oneapi-src/unified-runtime/actions/workflows/cmake.yml) [![CodeQL](https://github.com/oneapi-src/unified-runtime/actions/workflows/codeql.yml/badge.svg)](https://github.com/oneapi-src/unified-runtime/actions/workflows/codeql.yml) [![Bandit](https://github.com/oneapi-src/unified-runtime/actions/workflows/bandit.yml/badge.svg)](https://github.com/oneapi-src/unified-runtime/actions/workflows/bandit.yml) +[![Coverity](https://scan.coverity.com/projects/28213/badge.svg)](https://scan.coverity.com/projects/oneapi-src-unified-runtime) From 90e8de47836de1dd384bf673d921108853a364ab Mon Sep 17 00:00:00 2001 From: "Vinogradov, Sergei" Date: Mon, 10 Jul 2023 10:19:35 -0400 Subject: [PATCH 055/104] Add missing include to umf/memory_pool_ops.h --- .../unified_malloc_framework/include/umf/memory_pool_ops.h | 1 + 1 file changed, 1 insertion(+) diff --git a/source/common/unified_malloc_framework/include/umf/memory_pool_ops.h b/source/common/unified_malloc_framework/include/umf/memory_pool_ops.h index 16a7d1252e..03660f695c 100644 --- a/source/common/unified_malloc_framework/include/umf/memory_pool_ops.h +++ b/source/common/unified_malloc_framework/include/umf/memory_pool_ops.h @@ -12,6 +12,7 @@ #define UMF_MEMORY_POOL_OPS_H 1 #include +#include #ifdef __cplusplus extern "C" { From 6653648600bfcce798d9039327ec1e3f1716eeb4 Mon Sep 17 00:00:00 2001 From: Igor Chorazewicz Date: Fri, 7 Jul 2023 19:32:54 +0000 Subject: [PATCH 056/104] [umf] add extra poolMakeUnique overload to helpers --- source/common/umf_helpers.hpp | 132 +++++++++++------- .../memoryPoolAPI.cpp | 42 ++---- .../umf_pools/disjoint_pool.cpp | 13 +- 3 files changed, 98 insertions(+), 89 deletions(-) diff --git a/source/common/umf_helpers.hpp b/source/common/umf_helpers.hpp index 510af3e244..5dcb5f2b02 100644 --- a/source/common/umf_helpers.hpp +++ b/source/common/umf_helpers.hpp @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -48,6 +49,55 @@ using provider_unique_handle_t = } \ } +namespace detail { +template +umf_result_t initialize(T *obj, ArgsTuple &&args) { + try { + auto ret = std::apply(&T::initialize, + std::tuple_cat(std::make_tuple(obj), + std::forward(args))); + if (ret != UMF_RESULT_SUCCESS) { + delete obj; + } + return ret; + } catch (...) { + delete obj; + return UMF_RESULT_ERROR_UNKNOWN; + } +} + +template +umf_memory_pool_ops_t poolMakeUniqueOps() { + umf_memory_pool_ops_t ops; + + ops.version = UMF_VERSION_CURRENT; + ops.initialize = [](umf_memory_provider_handle_t *providers, + size_t numProviders, void *params, void **obj) { + try { + *obj = new T; + } catch (...) { + return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; + } + + return detail::initialize( + reinterpret_cast(*obj), + std::tuple_cat(std::make_tuple(providers, numProviders), + *reinterpret_cast(params))); + }; + ops.finalize = [](void *obj) { delete reinterpret_cast(obj); }; + + UMF_ASSIGN_OP(ops, T, malloc, ((void *)nullptr)); + UMF_ASSIGN_OP(ops, T, calloc, ((void *)nullptr)); + UMF_ASSIGN_OP(ops, T, aligned_malloc, ((void *)nullptr)); + UMF_ASSIGN_OP(ops, T, realloc, ((void *)nullptr)); + UMF_ASSIGN_OP(ops, T, malloc_usable_size, ((size_t)0)); + UMF_ASSIGN_OP_NORETURN(ops, T, free); + UMF_ASSIGN_OP(ops, T, get_last_allocation_error, UMF_RESULT_ERROR_UNKNOWN); + + return ops; +} +} // namespace detail + /// @brief creates UMF memory provider based on given T type. /// T should implement all functions defined by /// umf_memory_provider_ops_t, except for finalize (it is @@ -60,28 +110,15 @@ auto memoryProviderMakeUnique(Args &&...args) { ops.version = UMF_VERSION_CURRENT; ops.initialize = [](void *params, void **obj) { - auto *tuple = reinterpret_cast(params); - T *provider; try { - provider = new T; + *obj = new T; } catch (...) { return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; } - *obj = provider; - - try { - auto ret = - std::apply(&T::initialize, - std::tuple_cat(std::make_tuple(provider), *tuple)); - if (ret != UMF_RESULT_SUCCESS) { - delete provider; - } - return ret; - } catch (...) { - delete provider; - return UMF_RESULT_ERROR_UNKNOWN; - } + return detail::initialize( + reinterpret_cast(*obj), + *reinterpret_cast(params)); }; ops.finalize = [](void *obj) { delete reinterpret_cast(obj); }; @@ -108,51 +145,42 @@ auto memoryProviderMakeUnique(Args &&...args) { template auto poolMakeUnique(umf_memory_provider_handle_t *providers, size_t numProviders, Args &&...args) { - umf_memory_pool_ops_t ops; auto argsTuple = std::make_tuple(std::forward(args)...); + auto ops = detail::poolMakeUniqueOps(); - ops.version = UMF_VERSION_CURRENT; - ops.initialize = [](umf_memory_provider_handle_t *providers, - size_t numProviders, void *params, void **obj) { - auto *tuple = reinterpret_cast(params); - T *pool; + umf_memory_pool_handle_t hPool = nullptr; + auto ret = umfPoolCreate(&ops, providers, numProviders, &argsTuple, &hPool); + return std::pair{ + ret, pool_unique_handle_t(hPool, &umfPoolDestroy)}; +} - try { - pool = new T; - } catch (...) { - return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; - } +/// @brief creates UMF memory pool based on given T type. +/// This overload takes ownership of memory providers and destroys +/// them after memory pool is destroyed. +template +auto poolMakeUnique(std::array providers, + Args &&...args) { + auto argsTuple = std::make_tuple(std::forward(args)...); + auto ops = detail::poolMakeUniqueOps(); - *obj = pool; + std::array provider_handles; + for (size_t i = 0; i < N; i++) { + provider_handles[i] = providers[i].release(); + } - try { - auto ret = std::apply( - &T::initialize, - std::tuple_cat(std::make_tuple(pool, providers, numProviders), - *tuple)); - if (ret != UMF_RESULT_SUCCESS) { - delete pool; - } - return ret; - } catch (...) { - delete pool; - return UMF_RESULT_ERROR_UNKNOWN; + // capture providers and destroy them after the pool is destroyed + auto poolDestructor = [provider_handles](umf_memory_pool_handle_t hPool) { + umfPoolDestroy(hPool); + for (auto &provider : provider_handles) { + umfMemoryProviderDestroy(provider); } }; - ops.finalize = [](void *obj) { delete reinterpret_cast(obj); }; - - UMF_ASSIGN_OP(ops, T, malloc, ((void *)nullptr)); - UMF_ASSIGN_OP(ops, T, calloc, ((void *)nullptr)); - UMF_ASSIGN_OP(ops, T, aligned_malloc, ((void *)nullptr)); - UMF_ASSIGN_OP(ops, T, realloc, ((void *)nullptr)); - UMF_ASSIGN_OP(ops, T, malloc_usable_size, ((size_t)0)); - UMF_ASSIGN_OP_NORETURN(ops, T, free); - UMF_ASSIGN_OP(ops, T, get_last_allocation_error, UMF_RESULT_ERROR_UNKNOWN); umf_memory_pool_handle_t hPool = nullptr; - auto ret = umfPoolCreate(&ops, providers, numProviders, &argsTuple, &hPool); + auto ret = umfPoolCreate(&ops, provider_handles.data(), + provider_handles.size(), &argsTuple, &hPool); return std::pair{ - ret, pool_unique_handle_t(hPool, &umfPoolDestroy)}; + ret, pool_unique_handle_t(hPool, std::move(poolDestructor))}; } template umf_result_t &getPoolLastStatusRef() { diff --git a/test/unified_malloc_framework/memoryPoolAPI.cpp b/test/unified_malloc_framework/memoryPoolAPI.cpp index 1b3157bc39..d7fbe8efe2 100644 --- a/test/unified_malloc_framework/memoryPoolAPI.cpp +++ b/test/unified_malloc_framework/memoryPoolAPI.cpp @@ -133,41 +133,27 @@ TEST_F(test, retrieveMemoryProviders) { ASSERT_EQ(retProviders, providers); } -template -static auto -makePool(std::function makeProvider) { - auto providerUnique = makeProvider(); - umf_memory_provider_handle_t provider = providerUnique.get(); - auto pool = umf::poolMakeUnique(&provider, 1).second; - auto dtor = [provider = - providerUnique.release()](umf_memory_pool_handle_t hPool) { - umfPoolDestroy(hPool); - umfMemoryProviderDestroy(provider); - }; - return umf::pool_unique_handle_t(pool.release(), std::move(dtor)); -} - -INSTANTIATE_TEST_SUITE_P(mallocPoolTest, umfPoolTest, ::testing::Values([] { - return makePool([] { - return umf_test::wrapProviderUnique( - nullProviderCreate()); - }); - })); +INSTANTIATE_TEST_SUITE_P( + mallocPoolTest, umfPoolTest, ::testing::Values([] { + return umf::poolMakeUnique( + {umf_test::wrapProviderUnique(nullProviderCreate())}) + .second; + })); INSTANTIATE_TEST_SUITE_P( mallocProviderPoolTest, umfPoolTest, ::testing::Values([] { - return makePool([] { - return umf::memoryProviderMakeUnique() - .second; - }); + return umf::poolMakeUnique( + {umf::memoryProviderMakeUnique() + .second}) + .second; })); INSTANTIATE_TEST_SUITE_P( mallocMultiPoolTest, umfMultiPoolTest, ::testing::Values([] { - return makePool([] { - return umf::memoryProviderMakeUnique() - .second; - }); + return umf::poolMakeUnique( + {umf::memoryProviderMakeUnique() + .second}) + .second; })); ////////////////// Negative test cases ///////////////// diff --git a/test/unified_malloc_framework/umf_pools/disjoint_pool.cpp b/test/unified_malloc_framework/umf_pools/disjoint_pool.cpp index 937c853119..607415d14a 100644 --- a/test/unified_malloc_framework/umf_pools/disjoint_pool.cpp +++ b/test/unified_malloc_framework/umf_pools/disjoint_pool.cpp @@ -24,18 +24,13 @@ static usm::DisjointPool::Config poolConfig() { } static auto makePool() { - auto [ret, providerUnique] = + auto [ret, provider] = umf::memoryProviderMakeUnique(); EXPECT_EQ(ret, UMF_RESULT_SUCCESS); - auto provider = providerUnique.release(); - auto [retp, pool] = - umf::poolMakeUnique(&provider, 1, poolConfig()); + auto [retp, pool] = umf::poolMakeUnique( + {std::move(provider)}, poolConfig()); EXPECT_EQ(retp, UMF_RESULT_SUCCESS); - auto dtor = [provider = provider](umf_memory_pool_handle_t hPool) { - umfPoolDestroy(hPool); - umfMemoryProviderDestroy(provider); - }; - return umf::pool_unique_handle_t(pool.release(), std::move(dtor)); + return std::move(pool); } INSTANTIATE_TEST_SUITE_P(disjointPoolTests, umfPoolTest, From 2743832f4038a20220bf9e6f54fa7c6960f7e13b Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Fri, 7 Jul 2023 12:34:19 +0100 Subject: [PATCH 057/104] [UR] print unions correctly in ur_params --- include/ur.py | 6 +- include/ur_api.h | 8 +- scripts/YaML.md | 5 + scripts/core/device.yml | 8 +- scripts/core/program.yml | 9 +- scripts/templates/helper.py | 15 + scripts/templates/params.hpp.mako | 37 +- source/common/ur_params.hpp | 818 ++++++++++++++++++++++++++++-- test/unit/utils/params.cpp | 46 +- 9 files changed, 886 insertions(+), 66 deletions(-) diff --git a/include/ur.py b/include/ur.py index f1a1b48b2a..4fcfc40da6 100644 --- a/include/ur.py +++ b/include/ur.py @@ -848,7 +848,7 @@ class ur_device_partition_value_t(Structure): ("count", c_ulong), ## [in] Number of compute units in a sub-device when partitioning with ## ::UR_DEVICE_PARTITION_BY_COUNTS. ("affinity_domain", ur_device_affinity_domain_flags_t) ## [in] The affinity domain to partition for when partitioning with - ## $UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN. + ## ::UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN. ] ############################################################################### @@ -856,7 +856,7 @@ class ur_device_partition_value_t(Structure): class ur_device_partition_property_t(Structure): _fields_ = [ ("type", ur_device_partition_t), ## [in] The partitioning type to be used. - ("value", ur_device_partition_value_t) ## [in] The partitioning value. + ("value", ur_device_partition_value_t) ## [in][tagged_by(type)] The partitioning value. ] ############################################################################### @@ -1579,7 +1579,7 @@ class ur_program_metadata_t(Structure): ("type", ur_program_metadata_type_t), ## [in] the type of metadata value. ("size", c_size_t), ## [in] size in bytes of the data pointed to by value.pData, or 0 when ## value size is less than 64-bits and is stored directly in value.data. - ("value", ur_program_metadata_value_t) ## [in] the metadata value storage. + ("value", ur_program_metadata_value_t) ## [in][tagged_by(type)] the metadata value storage. ] ############################################################################### diff --git a/include/ur_api.h b/include/ur_api.h index aab6a9c50b..360cfe05d0 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -1348,7 +1348,7 @@ typedef union ur_device_partition_value_t { uint32_t count; ///< [in] Number of compute units in a sub-device when partitioning with ///< ::UR_DEVICE_PARTITION_BY_COUNTS. ur_device_affinity_domain_flags_t affinity_domain; ///< [in] The affinity domain to partition for when partitioning with - ///< $UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN. + ///< ::UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN. } ur_device_partition_value_t; @@ -1356,7 +1356,7 @@ typedef union ur_device_partition_value_t { /// @brief Device partition property typedef struct ur_device_partition_property_t { ur_device_partition_t type; ///< [in] The partitioning type to be used. - ur_device_partition_value_t value; ///< [in] The partitioning value. + ur_device_partition_value_t value; ///< [in][tagged_by(type)] The partitioning value. } ur_device_partition_property_t; @@ -3553,11 +3553,11 @@ typedef union ur_program_metadata_value_t { /////////////////////////////////////////////////////////////////////////////// /// @brief Program metadata property. typedef struct ur_program_metadata_t { - char *pName; ///< [in] null-terminated metadata name. + const char *pName; ///< [in] null-terminated metadata name. ur_program_metadata_type_t type; ///< [in] the type of metadata value. size_t size; ///< [in] size in bytes of the data pointed to by value.pData, or 0 when ///< value size is less than 64-bits and is stored directly in value.data. - ur_program_metadata_value_t value; ///< [in] the metadata value storage. + ur_program_metadata_value_t value; ///< [in][tagged_by(type)] the metadata value storage. } ur_program_metadata_t; diff --git a/scripts/YaML.md b/scripts/YaML.md index c6a8895d48..90b5c8f843 100644 --- a/scripts/YaML.md +++ b/scripts/YaML.md @@ -454,6 +454,8 @@ class ur_name_flags_v(IntEnum): - `name` must be a unique ISO-C standard identifier, start with `$` tag, be snake_case and end with `_t` + The special-case descriptor struct should always end with `_desc_t` + The special-case property struct should always end with `_properties_t` +* A union requires the following + - `tag` is a reference to a type which will be used to describe which field to access of the union. * A struct|union may take the following optional scalar fields: {`class`, `base`, `condition`, `ordinal`, `version`} - `class` will be used to scope the struct|union declaration within the specified C++ class - `base` will be used as the base type of the structure @@ -468,6 +470,8 @@ class ur_name_flags_v(IntEnum): - `out` is used for members that are write-only; if the member is a pointer, then the memory being pointed to is also write-only - `in,out` is used for members that are both read and write; typically this is used for pointers to other data structures that contain both read and write members - `nocheck` is used to specify that no additional validation checks will be generated. + + `desc` must also include the following annotation when describing a union: {`"tagged_by(param)"`} + - `tagged_by` is use to specify which parameter will be used as the tag for accessing the union. + `desc` may include one the following annotations: {`"[optional]"`, `"[typename(typeVarName, sizeVarName)]"`} - `optional` is used for members that are pointers where it is legal for the value to be `nullptr` - `typename` is used to denote the type enum for params that are opaque pointers to values of tagged data types. @@ -477,6 +481,7 @@ class ur_name_flags_v(IntEnum): + `init` will be used to initialize the C++ struct|union member's value + `init` must be an ISO-C standard identifier or literal + `version` will be used to define the minimum API version in which the member will appear; `default="1.0"` This will also affect the order in which the member appears within the struct|union. + + `tag` applies only to unions and refers to a value for when this member can be accessed. * A struct|union may take the following optional field which can be a scalar, a sequence of scalars or scalars to sequences: {`details`} - `details` will be used as the struct|union's detailed comment diff --git a/scripts/core/device.yml b/scripts/core/device.yml index ed404865ad..49da5206ed 100644 --- a/scripts/core/device.yml +++ b/scripts/core/device.yml @@ -518,16 +518,20 @@ type: union desc: "Device partition value." name: $x_device_partition_value_t class: $xDevice +tag: $x_device_partition_t members: - type: uint32_t name: equally desc: "[in] Number of compute units per sub-device when partitioning with $X_DEVICE_PARTITION_EQUALLY." + tag: $X_DEVICE_PARTITION_EQUALLY - type: uint32_t name: count desc: "[in] Number of compute units in a sub-device when partitioning with $X_DEVICE_PARTITION_BY_COUNTS." + tag: $X_DEVICE_PARTITION_BY_COUNTS - type: $x_device_affinity_domain_flags_t name: affinity_domain - desc: "[in] The affinity domain to partition for when partitioning with $UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN." + desc: "[in] The affinity domain to partition for when partitioning with $X_DEVICE_PARTITION_BY_AFFINITY_DOMAIN." + tag: $X_DEVICE_PARTITION_BY_AFFINITY_DOMAIN --- #-------------------------------------------------------------------------- type: struct desc: "Device partition property" @@ -539,7 +543,7 @@ members: desc: "[in] The partitioning type to be used." - type: $x_device_partition_value_t name: value - desc: "[in] The partitioning value." + desc: "[in][tagged_by(type)] The partitioning value." --- #-------------------------------------------------------------------------- type: struct desc: "Device Partition Properties" diff --git a/scripts/core/program.yml b/scripts/core/program.yml index 3ca6764238..ed5117851a 100644 --- a/scripts/core/program.yml +++ b/scripts/core/program.yml @@ -29,26 +29,31 @@ type: union desc: "Program metadata value union." class: $xProgram name: $x_program_metadata_value_t +tag: $x_program_metadata_type_t members: - type: uint32_t name: data32 desc: "[in] inline storage for the 32-bit data, type $X_PROGRAM_METADATA_TYPE_UINT32." + tag: $X_PROGRAM_METADATA_TYPE_UINT32 - type: uint64_t name: data64 desc: "[in] inline storage for the 64-bit data, type $X_PROGRAM_METADATA_TYPE_UINT64." + tag: $X_PROGRAM_METADATA_TYPE_UINT64 - type: char* name: pString desc: "[in] pointer to null-terminated string data, type $X_PROGRAM_METADATA_TYPE_STRING." + tag: $X_PROGRAM_METADATA_TYPE_STRING - type: void* name: pData desc: "[in] pointer to binary data, type $X_PROGRAM_METADATA_TYPE_BYTE_ARRAY." + tag: $X_PROGRAM_METADATA_TYPE_BYTE_ARRAY --- #-------------------------------------------------------------------------- type: struct desc: "Program metadata property." class: $xProgram name: $x_program_metadata_t members: - - type: char* + - type: const char* name: pName desc: "[in] null-terminated metadata name." - type: $x_program_metadata_type_t @@ -59,7 +64,7 @@ members: desc: "[in] size in bytes of the data pointed to by value.pData, or 0 when value size is less than 64-bits and is stored directly in value.data." - type: $x_program_metadata_value_t name: value - desc: "[in] the metadata value storage." + desc: "[in][tagged_by(type)] the metadata value storage." --- #-------------------------------------------------------------------------- type: struct desc: "Program creation properties." diff --git a/scripts/templates/helper.py b/scripts/templates/helper.py index 2a70c1c326..1e738dbc09 100644 --- a/scripts/templates/helper.py +++ b/scripts/templates/helper.py @@ -319,6 +319,7 @@ class param_traits: RE_RANGE = r".*\[range\((.+),\s*(.+)\)\][\S\s]*" RE_RELEASE = r".*\[release\].*" RE_TYPENAME = r".*\[typename\((.+),\s(.+)\)\].*" + RE_TAGGED = r".*\[tagged_by\((.+)\)].*" @classmethod def is_mbz(cls, item): @@ -369,6 +370,20 @@ def is_range(cls, item): except: return False + @classmethod + def is_tagged(cls, item): + try: + return True if re.match(cls.RE_TAGGED, item['desc']) else False + except: + return False + + @classmethod + def tagged_member(cls, item): + try: + return re.sub(cls.RE_TAGGED, r"\1", item['desc']) + except: + return None + @classmethod def range_start(cls, item): try: diff --git a/scripts/templates/params.hpp.mako b/scripts/templates/params.hpp.mako index c48d020ec8..767f36977f 100644 --- a/scripts/templates/params.hpp.mako +++ b/scripts/templates/params.hpp.mako @@ -57,6 +57,9 @@ from templates import helper as th %if n != 0: os << ", "; %endif + ## Find out if the member refers to a union +<% query = [_o for _s in specs for _o in _s['objects'] if _o['name'] == item['type']] +member_type = query[0] if len(query) > 0 else None%> ## can't iterate over 'void *'... %if th.param_traits.is_range(item) and "void*" not in itype: os << ".${iname} = {"; @@ -69,6 +72,9 @@ from templates import helper as th } os << "}"; + %elif member_type is not None and member_type['type'] == "union": + os << ".${iname} = "; + ${x}_params::print_union(os, params.${item['name']}, params.${th.param_traits.tagged_member(item)}); %elif typename is not None: os << ".${iname} = "; ${x}_params::serializeTagged(os, ${deref}(params${access}${pname}), ${deref}(params${access}${prefix}${typename}), ${deref}(params${access}${prefix}${typename_size})); @@ -96,6 +102,15 @@ template inline void serializeTagged(std::ostream &os, const void * %endif %endif +%if re.match(r"union", obj['type']) and obj['name']: + <% tag = [_obj for _s in specs for _obj in _s['objects'] if _obj['name'] == obj['tag']][0] %> + inline void print_union( + std::ostream &os, + const ${obj['type']} ${th.make_type_name(n, tags, obj)} params, + const ${tag['type']} ${th.make_type_name(n, tags, tag)} tag + ); +%endif + %if th.type_traits.is_flags(obj['name']): template<> inline void serializeFlag<${th.make_enum_name(n, tags, obj)}>(std::ostream &os, uint32_t flag); @@ -109,7 +124,7 @@ template inline void serializeTagged(std::ostream &os, const void * ## ENUM ####################################################################### %if re.match(r"enum", obj['type']): inline std::ostream &operator<<(std::ostream &os, enum ${th.make_enum_name(n, tags, obj)} value); -%elif re.match(r"struct|union", obj['type']): +%elif re.match(r"struct", obj['type']): inline std::ostream &operator<<(std::ostream &os, const ${obj['type']} ${th.make_type_name(n, tags, obj)} params); %endif %endfor # obj in spec['objects'] @@ -260,7 +275,7 @@ inline void serializeFlag<${th.make_enum_name(n, tags, obj)}>(std::ostream &os, } // namespace ${x}_params %endif ## STRUCT/UNION ############################################################### -%elif re.match(r"struct|union", obj['type']): +%elif re.match(r"struct", obj['type']): inline std::ostream &operator<<(std::ostream &os, const ${obj['type']} ${th.make_type_name(n, tags, obj)} params) { os << "(${obj['type']} ${th.make_type_name(n, tags, obj)}){"; <% @@ -277,6 +292,24 @@ inline std::ostream &operator<<(std::ostream &os, const ${obj['type']} ${th.make os << "}"; return os; } +%elif re.match(r"union", obj['type']) and obj['name']: +<% tag = [_obj for _s in specs for _obj in _s['objects'] if _obj['name'] == obj['tag']][0] %> +inline void ${x}_params::print_union( + std::ostream &os, + const ${obj['type']} ${th.make_type_name(n, tags, obj)} params, + const ${tag['type']} ${th.make_type_name(n, tags, tag)} tag +){ + switch(tag){ +%for mem in obj['members']: + case ${th.subt(n, tags, mem['tag'])}: + os << params.${mem['name']}; + break; +%endfor + default: + os << ""; + break; + } +} %endif %endfor # obj in spec['objects'] %endfor diff --git a/source/common/ur_params.hpp b/source/common/ur_params.hpp index e24401c3f6..5c1950ab1e 100644 --- a/source/common/ur_params.hpp +++ b/source/common/ur_params.hpp @@ -42,6 +42,10 @@ template <> inline void serializeFlag(std::ostream &os, uint32_t flag); +inline void print_union(std::ostream &os, + const union ur_device_partition_value_t params, + const enum ur_device_partition_t tag); + template <> inline void serializeFlag(std::ostream &os, uint32_t flag); @@ -125,6 +129,10 @@ template <> inline void serializeFlag(std::ostream &os, uint32_t flag); +inline void print_union(std::ostream &os, + const union ur_program_metadata_value_t params, + const enum ur_program_metadata_type_t tag); + template <> inline void serializeTagged(std::ostream &os, const void *ptr, ur_program_info_t value, size_t size); @@ -211,8 +219,6 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_device_affinity_domain_flag_t value); inline std::ostream &operator<<(std::ostream &os, enum ur_device_partition_t value); -inline std::ostream &operator<<(std::ostream &os, - const union ur_device_partition_value_t params); inline std::ostream & operator<<(std::ostream &os, const struct ur_device_partition_property_t params); @@ -313,8 +319,6 @@ inline std::ostream & operator<<(std::ostream &os, const struct ur_physical_mem_properties_t params); inline std::ostream &operator<<(std::ostream &os, enum ur_program_metadata_type_t value); -inline std::ostream &operator<<(std::ostream &os, - const union ur_program_metadata_value_t params); inline std::ostream &operator<<(std::ostream &os, const struct ur_program_metadata_t params); inline std::ostream &operator<<(std::ostream &os, @@ -1743,6 +1747,7 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); @@ -1759,6 +1764,7 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); @@ -1775,11 +1781,13 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.x); os << ", "; + os << ".y = "; os << (params.y); os << ", "; + os << ".z = "; os << (params.z); @@ -1796,11 +1804,13 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.width); os << ", "; + os << ".height = "; os << (params.height); os << ", "; + os << ".depth = "; os << (params.depth); @@ -2013,11 +2023,13 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".isNativeHandleOwned = "; os << (params.isNativeHandleOwned); @@ -2063,11 +2075,13 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".pDeviceTargetSpec = "; ur_params::serializePtr(os, (params.pDeviceTargetSpec)); @@ -4565,27 +4579,25 @@ inline std::ostream &operator<<(std::ostream &os, } return os; } -inline std::ostream & -operator<<(std::ostream &os, const union ur_device_partition_value_t params) { - os << "(union ur_device_partition_value_t){"; - - os << ".equally = "; - os << (params.equally); - - os << ", "; - os << ".count = "; - - os << (params.count); - - os << ", "; - os << ".affinity_domain = "; - - ur_params::serializeFlag( - os, (params.affinity_domain)); - - os << "}"; - return os; +inline void +ur_params::print_union(std::ostream &os, + const union ur_device_partition_value_t params, + const enum ur_device_partition_t tag) { + switch (tag) { + case UR_DEVICE_PARTITION_EQUALLY: + os << params.equally; + break; + case UR_DEVICE_PARTITION_BY_COUNTS: + os << params.count; + break; + case UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN: + os << params.affinity_domain; + break; + default: + os << ""; + break; + } } inline std::ostream & operator<<(std::ostream &os, @@ -4597,9 +4609,9 @@ operator<<(std::ostream &os, os << (params.type); os << ", "; - os << ".value = "; - os << (params.value); + os << ".value = "; + ur_params::print_union(os, params.value, params.type); os << "}"; return os; @@ -4614,16 +4626,19 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".pProperties = "; ur_params::serializePtr(os, (params.pProperties)); os << ", "; + os << ".PropCount = "; os << (params.PropCount); @@ -4888,11 +4903,13 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".isNativeHandleOwned = "; os << (params.isNativeHandleOwned); @@ -5244,11 +5261,13 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".flags = "; ur_params::serializeFlag(os, (params.flags)); @@ -5462,11 +5481,13 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".isNativeHandleOwned = "; os << (params.isNativeHandleOwned); @@ -5979,6 +6000,7 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.channelOrder); os << ", "; + os << ".channelType = "; os << (params.channelType); @@ -5995,51 +6017,61 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".type = "; os << (params.type); os << ", "; + os << ".width = "; os << (params.width); os << ", "; + os << ".height = "; os << (params.height); os << ", "; + os << ".depth = "; os << (params.depth); os << ", "; + os << ".arraySize = "; os << (params.arraySize); os << ", "; + os << ".rowPitch = "; os << (params.rowPitch); os << ", "; + os << ".slicePitch = "; os << (params.slicePitch); os << ", "; + os << ".numMipLevel = "; os << (params.numMipLevel); os << ", "; + os << ".numSamples = "; os << (params.numSamples); @@ -6056,11 +6088,13 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".pHost = "; ur_params::serializePtr(os, (params.pHost)); @@ -6078,11 +6112,13 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".channel = "; os << (params.channel); @@ -6100,11 +6136,13 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".location = "; os << (params.location); @@ -6121,16 +6159,19 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".origin = "; os << (params.origin); os << ", "; + os << ".size = "; os << (params.size); @@ -6160,11 +6201,13 @@ operator<<(std::ostream &os, const struct ur_mem_native_properties_t params) { os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".isNativeHandleOwned = "; os << (params.isNativeHandleOwned); @@ -6345,21 +6388,25 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".normalizedCoords = "; os << (params.normalizedCoords); os << ", "; + os << ".addressingMode = "; os << (params.addressingMode); os << ", "; + os << ".filterMode = "; os << (params.filterMode); @@ -6377,11 +6424,13 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".isNativeHandleOwned = "; os << (params.isNativeHandleOwned); @@ -6944,16 +6993,19 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".hints = "; ur_params::serializeFlag(os, (params.hints)); os << ", "; + os << ".align = "; os << (params.align); @@ -6970,11 +7022,13 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".flags = "; ur_params::serializeFlag(os, (params.flags)); @@ -6991,11 +7045,13 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".flags = "; ur_params::serializeFlag(os, (params.flags)); @@ -7012,11 +7068,13 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".flags = "; ur_params::serializeFlag(os, (params.flags)); @@ -7033,16 +7091,19 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".maxPoolableSize = "; os << (params.maxPoolableSize); os << ", "; + os << ".minDriverAllocSize = "; os << (params.minDriverAllocSize); @@ -7341,11 +7402,13 @@ operator<<(std::ostream &os, const struct ur_physical_mem_properties_t params) { os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".flags = "; ur_params::serializeFlag(os, (params.flags)); @@ -7378,31 +7441,28 @@ inline std::ostream &operator<<(std::ostream &os, } return os; } -inline std::ostream & -operator<<(std::ostream &os, const union ur_program_metadata_value_t params) { - os << "(union ur_program_metadata_value_t){"; - - os << ".data32 = "; - - os << (params.data32); - - os << ", "; - os << ".data64 = "; - - os << (params.data64); - os << ", "; - os << ".pString = "; - - ur_params::serializePtr(os, (params.pString)); - - os << ", "; - os << ".pData = "; - - ur_params::serializePtr(os, (params.pData)); - - os << "}"; - return os; +inline void +ur_params::print_union(std::ostream &os, + const union ur_program_metadata_value_t params, + const enum ur_program_metadata_type_t tag) { + switch (tag) { + case UR_PROGRAM_METADATA_TYPE_UINT32: + os << params.data32; + break; + case UR_PROGRAM_METADATA_TYPE_UINT64: + os << params.data64; + break; + case UR_PROGRAM_METADATA_TYPE_STRING: + os << params.pString; + break; + case UR_PROGRAM_METADATA_TYPE_BYTE_ARRAY: + os << params.pData; + break; + default: + os << ""; + break; + } } inline std::ostream &operator<<(std::ostream &os, const struct ur_program_metadata_t params) { @@ -7413,19 +7473,21 @@ inline std::ostream &operator<<(std::ostream &os, ur_params::serializePtr(os, (params.pName)); os << ", "; + os << ".type = "; os << (params.type); os << ", "; + os << ".size = "; os << (params.size); os << ", "; - os << ".value = "; - os << (params.value); + os << ".value = "; + ur_params::print_union(os, params.value, params.type); os << "}"; return os; @@ -7439,16 +7501,19 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".count = "; os << (params.count); os << ", "; + os << ".pMetadatas = {"; for (size_t i = 0; (params.pMetadatas) != NULL && i < params.count; ++i) { if (i != 0) { @@ -7770,11 +7835,13 @@ operator<<(std::ostream &os, os << (params.id); os << ", "; + os << ".size = "; os << (params.size); os << ", "; + os << ".pValue = "; ur_params::serializePtr(os, (params.pValue)); @@ -7792,11 +7859,13 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".isNativeHandleOwned = "; os << (params.isNativeHandleOwned); @@ -7814,6 +7883,7 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); @@ -7831,6 +7901,7 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); @@ -8316,6 +8387,7 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); @@ -8333,6 +8405,7 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); @@ -8350,6 +8423,7 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); @@ -8367,11 +8441,13 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".memoryAccess = "; ur_params::serializeFlag(os, (params.memoryAccess)); @@ -8389,11 +8465,13 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".isNativeHandleOwned = "; os << (params.isNativeHandleOwned); @@ -8749,11 +8827,13 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".flags = "; ur_params::serializeFlag(os, (params.flags)); @@ -8770,11 +8850,13 @@ operator<<(std::ostream &os, const struct ur_queue_index_properties_t params) { os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".computeIndex = "; os << (params.computeIndex); @@ -8791,11 +8873,13 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".pNativeData = "; ur_params::serializePtr(os, (params.pNativeData)); @@ -8812,11 +8896,13 @@ operator<<(std::ostream &os, const struct ur_queue_native_properties_t params) { os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".isNativeHandleOwned = "; os << (params.isNativeHandleOwned); @@ -9207,11 +9293,13 @@ operator<<(std::ostream &os, const struct ur_event_native_properties_t params) { os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".isNativeHandleOwned = "; os << (params.isNativeHandleOwned); @@ -9436,26 +9524,31 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; + os << ".minMipmapLevelClamp = "; os << (params.minMipmapLevelClamp); os << ", "; + os << ".maxMipmapLevelClamp = "; os << (params.maxMipmapLevelClamp); os << ", "; + os << ".maxAnisotropy = "; os << (params.maxAnisotropy); os << ", "; + os << ".mipFilterMode = "; os << (params.mipFilterMode); @@ -9472,6 +9565,7 @@ operator<<(std::ostream &os, const struct ur_exp_command_buffer_desc_t params) { os << (params.stype); os << ", "; + os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); @@ -9572,11 +9666,13 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".hImage = "; ur_params::serializePtr(os, *(params->phImage)); @@ -9594,11 +9690,13 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".hImage = "; ur_params::serializePtr(os, *(params->phImage)); @@ -9615,21 +9713,25 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".pImageFormat = "; ur_params::serializePtr(os, *(params->ppImageFormat)); os << ", "; + os << ".pImageDesc = "; ur_params::serializePtr(os, *(params->ppImageDesc)); os << ", "; + os << ".phImageMem = "; ur_params::serializePtr(os, *(params->pphImageMem)); @@ -9646,11 +9748,13 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".hImageMem = "; ur_params::serializePtr(os, *(params->phImageMem)); @@ -9668,31 +9772,37 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".hImageMem = "; ur_params::serializePtr(os, *(params->phImageMem)); os << ", "; + os << ".pImageFormat = "; ur_params::serializePtr(os, *(params->ppImageFormat)); os << ", "; + os << ".pImageDesc = "; ur_params::serializePtr(os, *(params->ppImageDesc)); os << ", "; + os << ".phMem = "; ur_params::serializePtr(os, *(params->pphMem)); os << ", "; + os << ".phImage = "; ur_params::serializePtr(os, *(params->pphImage)); @@ -9709,36 +9819,43 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".hImageMem = "; ur_params::serializePtr(os, *(params->phImageMem)); os << ", "; + os << ".pImageFormat = "; ur_params::serializePtr(os, *(params->ppImageFormat)); os << ", "; + os << ".pImageDesc = "; ur_params::serializePtr(os, *(params->ppImageDesc)); os << ", "; + os << ".hSampler = "; ur_params::serializePtr(os, *(params->phSampler)); os << ", "; + os << ".phMem = "; ur_params::serializePtr(os, *(params->pphMem)); os << ", "; + os << ".phImage = "; ur_params::serializePtr(os, *(params->pphImage)); @@ -9755,57 +9872,68 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".pDst = "; ur_params::serializePtr(os, *(params->ppDst)); os << ", "; + os << ".pSrc = "; ur_params::serializePtr(os, *(params->ppSrc)); os << ", "; + os << ".pImageFormat = "; ur_params::serializePtr(os, *(params->ppImageFormat)); os << ", "; + os << ".pImageDesc = "; ur_params::serializePtr(os, *(params->ppImageDesc)); os << ", "; + os << ".imageCopyFlags = "; ur_params::serializeFlag( os, *(params->pimageCopyFlags)); os << ", "; + os << ".srcOffset = "; os << *(params->psrcOffset); os << ", "; + os << ".dstOffset = "; os << *(params->pdstOffset); os << ", "; + os << ".copyExtent = "; os << *(params->pcopyExtent); os << ", "; + os << ".hostExtent = "; os << *(params->phostExtent); os << ", "; + os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; + os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -9819,6 +9947,7 @@ operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -9835,16 +9964,19 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phImageMem)); os << ", "; + os << ".propName = "; os << *(params->ppropName); os << ", "; + os << ".pPropValue = "; ur_params::serializePtr(os, *(params->ppPropValue)); os << ", "; + os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -9861,21 +9993,25 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".hImageMem = "; ur_params::serializePtr(os, *(params->phImageMem)); os << ", "; + os << ".mipmapLevel = "; os << *(params->pmipmapLevel); os << ", "; + os << ".phImageMem = "; ur_params::serializePtr(os, *(params->pphImageMem)); @@ -9892,11 +10028,13 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".hMem = "; ur_params::serializePtr(os, *(params->phMem)); @@ -9913,21 +10051,25 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".size = "; os << *(params->psize); os << ", "; + os << ".fileDescriptor = "; os << *(params->pfileDescriptor); os << ", "; + os << ".phInteropMem = "; ur_params::serializePtr(os, *(params->pphInteropMem)); @@ -9944,26 +10086,31 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".pImageFormat = "; ur_params::serializePtr(os, *(params->ppImageFormat)); os << ", "; + os << ".pImageDesc = "; ur_params::serializePtr(os, *(params->ppImageDesc)); os << ", "; + os << ".hInteropMem = "; ur_params::serializePtr(os, *(params->phInteropMem)); os << ", "; + os << ".phImageMem = "; ur_params::serializePtr(os, *(params->pphImageMem)); @@ -9980,11 +10127,13 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".hInteropMem = "; ur_params::serializePtr(os, *(params->phInteropMem)); @@ -10002,16 +10151,19 @@ operator<<(std::ostream &os, const struct ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".fileDescriptor = "; os << *(params->pfileDescriptor); os << ", "; + os << ".phInteropSemaphoreHandle = "; ur_params::serializePtr(os, *(params->pphInteropSemaphoreHandle)); @@ -10029,11 +10181,13 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".hInteropSemaphore = "; ur_params::serializePtr(os, *(params->phInteropSemaphore)); @@ -10051,16 +10205,19 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".hSemaphore = "; ur_params::serializePtr(os, *(params->phSemaphore)); os << ", "; + os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; + os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -10074,6 +10231,7 @@ operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -10091,16 +10249,19 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".hSemaphore = "; ur_params::serializePtr(os, *(params->phSemaphore)); os << ", "; + os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; + os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -10114,6 +10275,7 @@ inline std::ostream &operator<<( os << "}"; os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -10130,16 +10292,19 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".pCommandBufferDesc = "; ur_params::serializePtr(os, *(params->ppCommandBufferDesc)); os << ", "; + os << ".phCommandBuffer = "; ur_params::serializePtr(os, *(params->pphCommandBuffer)); @@ -10189,41 +10354,49 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phCommandBuffer)); os << ", "; + os << ".hKernel = "; ur_params::serializePtr(os, *(params->phKernel)); os << ", "; + os << ".workDim = "; os << *(params->pworkDim); os << ", "; + os << ".pGlobalWorkOffset = "; ur_params::serializePtr(os, *(params->ppGlobalWorkOffset)); os << ", "; + os << ".pGlobalWorkSize = "; ur_params::serializePtr(os, *(params->ppGlobalWorkSize)); os << ", "; + os << ".pLocalWorkSize = "; ur_params::serializePtr(os, *(params->ppLocalWorkSize)); os << ", "; + os << ".numSyncPointsInWaitList = "; os << *(params->pnumSyncPointsInWaitList); os << ", "; + os << ".pSyncPointWaitList = "; ur_params::serializePtr(os, *(params->ppSyncPointWaitList)); os << ", "; + os << ".pSyncPoint = "; ur_params::serializePtr(os, *(params->ppSyncPoint)); @@ -10240,31 +10413,37 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phCommandBuffer)); os << ", "; + os << ".pDst = "; ur_params::serializePtr(os, *(params->ppDst)); os << ", "; + os << ".pSrc = "; ur_params::serializePtr(os, *(params->ppSrc)); os << ", "; + os << ".size = "; os << *(params->psize); os << ", "; + os << ".numSyncPointsInWaitList = "; os << *(params->pnumSyncPointsInWaitList); os << ", "; + os << ".pSyncPointWaitList = "; ur_params::serializePtr(os, *(params->ppSyncPointWaitList)); os << ", "; + os << ".pSyncPoint = "; ur_params::serializePtr(os, *(params->ppSyncPoint)); @@ -10281,41 +10460,49 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phCommandBuffer)); os << ", "; + os << ".hSrcMem = "; ur_params::serializePtr(os, *(params->phSrcMem)); os << ", "; + os << ".hDstMem = "; ur_params::serializePtr(os, *(params->phDstMem)); os << ", "; + os << ".srcOffset = "; os << *(params->psrcOffset); os << ", "; + os << ".dstOffset = "; os << *(params->pdstOffset); os << ", "; + os << ".size = "; os << *(params->psize); os << ", "; + os << ".numSyncPointsInWaitList = "; os << *(params->pnumSyncPointsInWaitList); os << ", "; + os << ".pSyncPointWaitList = "; ur_params::serializePtr(os, *(params->ppSyncPointWaitList)); os << ", "; + os << ".pSyncPoint = "; ur_params::serializePtr(os, *(params->ppSyncPoint)); @@ -10333,36 +10520,43 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phCommandBuffer)); os << ", "; + os << ".hBuffer = "; ur_params::serializePtr(os, *(params->phBuffer)); os << ", "; + os << ".offset = "; os << *(params->poffset); os << ", "; + os << ".size = "; os << *(params->psize); os << ", "; + os << ".pSrc = "; ur_params::serializePtr(os, *(params->ppSrc)); os << ", "; + os << ".numSyncPointsInWaitList = "; os << *(params->pnumSyncPointsInWaitList); os << ", "; + os << ".pSyncPointWaitList = "; ur_params::serializePtr(os, *(params->ppSyncPointWaitList)); os << ", "; + os << ".pSyncPoint = "; ur_params::serializePtr(os, *(params->ppSyncPoint)); @@ -10379,36 +10573,43 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phCommandBuffer)); os << ", "; + os << ".hBuffer = "; ur_params::serializePtr(os, *(params->phBuffer)); os << ", "; + os << ".offset = "; os << *(params->poffset); os << ", "; + os << ".size = "; os << *(params->psize); os << ", "; + os << ".pDst = "; ur_params::serializePtr(os, *(params->ppDst)); os << ", "; + os << ".numSyncPointsInWaitList = "; os << *(params->pnumSyncPointsInWaitList); os << ", "; + os << ".pSyncPointWaitList = "; ur_params::serializePtr(os, *(params->ppSyncPointWaitList)); os << ", "; + os << ".pSyncPoint = "; ur_params::serializePtr(os, *(params->ppSyncPoint)); @@ -10426,61 +10627,73 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phCommandBuffer)); os << ", "; + os << ".hSrcMem = "; ur_params::serializePtr(os, *(params->phSrcMem)); os << ", "; + os << ".hDstMem = "; ur_params::serializePtr(os, *(params->phDstMem)); os << ", "; + os << ".srcOrigin = "; os << *(params->psrcOrigin); os << ", "; + os << ".dstOrigin = "; os << *(params->pdstOrigin); os << ", "; + os << ".region = "; os << *(params->pregion); os << ", "; + os << ".srcRowPitch = "; os << *(params->psrcRowPitch); os << ", "; + os << ".srcSlicePitch = "; os << *(params->psrcSlicePitch); os << ", "; + os << ".dstRowPitch = "; os << *(params->pdstRowPitch); os << ", "; + os << ".dstSlicePitch = "; os << *(params->pdstSlicePitch); os << ", "; + os << ".numSyncPointsInWaitList = "; os << *(params->pnumSyncPointsInWaitList); os << ", "; + os << ".pSyncPointWaitList = "; ur_params::serializePtr(os, *(params->ppSyncPointWaitList)); os << ", "; + os << ".pSyncPoint = "; ur_params::serializePtr(os, *(params->ppSyncPoint)); @@ -10498,61 +10711,73 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phCommandBuffer)); os << ", "; + os << ".hBuffer = "; ur_params::serializePtr(os, *(params->phBuffer)); os << ", "; + os << ".bufferOffset = "; os << *(params->pbufferOffset); os << ", "; + os << ".hostOffset = "; os << *(params->phostOffset); os << ", "; + os << ".region = "; os << *(params->pregion); os << ", "; + os << ".bufferRowPitch = "; os << *(params->pbufferRowPitch); os << ", "; + os << ".bufferSlicePitch = "; os << *(params->pbufferSlicePitch); os << ", "; + os << ".hostRowPitch = "; os << *(params->phostRowPitch); os << ", "; + os << ".hostSlicePitch = "; os << *(params->phostSlicePitch); os << ", "; + os << ".pSrc = "; ur_params::serializePtr(os, *(params->ppSrc)); os << ", "; + os << ".numSyncPointsInWaitList = "; os << *(params->pnumSyncPointsInWaitList); os << ", "; + os << ".pSyncPointWaitList = "; ur_params::serializePtr(os, *(params->ppSyncPointWaitList)); os << ", "; + os << ".pSyncPoint = "; ur_params::serializePtr(os, *(params->ppSyncPoint)); @@ -10570,61 +10795,73 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phCommandBuffer)); os << ", "; + os << ".hBuffer = "; ur_params::serializePtr(os, *(params->phBuffer)); os << ", "; + os << ".bufferOffset = "; os << *(params->pbufferOffset); os << ", "; + os << ".hostOffset = "; os << *(params->phostOffset); os << ", "; + os << ".region = "; os << *(params->pregion); os << ", "; + os << ".bufferRowPitch = "; os << *(params->pbufferRowPitch); os << ", "; + os << ".bufferSlicePitch = "; os << *(params->pbufferSlicePitch); os << ", "; + os << ".hostRowPitch = "; os << *(params->phostRowPitch); os << ", "; + os << ".hostSlicePitch = "; os << *(params->phostSlicePitch); os << ", "; + os << ".pDst = "; ur_params::serializePtr(os, *(params->ppDst)); os << ", "; + os << ".numSyncPointsInWaitList = "; os << *(params->pnumSyncPointsInWaitList); os << ", "; + os << ".pSyncPointWaitList = "; ur_params::serializePtr(os, *(params->ppSyncPointWaitList)); os << ", "; + os << ".pSyncPoint = "; ur_params::serializePtr(os, *(params->ppSyncPoint)); @@ -10641,16 +10878,19 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phCommandBuffer)); os << ", "; + os << ".hQueue = "; ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; + os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -10664,6 +10904,7 @@ operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -10679,6 +10920,7 @@ operator<<(std::ostream &os, const struct ur_context_create_params_t *params) { os << *(params->pDeviceCount); os << ", "; + os << ".phDevices = {"; for (size_t i = 0; *(params->pphDevices) != NULL && i < *params->pDeviceCount; ++i) { @@ -10691,11 +10933,13 @@ operator<<(std::ostream &os, const struct ur_context_create_params_t *params) { os << "}"; os << ", "; + os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; + os << ".phContext = "; ur_params::serializePtr(os, *(params->pphContext)); @@ -10732,21 +10976,25 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".propName = "; os << *(params->ppropName); os << ", "; + os << ".propSize = "; os << *(params->ppropSize); os << ", "; + os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; + os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -10763,6 +11011,7 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".phNativeContext = "; ur_params::serializePtr(os, *(params->pphNativeContext)); @@ -10779,11 +11028,13 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phNativeContext)); os << ", "; + os << ".numDevices = "; os << *(params->pnumDevices); os << ", "; + os << ".phDevices = {"; for (size_t i = 0; *(params->pphDevices) != NULL && i < *params->pnumDevices; ++i) { @@ -10796,11 +11047,13 @@ operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; + os << ".phContext = "; ur_params::serializePtr(os, *(params->pphContext)); @@ -10817,11 +11070,13 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".pfnDeleter = "; os << *(params->ppfnDeleter); os << ", "; + os << ".pUserData = "; ur_params::serializePtr(os, *(params->ppUserData)); @@ -10838,36 +11093,43 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".hKernel = "; ur_params::serializePtr(os, *(params->phKernel)); os << ", "; + os << ".workDim = "; os << *(params->pworkDim); os << ", "; + os << ".pGlobalWorkOffset = "; ur_params::serializePtr(os, *(params->ppGlobalWorkOffset)); os << ", "; + os << ".pGlobalWorkSize = "; ur_params::serializePtr(os, *(params->ppGlobalWorkSize)); os << ", "; + os << ".pLocalWorkSize = "; ur_params::serializePtr(os, *(params->ppLocalWorkSize)); os << ", "; + os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; + os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -10881,6 +11143,7 @@ operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -10897,11 +11160,13 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; + os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -10915,6 +11180,7 @@ operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -10931,11 +11197,13 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; + os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -10949,6 +11217,7 @@ operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -10965,36 +11234,43 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".hBuffer = "; ur_params::serializePtr(os, *(params->phBuffer)); os << ", "; + os << ".blockingRead = "; os << *(params->pblockingRead); os << ", "; + os << ".offset = "; os << *(params->poffset); os << ", "; + os << ".size = "; os << *(params->psize); os << ", "; + os << ".pDst = "; ur_params::serializePtr(os, *(params->ppDst)); os << ", "; + os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; + os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -11008,6 +11284,7 @@ operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -11024,36 +11301,43 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".hBuffer = "; ur_params::serializePtr(os, *(params->phBuffer)); os << ", "; + os << ".blockingWrite = "; os << *(params->pblockingWrite); os << ", "; + os << ".offset = "; os << *(params->poffset); os << ", "; + os << ".size = "; os << *(params->psize); os << ", "; + os << ".pSrc = "; ur_params::serializePtr(os, *(params->ppSrc)); os << ", "; + os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; + os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -11067,6 +11351,7 @@ operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -11083,61 +11368,73 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".hBuffer = "; ur_params::serializePtr(os, *(params->phBuffer)); os << ", "; + os << ".blockingRead = "; os << *(params->pblockingRead); os << ", "; + os << ".bufferOrigin = "; os << *(params->pbufferOrigin); os << ", "; + os << ".hostOrigin = "; os << *(params->phostOrigin); os << ", "; + os << ".region = "; os << *(params->pregion); os << ", "; + os << ".bufferRowPitch = "; os << *(params->pbufferRowPitch); os << ", "; + os << ".bufferSlicePitch = "; os << *(params->pbufferSlicePitch); os << ", "; + os << ".hostRowPitch = "; os << *(params->phostRowPitch); os << ", "; + os << ".hostSlicePitch = "; os << *(params->phostSlicePitch); os << ", "; + os << ".pDst = "; ur_params::serializePtr(os, *(params->ppDst)); os << ", "; + os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; + os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -11151,6 +11448,7 @@ operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -11167,61 +11465,73 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".hBuffer = "; ur_params::serializePtr(os, *(params->phBuffer)); os << ", "; + os << ".blockingWrite = "; os << *(params->pblockingWrite); os << ", "; + os << ".bufferOrigin = "; os << *(params->pbufferOrigin); os << ", "; + os << ".hostOrigin = "; os << *(params->phostOrigin); os << ", "; + os << ".region = "; os << *(params->pregion); os << ", "; + os << ".bufferRowPitch = "; os << *(params->pbufferRowPitch); os << ", "; + os << ".bufferSlicePitch = "; os << *(params->pbufferSlicePitch); os << ", "; + os << ".hostRowPitch = "; os << *(params->phostRowPitch); os << ", "; + os << ".hostSlicePitch = "; os << *(params->phostSlicePitch); os << ", "; + os << ".pSrc = "; ur_params::serializePtr(os, *(params->ppSrc)); os << ", "; + os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; + os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -11235,6 +11545,7 @@ operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -11251,36 +11562,43 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".hBufferSrc = "; ur_params::serializePtr(os, *(params->phBufferSrc)); os << ", "; + os << ".hBufferDst = "; ur_params::serializePtr(os, *(params->phBufferDst)); os << ", "; + os << ".srcOffset = "; os << *(params->psrcOffset); os << ", "; + os << ".dstOffset = "; os << *(params->pdstOffset); os << ", "; + os << ".size = "; os << *(params->psize); os << ", "; + os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; + os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -11294,6 +11612,7 @@ operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -11310,56 +11629,67 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".hBufferSrc = "; ur_params::serializePtr(os, *(params->phBufferSrc)); os << ", "; + os << ".hBufferDst = "; ur_params::serializePtr(os, *(params->phBufferDst)); os << ", "; + os << ".srcOrigin = "; os << *(params->psrcOrigin); os << ", "; + os << ".dstOrigin = "; os << *(params->pdstOrigin); os << ", "; + os << ".region = "; os << *(params->pregion); os << ", "; + os << ".srcRowPitch = "; os << *(params->psrcRowPitch); os << ", "; + os << ".srcSlicePitch = "; os << *(params->psrcSlicePitch); os << ", "; + os << ".dstRowPitch = "; os << *(params->pdstRowPitch); os << ", "; + os << ".dstSlicePitch = "; os << *(params->pdstSlicePitch); os << ", "; + os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; + os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -11373,6 +11703,7 @@ operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -11389,36 +11720,43 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".hBuffer = "; ur_params::serializePtr(os, *(params->phBuffer)); os << ", "; + os << ".pPattern = "; ur_params::serializePtr(os, *(params->ppPattern)); os << ", "; + os << ".patternSize = "; os << *(params->ppatternSize); os << ", "; + os << ".offset = "; os << *(params->poffset); os << ", "; + os << ".size = "; os << *(params->psize); os << ", "; + os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; + os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -11432,6 +11770,7 @@ operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -11448,46 +11787,55 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".hImage = "; ur_params::serializePtr(os, *(params->phImage)); os << ", "; + os << ".blockingRead = "; os << *(params->pblockingRead); os << ", "; + os << ".origin = "; os << *(params->porigin); os << ", "; + os << ".region = "; os << *(params->pregion); os << ", "; + os << ".rowPitch = "; os << *(params->prowPitch); os << ", "; + os << ".slicePitch = "; os << *(params->pslicePitch); os << ", "; + os << ".pDst = "; ur_params::serializePtr(os, *(params->ppDst)); os << ", "; + os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; + os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -11501,6 +11849,7 @@ operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -11517,46 +11866,55 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".hImage = "; ur_params::serializePtr(os, *(params->phImage)); os << ", "; + os << ".blockingWrite = "; os << *(params->pblockingWrite); os << ", "; + os << ".origin = "; os << *(params->porigin); os << ", "; + os << ".region = "; os << *(params->pregion); os << ", "; + os << ".rowPitch = "; os << *(params->prowPitch); os << ", "; + os << ".slicePitch = "; os << *(params->pslicePitch); os << ", "; + os << ".pSrc = "; ur_params::serializePtr(os, *(params->ppSrc)); os << ", "; + os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; + os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -11570,6 +11928,7 @@ operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -11586,36 +11945,43 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".hImageSrc = "; ur_params::serializePtr(os, *(params->phImageSrc)); os << ", "; + os << ".hImageDst = "; ur_params::serializePtr(os, *(params->phImageDst)); os << ", "; + os << ".srcOrigin = "; os << *(params->psrcOrigin); os << ", "; + os << ".dstOrigin = "; os << *(params->pdstOrigin); os << ", "; + os << ".region = "; os << *(params->pregion); os << ", "; + os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; + os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -11629,6 +11995,7 @@ operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -11645,36 +12012,43 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".hBuffer = "; ur_params::serializePtr(os, *(params->phBuffer)); os << ", "; + os << ".blockingMap = "; os << *(params->pblockingMap); os << ", "; + os << ".mapFlags = "; ur_params::serializeFlag(os, *(params->pmapFlags)); os << ", "; + os << ".offset = "; os << *(params->poffset); os << ", "; + os << ".size = "; os << *(params->psize); os << ", "; + os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; + os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -11688,11 +12062,13 @@ operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); os << ", "; + os << ".ppRetMap = "; ur_params::serializePtr(os, *(params->pppRetMap)); @@ -11709,21 +12085,25 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".hMem = "; ur_params::serializePtr(os, *(params->phMem)); os << ", "; + os << ".pMappedPtr = "; ur_params::serializePtr(os, *(params->ppMappedPtr)); os << ", "; + os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; + os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -11737,6 +12117,7 @@ operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -11753,31 +12134,37 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".ptr = "; ur_params::serializePtr(os, *(params->pptr)); os << ", "; + os << ".patternSize = "; os << *(params->ppatternSize); os << ", "; + os << ".pPattern = "; ur_params::serializePtr(os, *(params->ppPattern)); os << ", "; + os << ".size = "; os << *(params->psize); os << ", "; + os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; + os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -11791,6 +12178,7 @@ operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -11807,31 +12195,37 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".blocking = "; os << *(params->pblocking); os << ", "; + os << ".pDst = "; ur_params::serializePtr(os, *(params->ppDst)); os << ", "; + os << ".pSrc = "; ur_params::serializePtr(os, *(params->ppSrc)); os << ", "; + os << ".size = "; os << *(params->psize); os << ", "; + os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; + os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -11845,6 +12239,7 @@ operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -11861,26 +12256,31 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".pMem = "; ur_params::serializePtr(os, *(params->ppMem)); os << ", "; + os << ".size = "; os << *(params->psize); os << ", "; + os << ".flags = "; ur_params::serializeFlag(os, *(params->pflags)); os << ", "; + os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; + os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -11894,6 +12294,7 @@ operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -11910,21 +12311,25 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".pMem = "; ur_params::serializePtr(os, *(params->ppMem)); os << ", "; + os << ".size = "; os << *(params->psize); os << ", "; + os << ".advice = "; ur_params::serializeFlag(os, *(params->padvice)); os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -11941,41 +12346,49 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".pMem = "; ur_params::serializePtr(os, *(params->ppMem)); os << ", "; + os << ".pitch = "; os << *(params->ppitch); os << ", "; + os << ".patternSize = "; os << *(params->ppatternSize); os << ", "; + os << ".pPattern = "; ur_params::serializePtr(os, *(params->ppPattern)); os << ", "; + os << ".width = "; os << *(params->pwidth); os << ", "; + os << ".height = "; os << *(params->pheight); os << ", "; + os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; + os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -11989,6 +12402,7 @@ operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -12005,46 +12419,55 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".blocking = "; os << *(params->pblocking); os << ", "; + os << ".pDst = "; ur_params::serializePtr(os, *(params->ppDst)); os << ", "; + os << ".dstPitch = "; os << *(params->pdstPitch); os << ", "; + os << ".pSrc = "; ur_params::serializePtr(os, *(params->ppSrc)); os << ", "; + os << ".srcPitch = "; os << *(params->psrcPitch); os << ", "; + os << ".width = "; os << *(params->pwidth); os << ", "; + os << ".height = "; os << *(params->pheight); os << ", "; + os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; + os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -12058,6 +12481,7 @@ operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -12074,41 +12498,49 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".hProgram = "; ur_params::serializePtr(os, *(params->phProgram)); os << ", "; + os << ".name = "; ur_params::serializePtr(os, *(params->pname)); os << ", "; + os << ".blockingWrite = "; os << *(params->pblockingWrite); os << ", "; + os << ".count = "; os << *(params->pcount); os << ", "; + os << ".offset = "; os << *(params->poffset); os << ", "; + os << ".pSrc = "; ur_params::serializePtr(os, *(params->ppSrc)); os << ", "; + os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; + os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -12122,6 +12554,7 @@ inline std::ostream &operator<<( os << "}"; os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -12138,41 +12571,49 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".hProgram = "; ur_params::serializePtr(os, *(params->phProgram)); os << ", "; + os << ".name = "; ur_params::serializePtr(os, *(params->pname)); os << ", "; + os << ".blockingRead = "; os << *(params->pblockingRead); os << ", "; + os << ".count = "; os << *(params->pcount); os << ", "; + os << ".offset = "; os << *(params->poffset); os << ", "; + os << ".pDst = "; ur_params::serializePtr(os, *(params->ppDst)); os << ", "; + os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; + os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -12186,6 +12627,7 @@ inline std::ostream &operator<<( os << "}"; os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -12202,36 +12644,43 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".hProgram = "; ur_params::serializePtr(os, *(params->phProgram)); os << ", "; + os << ".pipe_symbol = "; ur_params::serializePtr(os, *(params->ppipe_symbol)); os << ", "; + os << ".blocking = "; os << *(params->pblocking); os << ", "; + os << ".pDst = "; ur_params::serializePtr(os, *(params->ppDst)); os << ", "; + os << ".size = "; os << *(params->psize); os << ", "; + os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; + os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -12245,6 +12694,7 @@ operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -12261,36 +12711,43 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".hProgram = "; ur_params::serializePtr(os, *(params->phProgram)); os << ", "; + os << ".pipe_symbol = "; ur_params::serializePtr(os, *(params->ppipe_symbol)); os << ", "; + os << ".blocking = "; os << *(params->pblocking); os << ", "; + os << ".pSrc = "; ur_params::serializePtr(os, *(params->ppSrc)); os << ", "; + os << ".size = "; os << *(params->psize); os << ", "; + os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; + os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -12304,6 +12761,7 @@ operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -12319,21 +12777,25 @@ operator<<(std::ostream &os, const struct ur_event_get_info_params_t *params) { ur_params::serializePtr(os, *(params->phEvent)); os << ", "; + os << ".propName = "; os << *(params->ppropName); os << ", "; + os << ".propSize = "; os << *(params->ppropSize); os << ", "; + os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; + os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -12350,21 +12812,25 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phEvent)); os << ", "; + os << ".propName = "; os << *(params->ppropName); os << ", "; + os << ".propSize = "; os << *(params->ppropSize); os << ", "; + os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; + os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -12380,6 +12846,7 @@ inline std::ostream &operator<<(std::ostream &os, os << *(params->pnumEvents); os << ", "; + os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEvents; ++i) { @@ -12423,6 +12890,7 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phEvent)); os << ", "; + os << ".phNativeEvent = "; ur_params::serializePtr(os, *(params->pphNativeEvent)); @@ -12439,16 +12907,19 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phNativeEvent)); os << ", "; + os << ".hContext = "; ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; + os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -12465,16 +12936,19 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phEvent)); os << ", "; + os << ".execStatus = "; os << *(params->pexecStatus); os << ", "; + os << ".pfnNotify = "; os << *(params->ppfnNotify); os << ", "; + os << ".pUserData = "; ur_params::serializePtr(os, *(params->ppUserData)); @@ -12490,11 +12964,13 @@ operator<<(std::ostream &os, const struct ur_kernel_create_params_t *params) { ur_params::serializePtr(os, *(params->phProgram)); os << ", "; + os << ".pKernelName = "; ur_params::serializePtr(os, *(params->ppKernelName)); os << ", "; + os << ".phKernel = "; ur_params::serializePtr(os, *(params->pphKernel)); @@ -12510,21 +12986,25 @@ operator<<(std::ostream &os, const struct ur_kernel_get_info_params_t *params) { ur_params::serializePtr(os, *(params->phKernel)); os << ", "; + os << ".propName = "; os << *(params->ppropName); os << ", "; + os << ".propSize = "; os << *(params->ppropSize); os << ", "; + os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; + os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -12541,26 +13021,31 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phKernel)); os << ", "; + os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".propName = "; os << *(params->ppropName); os << ", "; + os << ".propSize = "; os << *(params->ppropSize); os << ", "; + os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; + os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -12577,26 +13062,31 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phKernel)); os << ", "; + os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".propName = "; os << *(params->ppropName); os << ", "; + os << ".propSize = "; os << *(params->ppropSize); os << ", "; + os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; + os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -12633,6 +13123,7 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phKernel)); os << ", "; + os << ".phNativeKernel = "; ur_params::serializePtr(os, *(params->pphNativeKernel)); @@ -12649,21 +13140,25 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phNativeKernel)); os << ", "; + os << ".hContext = "; ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".hProgram = "; ur_params::serializePtr(os, *(params->phProgram)); os << ", "; + os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; + os << ".phKernel = "; ur_params::serializePtr(os, *(params->pphKernel)); @@ -12680,21 +13175,25 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phKernel)); os << ", "; + os << ".argIndex = "; os << *(params->pargIndex); os << ", "; + os << ".argSize = "; os << *(params->pargSize); os << ", "; + os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; + os << ".pArgValue = "; ur_params::serializePtr(os, *(params->ppArgValue)); @@ -12711,16 +13210,19 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phKernel)); os << ", "; + os << ".argIndex = "; os << *(params->pargIndex); os << ", "; + os << ".argSize = "; os << *(params->pargSize); os << ", "; + os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); @@ -12737,16 +13239,19 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phKernel)); os << ", "; + os << ".argIndex = "; os << *(params->pargIndex); os << ", "; + os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; + os << ".pArgValue = "; ur_params::serializePtr(os, *(params->ppArgValue)); @@ -12763,21 +13268,25 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phKernel)); os << ", "; + os << ".propName = "; os << *(params->ppropName); os << ", "; + os << ".propSize = "; os << *(params->ppropSize); os << ", "; + os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; + os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); @@ -12794,16 +13303,19 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phKernel)); os << ", "; + os << ".argIndex = "; os << *(params->pargIndex); os << ", "; + os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; + os << ".hArgValue = "; ur_params::serializePtr(os, *(params->phArgValue)); @@ -12820,16 +13332,19 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phKernel)); os << ", "; + os << ".argIndex = "; os << *(params->pargIndex); os << ", "; + os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; + os << ".hArgValue = "; ur_params::serializePtr(os, *(params->phArgValue)); @@ -12846,11 +13361,13 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phKernel)); os << ", "; + os << ".count = "; os << *(params->pcount); os << ", "; + os << ".pSpecConstants = "; ur_params::serializePtr(os, *(params->ppSpecConstants)); @@ -12867,26 +13384,31 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".flags = "; ur_params::serializeFlag(os, *(params->pflags)); os << ", "; + os << ".pImageFormat = "; ur_params::serializePtr(os, *(params->ppImageFormat)); os << ", "; + os << ".pImageDesc = "; ur_params::serializePtr(os, *(params->ppImageDesc)); os << ", "; + os << ".pHost = "; ur_params::serializePtr(os, *(params->ppHost)); os << ", "; + os << ".phMem = "; ur_params::serializePtr(os, *(params->pphMem)); @@ -12903,21 +13425,25 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".flags = "; ur_params::serializeFlag(os, *(params->pflags)); os << ", "; + os << ".size = "; os << *(params->psize); os << ", "; + os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; + os << ".phBuffer = "; ur_params::serializePtr(os, *(params->pphBuffer)); @@ -12954,21 +13480,25 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phBuffer)); os << ", "; + os << ".flags = "; ur_params::serializeFlag(os, *(params->pflags)); os << ", "; + os << ".bufferCreateType = "; os << *(params->pbufferCreateType); os << ", "; + os << ".pRegion = "; ur_params::serializePtr(os, *(params->ppRegion)); os << ", "; + os << ".phMem = "; ur_params::serializePtr(os, *(params->pphMem)); @@ -12985,6 +13515,7 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phMem)); os << ", "; + os << ".phNativeMem = "; ur_params::serializePtr(os, *(params->pphNativeMem)); @@ -13001,16 +13532,19 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phNativeMem)); os << ", "; + os << ".hContext = "; ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; + os << ".phMem = "; ur_params::serializePtr(os, *(params->pphMem)); @@ -13027,26 +13561,31 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phNativeMem)); os << ", "; + os << ".hContext = "; ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".pImageFormat = "; ur_params::serializePtr(os, *(params->ppImageFormat)); os << ", "; + os << ".pImageDesc = "; ur_params::serializePtr(os, *(params->ppImageDesc)); os << ", "; + os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; + os << ".phMem = "; ur_params::serializePtr(os, *(params->pphMem)); @@ -13062,21 +13601,25 @@ inline std::ostream &operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phMemory)); os << ", "; + os << ".propName = "; os << *(params->ppropName); os << ", "; + os << ".propSize = "; os << *(params->ppropSize); os << ", "; + os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; + os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -13093,21 +13636,25 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phMemory)); os << ", "; + os << ".propName = "; os << *(params->ppropName); os << ", "; + os << ".propSize = "; os << *(params->ppropSize); os << ", "; + os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; + os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -13124,21 +13671,25 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".size = "; os << *(params->psize); os << ", "; + os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; + os << ".phPhysicalMem = "; ur_params::serializePtr(os, *(params->pphPhysicalMem)); @@ -13176,6 +13727,7 @@ inline std::ostream &operator<<(std::ostream &os, os << *(params->pNumEntries); os << ", "; + os << ".phPlatforms = {"; for (size_t i = 0; *(params->pphPlatforms) != NULL && i < *params->pNumEntries; ++i) { @@ -13188,6 +13740,7 @@ inline std::ostream &operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".pNumPlatforms = "; ur_params::serializePtr(os, *(params->ppNumPlatforms)); @@ -13204,21 +13757,25 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phPlatform)); os << ", "; + os << ".propName = "; os << *(params->ppropName); os << ", "; + os << ".propSize = "; os << *(params->ppropSize); os << ", "; + os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; + os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -13235,6 +13792,7 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phPlatform)); os << ", "; + os << ".phNativePlatform = "; ur_params::serializePtr(os, *(params->pphNativePlatform)); @@ -13251,11 +13809,13 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phNativePlatform)); os << ", "; + os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; + os << ".phPlatform = "; ur_params::serializePtr(os, *(params->pphPlatform)); @@ -13272,11 +13832,13 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phPlatform)); os << ", "; + os << ".ppMessage = "; ur_params::serializePtr(os, *(params->pppMessage)); os << ", "; + os << ".pError = "; ur_params::serializePtr(os, *(params->ppError)); @@ -13293,6 +13855,7 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phPlatform)); os << ", "; + os << ".pVersion = "; ur_params::serializePtr(os, *(params->ppVersion)); @@ -13309,11 +13872,13 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phPlatform)); os << ", "; + os << ".pFrontendOption = "; ur_params::serializePtr(os, *(params->ppFrontendOption)); os << ", "; + os << ".ppPlatformOption = "; ur_params::serializePtr(os, *(params->pppPlatformOption)); @@ -13330,21 +13895,25 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".pIL = "; ur_params::serializePtr(os, *(params->ppIL)); os << ", "; + os << ".length = "; os << *(params->plength); os << ", "; + os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; + os << ".phProgram = "; ur_params::serializePtr(os, *(params->pphProgram)); @@ -13361,26 +13930,31 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".size = "; os << *(params->psize); os << ", "; + os << ".pBinary = "; ur_params::serializePtr(os, *(params->ppBinary)); os << ", "; + os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; + os << ".phProgram = "; ur_params::serializePtr(os, *(params->pphProgram)); @@ -13396,11 +13970,13 @@ operator<<(std::ostream &os, const struct ur_program_build_params_t *params) { ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".hProgram = "; ur_params::serializePtr(os, *(params->phProgram)); os << ", "; + os << ".pOptions = "; ur_params::serializePtr(os, *(params->ppOptions)); @@ -13416,11 +13992,13 @@ operator<<(std::ostream &os, const struct ur_program_compile_params_t *params) { ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".hProgram = "; ur_params::serializePtr(os, *(params->phProgram)); os << ", "; + os << ".pOptions = "; ur_params::serializePtr(os, *(params->ppOptions)); @@ -13436,11 +14014,13 @@ inline std::ostream &operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".count = "; os << *(params->pcount); os << ", "; + os << ".phPrograms = {"; for (size_t i = 0; *(params->pphPrograms) != NULL && i < *params->pcount; ++i) { @@ -13453,11 +14033,13 @@ inline std::ostream &operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".pOptions = "; ur_params::serializePtr(os, *(params->ppOptions)); os << ", "; + os << ".phProgram = "; ur_params::serializePtr(os, *(params->pphProgram)); @@ -13494,16 +14076,19 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".hProgram = "; ur_params::serializePtr(os, *(params->phProgram)); os << ", "; + os << ".pFunctionName = "; ur_params::serializePtr(os, *(params->ppFunctionName)); os << ", "; + os << ".ppFunctionPointer = "; ur_params::serializePtr(os, *(params->pppFunctionPointer)); @@ -13520,21 +14105,25 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phProgram)); os << ", "; + os << ".propName = "; os << *(params->ppropName); os << ", "; + os << ".propSize = "; os << *(params->ppropSize); os << ", "; + os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; + os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -13551,26 +14140,31 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phProgram)); os << ", "; + os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".propName = "; os << *(params->ppropName); os << ", "; + os << ".propSize = "; os << *(params->ppropSize); os << ", "; + os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; + os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -13587,11 +14181,13 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phProgram)); os << ", "; + os << ".count = "; os << *(params->pcount); os << ", "; + os << ".pSpecConstants = {"; for (size_t i = 0; *(params->ppSpecConstants) != NULL && i < *params->pcount; ++i) { @@ -13615,6 +14211,7 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phProgram)); os << ", "; + os << ".phNativeProgram = "; ur_params::serializePtr(os, *(params->pphNativeProgram)); @@ -13631,16 +14228,19 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phNativeProgram)); os << ", "; + os << ".hContext = "; ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; + os << ".phProgram = "; ur_params::serializePtr(os, *(params->pphProgram)); @@ -13656,21 +14256,25 @@ operator<<(std::ostream &os, const struct ur_queue_get_info_params_t *params) { ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".propName = "; os << *(params->ppropName); os << ", "; + os << ".propSize = "; os << *(params->ppropSize); os << ", "; + os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; + os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -13686,16 +14290,19 @@ inline std::ostream &operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; + os << ".phQueue = "; ur_params::serializePtr(os, *(params->pphQueue)); @@ -13732,11 +14339,13 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; + os << ".pDesc = "; ur_params::serializePtr(os, *(params->ppDesc)); os << ", "; + os << ".phNativeQueue = "; ur_params::serializePtr(os, *(params->pphNativeQueue)); @@ -13753,21 +14362,25 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phNativeQueue)); os << ", "; + os << ".hContext = "; ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; + os << ".phQueue = "; ur_params::serializePtr(os, *(params->pphQueue)); @@ -13803,11 +14416,13 @@ operator<<(std::ostream &os, const struct ur_sampler_create_params_t *params) { ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".pDesc = "; ur_params::serializePtr(os, *(params->ppDesc)); os << ", "; + os << ".phSampler = "; ur_params::serializePtr(os, *(params->pphSampler)); @@ -13844,21 +14459,25 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phSampler)); os << ", "; + os << ".propName = "; os << *(params->ppropName); os << ", "; + os << ".propSize = "; os << *(params->ppropSize); os << ", "; + os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; + os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -13875,6 +14494,7 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phSampler)); os << ", "; + os << ".phNativeSampler = "; ur_params::serializePtr(os, *(params->pphNativeSampler)); @@ -13891,16 +14511,19 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phNativeSampler)); os << ", "; + os << ".hContext = "; ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; + os << ".phSampler = "; ur_params::serializePtr(os, *(params->pphSampler)); @@ -13916,21 +14539,25 @@ operator<<(std::ostream &os, const struct ur_usm_host_alloc_params_t *params) { ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".pUSMDesc = "; ur_params::serializePtr(os, *(params->ppUSMDesc)); os << ", "; + os << ".pool = "; ur_params::serializePtr(os, *(params->ppool)); os << ", "; + os << ".size = "; os << *(params->psize); os << ", "; + os << ".ppMem = "; ur_params::serializePtr(os, *(params->pppMem)); @@ -13947,26 +14574,31 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".pUSMDesc = "; ur_params::serializePtr(os, *(params->ppUSMDesc)); os << ", "; + os << ".pool = "; ur_params::serializePtr(os, *(params->ppool)); os << ", "; + os << ".size = "; os << *(params->psize); os << ", "; + os << ".ppMem = "; ur_params::serializePtr(os, *(params->pppMem)); @@ -13983,26 +14615,31 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".pUSMDesc = "; ur_params::serializePtr(os, *(params->ppUSMDesc)); os << ", "; + os << ".pool = "; ur_params::serializePtr(os, *(params->ppool)); os << ", "; + os << ".size = "; os << *(params->psize); os << ", "; + os << ".ppMem = "; ur_params::serializePtr(os, *(params->pppMem)); @@ -14018,6 +14655,7 @@ inline std::ostream &operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".pMem = "; ur_params::serializePtr(os, *(params->ppMem)); @@ -14034,26 +14672,31 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".pMem = "; ur_params::serializePtr(os, *(params->ppMem)); os << ", "; + os << ".propName = "; os << *(params->ppropName); os << ", "; + os << ".propSize = "; os << *(params->ppropSize); os << ", "; + os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; + os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -14069,11 +14712,13 @@ operator<<(std::ostream &os, const struct ur_usm_pool_create_params_t *params) { ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".pPoolDesc = "; ur_params::serializePtr(os, *(params->ppPoolDesc)); os << ", "; + os << ".ppPool = "; ur_params::serializePtr(os, *(params->pppPool)); @@ -14111,21 +14756,25 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phPool)); os << ", "; + os << ".propName = "; os << *(params->ppropName); os << ", "; + os << ".propSize = "; os << *(params->ppropSize); os << ", "; + os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; + os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -14142,41 +14791,49 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".pUSMDesc = "; ur_params::serializePtr(os, *(params->ppUSMDesc)); os << ", "; + os << ".pool = "; ur_params::serializePtr(os, *(params->ppool)); os << ", "; + os << ".widthInBytes = "; os << *(params->pwidthInBytes); os << ", "; + os << ".height = "; os << *(params->pheight); os << ", "; + os << ".elementSizeBytes = "; os << *(params->pelementSizeBytes); os << ", "; + os << ".ppMem = "; ur_params::serializePtr(os, *(params->pppMem)); os << ", "; + os << ".pResultPitch = "; ur_params::serializePtr(os, *(params->ppResultPitch)); @@ -14192,11 +14849,13 @@ operator<<(std::ostream &os, const struct ur_usm_import_exp_params_t *params) { ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".pMem = "; ur_params::serializePtr(os, *(params->ppMem)); os << ", "; + os << ".size = "; os << *(params->psize); @@ -14212,6 +14871,7 @@ operator<<(std::ostream &os, const struct ur_usm_release_exp_params_t *params) { ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".pMem = "; ur_params::serializePtr(os, *(params->ppMem)); @@ -14228,6 +14888,7 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->pcommandDevice)); os << ", "; + os << ".peerDevice = "; ur_params::serializePtr(os, *(params->ppeerDevice)); @@ -14244,6 +14905,7 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->pcommandDevice)); os << ", "; + os << ".peerDevice = "; ur_params::serializePtr(os, *(params->ppeerDevice)); @@ -14260,26 +14922,31 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->pcommandDevice)); os << ", "; + os << ".peerDevice = "; ur_params::serializePtr(os, *(params->ppeerDevice)); os << ", "; + os << ".propName = "; os << *(params->ppropName); os << ", "; + os << ".propSize = "; os << *(params->ppropSize); os << ", "; + os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; + os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -14296,26 +14963,31 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".propName = "; os << *(params->ppropName); os << ", "; + os << ".propSize = "; os << *(params->ppropSize); os << ", "; + os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; + os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -14332,16 +15004,19 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".pStart = "; ur_params::serializePtr(os, *(params->ppStart)); os << ", "; + os << ".size = "; os << *(params->psize); os << ", "; + os << ".ppStart = "; ur_params::serializePtr(os, *(params->pppStart)); @@ -14358,11 +15033,13 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".pStart = "; ur_params::serializePtr(os, *(params->ppStart)); os << ", "; + os << ".size = "; os << *(params->psize); @@ -14378,26 +15055,31 @@ operator<<(std::ostream &os, const struct ur_virtual_mem_map_params_t *params) { ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".pStart = "; ur_params::serializePtr(os, *(params->ppStart)); os << ", "; + os << ".size = "; os << *(params->psize); os << ", "; + os << ".hPhysicalMem = "; ur_params::serializePtr(os, *(params->phPhysicalMem)); os << ", "; + os << ".offset = "; os << *(params->poffset); os << ", "; + os << ".flags = "; ur_params::serializeFlag(os, @@ -14415,11 +15097,13 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".pStart = "; ur_params::serializePtr(os, *(params->ppStart)); os << ", "; + os << ".size = "; os << *(params->psize); @@ -14436,16 +15120,19 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".pStart = "; ur_params::serializePtr(os, *(params->ppStart)); os << ", "; + os << ".size = "; os << *(params->psize); os << ", "; + os << ".flags = "; ur_params::serializeFlag(os, @@ -14463,31 +15150,37 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; + os << ".pStart = "; ur_params::serializePtr(os, *(params->ppStart)); os << ", "; + os << ".size = "; os << *(params->psize); os << ", "; + os << ".propName = "; os << *(params->ppropName); os << ", "; + os << ".propSize = "; os << *(params->ppropSize); os << ", "; + os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; + os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -14503,16 +15196,19 @@ inline std::ostream &operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phPlatform)); os << ", "; + os << ".DeviceType = "; os << *(params->pDeviceType); os << ", "; + os << ".NumEntries = "; os << *(params->pNumEntries); os << ", "; + os << ".phDevices = {"; for (size_t i = 0; *(params->pphDevices) != NULL && i < *params->pNumEntries; ++i) { @@ -14525,6 +15221,7 @@ inline std::ostream &operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".pNumDevices = "; ur_params::serializePtr(os, *(params->ppNumDevices)); @@ -14540,21 +15237,25 @@ operator<<(std::ostream &os, const struct ur_device_get_info_params_t *params) { ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".propName = "; os << *(params->ppropName); os << ", "; + os << ".propSize = "; os << *(params->ppropSize); os << ", "; + os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; + os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -14591,16 +15292,19 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; + os << ".NumDevices = "; os << *(params->pNumDevices); os << ", "; + os << ".phSubDevices = {"; for (size_t i = 0; *(params->pphSubDevices) != NULL && i < *params->pNumDevices; ++i) { @@ -14613,6 +15317,7 @@ operator<<(std::ostream &os, os << "}"; os << ", "; + os << ".pNumDevicesRet = "; ur_params::serializePtr(os, *(params->ppNumDevicesRet)); @@ -14629,16 +15334,19 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".pBinaries = "; ur_params::serializePtr(os, *(params->ppBinaries)); os << ", "; + os << ".NumBinaries = "; os << *(params->pNumBinaries); os << ", "; + os << ".pSelectedBinary = "; ur_params::serializePtr(os, *(params->ppSelectedBinary)); @@ -14655,6 +15363,7 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".phNativeDevice = "; ur_params::serializePtr(os, *(params->pphNativeDevice)); @@ -14671,16 +15380,19 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phNativeDevice)); os << ", "; + os << ".hPlatform = "; ur_params::serializePtr(os, *(params->phPlatform)); os << ", "; + os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; + os << ".phDevice = "; ur_params::serializePtr(os, *(params->pphDevice)); @@ -14697,11 +15409,13 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phDevice)); os << ", "; + os << ".pDeviceTimestamp = "; ur_params::serializePtr(os, *(params->ppDeviceTimestamp)); os << ", "; + os << ".pHostTimestamp = "; ur_params::serializePtr(os, *(params->ppHostTimestamp)); diff --git a/test/unit/utils/params.cpp b/test/unit/utils/params.cpp index 742804101d..95fc8d0e68 100644 --- a/test/unit/utils/params.cpp +++ b/test/unit/utils/params.cpp @@ -306,6 +306,49 @@ struct UrContextGetInfoParamsDevicesArray : UrContextGetInfoParams { }; }; +struct UrProgramMetadataTest { + UrProgramMetadataTest() { + meta.pName = "MY_META"; + meta.size = 0; + meta.type = UR_PROGRAM_METADATA_TYPE_UINT32; + ur_program_metadata_value_t value{}; + value.data32 = 42; + meta.value = value; + } + + ur_program_metadata_t &get_struct() { return meta; } + const char *get_expected() { + return "\\(struct ur_program_metadata_t\\)" + "\\{" + ".pName = .+ \\(MY_META\\), " + ".type = UR_PROGRAM_METADATA_TYPE_UINT32, " + ".size = 0, " + ".value = 42" + "\\}"; + } + ur_program_metadata_t meta; +}; + +struct UrDevicePartitionPropertyTest { + UrDevicePartitionPropertyTest() { + prop.type = UR_DEVICE_PARTITION_EQUALLY; + ur_device_partition_value_t value{}; + value.equally = 4; + prop.value = value; + } + + ur_device_partition_property_t &get_struct() { return prop; } + const char *get_expected() { + return "\\(struct ur_device_partition_property_t\\)" + "\\{" + ".type = UR_DEVICE_PARTITION_EQUALLY, " + ".value = 4" + "\\}"; + } + + ur_device_partition_property_t prop; +}; + using testing::Types; typedef Types< UrInitParamsNoFlags, UrInitParamsInvalidFlags, UrUsmHostAllocParamsEmpty, @@ -313,7 +356,8 @@ typedef Types< UrUsmHostAllocParamsUsmDesc, UrUsmHostAllocParamsHostDesc, UrDeviceGetInfoParamsEmpty, UrDeviceGetInfoParamsName, UrDeviceGetInfoParamsQueueFlag, UrDeviceGetInfoParamsPartitionArray, - UrContextGetInfoParamsDevicesArray, UrDeviceGetInfoParamsInvalidSize> + UrContextGetInfoParamsDevicesArray, UrDeviceGetInfoParamsInvalidSize, + UrProgramMetadataTest, UrDevicePartitionPropertyTest> Implementations; using ::testing::MatchesRegex; From 7d22d0a1cb62f515c04f91d551ea2f5eb93455b3 Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Mon, 10 Jul 2023 09:03:13 +0100 Subject: [PATCH 058/104] [UR] Address review comments for union serialize --- scripts/YaML.md | 2 +- scripts/templates/params.hpp.mako | 14 ++++++++++---- source/common/ur_params.hpp | 28 ++++++++++++++-------------- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/scripts/YaML.md b/scripts/YaML.md index 90b5c8f843..4b7dcca147 100644 --- a/scripts/YaML.md +++ b/scripts/YaML.md @@ -455,7 +455,7 @@ class ur_name_flags_v(IntEnum): + The special-case descriptor struct should always end with `_desc_t` + The special-case property struct should always end with `_properties_t` * A union requires the following - - `tag` is a reference to a type which will be used to describe which field to access of the union. + - `tag` is a reference to an enum type that will be used to describe which field of the union to access. * A struct|union may take the following optional scalar fields: {`class`, `base`, `condition`, `ordinal`, `version`} - `class` will be used to scope the struct|union declaration within the specified C++ class - `base` will be used as the base type of the structure diff --git a/scripts/templates/params.hpp.mako b/scripts/templates/params.hpp.mako index 767f36977f..ebb3349e1e 100644 --- a/scripts/templates/params.hpp.mako +++ b/scripts/templates/params.hpp.mako @@ -41,6 +41,12 @@ from templates import helper as th %endif +<% +def findUnionTag(union): + tag = [_obj for _s in specs for _obj in _s['objects'] if _obj['name'] == obj['tag']] + return tag[0] if len(tag) > 0 else None +%> + <%def name="line(item, n, params, params_dict)"> <% iname = th._get_param_name(n, tags, item) @@ -74,7 +80,7 @@ member_type = query[0] if len(query) > 0 else None%> os << "}"; %elif member_type is not None and member_type['type'] == "union": os << ".${iname} = "; - ${x}_params::print_union(os, params.${item['name']}, params.${th.param_traits.tagged_member(item)}); + ${x}_params::serializeUnion(os, ${deref}(params${access}${item['name']}), params${access}${th.param_traits.tagged_member(item)}); %elif typename is not None: os << ".${iname} = "; ${x}_params::serializeTagged(os, ${deref}(params${access}${pname}), ${deref}(params${access}${prefix}${typename}), ${deref}(params${access}${prefix}${typename_size})); @@ -104,7 +110,7 @@ template inline void serializeTagged(std::ostream &os, const void * %if re.match(r"union", obj['type']) and obj['name']: <% tag = [_obj for _s in specs for _obj in _s['objects'] if _obj['name'] == obj['tag']][0] %> - inline void print_union( + inline void serializeUnion( std::ostream &os, const ${obj['type']} ${th.make_type_name(n, tags, obj)} params, const ${tag['type']} ${th.make_type_name(n, tags, tag)} tag @@ -293,8 +299,8 @@ inline std::ostream &operator<<(std::ostream &os, const ${obj['type']} ${th.make return os; } %elif re.match(r"union", obj['type']) and obj['name']: -<% tag = [_obj for _s in specs for _obj in _s['objects'] if _obj['name'] == obj['tag']][0] %> -inline void ${x}_params::print_union( +<% tag = findUnionTag(obj) %> +inline void ${x}_params::serializeUnion( std::ostream &os, const ${obj['type']} ${th.make_type_name(n, tags, obj)} params, const ${tag['type']} ${th.make_type_name(n, tags, tag)} tag diff --git a/source/common/ur_params.hpp b/source/common/ur_params.hpp index 5c1950ab1e..0b297c81cb 100644 --- a/source/common/ur_params.hpp +++ b/source/common/ur_params.hpp @@ -42,9 +42,9 @@ template <> inline void serializeFlag(std::ostream &os, uint32_t flag); -inline void print_union(std::ostream &os, - const union ur_device_partition_value_t params, - const enum ur_device_partition_t tag); +inline void serializeUnion(std::ostream &os, + const union ur_device_partition_value_t params, + const enum ur_device_partition_t tag); template <> inline void serializeFlag(std::ostream &os, @@ -129,9 +129,9 @@ template <> inline void serializeFlag(std::ostream &os, uint32_t flag); -inline void print_union(std::ostream &os, - const union ur_program_metadata_value_t params, - const enum ur_program_metadata_type_t tag); +inline void serializeUnion(std::ostream &os, + const union ur_program_metadata_value_t params, + const enum ur_program_metadata_type_t tag); template <> inline void serializeTagged(std::ostream &os, const void *ptr, @@ -4581,9 +4581,9 @@ inline std::ostream &operator<<(std::ostream &os, } inline void -ur_params::print_union(std::ostream &os, - const union ur_device_partition_value_t params, - const enum ur_device_partition_t tag) { +ur_params::serializeUnion(std::ostream &os, + const union ur_device_partition_value_t params, + const enum ur_device_partition_t tag) { switch (tag) { case UR_DEVICE_PARTITION_EQUALLY: os << params.equally; @@ -4611,7 +4611,7 @@ operator<<(std::ostream &os, os << ", "; os << ".value = "; - ur_params::print_union(os, params.value, params.type); + ur_params::serializeUnion(os, (params.value), params.type); os << "}"; return os; @@ -7443,9 +7443,9 @@ inline std::ostream &operator<<(std::ostream &os, } inline void -ur_params::print_union(std::ostream &os, - const union ur_program_metadata_value_t params, - const enum ur_program_metadata_type_t tag) { +ur_params::serializeUnion(std::ostream &os, + const union ur_program_metadata_value_t params, + const enum ur_program_metadata_type_t tag) { switch (tag) { case UR_PROGRAM_METADATA_TYPE_UINT32: os << params.data32; @@ -7487,7 +7487,7 @@ inline std::ostream &operator<<(std::ostream &os, os << ", "; os << ".value = "; - ur_params::print_union(os, params.value, params.type); + ur_params::serializeUnion(os, (params.value), params.type); os << "}"; return os; From a454183e15551279f2e31425754106b445572eee Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Mon, 10 Jul 2023 10:13:56 +0100 Subject: [PATCH 059/104] [UR] Use 'line' to print union members --- scripts/templates/params.hpp.mako | 12 +++++++- source/common/ur_params.hpp | 49 ++++++++++++++++++++++++++----- test/unit/utils/params.cpp | 8 +++-- 3 files changed, 59 insertions(+), 10 deletions(-) diff --git a/scripts/templates/params.hpp.mako b/scripts/templates/params.hpp.mako index ebb3349e1e..a03733d73d 100644 --- a/scripts/templates/params.hpp.mako +++ b/scripts/templates/params.hpp.mako @@ -305,16 +305,26 @@ inline void ${x}_params::serializeUnion( const ${obj['type']} ${th.make_type_name(n, tags, obj)} params, const ${tag['type']} ${th.make_type_name(n, tags, tag)} tag ){ + os << "(${obj['type']} ${th.make_type_name(n, tags, obj)}){"; +<% +params_dict = dict() +for item in obj['members']: + iname = th._get_param_name(n, tags, item) + itype = th._get_type_name(n, tags, obj, item) + params_dict[iname] = itype +%> switch(tag){ %for mem in obj['members']: case ${th.subt(n, tags, mem['tag'])}: - os << params.${mem['name']}; + ## os << params.${mem['name']}; + ${line(mem, 0, False, params_dict)} break; %endfor default: os << ""; break; } + os << "}"; } %endif %endfor # obj in spec['objects'] diff --git a/source/common/ur_params.hpp b/source/common/ur_params.hpp index 0b297c81cb..833c47f559 100644 --- a/source/common/ur_params.hpp +++ b/source/common/ur_params.hpp @@ -4584,20 +4584,36 @@ inline void ur_params::serializeUnion(std::ostream &os, const union ur_device_partition_value_t params, const enum ur_device_partition_t tag) { + os << "(union ur_device_partition_value_t){"; + switch (tag) { case UR_DEVICE_PARTITION_EQUALLY: - os << params.equally; + + os << ".equally = "; + + os << (params.equally); + break; case UR_DEVICE_PARTITION_BY_COUNTS: - os << params.count; + + os << ".count = "; + + os << (params.count); + break; case UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN: - os << params.affinity_domain; + + os << ".affinity_domain = "; + + ur_params::serializeFlag( + os, (params.affinity_domain)); + break; default: os << ""; break; } + os << "}"; } inline std::ostream & operator<<(std::ostream &os, @@ -7446,23 +7462,42 @@ inline void ur_params::serializeUnion(std::ostream &os, const union ur_program_metadata_value_t params, const enum ur_program_metadata_type_t tag) { + os << "(union ur_program_metadata_value_t){"; + switch (tag) { case UR_PROGRAM_METADATA_TYPE_UINT32: - os << params.data32; + + os << ".data32 = "; + + os << (params.data32); + break; case UR_PROGRAM_METADATA_TYPE_UINT64: - os << params.data64; + + os << ".data64 = "; + + os << (params.data64); + break; case UR_PROGRAM_METADATA_TYPE_STRING: - os << params.pString; + + os << ".pString = "; + + ur_params::serializePtr(os, (params.pString)); + break; case UR_PROGRAM_METADATA_TYPE_BYTE_ARRAY: - os << params.pData; + + os << ".pData = "; + + ur_params::serializePtr(os, (params.pData)); + break; default: os << ""; break; } + os << "}"; } inline std::ostream &operator<<(std::ostream &os, const struct ur_program_metadata_t params) { diff --git a/test/unit/utils/params.cpp b/test/unit/utils/params.cpp index 95fc8d0e68..b1621f7bb2 100644 --- a/test/unit/utils/params.cpp +++ b/test/unit/utils/params.cpp @@ -323,7 +323,9 @@ struct UrProgramMetadataTest { ".pName = .+ \\(MY_META\\), " ".type = UR_PROGRAM_METADATA_TYPE_UINT32, " ".size = 0, " - ".value = 42" + ".value = \\(union ur_program_metadata_value_t\\)\\{" + ".data32 = 42" + "\\}" "\\}"; } ur_program_metadata_t meta; @@ -342,7 +344,9 @@ struct UrDevicePartitionPropertyTest { return "\\(struct ur_device_partition_property_t\\)" "\\{" ".type = UR_DEVICE_PARTITION_EQUALLY, " - ".value = 4" + ".value = \\(union ur_device_partition_value_t\\)\\{" + ".equally = 4" + "\\}" "\\}"; } From cb554c25c1c26f78dc63f2ad744eb4bc683f84e7 Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Mon, 10 Jul 2023 10:57:55 +0100 Subject: [PATCH 060/104] [UR] add verification checks for tags --- scripts/parse_specs.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/parse_specs.py b/scripts/parse_specs.py index c6a51b7102..d0094f958c 100644 --- a/scripts/parse_specs.py +++ b/scripts/parse_specs.py @@ -292,6 +292,9 @@ def __validate_members(d, tags): if item['type'].endswith("flag_t"): raise Exception(prefix+"'type' must not be '*_flag_t': %s"%item['type']) + if d['type'] == 'union'and item.get('tag') is None: + raise Exception(prefix + f"union member {item['name']} must include a 'tag' annotation") + ver = __validate_version(item, prefix=prefix, base_version=d_ver) if ver < max_ver: raise Exception(prefix+"'version' must be increasing: %s"%item['version']) @@ -339,7 +342,11 @@ def __validate_params(d, tags): if ver < max_ver: raise Exception(prefix+"'version' must be increasing: %s"%item['version']) max_ver = ver - + + def __validate_union_tag(d): + if d.get('tag') is None: + raise Exception(f"{d['name']} must include a 'tag' part of the union.") + try: if 'type' not in d: raise Exception("every document must have 'type'") @@ -401,6 +408,8 @@ def __validate_params(d, tags): if ('desc' not in d) or ('name' not in d): raise Exception("'%s' requires the following scalar fields: {`desc`, `name`}"%d['type']) + if d['type'] == 'union': + __validate_union_tag(d) __validate_type(d, 'name', tags) __validate_base(d) __validate_members(d, tags) From d66a8500d1822c6366e2e57c418b5897cf692760 Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Tue, 11 Jul 2023 10:30:33 +0100 Subject: [PATCH 061/104] [UR] Remove extra whitespace from template --- scripts/YaML.md | 2 +- scripts/templates/params.hpp.mako | 16 +- source/common/ur_params.hpp | 717 ------------------------------ 3 files changed, 9 insertions(+), 726 deletions(-) diff --git a/scripts/YaML.md b/scripts/YaML.md index 4b7dcca147..a735a7f7a4 100644 --- a/scripts/YaML.md +++ b/scripts/YaML.md @@ -471,7 +471,7 @@ class ur_name_flags_v(IntEnum): - `in,out` is used for members that are both read and write; typically this is used for pointers to other data structures that contain both read and write members - `nocheck` is used to specify that no additional validation checks will be generated. + `desc` must also include the following annotation when describing a union: {`"tagged_by(param)"`} - - `tagged_by` is use to specify which parameter will be used as the tag for accessing the union. + - `tagged_by` is used to specify which parameter will be used as the tag for accessing the union. + `desc` may include one the following annotations: {`"[optional]"`, `"[typename(typeVarName, sizeVarName)]"`} - `optional` is used for members that are pointers where it is legal for the value to be `nullptr` - `typename` is used to denote the type enum for params that are opaque pointers to values of tagged data types. diff --git a/scripts/templates/params.hpp.mako b/scripts/templates/params.hpp.mako index a03733d73d..78966d66ff 100644 --- a/scripts/templates/params.hpp.mako +++ b/scripts/templates/params.hpp.mako @@ -42,9 +42,13 @@ from templates import helper as th <% -def findUnionTag(union): - tag = [_obj for _s in specs for _obj in _s['objects'] if _obj['name'] == obj['tag']] +def findUnionTag(_union): + tag = [_obj for _s in specs for _obj in _s['objects'] if _obj['name'] == _union['tag']] return tag[0] if len(tag) > 0 else None + +def findMemberType(_item): + query = [_o for _s in specs for _o in _s['objects'] if _o['name'] == _item['type']] + return query[0] if len(query) > 0 else None %> <%def name="line(item, n, params, params_dict)"> @@ -63,10 +67,7 @@ def findUnionTag(union): %if n != 0: os << ", "; %endif - ## Find out if the member refers to a union -<% query = [_o for _s in specs for _o in _s['objects'] if _o['name'] == item['type']] -member_type = query[0] if len(query) > 0 else None%> - ## can't iterate over 'void *'... +## can't iterate over 'void *'... %if th.param_traits.is_range(item) and "void*" not in itype: os << ".${iname} = {"; for (size_t i = ${th.param_traits.range_start(item)}; ${deref}(params${access}${pname}) != NULL && i < ${deref}params${access}${prefix + th.param_traits.range_end(item)}; ++i) { @@ -78,7 +79,7 @@ member_type = query[0] if len(query) > 0 else None%> } os << "}"; - %elif member_type is not None and member_type['type'] == "union": + %elif findMemberType(item) is not None and findMemberType(item)['type'] == "union": os << ".${iname} = "; ${x}_params::serializeUnion(os, ${deref}(params${access}${item['name']}), params${access}${th.param_traits.tagged_member(item)}); %elif typename is not None: @@ -316,7 +317,6 @@ for item in obj['members']: switch(tag){ %for mem in obj['members']: case ${th.subt(n, tags, mem['tag'])}: - ## os << params.${mem['name']}; ${line(mem, 0, False, params_dict)} break; %endfor diff --git a/source/common/ur_params.hpp b/source/common/ur_params.hpp index 833c47f559..e3e17281d4 100644 --- a/source/common/ur_params.hpp +++ b/source/common/ur_params.hpp @@ -1747,7 +1747,6 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); @@ -1764,7 +1763,6 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); @@ -1781,13 +1779,11 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.x); os << ", "; - os << ".y = "; os << (params.y); os << ", "; - os << ".z = "; os << (params.z); @@ -1804,13 +1800,11 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.width); os << ", "; - os << ".height = "; os << (params.height); os << ", "; - os << ".depth = "; os << (params.depth); @@ -2023,13 +2017,11 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".isNativeHandleOwned = "; os << (params.isNativeHandleOwned); @@ -2075,13 +2067,11 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".pDeviceTargetSpec = "; ur_params::serializePtr(os, (params.pDeviceTargetSpec)); @@ -4625,7 +4615,6 @@ operator<<(std::ostream &os, os << (params.type); os << ", "; - os << ".value = "; ur_params::serializeUnion(os, (params.value), params.type); @@ -4642,19 +4631,16 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".pProperties = "; ur_params::serializePtr(os, (params.pProperties)); os << ", "; - os << ".PropCount = "; os << (params.PropCount); @@ -4919,13 +4905,11 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".isNativeHandleOwned = "; os << (params.isNativeHandleOwned); @@ -5277,13 +5261,11 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".flags = "; ur_params::serializeFlag(os, (params.flags)); @@ -5497,13 +5479,11 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".isNativeHandleOwned = "; os << (params.isNativeHandleOwned); @@ -6016,7 +5996,6 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.channelOrder); os << ", "; - os << ".channelType = "; os << (params.channelType); @@ -6033,61 +6012,51 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".type = "; os << (params.type); os << ", "; - os << ".width = "; os << (params.width); os << ", "; - os << ".height = "; os << (params.height); os << ", "; - os << ".depth = "; os << (params.depth); os << ", "; - os << ".arraySize = "; os << (params.arraySize); os << ", "; - os << ".rowPitch = "; os << (params.rowPitch); os << ", "; - os << ".slicePitch = "; os << (params.slicePitch); os << ", "; - os << ".numMipLevel = "; os << (params.numMipLevel); os << ", "; - os << ".numSamples = "; os << (params.numSamples); @@ -6104,13 +6073,11 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".pHost = "; ur_params::serializePtr(os, (params.pHost)); @@ -6128,13 +6095,11 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".channel = "; os << (params.channel); @@ -6152,13 +6117,11 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".location = "; os << (params.location); @@ -6175,19 +6138,16 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".origin = "; os << (params.origin); os << ", "; - os << ".size = "; os << (params.size); @@ -6217,13 +6177,11 @@ operator<<(std::ostream &os, const struct ur_mem_native_properties_t params) { os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".isNativeHandleOwned = "; os << (params.isNativeHandleOwned); @@ -6404,25 +6362,21 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".normalizedCoords = "; os << (params.normalizedCoords); os << ", "; - os << ".addressingMode = "; os << (params.addressingMode); os << ", "; - os << ".filterMode = "; os << (params.filterMode); @@ -6440,13 +6394,11 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".isNativeHandleOwned = "; os << (params.isNativeHandleOwned); @@ -7009,19 +6961,16 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".hints = "; ur_params::serializeFlag(os, (params.hints)); os << ", "; - os << ".align = "; os << (params.align); @@ -7038,13 +6987,11 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".flags = "; ur_params::serializeFlag(os, (params.flags)); @@ -7061,13 +7008,11 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".flags = "; ur_params::serializeFlag(os, (params.flags)); @@ -7084,13 +7029,11 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".flags = "; ur_params::serializeFlag(os, (params.flags)); @@ -7107,19 +7050,16 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".maxPoolableSize = "; os << (params.maxPoolableSize); os << ", "; - os << ".minDriverAllocSize = "; os << (params.minDriverAllocSize); @@ -7418,13 +7358,11 @@ operator<<(std::ostream &os, const struct ur_physical_mem_properties_t params) { os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".flags = "; ur_params::serializeFlag(os, (params.flags)); @@ -7508,19 +7446,16 @@ inline std::ostream &operator<<(std::ostream &os, ur_params::serializePtr(os, (params.pName)); os << ", "; - os << ".type = "; os << (params.type); os << ", "; - os << ".size = "; os << (params.size); os << ", "; - os << ".value = "; ur_params::serializeUnion(os, (params.value), params.type); @@ -7536,19 +7471,16 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".count = "; os << (params.count); os << ", "; - os << ".pMetadatas = {"; for (size_t i = 0; (params.pMetadatas) != NULL && i < params.count; ++i) { if (i != 0) { @@ -7870,13 +7802,11 @@ operator<<(std::ostream &os, os << (params.id); os << ", "; - os << ".size = "; os << (params.size); os << ", "; - os << ".pValue = "; ur_params::serializePtr(os, (params.pValue)); @@ -7894,13 +7824,11 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".isNativeHandleOwned = "; os << (params.isNativeHandleOwned); @@ -7918,7 +7846,6 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); @@ -7936,7 +7863,6 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); @@ -8422,7 +8348,6 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); @@ -8440,7 +8365,6 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); @@ -8458,7 +8382,6 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); @@ -8476,13 +8399,11 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".memoryAccess = "; ur_params::serializeFlag(os, (params.memoryAccess)); @@ -8500,13 +8421,11 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".isNativeHandleOwned = "; os << (params.isNativeHandleOwned); @@ -8862,13 +8781,11 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".flags = "; ur_params::serializeFlag(os, (params.flags)); @@ -8885,13 +8802,11 @@ operator<<(std::ostream &os, const struct ur_queue_index_properties_t params) { os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".computeIndex = "; os << (params.computeIndex); @@ -8908,13 +8823,11 @@ inline std::ostream &operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".pNativeData = "; ur_params::serializePtr(os, (params.pNativeData)); @@ -8931,13 +8844,11 @@ operator<<(std::ostream &os, const struct ur_queue_native_properties_t params) { os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".isNativeHandleOwned = "; os << (params.isNativeHandleOwned); @@ -9328,13 +9239,11 @@ operator<<(std::ostream &os, const struct ur_event_native_properties_t params) { os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".isNativeHandleOwned = "; os << (params.isNativeHandleOwned); @@ -9559,31 +9468,26 @@ operator<<(std::ostream &os, os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".minMipmapLevelClamp = "; os << (params.minMipmapLevelClamp); os << ", "; - os << ".maxMipmapLevelClamp = "; os << (params.maxMipmapLevelClamp); os << ", "; - os << ".maxAnisotropy = "; os << (params.maxAnisotropy); os << ", "; - os << ".mipFilterMode = "; os << (params.mipFilterMode); @@ -9600,7 +9504,6 @@ operator<<(std::ostream &os, const struct ur_exp_command_buffer_desc_t params) { os << (params.stype); os << ", "; - os << ".pNext = "; ur_params::serializeStruct(os, (params.pNext)); @@ -9701,13 +9604,11 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".hImage = "; ur_params::serializePtr(os, *(params->phImage)); @@ -9725,13 +9626,11 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".hImage = "; ur_params::serializePtr(os, *(params->phImage)); @@ -9748,25 +9647,21 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".pImageFormat = "; ur_params::serializePtr(os, *(params->ppImageFormat)); os << ", "; - os << ".pImageDesc = "; ur_params::serializePtr(os, *(params->ppImageDesc)); os << ", "; - os << ".phImageMem = "; ur_params::serializePtr(os, *(params->pphImageMem)); @@ -9783,13 +9678,11 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".hImageMem = "; ur_params::serializePtr(os, *(params->phImageMem)); @@ -9807,37 +9700,31 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".hImageMem = "; ur_params::serializePtr(os, *(params->phImageMem)); os << ", "; - os << ".pImageFormat = "; ur_params::serializePtr(os, *(params->ppImageFormat)); os << ", "; - os << ".pImageDesc = "; ur_params::serializePtr(os, *(params->ppImageDesc)); os << ", "; - os << ".phMem = "; ur_params::serializePtr(os, *(params->pphMem)); os << ", "; - os << ".phImage = "; ur_params::serializePtr(os, *(params->pphImage)); @@ -9854,43 +9741,36 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".hImageMem = "; ur_params::serializePtr(os, *(params->phImageMem)); os << ", "; - os << ".pImageFormat = "; ur_params::serializePtr(os, *(params->ppImageFormat)); os << ", "; - os << ".pImageDesc = "; ur_params::serializePtr(os, *(params->ppImageDesc)); os << ", "; - os << ".hSampler = "; ur_params::serializePtr(os, *(params->phSampler)); os << ", "; - os << ".phMem = "; ur_params::serializePtr(os, *(params->pphMem)); os << ", "; - os << ".phImage = "; ur_params::serializePtr(os, *(params->pphImage)); @@ -9907,68 +9787,57 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".pDst = "; ur_params::serializePtr(os, *(params->ppDst)); os << ", "; - os << ".pSrc = "; ur_params::serializePtr(os, *(params->ppSrc)); os << ", "; - os << ".pImageFormat = "; ur_params::serializePtr(os, *(params->ppImageFormat)); os << ", "; - os << ".pImageDesc = "; ur_params::serializePtr(os, *(params->ppImageDesc)); os << ", "; - os << ".imageCopyFlags = "; ur_params::serializeFlag( os, *(params->pimageCopyFlags)); os << ", "; - os << ".srcOffset = "; os << *(params->psrcOffset); os << ", "; - os << ".dstOffset = "; os << *(params->pdstOffset); os << ", "; - os << ".copyExtent = "; os << *(params->pcopyExtent); os << ", "; - os << ".hostExtent = "; os << *(params->phostExtent); os << ", "; - os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; - os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -9982,7 +9851,6 @@ operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -9999,19 +9867,16 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phImageMem)); os << ", "; - os << ".propName = "; os << *(params->ppropName); os << ", "; - os << ".pPropValue = "; ur_params::serializePtr(os, *(params->ppPropValue)); os << ", "; - os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -10028,25 +9893,21 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".hImageMem = "; ur_params::serializePtr(os, *(params->phImageMem)); os << ", "; - os << ".mipmapLevel = "; os << *(params->pmipmapLevel); os << ", "; - os << ".phImageMem = "; ur_params::serializePtr(os, *(params->pphImageMem)); @@ -10063,13 +9924,11 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".hMem = "; ur_params::serializePtr(os, *(params->phMem)); @@ -10086,25 +9945,21 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".size = "; os << *(params->psize); os << ", "; - os << ".fileDescriptor = "; os << *(params->pfileDescriptor); os << ", "; - os << ".phInteropMem = "; ur_params::serializePtr(os, *(params->pphInteropMem)); @@ -10121,31 +9976,26 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".pImageFormat = "; ur_params::serializePtr(os, *(params->ppImageFormat)); os << ", "; - os << ".pImageDesc = "; ur_params::serializePtr(os, *(params->ppImageDesc)); os << ", "; - os << ".hInteropMem = "; ur_params::serializePtr(os, *(params->phInteropMem)); os << ", "; - os << ".phImageMem = "; ur_params::serializePtr(os, *(params->pphImageMem)); @@ -10162,13 +10012,11 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".hInteropMem = "; ur_params::serializePtr(os, *(params->phInteropMem)); @@ -10186,19 +10034,16 @@ operator<<(std::ostream &os, const struct ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".fileDescriptor = "; os << *(params->pfileDescriptor); os << ", "; - os << ".phInteropSemaphoreHandle = "; ur_params::serializePtr(os, *(params->pphInteropSemaphoreHandle)); @@ -10216,13 +10061,11 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".hInteropSemaphore = "; ur_params::serializePtr(os, *(params->phInteropSemaphore)); @@ -10240,19 +10083,16 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".hSemaphore = "; ur_params::serializePtr(os, *(params->phSemaphore)); os << ", "; - os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; - os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -10266,7 +10106,6 @@ operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -10284,19 +10123,16 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".hSemaphore = "; ur_params::serializePtr(os, *(params->phSemaphore)); os << ", "; - os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; - os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -10310,7 +10146,6 @@ inline std::ostream &operator<<( os << "}"; os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -10327,19 +10162,16 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".pCommandBufferDesc = "; ur_params::serializePtr(os, *(params->ppCommandBufferDesc)); os << ", "; - os << ".phCommandBuffer = "; ur_params::serializePtr(os, *(params->pphCommandBuffer)); @@ -10389,49 +10221,41 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phCommandBuffer)); os << ", "; - os << ".hKernel = "; ur_params::serializePtr(os, *(params->phKernel)); os << ", "; - os << ".workDim = "; os << *(params->pworkDim); os << ", "; - os << ".pGlobalWorkOffset = "; ur_params::serializePtr(os, *(params->ppGlobalWorkOffset)); os << ", "; - os << ".pGlobalWorkSize = "; ur_params::serializePtr(os, *(params->ppGlobalWorkSize)); os << ", "; - os << ".pLocalWorkSize = "; ur_params::serializePtr(os, *(params->ppLocalWorkSize)); os << ", "; - os << ".numSyncPointsInWaitList = "; os << *(params->pnumSyncPointsInWaitList); os << ", "; - os << ".pSyncPointWaitList = "; ur_params::serializePtr(os, *(params->ppSyncPointWaitList)); os << ", "; - os << ".pSyncPoint = "; ur_params::serializePtr(os, *(params->ppSyncPoint)); @@ -10448,37 +10272,31 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phCommandBuffer)); os << ", "; - os << ".pDst = "; ur_params::serializePtr(os, *(params->ppDst)); os << ", "; - os << ".pSrc = "; ur_params::serializePtr(os, *(params->ppSrc)); os << ", "; - os << ".size = "; os << *(params->psize); os << ", "; - os << ".numSyncPointsInWaitList = "; os << *(params->pnumSyncPointsInWaitList); os << ", "; - os << ".pSyncPointWaitList = "; ur_params::serializePtr(os, *(params->ppSyncPointWaitList)); os << ", "; - os << ".pSyncPoint = "; ur_params::serializePtr(os, *(params->ppSyncPoint)); @@ -10495,49 +10313,41 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phCommandBuffer)); os << ", "; - os << ".hSrcMem = "; ur_params::serializePtr(os, *(params->phSrcMem)); os << ", "; - os << ".hDstMem = "; ur_params::serializePtr(os, *(params->phDstMem)); os << ", "; - os << ".srcOffset = "; os << *(params->psrcOffset); os << ", "; - os << ".dstOffset = "; os << *(params->pdstOffset); os << ", "; - os << ".size = "; os << *(params->psize); os << ", "; - os << ".numSyncPointsInWaitList = "; os << *(params->pnumSyncPointsInWaitList); os << ", "; - os << ".pSyncPointWaitList = "; ur_params::serializePtr(os, *(params->ppSyncPointWaitList)); os << ", "; - os << ".pSyncPoint = "; ur_params::serializePtr(os, *(params->ppSyncPoint)); @@ -10555,43 +10365,36 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phCommandBuffer)); os << ", "; - os << ".hBuffer = "; ur_params::serializePtr(os, *(params->phBuffer)); os << ", "; - os << ".offset = "; os << *(params->poffset); os << ", "; - os << ".size = "; os << *(params->psize); os << ", "; - os << ".pSrc = "; ur_params::serializePtr(os, *(params->ppSrc)); os << ", "; - os << ".numSyncPointsInWaitList = "; os << *(params->pnumSyncPointsInWaitList); os << ", "; - os << ".pSyncPointWaitList = "; ur_params::serializePtr(os, *(params->ppSyncPointWaitList)); os << ", "; - os << ".pSyncPoint = "; ur_params::serializePtr(os, *(params->ppSyncPoint)); @@ -10608,43 +10411,36 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phCommandBuffer)); os << ", "; - os << ".hBuffer = "; ur_params::serializePtr(os, *(params->phBuffer)); os << ", "; - os << ".offset = "; os << *(params->poffset); os << ", "; - os << ".size = "; os << *(params->psize); os << ", "; - os << ".pDst = "; ur_params::serializePtr(os, *(params->ppDst)); os << ", "; - os << ".numSyncPointsInWaitList = "; os << *(params->pnumSyncPointsInWaitList); os << ", "; - os << ".pSyncPointWaitList = "; ur_params::serializePtr(os, *(params->ppSyncPointWaitList)); os << ", "; - os << ".pSyncPoint = "; ur_params::serializePtr(os, *(params->ppSyncPoint)); @@ -10662,73 +10458,61 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phCommandBuffer)); os << ", "; - os << ".hSrcMem = "; ur_params::serializePtr(os, *(params->phSrcMem)); os << ", "; - os << ".hDstMem = "; ur_params::serializePtr(os, *(params->phDstMem)); os << ", "; - os << ".srcOrigin = "; os << *(params->psrcOrigin); os << ", "; - os << ".dstOrigin = "; os << *(params->pdstOrigin); os << ", "; - os << ".region = "; os << *(params->pregion); os << ", "; - os << ".srcRowPitch = "; os << *(params->psrcRowPitch); os << ", "; - os << ".srcSlicePitch = "; os << *(params->psrcSlicePitch); os << ", "; - os << ".dstRowPitch = "; os << *(params->pdstRowPitch); os << ", "; - os << ".dstSlicePitch = "; os << *(params->pdstSlicePitch); os << ", "; - os << ".numSyncPointsInWaitList = "; os << *(params->pnumSyncPointsInWaitList); os << ", "; - os << ".pSyncPointWaitList = "; ur_params::serializePtr(os, *(params->ppSyncPointWaitList)); os << ", "; - os << ".pSyncPoint = "; ur_params::serializePtr(os, *(params->ppSyncPoint)); @@ -10746,73 +10530,61 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phCommandBuffer)); os << ", "; - os << ".hBuffer = "; ur_params::serializePtr(os, *(params->phBuffer)); os << ", "; - os << ".bufferOffset = "; os << *(params->pbufferOffset); os << ", "; - os << ".hostOffset = "; os << *(params->phostOffset); os << ", "; - os << ".region = "; os << *(params->pregion); os << ", "; - os << ".bufferRowPitch = "; os << *(params->pbufferRowPitch); os << ", "; - os << ".bufferSlicePitch = "; os << *(params->pbufferSlicePitch); os << ", "; - os << ".hostRowPitch = "; os << *(params->phostRowPitch); os << ", "; - os << ".hostSlicePitch = "; os << *(params->phostSlicePitch); os << ", "; - os << ".pSrc = "; ur_params::serializePtr(os, *(params->ppSrc)); os << ", "; - os << ".numSyncPointsInWaitList = "; os << *(params->pnumSyncPointsInWaitList); os << ", "; - os << ".pSyncPointWaitList = "; ur_params::serializePtr(os, *(params->ppSyncPointWaitList)); os << ", "; - os << ".pSyncPoint = "; ur_params::serializePtr(os, *(params->ppSyncPoint)); @@ -10830,73 +10602,61 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phCommandBuffer)); os << ", "; - os << ".hBuffer = "; ur_params::serializePtr(os, *(params->phBuffer)); os << ", "; - os << ".bufferOffset = "; os << *(params->pbufferOffset); os << ", "; - os << ".hostOffset = "; os << *(params->phostOffset); os << ", "; - os << ".region = "; os << *(params->pregion); os << ", "; - os << ".bufferRowPitch = "; os << *(params->pbufferRowPitch); os << ", "; - os << ".bufferSlicePitch = "; os << *(params->pbufferSlicePitch); os << ", "; - os << ".hostRowPitch = "; os << *(params->phostRowPitch); os << ", "; - os << ".hostSlicePitch = "; os << *(params->phostSlicePitch); os << ", "; - os << ".pDst = "; ur_params::serializePtr(os, *(params->ppDst)); os << ", "; - os << ".numSyncPointsInWaitList = "; os << *(params->pnumSyncPointsInWaitList); os << ", "; - os << ".pSyncPointWaitList = "; ur_params::serializePtr(os, *(params->ppSyncPointWaitList)); os << ", "; - os << ".pSyncPoint = "; ur_params::serializePtr(os, *(params->ppSyncPoint)); @@ -10913,19 +10673,16 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phCommandBuffer)); os << ", "; - os << ".hQueue = "; ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; - os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -10939,7 +10696,6 @@ operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -10955,7 +10711,6 @@ operator<<(std::ostream &os, const struct ur_context_create_params_t *params) { os << *(params->pDeviceCount); os << ", "; - os << ".phDevices = {"; for (size_t i = 0; *(params->pphDevices) != NULL && i < *params->pDeviceCount; ++i) { @@ -10968,13 +10723,11 @@ operator<<(std::ostream &os, const struct ur_context_create_params_t *params) { os << "}"; os << ", "; - os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; - os << ".phContext = "; ur_params::serializePtr(os, *(params->pphContext)); @@ -11011,25 +10764,21 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".propName = "; os << *(params->ppropName); os << ", "; - os << ".propSize = "; os << *(params->ppropSize); os << ", "; - os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; - os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -11046,7 +10795,6 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".phNativeContext = "; ur_params::serializePtr(os, *(params->pphNativeContext)); @@ -11063,13 +10811,11 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phNativeContext)); os << ", "; - os << ".numDevices = "; os << *(params->pnumDevices); os << ", "; - os << ".phDevices = {"; for (size_t i = 0; *(params->pphDevices) != NULL && i < *params->pnumDevices; ++i) { @@ -11082,13 +10828,11 @@ operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; - os << ".phContext = "; ur_params::serializePtr(os, *(params->pphContext)); @@ -11105,13 +10849,11 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".pfnDeleter = "; os << *(params->ppfnDeleter); os << ", "; - os << ".pUserData = "; ur_params::serializePtr(os, *(params->ppUserData)); @@ -11128,43 +10870,36 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".hKernel = "; ur_params::serializePtr(os, *(params->phKernel)); os << ", "; - os << ".workDim = "; os << *(params->pworkDim); os << ", "; - os << ".pGlobalWorkOffset = "; ur_params::serializePtr(os, *(params->ppGlobalWorkOffset)); os << ", "; - os << ".pGlobalWorkSize = "; ur_params::serializePtr(os, *(params->ppGlobalWorkSize)); os << ", "; - os << ".pLocalWorkSize = "; ur_params::serializePtr(os, *(params->ppLocalWorkSize)); os << ", "; - os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; - os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -11178,7 +10913,6 @@ operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -11195,13 +10929,11 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; - os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -11215,7 +10947,6 @@ operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -11232,13 +10963,11 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; - os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -11252,7 +10981,6 @@ operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -11269,43 +10997,36 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".hBuffer = "; ur_params::serializePtr(os, *(params->phBuffer)); os << ", "; - os << ".blockingRead = "; os << *(params->pblockingRead); os << ", "; - os << ".offset = "; os << *(params->poffset); os << ", "; - os << ".size = "; os << *(params->psize); os << ", "; - os << ".pDst = "; ur_params::serializePtr(os, *(params->ppDst)); os << ", "; - os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; - os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -11319,7 +11040,6 @@ operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -11336,43 +11056,36 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".hBuffer = "; ur_params::serializePtr(os, *(params->phBuffer)); os << ", "; - os << ".blockingWrite = "; os << *(params->pblockingWrite); os << ", "; - os << ".offset = "; os << *(params->poffset); os << ", "; - os << ".size = "; os << *(params->psize); os << ", "; - os << ".pSrc = "; ur_params::serializePtr(os, *(params->ppSrc)); os << ", "; - os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; - os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -11386,7 +11099,6 @@ operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -11403,73 +11115,61 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".hBuffer = "; ur_params::serializePtr(os, *(params->phBuffer)); os << ", "; - os << ".blockingRead = "; os << *(params->pblockingRead); os << ", "; - os << ".bufferOrigin = "; os << *(params->pbufferOrigin); os << ", "; - os << ".hostOrigin = "; os << *(params->phostOrigin); os << ", "; - os << ".region = "; os << *(params->pregion); os << ", "; - os << ".bufferRowPitch = "; os << *(params->pbufferRowPitch); os << ", "; - os << ".bufferSlicePitch = "; os << *(params->pbufferSlicePitch); os << ", "; - os << ".hostRowPitch = "; os << *(params->phostRowPitch); os << ", "; - os << ".hostSlicePitch = "; os << *(params->phostSlicePitch); os << ", "; - os << ".pDst = "; ur_params::serializePtr(os, *(params->ppDst)); os << ", "; - os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; - os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -11483,7 +11183,6 @@ operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -11500,73 +11199,61 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".hBuffer = "; ur_params::serializePtr(os, *(params->phBuffer)); os << ", "; - os << ".blockingWrite = "; os << *(params->pblockingWrite); os << ", "; - os << ".bufferOrigin = "; os << *(params->pbufferOrigin); os << ", "; - os << ".hostOrigin = "; os << *(params->phostOrigin); os << ", "; - os << ".region = "; os << *(params->pregion); os << ", "; - os << ".bufferRowPitch = "; os << *(params->pbufferRowPitch); os << ", "; - os << ".bufferSlicePitch = "; os << *(params->pbufferSlicePitch); os << ", "; - os << ".hostRowPitch = "; os << *(params->phostRowPitch); os << ", "; - os << ".hostSlicePitch = "; os << *(params->phostSlicePitch); os << ", "; - os << ".pSrc = "; ur_params::serializePtr(os, *(params->ppSrc)); os << ", "; - os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; - os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -11580,7 +11267,6 @@ operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -11597,43 +11283,36 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".hBufferSrc = "; ur_params::serializePtr(os, *(params->phBufferSrc)); os << ", "; - os << ".hBufferDst = "; ur_params::serializePtr(os, *(params->phBufferDst)); os << ", "; - os << ".srcOffset = "; os << *(params->psrcOffset); os << ", "; - os << ".dstOffset = "; os << *(params->pdstOffset); os << ", "; - os << ".size = "; os << *(params->psize); os << ", "; - os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; - os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -11647,7 +11326,6 @@ operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -11664,67 +11342,56 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".hBufferSrc = "; ur_params::serializePtr(os, *(params->phBufferSrc)); os << ", "; - os << ".hBufferDst = "; ur_params::serializePtr(os, *(params->phBufferDst)); os << ", "; - os << ".srcOrigin = "; os << *(params->psrcOrigin); os << ", "; - os << ".dstOrigin = "; os << *(params->pdstOrigin); os << ", "; - os << ".region = "; os << *(params->pregion); os << ", "; - os << ".srcRowPitch = "; os << *(params->psrcRowPitch); os << ", "; - os << ".srcSlicePitch = "; os << *(params->psrcSlicePitch); os << ", "; - os << ".dstRowPitch = "; os << *(params->pdstRowPitch); os << ", "; - os << ".dstSlicePitch = "; os << *(params->pdstSlicePitch); os << ", "; - os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; - os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -11738,7 +11405,6 @@ operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -11755,43 +11421,36 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".hBuffer = "; ur_params::serializePtr(os, *(params->phBuffer)); os << ", "; - os << ".pPattern = "; ur_params::serializePtr(os, *(params->ppPattern)); os << ", "; - os << ".patternSize = "; os << *(params->ppatternSize); os << ", "; - os << ".offset = "; os << *(params->poffset); os << ", "; - os << ".size = "; os << *(params->psize); os << ", "; - os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; - os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -11805,7 +11464,6 @@ operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -11822,55 +11480,46 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".hImage = "; ur_params::serializePtr(os, *(params->phImage)); os << ", "; - os << ".blockingRead = "; os << *(params->pblockingRead); os << ", "; - os << ".origin = "; os << *(params->porigin); os << ", "; - os << ".region = "; os << *(params->pregion); os << ", "; - os << ".rowPitch = "; os << *(params->prowPitch); os << ", "; - os << ".slicePitch = "; os << *(params->pslicePitch); os << ", "; - os << ".pDst = "; ur_params::serializePtr(os, *(params->ppDst)); os << ", "; - os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; - os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -11884,7 +11533,6 @@ operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -11901,55 +11549,46 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".hImage = "; ur_params::serializePtr(os, *(params->phImage)); os << ", "; - os << ".blockingWrite = "; os << *(params->pblockingWrite); os << ", "; - os << ".origin = "; os << *(params->porigin); os << ", "; - os << ".region = "; os << *(params->pregion); os << ", "; - os << ".rowPitch = "; os << *(params->prowPitch); os << ", "; - os << ".slicePitch = "; os << *(params->pslicePitch); os << ", "; - os << ".pSrc = "; ur_params::serializePtr(os, *(params->ppSrc)); os << ", "; - os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; - os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -11963,7 +11602,6 @@ operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -11980,43 +11618,36 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".hImageSrc = "; ur_params::serializePtr(os, *(params->phImageSrc)); os << ", "; - os << ".hImageDst = "; ur_params::serializePtr(os, *(params->phImageDst)); os << ", "; - os << ".srcOrigin = "; os << *(params->psrcOrigin); os << ", "; - os << ".dstOrigin = "; os << *(params->pdstOrigin); os << ", "; - os << ".region = "; os << *(params->pregion); os << ", "; - os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; - os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -12030,7 +11661,6 @@ operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -12047,43 +11677,36 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".hBuffer = "; ur_params::serializePtr(os, *(params->phBuffer)); os << ", "; - os << ".blockingMap = "; os << *(params->pblockingMap); os << ", "; - os << ".mapFlags = "; ur_params::serializeFlag(os, *(params->pmapFlags)); os << ", "; - os << ".offset = "; os << *(params->poffset); os << ", "; - os << ".size = "; os << *(params->psize); os << ", "; - os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; - os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -12097,13 +11720,11 @@ operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); os << ", "; - os << ".ppRetMap = "; ur_params::serializePtr(os, *(params->pppRetMap)); @@ -12120,25 +11741,21 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".hMem = "; ur_params::serializePtr(os, *(params->phMem)); os << ", "; - os << ".pMappedPtr = "; ur_params::serializePtr(os, *(params->ppMappedPtr)); os << ", "; - os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; - os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -12152,7 +11769,6 @@ operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -12169,37 +11785,31 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".ptr = "; ur_params::serializePtr(os, *(params->pptr)); os << ", "; - os << ".patternSize = "; os << *(params->ppatternSize); os << ", "; - os << ".pPattern = "; ur_params::serializePtr(os, *(params->ppPattern)); os << ", "; - os << ".size = "; os << *(params->psize); os << ", "; - os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; - os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -12213,7 +11823,6 @@ operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -12230,37 +11839,31 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".blocking = "; os << *(params->pblocking); os << ", "; - os << ".pDst = "; ur_params::serializePtr(os, *(params->ppDst)); os << ", "; - os << ".pSrc = "; ur_params::serializePtr(os, *(params->ppSrc)); os << ", "; - os << ".size = "; os << *(params->psize); os << ", "; - os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; - os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -12274,7 +11877,6 @@ operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -12291,31 +11893,26 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".pMem = "; ur_params::serializePtr(os, *(params->ppMem)); os << ", "; - os << ".size = "; os << *(params->psize); os << ", "; - os << ".flags = "; ur_params::serializeFlag(os, *(params->pflags)); os << ", "; - os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; - os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -12329,7 +11926,6 @@ operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -12346,25 +11942,21 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".pMem = "; ur_params::serializePtr(os, *(params->ppMem)); os << ", "; - os << ".size = "; os << *(params->psize); os << ", "; - os << ".advice = "; ur_params::serializeFlag(os, *(params->padvice)); os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -12381,49 +11973,41 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".pMem = "; ur_params::serializePtr(os, *(params->ppMem)); os << ", "; - os << ".pitch = "; os << *(params->ppitch); os << ", "; - os << ".patternSize = "; os << *(params->ppatternSize); os << ", "; - os << ".pPattern = "; ur_params::serializePtr(os, *(params->ppPattern)); os << ", "; - os << ".width = "; os << *(params->pwidth); os << ", "; - os << ".height = "; os << *(params->pheight); os << ", "; - os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; - os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -12437,7 +12021,6 @@ operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -12454,55 +12037,46 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".blocking = "; os << *(params->pblocking); os << ", "; - os << ".pDst = "; ur_params::serializePtr(os, *(params->ppDst)); os << ", "; - os << ".dstPitch = "; os << *(params->pdstPitch); os << ", "; - os << ".pSrc = "; ur_params::serializePtr(os, *(params->ppSrc)); os << ", "; - os << ".srcPitch = "; os << *(params->psrcPitch); os << ", "; - os << ".width = "; os << *(params->pwidth); os << ", "; - os << ".height = "; os << *(params->pheight); os << ", "; - os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; - os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -12516,7 +12090,6 @@ operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -12533,49 +12106,41 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".hProgram = "; ur_params::serializePtr(os, *(params->phProgram)); os << ", "; - os << ".name = "; ur_params::serializePtr(os, *(params->pname)); os << ", "; - os << ".blockingWrite = "; os << *(params->pblockingWrite); os << ", "; - os << ".count = "; os << *(params->pcount); os << ", "; - os << ".offset = "; os << *(params->poffset); os << ", "; - os << ".pSrc = "; ur_params::serializePtr(os, *(params->ppSrc)); os << ", "; - os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; - os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -12589,7 +12154,6 @@ inline std::ostream &operator<<( os << "}"; os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -12606,49 +12170,41 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".hProgram = "; ur_params::serializePtr(os, *(params->phProgram)); os << ", "; - os << ".name = "; ur_params::serializePtr(os, *(params->pname)); os << ", "; - os << ".blockingRead = "; os << *(params->pblockingRead); os << ", "; - os << ".count = "; os << *(params->pcount); os << ", "; - os << ".offset = "; os << *(params->poffset); os << ", "; - os << ".pDst = "; ur_params::serializePtr(os, *(params->ppDst)); os << ", "; - os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; - os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -12662,7 +12218,6 @@ inline std::ostream &operator<<( os << "}"; os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -12679,43 +12234,36 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".hProgram = "; ur_params::serializePtr(os, *(params->phProgram)); os << ", "; - os << ".pipe_symbol = "; ur_params::serializePtr(os, *(params->ppipe_symbol)); os << ", "; - os << ".blocking = "; os << *(params->pblocking); os << ", "; - os << ".pDst = "; ur_params::serializePtr(os, *(params->ppDst)); os << ", "; - os << ".size = "; os << *(params->psize); os << ", "; - os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; - os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -12729,7 +12277,6 @@ operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -12746,43 +12293,36 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".hProgram = "; ur_params::serializePtr(os, *(params->phProgram)); os << ", "; - os << ".pipe_symbol = "; ur_params::serializePtr(os, *(params->ppipe_symbol)); os << ", "; - os << ".blocking = "; os << *(params->pblocking); os << ", "; - os << ".pSrc = "; ur_params::serializePtr(os, *(params->ppSrc)); os << ", "; - os << ".size = "; os << *(params->psize); os << ", "; - os << ".numEventsInWaitList = "; os << *(params->pnumEventsInWaitList); os << ", "; - os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEventsInWaitList; @@ -12796,7 +12336,6 @@ operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -12812,25 +12351,21 @@ operator<<(std::ostream &os, const struct ur_event_get_info_params_t *params) { ur_params::serializePtr(os, *(params->phEvent)); os << ", "; - os << ".propName = "; os << *(params->ppropName); os << ", "; - os << ".propSize = "; os << *(params->ppropSize); os << ", "; - os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; - os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -12847,25 +12382,21 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phEvent)); os << ", "; - os << ".propName = "; os << *(params->ppropName); os << ", "; - os << ".propSize = "; os << *(params->ppropSize); os << ", "; - os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; - os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -12881,7 +12412,6 @@ inline std::ostream &operator<<(std::ostream &os, os << *(params->pnumEvents); os << ", "; - os << ".phEventWaitList = {"; for (size_t i = 0; *(params->pphEventWaitList) != NULL && i < *params->pnumEvents; ++i) { @@ -12925,7 +12455,6 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phEvent)); os << ", "; - os << ".phNativeEvent = "; ur_params::serializePtr(os, *(params->pphNativeEvent)); @@ -12942,19 +12471,16 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phNativeEvent)); os << ", "; - os << ".hContext = "; ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; - os << ".phEvent = "; ur_params::serializePtr(os, *(params->pphEvent)); @@ -12971,19 +12497,16 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phEvent)); os << ", "; - os << ".execStatus = "; os << *(params->pexecStatus); os << ", "; - os << ".pfnNotify = "; os << *(params->ppfnNotify); os << ", "; - os << ".pUserData = "; ur_params::serializePtr(os, *(params->ppUserData)); @@ -12999,13 +12522,11 @@ operator<<(std::ostream &os, const struct ur_kernel_create_params_t *params) { ur_params::serializePtr(os, *(params->phProgram)); os << ", "; - os << ".pKernelName = "; ur_params::serializePtr(os, *(params->ppKernelName)); os << ", "; - os << ".phKernel = "; ur_params::serializePtr(os, *(params->pphKernel)); @@ -13021,25 +12542,21 @@ operator<<(std::ostream &os, const struct ur_kernel_get_info_params_t *params) { ur_params::serializePtr(os, *(params->phKernel)); os << ", "; - os << ".propName = "; os << *(params->ppropName); os << ", "; - os << ".propSize = "; os << *(params->ppropSize); os << ", "; - os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; - os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -13056,31 +12573,26 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phKernel)); os << ", "; - os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".propName = "; os << *(params->ppropName); os << ", "; - os << ".propSize = "; os << *(params->ppropSize); os << ", "; - os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; - os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -13097,31 +12609,26 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phKernel)); os << ", "; - os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".propName = "; os << *(params->ppropName); os << ", "; - os << ".propSize = "; os << *(params->ppropSize); os << ", "; - os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; - os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -13158,7 +12665,6 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phKernel)); os << ", "; - os << ".phNativeKernel = "; ur_params::serializePtr(os, *(params->pphNativeKernel)); @@ -13175,25 +12681,21 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phNativeKernel)); os << ", "; - os << ".hContext = "; ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".hProgram = "; ur_params::serializePtr(os, *(params->phProgram)); os << ", "; - os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; - os << ".phKernel = "; ur_params::serializePtr(os, *(params->pphKernel)); @@ -13210,25 +12712,21 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phKernel)); os << ", "; - os << ".argIndex = "; os << *(params->pargIndex); os << ", "; - os << ".argSize = "; os << *(params->pargSize); os << ", "; - os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; - os << ".pArgValue = "; ur_params::serializePtr(os, *(params->ppArgValue)); @@ -13245,19 +12743,16 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phKernel)); os << ", "; - os << ".argIndex = "; os << *(params->pargIndex); os << ", "; - os << ".argSize = "; os << *(params->pargSize); os << ", "; - os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); @@ -13274,19 +12769,16 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phKernel)); os << ", "; - os << ".argIndex = "; os << *(params->pargIndex); os << ", "; - os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; - os << ".pArgValue = "; ur_params::serializePtr(os, *(params->ppArgValue)); @@ -13303,25 +12795,21 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phKernel)); os << ", "; - os << ".propName = "; os << *(params->ppropName); os << ", "; - os << ".propSize = "; os << *(params->ppropSize); os << ", "; - os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; - os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); @@ -13338,19 +12826,16 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phKernel)); os << ", "; - os << ".argIndex = "; os << *(params->pargIndex); os << ", "; - os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; - os << ".hArgValue = "; ur_params::serializePtr(os, *(params->phArgValue)); @@ -13367,19 +12852,16 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phKernel)); os << ", "; - os << ".argIndex = "; os << *(params->pargIndex); os << ", "; - os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; - os << ".hArgValue = "; ur_params::serializePtr(os, *(params->phArgValue)); @@ -13396,13 +12878,11 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phKernel)); os << ", "; - os << ".count = "; os << *(params->pcount); os << ", "; - os << ".pSpecConstants = "; ur_params::serializePtr(os, *(params->ppSpecConstants)); @@ -13419,31 +12899,26 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".flags = "; ur_params::serializeFlag(os, *(params->pflags)); os << ", "; - os << ".pImageFormat = "; ur_params::serializePtr(os, *(params->ppImageFormat)); os << ", "; - os << ".pImageDesc = "; ur_params::serializePtr(os, *(params->ppImageDesc)); os << ", "; - os << ".pHost = "; ur_params::serializePtr(os, *(params->ppHost)); os << ", "; - os << ".phMem = "; ur_params::serializePtr(os, *(params->pphMem)); @@ -13460,25 +12935,21 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".flags = "; ur_params::serializeFlag(os, *(params->pflags)); os << ", "; - os << ".size = "; os << *(params->psize); os << ", "; - os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; - os << ".phBuffer = "; ur_params::serializePtr(os, *(params->pphBuffer)); @@ -13515,25 +12986,21 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phBuffer)); os << ", "; - os << ".flags = "; ur_params::serializeFlag(os, *(params->pflags)); os << ", "; - os << ".bufferCreateType = "; os << *(params->pbufferCreateType); os << ", "; - os << ".pRegion = "; ur_params::serializePtr(os, *(params->ppRegion)); os << ", "; - os << ".phMem = "; ur_params::serializePtr(os, *(params->pphMem)); @@ -13550,7 +13017,6 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phMem)); os << ", "; - os << ".phNativeMem = "; ur_params::serializePtr(os, *(params->pphNativeMem)); @@ -13567,19 +13033,16 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phNativeMem)); os << ", "; - os << ".hContext = "; ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; - os << ".phMem = "; ur_params::serializePtr(os, *(params->pphMem)); @@ -13596,31 +13059,26 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phNativeMem)); os << ", "; - os << ".hContext = "; ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".pImageFormat = "; ur_params::serializePtr(os, *(params->ppImageFormat)); os << ", "; - os << ".pImageDesc = "; ur_params::serializePtr(os, *(params->ppImageDesc)); os << ", "; - os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; - os << ".phMem = "; ur_params::serializePtr(os, *(params->pphMem)); @@ -13636,25 +13094,21 @@ inline std::ostream &operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phMemory)); os << ", "; - os << ".propName = "; os << *(params->ppropName); os << ", "; - os << ".propSize = "; os << *(params->ppropSize); os << ", "; - os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; - os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -13671,25 +13125,21 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phMemory)); os << ", "; - os << ".propName = "; os << *(params->ppropName); os << ", "; - os << ".propSize = "; os << *(params->ppropSize); os << ", "; - os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; - os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -13706,25 +13156,21 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".size = "; os << *(params->psize); os << ", "; - os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; - os << ".phPhysicalMem = "; ur_params::serializePtr(os, *(params->pphPhysicalMem)); @@ -13762,7 +13208,6 @@ inline std::ostream &operator<<(std::ostream &os, os << *(params->pNumEntries); os << ", "; - os << ".phPlatforms = {"; for (size_t i = 0; *(params->pphPlatforms) != NULL && i < *params->pNumEntries; ++i) { @@ -13775,7 +13220,6 @@ inline std::ostream &operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".pNumPlatforms = "; ur_params::serializePtr(os, *(params->ppNumPlatforms)); @@ -13792,25 +13236,21 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phPlatform)); os << ", "; - os << ".propName = "; os << *(params->ppropName); os << ", "; - os << ".propSize = "; os << *(params->ppropSize); os << ", "; - os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; - os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -13827,7 +13267,6 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phPlatform)); os << ", "; - os << ".phNativePlatform = "; ur_params::serializePtr(os, *(params->pphNativePlatform)); @@ -13844,13 +13283,11 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phNativePlatform)); os << ", "; - os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; - os << ".phPlatform = "; ur_params::serializePtr(os, *(params->pphPlatform)); @@ -13867,13 +13304,11 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phPlatform)); os << ", "; - os << ".ppMessage = "; ur_params::serializePtr(os, *(params->pppMessage)); os << ", "; - os << ".pError = "; ur_params::serializePtr(os, *(params->ppError)); @@ -13890,7 +13325,6 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phPlatform)); os << ", "; - os << ".pVersion = "; ur_params::serializePtr(os, *(params->ppVersion)); @@ -13907,13 +13341,11 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phPlatform)); os << ", "; - os << ".pFrontendOption = "; ur_params::serializePtr(os, *(params->ppFrontendOption)); os << ", "; - os << ".ppPlatformOption = "; ur_params::serializePtr(os, *(params->pppPlatformOption)); @@ -13930,25 +13362,21 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".pIL = "; ur_params::serializePtr(os, *(params->ppIL)); os << ", "; - os << ".length = "; os << *(params->plength); os << ", "; - os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; - os << ".phProgram = "; ur_params::serializePtr(os, *(params->pphProgram)); @@ -13965,31 +13393,26 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".size = "; os << *(params->psize); os << ", "; - os << ".pBinary = "; ur_params::serializePtr(os, *(params->ppBinary)); os << ", "; - os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; - os << ".phProgram = "; ur_params::serializePtr(os, *(params->pphProgram)); @@ -14005,13 +13428,11 @@ operator<<(std::ostream &os, const struct ur_program_build_params_t *params) { ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".hProgram = "; ur_params::serializePtr(os, *(params->phProgram)); os << ", "; - os << ".pOptions = "; ur_params::serializePtr(os, *(params->ppOptions)); @@ -14027,13 +13448,11 @@ operator<<(std::ostream &os, const struct ur_program_compile_params_t *params) { ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".hProgram = "; ur_params::serializePtr(os, *(params->phProgram)); os << ", "; - os << ".pOptions = "; ur_params::serializePtr(os, *(params->ppOptions)); @@ -14049,13 +13468,11 @@ inline std::ostream &operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".count = "; os << *(params->pcount); os << ", "; - os << ".phPrograms = {"; for (size_t i = 0; *(params->pphPrograms) != NULL && i < *params->pcount; ++i) { @@ -14068,13 +13485,11 @@ inline std::ostream &operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".pOptions = "; ur_params::serializePtr(os, *(params->ppOptions)); os << ", "; - os << ".phProgram = "; ur_params::serializePtr(os, *(params->pphProgram)); @@ -14111,19 +13526,16 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".hProgram = "; ur_params::serializePtr(os, *(params->phProgram)); os << ", "; - os << ".pFunctionName = "; ur_params::serializePtr(os, *(params->ppFunctionName)); os << ", "; - os << ".ppFunctionPointer = "; ur_params::serializePtr(os, *(params->pppFunctionPointer)); @@ -14140,25 +13552,21 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phProgram)); os << ", "; - os << ".propName = "; os << *(params->ppropName); os << ", "; - os << ".propSize = "; os << *(params->ppropSize); os << ", "; - os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; - os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -14175,31 +13583,26 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phProgram)); os << ", "; - os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".propName = "; os << *(params->ppropName); os << ", "; - os << ".propSize = "; os << *(params->ppropSize); os << ", "; - os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; - os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -14216,13 +13619,11 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phProgram)); os << ", "; - os << ".count = "; os << *(params->pcount); os << ", "; - os << ".pSpecConstants = {"; for (size_t i = 0; *(params->ppSpecConstants) != NULL && i < *params->pcount; ++i) { @@ -14246,7 +13647,6 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phProgram)); os << ", "; - os << ".phNativeProgram = "; ur_params::serializePtr(os, *(params->pphNativeProgram)); @@ -14263,19 +13663,16 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phNativeProgram)); os << ", "; - os << ".hContext = "; ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; - os << ".phProgram = "; ur_params::serializePtr(os, *(params->pphProgram)); @@ -14291,25 +13688,21 @@ operator<<(std::ostream &os, const struct ur_queue_get_info_params_t *params) { ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".propName = "; os << *(params->ppropName); os << ", "; - os << ".propSize = "; os << *(params->ppropSize); os << ", "; - os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; - os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -14325,19 +13718,16 @@ inline std::ostream &operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; - os << ".phQueue = "; ur_params::serializePtr(os, *(params->pphQueue)); @@ -14374,13 +13764,11 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phQueue)); os << ", "; - os << ".pDesc = "; ur_params::serializePtr(os, *(params->ppDesc)); os << ", "; - os << ".phNativeQueue = "; ur_params::serializePtr(os, *(params->pphNativeQueue)); @@ -14397,25 +13785,21 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phNativeQueue)); os << ", "; - os << ".hContext = "; ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; - os << ".phQueue = "; ur_params::serializePtr(os, *(params->pphQueue)); @@ -14451,13 +13835,11 @@ operator<<(std::ostream &os, const struct ur_sampler_create_params_t *params) { ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".pDesc = "; ur_params::serializePtr(os, *(params->ppDesc)); os << ", "; - os << ".phSampler = "; ur_params::serializePtr(os, *(params->pphSampler)); @@ -14494,25 +13876,21 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phSampler)); os << ", "; - os << ".propName = "; os << *(params->ppropName); os << ", "; - os << ".propSize = "; os << *(params->ppropSize); os << ", "; - os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; - os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -14529,7 +13907,6 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phSampler)); os << ", "; - os << ".phNativeSampler = "; ur_params::serializePtr(os, *(params->pphNativeSampler)); @@ -14546,19 +13923,16 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phNativeSampler)); os << ", "; - os << ".hContext = "; ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; - os << ".phSampler = "; ur_params::serializePtr(os, *(params->pphSampler)); @@ -14574,25 +13948,21 @@ operator<<(std::ostream &os, const struct ur_usm_host_alloc_params_t *params) { ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".pUSMDesc = "; ur_params::serializePtr(os, *(params->ppUSMDesc)); os << ", "; - os << ".pool = "; ur_params::serializePtr(os, *(params->ppool)); os << ", "; - os << ".size = "; os << *(params->psize); os << ", "; - os << ".ppMem = "; ur_params::serializePtr(os, *(params->pppMem)); @@ -14609,31 +13979,26 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".pUSMDesc = "; ur_params::serializePtr(os, *(params->ppUSMDesc)); os << ", "; - os << ".pool = "; ur_params::serializePtr(os, *(params->ppool)); os << ", "; - os << ".size = "; os << *(params->psize); os << ", "; - os << ".ppMem = "; ur_params::serializePtr(os, *(params->pppMem)); @@ -14650,31 +14015,26 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".pUSMDesc = "; ur_params::serializePtr(os, *(params->ppUSMDesc)); os << ", "; - os << ".pool = "; ur_params::serializePtr(os, *(params->ppool)); os << ", "; - os << ".size = "; os << *(params->psize); os << ", "; - os << ".ppMem = "; ur_params::serializePtr(os, *(params->pppMem)); @@ -14690,7 +14050,6 @@ inline std::ostream &operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".pMem = "; ur_params::serializePtr(os, *(params->ppMem)); @@ -14707,31 +14066,26 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".pMem = "; ur_params::serializePtr(os, *(params->ppMem)); os << ", "; - os << ".propName = "; os << *(params->ppropName); os << ", "; - os << ".propSize = "; os << *(params->ppropSize); os << ", "; - os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; - os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -14747,13 +14101,11 @@ operator<<(std::ostream &os, const struct ur_usm_pool_create_params_t *params) { ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".pPoolDesc = "; ur_params::serializePtr(os, *(params->ppPoolDesc)); os << ", "; - os << ".ppPool = "; ur_params::serializePtr(os, *(params->pppPool)); @@ -14791,25 +14143,21 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phPool)); os << ", "; - os << ".propName = "; os << *(params->ppropName); os << ", "; - os << ".propSize = "; os << *(params->ppropSize); os << ", "; - os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; - os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -14826,49 +14174,41 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".pUSMDesc = "; ur_params::serializePtr(os, *(params->ppUSMDesc)); os << ", "; - os << ".pool = "; ur_params::serializePtr(os, *(params->ppool)); os << ", "; - os << ".widthInBytes = "; os << *(params->pwidthInBytes); os << ", "; - os << ".height = "; os << *(params->pheight); os << ", "; - os << ".elementSizeBytes = "; os << *(params->pelementSizeBytes); os << ", "; - os << ".ppMem = "; ur_params::serializePtr(os, *(params->pppMem)); os << ", "; - os << ".pResultPitch = "; ur_params::serializePtr(os, *(params->ppResultPitch)); @@ -14884,13 +14224,11 @@ operator<<(std::ostream &os, const struct ur_usm_import_exp_params_t *params) { ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".pMem = "; ur_params::serializePtr(os, *(params->ppMem)); os << ", "; - os << ".size = "; os << *(params->psize); @@ -14906,7 +14244,6 @@ operator<<(std::ostream &os, const struct ur_usm_release_exp_params_t *params) { ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".pMem = "; ur_params::serializePtr(os, *(params->ppMem)); @@ -14923,7 +14260,6 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->pcommandDevice)); os << ", "; - os << ".peerDevice = "; ur_params::serializePtr(os, *(params->ppeerDevice)); @@ -14940,7 +14276,6 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->pcommandDevice)); os << ", "; - os << ".peerDevice = "; ur_params::serializePtr(os, *(params->ppeerDevice)); @@ -14957,31 +14292,26 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->pcommandDevice)); os << ", "; - os << ".peerDevice = "; ur_params::serializePtr(os, *(params->ppeerDevice)); os << ", "; - os << ".propName = "; os << *(params->ppropName); os << ", "; - os << ".propSize = "; os << *(params->ppropSize); os << ", "; - os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; - os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -14998,31 +14328,26 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".hDevice = "; ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".propName = "; os << *(params->ppropName); os << ", "; - os << ".propSize = "; os << *(params->ppropSize); os << ", "; - os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; - os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -15039,19 +14364,16 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".pStart = "; ur_params::serializePtr(os, *(params->ppStart)); os << ", "; - os << ".size = "; os << *(params->psize); os << ", "; - os << ".ppStart = "; ur_params::serializePtr(os, *(params->pppStart)); @@ -15068,13 +14390,11 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".pStart = "; ur_params::serializePtr(os, *(params->ppStart)); os << ", "; - os << ".size = "; os << *(params->psize); @@ -15090,31 +14410,26 @@ operator<<(std::ostream &os, const struct ur_virtual_mem_map_params_t *params) { ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".pStart = "; ur_params::serializePtr(os, *(params->ppStart)); os << ", "; - os << ".size = "; os << *(params->psize); os << ", "; - os << ".hPhysicalMem = "; ur_params::serializePtr(os, *(params->phPhysicalMem)); os << ", "; - os << ".offset = "; os << *(params->poffset); os << ", "; - os << ".flags = "; ur_params::serializeFlag(os, @@ -15132,13 +14447,11 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".pStart = "; ur_params::serializePtr(os, *(params->ppStart)); os << ", "; - os << ".size = "; os << *(params->psize); @@ -15155,19 +14468,16 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".pStart = "; ur_params::serializePtr(os, *(params->ppStart)); os << ", "; - os << ".size = "; os << *(params->psize); os << ", "; - os << ".flags = "; ur_params::serializeFlag(os, @@ -15185,37 +14495,31 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".pStart = "; ur_params::serializePtr(os, *(params->ppStart)); os << ", "; - os << ".size = "; os << *(params->psize); os << ", "; - os << ".propName = "; os << *(params->ppropName); os << ", "; - os << ".propSize = "; os << *(params->ppropSize); os << ", "; - os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; - os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -15231,19 +14535,16 @@ inline std::ostream &operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phPlatform)); os << ", "; - os << ".DeviceType = "; os << *(params->pDeviceType); os << ", "; - os << ".NumEntries = "; os << *(params->pNumEntries); os << ", "; - os << ".phDevices = {"; for (size_t i = 0; *(params->pphDevices) != NULL && i < *params->pNumEntries; ++i) { @@ -15256,7 +14557,6 @@ inline std::ostream &operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".pNumDevices = "; ur_params::serializePtr(os, *(params->ppNumDevices)); @@ -15272,25 +14572,21 @@ operator<<(std::ostream &os, const struct ur_device_get_info_params_t *params) { ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".propName = "; os << *(params->ppropName); os << ", "; - os << ".propSize = "; os << *(params->ppropSize); os << ", "; - os << ".pPropValue = "; ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); os << ", "; - os << ".pPropSizeRet = "; ur_params::serializePtr(os, *(params->ppPropSizeRet)); @@ -15327,19 +14623,16 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; - os << ".NumDevices = "; os << *(params->pNumDevices); os << ", "; - os << ".phSubDevices = {"; for (size_t i = 0; *(params->pphSubDevices) != NULL && i < *params->pNumDevices; ++i) { @@ -15352,7 +14645,6 @@ operator<<(std::ostream &os, os << "}"; os << ", "; - os << ".pNumDevicesRet = "; ur_params::serializePtr(os, *(params->ppNumDevicesRet)); @@ -15369,19 +14661,16 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".pBinaries = "; ur_params::serializePtr(os, *(params->ppBinaries)); os << ", "; - os << ".NumBinaries = "; os << *(params->pNumBinaries); os << ", "; - os << ".pSelectedBinary = "; ur_params::serializePtr(os, *(params->ppSelectedBinary)); @@ -15398,7 +14687,6 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".phNativeDevice = "; ur_params::serializePtr(os, *(params->pphNativeDevice)); @@ -15415,19 +14703,16 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phNativeDevice)); os << ", "; - os << ".hPlatform = "; ur_params::serializePtr(os, *(params->phPlatform)); os << ", "; - os << ".pProperties = "; ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; - os << ".phDevice = "; ur_params::serializePtr(os, *(params->pphDevice)); @@ -15444,13 +14729,11 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".pDeviceTimestamp = "; ur_params::serializePtr(os, *(params->ppDeviceTimestamp)); os << ", "; - os << ".pHostTimestamp = "; ur_params::serializePtr(os, *(params->ppHostTimestamp)); From 64a847bba9dda77e514f869b46ee5b15a3a88138 Mon Sep 17 00:00:00 2001 From: Weronika Lewandowska Date: Thu, 29 Jun 2023 12:33:47 +0200 Subject: [PATCH 062/104] Add strongly recommended security compiler flags --- CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f19ea5618b..8077b4772e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,8 +57,11 @@ if(NOT MSVC) add_compile_options(-fPIC -Wall -Wpedantic $<$:-fdiagnostics-color=always> $<$:-fcolor-diagnostics>) + if (CMAKE_BUILD_TYPE STREQUAL "Release") + add_compile_options(-D_FORTIFY_SOURCE=2) + endif() if(UR_DEVELOPER_MODE) - add_compile_options(-Werror -fno-omit-frame-pointer) + add_compile_options(-Werror -fno-omit-frame-pointer -fstack-protector-strong) endif() # Determine if libstdc++ is being used. check_cxx_source_compiles(" @@ -81,7 +84,7 @@ elseif(MSVC) add_compile_options(/MP /W3 /MD$<$:d>) if(UR_DEVELOPER_MODE) - add_compile_options(/WX) + add_compile_options(/WX /GS) endif() endif() From f0132d16ea6f75f00089866a537702417201cd05 Mon Sep 17 00:00:00 2001 From: Damian Duy Date: Tue, 11 Jul 2023 12:21:07 +0200 Subject: [PATCH 063/104] add handling unsupported functions for disjoint pool --- source/common/umf_pools/disjoint_pool.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/source/common/umf_pools/disjoint_pool.cpp b/source/common/umf_pools/disjoint_pool.cpp index 0a5622588e..8b1f993355 100644 --- a/source/common/umf_pools/disjoint_pool.cpp +++ b/source/common/umf_pools/disjoint_pool.cpp @@ -908,13 +908,13 @@ void *DisjointPool::malloc(size_t size) { // For full-slab allocations indicates void *DisjointPool::calloc(size_t, size_t) { // Not supported - assert(false); + umf::getPoolLastStatusRef() = UMF_RESULT_ERROR_NOT_SUPPORTED; return NULL; } void *DisjointPool::realloc(void *, size_t) { // Not supported - assert(false); + umf::getPoolLastStatusRef() = UMF_RESULT_ERROR_NOT_SUPPORTED; return NULL; } @@ -934,8 +934,6 @@ void *DisjointPool::aligned_malloc(size_t size, size_t alignment) { size_t DisjointPool::malloc_usable_size(void *) { // Not supported - assert(false); - return 0; } From 1000c260bd13e32c543371b0599395cfa2be3fa2 Mon Sep 17 00:00:00 2001 From: Alberto Cabrera Date: Thu, 13 Jul 2023 09:34:27 +0100 Subject: [PATCH 064/104] [UR] Added Native CPU adapter constants --- include/ur.py | 1 + include/ur_api.h | 1 + scripts/core/platform.yml | 3 +++ source/common/ur_params.hpp | 5 +++++ 4 files changed, 10 insertions(+) diff --git a/include/ur.py b/include/ur.py index 4fcfc40da6..286ae6228c 100644 --- a/include/ur.py +++ b/include/ur.py @@ -530,6 +530,7 @@ class ur_platform_backend_v(IntEnum): OPENCL = 2 ## The backend is OpenCL CUDA = 3 ## The backend is CUDA HIP = 4 ## The backend is HIP + NATIVE_CPU = 5 ## The backend is Native CPU class ur_platform_backend_t(c_int): def __str__(self): diff --git a/include/ur_api.h b/include/ur_api.h index 360cfe05d0..3e319c5b8e 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -858,6 +858,7 @@ typedef enum ur_platform_backend_t { UR_PLATFORM_BACKEND_OPENCL = 2, ///< The backend is OpenCL UR_PLATFORM_BACKEND_CUDA = 3, ///< The backend is CUDA UR_PLATFORM_BACKEND_HIP = 4, ///< The backend is HIP + UR_PLATFORM_BACKEND_NATIVE_CPU = 5, ///< The backend is Native CPU /// @cond UR_PLATFORM_BACKEND_FORCE_UINT32 = 0x7fffffff /// @endcond diff --git a/scripts/core/platform.yml b/scripts/core/platform.yml index 9dab95a68a..69e9ac3665 100644 --- a/scripts/core/platform.yml +++ b/scripts/core/platform.yml @@ -291,3 +291,6 @@ etors: - name: HIP value: "4" desc: "The backend is HIP" + - name: NATIVE_CPU + value: "5" + desc: "The backend is Native CPU" diff --git a/source/common/ur_params.hpp b/source/common/ur_params.hpp index e3e17281d4..a9d49ea35b 100644 --- a/source/common/ur_params.hpp +++ b/source/common/ur_params.hpp @@ -2052,6 +2052,11 @@ inline std::ostream &operator<<(std::ostream &os, case UR_PLATFORM_BACKEND_HIP: os << "UR_PLATFORM_BACKEND_HIP"; break; + + case UR_PLATFORM_BACKEND_NATIVE_CPU: + os << "UR_PLATFORM_BACKEND_NATIVE_CPU"; + break; + default: os << "unknown enumerator"; break; From 0033c6e35765d41ad6a940076703caf211f1fea4 Mon Sep 17 00:00:00 2001 From: Patryk Kaminski Date: Wed, 12 Jul 2023 15:09:45 +0200 Subject: [PATCH 065/104] Set global compile flags for UR targets only Currently, some of compile flags are set globally for the whole project including third-party libraries. Introduce wrapper functions for add_executable and add_library CMake functions in order to add compile flags only where needed. --- CMakeLists.txt | 18 -------- cmake/helpers.cmake | 42 +++++++++++++++++++ examples/collector/CMakeLists.txt | 2 +- examples/hello_world/CMakeLists.txt | 2 +- source/adapters/null/CMakeLists.txt | 2 +- source/common/umf_pools/CMakeLists.txt | 2 +- .../unified_malloc_framework/CMakeLists.txt | 4 +- source/loader/CMakeLists.txt | 2 +- test/conformance/CMakeLists.txt | 2 +- test/conformance/testing/CMakeLists.txt | 2 +- test/layers/validation/CMakeLists.txt | 2 +- test/loader/adapter_registry/CMakeLists.txt | 2 +- test/loader/platforms/CMakeLists.txt | 2 +- test/unified_malloc_framework/CMakeLists.txt | 4 +- test/unit/CMakeLists.txt | 2 +- test/unit/logger/CMakeLists.txt | 2 +- test/usm/CMakeLists.txt | 2 +- tools/urtrace/CMakeLists.txt | 2 +- 18 files changed, 60 insertions(+), 36 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8077b4772e..fa5f48ea77 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,17 +52,7 @@ if(MSVC) set(CUSTOM_COMMAND_BINARY_DIR ${CUSTOM_COMMAND_BINARY_DIR}/$) endif() -# CXX flags setup if(NOT MSVC) - add_compile_options(-fPIC -Wall -Wpedantic - $<$:-fdiagnostics-color=always> - $<$:-fcolor-diagnostics>) - if (CMAKE_BUILD_TYPE STREQUAL "Release") - add_compile_options(-D_FORTIFY_SOURCE=2) - endif() - if(UR_DEVELOPER_MODE) - add_compile_options(-Werror -fno-omit-frame-pointer -fstack-protector-strong) - endif() # Determine if libstdc++ is being used. check_cxx_source_compiles(" #include @@ -78,14 +68,6 @@ if(NOT MSVC) # is available we still need to link this library. link_libraries(stdc++fs) endif() -elseif(MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") - add_compile_options(/MP /W3 /MD$<$:d>) - - if(UR_DEVELOPER_MODE) - add_compile_options(/WX /GS) - endif() endif() if(UR_ENABLE_TRACING) diff --git a/cmake/helpers.cmake b/cmake/helpers.cmake index 4651cba59d..c25806a1f2 100644 --- a/cmake/helpers.cmake +++ b/cmake/helpers.cmake @@ -57,6 +57,48 @@ macro(add_sanitizer_flag flag) set(CMAKE_REQUIRED_LIBRARIES ${SAVED_CMAKE_REQUIRED_LIBRARIES}) endmacro() +function(add_ur_target_compile_options name) + if(NOT MSVC) + target_compile_options(${name} PRIVATE + -fPIC + -Wall + -Wpedantic + $<$:-fdiagnostics-color=always> + $<$:-fcolor-diagnostics> + ) + if (CMAKE_BUILD_TYPE STREQUAL "Release") + target_compile_definitions(${name} PRIVATE -D_FORTIFY_SOURCE=2) + endif() + if(UR_DEVELOPER_MODE) + target_compile_options(${name} PRIVATE + -Werror + -fno-omit-frame-pointer + -fstack-protector-strong + ) + endif() + elseif(MSVC) + target_compile_options(${name} PRIVATE + /MP + /W3 + /MD$<$:d> + ) + + if(UR_DEVELOPER_MODE) + target_compile_options(${name} PRIVATE /WX /GS) + endif() + endif() +endfunction() + +function(add_ur_executable name) + add_executable(${name} ${ARGN}) + add_ur_target_compile_options(${name}) +endfunction() + +function(add_ur_library name) + add_library(${name} ${ARGN}) + add_ur_target_compile_options(${name}) +endfunction() + include(FetchContent) # A wrapper around FetchContent_Declare that supports git sparse checkout. diff --git a/examples/collector/CMakeLists.txt b/examples/collector/CMakeLists.txt index e9ce42c14e..5fe484d0b8 100644 --- a/examples/collector/CMakeLists.txt +++ b/examples/collector/CMakeLists.txt @@ -5,7 +5,7 @@ set(TARGET_NAME collector) -add_library(${TARGET_NAME} SHARED +add_ur_library(${TARGET_NAME} SHARED ${CMAKE_CURRENT_SOURCE_DIR}/collector.cpp ) diff --git a/examples/hello_world/CMakeLists.txt b/examples/hello_world/CMakeLists.txt index bde1fd9cf5..8fd9bda19d 100644 --- a/examples/hello_world/CMakeLists.txt +++ b/examples/hello_world/CMakeLists.txt @@ -5,7 +5,7 @@ set(TARGET_NAME hello_world) -add_executable(${TARGET_NAME} +add_ur_executable(${TARGET_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/hello_world.cpp ) diff --git a/source/adapters/null/CMakeLists.txt b/source/adapters/null/CMakeLists.txt index 56b8815929..9cd093a9aa 100644 --- a/source/adapters/null/CMakeLists.txt +++ b/source/adapters/null/CMakeLists.txt @@ -5,7 +5,7 @@ set(TARGET_NAME ur_adapter_null) -add_library(${TARGET_NAME} +add_ur_library(${TARGET_NAME} SHARED ${CMAKE_CURRENT_SOURCE_DIR}/ur_null.hpp ${CMAKE_CURRENT_SOURCE_DIR}/ur_null.cpp diff --git a/source/common/umf_pools/CMakeLists.txt b/source/common/umf_pools/CMakeLists.txt index fc511cd814..d9bc3deaaf 100644 --- a/source/common/umf_pools/CMakeLists.txt +++ b/source/common/umf_pools/CMakeLists.txt @@ -3,7 +3,7 @@ # See LICENSE.TXT # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -add_library(disjoint_pool STATIC +add_ur_library(disjoint_pool STATIC disjoint_pool.cpp disjoint_pool_config_parser.cpp ) diff --git a/source/common/unified_malloc_framework/CMakeLists.txt b/source/common/unified_malloc_framework/CMakeLists.txt index 86d19f3099..e73374d4eb 100644 --- a/source/common/unified_malloc_framework/CMakeLists.txt +++ b/source/common/unified_malloc_framework/CMakeLists.txt @@ -14,11 +14,11 @@ if(UMF_BUILD_SHARED_LIBRARY) message(WARNING "Unified Malloc Framework is still an early work in progress." "There are no API/ABI backward compatibility guarantees. There will be breakages." "Do not use the shared library in production software.") - add_library(unified_malloc_framework SHARED + add_ur_library(unified_malloc_framework SHARED ${UMF_SOURCES}) target_compile_definitions(unified_malloc_framework PUBLIC UMF_SHARED_LIBRARY) else() - add_library(unified_malloc_framework STATIC + add_ur_library(unified_malloc_framework STATIC ${UMF_SOURCES}) endif() diff --git a/source/loader/CMakeLists.txt b/source/loader/CMakeLists.txt index 0c4c89eac0..b1a3e8bb91 100644 --- a/source/loader/CMakeLists.txt +++ b/source/loader/CMakeLists.txt @@ -9,7 +9,7 @@ configure_file( @ONLY ) -add_library(ur_loader +add_ur_library(ur_loader SHARED "" ${CMAKE_CURRENT_BINARY_DIR}/UrLoaderVersion.rc diff --git a/test/conformance/CMakeLists.txt b/test/conformance/CMakeLists.txt index 3b9292e13f..2b2c5238c6 100644 --- a/test/conformance/CMakeLists.txt +++ b/test/conformance/CMakeLists.txt @@ -7,7 +7,7 @@ set(UR_CONFORMANCE_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) function(add_conformance_test name) set(TEST_TARGET_NAME test-${name}) - add_executable(${TEST_TARGET_NAME} + add_ur_executable(${TEST_TARGET_NAME} ${ARGN} ${UR_CONFORMANCE_TEST_DIR}/source/environment.cpp ${UR_CONFORMANCE_TEST_DIR}/source/main.cpp) diff --git a/test/conformance/testing/CMakeLists.txt b/test/conformance/testing/CMakeLists.txt index a894478fe4..47e90915ed 100644 --- a/test/conformance/testing/CMakeLists.txt +++ b/test/conformance/testing/CMakeLists.txt @@ -3,7 +3,7 @@ # See LICENSE.TXT # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -add_library(ur_testing STATIC +add_ur_library(ur_testing STATIC source/utils.cpp) target_include_directories(ur_testing PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) target_link_libraries(ur_testing PRIVATE gtest_main unified-runtime::headers) diff --git a/test/layers/validation/CMakeLists.txt b/test/layers/validation/CMakeLists.txt index 7ebd23c11b..83b2be102c 100644 --- a/test/layers/validation/CMakeLists.txt +++ b/test/layers/validation/CMakeLists.txt @@ -7,7 +7,7 @@ set(UR_VALIDATION_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) function(add_validation_test name) set(TEST_TARGET_NAME validation_test-${name}) - add_executable(${TEST_TARGET_NAME} + add_ur_executable(${TEST_TARGET_NAME} ${ARGN}) target_link_libraries(${TEST_TARGET_NAME} PRIVATE diff --git a/test/loader/adapter_registry/CMakeLists.txt b/test/loader/adapter_registry/CMakeLists.txt index 5481bd8de7..2778ad5c40 100644 --- a/test/loader/adapter_registry/CMakeLists.txt +++ b/test/loader/adapter_registry/CMakeLists.txt @@ -7,7 +7,7 @@ function(add_adapter_reg_search_test name) cmake_parse_arguments(TEST "" "" "SEARCH_PATH;ENVS;SOURCES" ${ARGN}) set(TEST_TARGET_NAME adapter-reg-test-${name}) - add_executable(${TEST_TARGET_NAME} + add_ur_executable(${TEST_TARGET_NAME} ${TEST_SOURCES}) if(WIN32) diff --git a/test/loader/platforms/CMakeLists.txt b/test/loader/platforms/CMakeLists.txt index 69441d3f13..7c1e7315ec 100644 --- a/test/loader/platforms/CMakeLists.txt +++ b/test/loader/platforms/CMakeLists.txt @@ -3,7 +3,7 @@ # See LICENSE.TXT # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -add_executable(test-loader-platforms +add_ur_executable(test-loader-platforms platforms.cpp ) diff --git a/test/unified_malloc_framework/CMakeLists.txt b/test/unified_malloc_framework/CMakeLists.txt index 7636c5d26f..d49082c927 100644 --- a/test/unified_malloc_framework/CMakeLists.txt +++ b/test/unified_malloc_framework/CMakeLists.txt @@ -5,7 +5,7 @@ set(UR_UMF_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) -add_library(umf_test_helpers STATIC +add_ur_library(umf_test_helpers STATIC ${UR_UMF_TEST_DIR}/common/pool.c ${UR_UMF_TEST_DIR}/common/provider.c ) @@ -14,7 +14,7 @@ target_link_libraries(umf_test_helpers PRIVATE ${PROJECT_NAME}::common) function(add_umf_test name) set(TEST_TARGET_NAME umf_test-${name}) - add_executable(${TEST_TARGET_NAME} + add_ur_executable(${TEST_TARGET_NAME} ${ARGN}) target_link_libraries(${TEST_TARGET_NAME} PRIVATE diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index 58ba249c10..fbb3b0cea3 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -12,7 +12,7 @@ target_include_directories(unit_tests_helpers INTERFACE function(add_unit_test name) set(TEST_TARGET_NAME test-${name}) - add_executable(${TEST_TARGET_NAME} + add_ur_executable(${TEST_TARGET_NAME} ${ARGN} ) target_link_libraries(${TEST_TARGET_NAME} diff --git a/test/unit/logger/CMakeLists.txt b/test/unit/logger/CMakeLists.txt index 22ed897916..86e5859a22 100644 --- a/test/unit/logger/CMakeLists.txt +++ b/test/unit/logger/CMakeLists.txt @@ -8,7 +8,7 @@ add_unit_test(logger ) set(TEST_TARGET_NAME test-logger_env_var) -add_executable(${TEST_TARGET_NAME} +add_ur_executable(${TEST_TARGET_NAME} env_var.cpp ) target_link_libraries(${TEST_TARGET_NAME} diff --git a/test/usm/CMakeLists.txt b/test/usm/CMakeLists.txt index e0cb5fd943..b673b6d1b9 100644 --- a/test/usm/CMakeLists.txt +++ b/test/usm/CMakeLists.txt @@ -7,7 +7,7 @@ set(UR_USM_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) function(add_usm_test name) set(TEST_TARGET_NAME usm_test-${name}) - add_executable(${TEST_TARGET_NAME} + add_ur_executable(${TEST_TARGET_NAME} ${UR_USM_TEST_DIR}/../conformance/source/environment.cpp ${UR_USM_TEST_DIR}/../conformance/source/main.cpp ${ARGN}) diff --git a/tools/urtrace/CMakeLists.txt b/tools/urtrace/CMakeLists.txt index be81a11e25..085f361223 100644 --- a/tools/urtrace/CMakeLists.txt +++ b/tools/urtrace/CMakeLists.txt @@ -5,7 +5,7 @@ set(TARGET_NAME ur_collector) -add_library(${TARGET_NAME} SHARED +add_ur_library(${TARGET_NAME} SHARED ${CMAKE_CURRENT_SOURCE_DIR}/collector.cpp ) From 4e22bd765e1167dbba402de88284aedb40f3e63d Mon Sep 17 00:00:00 2001 From: Alberto Cabrera Date: Thu, 13 Jul 2023 12:44:13 +0100 Subject: [PATCH 066/104] [UR] Fixed extra newline introduced in generated code --- source/common/ur_params.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/source/common/ur_params.hpp b/source/common/ur_params.hpp index a9d49ea35b..c1368c79de 100644 --- a/source/common/ur_params.hpp +++ b/source/common/ur_params.hpp @@ -2056,7 +2056,6 @@ inline std::ostream &operator<<(std::ostream &os, case UR_PLATFORM_BACKEND_NATIVE_CPU: os << "UR_PLATFORM_BACKEND_NATIVE_CPU"; break; - default: os << "unknown enumerator"; break; From 57d68953c1eb9f7b752993e67d8a56a3ff1d1ce9 Mon Sep 17 00:00:00 2001 From: Krzysztof Swiecicki Date: Wed, 12 Jul 2023 17:11:12 +0200 Subject: [PATCH 067/104] [umf] add error translation function to helpers --- source/common/umf_helpers.hpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/source/common/umf_helpers.hpp b/source/common/umf_helpers.hpp index 510af3e244..198684b134 100644 --- a/source/common/umf_helpers.hpp +++ b/source/common/umf_helpers.hpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -160,6 +161,37 @@ template umf_result_t &getPoolLastStatusRef() { return last_status; } +/// @brief translates UMF return values to UR. +/// This function assumes that the native error of +/// the last failed memory provider is ur_result_t. +inline ur_result_t umf2urResult(umf_result_t umfResult) { + switch (umfResult) { + case UMF_RESULT_SUCCESS: + return UR_RESULT_SUCCESS; + case UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY: + return UR_RESULT_ERROR_OUT_OF_HOST_MEMORY; + case UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC: { + auto hProvider = umfGetLastFailedMemoryProvider(); + if (hProvider == nullptr) { + return UR_RESULT_ERROR_UNKNOWN; + } + + ur_result_t Err = UR_RESULT_ERROR_UNKNOWN; + umfMemoryProviderGetLastNativeError(hProvider, nullptr, + reinterpret_cast(&Err)); + return Err; + } + case UMF_RESULT_ERROR_INVALID_ARGUMENT: + return UR_RESULT_ERROR_INVALID_ARGUMENT; + case UMF_RESULT_ERROR_INVALID_ALIGNMENT: + return UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT; + case UMF_RESULT_ERROR_NOT_SUPPORTED: + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + default: + return UR_RESULT_ERROR_UNKNOWN; + }; +} + } // namespace umf #endif /* UMF_HELPERS_H */ From fc5049426bcf41fbb1e428cec950017b221290ac Mon Sep 17 00:00:00 2001 From: Przemek Malon Date: Thu, 13 Jul 2023 13:16:25 +0100 Subject: [PATCH 068/104] [Bindless][Exp] Add bindless images interop resource handles - Added new structs `ur_exp_interop_memory_desc_t` and `ur_exp_interop_semaphore_desc_t`. - Updated `urBindlessImagesImportOpaqueFDExp` and `urBindlessImagesImportExternalSemaphoreOpaqueFDExp` to use the new structs. Co-authored-by: Isaac Ault Co-authored-by: Przemek Malon Co-authored-by: Petr Vesely --- include/ur.py | 50 ++++++- include/ur_api.h | 70 +++++++-- include/ur_ddi.h | 4 +- scripts/core/EXP-BINDLESS-IMAGES.rst | 15 +- scripts/core/exp-bindless-images.yml | 58 +++++++- source/adapters/null/ur_nullddi.cpp | 14 +- source/common/ur_params.hpp | 136 +++++++++++++++++- source/loader/layers/tracing/ur_trcddi.cpp | 16 ++- source/loader/layers/validation/ur_valddi.cpp | 22 ++- source/loader/ur_ldrddi.cpp | 16 ++- source/loader/ur_libapi.cpp | 16 ++- source/ur_api.cpp | 12 +- 12 files changed, 359 insertions(+), 70 deletions(-) diff --git a/include/ur.py b/include/ur.py index 286ae6228c..39888418af 100644 --- a/include/ur.py +++ b/include/ur.py @@ -232,6 +232,10 @@ class ur_structure_type_v(IntEnum): KERNEL_ARG_LOCAL_PROPERTIES = 33 ## ::ur_kernel_arg_local_properties_t EXP_COMMAND_BUFFER_DESC = 0x1000 ## ::ur_exp_command_buffer_desc_t EXP_SAMPLER_MIP_PROPERTIES = 0x2000 ## ::ur_exp_sampler_mip_properties_t + EXP_INTEROP_MEMORY_DESC = 0x2001 ## ::ur_exp_interop_memory_desc_t + EXP_INTEROP_SEMAPHORE_DESC = 0x2002 ## ::ur_exp_interop_semaphore_desc_t + EXP_FILE_DESCRIPTOR = 0x2003 ## ::ur_exp_file_descriptor_t + EXP_WIN32_HANDLE = 0x2004 ## ::ur_exp_win32_handle_t class ur_structure_type_t(c_int): def __str__(self): @@ -2097,6 +2101,26 @@ def __str__(self): return hex(self.value) +############################################################################### +## @brief File descriptor +class ur_exp_file_descriptor_t(Structure): + _fields_ = [ + ("stype", ur_structure_type_t), ## [in] type of this structure, must be + ## ::UR_STRUCTURE_TYPE_EXP_FILE_DESCRIPTOR + ("pNext", c_void_p), ## [in][optional] pointer to extension-specific structure + ("fd", c_int) ## [in] A file descriptor used for Linux and & MacOS operating systems. + ] + +############################################################################### +## @brief Windows specific file handle +class ur_exp_win32_handle_t(Structure): + _fields_ = [ + ("stype", ur_structure_type_t), ## [in] type of this structure, must be + ## ::UR_STRUCTURE_TYPE_EXP_WIN32_HANDLE + ("pNext", c_void_p), ## [in][optional] pointer to extension-specific structure + ("handle", c_void_p) ## [in] A win32 file handle. + ] + ############################################################################### ## @brief Describes mipmap sampler properties ## @@ -2117,6 +2141,24 @@ class ur_exp_sampler_mip_properties_t(Structure): ("mipFilterMode", ur_sampler_filter_mode_t) ## [in] mipmap filter mode used for filtering between mipmap levels ] +############################################################################### +## @brief Describes an interop memory resource descriptor +class ur_exp_interop_memory_desc_t(Structure): + _fields_ = [ + ("stype", ur_structure_type_t), ## [in] type of this structure, must be + ## ::UR_STRUCTURE_TYPE_EXP_INTEROP_MEMORY_DESC + ("pNext", c_void_p) ## [in][optional] pointer to extension-specific structure + ] + +############################################################################### +## @brief Describes an interop semaphore resource descriptor +class ur_exp_interop_semaphore_desc_t(Structure): + _fields_ = [ + ("stype", ur_structure_type_t), ## [in] type of this structure, must be + ## ::UR_STRUCTURE_TYPE_EXP_INTEROP_SEMAPHORE_DESC + ("pNext", c_void_p) ## [in][optional] pointer to extension-specific structure + ] + ############################################################################### ## @brief The extension string which defines support for command-buffers which ## is returned when querying device extensions. @@ -3117,9 +3159,9 @@ class ur_queue_dditable_t(Structure): ############################################################################### ## @brief Function-pointer for urBindlessImagesImportOpaqueFDExp if __use_win_types: - _urBindlessImagesImportOpaqueFDExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, c_size_t, c_ulong, POINTER(ur_exp_interop_mem_handle_t) ) + _urBindlessImagesImportOpaqueFDExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, c_size_t, POINTER(ur_exp_interop_memory_desc_t), POINTER(ur_exp_interop_mem_handle_t) ) else: - _urBindlessImagesImportOpaqueFDExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, c_size_t, c_ulong, POINTER(ur_exp_interop_mem_handle_t) ) + _urBindlessImagesImportOpaqueFDExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, c_size_t, POINTER(ur_exp_interop_memory_desc_t), POINTER(ur_exp_interop_mem_handle_t) ) ############################################################################### ## @brief Function-pointer for urBindlessImagesMapExternalArrayExp @@ -3138,9 +3180,9 @@ class ur_queue_dditable_t(Structure): ############################################################################### ## @brief Function-pointer for urBindlessImagesImportExternalSemaphoreOpaqueFDExp if __use_win_types: - _urBindlessImagesImportExternalSemaphoreOpaqueFDExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, c_ulong, POINTER(ur_exp_interop_semaphore_handle_t) ) + _urBindlessImagesImportExternalSemaphoreOpaqueFDExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, POINTER(ur_exp_interop_semaphore_desc_t), POINTER(ur_exp_interop_semaphore_handle_t) ) else: - _urBindlessImagesImportExternalSemaphoreOpaqueFDExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, c_ulong, POINTER(ur_exp_interop_semaphore_handle_t) ) + _urBindlessImagesImportExternalSemaphoreOpaqueFDExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, POINTER(ur_exp_interop_semaphore_desc_t), POINTER(ur_exp_interop_semaphore_handle_t) ) ############################################################################### ## @brief Function-pointer for urBindlessImagesDestroyExternalSemaphoreExp diff --git a/include/ur_api.h b/include/ur_api.h index 3e319c5b8e..de09cda21f 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -241,6 +241,10 @@ typedef enum ur_structure_type_t { UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES = 33, ///< ::ur_kernel_arg_local_properties_t UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC = 0x1000, ///< ::ur_exp_command_buffer_desc_t UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES = 0x2000, ///< ::ur_exp_sampler_mip_properties_t + UR_STRUCTURE_TYPE_EXP_INTEROP_MEMORY_DESC = 0x2001, ///< ::ur_exp_interop_memory_desc_t + UR_STRUCTURE_TYPE_EXP_INTEROP_SEMAPHORE_DESC = 0x2002, ///< ::ur_exp_interop_semaphore_desc_t + UR_STRUCTURE_TYPE_EXP_FILE_DESCRIPTOR = 0x2003, ///< ::ur_exp_file_descriptor_t + UR_STRUCTURE_TYPE_EXP_WIN32_HANDLE = 0x2004, ///< ::ur_exp_win32_handle_t /// @cond UR_STRUCTURE_TYPE_FORCE_UINT32 = 0x7fffffff /// @endcond @@ -6616,6 +6620,26 @@ typedef enum ur_exp_image_copy_flag_t { /// @brief Bit Mask for validating ur_exp_image_copy_flags_t #define UR_EXP_IMAGE_COPY_FLAGS_MASK 0xfffffff8 +/////////////////////////////////////////////////////////////////////////////// +/// @brief File descriptor +typedef struct ur_exp_file_descriptor_t { + ur_structure_type_t stype; ///< [in] type of this structure, must be + ///< ::UR_STRUCTURE_TYPE_EXP_FILE_DESCRIPTOR + const void *pNext; ///< [in][optional] pointer to extension-specific structure + int fd; ///< [in] A file descriptor used for Linux and & MacOS operating systems. + +} ur_exp_file_descriptor_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Windows specific file handle +typedef struct ur_exp_win32_handle_t { + ur_structure_type_t stype; ///< [in] type of this structure, must be + ///< ::UR_STRUCTURE_TYPE_EXP_WIN32_HANDLE + const void *pNext; ///< [in][optional] pointer to extension-specific structure + void *handle; ///< [in] A win32 file handle. + +} ur_exp_win32_handle_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief Describes mipmap sampler properties /// @@ -6636,6 +6660,24 @@ typedef struct ur_exp_sampler_mip_properties_t { } ur_exp_sampler_mip_properties_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Describes an interop memory resource descriptor +typedef struct ur_exp_interop_memory_desc_t { + ur_structure_type_t stype; ///< [in] type of this structure, must be + ///< ::UR_STRUCTURE_TYPE_EXP_INTEROP_MEMORY_DESC + const void *pNext; ///< [in][optional] pointer to extension-specific structure + +} ur_exp_interop_memory_desc_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Describes an interop semaphore resource descriptor +typedef struct ur_exp_interop_semaphore_desc_t { + ur_structure_type_t stype; ///< [in] type of this structure, must be + ///< ::UR_STRUCTURE_TYPE_EXP_INTEROP_SEMAPHORE_DESC + const void *pNext; ///< [in][optional] pointer to extension-specific structure + +} ur_exp_interop_semaphore_desc_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief USM allocate pitched memory /// @@ -7034,17 +7076,18 @@ urBindlessImagesMipmapFreeExp( /// + `NULL == hContext` /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == interopMemDesc` /// + `NULL == phInteropMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE /// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( - ur_context_handle_t hContext, ///< [in] handle of the context object - ur_device_handle_t hDevice, ///< [in] handle of the device object - size_t size, ///< [in] size of the external memory - uint32_t fileDescriptor, ///< [in] the file descriptor - ur_exp_interop_mem_handle_t *phInteropMem ///< [out] interop memory handle to the external memory + ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object + size_t size, ///< [in] size of the external memory + ur_exp_interop_memory_desc_t *interopMemDesc, ///< [in] the interop memory descriptor + ur_exp_interop_mem_handle_t *phInteropMem ///< [out] interop memory handle to the external memory ); /////////////////////////////////////////////////////////////////////////////// @@ -7121,15 +7164,16 @@ urBindlessImagesReleaseInteropExp( /// + `NULL == hContext` /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// + `NULL == phInteropSemaphoreHandle` +/// + `NULL == interopSemaphoreDesc` +/// + `NULL == phInteropSemaphore` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( - ur_context_handle_t hContext, ///< [in] handle of the context object - ur_device_handle_t hDevice, ///< [in] handle of the device object - uint32_t fileDescriptor, ///< [in] the file descriptor - ur_exp_interop_semaphore_handle_t *phInteropSemaphoreHandle ///< [out] interop semaphore handle to the external semaphore + ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object + ur_exp_interop_semaphore_desc_t *interopSemaphoreDesc, ///< [in] the interop semaphore descriptor + ur_exp_interop_semaphore_handle_t *phInteropSemaphore ///< [out] interop semaphore handle to the external semaphore ); /////////////////////////////////////////////////////////////////////////////// @@ -9199,7 +9243,7 @@ typedef struct ur_bindless_images_import_opaque_fd_exp_params_t { ur_context_handle_t *phContext; ur_device_handle_t *phDevice; size_t *psize; - uint32_t *pfileDescriptor; + ur_exp_interop_memory_desc_t **pinteropMemDesc; ur_exp_interop_mem_handle_t **pphInteropMem; } ur_bindless_images_import_opaque_fd_exp_params_t; @@ -9233,8 +9277,8 @@ typedef struct ur_bindless_images_release_interop_exp_params_t { typedef struct ur_bindless_images_import_external_semaphore_opaque_fd_exp_params_t { ur_context_handle_t *phContext; ur_device_handle_t *phDevice; - uint32_t *pfileDescriptor; - ur_exp_interop_semaphore_handle_t **pphInteropSemaphoreHandle; + ur_exp_interop_semaphore_desc_t **pinteropSemaphoreDesc; + ur_exp_interop_semaphore_handle_t **pphInteropSemaphore; } ur_bindless_images_import_external_semaphore_opaque_fd_exp_params_t; /////////////////////////////////////////////////////////////////////////////// diff --git a/include/ur_ddi.h b/include/ur_ddi.h index 3729208835..66ab7cde74 100644 --- a/include/ur_ddi.h +++ b/include/ur_ddi.h @@ -1375,7 +1375,7 @@ typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImportOpaqueFDExp_t)( ur_context_handle_t, ur_device_handle_t, size_t, - uint32_t, + ur_exp_interop_memory_desc_t *, ur_exp_interop_mem_handle_t *); /////////////////////////////////////////////////////////////////////////////// @@ -1400,7 +1400,7 @@ typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesReleaseInteropExp_t)( typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImportExternalSemaphoreOpaqueFDExp_t)( ur_context_handle_t, ur_device_handle_t, - uint32_t, + ur_exp_interop_semaphore_desc_t *, ur_exp_interop_semaphore_handle_t *); /////////////////////////////////////////////////////////////////////////////// diff --git a/scripts/core/EXP-BINDLESS-IMAGES.rst b/scripts/core/EXP-BINDLESS-IMAGES.rst index 7bd1445871..d7d1bd4486 100644 --- a/scripts/core/EXP-BINDLESS-IMAGES.rst +++ b/scripts/core/EXP-BINDLESS-IMAGES.rst @@ -64,6 +64,10 @@ Enums ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * ${x}_structure_type_t ${X}_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES + ${X}_STRUCTURE_TYPE_EXP_INTEROP_MEMORY_DESC + ${X}_STRUCTURE_TYPE_EXP_INTEROP_SEMAPHORE_DESC + ${X}_STRUCTURE_TYPE_EXP_FILE_DESCRIPTOR + ${X}_STRUCTURE_TYPE_EXP_WIN32_HANDLE * ${x}_device_info_t * ${X}_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP @@ -119,6 +123,10 @@ Types * ${x}_exp_image_mem_handle_t * ${x}_exp_interop_mem_handle_t * ${x}_exp_interop_semaphore_handle_t +* ${x}_exp_interop_memory_desc_t +* ${x}_exp_interop_semaphore_desc_t +* ${x}_exp_file_descriptor_t +* ${x}_exp_win32_handle_t Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -159,8 +167,11 @@ Changelog | || Removed 3D USM capabilities. | | || Added mip filter mode. | +----------+----------------------------------------------------------+ -| 3.0 | Added device query for bindless images on shared USM | -+----------+---------------------------------------------------------+ +| 3.0 | Added device query for bindless images on shared USM | ++----------+-------------------------------------------------------------+ +| 4.0 || Added platform specific interop resource handles. | +| || Added and updated to use new interop resource descriptors. | ++----------+-------------------------------------------------------------+ Contributors -------------------------------------------------------------------------------- diff --git a/scripts/core/exp-bindless-images.yml b/scripts/core/exp-bindless-images.yml index 800808f6f0..a84d571807 100644 --- a/scripts/core/exp-bindless-images.yml +++ b/scripts/core/exp-bindless-images.yml @@ -86,6 +86,18 @@ etors: - name: EXP_SAMPLER_MIP_PROPERTIES desc: $x_exp_sampler_mip_properties_t value: "0x2000" + - name: EXP_INTEROP_MEMORY_DESC + desc: $x_exp_interop_memory_desc_t + value: "0x2001" + - name: EXP_INTEROP_SEMAPHORE_DESC + desc: $x_exp_interop_semaphore_desc_t + value: "0x2002" + - name: EXP_FILE_DESCRIPTOR + desc: $x_exp_file_descriptor_t + value: "0x2003" + - name: EXP_WIN32_HANDLE + desc: $x_exp_win32_handle_t + value: "0x2004" --- #-------------------------------------------------------------------------- type: enum extend: true @@ -112,6 +124,24 @@ etors: desc: "Device to device" --- #-------------------------------------------------------------------------- type: struct +desc: "File descriptor" +name: $x_exp_file_descriptor_t +base: $x_base_desc_t +members: + - type: int + name: fd + desc: "[in] A file descriptor used for Linux and & MacOS operating systems." +--- #-------------------------------------------------------------------------- +type: struct +desc: "Windows specific file handle" +name: $x_exp_win32_handle_t +base: $x_base_desc_t +members: + - type: void* + name: handle + desc: "[in] A win32 file handle." +--- #-------------------------------------------------------------------------- +type: struct desc: "Describes mipmap sampler properties" details: - Specify these properties in $xSamplerCreate via $x_sampler_desc_t as part @@ -133,6 +163,20 @@ members: name: mipFilterMode desc: "[in] mipmap filter mode used for filtering between mipmap levels" --- #-------------------------------------------------------------------------- +type: struct +desc: "Describes an interop memory resource descriptor" +class: $xBindlessImages +name: $x_exp_interop_memory_desc_t +base: $x_base_desc_t +members: [] +--- #-------------------------------------------------------------------------- +type: struct +desc: "Describes an interop semaphore resource descriptor" +class: $xBindlessImages +name: $x_exp_interop_semaphore_desc_t +base: $x_base_desc_t +members: [] +--- #-------------------------------------------------------------------------- type: function desc: "USM allocate pitched memory" class: $xUSM @@ -518,9 +562,9 @@ params: - type: size_t name: size desc: "[in] size of the external memory" - - type: uint32_t - name: fileDescriptor - desc: "[in] the file descriptor" + - type: $x_exp_interop_memory_desc_t* + name: interopMemDesc + desc: "[in] the interop memory descriptor" - type: $x_exp_interop_mem_handle_t* name: phInteropMem desc: "[out] interop memory handle to the external memory" @@ -597,11 +641,11 @@ params: - type: $x_device_handle_t name: hDevice desc: "[in] handle of the device object" - - type: uint32_t - name: fileDescriptor - desc: "[in] the file descriptor" + - type: $x_exp_interop_semaphore_desc_t* + name: interopSemaphoreDesc + desc: "[in] the interop semaphore descriptor" - type: $x_exp_interop_semaphore_handle_t* - name: phInteropSemaphoreHandle + name: phInteropSemaphore desc: "[out] interop semaphore handle to the external semaphore" returns: - $X_RESULT_ERROR_INVALID_CONTEXT diff --git a/source/adapters/null/ur_nullddi.cpp b/source/adapters/null/ur_nullddi.cpp index e2c4956c14..91d91d6910 100644 --- a/source/adapters/null/ur_nullddi.cpp +++ b/source/adapters/null/ur_nullddi.cpp @@ -4128,7 +4128,8 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object ur_device_handle_t hDevice, ///< [in] handle of the device object size_t size, ///< [in] size of the external memory - uint32_t fileDescriptor, ///< [in] the file descriptor + ur_exp_interop_memory_desc_t + *interopMemDesc, ///< [in] the interop memory descriptor ur_exp_interop_mem_handle_t *phInteropMem ///< [out] interop memory handle to the external memory ) try { @@ -4138,7 +4139,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( auto pfnImportOpaqueFDExp = d_context.urDdiTable.BindlessImagesExp.pfnImportOpaqueFDExp; if (nullptr != pfnImportOpaqueFDExp) { - result = pfnImportOpaqueFDExp(hContext, hDevice, size, fileDescriptor, + result = pfnImportOpaqueFDExp(hContext, hDevice, size, interopMemDesc, phInteropMem); } else { // generic implementation @@ -4213,9 +4214,10 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object ur_device_handle_t hDevice, ///< [in] handle of the device object - uint32_t fileDescriptor, ///< [in] the file descriptor + ur_exp_interop_semaphore_desc_t + *interopSemaphoreDesc, ///< [in] the interop semaphore descriptor ur_exp_interop_semaphore_handle_t * - phInteropSemaphoreHandle ///< [out] interop semaphore handle to the external semaphore + phInteropSemaphore ///< [out] interop semaphore handle to the external semaphore ) try { ur_result_t result = UR_RESULT_SUCCESS; @@ -4225,10 +4227,10 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( .pfnImportExternalSemaphoreOpaqueFDExp; if (nullptr != pfnImportExternalSemaphoreOpaqueFDExp) { result = pfnImportExternalSemaphoreOpaqueFDExp( - hContext, hDevice, fileDescriptor, phInteropSemaphoreHandle); + hContext, hDevice, interopSemaphoreDesc, phInteropSemaphore); } else { // generic implementation - *phInteropSemaphoreHandle = + *phInteropSemaphore = reinterpret_cast( d_context.get()); } diff --git a/source/common/ur_params.hpp b/source/common/ur_params.hpp index c1368c79de..3036d2791e 100644 --- a/source/common/ur_params.hpp +++ b/source/common/ur_params.hpp @@ -389,10 +389,19 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_usm_migration_flag_t value); inline std::ostream &operator<<(std::ostream &os, enum ur_exp_image_copy_flag_t value); +inline std::ostream &operator<<(std::ostream &os, + const struct ur_exp_file_descriptor_t params); +inline std::ostream &operator<<(std::ostream &os, + const struct ur_exp_win32_handle_t params); inline std::ostream & operator<<(std::ostream &os, const struct ur_exp_sampler_mip_properties_t params); inline std::ostream & +operator<<(std::ostream &os, const struct ur_exp_interop_memory_desc_t params); +inline std::ostream & +operator<<(std::ostream &os, + const struct ur_exp_interop_semaphore_desc_t params); +inline std::ostream & operator<<(std::ostream &os, const struct ur_exp_command_buffer_desc_t params); inline std::ostream &operator<<(std::ostream &os, enum ur_exp_peer_info_t value); @@ -1213,6 +1222,22 @@ inline std::ostream &operator<<(std::ostream &os, case UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES: os << "UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES"; break; + + case UR_STRUCTURE_TYPE_EXP_INTEROP_MEMORY_DESC: + os << "UR_STRUCTURE_TYPE_EXP_INTEROP_MEMORY_DESC"; + break; + + case UR_STRUCTURE_TYPE_EXP_INTEROP_SEMAPHORE_DESC: + os << "UR_STRUCTURE_TYPE_EXP_INTEROP_SEMAPHORE_DESC"; + break; + + case UR_STRUCTURE_TYPE_EXP_FILE_DESCRIPTOR: + os << "UR_STRUCTURE_TYPE_EXP_FILE_DESCRIPTOR"; + break; + + case UR_STRUCTURE_TYPE_EXP_WIN32_HANDLE: + os << "UR_STRUCTURE_TYPE_EXP_WIN32_HANDLE"; + break; default: os << "unknown enumerator"; break; @@ -1436,6 +1461,30 @@ inline void serializeStruct(std::ostream &os, const void *ptr) { (const ur_exp_sampler_mip_properties_t *)ptr; ur_params::serializePtr(os, pstruct); } break; + + case UR_STRUCTURE_TYPE_EXP_INTEROP_MEMORY_DESC: { + const ur_exp_interop_memory_desc_t *pstruct = + (const ur_exp_interop_memory_desc_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_EXP_INTEROP_SEMAPHORE_DESC: { + const ur_exp_interop_semaphore_desc_t *pstruct = + (const ur_exp_interop_semaphore_desc_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_EXP_FILE_DESCRIPTOR: { + const ur_exp_file_descriptor_t *pstruct = + (const ur_exp_file_descriptor_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_EXP_WIN32_HANDLE: { + const ur_exp_win32_handle_t *pstruct = + (const ur_exp_win32_handle_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; default: os << "unknown enumerator"; break; @@ -9462,6 +9511,48 @@ inline void serializeFlag(std::ostream &os, } } } // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, + const struct ur_exp_file_descriptor_t params) { + os << "(struct ur_exp_file_descriptor_t){"; + + os << ".stype = "; + + os << (params.stype); + + os << ", "; + os << ".pNext = "; + + ur_params::serializeStruct(os, (params.pNext)); + + os << ", "; + os << ".fd = "; + + os << (params.fd); + + os << "}"; + return os; +} +inline std::ostream &operator<<(std::ostream &os, + const struct ur_exp_win32_handle_t params) { + os << "(struct ur_exp_win32_handle_t){"; + + os << ".stype = "; + + os << (params.stype); + + os << ", "; + os << ".pNext = "; + + ur_params::serializeStruct(os, (params.pNext)); + + os << ", "; + os << ".handle = "; + + ur_params::serializePtr(os, (params.handle)); + + os << "}"; + return os; +} inline std::ostream & operator<<(std::ostream &os, const struct ur_exp_sampler_mip_properties_t params) { @@ -9500,6 +9591,39 @@ operator<<(std::ostream &os, return os; } inline std::ostream & +operator<<(std::ostream &os, const struct ur_exp_interop_memory_desc_t params) { + os << "(struct ur_exp_interop_memory_desc_t){"; + + os << ".stype = "; + + os << (params.stype); + + os << ", "; + os << ".pNext = "; + + ur_params::serializeStruct(os, (params.pNext)); + + os << "}"; + return os; +} +inline std::ostream & +operator<<(std::ostream &os, + const struct ur_exp_interop_semaphore_desc_t params) { + os << "(struct ur_exp_interop_semaphore_desc_t){"; + + os << ".stype = "; + + os << (params.stype); + + os << ", "; + os << ".pNext = "; + + ur_params::serializeStruct(os, (params.pNext)); + + os << "}"; + return os; +} +inline std::ostream & operator<<(std::ostream &os, const struct ur_exp_command_buffer_desc_t params) { os << "(struct ur_exp_command_buffer_desc_t){"; @@ -9959,9 +10083,9 @@ inline std::ostream &operator<<( os << *(params->psize); os << ", "; - os << ".fileDescriptor = "; + os << ".interopMemDesc = "; - os << *(params->pfileDescriptor); + ur_params::serializePtr(os, *(params->pinteropMemDesc)); os << ", "; os << ".phInteropMem = "; @@ -10043,14 +10167,14 @@ operator<<(std::ostream &os, const struct ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".fileDescriptor = "; + os << ".interopSemaphoreDesc = "; - os << *(params->pfileDescriptor); + ur_params::serializePtr(os, *(params->pinteropSemaphoreDesc)); os << ", "; - os << ".phInteropSemaphoreHandle = "; + os << ".phInteropSemaphore = "; - ur_params::serializePtr(os, *(params->pphInteropSemaphoreHandle)); + ur_params::serializePtr(os, *(params->pphInteropSemaphore)); return os; } diff --git a/source/loader/layers/tracing/ur_trcddi.cpp b/source/loader/layers/tracing/ur_trcddi.cpp index b66101ddc6..ff9892fc2e 100644 --- a/source/loader/layers/tracing/ur_trcddi.cpp +++ b/source/loader/layers/tracing/ur_trcddi.cpp @@ -4700,7 +4700,8 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object ur_device_handle_t hDevice, ///< [in] handle of the device object size_t size, ///< [in] size of the external memory - uint32_t fileDescriptor, ///< [in] the file descriptor + ur_exp_interop_memory_desc_t + *interopMemDesc, ///< [in] the interop memory descriptor ur_exp_interop_mem_handle_t *phInteropMem ///< [out] interop memory handle to the external memory ) { @@ -4712,13 +4713,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( } ur_bindless_images_import_opaque_fd_exp_params_t params = { - &hContext, &hDevice, &size, &fileDescriptor, &phInteropMem}; + &hContext, &hDevice, &size, &interopMemDesc, &phInteropMem}; uint64_t instance = context.notify_begin(UR_FUNCTION_BINDLESS_IMAGES_IMPORT_OPAQUE_FD_EXP, "urBindlessImagesImportOpaqueFDExp", ¶ms); ur_result_t result = pfnImportOpaqueFDExp(hContext, hDevice, size, - fileDescriptor, phInteropMem); + interopMemDesc, phInteropMem); context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_IMPORT_OPAQUE_FD_EXP, "urBindlessImagesImportOpaqueFDExp", ¶ms, &result, @@ -4800,9 +4801,10 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object ur_device_handle_t hDevice, ///< [in] handle of the device object - uint32_t fileDescriptor, ///< [in] the file descriptor + ur_exp_interop_semaphore_desc_t + *interopSemaphoreDesc, ///< [in] the interop semaphore descriptor ur_exp_interop_semaphore_handle_t * - phInteropSemaphoreHandle ///< [out] interop semaphore handle to the external semaphore + phInteropSemaphore ///< [out] interop semaphore handle to the external semaphore ) { auto pfnImportExternalSemaphoreOpaqueFDExp = context.urDdiTable.BindlessImagesExp @@ -4813,13 +4815,13 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( } ur_bindless_images_import_external_semaphore_opaque_fd_exp_params_t params = - {&hContext, &hDevice, &fileDescriptor, &phInteropSemaphoreHandle}; + {&hContext, &hDevice, &interopSemaphoreDesc, &phInteropSemaphore}; uint64_t instance = context.notify_begin( UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXP, "urBindlessImagesImportExternalSemaphoreOpaqueFDExp", ¶ms); ur_result_t result = pfnImportExternalSemaphoreOpaqueFDExp( - hContext, hDevice, fileDescriptor, phInteropSemaphoreHandle); + hContext, hDevice, interopSemaphoreDesc, phInteropSemaphore); context.notify_end( UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXP, diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index 5f7290cb24..a1bd38d8ea 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -5955,7 +5955,8 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object ur_device_handle_t hDevice, ///< [in] handle of the device object size_t size, ///< [in] size of the external memory - uint32_t fileDescriptor, ///< [in] the file descriptor + ur_exp_interop_memory_desc_t + *interopMemDesc, ///< [in] the interop memory descriptor ur_exp_interop_mem_handle_t *phInteropMem ///< [out] interop memory handle to the external memory ) { @@ -5975,13 +5976,17 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (NULL == interopMemDesc) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + if (NULL == phInteropMem) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } } ur_result_t result = pfnImportOpaqueFDExp(hContext, hDevice, size, - fileDescriptor, phInteropMem); + interopMemDesc, phInteropMem); return result; } @@ -6086,9 +6091,10 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object ur_device_handle_t hDevice, ///< [in] handle of the device object - uint32_t fileDescriptor, ///< [in] the file descriptor + ur_exp_interop_semaphore_desc_t + *interopSemaphoreDesc, ///< [in] the interop semaphore descriptor ur_exp_interop_semaphore_handle_t * - phInteropSemaphoreHandle ///< [out] interop semaphore handle to the external semaphore + phInteropSemaphore ///< [out] interop semaphore handle to the external semaphore ) { auto pfnImportExternalSemaphoreOpaqueFDExp = context.urDdiTable.BindlessImagesExp @@ -6107,13 +6113,17 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } - if (NULL == phInteropSemaphoreHandle) { + if (NULL == interopSemaphoreDesc) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + + if (NULL == phInteropSemaphore) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } } ur_result_t result = pfnImportExternalSemaphoreOpaqueFDExp( - hContext, hDevice, fileDescriptor, phInteropSemaphoreHandle); + hContext, hDevice, interopSemaphoreDesc, phInteropSemaphore); return result; } diff --git a/source/loader/ur_ldrddi.cpp b/source/loader/ur_ldrddi.cpp index 049f618703..4fd29c846a 100644 --- a/source/loader/ur_ldrddi.cpp +++ b/source/loader/ur_ldrddi.cpp @@ -5725,7 +5725,8 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object ur_device_handle_t hDevice, ///< [in] handle of the device object size_t size, ///< [in] size of the external memory - uint32_t fileDescriptor, ///< [in] the file descriptor + ur_exp_interop_memory_desc_t + *interopMemDesc, ///< [in] the interop memory descriptor ur_exp_interop_mem_handle_t *phInteropMem ///< [out] interop memory handle to the external memory ) { @@ -5746,7 +5747,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( hDevice = reinterpret_cast(hDevice)->handle; // forward to device-platform - result = pfnImportOpaqueFDExp(hContext, hDevice, size, fileDescriptor, + result = pfnImportOpaqueFDExp(hContext, hDevice, size, interopMemDesc, phInteropMem); if (UR_RESULT_SUCCESS != result) { @@ -5856,9 +5857,10 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object ur_device_handle_t hDevice, ///< [in] handle of the device object - uint32_t fileDescriptor, ///< [in] the file descriptor + ur_exp_interop_semaphore_desc_t + *interopSemaphoreDesc, ///< [in] the interop semaphore descriptor ur_exp_interop_semaphore_handle_t * - phInteropSemaphoreHandle ///< [out] interop semaphore handle to the external semaphore + phInteropSemaphore ///< [out] interop semaphore handle to the external semaphore ) { ur_result_t result = UR_RESULT_SUCCESS; @@ -5878,7 +5880,7 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( // forward to device-platform result = pfnImportExternalSemaphoreOpaqueFDExp( - hContext, hDevice, fileDescriptor, phInteropSemaphoreHandle); + hContext, hDevice, interopSemaphoreDesc, phInteropSemaphore); if (UR_RESULT_SUCCESS != result) { return result; @@ -5886,10 +5888,10 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( try { // convert platform handle to loader handle - *phInteropSemaphoreHandle = + *phInteropSemaphore = reinterpret_cast( ur_exp_interop_semaphore_factory.getInstance( - *phInteropSemaphoreHandle, dditable)); + *phInteropSemaphore, dditable)); } catch (std::bad_alloc &) { result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY; } diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index 238079ebe7..4d5c95be98 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -6304,6 +6304,7 @@ ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( /// + `NULL == hContext` /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == interopMemDesc` /// + `NULL == phInteropMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE @@ -6312,7 +6313,8 @@ ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object ur_device_handle_t hDevice, ///< [in] handle of the device object size_t size, ///< [in] size of the external memory - uint32_t fileDescriptor, ///< [in] the file descriptor + ur_exp_interop_memory_desc_t + *interopMemDesc, ///< [in] the interop memory descriptor ur_exp_interop_mem_handle_t *phInteropMem ///< [out] interop memory handle to the external memory ) try { @@ -6322,7 +6324,7 @@ ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnImportOpaqueFDExp(hContext, hDevice, size, fileDescriptor, + return pfnImportOpaqueFDExp(hContext, hDevice, size, interopMemDesc, phInteropMem); } catch (...) { return exceptionToResult(std::current_exception()); @@ -6425,15 +6427,17 @@ ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( /// + `NULL == hContext` /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// + `NULL == phInteropSemaphoreHandle` +/// + `NULL == interopSemaphoreDesc` +/// + `NULL == phInteropSemaphore` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object ur_device_handle_t hDevice, ///< [in] handle of the device object - uint32_t fileDescriptor, ///< [in] the file descriptor + ur_exp_interop_semaphore_desc_t + *interopSemaphoreDesc, ///< [in] the interop semaphore descriptor ur_exp_interop_semaphore_handle_t * - phInteropSemaphoreHandle ///< [out] interop semaphore handle to the external semaphore + phInteropSemaphore ///< [out] interop semaphore handle to the external semaphore ) try { auto pfnImportExternalSemaphoreOpaqueFDExp = ur_lib::context->urDdiTable.BindlessImagesExp @@ -6443,7 +6447,7 @@ ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( } return pfnImportExternalSemaphoreOpaqueFDExp( - hContext, hDevice, fileDescriptor, phInteropSemaphoreHandle); + hContext, hDevice, interopSemaphoreDesc, phInteropSemaphore); } catch (...) { return exceptionToResult(std::current_exception()); } diff --git a/source/ur_api.cpp b/source/ur_api.cpp index 4a9b80695a..082693d32c 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -5326,6 +5326,7 @@ ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( /// + `NULL == hContext` /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == interopMemDesc` /// + `NULL == phInteropMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE @@ -5334,7 +5335,8 @@ ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object ur_device_handle_t hDevice, ///< [in] handle of the device object size_t size, ///< [in] size of the external memory - uint32_t fileDescriptor, ///< [in] the file descriptor + ur_exp_interop_memory_desc_t + *interopMemDesc, ///< [in] the interop memory descriptor ur_exp_interop_mem_handle_t *phInteropMem ///< [out] interop memory handle to the external memory ) { @@ -5424,15 +5426,17 @@ ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( /// + `NULL == hContext` /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// + `NULL == phInteropSemaphoreHandle` +/// + `NULL == interopSemaphoreDesc` +/// + `NULL == phInteropSemaphore` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object ur_device_handle_t hDevice, ///< [in] handle of the device object - uint32_t fileDescriptor, ///< [in] the file descriptor + ur_exp_interop_semaphore_desc_t + *interopSemaphoreDesc, ///< [in] the interop semaphore descriptor ur_exp_interop_semaphore_handle_t * - phInteropSemaphoreHandle ///< [out] interop semaphore handle to the external semaphore + phInteropSemaphore ///< [out] interop semaphore handle to the external semaphore ) { ur_result_t result = UR_RESULT_SUCCESS; return result; From 5aff9441857fb2cb7eb6987fb3ca409656c738b8 Mon Sep 17 00:00:00 2001 From: Igor Chorazewicz Date: Thu, 13 Jul 2023 16:04:38 +0000 Subject: [PATCH 069/104] [umf] return umf_result_t from umfPoolFree This is needed in implementation of urUSMFree. For most cases, the expectation is that the return value from umfPoolFree will be ingnored. --- source/common/umf_helpers.hpp | 2 +- source/common/umf_pools/disjoint_pool.cpp | 10 +++--- source/common/umf_pools/disjoint_pool.hpp | 2 +- .../include/umf/memory_pool.h | 10 ++++-- .../include/umf/memory_pool_ops.h | 2 +- .../src/memory_pool.c | 9 ++--- test/unified_malloc_framework/common/pool.c | 7 ++-- test/unified_malloc_framework/common/pool.hpp | 10 ++++-- .../umf_pools/disjoint_pool.cpp | 36 +++++++++++++++++++ 9 files changed, 68 insertions(+), 20 deletions(-) diff --git a/source/common/umf_helpers.hpp b/source/common/umf_helpers.hpp index 4302ec84a3..4f2113f3d6 100644 --- a/source/common/umf_helpers.hpp +++ b/source/common/umf_helpers.hpp @@ -92,7 +92,7 @@ umf_memory_pool_ops_t poolMakeUniqueOps() { UMF_ASSIGN_OP(ops, T, aligned_malloc, ((void *)nullptr)); UMF_ASSIGN_OP(ops, T, realloc, ((void *)nullptr)); UMF_ASSIGN_OP(ops, T, malloc_usable_size, ((size_t)0)); - UMF_ASSIGN_OP_NORETURN(ops, T, free); + UMF_ASSIGN_OP(ops, T, free, UMF_RESULT_SUCCESS); UMF_ASSIGN_OP(ops, T, get_last_allocation_error, UMF_RESULT_ERROR_UNKNOWN); return ops; diff --git a/source/common/umf_pools/disjoint_pool.cpp b/source/common/umf_pools/disjoint_pool.cpp index 8b1f993355..7efd243f63 100644 --- a/source/common/umf_pools/disjoint_pool.cpp +++ b/source/common/umf_pools/disjoint_pool.cpp @@ -819,7 +819,7 @@ Bucket &DisjointPool::AllocImpl::findBucket(size_t Size) { return *(*It); } -void DisjointPool::AllocImpl::deallocate(void *Ptr, bool &ToPool) try { +void DisjointPool::AllocImpl::deallocate(void *Ptr, bool &ToPool) { auto *SlabPtr = AlignPtrDown(Ptr, SlabMinSize()); // Lock the map on read @@ -862,8 +862,6 @@ void DisjointPool::AllocImpl::deallocate(void *Ptr, bool &ToPool) try { // to some slab with an entry in the map. So we find a slab // but the range checks fail. memoryProviderFree(getMemHandle(), Ptr); -} catch (MemoryProviderError &e) { - umf::getPoolLastStatusRef() = e.code; } void DisjointPool::AllocImpl::printStats(bool &TitlePrinted, @@ -937,7 +935,7 @@ size_t DisjointPool::malloc_usable_size(void *) { return 0; } -void DisjointPool::free(void *ptr) { +enum umf_result_t DisjointPool::free(void *ptr) try { bool ToPool; impl->deallocate(ptr, ToPool); @@ -950,7 +948,9 @@ void DisjointPool::free(void *ptr) { << ", Current pool size for " << MT << " " << impl->getParams().CurPoolSize << "\n"; } - return; + return UMF_RESULT_SUCCESS; +} catch (MemoryProviderError &e) { + return e.code; } enum umf_result_t DisjointPool::get_last_allocation_error() { diff --git a/source/common/umf_pools/disjoint_pool.hpp b/source/common/umf_pools/disjoint_pool.hpp index 48d0ecf51b..a8c9487ef2 100644 --- a/source/common/umf_pools/disjoint_pool.hpp +++ b/source/common/umf_pools/disjoint_pool.hpp @@ -68,7 +68,7 @@ class DisjointPool { void *realloc(void *, size_t); void *aligned_malloc(size_t size, size_t alignment); size_t malloc_usable_size(void *); - void free(void *ptr); + enum umf_result_t free(void *ptr); enum umf_result_t get_last_allocation_error(); DisjointPool(); diff --git a/source/common/unified_malloc_framework/include/umf/memory_pool.h b/source/common/unified_malloc_framework/include/umf/memory_pool.h index 294ce6a46c..8c3c2241b5 100644 --- a/source/common/unified_malloc_framework/include/umf/memory_pool.h +++ b/source/common/unified_malloc_framework/include/umf/memory_pool.h @@ -94,14 +94,20 @@ size_t umfPoolMallocUsableSize(umf_memory_pool_handle_t hPool, void *ptr); /// \brief Frees the memory space of the specified hPool pointed by ptr. /// \param hPool specified memory hPool /// \param ptr pointer to the allocated memory +/// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure. +/// Whether any status other than UMF_RESULT_SUCCESS can be returned +/// depends on the memory provider used by the pool. /// -void umfPoolFree(umf_memory_pool_handle_t hPool, void *ptr); +enum umf_result_t umfPoolFree(umf_memory_pool_handle_t hPool, void *ptr); /// /// \brief Frees the memory space pointed by ptr if it belongs to UMF pool, does nothing otherwise. /// \param ptr pointer to the allocated memory +/// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure. +/// Whether any status other than UMF_RESULT_SUCCESS can be returned +/// depends on the memory provider used by the pool. /// -void umfFree(void *ptr); +enum umf_result_t umfFree(void *ptr); /// /// \brief Retrieve umf_result_t representing the error of the last failed allocation diff --git a/source/common/unified_malloc_framework/include/umf/memory_pool_ops.h b/source/common/unified_malloc_framework/include/umf/memory_pool_ops.h index 03660f695c..b858e5fc04 100644 --- a/source/common/unified_malloc_framework/include/umf/memory_pool_ops.h +++ b/source/common/unified_malloc_framework/include/umf/memory_pool_ops.h @@ -49,7 +49,7 @@ struct umf_memory_pool_ops_t { void *(*realloc)(void *pool, void *ptr, size_t size); void *(*aligned_malloc)(void *pool, size_t size, size_t alignment); size_t (*malloc_usable_size)(void *pool, void *ptr); - void (*free)(void *pool, void *); + enum umf_result_t (*free)(void *pool, void *); enum umf_result_t (*get_last_allocation_error)(void *pool); }; diff --git a/source/common/unified_malloc_framework/src/memory_pool.c b/source/common/unified_malloc_framework/src/memory_pool.c index 9328b3896a..222d785079 100644 --- a/source/common/unified_malloc_framework/src/memory_pool.c +++ b/source/common/unified_malloc_framework/src/memory_pool.c @@ -119,15 +119,16 @@ size_t umfPoolMallocUsableSize(umf_memory_pool_handle_t hPool, void *ptr) { return hPool->ops.malloc_usable_size(hPool->pool_priv, ptr); } -void umfPoolFree(umf_memory_pool_handle_t hPool, void *ptr) { - hPool->ops.free(hPool->pool_priv, ptr); +enum umf_result_t umfPoolFree(umf_memory_pool_handle_t hPool, void *ptr) { + return hPool->ops.free(hPool->pool_priv, ptr); } -void umfFree(void *ptr) { +enum umf_result_t umfFree(void *ptr) { umf_memory_pool_handle_t hPool = umfPoolByPtr(ptr); if (hPool) { - umfPoolFree(hPool, ptr); + return umfPoolFree(hPool, ptr); } + return UMF_RESULT_SUCCESS; } enum umf_result_t diff --git a/test/unified_malloc_framework/common/pool.c b/test/unified_malloc_framework/common/pool.c index 63c8a0c95f..7481557760 100644 --- a/test/unified_malloc_framework/common/pool.c +++ b/test/unified_malloc_framework/common/pool.c @@ -57,9 +57,10 @@ static size_t nullMallocUsableSize(void *pool, void *ptr) { return 0; } -static void nullFree(void *pool, void *ptr) { +static enum umf_result_t nullFree(void *pool, void *ptr) { (void)pool; (void)ptr; + return UMF_RESULT_SUCCESS; } enum umf_result_t nullGetLastStatus(void *pool) { @@ -151,11 +152,11 @@ static size_t traceMallocUsableSize(void *pool, void *ptr) { return umfPoolMallocUsableSize(tracePool->params.hUpstreamPool, ptr); } -static void traceFree(void *pool, void *ptr) { +static enum umf_result_t traceFree(void *pool, void *ptr) { struct tracePool *tracePool = (struct tracePool *)pool; tracePool->params.trace("free"); - umfPoolFree(tracePool->params.hUpstreamPool, ptr); + return umfPoolFree(tracePool->params.hUpstreamPool, ptr); } enum umf_result_t traceGetLastStatus(void *pool) { diff --git a/test/unified_malloc_framework/common/pool.hpp b/test/unified_malloc_framework/common/pool.hpp index 5be080ef33..8eb35ad45c 100644 --- a/test/unified_malloc_framework/common/pool.hpp +++ b/test/unified_malloc_framework/common/pool.hpp @@ -40,7 +40,7 @@ struct pool_base { void *realloc(void *, size_t) noexcept { return nullptr; } void *aligned_malloc(size_t, size_t) noexcept { return nullptr; } size_t malloc_usable_size(void *) noexcept { return 0; } - void free(void *) noexcept {} + enum umf_result_t free(void *) noexcept { return UMF_RESULT_SUCCESS; } enum umf_result_t get_last_allocation_error() noexcept { return UMF_RESULT_SUCCESS; } @@ -71,7 +71,10 @@ struct malloc_pool : public pool_base { return ::malloc_usable_size(ptr); #endif } - void free(void *ptr) noexcept { return ::free(ptr); } + enum umf_result_t free(void *ptr) noexcept { + ::free(ptr); + return UMF_RESULT_SUCCESS; + } }; struct proxy_pool : public pool_base { @@ -108,9 +111,10 @@ struct proxy_pool : public pool_base { // TODO: not supported return 0; } - void free(void *ptr) noexcept { + enum umf_result_t free(void *ptr) noexcept { auto ret = umfMemoryProviderFree(provider, ptr, 0); EXPECT_EQ_NOEXCEPT(ret, UMF_RESULT_SUCCESS); + return ret; } umf_memory_provider_handle_t provider; }; diff --git a/test/unified_malloc_framework/umf_pools/disjoint_pool.cpp b/test/unified_malloc_framework/umf_pools/disjoint_pool.cpp index 607415d14a..5c9584e46d 100644 --- a/test/unified_malloc_framework/umf_pools/disjoint_pool.cpp +++ b/test/unified_malloc_framework/umf_pools/disjoint_pool.cpp @@ -33,6 +33,42 @@ static auto makePool() { return std::move(pool); } +using umf_test::test; + +TEST_F(test, freeErrorPropagation) { + static enum umf_result_t freeReturn = UMF_RESULT_SUCCESS; + struct memory_provider : public umf_test::provider_base { + enum umf_result_t alloc(size_t size, size_t, void **ptr) noexcept { + *ptr = malloc(size); + return UMF_RESULT_SUCCESS; + } + enum umf_result_t free(void *ptr, size_t size) noexcept { + ::free(ptr); + return freeReturn; + } + }; + + auto [ret, providerUnique] = + umf::memoryProviderMakeUnique(); + ASSERT_EQ(ret, UMF_RESULT_SUCCESS); + + auto config = poolConfig(); + config.MaxPoolableSize = + 0; // force all allocations to go to memory provider + + auto [retp, pool] = umf::poolMakeUnique( + {std::move(providerUnique)}, config); + EXPECT_EQ(retp, UMF_RESULT_SUCCESS); + + static constexpr size_t size = 1024; + void *ptr = umfPoolMalloc(pool.get(), size); + + freeReturn = UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC; + auto freeRet = umfFree(ptr); + + EXPECT_EQ(freeRet, freeReturn); +} + INSTANTIATE_TEST_SUITE_P(disjointPoolTests, umfPoolTest, ::testing::Values(makePool)); From e46f3fb25048a3cbb1752823e4829a9296b6f1f0 Mon Sep 17 00:00:00 2001 From: Przemek Malon Date: Fri, 14 Jul 2023 10:39:12 +0100 Subject: [PATCH 070/104] [Bindless][Exp] Update struct and param naming style to adhere to convention --- include/ur.py | 10 ++++---- include/ur_api.h | 22 ++++++++--------- include/ur_ddi.h | 2 +- scripts/core/EXP-BINDLESS-IMAGES.rst | 6 +++-- scripts/core/exp-bindless-images.yml | 10 ++++---- source/adapters/null/ur_nullddi.cpp | 6 ++--- source/common/ur_params.hpp | 24 +++++++++---------- source/loader/layers/tracing/ur_trcddi.cpp | 8 +++---- source/loader/layers/validation/ur_valddi.cpp | 8 +++---- source/loader/ur_ldrddi.cpp | 6 ++--- source/loader/ur_libapi.cpp | 8 +++---- source/ur_api.cpp | 6 ++--- 12 files changed, 59 insertions(+), 57 deletions(-) diff --git a/include/ur.py b/include/ur.py index 39888418af..f6a8d0ab3c 100644 --- a/include/ur.py +++ b/include/ur.py @@ -232,7 +232,7 @@ class ur_structure_type_v(IntEnum): KERNEL_ARG_LOCAL_PROPERTIES = 33 ## ::ur_kernel_arg_local_properties_t EXP_COMMAND_BUFFER_DESC = 0x1000 ## ::ur_exp_command_buffer_desc_t EXP_SAMPLER_MIP_PROPERTIES = 0x2000 ## ::ur_exp_sampler_mip_properties_t - EXP_INTEROP_MEMORY_DESC = 0x2001 ## ::ur_exp_interop_memory_desc_t + EXP_INTEROP_MEM_DESC = 0x2001 ## ::ur_exp_interop_mem_desc_t EXP_INTEROP_SEMAPHORE_DESC = 0x2002 ## ::ur_exp_interop_semaphore_desc_t EXP_FILE_DESCRIPTOR = 0x2003 ## ::ur_exp_file_descriptor_t EXP_WIN32_HANDLE = 0x2004 ## ::ur_exp_win32_handle_t @@ -2143,10 +2143,10 @@ class ur_exp_sampler_mip_properties_t(Structure): ############################################################################### ## @brief Describes an interop memory resource descriptor -class ur_exp_interop_memory_desc_t(Structure): +class ur_exp_interop_mem_desc_t(Structure): _fields_ = [ ("stype", ur_structure_type_t), ## [in] type of this structure, must be - ## ::UR_STRUCTURE_TYPE_EXP_INTEROP_MEMORY_DESC + ## ::UR_STRUCTURE_TYPE_EXP_INTEROP_MEM_DESC ("pNext", c_void_p) ## [in][optional] pointer to extension-specific structure ] @@ -3159,9 +3159,9 @@ class ur_queue_dditable_t(Structure): ############################################################################### ## @brief Function-pointer for urBindlessImagesImportOpaqueFDExp if __use_win_types: - _urBindlessImagesImportOpaqueFDExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, c_size_t, POINTER(ur_exp_interop_memory_desc_t), POINTER(ur_exp_interop_mem_handle_t) ) + _urBindlessImagesImportOpaqueFDExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, c_size_t, POINTER(ur_exp_interop_mem_desc_t), POINTER(ur_exp_interop_mem_handle_t) ) else: - _urBindlessImagesImportOpaqueFDExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, c_size_t, POINTER(ur_exp_interop_memory_desc_t), POINTER(ur_exp_interop_mem_handle_t) ) + _urBindlessImagesImportOpaqueFDExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, c_size_t, POINTER(ur_exp_interop_mem_desc_t), POINTER(ur_exp_interop_mem_handle_t) ) ############################################################################### ## @brief Function-pointer for urBindlessImagesMapExternalArrayExp diff --git a/include/ur_api.h b/include/ur_api.h index de09cda21f..99f4d71872 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -241,7 +241,7 @@ typedef enum ur_structure_type_t { UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES = 33, ///< ::ur_kernel_arg_local_properties_t UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC = 0x1000, ///< ::ur_exp_command_buffer_desc_t UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES = 0x2000, ///< ::ur_exp_sampler_mip_properties_t - UR_STRUCTURE_TYPE_EXP_INTEROP_MEMORY_DESC = 0x2001, ///< ::ur_exp_interop_memory_desc_t + UR_STRUCTURE_TYPE_EXP_INTEROP_MEM_DESC = 0x2001, ///< ::ur_exp_interop_mem_desc_t UR_STRUCTURE_TYPE_EXP_INTEROP_SEMAPHORE_DESC = 0x2002, ///< ::ur_exp_interop_semaphore_desc_t UR_STRUCTURE_TYPE_EXP_FILE_DESCRIPTOR = 0x2003, ///< ::ur_exp_file_descriptor_t UR_STRUCTURE_TYPE_EXP_WIN32_HANDLE = 0x2004, ///< ::ur_exp_win32_handle_t @@ -6662,12 +6662,12 @@ typedef struct ur_exp_sampler_mip_properties_t { /////////////////////////////////////////////////////////////////////////////// /// @brief Describes an interop memory resource descriptor -typedef struct ur_exp_interop_memory_desc_t { +typedef struct ur_exp_interop_mem_desc_t { ur_structure_type_t stype; ///< [in] type of this structure, must be - ///< ::UR_STRUCTURE_TYPE_EXP_INTEROP_MEMORY_DESC + ///< ::UR_STRUCTURE_TYPE_EXP_INTEROP_MEM_DESC const void *pNext; ///< [in][optional] pointer to extension-specific structure -} ur_exp_interop_memory_desc_t; +} ur_exp_interop_mem_desc_t; /////////////////////////////////////////////////////////////////////////////// /// @brief Describes an interop semaphore resource descriptor @@ -7076,18 +7076,18 @@ urBindlessImagesMipmapFreeExp( /// + `NULL == hContext` /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// + `NULL == interopMemDesc` +/// + `NULL == pInteropMemDesc` /// + `NULL == phInteropMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE /// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( - ur_context_handle_t hContext, ///< [in] handle of the context object - ur_device_handle_t hDevice, ///< [in] handle of the device object - size_t size, ///< [in] size of the external memory - ur_exp_interop_memory_desc_t *interopMemDesc, ///< [in] the interop memory descriptor - ur_exp_interop_mem_handle_t *phInteropMem ///< [out] interop memory handle to the external memory + ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object + size_t size, ///< [in] size of the external memory + ur_exp_interop_mem_desc_t *pInteropMemDesc, ///< [in] the interop memory descriptor + ur_exp_interop_mem_handle_t *phInteropMem ///< [out] interop memory handle to the external memory ); /////////////////////////////////////////////////////////////////////////////// @@ -9243,7 +9243,7 @@ typedef struct ur_bindless_images_import_opaque_fd_exp_params_t { ur_context_handle_t *phContext; ur_device_handle_t *phDevice; size_t *psize; - ur_exp_interop_memory_desc_t **pinteropMemDesc; + ur_exp_interop_mem_desc_t **ppInteropMemDesc; ur_exp_interop_mem_handle_t **pphInteropMem; } ur_bindless_images_import_opaque_fd_exp_params_t; diff --git a/include/ur_ddi.h b/include/ur_ddi.h index 66ab7cde74..8856249ed7 100644 --- a/include/ur_ddi.h +++ b/include/ur_ddi.h @@ -1375,7 +1375,7 @@ typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImportOpaqueFDExp_t)( ur_context_handle_t, ur_device_handle_t, size_t, - ur_exp_interop_memory_desc_t *, + ur_exp_interop_mem_desc_t *, ur_exp_interop_mem_handle_t *); /////////////////////////////////////////////////////////////////////////////// diff --git a/scripts/core/EXP-BINDLESS-IMAGES.rst b/scripts/core/EXP-BINDLESS-IMAGES.rst index d7d1bd4486..5a001f2915 100644 --- a/scripts/core/EXP-BINDLESS-IMAGES.rst +++ b/scripts/core/EXP-BINDLESS-IMAGES.rst @@ -64,7 +64,7 @@ Enums ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * ${x}_structure_type_t ${X}_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES - ${X}_STRUCTURE_TYPE_EXP_INTEROP_MEMORY_DESC + ${X}_STRUCTURE_TYPE_EXP_INTEROP_MEM_DESC ${X}_STRUCTURE_TYPE_EXP_INTEROP_SEMAPHORE_DESC ${X}_STRUCTURE_TYPE_EXP_FILE_DESCRIPTOR ${X}_STRUCTURE_TYPE_EXP_WIN32_HANDLE @@ -123,7 +123,7 @@ Types * ${x}_exp_image_mem_handle_t * ${x}_exp_interop_mem_handle_t * ${x}_exp_interop_semaphore_handle_t -* ${x}_exp_interop_memory_desc_t +* ${x}_exp_interop_mem_desc_t * ${x}_exp_interop_semaphore_desc_t * ${x}_exp_file_descriptor_t * ${x}_exp_win32_handle_t @@ -172,6 +172,8 @@ Changelog | 4.0 || Added platform specific interop resource handles. | | || Added and updated to use new interop resource descriptors. | +----------+-------------------------------------------------------------+ +| 5.0 | Update interop struct and func param names to adhere to convention. | ++----------+-------------------------------------------------------------+ Contributors -------------------------------------------------------------------------------- diff --git a/scripts/core/exp-bindless-images.yml b/scripts/core/exp-bindless-images.yml index a84d571807..993c95add8 100644 --- a/scripts/core/exp-bindless-images.yml +++ b/scripts/core/exp-bindless-images.yml @@ -86,8 +86,8 @@ etors: - name: EXP_SAMPLER_MIP_PROPERTIES desc: $x_exp_sampler_mip_properties_t value: "0x2000" - - name: EXP_INTEROP_MEMORY_DESC - desc: $x_exp_interop_memory_desc_t + - name: EXP_INTEROP_MEM_DESC + desc: $x_exp_interop_mem_desc_t value: "0x2001" - name: EXP_INTEROP_SEMAPHORE_DESC desc: $x_exp_interop_semaphore_desc_t @@ -166,7 +166,7 @@ members: type: struct desc: "Describes an interop memory resource descriptor" class: $xBindlessImages -name: $x_exp_interop_memory_desc_t +name: $x_exp_interop_mem_desc_t base: $x_base_desc_t members: [] --- #-------------------------------------------------------------------------- @@ -562,8 +562,8 @@ params: - type: size_t name: size desc: "[in] size of the external memory" - - type: $x_exp_interop_memory_desc_t* - name: interopMemDesc + - type: $x_exp_interop_mem_desc_t* + name: pInteropMemDesc desc: "[in] the interop memory descriptor" - type: $x_exp_interop_mem_handle_t* name: phInteropMem diff --git a/source/adapters/null/ur_nullddi.cpp b/source/adapters/null/ur_nullddi.cpp index 91d91d6910..e2d80641cc 100644 --- a/source/adapters/null/ur_nullddi.cpp +++ b/source/adapters/null/ur_nullddi.cpp @@ -4128,8 +4128,8 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object ur_device_handle_t hDevice, ///< [in] handle of the device object size_t size, ///< [in] size of the external memory - ur_exp_interop_memory_desc_t - *interopMemDesc, ///< [in] the interop memory descriptor + ur_exp_interop_mem_desc_t + *pInteropMemDesc, ///< [in] the interop memory descriptor ur_exp_interop_mem_handle_t *phInteropMem ///< [out] interop memory handle to the external memory ) try { @@ -4139,7 +4139,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( auto pfnImportOpaqueFDExp = d_context.urDdiTable.BindlessImagesExp.pfnImportOpaqueFDExp; if (nullptr != pfnImportOpaqueFDExp) { - result = pfnImportOpaqueFDExp(hContext, hDevice, size, interopMemDesc, + result = pfnImportOpaqueFDExp(hContext, hDevice, size, pInteropMemDesc, phInteropMem); } else { // generic implementation diff --git a/source/common/ur_params.hpp b/source/common/ur_params.hpp index 3036d2791e..c9f0cf0201 100644 --- a/source/common/ur_params.hpp +++ b/source/common/ur_params.hpp @@ -396,8 +396,8 @@ inline std::ostream &operator<<(std::ostream &os, inline std::ostream & operator<<(std::ostream &os, const struct ur_exp_sampler_mip_properties_t params); -inline std::ostream & -operator<<(std::ostream &os, const struct ur_exp_interop_memory_desc_t params); +inline std::ostream &operator<<(std::ostream &os, + const struct ur_exp_interop_mem_desc_t params); inline std::ostream & operator<<(std::ostream &os, const struct ur_exp_interop_semaphore_desc_t params); @@ -1223,8 +1223,8 @@ inline std::ostream &operator<<(std::ostream &os, os << "UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES"; break; - case UR_STRUCTURE_TYPE_EXP_INTEROP_MEMORY_DESC: - os << "UR_STRUCTURE_TYPE_EXP_INTEROP_MEMORY_DESC"; + case UR_STRUCTURE_TYPE_EXP_INTEROP_MEM_DESC: + os << "UR_STRUCTURE_TYPE_EXP_INTEROP_MEM_DESC"; break; case UR_STRUCTURE_TYPE_EXP_INTEROP_SEMAPHORE_DESC: @@ -1462,9 +1462,9 @@ inline void serializeStruct(std::ostream &os, const void *ptr) { ur_params::serializePtr(os, pstruct); } break; - case UR_STRUCTURE_TYPE_EXP_INTEROP_MEMORY_DESC: { - const ur_exp_interop_memory_desc_t *pstruct = - (const ur_exp_interop_memory_desc_t *)ptr; + case UR_STRUCTURE_TYPE_EXP_INTEROP_MEM_DESC: { + const ur_exp_interop_mem_desc_t *pstruct = + (const ur_exp_interop_mem_desc_t *)ptr; ur_params::serializePtr(os, pstruct); } break; @@ -9590,9 +9590,9 @@ operator<<(std::ostream &os, os << "}"; return os; } -inline std::ostream & -operator<<(std::ostream &os, const struct ur_exp_interop_memory_desc_t params) { - os << "(struct ur_exp_interop_memory_desc_t){"; +inline std::ostream &operator<<(std::ostream &os, + const struct ur_exp_interop_mem_desc_t params) { + os << "(struct ur_exp_interop_mem_desc_t){"; os << ".stype = "; @@ -10083,9 +10083,9 @@ inline std::ostream &operator<<( os << *(params->psize); os << ", "; - os << ".interopMemDesc = "; + os << ".pInteropMemDesc = "; - ur_params::serializePtr(os, *(params->pinteropMemDesc)); + ur_params::serializePtr(os, *(params->ppInteropMemDesc)); os << ", "; os << ".phInteropMem = "; diff --git a/source/loader/layers/tracing/ur_trcddi.cpp b/source/loader/layers/tracing/ur_trcddi.cpp index ff9892fc2e..f0ccc8fea9 100644 --- a/source/loader/layers/tracing/ur_trcddi.cpp +++ b/source/loader/layers/tracing/ur_trcddi.cpp @@ -4700,8 +4700,8 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object ur_device_handle_t hDevice, ///< [in] handle of the device object size_t size, ///< [in] size of the external memory - ur_exp_interop_memory_desc_t - *interopMemDesc, ///< [in] the interop memory descriptor + ur_exp_interop_mem_desc_t + *pInteropMemDesc, ///< [in] the interop memory descriptor ur_exp_interop_mem_handle_t *phInteropMem ///< [out] interop memory handle to the external memory ) { @@ -4713,13 +4713,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( } ur_bindless_images_import_opaque_fd_exp_params_t params = { - &hContext, &hDevice, &size, &interopMemDesc, &phInteropMem}; + &hContext, &hDevice, &size, &pInteropMemDesc, &phInteropMem}; uint64_t instance = context.notify_begin(UR_FUNCTION_BINDLESS_IMAGES_IMPORT_OPAQUE_FD_EXP, "urBindlessImagesImportOpaqueFDExp", ¶ms); ur_result_t result = pfnImportOpaqueFDExp(hContext, hDevice, size, - interopMemDesc, phInteropMem); + pInteropMemDesc, phInteropMem); context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_IMPORT_OPAQUE_FD_EXP, "urBindlessImagesImportOpaqueFDExp", ¶ms, &result, diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index a1bd38d8ea..a79756d755 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -5955,8 +5955,8 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object ur_device_handle_t hDevice, ///< [in] handle of the device object size_t size, ///< [in] size of the external memory - ur_exp_interop_memory_desc_t - *interopMemDesc, ///< [in] the interop memory descriptor + ur_exp_interop_mem_desc_t + *pInteropMemDesc, ///< [in] the interop memory descriptor ur_exp_interop_mem_handle_t *phInteropMem ///< [out] interop memory handle to the external memory ) { @@ -5976,7 +5976,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } - if (NULL == interopMemDesc) { + if (NULL == pInteropMemDesc) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } @@ -5986,7 +5986,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( } ur_result_t result = pfnImportOpaqueFDExp(hContext, hDevice, size, - interopMemDesc, phInteropMem); + pInteropMemDesc, phInteropMem); return result; } diff --git a/source/loader/ur_ldrddi.cpp b/source/loader/ur_ldrddi.cpp index 4fd29c846a..7ae7865d0c 100644 --- a/source/loader/ur_ldrddi.cpp +++ b/source/loader/ur_ldrddi.cpp @@ -5725,8 +5725,8 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object ur_device_handle_t hDevice, ///< [in] handle of the device object size_t size, ///< [in] size of the external memory - ur_exp_interop_memory_desc_t - *interopMemDesc, ///< [in] the interop memory descriptor + ur_exp_interop_mem_desc_t + *pInteropMemDesc, ///< [in] the interop memory descriptor ur_exp_interop_mem_handle_t *phInteropMem ///< [out] interop memory handle to the external memory ) { @@ -5747,7 +5747,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( hDevice = reinterpret_cast(hDevice)->handle; // forward to device-platform - result = pfnImportOpaqueFDExp(hContext, hDevice, size, interopMemDesc, + result = pfnImportOpaqueFDExp(hContext, hDevice, size, pInteropMemDesc, phInteropMem); if (UR_RESULT_SUCCESS != result) { diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index 4d5c95be98..95077120e8 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -6304,7 +6304,7 @@ ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( /// + `NULL == hContext` /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// + `NULL == interopMemDesc` +/// + `NULL == pInteropMemDesc` /// + `NULL == phInteropMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE @@ -6313,8 +6313,8 @@ ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object ur_device_handle_t hDevice, ///< [in] handle of the device object size_t size, ///< [in] size of the external memory - ur_exp_interop_memory_desc_t - *interopMemDesc, ///< [in] the interop memory descriptor + ur_exp_interop_mem_desc_t + *pInteropMemDesc, ///< [in] the interop memory descriptor ur_exp_interop_mem_handle_t *phInteropMem ///< [out] interop memory handle to the external memory ) try { @@ -6324,7 +6324,7 @@ ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnImportOpaqueFDExp(hContext, hDevice, size, interopMemDesc, + return pfnImportOpaqueFDExp(hContext, hDevice, size, pInteropMemDesc, phInteropMem); } catch (...) { return exceptionToResult(std::current_exception()); diff --git a/source/ur_api.cpp b/source/ur_api.cpp index 082693d32c..da5d63e087 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -5326,7 +5326,7 @@ ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( /// + `NULL == hContext` /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// + `NULL == interopMemDesc` +/// + `NULL == pInteropMemDesc` /// + `NULL == phInteropMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE @@ -5335,8 +5335,8 @@ ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object ur_device_handle_t hDevice, ///< [in] handle of the device object size_t size, ///< [in] size of the external memory - ur_exp_interop_memory_desc_t - *interopMemDesc, ///< [in] the interop memory descriptor + ur_exp_interop_mem_desc_t + *pInteropMemDesc, ///< [in] the interop memory descriptor ur_exp_interop_mem_handle_t *phInteropMem ///< [out] interop memory handle to the external memory ) { From 1b138240de5db62aa66d2993ee553472354fafba Mon Sep 17 00:00:00 2001 From: Przemek Malon Date: Fri, 14 Jul 2023 12:02:16 +0100 Subject: [PATCH 071/104] [Bindless][Exp] Fix semaphore import function parameter name - Pointer parameter now correctly prefixed with `p` --- include/ur_api.h | 12 ++++++------ scripts/core/EXP-BINDLESS-IMAGES.rst | 2 ++ scripts/core/exp-bindless-images.yml | 2 +- source/adapters/null/ur_nullddi.cpp | 4 ++-- source/common/ur_params.hpp | 4 ++-- source/loader/layers/tracing/ur_trcddi.cpp | 6 +++--- source/loader/layers/validation/ur_valddi.cpp | 6 +++--- source/loader/ur_ldrddi.cpp | 4 ++-- source/loader/ur_libapi.cpp | 6 +++--- source/ur_api.cpp | 4 ++-- 10 files changed, 26 insertions(+), 24 deletions(-) diff --git a/include/ur_api.h b/include/ur_api.h index 99f4d71872..ef34cc39ce 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -7164,16 +7164,16 @@ urBindlessImagesReleaseInteropExp( /// + `NULL == hContext` /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// + `NULL == interopSemaphoreDesc` +/// + `NULL == pInteropSemaphoreDesc` /// + `NULL == phInteropSemaphore` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( - ur_context_handle_t hContext, ///< [in] handle of the context object - ur_device_handle_t hDevice, ///< [in] handle of the device object - ur_exp_interop_semaphore_desc_t *interopSemaphoreDesc, ///< [in] the interop semaphore descriptor - ur_exp_interop_semaphore_handle_t *phInteropSemaphore ///< [out] interop semaphore handle to the external semaphore + ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object + ur_exp_interop_semaphore_desc_t *pInteropSemaphoreDesc, ///< [in] the interop semaphore descriptor + ur_exp_interop_semaphore_handle_t *phInteropSemaphore ///< [out] interop semaphore handle to the external semaphore ); /////////////////////////////////////////////////////////////////////////////// @@ -9277,7 +9277,7 @@ typedef struct ur_bindless_images_release_interop_exp_params_t { typedef struct ur_bindless_images_import_external_semaphore_opaque_fd_exp_params_t { ur_context_handle_t *phContext; ur_device_handle_t *phDevice; - ur_exp_interop_semaphore_desc_t **pinteropSemaphoreDesc; + ur_exp_interop_semaphore_desc_t **ppInteropSemaphoreDesc; ur_exp_interop_semaphore_handle_t **pphInteropSemaphore; } ur_bindless_images_import_external_semaphore_opaque_fd_exp_params_t; diff --git a/scripts/core/EXP-BINDLESS-IMAGES.rst b/scripts/core/EXP-BINDLESS-IMAGES.rst index 5a001f2915..071fe799fd 100644 --- a/scripts/core/EXP-BINDLESS-IMAGES.rst +++ b/scripts/core/EXP-BINDLESS-IMAGES.rst @@ -174,6 +174,8 @@ Changelog +----------+-------------------------------------------------------------+ | 5.0 | Update interop struct and func param names to adhere to convention. | +----------+-------------------------------------------------------------+ +| 6.0 | Fix semaphore import function parameter name. | ++----------+-------------------------------------------------------------+ Contributors -------------------------------------------------------------------------------- diff --git a/scripts/core/exp-bindless-images.yml b/scripts/core/exp-bindless-images.yml index 993c95add8..cbb194849f 100644 --- a/scripts/core/exp-bindless-images.yml +++ b/scripts/core/exp-bindless-images.yml @@ -642,7 +642,7 @@ params: name: hDevice desc: "[in] handle of the device object" - type: $x_exp_interop_semaphore_desc_t* - name: interopSemaphoreDesc + name: pInteropSemaphoreDesc desc: "[in] the interop semaphore descriptor" - type: $x_exp_interop_semaphore_handle_t* name: phInteropSemaphore diff --git a/source/adapters/null/ur_nullddi.cpp b/source/adapters/null/ur_nullddi.cpp index e2d80641cc..3971e9188b 100644 --- a/source/adapters/null/ur_nullddi.cpp +++ b/source/adapters/null/ur_nullddi.cpp @@ -4215,7 +4215,7 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_semaphore_desc_t - *interopSemaphoreDesc, ///< [in] the interop semaphore descriptor + *pInteropSemaphoreDesc, ///< [in] the interop semaphore descriptor ur_exp_interop_semaphore_handle_t * phInteropSemaphore ///< [out] interop semaphore handle to the external semaphore ) try { @@ -4227,7 +4227,7 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( .pfnImportExternalSemaphoreOpaqueFDExp; if (nullptr != pfnImportExternalSemaphoreOpaqueFDExp) { result = pfnImportExternalSemaphoreOpaqueFDExp( - hContext, hDevice, interopSemaphoreDesc, phInteropSemaphore); + hContext, hDevice, pInteropSemaphoreDesc, phInteropSemaphore); } else { // generic implementation *phInteropSemaphore = diff --git a/source/common/ur_params.hpp b/source/common/ur_params.hpp index c9f0cf0201..fd20752dad 100644 --- a/source/common/ur_params.hpp +++ b/source/common/ur_params.hpp @@ -10167,9 +10167,9 @@ operator<<(std::ostream &os, const struct ur_params::serializePtr(os, *(params->phDevice)); os << ", "; - os << ".interopSemaphoreDesc = "; + os << ".pInteropSemaphoreDesc = "; - ur_params::serializePtr(os, *(params->pinteropSemaphoreDesc)); + ur_params::serializePtr(os, *(params->ppInteropSemaphoreDesc)); os << ", "; os << ".phInteropSemaphore = "; diff --git a/source/loader/layers/tracing/ur_trcddi.cpp b/source/loader/layers/tracing/ur_trcddi.cpp index f0ccc8fea9..f951d0280e 100644 --- a/source/loader/layers/tracing/ur_trcddi.cpp +++ b/source/loader/layers/tracing/ur_trcddi.cpp @@ -4802,7 +4802,7 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_semaphore_desc_t - *interopSemaphoreDesc, ///< [in] the interop semaphore descriptor + *pInteropSemaphoreDesc, ///< [in] the interop semaphore descriptor ur_exp_interop_semaphore_handle_t * phInteropSemaphore ///< [out] interop semaphore handle to the external semaphore ) { @@ -4815,13 +4815,13 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( } ur_bindless_images_import_external_semaphore_opaque_fd_exp_params_t params = - {&hContext, &hDevice, &interopSemaphoreDesc, &phInteropSemaphore}; + {&hContext, &hDevice, &pInteropSemaphoreDesc, &phInteropSemaphore}; uint64_t instance = context.notify_begin( UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXP, "urBindlessImagesImportExternalSemaphoreOpaqueFDExp", ¶ms); ur_result_t result = pfnImportExternalSemaphoreOpaqueFDExp( - hContext, hDevice, interopSemaphoreDesc, phInteropSemaphore); + hContext, hDevice, pInteropSemaphoreDesc, phInteropSemaphore); context.notify_end( UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXP, diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index a79756d755..ee7f665783 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -6092,7 +6092,7 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_semaphore_desc_t - *interopSemaphoreDesc, ///< [in] the interop semaphore descriptor + *pInteropSemaphoreDesc, ///< [in] the interop semaphore descriptor ur_exp_interop_semaphore_handle_t * phInteropSemaphore ///< [out] interop semaphore handle to the external semaphore ) { @@ -6113,7 +6113,7 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } - if (NULL == interopSemaphoreDesc) { + if (NULL == pInteropSemaphoreDesc) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } @@ -6123,7 +6123,7 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( } ur_result_t result = pfnImportExternalSemaphoreOpaqueFDExp( - hContext, hDevice, interopSemaphoreDesc, phInteropSemaphore); + hContext, hDevice, pInteropSemaphoreDesc, phInteropSemaphore); return result; } diff --git a/source/loader/ur_ldrddi.cpp b/source/loader/ur_ldrddi.cpp index 7ae7865d0c..ecd56c1f46 100644 --- a/source/loader/ur_ldrddi.cpp +++ b/source/loader/ur_ldrddi.cpp @@ -5858,7 +5858,7 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_semaphore_desc_t - *interopSemaphoreDesc, ///< [in] the interop semaphore descriptor + *pInteropSemaphoreDesc, ///< [in] the interop semaphore descriptor ur_exp_interop_semaphore_handle_t * phInteropSemaphore ///< [out] interop semaphore handle to the external semaphore ) { @@ -5880,7 +5880,7 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( // forward to device-platform result = pfnImportExternalSemaphoreOpaqueFDExp( - hContext, hDevice, interopSemaphoreDesc, phInteropSemaphore); + hContext, hDevice, pInteropSemaphoreDesc, phInteropSemaphore); if (UR_RESULT_SUCCESS != result) { return result; diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index 95077120e8..ee8914ccba 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -6427,7 +6427,7 @@ ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( /// + `NULL == hContext` /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// + `NULL == interopSemaphoreDesc` +/// + `NULL == pInteropSemaphoreDesc` /// + `NULL == phInteropSemaphore` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE @@ -6435,7 +6435,7 @@ ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_semaphore_desc_t - *interopSemaphoreDesc, ///< [in] the interop semaphore descriptor + *pInteropSemaphoreDesc, ///< [in] the interop semaphore descriptor ur_exp_interop_semaphore_handle_t * phInteropSemaphore ///< [out] interop semaphore handle to the external semaphore ) try { @@ -6447,7 +6447,7 @@ ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( } return pfnImportExternalSemaphoreOpaqueFDExp( - hContext, hDevice, interopSemaphoreDesc, phInteropSemaphore); + hContext, hDevice, pInteropSemaphoreDesc, phInteropSemaphore); } catch (...) { return exceptionToResult(std::current_exception()); } diff --git a/source/ur_api.cpp b/source/ur_api.cpp index da5d63e087..c5fb0d48c5 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -5426,7 +5426,7 @@ ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( /// + `NULL == hContext` /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// + `NULL == interopSemaphoreDesc` +/// + `NULL == pInteropSemaphoreDesc` /// + `NULL == phInteropSemaphore` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE @@ -5434,7 +5434,7 @@ ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_semaphore_desc_t - *interopSemaphoreDesc, ///< [in] the interop semaphore descriptor + *pInteropSemaphoreDesc, ///< [in] the interop semaphore descriptor ur_exp_interop_semaphore_handle_t * phInteropSemaphore ///< [out] interop semaphore handle to the external semaphore ) { From dd0a598035ca7821815daac2310a3df223b78cbf Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Fri, 14 Jul 2023 13:17:58 +0100 Subject: [PATCH 072/104] [UR] Add nocheck to native handle types --- include/ur_api.h | 32 +++----- scripts/core/context.yml | 2 +- scripts/core/device.yml | 2 +- scripts/core/event.yml | 2 +- scripts/core/kernel.yml | 2 +- scripts/core/memory.yml | 4 +- scripts/core/platform.yml | 2 +- scripts/core/program.yml | 2 +- scripts/core/queue.yml | 2 +- scripts/core/sampler.yml | 2 +- source/adapters/null/ur_nullddi.cpp | 40 ++++++---- source/loader/layers/tracing/ur_trcddi.cpp | 40 ++++++---- source/loader/layers/validation/ur_valddi.cpp | 80 ++++++------------- source/loader/ur_ldrddi.cpp | 40 ++++++---- source/loader/ur_libapi.cpp | 52 ++++++------ source/ur_api.cpp | 52 ++++++------ 16 files changed, 158 insertions(+), 198 deletions(-) diff --git a/include/ur_api.h b/include/ur_api.h index 99f4d71872..e559deffc8 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -758,13 +758,11 @@ typedef struct ur_platform_native_properties_t { /// - ::UR_RESULT_ERROR_UNINITIALIZED /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC -/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativePlatform` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phPlatform` UR_APIEXPORT ur_result_t UR_APICALL urPlatformCreateWithNativeHandle( - ur_native_handle_t hNativePlatform, ///< [in] the native handle of the platform. + ur_native_handle_t hNativePlatform, ///< [in][nocheck] the native handle of the platform. const ur_platform_native_properties_t *pProperties, ///< [in][optional] pointer to native platform properties struct. ur_platform_handle_t *phPlatform ///< [out] pointer to the handle of the platform object created. ); @@ -1564,13 +1562,12 @@ typedef struct ur_device_native_properties_t { /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeDevice` /// + `NULL == hPlatform` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phDevice` UR_APIEXPORT ur_result_t UR_APICALL urDeviceCreateWithNativeHandle( - ur_native_handle_t hNativeDevice, ///< [in] the native handle of the device. + ur_native_handle_t hNativeDevice, ///< [in][nocheck] the native handle of the device. ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance const ur_device_native_properties_t *pProperties, ///< [in][optional] pointer to native device properties struct. ur_device_handle_t *phDevice ///< [out] pointer to the handle of the device object created. @@ -1899,14 +1896,12 @@ typedef struct ur_context_native_properties_t { /// - ::UR_RESULT_ERROR_UNINITIALIZED /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC -/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phDevices` /// + `NULL == phContext` UR_APIEXPORT ur_result_t UR_APICALL urContextCreateWithNativeHandle( - ur_native_handle_t hNativeContext, ///< [in] the native handle of the context. + ur_native_handle_t hNativeContext, ///< [in][nocheck] the native handle of the context. uint32_t numDevices, ///< [in] number of devices associated with the context const ur_device_handle_t *phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context const ur_context_native_properties_t *pProperties, ///< [in][optional] pointer to native context properties struct @@ -2377,13 +2372,12 @@ typedef struct ur_mem_native_properties_t { /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeMem` /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phMem` UR_APIEXPORT ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( - ur_native_handle_t hNativeMem, ///< [in] the native handle to the memory. + ur_native_handle_t hNativeMem, ///< [in][nocheck] the native handle to the memory. ur_context_handle_t hContext, ///< [in] handle of the context object. const ur_mem_native_properties_t *pProperties, ///< [in][optional] pointer to native memory creation properties. ur_mem_handle_t *phMem ///< [out] pointer to handle of buffer memory object created. @@ -2403,7 +2397,6 @@ urMemBufferCreateWithNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeMem` /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pImageFormat` @@ -2411,7 +2404,7 @@ urMemBufferCreateWithNativeHandle( /// + `NULL == phMem` UR_APIEXPORT ur_result_t UR_APICALL urMemImageCreateWithNativeHandle( - ur_native_handle_t hNativeMem, ///< [in] the native handle to the memory. + ur_native_handle_t hNativeMem, ///< [in][nocheck] the native handle to the memory. ur_context_handle_t hContext, ///< [in] handle of the context object. const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification. const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description. @@ -2740,13 +2733,12 @@ typedef struct ur_sampler_native_properties_t { /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeSampler` /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phSampler` UR_APIEXPORT ur_result_t UR_APICALL urSamplerCreateWithNativeHandle( - ur_native_handle_t hNativeSampler, ///< [in] the native handle of the sampler. + ur_native_handle_t hNativeSampler, ///< [in][nocheck] the native handle of the sampler. ur_context_handle_t hContext, ///< [in] handle of the context object const ur_sampler_native_properties_t *pProperties, ///< [in][optional] pointer to native sampler properties struct. ur_sampler_handle_t *phSampler ///< [out] pointer to the handle of the sampler object created. @@ -4073,13 +4065,12 @@ typedef struct ur_program_native_properties_t { /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeProgram` /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phProgram` UR_APIEXPORT ur_result_t UR_APICALL urProgramCreateWithNativeHandle( - ur_native_handle_t hNativeProgram, ///< [in] the native handle of the program. + ur_native_handle_t hNativeProgram, ///< [in][nocheck] the native handle of the program. ur_context_handle_t hContext, ///< [in] handle of the context instance const ur_program_native_properties_t *pProperties, ///< [in][optional] pointer to native program properties struct. ur_program_handle_t *phProgram ///< [out] pointer to the handle of the program object created. @@ -4653,14 +4644,13 @@ typedef struct ur_kernel_native_properties_t { /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeKernel` /// + `NULL == hContext` /// + `NULL == hProgram` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phKernel` UR_APIEXPORT ur_result_t UR_APICALL urKernelCreateWithNativeHandle( - ur_native_handle_t hNativeKernel, ///< [in] the native handle of the kernel. + ur_native_handle_t hNativeKernel, ///< [in][nocheck] the native handle of the kernel. ur_context_handle_t hContext, ///< [in] handle of the context object ur_program_handle_t hProgram, ///< [in] handle of the program associated with the kernel const ur_kernel_native_properties_t *pProperties, ///< [in][optional] pointer to native kernel properties struct @@ -4946,14 +4936,13 @@ typedef struct ur_queue_native_properties_t { /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeQueue` /// + `NULL == hContext` /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phQueue` UR_APIEXPORT ur_result_t UR_APICALL urQueueCreateWithNativeHandle( - ur_native_handle_t hNativeQueue, ///< [in] the native handle of the queue. + ur_native_handle_t hNativeQueue, ///< [in][nocheck] the native handle of the queue. ur_context_handle_t hContext, ///< [in] handle of the context object ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_queue_native_properties_t *pProperties, ///< [in][optional] pointer to native queue properties struct @@ -5308,13 +5297,12 @@ typedef struct ur_event_native_properties_t { /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeEvent` /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phEvent` UR_APIEXPORT ur_result_t UR_APICALL urEventCreateWithNativeHandle( - ur_native_handle_t hNativeEvent, ///< [in] the native handle of the event. + ur_native_handle_t hNativeEvent, ///< [in][nocheck] the native handle of the event. ur_context_handle_t hContext, ///< [in] handle of the context object const ur_event_native_properties_t *pProperties, ///< [in][optional] pointer to native event properties struct ur_event_handle_t *phEvent ///< [out] pointer to the handle of the event object created. diff --git a/scripts/core/context.yml b/scripts/core/context.yml index 345798a043..d23c7b1320 100644 --- a/scripts/core/context.yml +++ b/scripts/core/context.yml @@ -224,7 +224,7 @@ params: - type: $x_native_handle_t name: hNativeContext desc: | - [in] the native handle of the context. + [in][nocheck] the native handle of the context. - type: uint32_t name: numDevices desc: "[in] number of devices associated with the context" diff --git a/scripts/core/device.yml b/scripts/core/device.yml index 49da5206ed..9efebc5e72 100644 --- a/scripts/core/device.yml +++ b/scripts/core/device.yml @@ -758,7 +758,7 @@ details: params: - type: $x_native_handle_t name: hNativeDevice - desc: "[in] the native handle of the device." + desc: "[in][nocheck] the native handle of the device." - type: $x_platform_handle_t name: hPlatform desc: "[in] handle of the platform instance" diff --git a/scripts/core/event.yml b/scripts/core/event.yml index f38d68b779..7da347dae2 100644 --- a/scripts/core/event.yml +++ b/scripts/core/event.yml @@ -294,7 +294,7 @@ params: - type: $x_native_handle_t name: hNativeEvent desc: | - [in] the native handle of the event. + [in][nocheck] the native handle of the event. - type: $x_context_handle_t name: hContext desc: "[in] handle of the context object" diff --git a/scripts/core/kernel.yml b/scripts/core/kernel.yml index 320410926e..bd444873d5 100644 --- a/scripts/core/kernel.yml +++ b/scripts/core/kernel.yml @@ -515,7 +515,7 @@ params: - type: $x_native_handle_t name: hNativeKernel desc: | - [in] the native handle of the kernel. + [in][nocheck] the native handle of the kernel. - type: $x_context_handle_t name: hContext desc: "[in] handle of the context object" diff --git a/scripts/core/memory.yml b/scripts/core/memory.yml index e8b190143c..5a0d6ed6b5 100644 --- a/scripts/core/memory.yml +++ b/scripts/core/memory.yml @@ -463,7 +463,7 @@ details: params: - type: $x_native_handle_t name: hNativeMem - desc: "[in] the native handle to the memory." + desc: "[in][nocheck] the native handle to the memory." - type: $x_context_handle_t name: hContext desc: "[in] handle of the context object." @@ -487,7 +487,7 @@ details: params: - type: $x_native_handle_t name: hNativeMem - desc: "[in] the native handle to the memory." + desc: "[in][nocheck] the native handle to the memory." - type: $x_context_handle_t name: hContext desc: "[in] handle of the context object." diff --git a/scripts/core/platform.yml b/scripts/core/platform.yml index 69e9ac3665..7188044848 100644 --- a/scripts/core/platform.yml +++ b/scripts/core/platform.yml @@ -188,7 +188,7 @@ details: params: - type: $x_native_handle_t name: hNativePlatform - desc: "[in] the native handle of the platform." + desc: "[in][nocheck] the native handle of the platform." - type: const $x_platform_native_properties_t* name: pProperties desc: "[in][optional] pointer to native platform properties struct." diff --git a/scripts/core/program.yml b/scripts/core/program.yml index ed5117851a..ade7e43541 100644 --- a/scripts/core/program.yml +++ b/scripts/core/program.yml @@ -541,7 +541,7 @@ details: params: - type: $x_native_handle_t name: hNativeProgram - desc: "[in] the native handle of the program." + desc: "[in][nocheck] the native handle of the program." - type: $x_context_handle_t name: hContext desc: "[in] handle of the context instance" diff --git a/scripts/core/queue.yml b/scripts/core/queue.yml index 86d167b7b9..2aa1f936af 100644 --- a/scripts/core/queue.yml +++ b/scripts/core/queue.yml @@ -272,7 +272,7 @@ params: - type: $x_native_handle_t name: hNativeQueue desc: | - [in] the native handle of the queue. + [in][nocheck] the native handle of the queue. - type: $x_context_handle_t name: hContext desc: "[in] handle of the context object" diff --git a/scripts/core/sampler.yml b/scripts/core/sampler.yml index 17719f6c3b..fd3eb6ebbb 100644 --- a/scripts/core/sampler.yml +++ b/scripts/core/sampler.yml @@ -221,7 +221,7 @@ details: params: - type: $x_native_handle_t name: hNativeSampler - desc: "[in] the native handle of the sampler." + desc: "[in][nocheck] the native handle of the sampler." - type: $x_context_handle_t name: hContext desc: "[in] handle of the context object" diff --git a/source/adapters/null/ur_nullddi.cpp b/source/adapters/null/ur_nullddi.cpp index e2d80641cc..3785579c93 100644 --- a/source/adapters/null/ur_nullddi.cpp +++ b/source/adapters/null/ur_nullddi.cpp @@ -167,7 +167,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetNativeHandle( /// @brief Intercept function for urPlatformCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urPlatformCreateWithNativeHandle( ur_native_handle_t - hNativePlatform, ///< [in] the native handle of the platform. + hNativePlatform, ///< [in][nocheck] the native handle of the platform. const ur_platform_native_properties_t * pProperties, ///< [in][optional] pointer to native platform properties struct. ur_platform_handle_t * @@ -445,8 +445,9 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urDeviceCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urDeviceCreateWithNativeHandle( - ur_native_handle_t hNativeDevice, ///< [in] the native handle of the device. - ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance + ur_native_handle_t + hNativeDevice, ///< [in][nocheck] the native handle of the device. + ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance const ur_device_native_properties_t * pProperties, ///< [in][optional] pointer to native device properties struct. ur_device_handle_t @@ -627,7 +628,7 @@ __urdlllocal ur_result_t UR_APICALL urContextGetNativeHandle( /// @brief Intercept function for urContextCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( ur_native_handle_t - hNativeContext, ///< [in] the native handle of the context. + hNativeContext, ///< [in][nocheck] the native handle of the context. uint32_t numDevices, ///< [in] number of devices associated with the context const ur_device_handle_t * phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context @@ -829,8 +830,9 @@ __urdlllocal ur_result_t UR_APICALL urMemGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urMemBufferCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( - ur_native_handle_t hNativeMem, ///< [in] the native handle to the memory. - ur_context_handle_t hContext, ///< [in] handle of the context object. + ur_native_handle_t + hNativeMem, ///< [in][nocheck] the native handle to the memory. + ur_context_handle_t hContext, ///< [in] handle of the context object. const ur_mem_native_properties_t * pProperties, ///< [in][optional] pointer to native memory creation properties. ur_mem_handle_t @@ -857,8 +859,9 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urMemImageCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urMemImageCreateWithNativeHandle( - ur_native_handle_t hNativeMem, ///< [in] the native handle to the memory. - ur_context_handle_t hContext, ///< [in] handle of the context object. + ur_native_handle_t + hNativeMem, ///< [in][nocheck] the native handle to the memory. + ur_context_handle_t hContext, ///< [in] handle of the context object. const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification. const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description. @@ -1073,7 +1076,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetNativeHandle( /// @brief Intercept function for urSamplerCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urSamplerCreateWithNativeHandle( ur_native_handle_t - hNativeSampler, ///< [in] the native handle of the sampler. + hNativeSampler, ///< [in][nocheck] the native handle of the sampler. ur_context_handle_t hContext, ///< [in] handle of the context object const ur_sampler_native_properties_t * pProperties, ///< [in][optional] pointer to native sampler properties struct. @@ -1919,7 +1922,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetNativeHandle( /// @brief Intercept function for urProgramCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urProgramCreateWithNativeHandle( ur_native_handle_t - hNativeProgram, ///< [in] the native handle of the program. + hNativeProgram, ///< [in][nocheck] the native handle of the program. ur_context_handle_t hContext, ///< [in] handle of the context instance const ur_program_native_properties_t * pProperties, ///< [in][optional] pointer to native program properties struct. @@ -2307,8 +2310,9 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urKernelCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urKernelCreateWithNativeHandle( - ur_native_handle_t hNativeKernel, ///< [in] the native handle of the kernel. - ur_context_handle_t hContext, ///< [in] handle of the context object + ur_native_handle_t + hNativeKernel, ///< [in][nocheck] the native handle of the kernel. + ur_context_handle_t hContext, ///< [in] handle of the context object ur_program_handle_t hProgram, ///< [in] handle of the program associated with the kernel const ur_kernel_native_properties_t * @@ -2457,9 +2461,10 @@ __urdlllocal ur_result_t UR_APICALL urQueueGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urQueueCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urQueueCreateWithNativeHandle( - ur_native_handle_t hNativeQueue, ///< [in] the native handle of the queue. - ur_context_handle_t hContext, ///< [in] handle of the context object - ur_device_handle_t hDevice, ///< [in] handle of the device object + ur_native_handle_t + hNativeQueue, ///< [in][nocheck] the native handle of the queue. + ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_queue_native_properties_t * pProperties, ///< [in][optional] pointer to native queue properties struct ur_queue_handle_t @@ -2669,8 +2674,9 @@ __urdlllocal ur_result_t UR_APICALL urEventGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urEventCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urEventCreateWithNativeHandle( - ur_native_handle_t hNativeEvent, ///< [in] the native handle of the event. - ur_context_handle_t hContext, ///< [in] handle of the context object + ur_native_handle_t + hNativeEvent, ///< [in][nocheck] the native handle of the event. + ur_context_handle_t hContext, ///< [in] handle of the context object const ur_event_native_properties_t * pProperties, ///< [in][optional] pointer to native event properties struct ur_event_handle_t diff --git a/source/loader/layers/tracing/ur_trcddi.cpp b/source/loader/layers/tracing/ur_trcddi.cpp index f0ccc8fea9..fc5a102e34 100644 --- a/source/loader/layers/tracing/ur_trcddi.cpp +++ b/source/loader/layers/tracing/ur_trcddi.cpp @@ -186,7 +186,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetNativeHandle( /// @brief Intercept function for urPlatformCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urPlatformCreateWithNativeHandle( ur_native_handle_t - hNativePlatform, ///< [in] the native handle of the platform. + hNativePlatform, ///< [in][nocheck] the native handle of the platform. const ur_platform_native_properties_t * pProperties, ///< [in][optional] pointer to native platform properties struct. ur_platform_handle_t * @@ -495,8 +495,9 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urDeviceCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urDeviceCreateWithNativeHandle( - ur_native_handle_t hNativeDevice, ///< [in] the native handle of the device. - ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance + ur_native_handle_t + hNativeDevice, ///< [in][nocheck] the native handle of the device. + ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance const ur_device_native_properties_t * pProperties, ///< [in][optional] pointer to native device properties struct. ur_device_handle_t @@ -705,7 +706,7 @@ __urdlllocal ur_result_t UR_APICALL urContextGetNativeHandle( /// @brief Intercept function for urContextCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( ur_native_handle_t - hNativeContext, ///< [in] the native handle of the context. + hNativeContext, ///< [in][nocheck] the native handle of the context. uint32_t numDevices, ///< [in] number of devices associated with the context const ur_device_handle_t * phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context @@ -936,8 +937,9 @@ __urdlllocal ur_result_t UR_APICALL urMemGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urMemBufferCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( - ur_native_handle_t hNativeMem, ///< [in] the native handle to the memory. - ur_context_handle_t hContext, ///< [in] handle of the context object. + ur_native_handle_t + hNativeMem, ///< [in][nocheck] the native handle to the memory. + ur_context_handle_t hContext, ///< [in] handle of the context object. const ur_mem_native_properties_t * pProperties, ///< [in][optional] pointer to native memory creation properties. ur_mem_handle_t @@ -969,8 +971,9 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urMemImageCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urMemImageCreateWithNativeHandle( - ur_native_handle_t hNativeMem, ///< [in] the native handle to the memory. - ur_context_handle_t hContext, ///< [in] handle of the context object. + ur_native_handle_t + hNativeMem, ///< [in][nocheck] the native handle to the memory. + ur_context_handle_t hContext, ///< [in] handle of the context object. const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification. const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description. @@ -1214,7 +1217,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetNativeHandle( /// @brief Intercept function for urSamplerCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urSamplerCreateWithNativeHandle( ur_native_handle_t - hNativeSampler, ///< [in] the native handle of the sampler. + hNativeSampler, ///< [in][nocheck] the native handle of the sampler. ur_context_handle_t hContext, ///< [in] handle of the context object const ur_sampler_native_properties_t * pProperties, ///< [in][optional] pointer to native sampler properties struct. @@ -2185,7 +2188,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetNativeHandle( /// @brief Intercept function for urProgramCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urProgramCreateWithNativeHandle( ur_native_handle_t - hNativeProgram, ///< [in] the native handle of the program. + hNativeProgram, ///< [in][nocheck] the native handle of the program. ur_context_handle_t hContext, ///< [in] handle of the context instance const ur_program_native_properties_t * pProperties, ///< [in][optional] pointer to native program properties struct. @@ -2637,8 +2640,9 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urKernelCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urKernelCreateWithNativeHandle( - ur_native_handle_t hNativeKernel, ///< [in] the native handle of the kernel. - ur_context_handle_t hContext, ///< [in] handle of the context object + ur_native_handle_t + hNativeKernel, ///< [in][nocheck] the native handle of the kernel. + ur_context_handle_t hContext, ///< [in] handle of the context object ur_program_handle_t hProgram, ///< [in] handle of the program associated with the kernel const ur_kernel_native_properties_t * @@ -2808,9 +2812,10 @@ __urdlllocal ur_result_t UR_APICALL urQueueGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urQueueCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urQueueCreateWithNativeHandle( - ur_native_handle_t hNativeQueue, ///< [in] the native handle of the queue. - ur_context_handle_t hContext, ///< [in] handle of the context object - ur_device_handle_t hDevice, ///< [in] handle of the device object + ur_native_handle_t + hNativeQueue, ///< [in][nocheck] the native handle of the queue. + ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_queue_native_properties_t * pProperties, ///< [in][optional] pointer to native queue properties struct ur_queue_handle_t @@ -3051,8 +3056,9 @@ __urdlllocal ur_result_t UR_APICALL urEventGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urEventCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urEventCreateWithNativeHandle( - ur_native_handle_t hNativeEvent, ///< [in] the native handle of the event. - ur_context_handle_t hContext, ///< [in] handle of the context object + ur_native_handle_t + hNativeEvent, ///< [in][nocheck] the native handle of the event. + ur_context_handle_t hContext, ///< [in] handle of the context object const ur_event_native_properties_t * pProperties, ///< [in][optional] pointer to native event properties struct ur_event_handle_t diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index a79756d755..fad68064f7 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -201,7 +201,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetNativeHandle( /// @brief Intercept function for urPlatformCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urPlatformCreateWithNativeHandle( ur_native_handle_t - hNativePlatform, ///< [in] the native handle of the platform. + hNativePlatform, ///< [in][nocheck] the native handle of the platform. const ur_platform_native_properties_t * pProperties, ///< [in][optional] pointer to native platform properties struct. ur_platform_handle_t * @@ -215,10 +215,6 @@ __urdlllocal ur_result_t UR_APICALL urPlatformCreateWithNativeHandle( } if (context.enableParameterValidation) { - if (NULL == hNativePlatform) { - return UR_RESULT_ERROR_INVALID_NULL_HANDLE; - } - if (NULL == phPlatform) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } @@ -556,8 +552,9 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urDeviceCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urDeviceCreateWithNativeHandle( - ur_native_handle_t hNativeDevice, ///< [in] the native handle of the device. - ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance + ur_native_handle_t + hNativeDevice, ///< [in][nocheck] the native handle of the device. + ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance const ur_device_native_properties_t * pProperties, ///< [in][optional] pointer to native device properties struct. ur_device_handle_t @@ -571,10 +568,6 @@ __urdlllocal ur_result_t UR_APICALL urDeviceCreateWithNativeHandle( } if (context.enableParameterValidation) { - if (NULL == hNativeDevice) { - return UR_RESULT_ERROR_INVALID_NULL_HANDLE; - } - if (NULL == hPlatform) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -797,7 +790,7 @@ __urdlllocal ur_result_t UR_APICALL urContextGetNativeHandle( /// @brief Intercept function for urContextCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( ur_native_handle_t - hNativeContext, ///< [in] the native handle of the context. + hNativeContext, ///< [in][nocheck] the native handle of the context. uint32_t numDevices, ///< [in] number of devices associated with the context const ur_device_handle_t * phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context @@ -814,10 +807,6 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( } if (context.enableParameterValidation) { - if (NULL == hNativeContext) { - return UR_RESULT_ERROR_INVALID_NULL_HANDLE; - } - if (NULL == phDevices) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } @@ -1113,8 +1102,9 @@ __urdlllocal ur_result_t UR_APICALL urMemGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urMemBufferCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( - ur_native_handle_t hNativeMem, ///< [in] the native handle to the memory. - ur_context_handle_t hContext, ///< [in] handle of the context object. + ur_native_handle_t + hNativeMem, ///< [in][nocheck] the native handle to the memory. + ur_context_handle_t hContext, ///< [in] handle of the context object. const ur_mem_native_properties_t * pProperties, ///< [in][optional] pointer to native memory creation properties. ur_mem_handle_t @@ -1128,10 +1118,6 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( } if (context.enableParameterValidation) { - if (NULL == hNativeMem) { - return UR_RESULT_ERROR_INVALID_NULL_HANDLE; - } - if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -1150,8 +1136,9 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urMemImageCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urMemImageCreateWithNativeHandle( - ur_native_handle_t hNativeMem, ///< [in] the native handle to the memory. - ur_context_handle_t hContext, ///< [in] handle of the context object. + ur_native_handle_t + hNativeMem, ///< [in][nocheck] the native handle to the memory. + ur_context_handle_t hContext, ///< [in] handle of the context object. const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification. const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description. @@ -1168,10 +1155,6 @@ __urdlllocal ur_result_t UR_APICALL urMemImageCreateWithNativeHandle( } if (context.enableParameterValidation) { - if (NULL == hNativeMem) { - return UR_RESULT_ERROR_INVALID_NULL_HANDLE; - } - if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -1475,7 +1458,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetNativeHandle( /// @brief Intercept function for urSamplerCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urSamplerCreateWithNativeHandle( ur_native_handle_t - hNativeSampler, ///< [in] the native handle of the sampler. + hNativeSampler, ///< [in][nocheck] the native handle of the sampler. ur_context_handle_t hContext, ///< [in] handle of the context object const ur_sampler_native_properties_t * pProperties, ///< [in][optional] pointer to native sampler properties struct. @@ -1490,10 +1473,6 @@ __urdlllocal ur_result_t UR_APICALL urSamplerCreateWithNativeHandle( } if (context.enableParameterValidation) { - if (NULL == hNativeSampler) { - return UR_RESULT_ERROR_INVALID_NULL_HANDLE; - } - if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -2698,7 +2677,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetNativeHandle( /// @brief Intercept function for urProgramCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urProgramCreateWithNativeHandle( ur_native_handle_t - hNativeProgram, ///< [in] the native handle of the program. + hNativeProgram, ///< [in][nocheck] the native handle of the program. ur_context_handle_t hContext, ///< [in] handle of the context instance const ur_program_native_properties_t * pProperties, ///< [in][optional] pointer to native program properties struct. @@ -2713,10 +2692,6 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithNativeHandle( } if (context.enableParameterValidation) { - if (NULL == hNativeProgram) { - return UR_RESULT_ERROR_INVALID_NULL_HANDLE; - } - if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -3210,8 +3185,9 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urKernelCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urKernelCreateWithNativeHandle( - ur_native_handle_t hNativeKernel, ///< [in] the native handle of the kernel. - ur_context_handle_t hContext, ///< [in] handle of the context object + ur_native_handle_t + hNativeKernel, ///< [in][nocheck] the native handle of the kernel. + ur_context_handle_t hContext, ///< [in] handle of the context object ur_program_handle_t hProgram, ///< [in] handle of the program associated with the kernel const ur_kernel_native_properties_t * @@ -3227,10 +3203,6 @@ __urdlllocal ur_result_t UR_APICALL urKernelCreateWithNativeHandle( } if (context.enableParameterValidation) { - if (NULL == hNativeKernel) { - return UR_RESULT_ERROR_INVALID_NULL_HANDLE; - } - if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -3425,9 +3397,10 @@ __urdlllocal ur_result_t UR_APICALL urQueueGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urQueueCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urQueueCreateWithNativeHandle( - ur_native_handle_t hNativeQueue, ///< [in] the native handle of the queue. - ur_context_handle_t hContext, ///< [in] handle of the context object - ur_device_handle_t hDevice, ///< [in] handle of the device object + ur_native_handle_t + hNativeQueue, ///< [in][nocheck] the native handle of the queue. + ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_queue_native_properties_t * pProperties, ///< [in][optional] pointer to native queue properties struct ur_queue_handle_t @@ -3441,10 +3414,6 @@ __urdlllocal ur_result_t UR_APICALL urQueueCreateWithNativeHandle( } if (context.enableParameterValidation) { - if (NULL == hNativeQueue) { - return UR_RESULT_ERROR_INVALID_NULL_HANDLE; - } - if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -3709,8 +3678,9 @@ __urdlllocal ur_result_t UR_APICALL urEventGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urEventCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urEventCreateWithNativeHandle( - ur_native_handle_t hNativeEvent, ///< [in] the native handle of the event. - ur_context_handle_t hContext, ///< [in] handle of the context object + ur_native_handle_t + hNativeEvent, ///< [in][nocheck] the native handle of the event. + ur_context_handle_t hContext, ///< [in] handle of the context object const ur_event_native_properties_t * pProperties, ///< [in][optional] pointer to native event properties struct ur_event_handle_t @@ -3724,10 +3694,6 @@ __urdlllocal ur_result_t UR_APICALL urEventCreateWithNativeHandle( } if (context.enableParameterValidation) { - if (NULL == hNativeEvent) { - return UR_RESULT_ERROR_INVALID_NULL_HANDLE; - } - if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } diff --git a/source/loader/ur_ldrddi.cpp b/source/loader/ur_ldrddi.cpp index 7ae7865d0c..2895803990 100644 --- a/source/loader/ur_ldrddi.cpp +++ b/source/loader/ur_ldrddi.cpp @@ -239,7 +239,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetNativeHandle( /// @brief Intercept function for urPlatformCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urPlatformCreateWithNativeHandle( ur_native_handle_t - hNativePlatform, ///< [in] the native handle of the platform. + hNativePlatform, ///< [in][nocheck] the native handle of the platform. const ur_platform_native_properties_t * pProperties, ///< [in][optional] pointer to native platform properties struct. ur_platform_handle_t * @@ -589,8 +589,9 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urDeviceCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urDeviceCreateWithNativeHandle( - ur_native_handle_t hNativeDevice, ///< [in] the native handle of the device. - ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance + ur_native_handle_t + hNativeDevice, ///< [in][nocheck] the native handle of the device. + ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance const ur_device_native_properties_t * pProperties, ///< [in][optional] pointer to native device properties struct. ur_device_handle_t @@ -832,7 +833,7 @@ __urdlllocal ur_result_t UR_APICALL urContextGetNativeHandle( /// @brief Intercept function for urContextCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( ur_native_handle_t - hNativeContext, ///< [in] the native handle of the context. + hNativeContext, ///< [in][nocheck] the native handle of the context. uint32_t numDevices, ///< [in] number of devices associated with the context const ur_device_handle_t * phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context @@ -1122,8 +1123,9 @@ __urdlllocal ur_result_t UR_APICALL urMemGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urMemBufferCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( - ur_native_handle_t hNativeMem, ///< [in] the native handle to the memory. - ur_context_handle_t hContext, ///< [in] handle of the context object. + ur_native_handle_t + hNativeMem, ///< [in][nocheck] the native handle to the memory. + ur_context_handle_t hContext, ///< [in] handle of the context object. const ur_mem_native_properties_t * pProperties, ///< [in][optional] pointer to native memory creation properties. ur_mem_handle_t @@ -1168,8 +1170,9 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urMemImageCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urMemImageCreateWithNativeHandle( - ur_native_handle_t hNativeMem, ///< [in] the native handle to the memory. - ur_context_handle_t hContext, ///< [in] handle of the context object. + ur_native_handle_t + hNativeMem, ///< [in][nocheck] the native handle to the memory. + ur_context_handle_t hContext, ///< [in] handle of the context object. const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification. const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description. @@ -1442,7 +1445,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetNativeHandle( /// @brief Intercept function for urSamplerCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urSamplerCreateWithNativeHandle( ur_native_handle_t - hNativeSampler, ///< [in] the native handle of the sampler. + hNativeSampler, ///< [in][nocheck] the native handle of the sampler. ur_context_handle_t hContext, ///< [in] handle of the context object const ur_sampler_native_properties_t * pProperties, ///< [in][optional] pointer to native sampler properties struct. @@ -2518,7 +2521,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetNativeHandle( /// @brief Intercept function for urProgramCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urProgramCreateWithNativeHandle( ur_native_handle_t - hNativeProgram, ///< [in] the native handle of the program. + hNativeProgram, ///< [in][nocheck] the native handle of the program. ur_context_handle_t hContext, ///< [in] handle of the context instance const ur_program_native_properties_t * pProperties, ///< [in][optional] pointer to native program properties struct. @@ -3001,8 +3004,9 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urKernelCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urKernelCreateWithNativeHandle( - ur_native_handle_t hNativeKernel, ///< [in] the native handle of the kernel. - ur_context_handle_t hContext, ///< [in] handle of the context object + ur_native_handle_t + hNativeKernel, ///< [in][nocheck] the native handle of the kernel. + ur_context_handle_t hContext, ///< [in] handle of the context object ur_program_handle_t hProgram, ///< [in] handle of the program associated with the kernel const ur_kernel_native_properties_t * @@ -3212,9 +3216,10 @@ __urdlllocal ur_result_t UR_APICALL urQueueGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urQueueCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urQueueCreateWithNativeHandle( - ur_native_handle_t hNativeQueue, ///< [in] the native handle of the queue. - ur_context_handle_t hContext, ///< [in] handle of the context object - ur_device_handle_t hDevice, ///< [in] handle of the device object + ur_native_handle_t + hNativeQueue, ///< [in][nocheck] the native handle of the queue. + ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_queue_native_properties_t * pProperties, ///< [in][optional] pointer to native queue properties struct ur_queue_handle_t @@ -3484,8 +3489,9 @@ __urdlllocal ur_result_t UR_APICALL urEventGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urEventCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urEventCreateWithNativeHandle( - ur_native_handle_t hNativeEvent, ///< [in] the native handle of the event. - ur_context_handle_t hContext, ///< [in] handle of the context object + ur_native_handle_t + hNativeEvent, ///< [in][nocheck] the native handle of the event. + ur_context_handle_t hContext, ///< [in] handle of the context object const ur_event_native_properties_t * pProperties, ///< [in][optional] pointer to native event properties struct ur_event_handle_t diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index 95077120e8..2d40afb654 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -265,13 +265,11 @@ ur_result_t UR_APICALL urPlatformGetNativeHandle( /// - ::UR_RESULT_ERROR_UNINITIALIZED /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC -/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativePlatform` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phPlatform` ur_result_t UR_APICALL urPlatformCreateWithNativeHandle( ur_native_handle_t - hNativePlatform, ///< [in] the native handle of the platform. + hNativePlatform, ///< [in][nocheck] the native handle of the platform. const ur_platform_native_properties_t * pProperties, ///< [in][optional] pointer to native platform properties struct. ur_platform_handle_t * @@ -729,13 +727,13 @@ ur_result_t UR_APICALL urDeviceGetNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeDevice` /// + `NULL == hPlatform` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phDevice` ur_result_t UR_APICALL urDeviceCreateWithNativeHandle( - ur_native_handle_t hNativeDevice, ///< [in] the native handle of the device. - ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance + ur_native_handle_t + hNativeDevice, ///< [in][nocheck] the native handle of the device. + ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance const ur_device_native_properties_t * pProperties, ///< [in][optional] pointer to native device properties struct. ur_device_handle_t @@ -1014,14 +1012,12 @@ ur_result_t UR_APICALL urContextGetNativeHandle( /// - ::UR_RESULT_ERROR_UNINITIALIZED /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC -/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phDevices` /// + `NULL == phContext` ur_result_t UR_APICALL urContextCreateWithNativeHandle( ur_native_handle_t - hNativeContext, ///< [in] the native handle of the context. + hNativeContext, ///< [in][nocheck] the native handle of the context. uint32_t numDevices, ///< [in] number of devices associated with the context const ur_device_handle_t * phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context @@ -1347,13 +1343,13 @@ ur_result_t UR_APICALL urMemGetNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeMem` /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phMem` ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( - ur_native_handle_t hNativeMem, ///< [in] the native handle to the memory. - ur_context_handle_t hContext, ///< [in] handle of the context object. + ur_native_handle_t + hNativeMem, ///< [in][nocheck] the native handle to the memory. + ur_context_handle_t hContext, ///< [in] handle of the context object. const ur_mem_native_properties_t * pProperties, ///< [in][optional] pointer to native memory creation properties. ur_mem_handle_t @@ -1385,15 +1381,15 @@ ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeMem` /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pImageFormat` /// + `NULL == pImageDesc` /// + `NULL == phMem` ur_result_t UR_APICALL urMemImageCreateWithNativeHandle( - ur_native_handle_t hNativeMem, ///< [in] the native handle to the memory. - ur_context_handle_t hContext, ///< [in] handle of the context object. + ur_native_handle_t + hNativeMem, ///< [in][nocheck] the native handle to the memory. + ur_context_handle_t hContext, ///< [in] handle of the context object. const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification. const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description. @@ -1735,13 +1731,12 @@ ur_result_t UR_APICALL urSamplerGetNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeSampler` /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phSampler` ur_result_t UR_APICALL urSamplerCreateWithNativeHandle( ur_native_handle_t - hNativeSampler, ///< [in] the native handle of the sampler. + hNativeSampler, ///< [in][nocheck] the native handle of the sampler. ur_context_handle_t hContext, ///< [in] handle of the context object const ur_sampler_native_properties_t * pProperties, ///< [in][optional] pointer to native sampler properties struct. @@ -3009,13 +3004,12 @@ ur_result_t UR_APICALL urProgramGetNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeProgram` /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phProgram` ur_result_t UR_APICALL urProgramCreateWithNativeHandle( ur_native_handle_t - hNativeProgram, ///< [in] the native handle of the program. + hNativeProgram, ///< [in][nocheck] the native handle of the program. ur_context_handle_t hContext, ///< [in] handle of the context instance const ur_program_native_properties_t * pProperties, ///< [in][optional] pointer to native program properties struct. @@ -3590,14 +3584,14 @@ ur_result_t UR_APICALL urKernelGetNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeKernel` /// + `NULL == hContext` /// + `NULL == hProgram` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phKernel` ur_result_t UR_APICALL urKernelCreateWithNativeHandle( - ur_native_handle_t hNativeKernel, ///< [in] the native handle of the kernel. - ur_context_handle_t hContext, ///< [in] handle of the context object + ur_native_handle_t + hNativeKernel, ///< [in][nocheck] the native handle of the kernel. + ur_context_handle_t hContext, ///< [in] handle of the context object ur_program_handle_t hProgram, ///< [in] handle of the program associated with the kernel const ur_kernel_native_properties_t * @@ -3835,15 +3829,15 @@ ur_result_t UR_APICALL urQueueGetNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeQueue` /// + `NULL == hContext` /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phQueue` ur_result_t UR_APICALL urQueueCreateWithNativeHandle( - ur_native_handle_t hNativeQueue, ///< [in] the native handle of the queue. - ur_context_handle_t hContext, ///< [in] handle of the context object - ur_device_handle_t hDevice, ///< [in] handle of the device object + ur_native_handle_t + hNativeQueue, ///< [in][nocheck] the native handle of the queue. + ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_queue_native_properties_t * pProperties, ///< [in][optional] pointer to native queue properties struct ur_queue_handle_t @@ -4176,13 +4170,13 @@ ur_result_t UR_APICALL urEventGetNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeEvent` /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phEvent` ur_result_t UR_APICALL urEventCreateWithNativeHandle( - ur_native_handle_t hNativeEvent, ///< [in] the native handle of the event. - ur_context_handle_t hContext, ///< [in] handle of the context object + ur_native_handle_t + hNativeEvent, ///< [in][nocheck] the native handle of the event. + ur_context_handle_t hContext, ///< [in] handle of the context object const ur_event_native_properties_t * pProperties, ///< [in][optional] pointer to native event properties struct ur_event_handle_t diff --git a/source/ur_api.cpp b/source/ur_api.cpp index da5d63e087..96b6ce5382 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -215,13 +215,11 @@ ur_result_t UR_APICALL urPlatformGetNativeHandle( /// - ::UR_RESULT_ERROR_UNINITIALIZED /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC -/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativePlatform` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phPlatform` ur_result_t UR_APICALL urPlatformCreateWithNativeHandle( ur_native_handle_t - hNativePlatform, ///< [in] the native handle of the platform. + hNativePlatform, ///< [in][nocheck] the native handle of the platform. const ur_platform_native_properties_t * pProperties, ///< [in][optional] pointer to native platform properties struct. ur_platform_handle_t * @@ -615,13 +613,13 @@ ur_result_t UR_APICALL urDeviceGetNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeDevice` /// + `NULL == hPlatform` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phDevice` ur_result_t UR_APICALL urDeviceCreateWithNativeHandle( - ur_native_handle_t hNativeDevice, ///< [in] the native handle of the device. - ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance + ur_native_handle_t + hNativeDevice, ///< [in][nocheck] the native handle of the device. + ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance const ur_device_native_properties_t * pProperties, ///< [in][optional] pointer to native device properties struct. ur_device_handle_t @@ -854,14 +852,12 @@ ur_result_t UR_APICALL urContextGetNativeHandle( /// - ::UR_RESULT_ERROR_UNINITIALIZED /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC -/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phDevices` /// + `NULL == phContext` ur_result_t UR_APICALL urContextCreateWithNativeHandle( ur_native_handle_t - hNativeContext, ///< [in] the native handle of the context. + hNativeContext, ///< [in][nocheck] the native handle of the context. uint32_t numDevices, ///< [in] number of devices associated with the context const ur_device_handle_t * phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context @@ -1133,13 +1129,13 @@ ur_result_t UR_APICALL urMemGetNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeMem` /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phMem` ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( - ur_native_handle_t hNativeMem, ///< [in] the native handle to the memory. - ur_context_handle_t hContext, ///< [in] handle of the context object. + ur_native_handle_t + hNativeMem, ///< [in][nocheck] the native handle to the memory. + ur_context_handle_t hContext, ///< [in] handle of the context object. const ur_mem_native_properties_t * pProperties, ///< [in][optional] pointer to native memory creation properties. ur_mem_handle_t @@ -1163,15 +1159,15 @@ ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeMem` /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pImageFormat` /// + `NULL == pImageDesc` /// + `NULL == phMem` ur_result_t UR_APICALL urMemImageCreateWithNativeHandle( - ur_native_handle_t hNativeMem, ///< [in] the native handle to the memory. - ur_context_handle_t hContext, ///< [in] handle of the context object. + ur_native_handle_t + hNativeMem, ///< [in][nocheck] the native handle to the memory. + ur_context_handle_t hContext, ///< [in] handle of the context object. const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification. const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description. @@ -1461,13 +1457,12 @@ ur_result_t UR_APICALL urSamplerGetNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeSampler` /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phSampler` ur_result_t UR_APICALL urSamplerCreateWithNativeHandle( ur_native_handle_t - hNativeSampler, ///< [in] the native handle of the sampler. + hNativeSampler, ///< [in][nocheck] the native handle of the sampler. ur_context_handle_t hContext, ///< [in] handle of the context object const ur_sampler_native_properties_t * pProperties, ///< [in][optional] pointer to native sampler properties struct. @@ -2529,13 +2524,12 @@ ur_result_t UR_APICALL urProgramGetNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeProgram` /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phProgram` ur_result_t UR_APICALL urProgramCreateWithNativeHandle( ur_native_handle_t - hNativeProgram, ///< [in] the native handle of the program. + hNativeProgram, ///< [in][nocheck] the native handle of the program. ur_context_handle_t hContext, ///< [in] handle of the context instance const ur_program_native_properties_t * pProperties, ///< [in][optional] pointer to native program properties struct. @@ -3013,14 +3007,14 @@ ur_result_t UR_APICALL urKernelGetNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeKernel` /// + `NULL == hContext` /// + `NULL == hProgram` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phKernel` ur_result_t UR_APICALL urKernelCreateWithNativeHandle( - ur_native_handle_t hNativeKernel, ///< [in] the native handle of the kernel. - ur_context_handle_t hContext, ///< [in] handle of the context object + ur_native_handle_t + hNativeKernel, ///< [in][nocheck] the native handle of the kernel. + ur_context_handle_t hContext, ///< [in] handle of the context object ur_program_handle_t hProgram, ///< [in] handle of the program associated with the kernel const ur_kernel_native_properties_t * @@ -3219,15 +3213,15 @@ ur_result_t UR_APICALL urQueueGetNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeQueue` /// + `NULL == hContext` /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phQueue` ur_result_t UR_APICALL urQueueCreateWithNativeHandle( - ur_native_handle_t hNativeQueue, ///< [in] the native handle of the queue. - ur_context_handle_t hContext, ///< [in] handle of the context object - ur_device_handle_t hDevice, ///< [in] handle of the device object + ur_native_handle_t + hNativeQueue, ///< [in][nocheck] the native handle of the queue. + ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_queue_native_properties_t * pProperties, ///< [in][optional] pointer to native queue properties struct ur_queue_handle_t @@ -3501,13 +3495,13 @@ ur_result_t UR_APICALL urEventGetNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeEvent` /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phEvent` ur_result_t UR_APICALL urEventCreateWithNativeHandle( - ur_native_handle_t hNativeEvent, ///< [in] the native handle of the event. - ur_context_handle_t hContext, ///< [in] handle of the context object + ur_native_handle_t + hNativeEvent, ///< [in][nocheck] the native handle of the event. + ur_context_handle_t hContext, ///< [in] handle of the context object const ur_event_native_properties_t * pProperties, ///< [in][optional] pointer to native event properties struct ur_event_handle_t From 744e549f38df28b868fabca3b9f3b43b3552aab6 Mon Sep 17 00:00:00 2001 From: Aaron Greig Date: Fri, 30 Jun 2023 11:50:01 +0100 Subject: [PATCH 073/104] Implement loader config object, allow programatic layer management. --- examples/hello_world/hello_world.cpp | 2 +- include/ur.py | 75 ++++++- include/ur_api.h | 192 +++++++++++++++++- include/ur_ddi.h | 3 +- scripts/core/INTRO.rst | 44 ++-- scripts/core/common.yml | 7 + scripts/core/registry.yml | 15 ++ scripts/core/runtime.yml | 110 ++++++++++ scripts/json2src.py | 30 +++ scripts/templates/api.py.mako | 3 + scripts/templates/ddi.h.mako | 6 + scripts/templates/libapi.cpp.mako | 8 +- scripts/templates/libddi.cpp.mako | 3 + scripts/templates/trcddi.cpp.mako | 5 +- scripts/templates/valddi.cpp.mako | 9 +- source/adapters/null/ur_nullddi.cpp | 6 +- source/common/ur_params.hpp | 29 +++ .../layers/tracing/ur_tracing_layer.cpp | 2 +- .../layers/tracing/ur_tracing_layer.hpp | 10 +- source/loader/layers/tracing/ur_trcddi.cpp | 8 +- source/loader/layers/ur_proxy_layer.hpp | 8 +- source/loader/layers/validation/ur_valddi.cpp | 10 +- .../layers/validation/ur_validation_layer.cpp | 23 ++- .../layers/validation/ur_validation_layer.hpp | 17 +- source/loader/ur_ldrddi.cpp | 7 +- source/loader/ur_lib.cpp | 154 ++++++++++++-- source/loader/ur_lib.hpp | 46 ++++- source/loader/ur_libapi.cpp | 152 +++++++++++++- source/ur_api.cpp | 140 ++++++++++++- test/conformance/platform/fixtures.h | 2 +- test/conformance/platform/urInit.cpp | 9 +- test/conformance/platform/urTearDown.cpp | 2 +- test/conformance/source/environment.cpp | 8 +- test/layers/tracing/CMakeLists.txt | 3 +- test/layers/validation/CMakeLists.txt | 4 +- test/layers/validation/fixtures.hpp | 8 +- test/layers/validation/parameters.cpp | 8 +- test/loader/CMakeLists.txt | 1 + test/loader/loader_config/CMakeLists.txt | 26 +++ test/loader/loader_config/fixtures.hpp | 30 +++ .../loader_config/urLoaderConfigCreate.cpp | 19 ++ .../urLoaderConfigEnableLayer.cpp | 46 +++++ .../loader_config/urLoaderConfigGetInfo.cpp | 52 +++++ .../loader_config/urLoaderConfigRelease.cpp | 31 +++ .../loader_config/urLoaderConfigRetain.cpp | 31 +++ test/loader/platforms/platforms.cpp | 2 +- test/tools/urtrace/null_hello.match | 2 +- test/tools/urtrace/null_hello_begin.match | 4 +- test/tools/urtrace/null_hello_json.match | 4 +- test/tools/urtrace/null_hello_profiling.match | 2 +- test/unit/utils/params.cpp | 12 +- tools/urtrace/urtrace.py | 2 + 52 files changed, 1326 insertions(+), 106 deletions(-) create mode 100644 test/loader/loader_config/CMakeLists.txt create mode 100644 test/loader/loader_config/fixtures.hpp create mode 100644 test/loader/loader_config/urLoaderConfigCreate.cpp create mode 100644 test/loader/loader_config/urLoaderConfigEnableLayer.cpp create mode 100644 test/loader/loader_config/urLoaderConfigGetInfo.cpp create mode 100644 test/loader/loader_config/urLoaderConfigRelease.cpp create mode 100644 test/loader/loader_config/urLoaderConfigRetain.cpp diff --git a/examples/hello_world/hello_world.cpp b/examples/hello_world/hello_world.cpp index 454aeea540..dcd504bf4e 100644 --- a/examples/hello_world/hello_world.cpp +++ b/examples/hello_world/hello_world.cpp @@ -19,7 +19,7 @@ int main(int argc, char *argv[]) { ur_result_t status; // Initialize the platform - status = urInit(0); + status = urInit(0, nullptr); if (status != UR_RESULT_SUCCESS) { std::cout << "urInit failed with return code: " << status << std::endl; return 1; diff --git a/include/ur.py b/include/ur.py index f6a8d0ab3c..50d2969fc8 100644 --- a/include/ur.py +++ b/include/ur.py @@ -187,6 +187,11 @@ class ur_function_v(IntEnum): COMMAND_BUFFER_APPEND_MEMBUFFER_READ_EXP = 169 ## Enumerator for ::urCommandBufferAppendMembufferReadExp COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_RECT_EXP = 170## Enumerator for ::urCommandBufferAppendMembufferWriteRectExp COMMAND_BUFFER_APPEND_MEMBUFFER_READ_RECT_EXP = 171 ## Enumerator for ::urCommandBufferAppendMembufferReadRectExp + LOADER_CONFIG_CREATE = 172 ## Enumerator for ::urLoaderConfigCreate + LOADER_CONFIG_RELEASE = 173 ## Enumerator for ::urLoaderConfigRelease + LOADER_CONFIG_RETAIN = 174 ## Enumerator for ::urLoaderConfigRetain + LOADER_CONFIG_GET_INFO = 175 ## Enumerator for ::urLoaderConfigGetInfo + LOADER_CONFIG_ENABLE_LAYER = 176 ## Enumerator for ::urLoaderConfigEnableLayer class ur_function_t(c_int): def __str__(self): @@ -278,6 +283,11 @@ def UR_MINOR_VERSION( _ver ): class ur_bool_t(c_ubyte): pass +############################################################################### +## @brief Handle of a loader config object +class ur_loader_config_handle_t(c_void_p): + pass + ############################################################################### ## @brief Handle of a platform instance class ur_platform_handle_t(c_void_p): @@ -420,6 +430,7 @@ class ur_result_v(IntEnum): ERROR_OBJECT_ALLOCATION_FAILURE = 66 ## Objection allocation failure ERROR_ADAPTER_SPECIFIC = 67 ## An adapter specific warning/error has been reported and can be ## retrieved via the urPlatformGetLastError entry point. + ERROR_LAYER_NOT_PRESENT = 68 ## A requested layer was not found by the loader. ERROR_INVALID_COMMAND_BUFFER_EXP = 0x1000 ## Invalid Command-Buffer ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_EXP = 0x1001## Sync point is not valid for the command-buffer ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_WAIT_LIST_EXP = 0x1002 ## Sync point wait list is invalid @@ -478,6 +489,18 @@ def __str__(self): return hex(self.value) +############################################################################### +## @brief Supported loader info +class ur_loader_config_info_v(IntEnum): + AVAILABLE_LAYERS = 0 ## [char[]] Null-terminated, semi-colon separated list of available + ## layers. + REFERENCE_COUNT = 1 ## [uint32_t] Reference count of the loader config object. + +class ur_loader_config_info_t(c_int): + def __str__(self): + return str(ur_loader_config_info_v(self.value)) + + ############################################################################### ## @brief Supported platform info class ur_platform_info_v(IntEnum): @@ -2200,6 +2223,53 @@ def __str__(self): ############################################################################### __use_win_types = "Windows" == platform.uname()[0] +############################################################################### +## @brief Function-pointer for urLoaderConfigCreate +if __use_win_types: + _urLoaderConfigCreate_t = WINFUNCTYPE( ur_result_t, POINTER(ur_loader_config_handle_t) ) +else: + _urLoaderConfigCreate_t = CFUNCTYPE( ur_result_t, POINTER(ur_loader_config_handle_t) ) + +############################################################################### +## @brief Function-pointer for urLoaderConfigRetain +if __use_win_types: + _urLoaderConfigRetain_t = WINFUNCTYPE( ur_result_t, ur_loader_config_handle_t ) +else: + _urLoaderConfigRetain_t = CFUNCTYPE( ur_result_t, ur_loader_config_handle_t ) + +############################################################################### +## @brief Function-pointer for urLoaderConfigRelease +if __use_win_types: + _urLoaderConfigRelease_t = WINFUNCTYPE( ur_result_t, ur_loader_config_handle_t ) +else: + _urLoaderConfigRelease_t = CFUNCTYPE( ur_result_t, ur_loader_config_handle_t ) + +############################################################################### +## @brief Function-pointer for urLoaderConfigGetInfo +if __use_win_types: + _urLoaderConfigGetInfo_t = WINFUNCTYPE( ur_result_t, ur_loader_config_handle_t, ur_loader_config_info_t, c_size_t, c_void_p, POINTER(c_size_t) ) +else: + _urLoaderConfigGetInfo_t = CFUNCTYPE( ur_result_t, ur_loader_config_handle_t, ur_loader_config_info_t, c_size_t, c_void_p, POINTER(c_size_t) ) + +############################################################################### +## @brief Function-pointer for urLoaderConfigEnableLayer +if __use_win_types: + _urLoaderConfigEnableLayer_t = WINFUNCTYPE( ur_result_t, ur_loader_config_handle_t, c_char_p ) +else: + _urLoaderConfigEnableLayer_t = CFUNCTYPE( ur_result_t, ur_loader_config_handle_t, c_char_p ) + + +############################################################################### +## @brief Table of LoaderConfig functions pointers +class ur_loader_config_dditable_t(Structure): + _fields_ = [ + ("pfnCreate", c_void_p), ## _urLoaderConfigCreate_t + ("pfnRetain", c_void_p), ## _urLoaderConfigRetain_t + ("pfnRelease", c_void_p), ## _urLoaderConfigRelease_t + ("pfnGetInfo", c_void_p), ## _urLoaderConfigGetInfo_t + ("pfnEnableLayer", c_void_p) ## _urLoaderConfigEnableLayer_t + ] + ############################################################################### ## @brief Function-pointer for urPlatformGet if __use_win_types: @@ -3484,9 +3554,9 @@ class ur_usm_p2p_exp_dditable_t(Structure): ############################################################################### ## @brief Function-pointer for urInit if __use_win_types: - _urInit_t = WINFUNCTYPE( ur_result_t, ur_device_init_flags_t ) + _urInit_t = WINFUNCTYPE( ur_result_t, ur_device_init_flags_t, ur_loader_config_handle_t ) else: - _urInit_t = CFUNCTYPE( ur_result_t, ur_device_init_flags_t ) + _urInit_t = CFUNCTYPE( ur_result_t, ur_device_init_flags_t, ur_loader_config_handle_t ) ############################################################################### ## @brief Function-pointer for urTearDown @@ -3649,6 +3719,7 @@ class ur_device_dditable_t(Structure): ############################################################################### class ur_dditable_t(Structure): _fields_ = [ + ("LoaderConfig", ur_loader_config_dditable_t), ("Platform", ur_platform_dditable_t), ("Context", ur_context_dditable_t), ("Event", ur_event_dditable_t), diff --git a/include/ur_api.h b/include/ur_api.h index 7bae504b3a..e80d850442 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -196,6 +196,11 @@ typedef enum ur_function_t { UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_READ_EXP = 169, ///< Enumerator for ::urCommandBufferAppendMembufferReadExp UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_RECT_EXP = 170, ///< Enumerator for ::urCommandBufferAppendMembufferWriteRectExp UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_READ_RECT_EXP = 171, ///< Enumerator for ::urCommandBufferAppendMembufferReadRectExp + UR_FUNCTION_LOADER_CONFIG_CREATE = 172, ///< Enumerator for ::urLoaderConfigCreate + UR_FUNCTION_LOADER_CONFIG_RELEASE = 173, ///< Enumerator for ::urLoaderConfigRelease + UR_FUNCTION_LOADER_CONFIG_RETAIN = 174, ///< Enumerator for ::urLoaderConfigRetain + UR_FUNCTION_LOADER_CONFIG_GET_INFO = 175, ///< Enumerator for ::urLoaderConfigGetInfo + UR_FUNCTION_LOADER_CONFIG_ENABLE_LAYER = 176, ///< Enumerator for ::urLoaderConfigEnableLayer /// @cond UR_FUNCTION_FORCE_UINT32 = 0x7fffffff /// @endcond @@ -318,6 +323,10 @@ typedef enum ur_structure_type_t { /// @brief compiler-independent type typedef uint8_t ur_bool_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Handle of a loader config object +typedef struct ur_loader_config_handle_t_ *ur_loader_config_handle_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief Handle of a platform instance typedef struct ur_platform_handle_t_ *ur_platform_handle_t; @@ -450,6 +459,7 @@ typedef enum ur_result_t { UR_RESULT_ERROR_OBJECT_ALLOCATION_FAILURE = 66, ///< Objection allocation failure UR_RESULT_ERROR_ADAPTER_SPECIFIC = 67, ///< An adapter specific warning/error has been reported and can be ///< retrieved via the urPlatformGetLastError entry point. + UR_RESULT_ERROR_LAYER_NOT_PRESENT = 68, ///< A requested layer was not found by the loader. UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_EXP = 0x1000, ///< Invalid Command-Buffer UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_EXP = 0x1001, ///< Sync point is not valid for the command-buffer UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_WAIT_LIST_EXP = 0x1002, ///< Sync point wait list is invalid @@ -518,6 +528,137 @@ typedef enum ur_device_init_flag_t { /// @brief Bit Mask for validating ur_device_init_flags_t #define UR_DEVICE_INIT_FLAGS_MASK 0xffffffe0 +/////////////////////////////////////////////////////////////////////////////// +/// @brief Create a loader config object. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == phLoaderConfig` +UR_APIEXPORT ur_result_t UR_APICALL +urLoaderConfigCreate( + ur_loader_config_handle_t *phLoaderConfig ///< [out] Pointer to handle of loader config object created. +); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get a reference to the loader config object. +/// +/// @details +/// - Get a reference to the loader config handle. Increment its reference +/// count +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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 == hLoaderConfig` +UR_APIEXPORT ur_result_t UR_APICALL +urLoaderConfigRetain( + ur_loader_config_handle_t hLoaderConfig ///< [in] loader config handle to retain +); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Release config handle. +/// +/// @details +/// - Decrement reference count and destroy the config handle if reference +/// count becomes zero. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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 == hLoaderConfig` +UR_APIEXPORT ur_result_t UR_APICALL +urLoaderConfigRelease( + ur_loader_config_handle_t hLoaderConfig ///< [in] config handle to release +); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Supported loader info +typedef enum ur_loader_config_info_t { + UR_LOADER_CONFIG_INFO_AVAILABLE_LAYERS = 0, ///< [char[]] Null-terminated, semi-colon separated list of available + ///< layers. + UR_LOADER_CONFIG_INFO_REFERENCE_COUNT = 1, ///< [uint32_t] Reference count of the loader config object. + /// @cond + UR_LOADER_CONFIG_INFO_FORCE_UINT32 = 0x7fffffff + /// @endcond + +} ur_loader_config_info_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Retrieves various information about the loader. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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 == hLoaderConfig` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_LOADER_CONFIG_INFO_REFERENCE_COUNT < propName` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// + If `propName` is not supported by the loader. +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `propSize == 0 && pPropValue != NULL` +/// + If `propSize` is less than the real number of bytes needed to return the info. +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `propSize != 0 && pPropValue == NULL` +/// + `pPropValue == NULL && pPropSizeRet == NULL` +/// - ::UR_RESULT_ERROR_INVALID_DEVICE +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY +UR_APIEXPORT ur_result_t UR_APICALL +urLoaderConfigGetInfo( + ur_loader_config_handle_t hLoaderConfig, ///< [in] handle of the loader config object + ur_loader_config_info_t propName, ///< [in] type of the info to retrieve + size_t propSize, ///< [in] the number of bytes pointed to by pPropValue. + void *pPropValue, ///< [out][optional][typename(propName, propSize)] array of bytes holding + ///< the info. + ///< If propSize is not equal to or greater than the real number of bytes + ///< needed to return the info + ///< then the ::UR_RESULT_ERROR_INVALID_SIZE error is returned and + ///< pPropValue is not used. + size_t *pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName. +); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Enable a layer for the specified loader config. +/// +/// @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 == hLoaderConfig` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pLayerName` +/// - ::UR_RESULT_ERROR_LAYER_NOT_PRESENT +/// + If layer specified with `pLayerName` can't be found by the loader. +UR_APIEXPORT ur_result_t UR_APICALL +urLoaderConfigEnableLayer( + ur_loader_config_handle_t hLoaderConfig, ///< [in] Handle to config object the layer will be enabled for. + const char *pLayerName ///< [in] Null terminated string containing the name of the layer to + ///< enable. +); + /////////////////////////////////////////////////////////////////////////////// /// @brief Initialize the 'oneAPI' adapter(s) /// @@ -545,8 +686,9 @@ typedef enum ur_device_init_flag_t { /// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY UR_APIEXPORT ur_result_t UR_APICALL urInit( - ur_device_init_flags_t device_flags ///< [in] device initialization flags. - ///< must be 0 (default) or a combination of ::ur_device_init_flag_t. + ur_device_init_flags_t device_flags, ///< [in] device initialization flags. + ///< must be 0 (default) or a combination of ::ur_device_init_flag_t. + ur_loader_config_handle_t hLoaderConfig ///< [in][optional] Handle of loader config handle. ); /////////////////////////////////////////////////////////////////////////////// @@ -7901,6 +8043,51 @@ urUsmP2PPeerAccessGetInfoExp( #if !defined(__GNUC__) #pragma region callbacks #endif +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urLoaderConfigCreate +/// @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_loader_config_create_params_t { + ur_loader_config_handle_t **pphLoaderConfig; +} ur_loader_config_create_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urLoaderConfigRetain +/// @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_loader_config_retain_params_t { + ur_loader_config_handle_t *phLoaderConfig; +} ur_loader_config_retain_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urLoaderConfigRelease +/// @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_loader_config_release_params_t { + ur_loader_config_handle_t *phLoaderConfig; +} ur_loader_config_release_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urLoaderConfigGetInfo +/// @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_loader_config_get_info_params_t { + ur_loader_config_handle_t *phLoaderConfig; + ur_loader_config_info_t *ppropName; + size_t *ppropSize; + void **ppPropValue; + size_t **ppPropSizeRet; +} ur_loader_config_get_info_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urLoaderConfigEnableLayer +/// @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_loader_config_enable_layer_params_t { + ur_loader_config_handle_t *phLoaderConfig; + const char **ppLayerName; +} ur_loader_config_enable_layer_params_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief Function parameters for urPlatformGet /// @details Each entry is a pointer to the parameter passed to the function; @@ -9656,6 +9843,7 @@ typedef struct ur_usm_p2p_peer_access_get_info_exp_params_t { /// allowing the callback the ability to modify the parameter's value typedef struct ur_init_params_t { ur_device_init_flags_t *pdevice_flags; + ur_loader_config_handle_t *phLoaderConfig; } ur_init_params_t; /////////////////////////////////////////////////////////////////////////////// diff --git a/include/ur_ddi.h b/include/ur_ddi.h index 8856249ed7..cdf161412d 100644 --- a/include/ur_ddi.h +++ b/include/ur_ddi.h @@ -1869,7 +1869,8 @@ typedef ur_result_t(UR_APICALL *ur_pfnGetUsmP2PExpProcAddrTable_t)( /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urInit typedef ur_result_t(UR_APICALL *ur_pfnInit_t)( - ur_device_init_flags_t); + ur_device_init_flags_t, + ur_loader_config_handle_t); /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urTearDown diff --git a/scripts/core/INTRO.rst b/scripts/core/INTRO.rst index 6517cea1fc..4c3a1a9d2d 100644 --- a/scripts/core/INTRO.rst +++ b/scripts/core/INTRO.rst @@ -234,6 +234,25 @@ Currently, UR looks for these adapter libraries: For more information about the usage of mentioned environment variables see `Environment Variables`_ section. +Layers +--------------------- +UR comes with a mechanism that allows various API intercept layers to be enabled, either through the API or with an environment variable (see `Environment Variables`_). +Layers currently included with the runtime are as follows: + +.. list-table:: + :header-rows: 1 + + * - Layer Name + - Description + * - UR_LAYER_PARAMETER_VALIDATION + - Enables non-adapter-specific parameter validation (e.g. checking for null values). + * - UR_LAYER_LEAK_CHECKING + - Performs some leak checking for API calls involving object creation/destruction. + * - UR_LAYER_FULL_VALIDATION + - Enables UR_LAYER_PARAMETER_VALIDATION and UR_LAYER_LEAK_CHECKING. + * - UR_LAYER_TRACING + - Enables the XPTI tracing layer, see Tracing_ for more detail. + Environment Variables --------------------- @@ -277,30 +296,13 @@ Specific environment variables can be set to control the behavior of unified run This environment variable is ignored when :envvar:`UR_ADAPTERS_FORCE_LOAD` environment variable is used. -.. envvar:: UR_ENABLE_VALIDATION_LAYER +.. envvar:: UR_ENABLE_LAYERS - Holds the value ``0`` or ``1``. By setting it to ``1`` you enable validation layer. - - .. note:: - - This environment variable should be used for development and debugging only. + Holds a comma-separated list of layers to enable in addition to any specified via ``urInit``. -.. envvar:: UR_ENABLE_PARAMETER_VALIDATION - - Holds the value ``0`` or ``1``. By setting it to ``1`` you enable parameter validation for Unified Runtime API calls. - - .. note:: - - This environment variable should be used together with :envvar:`UR_ENABLE_VALIDATION_LAYER`. - -.. envvar:: UR_ENABLE_LEAK_CHECKING - - Holds the value ``0`` or ``1``. By setting it to ``1`` you enable leak checking for Unified Runtime API calls involving - object creation/destruction. Leak checking depends on the logging mechanism. - - .. note:: + .. note:: - This environment variable should be used together with :envvar:`UR_ENABLE_VALIDATION_LAYER` and :envvar:`UR_LOG_VALIDATION`. + See the Layers_ section for details of the layers currently included in the runtime. Service identifiers --------------------- diff --git a/scripts/core/common.yml b/scripts/core/common.yml index 5677727efa..ed29a1be99 100644 --- a/scripts/core/common.yml +++ b/scripts/core/common.yml @@ -60,6 +60,11 @@ name: $x_bool_t value: uint8_t --- #-------------------------------------------------------------------------- type: handle +desc: "Handle of a loader config object" +class: $xLoaderConfig +name: "$x_loader_config_handle_t" +--- #-------------------------------------------------------------------------- +type: handle desc: "Handle of a platform instance" class: $xPlatform name: "$x_platform_handle_t" @@ -261,6 +266,8 @@ etors: - name: ERROR_ADAPTER_SPECIFIC desc: "An adapter specific warning/error has been reported and can be retrieved via the urPlatformGetLastError entry point." + - name: ERROR_LAYER_NOT_PRESENT + desc: "A requested layer was not found by the loader." - name: ERROR_UNKNOWN value: "0x7ffffffe" desc: "Unknown or internal error" diff --git a/scripts/core/registry.yml b/scripts/core/registry.yml index 00096044ce..f0d198b668 100644 --- a/scripts/core/registry.yml +++ b/scripts/core/registry.yml @@ -502,6 +502,21 @@ etors: - name: COMMAND_BUFFER_APPEND_MEMBUFFER_READ_RECT_EXP desc: Enumerator for $xCommandBufferAppendMembufferReadRectExp value: '171' +- name: LOADER_CONFIG_CREATE + desc: Enumerator for $xLoaderConfigCreate + value: '172' +- name: LOADER_CONFIG_RELEASE + desc: Enumerator for $xLoaderConfigRelease + value: '173' +- name: LOADER_CONFIG_RETAIN + desc: Enumerator for $xLoaderConfigRetain + value: '174' +- name: LOADER_CONFIG_GET_INFO + desc: Enumerator for $xLoaderConfigGetInfo + value: '175' +- name: LOADER_CONFIG_ENABLE_LAYER + desc: Enumerator for $xLoaderConfigEnableLayer + value: '176' --- type: enum desc: Defines structure types diff --git a/scripts/core/runtime.yml b/scripts/core/runtime.yml index c0bd7a12c7..b5bbd9987c 100644 --- a/scripts/core/runtime.yml +++ b/scripts/core/runtime.yml @@ -29,6 +29,113 @@ etors: desc: "initialize VPU device adapters." --- #-------------------------------------------------------------------------- type: function +desc: "Create a loader config object." +class: $xLoaderConfig +name: Create +decl: static +params: + - type: $x_loader_config_handle_t* + name: phLoaderConfig + desc: "[out] Pointer to handle of loader config object created." +--- #-------------------------------------------------------------------------- +type: function +desc: "Get a reference to the loader config object." +class: $xLoaderConfig +name: Retain +decl: static +details: + - "Get a reference to the loader config handle. Increment its reference count" + - "The application may call this function from simultaneous threads." + - "The implementation of this function should be lock-free." +params: + - type: $x_loader_config_handle_t + name: hLoaderConfig + desc: "[in] loader config handle to retain" +--- #-------------------------------------------------------------------------- +type: function +desc: "Release config handle." +class: $xLoaderConfig +name: Release +decl: static +details: + - "Decrement reference count and destroy the config handle if reference count becomes zero." + - "The application may call this function from simultaneous threads." + - "The implementation of this function should be lock-free." +params: + - type: $x_loader_config_handle_t + name: hLoaderConfig + desc: "[in] config handle to release" +--- #-------------------------------------------------------------------------- +type: enum +desc: "Supported loader info" +class: $xLoaderConfig +name: $x_loader_config_info_t +typed_etors: True +etors: + - name: AVAILABLE_LAYERS + desc: "[char[]] Null-terminated, semi-colon separated list of available layers." + - name: REFERENCE_COUNT + desc: "[uint32_t] Reference count of the loader config object." +--- #-------------------------------------------------------------------------- +type: function +desc: "Retrieves various information about the loader." +class: $xLoaderConfig +name: GetInfo +decl: static +details: + - "The application may call this function from simultaneous threads." + - "The implementation of this function should be lock-free." +params: + - type: $x_loader_config_handle_t + name: hLoaderConfig + desc: "[in] handle of the loader config object" + - type: $x_loader_config_info_t + name: propName + desc: "[in] type of the info to retrieve" + - type: "size_t" + name: propSize + desc: | + [in] the number of bytes pointed to by pPropValue. + - type: "void*" + name: pPropValue + desc: | + [out][optional][typename(propName, propSize)] array of bytes holding the info. + If propSize is not equal to or greater than the real number of bytes needed to return the info + then the $X_RESULT_ERROR_INVALID_SIZE error is returned and pPropValue is not used. + - type: "size_t*" + name: pPropSizeRet + desc: | + [out][optional] pointer to the actual size in bytes of the queried propName. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_ENUMERATION: + - "If `propName` is not supported by the loader." + - $X_RESULT_ERROR_INVALID_SIZE: + - "`propSize == 0 && pPropValue != NULL`" + - "If `propSize` is less than the real number of bytes needed to return the info." + - $X_RESULT_ERROR_INVALID_NULL_POINTER: + - "`propSize != 0 && pPropValue == NULL`" + - "`pPropValue == NULL && pPropSizeRet == NULL`" + - $X_RESULT_ERROR_INVALID_DEVICE + - $X_RESULT_ERROR_OUT_OF_RESOURCES + - $X_RESULT_ERROR_OUT_OF_HOST_MEMORY +--- #-------------------------------------------------------------------------- +type: function +desc: "Enable a layer for the specified loader config." +class: $xLoaderConfig +name: EnableLayer +decl: static +params: + - type: $x_loader_config_handle_t + name: hLoaderConfig + desc: "[in] Handle to config object the layer will be enabled for." + - type: const char* + name: pLayerName + desc: "[in] Null terminated string containing the name of the layer to enable." +returns: + - $X_RESULT_ERROR_LAYER_NOT_PRESENT: + - "If layer specified with `pLayerName` can't be found by the loader." +--- #-------------------------------------------------------------------------- +type: function desc: "Initialize the $OneApi adapter(s)" class: $x name: Init @@ -49,6 +156,9 @@ params: [in] device initialization flags. must be 0 (default) or a combination of $x_device_init_flag_t. init: "0" + - type: $x_loader_config_handle_t + name: hLoaderConfig + desc: "[in][optional] Handle of loader config handle." returns: - $X_RESULT_ERROR_OUT_OF_HOST_MEMORY --- #-------------------------------------------------------------------------- diff --git a/scripts/json2src.py b/scripts/json2src.py index 0a5c52e38a..10ad00a2fc 100755 --- a/scripts/json2src.py +++ b/scripts/json2src.py @@ -23,6 +23,33 @@ def add_argument(parser, name, help, default=False): group.add_argument("--skip-" + name, dest=name, help="Skip "+help, action="store_false") parser.set_defaults(**{name:default}) +""" + helpers to strip loader only api constructs from the json +""" +def strip_specs_class(specs, strip_class): + for spec in specs: + remove_obj = [] + for obj in spec["objects"]: + if "class" in obj and strip_class in obj["class"]: + remove_obj.append(obj) + for obj in remove_obj: + spec["objects"].remove(obj) + +def strip_meta_entry(meta, entry_name, pattern): + loader_entries = [] + for entry in meta[entry_name]: + if pattern in entry: + loader_entries.append(entry) + + for entry in loader_entries: + del meta[entry_name][entry] + +def strip_loader_meta(meta): + strip_meta_entry(meta, "class", "Loader") + strip_meta_entry(meta, "function", "Loader") + strip_meta_entry(meta, "enum", "loader") + strip_meta_entry(meta, "handle", "loader") + if __name__ == '__main__': parser = argparse.ArgumentParser() add_argument(parser, "lib", "generation of lib files.", True) @@ -48,6 +75,9 @@ def add_argument(parser, name, help, default=False): if args.sections == None or config['name'] in args.sections: if args.lib: generate_code.generate_lib(srcpath, config['name'], config['namespace'], config['tags'], args.ver, specs, input['meta']) + # From here only generate code for functions adapters can implement. + strip_specs_class(specs, "Loader") + strip_loader_meta(input['meta']) if args.loader: generate_code.generate_loader(srcpath, config['name'], config['namespace'], config['tags'], args.ver, specs, input['meta']) if args.layers: diff --git a/scripts/templates/api.py.mako b/scripts/templates/api.py.mako index 35a2fd6d27..0399bf1ba8 100644 --- a/scripts/templates/api.py.mako +++ b/scripts/templates/api.py.mako @@ -178,6 +178,9 @@ class ${N}_DDI: self.__dll.${x}Init(0, 0) %for tbl in tables: + %if 'Loader' in tbl['name']: +<% continue %> + %endif # call driver to get function pointers ${tbl['name']} = ${tbl['type']}() r = ${x}_result_v(self.__dll.${tbl['export']['name']}(version, byref(${tbl['name']}))) diff --git a/scripts/templates/ddi.h.mako b/scripts/templates/ddi.h.mako index 3a0e0c1af2..26d7f3f93d 100644 --- a/scripts/templates/ddi.h.mako +++ b/scripts/templates/ddi.h.mako @@ -31,6 +31,9 @@ extern "C" { #endif %for tbl in th.get_pfntables(specs, meta, n, tags): +%if 'Loader' in tbl['export']['name']: + <% continue %> +%endif %for obj in tbl['functions']: /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for ${th.make_func_name(n, tags, obj)} @@ -94,6 +97,9 @@ typedef ${x}_result_t (${X}_APICALL *${tbl['pfn']})( typedef struct ${n}_dditable_t { %for tbl in th.get_pfntables(specs, meta, n, tags): +%if 'loader' in tbl['type']: + <% continue %> +%endif ${th.append_ws(tbl['type'], 35)} ${tbl['name']}; %endfor } ${n}_dditable_t; diff --git a/scripts/templates/libapi.cpp.mako b/scripts/templates/libapi.cpp.mako index b054180fb6..c2fb67808e 100644 --- a/scripts/templates/libapi.cpp.mako +++ b/scripts/templates/libapi.cpp.mako @@ -56,10 +56,13 @@ ${th.make_func_name(n, tags, obj)}( %endfor ) try { +%if 'Loader' in obj['class']: + return ur_lib::${th.make_func_name(n, tags, obj)}(${", ".join(th.make_param_lines(n, tags, obj, format=["name"]))} ); +%else: %if re.match("Init", obj['name']): static ${x}_result_t result = ${X}_RESULT_SUCCESS; - std::call_once(${x}_lib::context->initOnce, [device_flags]() { - result = ${x}_lib::context->Init(device_flags); + std::call_once(${x}_lib::context->initOnce, [device_flags, hLoaderConfig]() { + result = ${x}_lib::context->Init(device_flags, hLoaderConfig); }); if( ${X}_RESULT_SUCCESS != result ) @@ -71,6 +74,7 @@ try { return ${X}_RESULT_ERROR_UNINITIALIZED; return ${th.make_pfn_name(n, tags, obj)}( ${", ".join(th.make_param_lines(n, tags, obj, format=["name"]))} ); +%endif } catch(...) { return exceptionToResult(std::current_exception()); } %if 'condition' in obj: #endif // ${th.subt(n, tags, obj['condition'])} diff --git a/scripts/templates/libddi.cpp.mako b/scripts/templates/libddi.cpp.mako index de73cc2fc7..fc04c20ff8 100644 --- a/scripts/templates/libddi.cpp.mako +++ b/scripts/templates/libddi.cpp.mako @@ -33,6 +33,9 @@ namespace ${x}_lib ${x}_result_t result = ${X}_RESULT_SUCCESS; %for tbl in th.get_pfntables(specs, meta, n, tags): + %if 'Loader' in tbl['export']['name']: + <% continue %> + %endif if( ${X}_RESULT_SUCCESS == result ) { result = ${tbl['export']['name']}( ${X}_API_VERSION_CURRENT, &${n}DdiTable.${tbl['name']} ); diff --git a/scripts/templates/trcddi.cpp.mako b/scripts/templates/trcddi.cpp.mako index f8b506240a..7487aed5bc 100644 --- a/scripts/templates/trcddi.cpp.mako +++ b/scripts/templates/trcddi.cpp.mako @@ -102,10 +102,9 @@ namespace ur_tracing_layer } %endfor - ${x}_result_t context_t::init(ur_dditable_t *dditable) - { + ${x}_result_t context_t::init(ur_dditable_t *dditable) { ${x}_result_t result = ${X}_RESULT_SUCCESS; - + %for tbl in th.get_pfntables(specs, meta, n, tags): if( ${X}_RESULT_SUCCESS == result ) { diff --git a/scripts/templates/valddi.cpp.mako b/scripts/templates/valddi.cpp.mako index bd8b11d5a2..1b806f4ab9 100644 --- a/scripts/templates/valddi.cpp.mako +++ b/scripts/templates/valddi.cpp.mako @@ -138,11 +138,12 @@ namespace ur_validation_layer } %endfor - ${x}_result_t context_t::init( - ${x}_dditable_t *dditable - ) - { + ${x}_result_t context_t::init(${x}_dditable_t *dditable) { ${x}_result_t result = ${X}_RESULT_SUCCESS; + + if(!enableParameterValidation && !enableLeakChecking) { + return result; + } %for tbl in th.get_pfntables(specs, meta, n, tags): if ( ${X}_RESULT_SUCCESS == result ) diff --git a/source/adapters/null/ur_nullddi.cpp b/source/adapters/null/ur_nullddi.cpp index 614aed2c27..b26735876b 100644 --- a/source/adapters/null/ur_nullddi.cpp +++ b/source/adapters/null/ur_nullddi.cpp @@ -15,15 +15,17 @@ namespace driver { /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urInit __urdlllocal ur_result_t UR_APICALL urInit( - ur_device_init_flags_t device_flags ///< [in] device initialization flags. + ur_device_init_flags_t device_flags, ///< [in] device initialization flags. ///< must be 0 (default) or a combination of ::ur_device_init_flag_t. + ur_loader_config_handle_t + hLoaderConfig ///< [in][optional] Handle of loader config handle. ) try { ur_result_t result = UR_RESULT_SUCCESS; // if the driver has created a custom function, then call it instead of using the generic path auto pfnInit = d_context.urDdiTable.Global.pfnInit; if (nullptr != pfnInit) { - result = pfnInit(device_flags); + result = pfnInit(device_flags, hLoaderConfig); } else { // generic implementation } diff --git a/source/common/ur_params.hpp b/source/common/ur_params.hpp index fd20752dad..d84bc617fa 100644 --- a/source/common/ur_params.hpp +++ b/source/common/ur_params.hpp @@ -1069,6 +1069,26 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_function_t value) { case UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_READ_RECT_EXP: os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_READ_RECT_EXP"; break; + + case UR_FUNCTION_LOADER_CONFIG_CREATE: + os << "UR_FUNCTION_LOADER_CONFIG_CREATE"; + break; + + case UR_FUNCTION_LOADER_CONFIG_RELEASE: + os << "UR_FUNCTION_LOADER_CONFIG_RELEASE"; + break; + + case UR_FUNCTION_LOADER_CONFIG_RETAIN: + os << "UR_FUNCTION_LOADER_CONFIG_RETAIN"; + break; + + case UR_FUNCTION_LOADER_CONFIG_GET_INFO: + os << "UR_FUNCTION_LOADER_CONFIG_GET_INFO"; + break; + + case UR_FUNCTION_LOADER_CONFIG_ENABLE_LAYER: + os << "UR_FUNCTION_LOADER_CONFIG_ENABLE_LAYER"; + break; default: os << "unknown enumerator"; break; @@ -1766,6 +1786,10 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_result_t value) { os << "UR_RESULT_ERROR_ADAPTER_SPECIFIC"; break; + case UR_RESULT_ERROR_LAYER_NOT_PRESENT: + os << "UR_RESULT_ERROR_LAYER_NOT_PRESENT"; + break; + case UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_EXP: os << "UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_EXP"; break; @@ -9709,6 +9733,11 @@ inline std::ostream &operator<<(std::ostream &os, ur_params::serializeFlag(os, *(params->pdevice_flags)); + os << ", "; + os << ".hLoaderConfig = "; + + ur_params::serializePtr(os, *(params->phLoaderConfig)); + return os; } diff --git a/source/loader/layers/tracing/ur_tracing_layer.cpp b/source/loader/layers/tracing/ur_tracing_layer.cpp index e12557b599..b022ae831f 100644 --- a/source/loader/layers/tracing/ur_tracing_layer.cpp +++ b/source/loader/layers/tracing/ur_tracing_layer.cpp @@ -34,7 +34,7 @@ context_t::context_t() { streamv.str().data()); } -bool context_t::isEnabled() { return xptiTraceEnabled(); } +bool context_t::isAvailable() const { return xptiTraceEnabled(); } void context_t::notify(uint16_t trace_type, uint32_t id, const char *name, void *args, ur_result_t *resultp, uint64_t instance) { diff --git a/source/loader/layers/tracing/ur_tracing_layer.hpp b/source/loader/layers/tracing/ur_tracing_layer.hpp index c2708ab976..7bcc6d272b 100644 --- a/source/loader/layers/tracing/ur_tracing_layer.hpp +++ b/source/loader/layers/tracing/ur_tracing_layer.hpp @@ -28,7 +28,13 @@ class __urdlllocal context_t : public proxy_layer_context_t { context_t(); ~context_t(); - bool isEnabled() override; + bool isAvailable() const override; + + bool isEnabled(const std::set &enabledLayerNames) override { + return enabledLayerNames.find(name) != enabledLayerNames.end(); + } + + std::vector getNames() const override { return {name}; } ur_result_t init(ur_dditable_t *dditable) override; uint64_t notify_begin(uint32_t id, const char *name, void *args); void notify_end(uint32_t id, const char *name, void *args, @@ -38,6 +44,8 @@ class __urdlllocal context_t : public proxy_layer_context_t { void notify(uint16_t trace_type, uint32_t id, const char *name, void *args, ur_result_t *resultp, uint64_t instance); uint8_t call_stream_id; + + const std::string name = "UR_LAYER_TRACING"; }; extern context_t context; diff --git a/source/loader/layers/tracing/ur_trcddi.cpp b/source/loader/layers/tracing/ur_trcddi.cpp index 820a365b21..f49622e8cf 100644 --- a/source/loader/layers/tracing/ur_trcddi.cpp +++ b/source/loader/layers/tracing/ur_trcddi.cpp @@ -18,8 +18,10 @@ namespace ur_tracing_layer { /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urInit __urdlllocal ur_result_t UR_APICALL urInit( - ur_device_init_flags_t device_flags ///< [in] device initialization flags. + ur_device_init_flags_t device_flags, ///< [in] device initialization flags. ///< must be 0 (default) or a combination of ::ur_device_init_flag_t. + ur_loader_config_handle_t + hLoaderConfig ///< [in][optional] Handle of loader config handle. ) { auto pfnInit = context.urDdiTable.Global.pfnInit; @@ -27,11 +29,11 @@ __urdlllocal ur_result_t UR_APICALL urInit( return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - ur_init_params_t params = {&device_flags}; + ur_init_params_t params = {&device_flags, &hLoaderConfig}; uint64_t instance = context.notify_begin(UR_FUNCTION_INIT, "urInit", ¶ms); - ur_result_t result = pfnInit(device_flags); + ur_result_t result = pfnInit(device_flags, hLoaderConfig); context.notify_end(UR_FUNCTION_INIT, "urInit", ¶ms, &result, instance); diff --git a/source/loader/layers/ur_proxy_layer.hpp b/source/loader/layers/ur_proxy_layer.hpp index 723011eacf..303df2b9bd 100644 --- a/source/loader/layers/ur_proxy_layer.hpp +++ b/source/loader/layers/ur_proxy_layer.hpp @@ -15,13 +15,17 @@ #include "ur_ddi.h" #include "ur_util.hpp" +#include + /////////////////////////////////////////////////////////////////////////////// class __urdlllocal proxy_layer_context_t { public: ur_api_version_t version = UR_API_VERSION_0_6; - virtual bool isEnabled() = 0; + virtual std::vector getNames() const = 0; + virtual bool isAvailable() const = 0; + virtual bool isEnabled(const std::set &enabledLayerNames) = 0; virtual ur_result_t init(ur_dditable_t *dditable) = 0; }; -#endif /* UR_PROXY_LAYER_H */ \ No newline at end of file +#endif /* UR_PROXY_LAYER_H */ diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index 954bf936eb..2929bd3489 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -17,8 +17,10 @@ namespace ur_validation_layer { /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urInit __urdlllocal ur_result_t UR_APICALL urInit( - ur_device_init_flags_t device_flags ///< [in] device initialization flags. + ur_device_init_flags_t device_flags, ///< [in] device initialization flags. ///< must be 0 (default) or a combination of ::ur_device_init_flag_t. + ur_loader_config_handle_t + hLoaderConfig ///< [in][optional] Handle of loader config handle. ) { auto pfnInit = context.urDdiTable.Global.pfnInit; @@ -32,7 +34,7 @@ __urdlllocal ur_result_t UR_APICALL urInit( } } - ur_result_t result = pfnInit(device_flags); + ur_result_t result = pfnInit(device_flags, hLoaderConfig); return result; } @@ -8146,6 +8148,10 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetDeviceProcAddrTable( ur_result_t context_t::init(ur_dditable_t *dditable) { ur_result_t result = UR_RESULT_SUCCESS; + if (!enableParameterValidation && !enableLeakChecking) { + return result; + } + if (UR_RESULT_SUCCESS == result) { result = ur_validation_layer::urGetGlobalProcAddrTable( UR_API_VERSION_CURRENT, &dditable->Global); diff --git a/source/loader/layers/validation/ur_validation_layer.cpp b/source/loader/layers/validation/ur_validation_layer.cpp index 7da014054f..1a78c0ed79 100644 --- a/source/loader/layers/validation/ur_validation_layer.cpp +++ b/source/loader/layers/validation/ur_validation_layer.cpp @@ -15,13 +15,26 @@ namespace ur_validation_layer { context_t context; /////////////////////////////////////////////////////////////////////////////// -context_t::context_t() : logger(logger::create_logger("validation")) { - enableValidation = getenv_tobool("UR_ENABLE_VALIDATION_LAYER"); - enableParameterValidation = getenv_tobool("UR_ENABLE_PARAMETER_VALIDATION"); - enableLeakChecking = getenv_tobool("UR_ENABLE_LEAK_CHECKING"); -} +context_t::context_t() : logger(logger::create_logger("validation")) {} /////////////////////////////////////////////////////////////////////////////// context_t::~context_t() {} +bool context_t::isEnabled(const std::set &enabledLayerNames) { + if (enabledLayerNames.find(nameFullValidation) != enabledLayerNames.end()) { + enableParameterValidation = true; + enableLeakChecking = true; + } else { + if (enabledLayerNames.find(nameParameterValidation) != + enabledLayerNames.end()) { + enableParameterValidation = true; + } + if (enabledLayerNames.find(nameLeakChecking) != + enabledLayerNames.end()) { + enableLeakChecking = true; + } + } + return enableParameterValidation || enableLeakChecking; +} + } // namespace ur_validation_layer diff --git a/source/loader/layers/validation/ur_validation_layer.hpp b/source/loader/layers/validation/ur_validation_layer.hpp index 5aeacc30e9..755e72504c 100644 --- a/source/loader/layers/validation/ur_validation_layer.hpp +++ b/source/loader/layers/validation/ur_validation_layer.hpp @@ -20,10 +20,8 @@ namespace ur_validation_layer { /////////////////////////////////////////////////////////////////////////////// class __urdlllocal context_t : public proxy_layer_context_t { public: - bool enableValidation = false; - bool enableParameterValidation = false; - bool enableLeakChecking = false; - + bool enableParameterValidation; + bool enableLeakChecking; logger::Logger logger; ur_dditable_t urDdiTable = {}; @@ -31,8 +29,17 @@ class __urdlllocal context_t : public proxy_layer_context_t { context_t(); ~context_t(); - bool isEnabled() override { return enableValidation; }; + bool isAvailable() const override { return true; } + bool isEnabled(const std::set &enabledLayerNames) override; + std::vector getNames() const override { + return {nameFullValidation, nameParameterValidation, nameLeakChecking}; + } ur_result_t init(ur_dditable_t *dditable) override; + + private: + const std::string nameFullValidation = "UR_LAYER_FULL_VALIDATION"; + const std::string nameParameterValidation = "UR_LAYER_PARAMETER_VALIDATION"; + const std::string nameLeakChecking = "UR_LAYER_LEAK_CHECKING"; }; extern context_t context; diff --git a/source/loader/ur_ldrddi.cpp b/source/loader/ur_ldrddi.cpp index 29ed6be85f..ebdd60c739 100644 --- a/source/loader/ur_ldrddi.cpp +++ b/source/loader/ur_ldrddi.cpp @@ -35,8 +35,10 @@ ur_exp_command_buffer_factory_t ur_exp_command_buffer_factory; /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urInit __urdlllocal ur_result_t UR_APICALL urInit( - ur_device_init_flags_t device_flags ///< [in] device initialization flags. + ur_device_init_flags_t device_flags, ///< [in] device initialization flags. ///< must be 0 (default) or a combination of ::ur_device_init_flag_t. + ur_loader_config_handle_t + hLoaderConfig ///< [in][optional] Handle of loader config handle. ) { ur_result_t result = UR_RESULT_SUCCESS; @@ -44,7 +46,8 @@ __urdlllocal ur_result_t UR_APICALL urInit( if (platform.initStatus != UR_RESULT_SUCCESS) { continue; } - platform.initStatus = platform.dditable.ur.Global.pfnInit(device_flags); + platform.initStatus = + platform.dditable.ur.Global.pfnInit(device_flags, hLoaderConfig); } return result; diff --git a/source/loader/ur_lib.cpp b/source/loader/ur_lib.cpp index cfac087348..afd558f7c5 100644 --- a/source/loader/ur_lib.cpp +++ b/source/loader/ur_lib.cpp @@ -12,25 +12,63 @@ #include "ur_lib.hpp" #include "logger/ur_logger.hpp" #include "ur_loader.hpp" -#include "ur_proxy_layer.hpp" -#include "validation/ur_validation_layer.hpp" -#if UR_ENABLE_TRACING -#include "tracing/ur_tracing_layer.hpp" -#endif +#include namespace ur_lib { /////////////////////////////////////////////////////////////////////////////// context_t *context; /////////////////////////////////////////////////////////////////////////////// -context_t::context_t() {} +context_t::context_t() { + for (auto l : layers) { + if (l->isAvailable()) { + for (auto &layerName : l->getNames()) { + availableLayers += layerName + ";"; + } + } + } + availableLayers.pop_back(); + parseEnvEnabledLayers(); +} /////////////////////////////////////////////////////////////////////////////// context_t::~context_t() {} +bool context_t::layerExists(const std::string &layerName) const { + return availableLayers.find(layerName) != std::string::npos; +} + +void context_t::parseEnvEnabledLayers() { + auto maybeEnableEnvVar = ur_getenv("UR_ENABLE_LAYERS"); + if (!maybeEnableEnvVar.has_value()) { + return; + } + auto enableEnvVar = maybeEnableEnvVar.value(); + + size_t pos = 0; + while ((pos = enableEnvVar.find(",")) != std::string::npos) { + enabledLayerNames.insert(enableEnvVar.substr(0, pos)); + enableEnvVar.erase(0, enableEnvVar.find(";") + 1); + } + + if (!enableEnvVar.empty()) { + enabledLayerNames.insert(enableEnvVar); + } +} + +void context_t::initLayers() const { + for (auto &l : layers) { + if (l->isAvailable() && l->isEnabled(enabledLayerNames)) { + l->init(&context->urDdiTable); + } + } +} + ////////////////////////////////////////////////////////////////////////// -__urdlllocal ur_result_t context_t::Init(ur_device_init_flags_t device_flags) { +__urdlllocal ur_result_t +context_t::Init(ur_device_init_flags_t device_flags, + ur_loader_config_handle_t hLoaderConfig) { ur_result_t result; const char *logger_name = "loader"; logger::init(logger_name); @@ -42,20 +80,102 @@ __urdlllocal ur_result_t context_t::Init(ur_device_init_flags_t device_flags) { result = urInit(); } - proxy_layer_context_t *layers[] = { - &ur_validation_layer::context, -#if UR_ENABLE_TRACING - &ur_tracing_layer::context -#endif - }; + if (hLoaderConfig) { + enabledLayerNames.merge(hLoaderConfig->getEnabledLayerNames()); + } - for (proxy_layer_context_t *l : layers) { - if (l->isEnabled()) { - l->init(&context->urDdiTable); - } + if (!enabledLayerNames.empty()) { + initLayers(); } return result; } +ur_result_t urLoaderConfigCreate(ur_loader_config_handle_t *phLoaderConfig) { + if (!phLoaderConfig) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + *phLoaderConfig = new ur_loader_config_handle_t_; + return UR_RESULT_SUCCESS; +} + +ur_result_t urLoaderConfigRetain(ur_loader_config_handle_t hLoaderConfig) { + if (!hLoaderConfig) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + hLoaderConfig->incrementReferenceCount(); + return UR_RESULT_SUCCESS; +} + +ur_result_t urLoaderConfigRelease(ur_loader_config_handle_t hLoaderConfig) { + if (!hLoaderConfig) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (hLoaderConfig->decrementReferenceCount() == 0) { + delete hLoaderConfig; + } + return UR_RESULT_SUCCESS; +} + +ur_result_t urLoaderConfigGetInfo(ur_loader_config_handle_t hLoaderConfig, + ur_loader_config_info_t propName, + size_t propSize, void *pPropValue, + size_t *pPropSizeRet) { + if (!hLoaderConfig) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + + if (!pPropValue && !pPropSizeRet) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + + switch (propName) { + case UR_LOADER_CONFIG_INFO_AVAILABLE_LAYERS: { + if (pPropSizeRet) { + *pPropSizeRet = context->availableLayers.size() + 1; + } + if (pPropValue) { + char *outString = static_cast(pPropValue); + if (propSize != context->availableLayers.size() + 1) { + return UR_RESULT_ERROR_INVALID_SIZE; + } + std::memcpy(outString, context->availableLayers.data(), + propSize - 1); + outString[propSize - 1] = '\0'; + } + break; + } + case UR_LOADER_CONFIG_INFO_REFERENCE_COUNT: { + auto truePropSize = sizeof(hLoaderConfig->refCount); + if (pPropSizeRet) { + *pPropSizeRet = truePropSize; + } + if (pPropValue) { + if (propSize != truePropSize) { + return UR_RESULT_ERROR_INVALID_SIZE; + } + std::memcpy(pPropValue, &hLoaderConfig->refCount, truePropSize); + } + break; + } + default: + return UR_RESULT_ERROR_INVALID_ENUMERATION; + } + return UR_RESULT_SUCCESS; +} + +ur_result_t urLoaderConfigEnableLayer(ur_loader_config_handle_t hLoaderConfig, + const char *pLayerName) { + if (!hLoaderConfig) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (!pLayerName) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + if (!context->layerExists(std::string(pLayerName))) { + return UR_RESULT_ERROR_LAYER_NOT_PRESENT; + } + hLoaderConfig->enabledLayers.insert(pLayerName); + return UR_RESULT_SUCCESS; +} } // namespace ur_lib diff --git a/source/loader/ur_lib.hpp b/source/loader/ur_lib.hpp index bd12597475..ae48f537fc 100644 --- a/source/loader/ur_lib.hpp +++ b/source/loader/ur_lib.hpp @@ -15,13 +15,30 @@ #include "ur_api.h" #include "ur_ddi.h" +#include "ur_proxy_layer.hpp" #include "ur_util.hpp" + +#include "validation/ur_validation_layer.hpp" +#if UR_ENABLE_TRACING +#include "tracing/ur_tracing_layer.hpp" +#endif + #include +#include #include +struct ur_loader_config_handle_t_ { + std::set enabledLayers; + uint32_t refCount = 1; + + size_t incrementReferenceCount() { return ++refCount; } + size_t decrementReferenceCount() { return --refCount; } + std::set &getEnabledLayerNames() { return enabledLayers; } +}; + namespace ur_lib { /////////////////////////////////////////////////////////////////////////////// -class context_t { +class __urdlllocal context_t { public: #ifdef DYNAMIC_LOAD_LOADER HMODULE loader = nullptr; @@ -32,14 +49,35 @@ class context_t { std::once_flag initOnce; - ur_result_t Init(ur_device_init_flags_t dflags); + ur_result_t Init(ur_device_init_flags_t dflags, + ur_loader_config_handle_t hLoaderConfig); ur_result_t urInit(); ur_dditable_t urDdiTable = {}; + + const std::vector layers = { + &ur_validation_layer::context, +#if UR_ENABLE_TRACING + &ur_tracing_layer::context +#endif + }; + std::string availableLayers; + std::set enabledLayerNames; + + bool layerExists(const std::string &layerName) const; + void parseEnvEnabledLayers(); + void initLayers() const; }; extern context_t *context; - +ur_result_t urLoaderConfigCreate(ur_loader_config_handle_t *phLoaderConfig); +ur_result_t urLoaderConfigRetain(ur_loader_config_handle_t hLoaderConfig); +ur_result_t urLoaderConfigRelease(ur_loader_config_handle_t hLoaderConfig); +ur_result_t urLoaderConfigGetInfo(ur_loader_config_handle_t hLoaderConfig, + ur_loader_config_info_t propName, + size_t propSize, void *pPropValue, + size_t *pPropSizeRet); +ur_result_t urLoaderConfigEnableLayer(ur_loader_config_handle_t hLoaderConfig, + const char *pLayerName); } // namespace ur_lib - #endif /* UR_LOADER_LIB_H */ diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index c75e4cea04..e5e5b847c3 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -15,6 +15,148 @@ extern "C" { +/////////////////////////////////////////////////////////////////////////////// +/// @brief Create a loader config object. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == phLoaderConfig` +ur_result_t UR_APICALL urLoaderConfigCreate( + ur_loader_config_handle_t * + phLoaderConfig ///< [out] Pointer to handle of loader config object created. + ) try { + return ur_lib::urLoaderConfigCreate(phLoaderConfig); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get a reference to the loader config object. +/// +/// @details +/// - Get a reference to the loader config handle. Increment its reference +/// count +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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 == hLoaderConfig` +ur_result_t UR_APICALL urLoaderConfigRetain( + ur_loader_config_handle_t + hLoaderConfig ///< [in] loader config handle to retain + ) try { + return ur_lib::urLoaderConfigRetain(hLoaderConfig); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Release config handle. +/// +/// @details +/// - Decrement reference count and destroy the config handle if reference +/// count becomes zero. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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 == hLoaderConfig` +ur_result_t UR_APICALL urLoaderConfigRelease( + ur_loader_config_handle_t hLoaderConfig ///< [in] config handle to release + ) try { + return ur_lib::urLoaderConfigRelease(hLoaderConfig); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Retrieves various information about the loader. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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 == hLoaderConfig` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_LOADER_CONFIG_INFO_REFERENCE_COUNT < propName` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// + If `propName` is not supported by the loader. +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `propSize == 0 && pPropValue != NULL` +/// + If `propSize` is less than the real number of bytes needed to return the info. +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `propSize != 0 && pPropValue == NULL` +/// + `pPropValue == NULL && pPropSizeRet == NULL` +/// - ::UR_RESULT_ERROR_INVALID_DEVICE +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY +ur_result_t UR_APICALL urLoaderConfigGetInfo( + ur_loader_config_handle_t + hLoaderConfig, ///< [in] handle of the loader config object + ur_loader_config_info_t propName, ///< [in] type of the info to retrieve + size_t propSize, ///< [in] the number of bytes pointed to by pPropValue. + void * + pPropValue, ///< [out][optional][typename(propName, propSize)] array of bytes holding + ///< the info. + ///< If propSize is not equal to or greater than the real number of bytes + ///< needed to return the info + ///< then the ::UR_RESULT_ERROR_INVALID_SIZE error is returned and + ///< pPropValue is not used. + size_t * + pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName. + ) try { + return ur_lib::urLoaderConfigGetInfo(hLoaderConfig, propName, propSize, + pPropValue, pPropSizeRet); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Enable a layer for the specified loader config. +/// +/// @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 == hLoaderConfig` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pLayerName` +/// - ::UR_RESULT_ERROR_LAYER_NOT_PRESENT +/// + If layer specified with `pLayerName` can't be found by the loader. +ur_result_t UR_APICALL urLoaderConfigEnableLayer( + ur_loader_config_handle_t + hLoaderConfig, ///< [in] Handle to config object the layer will be enabled for. + const char * + pLayerName ///< [in] Null terminated string containing the name of the layer to + ///< enable. + ) try { + return ur_lib::urLoaderConfigEnableLayer(hLoaderConfig, pLayerName); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Initialize the 'oneAPI' adapter(s) /// @@ -41,12 +183,14 @@ extern "C" { /// + `::UR_DEVICE_INIT_FLAGS_MASK & device_flags` /// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY ur_result_t UR_APICALL urInit( - ur_device_init_flags_t device_flags ///< [in] device initialization flags. + ur_device_init_flags_t device_flags, ///< [in] device initialization flags. ///< must be 0 (default) or a combination of ::ur_device_init_flag_t. + ur_loader_config_handle_t + hLoaderConfig ///< [in][optional] Handle of loader config handle. ) try { static ur_result_t result = UR_RESULT_SUCCESS; - std::call_once(ur_lib::context->initOnce, [device_flags]() { - result = ur_lib::context->Init(device_flags); + std::call_once(ur_lib::context->initOnce, [device_flags, hLoaderConfig]() { + result = ur_lib::context->Init(device_flags, hLoaderConfig); }); if (UR_RESULT_SUCCESS != result) { @@ -58,7 +202,7 @@ ur_result_t UR_APICALL urInit( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnInit(device_flags); + return pfnInit(device_flags, hLoaderConfig); } catch (...) { return exceptionToResult(std::current_exception()); } diff --git a/source/ur_api.cpp b/source/ur_api.cpp index d571e4c34d..4ce155ddbb 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -12,6 +12,142 @@ */ #include "ur_api.h" +/////////////////////////////////////////////////////////////////////////////// +/// @brief Create a loader config object. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == phLoaderConfig` +ur_result_t UR_APICALL urLoaderConfigCreate( + ur_loader_config_handle_t * + phLoaderConfig ///< [out] Pointer to handle of loader config object created. +) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get a reference to the loader config object. +/// +/// @details +/// - Get a reference to the loader config handle. Increment its reference +/// count +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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 == hLoaderConfig` +ur_result_t UR_APICALL urLoaderConfigRetain( + ur_loader_config_handle_t + hLoaderConfig ///< [in] loader config handle to retain +) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Release config handle. +/// +/// @details +/// - Decrement reference count and destroy the config handle if reference +/// count becomes zero. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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 == hLoaderConfig` +ur_result_t UR_APICALL urLoaderConfigRelease( + ur_loader_config_handle_t hLoaderConfig ///< [in] config handle to release +) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Retrieves various information about the loader. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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 == hLoaderConfig` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_LOADER_CONFIG_INFO_REFERENCE_COUNT < propName` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// + If `propName` is not supported by the loader. +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `propSize == 0 && pPropValue != NULL` +/// + If `propSize` is less than the real number of bytes needed to return the info. +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `propSize != 0 && pPropValue == NULL` +/// + `pPropValue == NULL && pPropSizeRet == NULL` +/// - ::UR_RESULT_ERROR_INVALID_DEVICE +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY +ur_result_t UR_APICALL urLoaderConfigGetInfo( + ur_loader_config_handle_t + hLoaderConfig, ///< [in] handle of the loader config object + ur_loader_config_info_t propName, ///< [in] type of the info to retrieve + size_t propSize, ///< [in] the number of bytes pointed to by pPropValue. + void * + pPropValue, ///< [out][optional][typename(propName, propSize)] array of bytes holding + ///< the info. + ///< If propSize is not equal to or greater than the real number of bytes + ///< needed to return the info + ///< then the ::UR_RESULT_ERROR_INVALID_SIZE error is returned and + ///< pPropValue is not used. + size_t * + pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName. +) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Enable a layer for the specified loader config. +/// +/// @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 == hLoaderConfig` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pLayerName` +/// - ::UR_RESULT_ERROR_LAYER_NOT_PRESENT +/// + If layer specified with `pLayerName` can't be found by the loader. +ur_result_t UR_APICALL urLoaderConfigEnableLayer( + ur_loader_config_handle_t + hLoaderConfig, ///< [in] Handle to config object the layer will be enabled for. + const char * + pLayerName ///< [in] Null terminated string containing the name of the layer to + ///< enable. +) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Initialize the 'oneAPI' adapter(s) /// @@ -38,8 +174,10 @@ /// + `::UR_DEVICE_INIT_FLAGS_MASK & device_flags` /// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY ur_result_t UR_APICALL urInit( - ur_device_init_flags_t device_flags ///< [in] device initialization flags. + ur_device_init_flags_t device_flags, ///< [in] device initialization flags. ///< must be 0 (default) or a combination of ::ur_device_init_flag_t. + ur_loader_config_handle_t + hLoaderConfig ///< [in][optional] Handle of loader config handle. ) { ur_result_t result = UR_RESULT_SUCCESS; return result; diff --git a/test/conformance/platform/fixtures.h b/test/conformance/platform/fixtures.h index 77f1f5465d..038d8f9ff4 100644 --- a/test/conformance/platform/fixtures.h +++ b/test/conformance/platform/fixtures.h @@ -14,7 +14,7 @@ struct urTest : ::testing::Test { void SetUp() override { ur_device_init_flags_t device_flags = 0; - ASSERT_SUCCESS(urInit(device_flags)); + ASSERT_SUCCESS(urInit(device_flags, nullptr)); } void TearDown() override { diff --git a/test/conformance/platform/urInit.cpp b/test/conformance/platform/urInit.cpp index eedf58af34..1de30ff471 100644 --- a/test/conformance/platform/urInit.cpp +++ b/test/conformance/platform/urInit.cpp @@ -20,8 +20,12 @@ INSTANTIATE_TEST_SUITE_P( }); TEST_P(urInitTestWithParam, Success) { + ur_loader_config_handle_t config = nullptr; + urLoaderConfigCreate(&config); + urLoaderConfigEnableLayer(config, "UR_LAYER_FULL_VALIDATION"); + ur_device_init_flags_t device_flags = GetParam(); - ASSERT_SUCCESS(urInit(device_flags)); + ASSERT_SUCCESS(urInit(device_flags, config)); ur_tear_down_params_t tear_down_params{nullptr}; ASSERT_SUCCESS(urTearDown(&tear_down_params)); @@ -30,5 +34,6 @@ TEST_P(urInitTestWithParam, Success) { TEST(urInitTest, ErrorInvalidEnumerationDeviceFlags) { const ur_device_init_flags_t device_flags = UR_DEVICE_INIT_FLAG_FORCE_UINT32; - ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_ENUMERATION, urInit(device_flags)); + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_ENUMERATION, + urInit(device_flags, nullptr)); } diff --git a/test/conformance/platform/urTearDown.cpp b/test/conformance/platform/urTearDown.cpp index e4dd0bbcb8..3639515f82 100644 --- a/test/conformance/platform/urTearDown.cpp +++ b/test/conformance/platform/urTearDown.cpp @@ -7,7 +7,7 @@ struct urTearDownTest : testing::Test { void SetUp() override { ur_device_init_flags_t device_flags = 0; - ASSERT_SUCCESS(urInit(device_flags)); + ASSERT_SUCCESS(urInit(device_flags, nullptr)); } }; diff --git a/test/conformance/source/environment.cpp b/test/conformance/source/environment.cpp index 1da7ad7c86..af545f4c11 100644 --- a/test/conformance/source/environment.cpp +++ b/test/conformance/source/environment.cpp @@ -43,8 +43,13 @@ std::ostream &operator<<(std::ostream &out, uur::PlatformEnvironment::PlatformEnvironment(int argc, char **argv) : platform_options{parsePlatformOptions(argc, argv)} { instance = this; + + ur_loader_config_handle_t config; + urLoaderConfigCreate(&config); + urLoaderConfigEnableLayer(config, "UR_LAYER_FULL_VALIDATION"); + ur_device_init_flags_t device_flags = 0; - switch (urInit(device_flags)) { + switch (urInit(device_flags, config)) { case UR_RESULT_SUCCESS: break; case UR_RESULT_ERROR_UNINITIALIZED: @@ -54,6 +59,7 @@ uur::PlatformEnvironment::PlatformEnvironment(int argc, char **argv) error = "urInit() failed"; return; } + urLoaderConfigRelease(config); uint32_t count = 0; if (urPlatformGet(0, nullptr, &count)) { diff --git a/test/layers/tracing/CMakeLists.txt b/test/layers/tracing/CMakeLists.txt index 3fe641824d..db4b9da590 100644 --- a/test/layers/tracing/CMakeLists.txt +++ b/test/layers/tracing/CMakeLists.txt @@ -22,4 +22,5 @@ set_property(TEST ${TEST_NAME} PROPERTY ENVIRONMENT "XPTI_TRACE_ENABLE=1" "XPTI_FRAMEWORK_DISPATCHER=$" "XPTI_SUBSCRIBERS=$" - "UR_ADAPTERS_FORCE_LOAD=\"$\"") + "UR_ADAPTERS_FORCE_LOAD=\"$\"" + "UR_ENABLE_LAYERS=UR_LAYER_TRACING") diff --git a/test/layers/validation/CMakeLists.txt b/test/layers/validation/CMakeLists.txt index 83b2be102c..85d639d196 100644 --- a/test/layers/validation/CMakeLists.txt +++ b/test/layers/validation/CMakeLists.txt @@ -20,9 +20,7 @@ function(add_validation_test name) WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) set_tests_properties(${name} PROPERTIES LABELS "validation") set_property(TEST ${name} PROPERTY ENVIRONMENT - "UR_ENABLE_VALIDATION_LAYER=1" - "UR_ENABLE_PARAMETER_VALIDATION=1" - "UR_ENABLE_LEAK_CHECKING=1" + "UR_ENABLE_LAYERS=UR_LAYER_FULL_VALIDATION" "UR_ADAPTERS_FORCE_LOAD=\"$\"" "UR_LOG_VALIDATION=level:debug\;flush:debug\;output:stdout") endfunction() diff --git a/test/layers/validation/fixtures.hpp b/test/layers/validation/fixtures.hpp index 0348068fa9..11e2a33f24 100644 --- a/test/layers/validation/fixtures.hpp +++ b/test/layers/validation/fixtures.hpp @@ -12,8 +12,14 @@ struct urTest : ::testing::Test { void SetUp() override { + ur_loader_config_handle_t config; + ASSERT_EQ(urLoaderConfigCreate(&config), UR_RESULT_SUCCESS); + ASSERT_EQ(urLoaderConfigEnableLayer(config, "UR_LAYER_FULL_VALIDATION"), + UR_RESULT_SUCCESS); + ur_device_init_flags_t device_flags = 0; - ASSERT_EQ(urInit(device_flags), UR_RESULT_SUCCESS); + ASSERT_EQ(urInit(device_flags, config), UR_RESULT_SUCCESS); + ASSERT_EQ(urLoaderConfigRelease(config), UR_RESULT_SUCCESS); } void TearDown() override { diff --git a/test/layers/validation/parameters.cpp b/test/layers/validation/parameters.cpp index e7f73e87fc..ee679363dc 100644 --- a/test/layers/validation/parameters.cpp +++ b/test/layers/validation/parameters.cpp @@ -6,9 +6,15 @@ #include "fixtures.hpp" TEST(valTest, urInit) { + ur_loader_config_handle_t config; + urLoaderConfigCreate(&config); + urLoaderConfigEnableLayer(config, "UR_PARAMETER_VALIDATION_LAYER"); + const ur_device_init_flags_t device_flags = UR_DEVICE_INIT_FLAG_FORCE_UINT32; - ASSERT_EQ(UR_RESULT_ERROR_INVALID_ENUMERATION, urInit(device_flags)); + ASSERT_EQ(urInit(device_flags, config), + UR_RESULT_ERROR_INVALID_ENUMERATION); + ASSERT_EQ(urLoaderConfigRelease(config), UR_RESULT_SUCCESS); } TEST_F(valPlatformsTest, testUrPlatformGetApiVersion) { diff --git a/test/loader/CMakeLists.txt b/test/loader/CMakeLists.txt index e26e065ff8..0dbf999c45 100644 --- a/test/loader/CMakeLists.txt +++ b/test/loader/CMakeLists.txt @@ -9,4 +9,5 @@ set_tests_properties(example-hello-world PROPERTIES LABELS "loader" ) add_subdirectory(adapter_registry) +add_subdirectory(loader_config) add_subdirectory(platforms) diff --git a/test/loader/loader_config/CMakeLists.txt b/test/loader/loader_config/CMakeLists.txt new file mode 100644 index 0000000000..b2c2ffc4ec --- /dev/null +++ b/test/loader/loader_config/CMakeLists.txt @@ -0,0 +1,26 @@ +# Copyright (C) 2023 Intel Corporation +# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +# See LICENSE.TXT +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +add_executable(test-loader-config + urLoaderConfigCreate.cpp + urLoaderConfigGetInfo.cpp + urLoaderConfigEnableLayer.cpp + urLoaderConfigRelease.cpp + urLoaderConfigRetain.cpp +) + +target_link_libraries(test-loader-config + PRIVATE + ${PROJECT_NAME}::common + ${PROJECT_NAME}::headers + ${PROJECT_NAME}::loader + gmock + GTest::gtest_main +) + +add_test(NAME loader-config + COMMAND test-loader-config + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +) diff --git a/test/loader/loader_config/fixtures.hpp b/test/loader/loader_config/fixtures.hpp new file mode 100644 index 0000000000..3c1c52a0b1 --- /dev/null +++ b/test/loader/loader_config/fixtures.hpp @@ -0,0 +1,30 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#ifndef UR_LOADER_CONFIG_TEST_FIXTURES_H +#define UR_LOADER_CONFIG_TEST_FIXTURES_H + +#include "ur_api.h" +#include + +#ifndef ASSERT_SUCCESS +#define ASSERT_SUCCESS(ACTUAL) ASSERT_EQ(UR_RESULT_SUCCESS, ACTUAL) +#endif + +struct LoaderConfigTest : ::testing::Test { + void SetUp() override { + ASSERT_SUCCESS(urLoaderConfigCreate(&loaderConfig)); + } + + void TearDown() override { + if (loaderConfig) { + ASSERT_SUCCESS(urLoaderConfigRelease(loaderConfig)); + } + } + + ur_loader_config_handle_t loaderConfig = nullptr; +}; + +#endif diff --git a/test/loader/loader_config/urLoaderConfigCreate.cpp b/test/loader/loader_config/urLoaderConfigCreate.cpp new file mode 100644 index 0000000000..442f6e41dc --- /dev/null +++ b/test/loader/loader_config/urLoaderConfigCreate.cpp @@ -0,0 +1,19 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "fixtures.hpp" + +struct LoaderConfigCreateTest : ::testing::Test {}; + +TEST_F(LoaderConfigCreateTest, Success) { + ur_loader_config_handle_t loaderConfig = nullptr; + ASSERT_SUCCESS(urLoaderConfigCreate(&loaderConfig)); + ASSERT_SUCCESS(urLoaderConfigRelease(loaderConfig)); +} + +TEST_F(LoaderConfigCreateTest, InvalidNullPointerLoaderConfig) { + ASSERT_EQ(UR_RESULT_ERROR_INVALID_NULL_POINTER, + urLoaderConfigCreate(nullptr)); +} diff --git a/test/loader/loader_config/urLoaderConfigEnableLayer.cpp b/test/loader/loader_config/urLoaderConfigEnableLayer.cpp new file mode 100644 index 0000000000..60a50c1469 --- /dev/null +++ b/test/loader/loader_config/urLoaderConfigEnableLayer.cpp @@ -0,0 +1,46 @@ +// Copyright (C) 2022-2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "fixtures.hpp" + +struct urLoaderConfigEnableLayerTest : LoaderConfigTest { + void SetUp() override { + LoaderConfigTest::SetUp(); + // Get the first available layer to test with + size_t availableLayersLen = 0; + ASSERT_SUCCESS(urLoaderConfigGetInfo( + loaderConfig, UR_LOADER_CONFIG_INFO_AVAILABLE_LAYERS, 0, nullptr, + &availableLayersLen)); + validLayerName.resize(availableLayersLen); + ASSERT_SUCCESS(urLoaderConfigGetInfo( + loaderConfig, UR_LOADER_CONFIG_INFO_AVAILABLE_LAYERS, + availableLayersLen, validLayerName.data(), nullptr)); + if (validLayerName.find(";") != std::string::npos) { + validLayerName = validLayerName.substr(0, validLayerName.find(";")); + } + } + + std::string validLayerName; +}; + +TEST_F(urLoaderConfigEnableLayerTest, Success) { + ASSERT_SUCCESS( + urLoaderConfigEnableLayer(loaderConfig, validLayerName.data())); +} + +TEST_F(urLoaderConfigEnableLayerTest, LayerNotPresent) { + ASSERT_EQ(UR_RESULT_ERROR_LAYER_NOT_PRESENT, + urLoaderConfigEnableLayer(loaderConfig, "not a real layer")); +} + +TEST_F(urLoaderConfigEnableLayerTest, InvalidNullHandleLoaderConfig) { + ASSERT_EQ(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urLoaderConfigEnableLayer(nullptr, validLayerName.data())); +} + +TEST_F(urLoaderConfigEnableLayerTest, InvalidNullPointerLayerName) { + ASSERT_EQ(UR_RESULT_ERROR_INVALID_NULL_POINTER, + urLoaderConfigEnableLayer(loaderConfig, nullptr)); +} diff --git a/test/loader/loader_config/urLoaderConfigGetInfo.cpp b/test/loader/loader_config/urLoaderConfigGetInfo.cpp new file mode 100644 index 0000000000..1985e57060 --- /dev/null +++ b/test/loader/loader_config/urLoaderConfigGetInfo.cpp @@ -0,0 +1,52 @@ +// Copyright (C) 2022-2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "fixtures.hpp" + +struct urLoaderConfigGetInfoTest + : LoaderConfigTest, + ::testing::WithParamInterface { + void SetUp() override { + LoaderConfigTest::SetUp(); + infoType = GetParam(); + ASSERT_SUCCESS(urLoaderConfigGetInfo(loaderConfig, infoType, 0, nullptr, + &infoSize)); + EXPECT_NE(0, infoSize); + infoAllocation.resize(infoSize); + } + + ur_loader_config_info_t infoType; + size_t infoSize = 0; + std::vector infoAllocation; +}; + +INSTANTIATE_TEST_SUITE_P( + , urLoaderConfigGetInfoTest, + ::testing::Values(UR_LOADER_CONFIG_INFO_AVAILABLE_LAYERS, + UR_LOADER_CONFIG_INFO_REFERENCE_COUNT)); + +TEST_P(urLoaderConfigGetInfoTest, Success) { + ASSERT_SUCCESS(urLoaderConfigGetInfo(loaderConfig, infoType, infoSize, + infoAllocation.data(), nullptr)); +} + +TEST_P(urLoaderConfigGetInfoTest, InvalidNullHandleLoaderConfig) { + ASSERT_EQ(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urLoaderConfigGetInfo(nullptr, infoType, infoSize, + infoAllocation.data(), nullptr)); +} + +TEST_P(urLoaderConfigGetInfoTest, InvalidNullPointer) { + ASSERT_EQ( + UR_RESULT_ERROR_INVALID_NULL_POINTER, + urLoaderConfigGetInfo(loaderConfig, infoType, 0, nullptr, nullptr)); +} + +TEST_P(urLoaderConfigGetInfoTest, InvalidEnumerationInfoType) { + ASSERT_EQ(UR_RESULT_ERROR_INVALID_ENUMERATION, + urLoaderConfigGetInfo(loaderConfig, + UR_LOADER_CONFIG_INFO_FORCE_UINT32, 0, + nullptr, &infoSize)); +} diff --git a/test/loader/loader_config/urLoaderConfigRelease.cpp b/test/loader/loader_config/urLoaderConfigRelease.cpp new file mode 100644 index 0000000000..b58a954a1f --- /dev/null +++ b/test/loader/loader_config/urLoaderConfigRelease.cpp @@ -0,0 +1,31 @@ +// Copyright (C) 2022-2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "fixtures.hpp" + +using urLoaderConfigReleaseTest = LoaderConfigTest; + +TEST_F(urLoaderConfigReleaseTest, Success) { + ASSERT_SUCCESS(urLoaderConfigRetain(loaderConfig)); + + uint32_t prevRefCount = 0; + ASSERT_SUCCESS(urLoaderConfigGetInfo( + loaderConfig, UR_LOADER_CONFIG_INFO_REFERENCE_COUNT, + sizeof(prevRefCount), &prevRefCount, nullptr)); + + ASSERT_SUCCESS(urLoaderConfigRelease(loaderConfig)); + + uint32_t refCount = 0; + ASSERT_SUCCESS(urLoaderConfigGetInfo(loaderConfig, + UR_LOADER_CONFIG_INFO_REFERENCE_COUNT, + sizeof(refCount), &refCount, nullptr)); + + ASSERT_LT(refCount, prevRefCount); +} + +TEST_F(urLoaderConfigReleaseTest, InvalidNullHandleLoaderConfig) { + ASSERT_EQ(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urLoaderConfigRelease(nullptr)); +} diff --git a/test/loader/loader_config/urLoaderConfigRetain.cpp b/test/loader/loader_config/urLoaderConfigRetain.cpp new file mode 100644 index 0000000000..583b37c13e --- /dev/null +++ b/test/loader/loader_config/urLoaderConfigRetain.cpp @@ -0,0 +1,31 @@ +// Copyright (C) 2022-2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "fixtures.hpp" + +using urLoaderConfigRetainTest = LoaderConfigTest; + +TEST_F(urLoaderConfigRetainTest, Success) { + uint32_t prevRefCount = 0; + ASSERT_SUCCESS(urLoaderConfigGetInfo( + loaderConfig, UR_LOADER_CONFIG_INFO_REFERENCE_COUNT, + sizeof(prevRefCount), &prevRefCount, nullptr)); + + ASSERT_SUCCESS(urLoaderConfigRetain(loaderConfig)); + + uint32_t refCount = 0; + ASSERT_SUCCESS(urLoaderConfigGetInfo(loaderConfig, + UR_LOADER_CONFIG_INFO_REFERENCE_COUNT, + sizeof(refCount), &refCount, nullptr)); + + ASSERT_GT(refCount, prevRefCount); + + ASSERT_SUCCESS(urLoaderConfigRelease(loaderConfig)); +} + +TEST_F(urLoaderConfigRetainTest, InvalidNullHandleLoaderConfig) { + ASSERT_EQ(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urLoaderConfigRetain(nullptr)); +} diff --git a/test/loader/platforms/platforms.cpp b/test/loader/platforms/platforms.cpp index 2b7c3c8146..c39b0af160 100644 --- a/test/loader/platforms/platforms.cpp +++ b/test/loader/platforms/platforms.cpp @@ -24,7 +24,7 @@ int main(int argc, char *argv[]) { ur_result_t status; // Initialize the platform - status = urInit(0); + status = urInit(0, nullptr); if (status != UR_RESULT_SUCCESS) { error("urInit failed with return code: {}", status); return 1; diff --git a/test/tools/urtrace/null_hello.match b/test/tools/urtrace/null_hello.match index 59e4c95367..0c76ccac1a 100644 --- a/test/tools/urtrace/null_hello.match +++ b/test/tools/urtrace/null_hello.match @@ -1,4 +1,4 @@ -urInit(.device_flags = 0) -> UR_RESULT_SUCCESS; +urInit(.device_flags = 0, .hLoaderConfig = nullptr) -> UR_RESULT_SUCCESS; Platform initialized. urPlatformGet(.NumEntries = 1, .phPlatforms = {}, .pNumPlatforms = {{.*}} (1)) -> UR_RESULT_SUCCESS; urPlatformGet(.NumEntries = 1, .phPlatforms = {{{.*}}}, .pNumPlatforms = nullptr) -> UR_RESULT_SUCCESS; diff --git a/test/tools/urtrace/null_hello_begin.match b/test/tools/urtrace/null_hello_begin.match index c706e5616d..114eedfc23 100644 --- a/test/tools/urtrace/null_hello_begin.match +++ b/test/tools/urtrace/null_hello_begin.match @@ -1,5 +1,5 @@ -begin(1) - urInit(.device_flags = 0); -end(1) - urInit(.device_flags = 0) -> UR_RESULT_SUCCESS; +begin(1) - urInit(.device_flags = 0, .hLoaderConfig = nullptr); +end(1) - urInit(.device_flags = 0, .hLoaderConfig = nullptr) -> UR_RESULT_SUCCESS; Platform initialized. begin(2) - urPlatformGet(.NumEntries = 1, .phPlatforms = {}, .pNumPlatforms = {{.*}} (0)); end(2) - urPlatformGet(.NumEntries = 1, .phPlatforms = {}, .pNumPlatforms = {{.*}} (1)) -> UR_RESULT_SUCCESS; diff --git a/test/tools/urtrace/null_hello_json.match b/test/tools/urtrace/null_hello_json.match index 9b41e6e0d7..7e7c089f73 100644 --- a/test/tools/urtrace/null_hello_json.match +++ b/test/tools/urtrace/null_hello_json.match @@ -1,6 +1,6 @@ { "traceEvents": [ -{ "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urInit", "args": "(.device_flags = 0)" }, +{ "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urInit", "args": "(.device_flags = 0, .hLoaderConfig = nullptr)" }, Platform initialized. { "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urPlatformGet", "args": "(.NumEntries = 1, .phPlatforms = {}, .pNumPlatforms = {{.*}} (1))" }, { "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urPlatformGet", "args": "(.NumEntries = 1, .phPlatforms = {{{.*}}}, .pNumPlatforms = nullptr)" }, @@ -14,4 +14,4 @@ Found a Null Device gpu. { "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urTearDown", "args": "(.pParams = nullptr)" }, {"name": "", "cat": "", "ph": "", "pid": "", "tid": "", "ts": ""} ] -} \ No newline at end of file +} diff --git a/test/tools/urtrace/null_hello_profiling.match b/test/tools/urtrace/null_hello_profiling.match index 1162bb4a53..3ad7ae3614 100644 --- a/test/tools/urtrace/null_hello_profiling.match +++ b/test/tools/urtrace/null_hello_profiling.match @@ -1,4 +1,4 @@ -urInit(.device_flags = 0) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) +urInit(.device_flags = 0, .hLoaderConfig = nullptr) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) Platform initialized. urPlatformGet(.NumEntries = 1, .phPlatforms = {}, .pNumPlatforms = {{.*}} (1)) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) urPlatformGet(.NumEntries = 1, .phPlatforms = {{{.*}}}, .pNumPlatforms = nullptr) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) diff --git a/test/unit/utils/params.cpp b/test/unit/utils/params.cpp index b1621f7bb2..da87800121 100644 --- a/test/unit/utils/params.cpp +++ b/test/unit/utils/params.cpp @@ -20,8 +20,11 @@ template class ParamsTest : public testing::Test { struct UrInitParams { ur_init_params_t params; ur_device_init_flags_t flags; - UrInitParams(ur_device_init_flags_t _flags) : flags(_flags) { + ur_loader_config_handle_t config; + UrInitParams(ur_device_init_flags_t _flags) + : flags(_flags), config(nullptr) { params.pdevice_flags = &flags; + params.phLoaderConfig = &config; } ur_init_params_t *get_struct() { return ¶ms; } @@ -29,7 +32,9 @@ struct UrInitParams { struct UrInitParamsNoFlags : UrInitParams { UrInitParamsNoFlags() : UrInitParams(0) {} - const char *get_expected() { return ".device_flags = 0"; }; + const char *get_expected() { + return ".device_flags = 0, .hLoaderConfig = nullptr"; + }; }; struct UrInitParamsInvalidFlags : UrInitParams { @@ -39,7 +44,8 @@ struct UrInitParamsInvalidFlags : UrInitParams { const char *get_expected() { return ".device_flags = UR_DEVICE_INIT_FLAG_GPU \\| " "UR_DEVICE_INIT_FLAG_MCA \\| unknown bit flags " - "11000010000000000000000000000000"; + "11000010000000000000000000000000, " + ".hLoaderConfig = nullptr"; }; }; diff --git a/tools/urtrace/urtrace.py b/tools/urtrace/urtrace.py index 8ed43abc50..7b337d7cc8 100755 --- a/tools/urtrace/urtrace.py +++ b/tools/urtrace/urtrace.py @@ -96,6 +96,8 @@ def get_dynamic_library_name(name): env['XPTI_TRACE_ENABLE'] = "1" +env['UR_ENABLE_LAYERS'] = "UR_LAYER_TRACING" + xptifw_lib = get_dynamic_library_name("xptifw") xptifw = find_library(args.libpath, xptifw_lib, args.recursive) if xptifw is None: From c46db284aea831fa8b411bc5833dadef461486ce Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Mon, 17 Jul 2023 14:12:03 +0100 Subject: [PATCH 074/104] [ur] Update CTS to match native handle nocheck Follow up from #720 where the `nocheck` option was added to the `ur_native_handle_t` arguments of `urCreateWithNativeHandle`. This patch removes tests which assumed that `ur_native_handle_t` must not be `nullptr` which is an incorrect assumption. --- .../urContextCreateWithNativeHandle.cpp | 24 ++++++++---- .../context/urContextGetNativeHandle.cpp | 15 ------- .../device/urDeviceCreateWithNativeHandle.cpp | 25 +++++++++--- .../device/urDeviceGetNativeHandle.cpp | 13 ------- .../event/urEventCreateWithNativeHandle.cpp | 28 +++++++++---- .../event/urEventGetNativeHandle.cpp | 16 -------- .../kernel/urKernelCreateWithNativeHandle.cpp | 7 ---- .../kernel/urKernelGetNativeHandle.cpp | 18 --------- .../urMemBufferCreateWithNativeHandle.cpp | 26 +++++++++++-- .../memory/urMemGetNativeHandle.cpp | 20 ---------- .../urMemImageCreateWithNativeHandle.cpp | 39 ++++++++----------- .../urPlatformCreateWithNativeHandle.cpp | 33 +++++++++++++--- .../platform/urPlatformGetNativeHandle.cpp | 14 ------- .../urProgramCreateWithNativeHandle.cpp | 6 --- .../program/urProgramGetNativeHandle.cpp | 12 ------ .../queue/urQueueCreateWithNativeHandle.cpp | 25 +++++++++--- .../queue/urQueueGetNativeHandle.cpp | 16 -------- .../urSamplerCreateWithNativeHandle.cpp | 24 +++++++++--- .../sampler/urSamplerGetNativeHandle.cpp | 15 ------- .../testing/include/uur/fixtures.h | 32 +++++++++++++++ 20 files changed, 192 insertions(+), 216 deletions(-) diff --git a/test/conformance/context/urContextCreateWithNativeHandle.cpp b/test/conformance/context/urContextCreateWithNativeHandle.cpp index b227cebbf3..21881169cc 100644 --- a/test/conformance/context/urContextCreateWithNativeHandle.cpp +++ b/test/conformance/context/urContextCreateWithNativeHandle.cpp @@ -5,14 +5,24 @@ #include -using urContextCreateWithNativeHandleTest = uur::urDeviceTest; - +using urContextCreateWithNativeHandleTest = uur::urContextTest; UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urContextCreateWithNativeHandleTest); -TEST_P(urContextCreateWithNativeHandleTest, InvalidNullHandleNativeHandle) { - ur_context_handle_t context = nullptr; +TEST_P(urContextCreateWithNativeHandleTest, Success) { + ur_native_handle_t native_context = nullptr; + ASSERT_SUCCESS(urContextGetNativeHandle(context, &native_context)); + + // We cannot assume anything about a native_handle, not even if it's + // `nullptr` since this could be a valid representation within a backend. + // We can however convert the native_handle back into a unified-runtime handle + // and perform some query on it to verify that it works. + ur_context_handle_t ctx = nullptr; ur_context_native_properties_t props{}; - ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, - urContextCreateWithNativeHandle(nullptr, 0u, nullptr, - &props, &context)); + ASSERT_SUCCESS(urContextCreateWithNativeHandle(native_context, 0, nullptr, + &props, &ctx)); + ASSERT_NE(ctx, nullptr); + + uint32_t n_devices = 0; + ASSERT_SUCCESS(urContextGetInfo(ctx, UR_CONTEXT_INFO_NUM_DEVICES, + sizeof(uint32_t), &n_devices, nullptr)); } diff --git a/test/conformance/context/urContextGetNativeHandle.cpp b/test/conformance/context/urContextGetNativeHandle.cpp index 328649d590..420379fca4 100644 --- a/test/conformance/context/urContextGetNativeHandle.cpp +++ b/test/conformance/context/urContextGetNativeHandle.cpp @@ -6,26 +6,11 @@ #include using urContextGetNativeHandleTest = uur::urContextTest; - UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urContextGetNativeHandleTest); TEST_P(urContextGetNativeHandleTest, Success) { ur_native_handle_t native_context = nullptr; ASSERT_SUCCESS(urContextGetNativeHandle(context, &native_context)); - - // We cannot assume anything about a native_handle, not even if it's - // `nullptr` since this could be a valid representation within a backend. - // We can however convert the native_handle back into a unified-runtime handle - // and perform some query on it to verify that it works. - ur_context_handle_t ctx = nullptr; - ur_context_native_properties_t props{}; - ASSERT_SUCCESS(urContextCreateWithNativeHandle(native_context, 0, nullptr, - &props, &ctx)); - ASSERT_NE(ctx, nullptr); - - uint32_t n_devices = 0; - ASSERT_SUCCESS(urContextGetInfo(ctx, UR_CONTEXT_INFO_NUM_DEVICES, - sizeof(uint32_t), &n_devices, nullptr)); } TEST_P(urContextGetNativeHandleTest, InvalidNullHandleContext) { diff --git a/test/conformance/device/urDeviceCreateWithNativeHandle.cpp b/test/conformance/device/urDeviceCreateWithNativeHandle.cpp index ab16ca74a5..5707a4088b 100644 --- a/test/conformance/device/urDeviceCreateWithNativeHandle.cpp +++ b/test/conformance/device/urDeviceCreateWithNativeHandle.cpp @@ -4,11 +4,24 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include -using urDeviceCreateWithNativeHandleTest = uur::urPlatformTest; +using urDeviceCreateWithNativeHandleTest = uur::urAllDevicesTest; -TEST_F(urDeviceCreateWithNativeHandleTest, InvalidNullHandleNativeDevice) { - ur_device_handle_t device = nullptr; - ASSERT_EQ_RESULT( - UR_RESULT_ERROR_INVALID_NULL_HANDLE, - urDeviceCreateWithNativeHandle(nullptr, platform, nullptr, &device)); +TEST_F(urDeviceCreateWithNativeHandleTest, Success) { + for (auto device : devices) { + ur_native_handle_t native_handle = nullptr; + ASSERT_SUCCESS(urDeviceGetNativeHandle(device, &native_handle)); + + // We cannot assume anything about a native_handle, not even if it's + // `nullptr` since this could be a valid representation within a backend. + // We can however convert the native_handle back into a unified-runtime handle + // and perform some query on it to verify that it works. + ur_device_handle_t dev = nullptr; + ASSERT_SUCCESS(urDeviceCreateWithNativeHandle(native_handle, platform, + nullptr, &dev)); + ASSERT_NE(dev, nullptr); + + uint32_t dev_id = 0; + ASSERT_SUCCESS(urDeviceGetInfo(dev, UR_DEVICE_INFO_TYPE, + sizeof(uint32_t), &dev_id, nullptr)); + } } diff --git a/test/conformance/device/urDeviceGetNativeHandle.cpp b/test/conformance/device/urDeviceGetNativeHandle.cpp index 0ce43d37bc..301ec16d1d 100644 --- a/test/conformance/device/urDeviceGetNativeHandle.cpp +++ b/test/conformance/device/urDeviceGetNativeHandle.cpp @@ -10,19 +10,6 @@ TEST_F(urDeviceGetNativeHandleTest, Success) { for (auto device : devices) { ur_native_handle_t native_handle = nullptr; ASSERT_SUCCESS(urDeviceGetNativeHandle(device, &native_handle)); - - // We cannot assume anything about a native_handle, not even if it's - // `nullptr` since this could be a valid representation within a backend. - // We can however convert the native_handle back into a unified-runtime handle - // and perform some query on it to verify that it works. - ur_device_handle_t dev = nullptr; - ASSERT_SUCCESS(urDeviceCreateWithNativeHandle(native_handle, platform, - nullptr, &dev)); - ASSERT_NE(dev, nullptr); - - uint32_t dev_id = 0; - ASSERT_SUCCESS(urDeviceGetInfo(dev, UR_DEVICE_INFO_TYPE, - sizeof(uint32_t), &dev_id, nullptr)); } } diff --git a/test/conformance/event/urEventCreateWithNativeHandle.cpp b/test/conformance/event/urEventCreateWithNativeHandle.cpp index b8613540cb..29f1c1b9dc 100644 --- a/test/conformance/event/urEventCreateWithNativeHandle.cpp +++ b/test/conformance/event/urEventCreateWithNativeHandle.cpp @@ -3,14 +3,28 @@ // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#include +#include "fixtures.h" -using urEventCreateWithNativeHandleTest = uur::urContextTest; +using urEventCreateWithNativeHandleTest = uur::event::urEventTest; UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urEventCreateWithNativeHandleTest); -TEST_P(urEventCreateWithNativeHandleTest, InvalidNullHandleNativeEvent) { - ur_event_handle_t event = nullptr; - ASSERT_EQ_RESULT( - UR_RESULT_ERROR_INVALID_NULL_HANDLE, - urEventCreateWithNativeHandle(nullptr, context, nullptr, &event)); +TEST_P(urEventCreateWithNativeHandleTest, Success) { + ur_native_handle_t native_event = nullptr; + ASSERT_SUCCESS(urEventGetNativeHandle(event, &native_event)); + + // We cannot assume anything about a native_handle, not even if it's + // `nullptr` since this could be a valid representation within a backend. + // We can however convert the native_handle back into a unified-runtime handle + // and perform some query on it to verify that it works. + ur_event_handle_t evt = nullptr; + ASSERT_SUCCESS( + urEventCreateWithNativeHandle(native_event, context, nullptr, &evt)); + ASSERT_NE(evt, nullptr); + + ur_execution_info_t exec_info; + ASSERT_SUCCESS(urEventGetInfo(evt, UR_EVENT_INFO_COMMAND_EXECUTION_STATUS, + sizeof(ur_execution_info_t), &exec_info, + nullptr)); + + ASSERT_SUCCESS(urEventRelease(evt)); } diff --git a/test/conformance/event/urEventGetNativeHandle.cpp b/test/conformance/event/urEventGetNativeHandle.cpp index b97f63c8ba..6a6003091d 100644 --- a/test/conformance/event/urEventGetNativeHandle.cpp +++ b/test/conformance/event/urEventGetNativeHandle.cpp @@ -11,22 +11,6 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urEventGetNativeHandleTest); TEST_P(urEventGetNativeHandleTest, Success) { ur_native_handle_t native_event = nullptr; ASSERT_SUCCESS(urEventGetNativeHandle(event, &native_event)); - - // We cannot assume anything about a native_handle, not even if it's - // `nullptr` since this could be a valid representation within a backend. - // We can however convert the native_handle back into a unified-runtime handle - // and perform some query on it to verify that it works. - ur_event_handle_t evt = nullptr; - ASSERT_SUCCESS( - urEventCreateWithNativeHandle(native_event, context, nullptr, &evt)); - ASSERT_NE(evt, nullptr); - - ur_execution_info_t exec_info; - ASSERT_SUCCESS(urEventGetInfo(evt, UR_EVENT_INFO_COMMAND_EXECUTION_STATUS, - sizeof(ur_execution_info_t), &exec_info, - nullptr)); - - ASSERT_SUCCESS(urEventRelease(evt)); } TEST_P(urEventGetNativeHandleTest, InvalidNullHandleEvent) { diff --git a/test/conformance/kernel/urKernelCreateWithNativeHandle.cpp b/test/conformance/kernel/urKernelCreateWithNativeHandle.cpp index 365bc8cc08..336d44fd45 100644 --- a/test/conformance/kernel/urKernelCreateWithNativeHandle.cpp +++ b/test/conformance/kernel/urKernelCreateWithNativeHandle.cpp @@ -54,13 +54,6 @@ TEST_P(urKernelCreateWithNativeHandleTest, InvalidNullHandleProgram) { &properties, &native_kernel)); } -TEST_P(urKernelCreateWithNativeHandleTest, InvalidNullHandleNativeKernel) { - ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, - urKernelCreateWithNativeHandle(nullptr, context, program, - &properties, - &native_kernel)); -} - TEST_P(urKernelCreateWithNativeHandleTest, InvalidNullPointerProperties) { ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, urKernelCreateWithNativeHandle(native_kernel_handle, diff --git a/test/conformance/kernel/urKernelGetNativeHandle.cpp b/test/conformance/kernel/urKernelGetNativeHandle.cpp index 8e83f7afb3..84249c40b0 100644 --- a/test/conformance/kernel/urKernelGetNativeHandle.cpp +++ b/test/conformance/kernel/urKernelGetNativeHandle.cpp @@ -11,24 +11,6 @@ UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urKernelGetNativeHandleTest); TEST_P(urKernelGetNativeHandleTest, Success) { ur_native_handle_t native_kernel_handle = nullptr; ASSERT_SUCCESS(urKernelGetNativeHandle(kernel, &native_kernel_handle)); - - ur_kernel_handle_t native_kernel = nullptr; - - ur_kernel_native_properties_t properties = { - UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES, /*sType*/ - nullptr, /*pNext*/ - true /*isNativeHandleOwned*/ - }; - ASSERT_SUCCESS(urKernelCreateWithNativeHandle( - native_kernel_handle, context, program, &properties, &native_kernel)); - - uint32_t ref_count = 0; - ASSERT_SUCCESS(urKernelGetInfo(native_kernel, - UR_KERNEL_INFO_REFERENCE_COUNT, - sizeof(ref_count), &ref_count, nullptr)); - ASSERT_NE(ref_count, 0); - - ASSERT_SUCCESS(urKernelRelease(native_kernel)); } TEST_P(urKernelGetNativeHandleTest, InvalidNullHandleKernel) { diff --git a/test/conformance/memory/urMemBufferCreateWithNativeHandle.cpp b/test/conformance/memory/urMemBufferCreateWithNativeHandle.cpp index b5c470df72..ddc4516f46 100644 --- a/test/conformance/memory/urMemBufferCreateWithNativeHandle.cpp +++ b/test/conformance/memory/urMemBufferCreateWithNativeHandle.cpp @@ -8,9 +8,27 @@ using urMemBufferCreateWithNativeHandleTest = uur::urMemBufferTest; UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urMemBufferCreateWithNativeHandleTest); -TEST_P(urMemBufferCreateWithNativeHandleTest, InvalidNullHandleNativeMem) { +TEST_P(urMemBufferCreateWithNativeHandleTest, Success) { + ur_native_handle_t hNativeMem = nullptr; + ASSERT_SUCCESS(urMemGetNativeHandle(buffer, &hNativeMem)); + + // We cannot assume anything about a native_handle, not even if it's + // `nullptr` since this could be a valid representation within a backend. + // We can however convert the native_handle back into a unified-runtime handle + // and perform some query on it to verify that it works. ur_mem_handle_t mem = nullptr; - ASSERT_EQ_RESULT( - UR_RESULT_ERROR_INVALID_NULL_HANDLE, - urMemBufferCreateWithNativeHandle(nullptr, context, nullptr, &mem)); + ur_mem_native_properties_t props = { + /*.stype =*/UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES, + /*.pNext =*/nullptr, + /*.isNativeHandleOwned =*/false, + }; + ASSERT_SUCCESS( + urMemBufferCreateWithNativeHandle(hNativeMem, context, &props, &mem)); + ASSERT_NE(mem, nullptr); + + size_t alloc_size = 0; + ASSERT_SUCCESS(urMemGetInfo(mem, UR_MEM_INFO_SIZE, sizeof(size_t), + &alloc_size, nullptr)); + + ASSERT_SUCCESS(urMemRelease(mem)); } diff --git a/test/conformance/memory/urMemGetNativeHandle.cpp b/test/conformance/memory/urMemGetNativeHandle.cpp index 325986a23a..f667a9f571 100644 --- a/test/conformance/memory/urMemGetNativeHandle.cpp +++ b/test/conformance/memory/urMemGetNativeHandle.cpp @@ -10,26 +10,6 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urMemGetNativeHandleTest); TEST_P(urMemGetNativeHandleTest, Success) { ur_native_handle_t hNativeMem = nullptr; ASSERT_SUCCESS(urMemGetNativeHandle(buffer, &hNativeMem)); - - // We cannot assume anything about a native_handle, not even if it's - // `nullptr` since this could be a valid representation within a backend. - // We can however convert the native_handle back into a unified-runtime handle - // and perform some query on it to verify that it works. - ur_mem_handle_t mem = nullptr; - ur_mem_native_properties_t props = { - /*.stype =*/UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES, - /*.pNext =*/nullptr, - /*.isNativeHandleOwned =*/false, - }; - ASSERT_SUCCESS( - urMemBufferCreateWithNativeHandle(hNativeMem, context, &props, &mem)); - ASSERT_NE(mem, nullptr); - - size_t alloc_size = 0; - ASSERT_SUCCESS(urMemGetInfo(mem, UR_MEM_INFO_SIZE, sizeof(size_t), - &alloc_size, nullptr)); - - ASSERT_SUCCESS(urMemRelease(mem)); } TEST_P(urMemGetNativeHandleTest, InvalidNullHandleMem) { diff --git a/test/conformance/memory/urMemImageCreateWithNativeHandle.cpp b/test/conformance/memory/urMemImageCreateWithNativeHandle.cpp index b5fa232a6f..59331305f1 100644 --- a/test/conformance/memory/urMemImageCreateWithNativeHandle.cpp +++ b/test/conformance/memory/urMemImageCreateWithNativeHandle.cpp @@ -5,30 +5,23 @@ #include -using urMemImageCreateWithNativeHandleTest = uur::urMemBufferTest; +using urMemImageCreateWithNativeHandleTest = uur::urMemImageTest; UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urMemImageCreateWithNativeHandleTest); -TEST_P(urMemImageCreateWithNativeHandleTest, InvalidNullHandleNativeMem) { +TEST_P(urMemImageCreateWithNativeHandleTest, Success) { + ur_native_handle_t native_handle = nullptr; + ASSERT_SUCCESS(urMemGetNativeHandle(image, &native_handle)); + ur_mem_handle_t mem = nullptr; - ur_image_format_t imageFormat = { - /*.channelOrder =*/UR_IMAGE_CHANNEL_ORDER_ARGB, - /*.channelType =*/UR_IMAGE_CHANNEL_TYPE_UNORM_INT8, - }; - ur_image_desc_t imageDesc = { - /*.stype =*/UR_STRUCTURE_TYPE_IMAGE_DESC, - /*.pNext =*/nullptr, - /*.type =*/UR_MEM_TYPE_IMAGE2D, - /*.width =*/16, - /*.height =*/16, - /*.depth =*/1, - /*.arraySize =*/1, - /*.rowPitch =*/16, - /*.slicePitch =*/16 * 16, - /*.numMipLevel =*/0, - /*.numSamples =*/0, - }; - ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, - urMemImageCreateWithNativeHandle(nullptr, context, - &imageFormat, &imageDesc, - nullptr, &mem)); + ASSERT_EQ_RESULT( + UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urMemImageCreateWithNativeHandle(native_handle, context, &image_format, + &image_desc, nullptr, &mem)); + ASSERT_NE(nullptr, mem); + + ur_context_handle_t mem_context = nullptr; + ASSERT_SUCCESS(urMemGetInfo(mem, UR_MEM_INFO_CONTEXT, + sizeof(ur_context_handle_t), &mem_context, + nullptr)); + ASSERT_EQ(context, mem_context); } diff --git a/test/conformance/platform/urPlatformCreateWithNativeHandle.cpp b/test/conformance/platform/urPlatformCreateWithNativeHandle.cpp index 00d8ce78ea..837f1b6c5f 100644 --- a/test/conformance/platform/urPlatformCreateWithNativeHandle.cpp +++ b/test/conformance/platform/urPlatformCreateWithNativeHandle.cpp @@ -7,10 +7,33 @@ using urPlatformCreateWithNativeHandleTest = uur::platform::urPlatformTest; +TEST_F(urPlatformCreateWithNativeHandleTest, Success) { + for (auto platform : platforms) { + ur_native_handle_t native_handle = nullptr; + ASSERT_SUCCESS(urPlatformGetNativeHandle(platform, &native_handle)); + + // We cannot assume anything about a native_handle, not even if it's + // `nullptr` since this could be a valid representation within a backend. + // We can however convert the native_handle back into a unified-runtime + // handle and perform some query on it to verify that it works. + ur_platform_handle_t plat = nullptr; + ASSERT_SUCCESS( + urPlatformCreateWithNativeHandle(native_handle, nullptr, &plat)); + ASSERT_NE(plat, nullptr); + + ur_platform_backend_t backend; + ASSERT_SUCCESS(urPlatformGetInfo(plat, UR_PLATFORM_INFO_BACKEND, + sizeof(ur_platform_backend_t), + &backend, nullptr)); + } +} + TEST_F(urPlatformCreateWithNativeHandleTest, InvalidNullPointerPlatform) { - ur_native_handle_t native_handle = nullptr; - ASSERT_SUCCESS(urPlatformGetNativeHandle(platform, &native_handle)); - ASSERT_EQ_RESULT( - UR_RESULT_ERROR_INVALID_NULL_POINTER, - urPlatformCreateWithNativeHandle(native_handle, nullptr, nullptr)); + for (auto platform : platforms) { + ur_native_handle_t native_handle = nullptr; + ASSERT_SUCCESS(urPlatformGetNativeHandle(platform, &native_handle)); + ASSERT_EQ_RESULT( + UR_RESULT_ERROR_INVALID_NULL_POINTER, + urPlatformCreateWithNativeHandle(native_handle, nullptr, nullptr)); + } } diff --git a/test/conformance/platform/urPlatformGetNativeHandle.cpp b/test/conformance/platform/urPlatformGetNativeHandle.cpp index 77ae08bc78..7bf4fb4c0b 100644 --- a/test/conformance/platform/urPlatformGetNativeHandle.cpp +++ b/test/conformance/platform/urPlatformGetNativeHandle.cpp @@ -11,20 +11,6 @@ TEST_F(urPlatformGetNativeHandleTest, Success) { for (auto platform : platforms) { ur_native_handle_t native_handle = nullptr; ASSERT_SUCCESS(urPlatformGetNativeHandle(platform, &native_handle)); - - // We cannot assume anything about a native_handle, not even if it's - // `nullptr` since this could be a valid representation within a backend. - // We can however convert the native_handle back into a unified-runtime - // handle and perform some query on it to verify that it works. - ur_platform_handle_t plat = nullptr; - ASSERT_SUCCESS( - urPlatformCreateWithNativeHandle(native_handle, nullptr, &plat)); - ASSERT_NE(plat, nullptr); - - ur_platform_backend_t backend; - ASSERT_SUCCESS(urPlatformGetInfo(plat, UR_PLATFORM_INFO_BACKEND, - sizeof(ur_platform_backend_t), - &backend, nullptr)); } } diff --git a/test/conformance/program/urProgramCreateWithNativeHandle.cpp b/test/conformance/program/urProgramCreateWithNativeHandle.cpp index 7a833c77e9..7970630746 100644 --- a/test/conformance/program/urProgramCreateWithNativeHandle.cpp +++ b/test/conformance/program/urProgramCreateWithNativeHandle.cpp @@ -43,12 +43,6 @@ TEST_P(urProgramCreateWithNativeHandleTest, InvalidNullHandleContext) { &native_program)); } -TEST_P(urProgramCreateWithNativeHandleTest, InvalidNullHandleNativeProgram) { - ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, - urProgramCreateWithNativeHandle(nullptr, context, nullptr, - &native_program)); -} - TEST_P(urProgramCreateWithNativeHandleTest, InvalidNullPointerProgram) { ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, urProgramCreateWithNativeHandle( diff --git a/test/conformance/program/urProgramGetNativeHandle.cpp b/test/conformance/program/urProgramGetNativeHandle.cpp index 9984fb7768..193fd2d669 100644 --- a/test/conformance/program/urProgramGetNativeHandle.cpp +++ b/test/conformance/program/urProgramGetNativeHandle.cpp @@ -11,18 +11,6 @@ UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urProgramGetNativeHandleTest); TEST_P(urProgramGetNativeHandleTest, Success) { ur_native_handle_t native_program_handle = nullptr; ASSERT_SUCCESS(urProgramGetNativeHandle(program, &native_program_handle)); - - ur_program_handle_t native_program = nullptr; - ASSERT_SUCCESS(urProgramCreateWithNativeHandle( - native_program_handle, context, nullptr, &native_program)); - - uint32_t ref_count = 0; - ASSERT_SUCCESS(urProgramGetInfo(native_program, - UR_PROGRAM_INFO_REFERENCE_COUNT, - sizeof(ref_count), &ref_count, nullptr)); - ASSERT_NE(ref_count, 0); - - ASSERT_SUCCESS(urProgramRelease(native_program)); } TEST_P(urProgramGetNativeHandleTest, InvalidNullHandleProgram) { diff --git a/test/conformance/queue/urQueueCreateWithNativeHandle.cpp b/test/conformance/queue/urQueueCreateWithNativeHandle.cpp index cf326bc46e..fd12cdaed5 100644 --- a/test/conformance/queue/urQueueCreateWithNativeHandle.cpp +++ b/test/conformance/queue/urQueueCreateWithNativeHandle.cpp @@ -4,13 +4,26 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include -using urQueueCreateWithNativeHandleTest = uur::urContextTest; +using urQueueCreateWithNativeHandleTest = uur::urQueueTest; UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urQueueCreateWithNativeHandleTest); -TEST_P(urQueueCreateWithNativeHandleTest, InvalidNullHandleNativeQueue) { - ur_queue_handle_t queue = nullptr; +TEST_P(urQueueCreateWithNativeHandleTest, Success) { + ur_native_handle_t native_handle = nullptr; + ASSERT_SUCCESS(urQueueGetNativeHandle(queue, nullptr, &native_handle)); + + // We cannot assume anything about a native_handle, not even if it's + // `nullptr` since this could be a valid representation within a backend. + // We can however convert the native_handle back into a unified-runtime handle + // and perform some query on it to verify that it works. + ur_queue_handle_t q = nullptr; ur_queue_native_properties_t properties{}; - ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, - urQueueCreateWithNativeHandle(nullptr, context, device, - &properties, &queue)); + ASSERT_SUCCESS(urQueueCreateWithNativeHandle(native_handle, context, device, + &properties, &q)); + ASSERT_NE(q, nullptr); + + uint32_t q_size = 0; + ASSERT_SUCCESS(urQueueGetInfo(q, UR_QUEUE_INFO_SIZE, sizeof(uint32_t), + &q_size, nullptr)); + + ASSERT_SUCCESS(urQueueRelease(q)); } diff --git a/test/conformance/queue/urQueueGetNativeHandle.cpp b/test/conformance/queue/urQueueGetNativeHandle.cpp index 5702359b08..6d35895fea 100644 --- a/test/conformance/queue/urQueueGetNativeHandle.cpp +++ b/test/conformance/queue/urQueueGetNativeHandle.cpp @@ -10,22 +10,6 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urQueueGetNativeHandleTest); TEST_P(urQueueGetNativeHandleTest, Success) { ur_native_handle_t native_handle = nullptr; ASSERT_SUCCESS(urQueueGetNativeHandle(queue, nullptr, &native_handle)); - - // We cannot assume anything about a native_handle, not even if it's - // `nullptr` since this could be a valid representation within a backend. - // We can however convert the native_handle back into a unified-runtime handle - // and perform some query on it to verify that it works. - ur_queue_handle_t q = nullptr; - ur_queue_native_properties_t properties{}; - ASSERT_SUCCESS(urQueueCreateWithNativeHandle(native_handle, context, device, - &properties, &q)); - ASSERT_NE(q, nullptr); - - uint32_t q_size = 0; - ASSERT_SUCCESS(urQueueGetInfo(q, UR_QUEUE_INFO_SIZE, sizeof(uint32_t), - &q_size, nullptr)); - - ASSERT_SUCCESS(urQueueRelease(q)); } TEST_P(urQueueGetNativeHandleTest, InvalidNullHandleQueue) { diff --git a/test/conformance/sampler/urSamplerCreateWithNativeHandle.cpp b/test/conformance/sampler/urSamplerCreateWithNativeHandle.cpp index f9f114ffe0..0ea5e3685f 100644 --- a/test/conformance/sampler/urSamplerCreateWithNativeHandle.cpp +++ b/test/conformance/sampler/urSamplerCreateWithNativeHandle.cpp @@ -5,14 +5,26 @@ #include -using urSamplerCreateWithNativeHandleTest = uur::urContextTest; +using urSamplerCreateWithNativeHandleTest = uur::urSamplerTest; UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urSamplerCreateWithNativeHandleTest); -TEST_P(urSamplerCreateWithNativeHandleTest, InvalidNullHandleNativeHandle) { - ur_sampler_handle_t sampler = nullptr; +TEST_P(urSamplerCreateWithNativeHandleTest, Success) { + ur_native_handle_t native_sampler = nullptr; + ASSERT_SUCCESS(urSamplerGetNativeHandle(sampler, &native_sampler)); + + // We cannot assume anything about a native_handle, not even if it's + // `nullptr` since this could be a valid representation within a backend. + // We can however convert the native_handle back into a unified-runtime handle + // and perform some query on it to verify that it works. + ur_sampler_handle_t hSampler = nullptr; ur_sampler_native_properties_t props{}; - ASSERT_EQ_RESULT( - UR_RESULT_ERROR_INVALID_NULL_HANDLE, - urSamplerCreateWithNativeHandle(nullptr, context, &props, &sampler)); + ASSERT_SUCCESS(urSamplerCreateWithNativeHandle(native_sampler, context, + &props, &hSampler)); + ASSERT_NE(hSampler, nullptr); + + ur_sampler_addressing_mode_t addr_mode; + ASSERT_SUCCESS(urSamplerGetInfo(hSampler, UR_SAMPLER_INFO_ADDRESSING_MODE, + sizeof(addr_mode), &addr_mode, nullptr)); + ASSERT_EQ(addr_mode, sampler_desc.addressingMode); } diff --git a/test/conformance/sampler/urSamplerGetNativeHandle.cpp b/test/conformance/sampler/urSamplerGetNativeHandle.cpp index 5f7ed7508a..24bac6286e 100644 --- a/test/conformance/sampler/urSamplerGetNativeHandle.cpp +++ b/test/conformance/sampler/urSamplerGetNativeHandle.cpp @@ -12,21 +12,6 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urSamplerGetNativeHandleTest); TEST_P(urSamplerGetNativeHandleTest, Success) { ur_native_handle_t native_sampler = nullptr; ASSERT_SUCCESS(urSamplerGetNativeHandle(sampler, &native_sampler)); - - // We cannot assume anything about a native_handle, not even if it's - // `nullptr` since this could be a valid representation within a backend. - // We can however convert the native_handle back into a unified-runtime handle - // and perform some query on it to verify that it works. - ur_sampler_handle_t hSampler = nullptr; - ur_sampler_native_properties_t props{}; - ASSERT_SUCCESS(urSamplerCreateWithNativeHandle(native_sampler, context, - &props, &hSampler)); - ASSERT_NE(hSampler, nullptr); - - ur_sampler_addressing_mode_t addr_mode; - ASSERT_SUCCESS(urSamplerGetInfo(hSampler, UR_SAMPLER_INFO_ADDRESSING_MODE, - sizeof(addr_mode), &addr_mode, nullptr)); - ASSERT_EQ(addr_mode, sampler_desc.addressingMode); } TEST_P(urSamplerGetNativeHandleTest, InvalidNullHandleSampler) { diff --git a/test/conformance/testing/include/uur/fixtures.h b/test/conformance/testing/include/uur/fixtures.h index 4112cd9174..4c50c3c927 100644 --- a/test/conformance/testing/include/uur/fixtures.h +++ b/test/conformance/testing/include/uur/fixtures.h @@ -175,6 +175,38 @@ struct urMemBufferTest : urContextTest { ur_mem_handle_t buffer = nullptr; }; +struct urMemImageTest : urContextTest { + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE(urContextTest::SetUp()); + } + + void TearDown() override { + if (image) { + EXPECT_SUCCESS(urMemRelease(image)); + } + UUR_RETURN_ON_FATAL_FAILURE(urContextTest::TearDown()); + } + + ur_image_format_t image_format = { + /*.channelOrder =*/UR_IMAGE_CHANNEL_ORDER_ARGB, + /*.channelType =*/UR_IMAGE_CHANNEL_TYPE_UNORM_INT8, + }; + ur_image_desc_t image_desc = { + /*.stype =*/UR_STRUCTURE_TYPE_IMAGE_DESC, + /*.pNext =*/nullptr, + /*.type =*/UR_MEM_TYPE_IMAGE2D, + /*.width =*/16, + /*.height =*/16, + /*.depth =*/1, + /*.arraySize =*/1, + /*.rowPitch =*/16 * sizeof(char[4]), + /*.slicePitch =*/16 * 16 * sizeof(char[4]), + /*.numMipLevel =*/0, + /*.numSamples =*/0, + }; + ur_mem_handle_t image = nullptr; +}; + } // namespace uur #define UUR_TEST_SUITE_P(FIXTURE, VALUES, PRINTER) \ From 7162e22fabb0c3b4f298dea70d4d283a49aaa218 Mon Sep 17 00:00:00 2001 From: Aaron Greig Date: Mon, 17 Jul 2023 17:14:47 +0100 Subject: [PATCH 075/104] Address feedback: comment, atomic ref count, better env helper --- source/loader/ur_lib.cpp | 22 +++++++++------------- source/loader/ur_lib.hpp | 14 +++++++++++--- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/source/loader/ur_lib.cpp b/source/loader/ur_lib.cpp index afd558f7c5..062a2f40eb 100644 --- a/source/loader/ur_lib.cpp +++ b/source/loader/ur_lib.cpp @@ -28,6 +28,7 @@ context_t::context_t() { } } } + // Remove the trailing ";" availableLayers.pop_back(); parseEnvEnabledLayers(); } @@ -40,20 +41,14 @@ bool context_t::layerExists(const std::string &layerName) const { } void context_t::parseEnvEnabledLayers() { - auto maybeEnableEnvVar = ur_getenv("UR_ENABLE_LAYERS"); - if (!maybeEnableEnvVar.has_value()) { + auto maybeEnableEnvVarMap = getenv_to_map("UR_ENABLE_LAYERS", false); + if (!maybeEnableEnvVarMap.has_value()) { return; } - auto enableEnvVar = maybeEnableEnvVar.value(); + auto enableEnvVarMap = maybeEnableEnvVarMap.value(); - size_t pos = 0; - while ((pos = enableEnvVar.find(",")) != std::string::npos) { - enabledLayerNames.insert(enableEnvVar.substr(0, pos)); - enableEnvVar.erase(0, enableEnvVar.find(";") + 1); - } - - if (!enableEnvVar.empty()) { - enabledLayerNames.insert(enableEnvVar); + for (auto &key : enableEnvVarMap) { + enabledLayerNames.insert(key.first); } } @@ -146,7 +141,8 @@ ur_result_t urLoaderConfigGetInfo(ur_loader_config_handle_t hLoaderConfig, break; } case UR_LOADER_CONFIG_INFO_REFERENCE_COUNT: { - auto truePropSize = sizeof(hLoaderConfig->refCount); + auto refCount = hLoaderConfig->getReferenceCount(); + auto truePropSize = sizeof(refCount); if (pPropSizeRet) { *pPropSizeRet = truePropSize; } @@ -154,7 +150,7 @@ ur_result_t urLoaderConfigGetInfo(ur_loader_config_handle_t hLoaderConfig, if (propSize != truePropSize) { return UR_RESULT_ERROR_INVALID_SIZE; } - std::memcpy(pPropValue, &hLoaderConfig->refCount, truePropSize); + std::memcpy(pPropValue, &refCount, truePropSize); } break; } diff --git a/source/loader/ur_lib.hpp b/source/loader/ur_lib.hpp index ae48f537fc..1f0f23658b 100644 --- a/source/loader/ur_lib.hpp +++ b/source/loader/ur_lib.hpp @@ -23,16 +23,24 @@ #include "tracing/ur_tracing_layer.hpp" #endif +#include #include #include #include struct ur_loader_config_handle_t_ { std::set enabledLayers; - uint32_t refCount = 1; + std::atomic_uint32_t refCount = 1; - size_t incrementReferenceCount() { return ++refCount; } - size_t decrementReferenceCount() { return --refCount; } + uint32_t incrementReferenceCount() { + return refCount.fetch_add(1, std::memory_order_acq_rel) + 1; + } + uint32_t decrementReferenceCount() { + return refCount.fetch_sub(1, std::memory_order_acq_rel) - 1; + } + uint32_t getReferenceCount() { + return refCount.load(std::memory_order_acquire); + } std::set &getEnabledLayerNames() { return enabledLayers; } }; From f8d618236ff939e137c48507966e21e736c98beb Mon Sep 17 00:00:00 2001 From: Aaron Greig Date: Mon, 17 Jul 2023 17:41:33 +0100 Subject: [PATCH 076/104] Address feedback: rethink layer::isEnabled --- scripts/templates/trcddi.cpp.mako | 8 +++++++- scripts/templates/valddi.cpp.mako | 16 +++++++++++++++- .../loader/layers/tracing/ur_tracing_layer.hpp | 7 ++----- source/loader/layers/tracing/ur_trcddi.cpp | 7 ++++++- source/loader/layers/ur_proxy_layer.hpp | 5 +++-- source/loader/layers/validation/ur_valddi.cpp | 15 ++++++++++++++- .../layers/validation/ur_validation_layer.cpp | 17 ----------------- .../layers/validation/ur_validation_layer.hpp | 4 ++-- source/loader/ur_lib.cpp | 4 ++-- 9 files changed, 51 insertions(+), 32 deletions(-) diff --git a/scripts/templates/trcddi.cpp.mako b/scripts/templates/trcddi.cpp.mako index 7487aed5bc..6160b0072e 100644 --- a/scripts/templates/trcddi.cpp.mako +++ b/scripts/templates/trcddi.cpp.mako @@ -102,9 +102,15 @@ namespace ur_tracing_layer } %endfor - ${x}_result_t context_t::init(ur_dditable_t *dditable) { + ${x}_result_t + context_t::init(ur_dditable_t *dditable, + const std::set &enabledLayerNames) { ${x}_result_t result = ${X}_RESULT_SUCCESS; + if(!enabledLayerNames.count(name)) { + return result; + } + %for tbl in th.get_pfntables(specs, meta, n, tags): if( ${X}_RESULT_SUCCESS == result ) { diff --git a/scripts/templates/valddi.cpp.mako b/scripts/templates/valddi.cpp.mako index 1b806f4ab9..7a6aedaf54 100644 --- a/scripts/templates/valddi.cpp.mako +++ b/scripts/templates/valddi.cpp.mako @@ -138,9 +138,23 @@ namespace ur_validation_layer } %endfor - ${x}_result_t context_t::init(${x}_dditable_t *dditable) { + ${x}_result_t + context_t::init(ur_dditable_t *dditable, + const std::set &enabledLayerNames) { ${x}_result_t result = ${X}_RESULT_SUCCESS; + if (enabledLayerNames.count(nameFullValidation)) { + enableParameterValidation = true; + enableLeakChecking = true; + } else { + if (enabledLayerNames.count(nameParameterValidation)) { + enableParameterValidation = true; + } + if (enabledLayerNames.count(nameLeakChecking)) { + enableLeakChecking = true; + } + } + if(!enableParameterValidation && !enableLeakChecking) { return result; } diff --git a/source/loader/layers/tracing/ur_tracing_layer.hpp b/source/loader/layers/tracing/ur_tracing_layer.hpp index 7bcc6d272b..b00d12d301 100644 --- a/source/loader/layers/tracing/ur_tracing_layer.hpp +++ b/source/loader/layers/tracing/ur_tracing_layer.hpp @@ -30,12 +30,9 @@ class __urdlllocal context_t : public proxy_layer_context_t { bool isAvailable() const override; - bool isEnabled(const std::set &enabledLayerNames) override { - return enabledLayerNames.find(name) != enabledLayerNames.end(); - } - std::vector getNames() const override { return {name}; } - ur_result_t init(ur_dditable_t *dditable) override; + ur_result_t init(ur_dditable_t *dditable, + const std::set &enabledLayerNames) override; uint64_t notify_begin(uint32_t id, const char *name, void *args); void notify_end(uint32_t id, const char *name, void *args, ur_result_t *resultp, uint64_t instance); diff --git a/source/loader/layers/tracing/ur_trcddi.cpp b/source/loader/layers/tracing/ur_trcddi.cpp index f49622e8cf..bc0c0e8ea0 100644 --- a/source/loader/layers/tracing/ur_trcddi.cpp +++ b/source/loader/layers/tracing/ur_trcddi.cpp @@ -6782,9 +6782,14 @@ __urdlllocal ur_result_t UR_APICALL urGetDeviceProcAddrTable( return result; } -ur_result_t context_t::init(ur_dditable_t *dditable) { +ur_result_t context_t::init(ur_dditable_t *dditable, + const std::set &enabledLayerNames) { ur_result_t result = UR_RESULT_SUCCESS; + if (!enabledLayerNames.count(name)) { + return result; + } + if (UR_RESULT_SUCCESS == result) { result = ur_tracing_layer::urGetGlobalProcAddrTable( UR_API_VERSION_CURRENT, &dditable->Global); diff --git a/source/loader/layers/ur_proxy_layer.hpp b/source/loader/layers/ur_proxy_layer.hpp index 303df2b9bd..da45017a5f 100644 --- a/source/loader/layers/ur_proxy_layer.hpp +++ b/source/loader/layers/ur_proxy_layer.hpp @@ -24,8 +24,9 @@ class __urdlllocal proxy_layer_context_t { virtual std::vector getNames() const = 0; virtual bool isAvailable() const = 0; - virtual bool isEnabled(const std::set &enabledLayerNames) = 0; - virtual ur_result_t init(ur_dditable_t *dditable) = 0; + virtual ur_result_t + init(ur_dditable_t *dditable, + const std::set &enabledLayerNames) = 0; }; #endif /* UR_PROXY_LAYER_H */ diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index 2929bd3489..34440491f1 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -8145,9 +8145,22 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetDeviceProcAddrTable( return result; } -ur_result_t context_t::init(ur_dditable_t *dditable) { +ur_result_t context_t::init(ur_dditable_t *dditable, + const std::set &enabledLayerNames) { ur_result_t result = UR_RESULT_SUCCESS; + if (enabledLayerNames.count(nameFullValidation)) { + enableParameterValidation = true; + enableLeakChecking = true; + } else { + if (enabledLayerNames.count(nameParameterValidation)) { + enableParameterValidation = true; + } + if (enabledLayerNames.count(nameLeakChecking)) { + enableLeakChecking = true; + } + } + if (!enableParameterValidation && !enableLeakChecking) { return result; } diff --git a/source/loader/layers/validation/ur_validation_layer.cpp b/source/loader/layers/validation/ur_validation_layer.cpp index 1a78c0ed79..5cd3f8c13a 100644 --- a/source/loader/layers/validation/ur_validation_layer.cpp +++ b/source/loader/layers/validation/ur_validation_layer.cpp @@ -20,21 +20,4 @@ context_t::context_t() : logger(logger::create_logger("validation")) {} /////////////////////////////////////////////////////////////////////////////// context_t::~context_t() {} -bool context_t::isEnabled(const std::set &enabledLayerNames) { - if (enabledLayerNames.find(nameFullValidation) != enabledLayerNames.end()) { - enableParameterValidation = true; - enableLeakChecking = true; - } else { - if (enabledLayerNames.find(nameParameterValidation) != - enabledLayerNames.end()) { - enableParameterValidation = true; - } - if (enabledLayerNames.find(nameLeakChecking) != - enabledLayerNames.end()) { - enableLeakChecking = true; - } - } - return enableParameterValidation || enableLeakChecking; -} - } // namespace ur_validation_layer diff --git a/source/loader/layers/validation/ur_validation_layer.hpp b/source/loader/layers/validation/ur_validation_layer.hpp index 755e72504c..7a103568ca 100644 --- a/source/loader/layers/validation/ur_validation_layer.hpp +++ b/source/loader/layers/validation/ur_validation_layer.hpp @@ -30,11 +30,11 @@ class __urdlllocal context_t : public proxy_layer_context_t { ~context_t(); bool isAvailable() const override { return true; } - bool isEnabled(const std::set &enabledLayerNames) override; std::vector getNames() const override { return {nameFullValidation, nameParameterValidation, nameLeakChecking}; } - ur_result_t init(ur_dditable_t *dditable) override; + ur_result_t init(ur_dditable_t *dditable, + const std::set &enabledLayerNames) override; private: const std::string nameFullValidation = "UR_LAYER_FULL_VALIDATION"; diff --git a/source/loader/ur_lib.cpp b/source/loader/ur_lib.cpp index 062a2f40eb..964da234f1 100644 --- a/source/loader/ur_lib.cpp +++ b/source/loader/ur_lib.cpp @@ -54,8 +54,8 @@ void context_t::parseEnvEnabledLayers() { void context_t::initLayers() const { for (auto &l : layers) { - if (l->isAvailable() && l->isEnabled(enabledLayerNames)) { - l->init(&context->urDdiTable); + if (l->isAvailable()) { + l->init(&context->urDdiTable, enabledLayerNames); } } } From 13805ccfdc833efd03bd0b2d025687e1bc7d433b Mon Sep 17 00:00:00 2001 From: Krzysztof Swiecicki Date: Tue, 18 Jul 2023 12:45:28 +0200 Subject: [PATCH 077/104] Fix GetEnvironmentVariable encoding --- source/common/ur_util.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/common/ur_util.hpp b/source/common/ur_util.hpp index e77d439275..54617d7c87 100644 --- a/source/common/ur_util.hpp +++ b/source/common/ur_util.hpp @@ -92,7 +92,7 @@ inline std::optional ur_getenv(const char *name) { #if defined(_WIN32) constexpr int buffer_size = 1024; char buffer[buffer_size]; - auto rc = GetEnvironmentVariable(name, buffer, buffer_size); + auto rc = GetEnvironmentVariableA(name, buffer, buffer_size); if (0 != rc && rc < buffer_size) { return std::string(buffer); } else if (rc >= buffer_size) { From 7e1c90b6ce8bcdeaad8a61ce0c944632bbe1afc6 Mon Sep 17 00:00:00 2001 From: Aaron Greig Date: Tue, 18 Jul 2023 15:15:12 +0100 Subject: [PATCH 078/104] Address feedback: CTS environment error handling. --- test/conformance/source/environment.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/test/conformance/source/environment.cpp b/test/conformance/source/environment.cpp index af545f4c11..43862b0451 100644 --- a/test/conformance/source/environment.cpp +++ b/test/conformance/source/environment.cpp @@ -45,11 +45,21 @@ uur::PlatformEnvironment::PlatformEnvironment(int argc, char **argv) instance = this; ur_loader_config_handle_t config; - urLoaderConfigCreate(&config); - urLoaderConfigEnableLayer(config, "UR_LAYER_FULL_VALIDATION"); + if (urLoaderConfigCreate(&config) == UR_RESULT_SUCCESS) { + if (urLoaderConfigEnableLayer(config, "UR_LAYER_FULL_VALIDATION")) { + urLoaderConfigRelease(config); + error = "Failed to enable validation layer"; + return; + } + } else { + error = "Failed to create loader config handle"; + return; + } ur_device_init_flags_t device_flags = 0; - switch (urInit(device_flags, config)) { + auto initResult = urInit(device_flags, config); + auto configReleaseResult = urLoaderConfigRelease(config); + switch (initResult) { case UR_RESULT_SUCCESS: break; case UR_RESULT_ERROR_UNINITIALIZED: @@ -59,7 +69,11 @@ uur::PlatformEnvironment::PlatformEnvironment(int argc, char **argv) error = "urInit() failed"; return; } - urLoaderConfigRelease(config); + + if (configReleaseResult) { + error = "Failed to destroy loader config handle"; + return; + } uint32_t count = 0; if (urPlatformGet(0, nullptr, &count)) { From 5ec5bd4c7c7baa02a8efe03d6ec55b7a7e31f631 Mon Sep 17 00:00:00 2001 From: Aaron Greig Date: Tue, 18 Jul 2023 17:30:54 +0100 Subject: [PATCH 079/104] Enable validation on conformance tests for platform. Also necessitates splitting urInit/urTearDown into their own suite due to how they currently work WRT global state. --- test/conformance/CMakeLists.txt | 1 + test/conformance/platform/CMakeLists.txt | 4 +--- test/conformance/platform/fixtures.h | 7 ++++++- test/conformance/runtime/CMakeLists.txt | 8 ++++++++ test/conformance/{platform => runtime}/urInit.cpp | 0 test/conformance/{platform => runtime}/urTearDown.cpp | 0 6 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 test/conformance/runtime/CMakeLists.txt rename test/conformance/{platform => runtime}/urInit.cpp (100%) rename test/conformance/{platform => runtime}/urTearDown.cpp (100%) diff --git a/test/conformance/CMakeLists.txt b/test/conformance/CMakeLists.txt index 2b2c5238c6..8506afaa16 100644 --- a/test/conformance/CMakeLists.txt +++ b/test/conformance/CMakeLists.txt @@ -46,6 +46,7 @@ endfunction() add_subdirectory(testing) +add_subdirectory(runtime) add_subdirectory(platform) add_subdirectory(device) add_subdirectory(context) diff --git a/test/conformance/platform/CMakeLists.txt b/test/conformance/platform/CMakeLists.txt index 92e95018e4..3a9483e2a8 100644 --- a/test/conformance/platform/CMakeLists.txt +++ b/test/conformance/platform/CMakeLists.txt @@ -4,12 +4,10 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception add_conformance_test(platform - urInit.cpp urPlatformCreateWithNativeHandle.cpp urPlatformGet.cpp urPlatformGetApiVersion.cpp urPlatformGetBackendOption.cpp urPlatformGetInfo.cpp urPlatformGetLastError.cpp - urPlatformGetNativeHandle.cpp - urTearDown.cpp) + urPlatformGetNativeHandle.cpp) diff --git a/test/conformance/platform/fixtures.h b/test/conformance/platform/fixtures.h index 038d8f9ff4..1558d8d1b3 100644 --- a/test/conformance/platform/fixtures.h +++ b/test/conformance/platform/fixtures.h @@ -14,7 +14,12 @@ struct urTest : ::testing::Test { void SetUp() override { ur_device_init_flags_t device_flags = 0; - ASSERT_SUCCESS(urInit(device_flags, nullptr)); + ur_loader_config_handle_t config; + ASSERT_SUCCESS(urLoaderConfigCreate(&config)); + ASSERT_SUCCESS( + urLoaderConfigEnableLayer(config, "UR_LAYER_FULL_VALIDATION")); + ASSERT_SUCCESS(urInit(device_flags, config)); + ASSERT_SUCCESS(urLoaderConfigRelease(config)); } void TearDown() override { diff --git a/test/conformance/runtime/CMakeLists.txt b/test/conformance/runtime/CMakeLists.txt new file mode 100644 index 0000000000..1eff8db3b7 --- /dev/null +++ b/test/conformance/runtime/CMakeLists.txt @@ -0,0 +1,8 @@ +# Copyright (C) 2023 Intel Corporation +# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +# See LICENSE.TXT +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +add_conformance_test(runtime + urInit.cpp + urTearDown.cpp) diff --git a/test/conformance/platform/urInit.cpp b/test/conformance/runtime/urInit.cpp similarity index 100% rename from test/conformance/platform/urInit.cpp rename to test/conformance/runtime/urInit.cpp diff --git a/test/conformance/platform/urTearDown.cpp b/test/conformance/runtime/urTearDown.cpp similarity index 100% rename from test/conformance/platform/urTearDown.cpp rename to test/conformance/runtime/urTearDown.cpp From b3ea52c113992dc6dfbee3c73236837b0fe8614a Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Tue, 18 Jul 2023 17:49:57 +0100 Subject: [PATCH 080/104] [coverity] Fix 1566349 Resource leak Ensure that the `ur_loader_config_handle_t` is always cleaned up even in the event of assert failures in `SetUp()` by releasing it in `TearDown()`. --- test/layers/validation/fixtures.hpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/test/layers/validation/fixtures.hpp b/test/layers/validation/fixtures.hpp index 11e2a33f24..6af67c6f00 100644 --- a/test/layers/validation/fixtures.hpp +++ b/test/layers/validation/fixtures.hpp @@ -12,20 +12,24 @@ struct urTest : ::testing::Test { void SetUp() override { - ur_loader_config_handle_t config; - ASSERT_EQ(urLoaderConfigCreate(&config), UR_RESULT_SUCCESS); - ASSERT_EQ(urLoaderConfigEnableLayer(config, "UR_LAYER_FULL_VALIDATION"), + ASSERT_EQ(urLoaderConfigCreate(&loader_config), UR_RESULT_SUCCESS); + ASSERT_EQ(urLoaderConfigEnableLayer(loader_config, + "UR_LAYER_FULL_VALIDATION"), UR_RESULT_SUCCESS); - ur_device_init_flags_t device_flags = 0; - ASSERT_EQ(urInit(device_flags, config), UR_RESULT_SUCCESS); - ASSERT_EQ(urLoaderConfigRelease(config), UR_RESULT_SUCCESS); + ASSERT_EQ(urInit(device_flags, loader_config), UR_RESULT_SUCCESS); + ASSERT_EQ(urLoaderConfigRelease(loader_config), UR_RESULT_SUCCESS); } void TearDown() override { + if (loader_config) { + ASSERT_EQ(urLoaderConfigRelease(loader_config), UR_RESULT_SUCCESS); + } ur_tear_down_params_t tear_down_params{}; ASSERT_EQ(urTearDown(&tear_down_params), UR_RESULT_SUCCESS); } + + ur_loader_config_handle_t loader_config = nullptr; }; struct valPlatformsTest : urTest { From 19fdd60cfc274dae7f2a63d3b837ff9a5cf6e642 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Tue, 18 Jul 2023 17:55:31 +0100 Subject: [PATCH 081/104] [coverity] Fix 1566348 Uninitialized scalar field Default initialize the `enableParameterValidation` and `enableLeakChecking` data members of the `ur_validation_layer::context_t` object. --- source/loader/layers/validation/ur_validation_layer.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/loader/layers/validation/ur_validation_layer.hpp b/source/loader/layers/validation/ur_validation_layer.hpp index 7a103568ca..3201a5345e 100644 --- a/source/loader/layers/validation/ur_validation_layer.hpp +++ b/source/loader/layers/validation/ur_validation_layer.hpp @@ -20,8 +20,8 @@ namespace ur_validation_layer { /////////////////////////////////////////////////////////////////////////////// class __urdlllocal context_t : public proxy_layer_context_t { public: - bool enableParameterValidation; - bool enableLeakChecking; + bool enableParameterValidation = false; + bool enableLeakChecking = false; logger::Logger logger; ur_dditable_t urDdiTable = {}; From 38141b3e59634c3abb06ebdd8b3ba1be2c9793fc Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Tue, 18 Jul 2023 18:00:10 +0100 Subject: [PATCH 082/104] [coverity] Fix 1566349 Resource leak Move `ur_loader_config_handle_t` cleanup to the text fixture's `TearDown()`. --- test/loader/loader_config/urLoaderConfigCreate.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/loader/loader_config/urLoaderConfigCreate.cpp b/test/loader/loader_config/urLoaderConfigCreate.cpp index 442f6e41dc..df1293661b 100644 --- a/test/loader/loader_config/urLoaderConfigCreate.cpp +++ b/test/loader/loader_config/urLoaderConfigCreate.cpp @@ -5,12 +5,18 @@ #include "fixtures.hpp" -struct LoaderConfigCreateTest : ::testing::Test {}; +struct LoaderConfigCreateTest : ::testing::Test { + void TearDown() override { + if (loaderConfig) { + ASSERT_SUCCESS(urLoaderConfigRelease(loaderConfig)); + } + } -TEST_F(LoaderConfigCreateTest, Success) { ur_loader_config_handle_t loaderConfig = nullptr; +}; + +TEST_F(LoaderConfigCreateTest, Success) { ASSERT_SUCCESS(urLoaderConfigCreate(&loaderConfig)); - ASSERT_SUCCESS(urLoaderConfigRelease(loaderConfig)); } TEST_F(LoaderConfigCreateTest, InvalidNullPointerLoaderConfig) { From b2799850197b0586301b1047b8609bbdcd2c8931 Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Tue, 11 Jul 2023 12:10:30 +0100 Subject: [PATCH 083/104] Implement adapter instance handles --- examples/hello_world/hello_world.cpp | 25 +- include/ur.py | 101 +++++- include/ur_api.h | 319 ++++++++++++++---- include/ur_ddi.h | 48 ++- scripts/core/PROG.rst | 10 +- scripts/core/common.yml | 5 + scripts/core/platform.yml | 58 +--- scripts/core/registry.yml | 18 +- scripts/core/runtime.yml | 188 +++++++++++ scripts/templates/ldrddi.cpp.mako | 55 ++- source/adapters/null/ur_null.cpp | 23 +- source/adapters/null/ur_nullddi.cpp | 176 ++++++++-- source/common/ur_params.hpp | 280 +++++++++++++-- source/loader/layers/tracing/ur_trcddi.cpp | 203 +++++++++-- source/loader/layers/validation/ur_valddi.cpp | 231 ++++++++++--- source/loader/ur_ldrddi.cpp | 214 +++++++++--- source/loader/ur_ldrddi.hpp | 4 + source/loader/ur_libapi.cpp | 284 ++++++++++++---- source/ur_api.cpp | 241 +++++++++---- test/conformance/platform/CMakeLists.txt | 1 - test/conformance/platform/fixtures.h | 18 +- test/conformance/platform/urPlatformGet.cpp | 16 +- test/conformance/runtime/CMakeLists.txt | 5 + test/conformance/runtime/fixtures.h | 50 +++ test/conformance/runtime/urAdapterGet.cpp | 22 ++ test/conformance/runtime/urAdapterGetInfo.cpp | 89 +++++ .../urAdapterGetLastError.cpp} | 18 +- test/conformance/runtime/urAdapterRelease.cpp | 25 ++ test/conformance/runtime/urAdapterRetain.cpp | 25 ++ test/conformance/source/environment.cpp | 13 +- .../testing/include/uur/environment.h | 1 + test/layers/tracing/hello_world.out.match | 38 ++- test/layers/validation/fixtures.hpp | 17 +- test/loader/platforms/platforms.cpp | 21 +- test/tools/urtrace/null_hello.match | 7 +- test/tools/urtrace/null_hello_begin.match | 38 ++- test/tools/urtrace/null_hello_json.match | 7 +- test/tools/urtrace/null_hello_no_args.match | 3 + test/tools/urtrace/null_hello_profiling.match | 7 +- test/unit/utils/params.cpp | 12 +- 40 files changed, 2402 insertions(+), 514 deletions(-) create mode 100644 test/conformance/runtime/fixtures.h create mode 100644 test/conformance/runtime/urAdapterGet.cpp create mode 100644 test/conformance/runtime/urAdapterGetInfo.cpp rename test/conformance/{platform/urPlatformGetLastError.cpp => runtime/urAdapterGetLastError.cpp} (57%) create mode 100644 test/conformance/runtime/urAdapterRelease.cpp create mode 100644 test/conformance/runtime/urAdapterRetain.cpp diff --git a/examples/hello_world/hello_world.cpp b/examples/hello_world/hello_world.cpp index dcd504bf4e..4d903da65a 100644 --- a/examples/hello_world/hello_world.cpp +++ b/examples/hello_world/hello_world.cpp @@ -26,10 +26,27 @@ int main(int argc, char *argv[]) { } std::cout << "Platform initialized.\n"; + uint32_t adapterCount = 0; + std::vector adapters; uint32_t platformCount = 0; std::vector platforms; - status = urPlatformGet(1, nullptr, &platformCount); + status = urAdapterGet(0, nullptr, &adapterCount); + if (status != UR_RESULT_SUCCESS) { + std::cout << "urAdapterGet failed with return code: " << status + << std::endl; + return 1; + } + adapters.resize(adapterCount); + status = urAdapterGet(adapterCount, adapters.data(), nullptr); + if (status != UR_RESULT_SUCCESS) { + std::cout << "urAdapterGet failed with return code: " << status + << std::endl; + return 1; + } + + status = urPlatformGet(adapters.data(), adapterCount, 1, nullptr, + &platformCount); if (status != UR_RESULT_SUCCESS) { std::cout << "urPlatformGet failed with return code: " << status << std::endl; @@ -37,7 +54,8 @@ int main(int argc, char *argv[]) { } platforms.resize(platformCount); - status = urPlatformGet(platformCount, platforms.data(), nullptr); + status = urPlatformGet(adapters.data(), adapterCount, platformCount, + platforms.data(), nullptr); if (status != UR_RESULT_SUCCESS) { std::cout << "urPlatformGet failed with return code: " << status << std::endl; @@ -98,6 +116,9 @@ int main(int argc, char *argv[]) { } out: + for (auto adapter : adapters) { + urAdapterRelease(adapter); + } urTearDown(nullptr); return status == UR_RESULT_SUCCESS ? 0 : 1; } diff --git a/include/ur.py b/include/ur.py index 50d2969fc8..770e1d68a2 100644 --- a/include/ur.py +++ b/include/ur.py @@ -165,7 +165,6 @@ class ur_function_v(IntEnum): BINDLESS_IMAGES_DESTROY_EXTERNAL_SEMAPHORE_EXP = 147## Enumerator for ::urBindlessImagesDestroyExternalSemaphoreExp BINDLESS_IMAGES_WAIT_EXTERNAL_SEMAPHORE_EXP = 148 ## Enumerator for ::urBindlessImagesWaitExternalSemaphoreExp BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP = 149 ## Enumerator for ::urBindlessImagesSignalExternalSemaphoreExp - PLATFORM_GET_LAST_ERROR = 150 ## Enumerator for ::urPlatformGetLastError ENQUEUE_USM_FILL_2D = 151 ## Enumerator for ::urEnqueueUSMFill2D ENQUEUE_USM_MEMCPY_2D = 152 ## Enumerator for ::urEnqueueUSMMemcpy2D VIRTUAL_MEM_GRANULARITY_GET_INFO = 153 ## Enumerator for ::urVirtualMemGranularityGetInfo @@ -192,6 +191,11 @@ class ur_function_v(IntEnum): LOADER_CONFIG_RETAIN = 174 ## Enumerator for ::urLoaderConfigRetain LOADER_CONFIG_GET_INFO = 175 ## Enumerator for ::urLoaderConfigGetInfo LOADER_CONFIG_ENABLE_LAYER = 176 ## Enumerator for ::urLoaderConfigEnableLayer + ADAPTER_RELEASE = 177 ## Enumerator for ::urAdapterRelease + ADAPTER_GET = 178 ## Enumerator for ::urAdapterGet + ADAPTER_RETAIN = 179 ## Enumerator for ::urAdapterRetain + ADAPTER_GET_LAST_ERROR = 180 ## Enumerator for ::urAdapterGetLastError + ADAPTER_GET_INFO = 181 ## Enumerator for ::urAdapterGetInfo class ur_function_t(c_int): def __str__(self): @@ -288,6 +292,11 @@ class ur_bool_t(c_ubyte): class ur_loader_config_handle_t(c_void_p): pass +############################################################################### +## @brief Handle of an adapter instance +class ur_adapter_handle_t(c_void_p): + pass + ############################################################################### ## @brief Handle of a platform instance class ur_platform_handle_t(c_void_p): @@ -501,6 +510,36 @@ def __str__(self): return str(ur_loader_config_info_v(self.value)) +############################################################################### +## @brief Supported adapter info +class ur_adapter_info_v(IntEnum): + BACKEND = 0 ## [::ur_adapter_backend_t] Identifies the native backend supported by + ## the adapter. + REFERENCE_COUNT = 1 ## [uint32_t] Reference count of the adapter. + ## The reference count returned should be considered immediately stale. + ## It is unsuitable for general use in applications. This feature is + ## provided for identifying memory leaks. + +class ur_adapter_info_t(c_int): + def __str__(self): + return str(ur_adapter_info_v(self.value)) + + +############################################################################### +## @brief Identifies backend of the adapter +class ur_adapter_backend_v(IntEnum): + UNKNOWN = 0 ## The backend is not a recognized one + LEVEL_ZERO = 1 ## The backend is Level Zero + OPENCL = 2 ## The backend is OpenCL + CUDA = 3 ## The backend is CUDA + HIP = 4 ## The backend is HIP + NATIVE_CPU = 5 ## The backend is Native CPU + +class ur_adapter_backend_t(c_int): + def __str__(self): + return str(ur_adapter_backend_v(self.value)) + + ############################################################################### ## @brief Supported platform info class ur_platform_info_v(IntEnum): @@ -2273,9 +2312,9 @@ class ur_loader_config_dditable_t(Structure): ############################################################################### ## @brief Function-pointer for urPlatformGet if __use_win_types: - _urPlatformGet_t = WINFUNCTYPE( ur_result_t, c_ulong, POINTER(ur_platform_handle_t), POINTER(c_ulong) ) + _urPlatformGet_t = WINFUNCTYPE( ur_result_t, POINTER(ur_adapter_handle_t), c_ulong, c_ulong, POINTER(ur_platform_handle_t), POINTER(c_ulong) ) else: - _urPlatformGet_t = CFUNCTYPE( ur_result_t, c_ulong, POINTER(ur_platform_handle_t), POINTER(c_ulong) ) + _urPlatformGet_t = CFUNCTYPE( ur_result_t, POINTER(ur_adapter_handle_t), c_ulong, c_ulong, POINTER(ur_platform_handle_t), POINTER(c_ulong) ) ############################################################################### ## @brief Function-pointer for urPlatformGetInfo @@ -2298,13 +2337,6 @@ class ur_loader_config_dditable_t(Structure): else: _urPlatformCreateWithNativeHandle_t = CFUNCTYPE( ur_result_t, ur_native_handle_t, POINTER(ur_platform_native_properties_t), POINTER(ur_platform_handle_t) ) -############################################################################### -## @brief Function-pointer for urPlatformGetLastError -if __use_win_types: - _urPlatformGetLastError_t = WINFUNCTYPE( ur_result_t, ur_platform_handle_t, POINTER(c_char_p), POINTER(c_long) ) -else: - _urPlatformGetLastError_t = CFUNCTYPE( ur_result_t, ur_platform_handle_t, POINTER(c_char_p), POINTER(c_long) ) - ############################################################################### ## @brief Function-pointer for urPlatformGetApiVersion if __use_win_types: @@ -2328,7 +2360,6 @@ class ur_platform_dditable_t(Structure): ("pfnGetInfo", c_void_p), ## _urPlatformGetInfo_t ("pfnGetNativeHandle", c_void_p), ## _urPlatformGetNativeHandle_t ("pfnCreateWithNativeHandle", c_void_p), ## _urPlatformCreateWithNativeHandle_t - ("pfnGetLastError", c_void_p), ## _urPlatformGetLastError_t ("pfnGetApiVersion", c_void_p), ## _urPlatformGetApiVersion_t ("pfnGetBackendOption", c_void_p) ## _urPlatformGetBackendOption_t ] @@ -3565,13 +3596,53 @@ class ur_usm_p2p_exp_dditable_t(Structure): else: _urTearDown_t = CFUNCTYPE( ur_result_t, c_void_p ) +############################################################################### +## @brief Function-pointer for urAdapterGet +if __use_win_types: + _urAdapterGet_t = WINFUNCTYPE( ur_result_t, c_ulong, POINTER(ur_adapter_handle_t), POINTER(c_ulong) ) +else: + _urAdapterGet_t = CFUNCTYPE( ur_result_t, c_ulong, POINTER(ur_adapter_handle_t), POINTER(c_ulong) ) + +############################################################################### +## @brief Function-pointer for urAdapterRelease +if __use_win_types: + _urAdapterRelease_t = WINFUNCTYPE( ur_result_t, ur_adapter_handle_t ) +else: + _urAdapterRelease_t = CFUNCTYPE( ur_result_t, ur_adapter_handle_t ) + +############################################################################### +## @brief Function-pointer for urAdapterRetain +if __use_win_types: + _urAdapterRetain_t = WINFUNCTYPE( ur_result_t, ur_adapter_handle_t ) +else: + _urAdapterRetain_t = CFUNCTYPE( ur_result_t, ur_adapter_handle_t ) + +############################################################################### +## @brief Function-pointer for urAdapterGetLastError +if __use_win_types: + _urAdapterGetLastError_t = WINFUNCTYPE( ur_result_t, ur_adapter_handle_t, POINTER(c_char_p), POINTER(c_long) ) +else: + _urAdapterGetLastError_t = CFUNCTYPE( ur_result_t, ur_adapter_handle_t, POINTER(c_char_p), POINTER(c_long) ) + +############################################################################### +## @brief Function-pointer for urAdapterGetInfo +if __use_win_types: + _urAdapterGetInfo_t = WINFUNCTYPE( ur_result_t, ur_adapter_handle_t, ur_adapter_info_t, c_size_t, c_void_p, POINTER(c_size_t) ) +else: + _urAdapterGetInfo_t = CFUNCTYPE( ur_result_t, ur_adapter_handle_t, ur_adapter_info_t, c_size_t, c_void_p, POINTER(c_size_t) ) + ############################################################################### ## @brief Table of Global functions pointers class ur_global_dditable_t(Structure): _fields_ = [ ("pfnInit", c_void_p), ## _urInit_t - ("pfnTearDown", c_void_p) ## _urTearDown_t + ("pfnTearDown", c_void_p), ## _urTearDown_t + ("pfnAdapterGet", c_void_p), ## _urAdapterGet_t + ("pfnAdapterRelease", c_void_p), ## _urAdapterRelease_t + ("pfnAdapterRetain", c_void_p), ## _urAdapterRetain_t + ("pfnAdapterGetLastError", c_void_p), ## _urAdapterGetLastError_t + ("pfnAdapterGetInfo", c_void_p) ## _urAdapterGetInfo_t ] ############################################################################### @@ -3768,7 +3839,6 @@ def __init__(self, version : ur_api_version_t): self.urPlatformGetInfo = _urPlatformGetInfo_t(self.__dditable.Platform.pfnGetInfo) self.urPlatformGetNativeHandle = _urPlatformGetNativeHandle_t(self.__dditable.Platform.pfnGetNativeHandle) self.urPlatformCreateWithNativeHandle = _urPlatformCreateWithNativeHandle_t(self.__dditable.Platform.pfnCreateWithNativeHandle) - self.urPlatformGetLastError = _urPlatformGetLastError_t(self.__dditable.Platform.pfnGetLastError) self.urPlatformGetApiVersion = _urPlatformGetApiVersion_t(self.__dditable.Platform.pfnGetApiVersion) self.urPlatformGetBackendOption = _urPlatformGetBackendOption_t(self.__dditable.Platform.pfnGetBackendOption) @@ -4048,6 +4118,11 @@ def __init__(self, version : ur_api_version_t): # attach function interface to function address self.urInit = _urInit_t(self.__dditable.Global.pfnInit) self.urTearDown = _urTearDown_t(self.__dditable.Global.pfnTearDown) + self.urAdapterGet = _urAdapterGet_t(self.__dditable.Global.pfnAdapterGet) + self.urAdapterRelease = _urAdapterRelease_t(self.__dditable.Global.pfnAdapterRelease) + self.urAdapterRetain = _urAdapterRetain_t(self.__dditable.Global.pfnAdapterRetain) + self.urAdapterGetLastError = _urAdapterGetLastError_t(self.__dditable.Global.pfnAdapterGetLastError) + self.urAdapterGetInfo = _urAdapterGetInfo_t(self.__dditable.Global.pfnAdapterGetInfo) # call driver to get function pointers VirtualMem = ur_virtual_mem_dditable_t() diff --git a/include/ur_api.h b/include/ur_api.h index e80d850442..9460f43bd1 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -174,7 +174,6 @@ typedef enum ur_function_t { UR_FUNCTION_BINDLESS_IMAGES_DESTROY_EXTERNAL_SEMAPHORE_EXP = 147, ///< Enumerator for ::urBindlessImagesDestroyExternalSemaphoreExp UR_FUNCTION_BINDLESS_IMAGES_WAIT_EXTERNAL_SEMAPHORE_EXP = 148, ///< Enumerator for ::urBindlessImagesWaitExternalSemaphoreExp UR_FUNCTION_BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP = 149, ///< Enumerator for ::urBindlessImagesSignalExternalSemaphoreExp - UR_FUNCTION_PLATFORM_GET_LAST_ERROR = 150, ///< Enumerator for ::urPlatformGetLastError UR_FUNCTION_ENQUEUE_USM_FILL_2D = 151, ///< Enumerator for ::urEnqueueUSMFill2D UR_FUNCTION_ENQUEUE_USM_MEMCPY_2D = 152, ///< Enumerator for ::urEnqueueUSMMemcpy2D UR_FUNCTION_VIRTUAL_MEM_GRANULARITY_GET_INFO = 153, ///< Enumerator for ::urVirtualMemGranularityGetInfo @@ -201,6 +200,11 @@ typedef enum ur_function_t { UR_FUNCTION_LOADER_CONFIG_RETAIN = 174, ///< Enumerator for ::urLoaderConfigRetain UR_FUNCTION_LOADER_CONFIG_GET_INFO = 175, ///< Enumerator for ::urLoaderConfigGetInfo UR_FUNCTION_LOADER_CONFIG_ENABLE_LAYER = 176, ///< Enumerator for ::urLoaderConfigEnableLayer + UR_FUNCTION_ADAPTER_RELEASE = 177, ///< Enumerator for ::urAdapterRelease + UR_FUNCTION_ADAPTER_GET = 178, ///< Enumerator for ::urAdapterGet + UR_FUNCTION_ADAPTER_RETAIN = 179, ///< Enumerator for ::urAdapterRetain + UR_FUNCTION_ADAPTER_GET_LAST_ERROR = 180, ///< Enumerator for ::urAdapterGetLastError + UR_FUNCTION_ADAPTER_GET_INFO = 181, ///< Enumerator for ::urAdapterGetInfo /// @cond UR_FUNCTION_FORCE_UINT32 = 0x7fffffff /// @endcond @@ -327,6 +331,10 @@ typedef uint8_t ur_bool_t; /// @brief Handle of a loader config object typedef struct ur_loader_config_handle_t_ *ur_loader_config_handle_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Handle of an adapter instance +typedef struct ur_adapter_handle_t_ *ur_adapter_handle_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief Handle of a platform instance typedef struct ur_platform_handle_t_ *ur_platform_handle_t; @@ -707,6 +715,197 @@ urTearDown( void *pParams ///< [in] pointer to tear down parameters ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Retrieves all available adapters +/// +/// @details +/// - Adapter implementations must return exactly one adapter handle from +/// this entry point. +/// - The loader may return more than one adapter handle when there are +/// multiple available. +/// - Each returned adapter has its reference count incremented and should +/// be released with a subsequent call to ::urAdapterRelease. +/// - Adapters may perform adapter-specific state initialization when the +/// first reference to them is taken. +/// - An application may call this entry point multiple times to acquire +/// multiple references to the adapter handle(s). +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_SIZE +UR_APIEXPORT ur_result_t UR_APICALL +urAdapterGet( + uint32_t NumEntries, ///< [in] the number of adapters to be added to phAdapters. + ///< If phAdapters is not NULL, then NumEntries should be greater than + ///< zero, otherwise ::UR_RESULT_ERROR_INVALID_SIZE, + ///< will be returned. + ur_adapter_handle_t *phAdapters, ///< [out][optional][range(0, NumEntries)] array of handle of adapters. + ///< If NumEntries is less than the number of adapters available, then + ///< ::urAdapterGet shall only retrieve that number of platforms. + uint32_t *pNumAdapters ///< [out][optional] returns the total number of adapters available. +); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Releases the adapter handle reference indicating end of its usage +/// +/// @details +/// - When the reference count of the adapter reaches zero, the adapter may +/// perform adapter-specififc resource teardown +/// +/// @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 == hAdapter` +UR_APIEXPORT ur_result_t UR_APICALL +urAdapterRelease( + ur_adapter_handle_t hAdapter ///< [in] Adapter handle to release +); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get a reference to the adapter handle. +/// +/// @details +/// - Get a reference to the adapter handle. Increment its reference count +/// +/// @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 == hAdapter` +UR_APIEXPORT ur_result_t UR_APICALL +urAdapterRetain( + ur_adapter_handle_t hAdapter ///< [in] Adapter handle to retain +); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get the last adapter specific error. +/// +/// @details +/// To be used after another entry-point has returned +/// ::UR_RESULT_ERROR_ADAPTER_SPECIFIC in order to retrieve a message describing +/// the circumstances of the underlying driver error and the error code +/// returned by the failed driver entry-point. +/// +/// * Implementations *must* store the message and error code in thread-local +/// storage prior to returning ::UR_RESULT_ERROR_ADAPTER_SPECIFIC. +/// +/// * The message and error code storage is will only be valid if a previously +/// called entry-point returned ::UR_RESULT_ERROR_ADAPTER_SPECIFIC. +/// +/// * The memory pointed to by the C string returned in `ppMessage` is owned by +/// the adapter and *must* be null terminated. +/// +/// * The application *may* call this function from simultaneous threads. +/// +/// * The implementation of this function *should* be lock-free. +/// +/// Example usage: +/// +/// ```cpp +/// if (::urQueueCreate(hContext, hDevice, nullptr, &hQueue) == +/// ::UR_RESULT_ERROR_ADAPTER_SPECIFIC) { +/// const char* pMessage; +/// int32_t error; +/// ::urAdapterGetLastError(hAdapter, &pMessage, &error); +/// } +/// ``` +/// +/// @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 == hAdapter` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == ppMessage` +/// + `NULL == pError` +UR_APIEXPORT ur_result_t UR_APICALL +urAdapterGetLastError( + ur_adapter_handle_t hAdapter, ///< [in] handle of the adapter instance + const char **ppMessage, ///< [out] pointer to a C string where the adapter specific error message + ///< will be stored. + int32_t *pError ///< [out] pointer to an integer where the adapter specific error code will + ///< be stored. +); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Supported adapter info +typedef enum ur_adapter_info_t { + UR_ADAPTER_INFO_BACKEND = 0, ///< [::ur_adapter_backend_t] Identifies the native backend supported by + ///< the adapter. + UR_ADAPTER_INFO_REFERENCE_COUNT = 1, ///< [uint32_t] Reference count of the adapter. + ///< The reference count returned should be considered immediately stale. + ///< It is unsuitable for general use in applications. This feature is + ///< provided for identifying memory leaks. + /// @cond + UR_ADAPTER_INFO_FORCE_UINT32 = 0x7fffffff + /// @endcond + +} ur_adapter_info_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Retrieves information about the adapter +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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 == hAdapter` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_ADAPTER_INFO_REFERENCE_COUNT < propName` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// + If `propName` is not supported by the adapter. +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `propSize == 0 && pPropValue != NULL` +/// + If `propSize` is less than the real number of bytes needed to return the info. +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `propSize != 0 && pPropValue == NULL` +/// + `pPropValue == NULL && pPropSizeRet == NULL` +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY +UR_APIEXPORT ur_result_t UR_APICALL +urAdapterGetInfo( + ur_adapter_handle_t hAdapter, ///< [in] handle of the adapter + ur_adapter_info_t propName, ///< [in] type of the info to retrieve + size_t propSize, ///< [in] the number of bytes pointed to by pPropValue. + void *pPropValue, ///< [out][optional][typename(propName, propSize)] array of bytes holding + ///< the info. + ///< If Size is not equal to or greater to the real number of bytes needed + ///< to return the info then the ::UR_RESULT_ERROR_INVALID_SIZE error is + ///< returned and pPropValue is not used. + size_t *pPropSizeRet ///< [out][optional] pointer to the actual number of bytes being queried by pPropValue. +); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Identifies backend of the adapter +typedef enum ur_adapter_backend_t { + UR_ADAPTER_BACKEND_UNKNOWN = 0, ///< The backend is not a recognized one + UR_ADAPTER_BACKEND_LEVEL_ZERO = 1, ///< The backend is Level Zero + UR_ADAPTER_BACKEND_OPENCL = 2, ///< The backend is OpenCL + UR_ADAPTER_BACKEND_CUDA = 3, ///< The backend is CUDA + UR_ADAPTER_BACKEND_HIP = 4, ///< The backend is HIP + UR_ADAPTER_BACKEND_NATIVE_CPU = 5, ///< The backend is Native CPU + /// @cond + UR_ADAPTER_BACKEND_FORCE_UINT32 = 0x7fffffff + /// @endcond + +} ur_adapter_backend_t; + #if !defined(__GNUC__) #pragma endregion #endif @@ -715,7 +914,7 @@ urTearDown( #pragma region platform #endif /////////////////////////////////////////////////////////////////////////////// -/// @brief Retrieves all available platforms +/// @brief Retrieves all available platforms for the given adapters /// /// @details /// - Multiple calls to this function will return identical platforms @@ -732,9 +931,13 @@ urTearDown( /// - ::UR_RESULT_ERROR_UNINITIALIZED /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == phAdapters` /// - ::UR_RESULT_ERROR_INVALID_SIZE UR_APIEXPORT ur_result_t UR_APICALL urPlatformGet( + ur_adapter_handle_t *phAdapters, ///< [in][range(0, NumAdapters)] array of adapters to query for platforms. + uint32_t NumAdapters, ///< [in] number of adapters pointed to by phAdapters uint32_t NumEntries, ///< [in] the number of platforms to be added to phPlatforms. ///< If phPlatforms is not NULL, then NumEntries should be greater than ///< zero, otherwise ::UR_RESULT_ERROR_INVALID_SIZE, @@ -942,58 +1145,6 @@ urPlatformGetBackendOption( ///< the frontend option. ); -/////////////////////////////////////////////////////////////////////////////// -/// @brief Get the last adapter specific error. -/// -/// @details -/// To be used after another entry-point has returned -/// ::UR_RESULT_ERROR_ADAPTER_SPECIFIC in order to retrieve a message describing -/// the circumstances of the underlying driver error and the error code -/// returned by the failed driver entry-point. -/// -/// * Implementations *must* store the message and error code in thread-local -/// storage prior to returning ::UR_RESULT_ERROR_ADAPTER_SPECIFIC. -/// -/// * The message and error code storage is will only be valid if a previously -/// called entry-point returned ::UR_RESULT_ERROR_ADAPTER_SPECIFIC. -/// -/// * The memory pointed to by the C string returned in `ppMessage` is owned by -/// the adapter and *must* be null terminated. -/// -/// * The application *may* call this function from simultaneous threads. -/// -/// * The implementation of this function *should* be lock-free. -/// -/// Example usage: -/// -/// ```cpp -/// if (::urQueueCreate(hContext, hDevice, nullptr, &hQueue) == -/// ::UR_RESULT_ERROR_ADAPTER_SPECIFIC) { -/// const char* pMessage; -/// int32_t error; -/// ::urPlatformGetLastError(hPlatform, &pMessage, &error); -/// } -/// ``` -/// -/// @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 == hPlatform` -/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// + `NULL == ppMessage` -/// + `NULL == pError` -UR_APIEXPORT ur_result_t UR_APICALL -urPlatformGetLastError( - ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance - const char **ppMessage, ///< [out] pointer to a C string where the adapter specific error message - ///< will be stored. - int32_t *pError ///< [out] pointer to an integer where the adapter specific error code will - ///< be stored. -); - /////////////////////////////////////////////////////////////////////////////// /// @brief Identifies native backend adapters typedef enum ur_platform_backend_t { @@ -8093,6 +8244,8 @@ typedef struct ur_loader_config_enable_layer_params_t { /// @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_platform_get_params_t { + ur_adapter_handle_t **pphAdapters; + uint32_t *pNumAdapters; uint32_t *pNumEntries; ur_platform_handle_t **pphPlatforms; uint32_t **ppNumPlatforms; @@ -8129,16 +8282,6 @@ typedef struct ur_platform_create_with_native_handle_params_t { ur_platform_handle_t **pphPlatform; } ur_platform_create_with_native_handle_params_t; -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function parameters for urPlatformGetLastError -/// @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_platform_get_last_error_params_t { - ur_platform_handle_t *phPlatform; - const char ***pppMessage; - int32_t **ppError; -} ur_platform_get_last_error_params_t; - /////////////////////////////////////////////////////////////////////////////// /// @brief Function parameters for urPlatformGetApiVersion /// @details Each entry is a pointer to the parameter passed to the function; @@ -9854,6 +9997,54 @@ typedef struct ur_tear_down_params_t { void **ppParams; } ur_tear_down_params_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urAdapterGet +/// @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_adapter_get_params_t { + uint32_t *pNumEntries; + ur_adapter_handle_t **pphAdapters; + uint32_t **ppNumAdapters; +} ur_adapter_get_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urAdapterRelease +/// @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_adapter_release_params_t { + ur_adapter_handle_t *phAdapter; +} ur_adapter_release_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urAdapterRetain +/// @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_adapter_retain_params_t { + ur_adapter_handle_t *phAdapter; +} ur_adapter_retain_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urAdapterGetLastError +/// @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_adapter_get_last_error_params_t { + ur_adapter_handle_t *phAdapter; + const char ***pppMessage; + int32_t **ppError; +} ur_adapter_get_last_error_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urAdapterGetInfo +/// @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_adapter_get_info_params_t { + ur_adapter_handle_t *phAdapter; + ur_adapter_info_t *ppropName; + size_t *ppropSize; + void **ppPropValue; + size_t **ppPropSizeRet; +} ur_adapter_get_info_params_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief Function parameters for urVirtualMemGranularityGetInfo /// @details Each entry is a pointer to the parameter passed to the function; diff --git a/include/ur_ddi.h b/include/ur_ddi.h index cdf161412d..958f5ca29b 100644 --- a/include/ur_ddi.h +++ b/include/ur_ddi.h @@ -24,6 +24,8 @@ extern "C" { /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urPlatformGet typedef ur_result_t(UR_APICALL *ur_pfnPlatformGet_t)( + ur_adapter_handle_t *, + uint32_t, uint32_t, ur_platform_handle_t *, uint32_t *); @@ -50,13 +52,6 @@ typedef ur_result_t(UR_APICALL *ur_pfnPlatformCreateWithNativeHandle_t)( const ur_platform_native_properties_t *, ur_platform_handle_t *); -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for urPlatformGetLastError -typedef ur_result_t(UR_APICALL *ur_pfnPlatformGetLastError_t)( - ur_platform_handle_t, - const char **, - int32_t *); - /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urPlatformGetApiVersion typedef ur_result_t(UR_APICALL *ur_pfnPlatformGetApiVersion_t)( @@ -77,7 +72,6 @@ typedef struct ur_platform_dditable_t { ur_pfnPlatformGetInfo_t pfnGetInfo; ur_pfnPlatformGetNativeHandle_t pfnGetNativeHandle; ur_pfnPlatformCreateWithNativeHandle_t pfnCreateWithNativeHandle; - ur_pfnPlatformGetLastError_t pfnGetLastError; ur_pfnPlatformGetApiVersion_t pfnGetApiVersion; ur_pfnPlatformGetBackendOption_t pfnGetBackendOption; } ur_platform_dditable_t; @@ -1877,11 +1871,49 @@ typedef ur_result_t(UR_APICALL *ur_pfnInit_t)( typedef ur_result_t(UR_APICALL *ur_pfnTearDown_t)( void *); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urAdapterGet +typedef ur_result_t(UR_APICALL *ur_pfnAdapterGet_t)( + uint32_t, + ur_adapter_handle_t *, + uint32_t *); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urAdapterRelease +typedef ur_result_t(UR_APICALL *ur_pfnAdapterRelease_t)( + ur_adapter_handle_t); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urAdapterRetain +typedef ur_result_t(UR_APICALL *ur_pfnAdapterRetain_t)( + ur_adapter_handle_t); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urAdapterGetLastError +typedef ur_result_t(UR_APICALL *ur_pfnAdapterGetLastError_t)( + ur_adapter_handle_t, + const char **, + int32_t *); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urAdapterGetInfo +typedef ur_result_t(UR_APICALL *ur_pfnAdapterGetInfo_t)( + ur_adapter_handle_t, + ur_adapter_info_t, + size_t, + void *, + size_t *); + /////////////////////////////////////////////////////////////////////////////// /// @brief Table of Global functions pointers typedef struct ur_global_dditable_t { ur_pfnInit_t pfnInit; ur_pfnTearDown_t pfnTearDown; + ur_pfnAdapterGet_t pfnAdapterGet; + ur_pfnAdapterRelease_t pfnAdapterRelease; + ur_pfnAdapterRetain_t pfnAdapterRetain; + ur_pfnAdapterGetLastError_t pfnAdapterGetLastError; + ur_pfnAdapterGetInfo_t pfnAdapterGetInfo; } ur_global_dditable_t; /////////////////////////////////////////////////////////////////////////////// diff --git a/scripts/core/PROG.rst b/scripts/core/PROG.rst index 9c97823be1..e7bf24986b 100644 --- a/scripts/core/PROG.rst +++ b/scripts/core/PROG.rst @@ -51,12 +51,18 @@ Initialization and Discovery .. parsed-literal:: + // Discover all available adapters + uint32_t adapterCount = 0; + ${x}AdapterGet(0, nullptr, &adapterCount); + std::vector<${x}_adapter_handle_t> adapters(adapterCount); + ${x}AdapterGet(adapterCount, adapters.data(), nullptr); + // Discover all the platform instances uint32_t platformCount = 0; - ${x}PlatformGet(0, nullptr, &platformCount); + ${x}PlatformGet(adapters.data(), adapterCount, 0, nullptr, &platformCount); std::vector<${x}_platform_handle_t> platforms(platformCount); - ${x}PlatformGet(platform.size(), platforms.data(), &platformCount); + ${x}PlatformGet(adapters.data(), adapterCount, platform.size(), platforms.data(), &platformCount); // Get number of total GPU devices in the platform uint32_t deviceCount = 0; diff --git a/scripts/core/common.yml b/scripts/core/common.yml index ed29a1be99..7a522ada35 100644 --- a/scripts/core/common.yml +++ b/scripts/core/common.yml @@ -65,6 +65,11 @@ class: $xLoaderConfig name: "$x_loader_config_handle_t" --- #-------------------------------------------------------------------------- type: handle +desc: "Handle of an adapter instance" +class: $xAdapter +name: "$x_adapter_handle_t" +--- #-------------------------------------------------------------------------- +type: handle desc: "Handle of a platform instance" class: $xPlatform name: "$x_platform_handle_t" diff --git a/scripts/core/platform.yml b/scripts/core/platform.yml index 7188044848..c0c235c354 100644 --- a/scripts/core/platform.yml +++ b/scripts/core/platform.yml @@ -13,7 +13,7 @@ desc: "Intel $OneApi Unified Runtime APIs for Platform" ordinal: "1" --- #-------------------------------------------------------------------------- type: function -desc: "Retrieves all available platforms" +desc: "Retrieves all available platforms for the given adapters" class: $xPlatform name: Get decl: static @@ -24,6 +24,12 @@ details: - "Multiple calls to this function will return identical platforms handles, in the same order." - "The application may call this function from simultaneous threads, the implementation must be thread-safe" params: + - type: "$x_adapter_handle_t*" + name: "phAdapters" + desc: "[in][range(0, NumAdapters)] array of adapters to query for platforms." + - type: "uint32_t" + name: "NumAdapters" + desc: "[in] number of adapters pointed to by phAdapters" - type: "uint32_t" name: NumEntries desc: | @@ -221,56 +227,6 @@ returns: - $X_RESULT_ERROR_INVALID_VALUE: - "If `pFrontendOption` is not a valid frontend option." --- #-------------------------------------------------------------------------- -type: function -desc: "Get the last adapter specific error." -details: | - To be used after another entry-point has returned - $X_RESULT_ERROR_ADAPTER_SPECIFIC in order to retrieve a message describing - the circumstances of the underlying driver error and the error code - returned by the failed driver entry-point. - - * Implementations *must* store the message and error code in thread-local - storage prior to returning $X_RESULT_ERROR_ADAPTER_SPECIFIC. - - * The message and error code storage is will only be valid if a previously - called entry-point returned $X_RESULT_ERROR_ADAPTER_SPECIFIC. - - * The memory pointed to by the C string returned in `ppMessage` is owned by - the adapter and *must* be null terminated. - - * The application *may* call this function from simultaneous threads. - - * The implementation of this function *should* be lock-free. - - Example usage: - - ```cpp - if ($xQueueCreate(hContext, hDevice, nullptr, &hQueue) == - $X_RESULT_ERROR_ADAPTER_SPECIFIC) { - const char* pMessage; - int32_t error; - $xPlatformGetLastError(hPlatform, &pMessage, &error); - } - ``` -class: $xPlatform -name: GetLastError -decl: static -ordinal: "0" -params: - - type: $x_platform_handle_t - name: hPlatform - desc: "[in] handle of the platform instance" - - type: const char** - name: ppMessage - desc: > - [out] pointer to a C string where the adapter specific error message - will be stored. - - type: int32_t* - name: pError - desc: > - [out] pointer to an integer where the adapter specific error code - will be stored. ---- #-------------------------------------------------------------------------- type: enum desc: "Identifies native backend adapters" class: $xPlatform diff --git a/scripts/core/registry.yml b/scripts/core/registry.yml index f0d198b668..30596ec14e 100644 --- a/scripts/core/registry.yml +++ b/scripts/core/registry.yml @@ -436,9 +436,6 @@ etors: - name: BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP desc: Enumerator for $xBindlessImagesSignalExternalSemaphoreExp value: '149' -- name: PLATFORM_GET_LAST_ERROR - desc: Enumerator for $xPlatformGetLastError - value: '150' - name: ENQUEUE_USM_FILL_2D desc: Enumerator for $xEnqueueUSMFill2D value: '151' @@ -517,6 +514,21 @@ etors: - name: LOADER_CONFIG_ENABLE_LAYER desc: Enumerator for $xLoaderConfigEnableLayer value: '176' +- name: ADAPTER_RELEASE + desc: Enumerator for $xAdapterRelease + value: '177' +- name: ADAPTER_GET + desc: Enumerator for $xAdapterGet + value: '178' +- name: ADAPTER_RETAIN + desc: Enumerator for $xAdapterRetain + value: '179' +- name: ADAPTER_GET_LAST_ERROR + desc: Enumerator for $xAdapterGetLastError + value: '180' +- name: ADAPTER_GET_INFO + desc: Enumerator for $xAdapterGetInfo + value: '181' --- type: enum desc: Defines structure types diff --git a/scripts/core/runtime.yml b/scripts/core/runtime.yml index b5bbd9987c..06010a643c 100644 --- a/scripts/core/runtime.yml +++ b/scripts/core/runtime.yml @@ -174,3 +174,191 @@ params: desc: "[in] pointer to tear down parameters" returns: - $X_RESULT_ERROR_OUT_OF_HOST_MEMORY +--- #-------------------------------------------------------------------------- +type: function +desc: "Retrieves all available adapters" +class: $x +name: AdapterGet +decl: static +ordinal: "2" +details: + - "Adapter implementations must return exactly one adapter handle from this entry point." + - "The loader may return more than one adapter handle when there are multiple available." + - "Each returned adapter has its reference count incremented and should be released with a subsequent call to $xAdapterRelease." + - "Adapters may perform adapter-specific state initialization when the first reference to them is taken." + - "An application may call this entry point multiple times to acquire multiple references to the adapter handle(s)." +params: + - type: "uint32_t" + name: NumEntries + desc: | + [in] the number of adapters to be added to phAdapters. + If phAdapters is not NULL, then NumEntries should be greater than zero, otherwise $X_RESULT_ERROR_INVALID_SIZE, + will be returned. + - type: "$x_adapter_handle_t*" + name: phAdapters + desc: | + [out][optional][range(0, NumEntries)] array of handle of adapters. + If NumEntries is less than the number of adapters available, then $xAdapterGet shall only retrieve that number of platforms. + - type: "uint32_t*" + name: "pNumAdapters" + desc: | + [out][optional] returns the total number of adapters available. +returns: + - $X_RESULT_ERROR_INVALID_SIZE +--- #-------------------------------------------------------------------------- +type: function +desc: "Releases the adapter handle reference indicating end of its usage" +class: $x +name: AdapterRelease +decl: static +ordinal: "3" +details: + - "When the reference count of the adapter reaches zero, the adapter may perform adapter-specififc resource teardown" +params: + - type: "$x_adapter_handle_t" + name: hAdapter + desc: | + [in] Adapter handle to release +--- #-------------------------------------------------------------------------- +type: function +desc: "Get a reference to the adapter handle." +class: $x +name: AdapterRetain +decl: static +ordinal: "4" +details: + - "Get a reference to the adapter handle. Increment its reference count" +params: + - type: "$x_adapter_handle_t" + name: hAdapter + desc: | + [in] Adapter handle to retain +--- #-------------------------------------------------------------------------- +type: function +desc: "Get the last adapter specific error." +details: | + To be used after another entry-point has returned + $X_RESULT_ERROR_ADAPTER_SPECIFIC in order to retrieve a message describing + the circumstances of the underlying driver error and the error code + returned by the failed driver entry-point. + + * Implementations *must* store the message and error code in thread-local + storage prior to returning $X_RESULT_ERROR_ADAPTER_SPECIFIC. + + * The message and error code storage is will only be valid if a previously + called entry-point returned $X_RESULT_ERROR_ADAPTER_SPECIFIC. + + * The memory pointed to by the C string returned in `ppMessage` is owned by + the adapter and *must* be null terminated. + + * The application *may* call this function from simultaneous threads. + + * The implementation of this function *should* be lock-free. + + Example usage: + + ```cpp + if ($xQueueCreate(hContext, hDevice, nullptr, &hQueue) == + $X_RESULT_ERROR_ADAPTER_SPECIFIC) { + const char* pMessage; + int32_t error; + $xAdapterGetLastError(hAdapter, &pMessage, &error); + } + ``` +class: $x +name: AdapterGetLastError +decl: static +ordinal: "5" +params: + - type: $x_adapter_handle_t + name: hAdapter + desc: "[in] handle of the adapter instance" + - type: const char** + name: ppMessage + desc: > + [out] pointer to a C string where the adapter specific error message + will be stored. + - type: int32_t* + name: pError + desc: > + [out] pointer to an integer where the adapter specific error code + will be stored. +--- #-------------------------------------------------------------------------- +type: enum +desc: "Supported adapter info" +class: $xAdapter +name: $x_adapter_info_t +typed_etors: True +etors: + - name: BACKEND + desc: "[$x_adapter_backend_t] Identifies the native backend supported by the adapter." + - name: REFERENCE_COUNT + desc: | + [uint32_t] Reference count of the adapter. + The reference count returned should be considered immediately stale. + It is unsuitable for general use in applications. This feature is provided for identifying memory leaks. +--- #-------------------------------------------------------------------------- +type: function +desc: "Retrieves information about the adapter" +class: $x +name: AdapterGetInfo +decl: static +ordinal: "6" +details: + - "The application may call this function from simultaneous threads." + - "The implementation of this function should be lock-free." +params: + - type: $x_adapter_handle_t + name: hAdapter + desc: "[in] handle of the adapter" + - type: $x_adapter_info_t + name: propName + desc: "[in] type of the info to retrieve" + - type: "size_t" + name: propSize + desc: | + [in] the number of bytes pointed to by pPropValue. + - type: "void*" + name: pPropValue + desc: | + [out][optional][typename(propName, propSize)] array of bytes holding the info. + If Size is not equal to or greater to the real number of bytes needed to return the info then the $X_RESULT_ERROR_INVALID_SIZE error is returned and pPropValue is not used. + - type: "size_t*" + name: pPropSizeRet + desc: | + [out][optional] pointer to the actual number of bytes being queried by pPropValue. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_ENUMERATION: + - "If `propName` is not supported by the adapter." + - $X_RESULT_ERROR_INVALID_SIZE: + - "`propSize == 0 && pPropValue != NULL`" + - "If `propSize` is less than the real number of bytes needed to return the info." + - $X_RESULT_ERROR_INVALID_NULL_POINTER: + - "`propSize != 0 && pPropValue == NULL`" + - "`pPropValue == NULL && pPropSizeRet == NULL`" + - $X_RESULT_ERROR_OUT_OF_RESOURCES + - $X_RESULT_ERROR_OUT_OF_HOST_MEMORY +--- #-------------------------------------------------------------------------- +type: enum +desc: "Identifies backend of the adapter" +class: $x +name: $x_adapter_backend_t +etors: + - name: UNKNOWN + value: "0" + desc: "The backend is not a recognized one" + - name: LEVEL_ZERO + value: "1" + desc: "The backend is Level Zero" + - name: OPENCL + value: "2" + desc: "The backend is OpenCL" + - name: CUDA + value: "3" + desc: "The backend is CUDA" + - name: HIP + value: "4" + desc: "The backend is HIP" + - name: NATIVE_CPU + value: "5" + desc: "The backend is Native CPU" diff --git a/scripts/templates/ldrddi.cpp.mako b/scripts/templates/ldrddi.cpp.mako index 76ba506b64..bb15dc97c7 100644 --- a/scripts/templates/ldrddi.cpp.mako +++ b/scripts/templates/ldrddi.cpp.mako @@ -66,36 +66,65 @@ namespace ur_loader platform.dditable.${n}.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}( ${", ".join(th.make_param_lines(n, tags, obj, format=["name"]))} ); } + %elif re.match(r"\w+AdapterGet$", th.make_func_name(n, tags, obj)): + + size_t adapterIndex = 0; + if( nullptr != ${obj['params'][1]['name']} && ${obj['params'][0]['name']} !=0) + { + for( auto& platform : context->platforms ) + { + platform.dditable.${n}.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}( 1, &${obj['params'][1]['name']}[adapterIndex], nullptr ); + try + { + ${obj['params'][1]['name']}[adapterIndex] = reinterpret_cast<${n}_adapter_handle_t>(${n}_adapter_factory.getInstance( + ${obj['params'][1]['name']}[adapterIndex], &platform.dditable + )); + } + catch( std::bad_alloc &) + { + result = ${X}_RESULT_ERROR_OUT_OF_HOST_MEMORY; + break; + } + adapterIndex++; + } + } + + if( ${obj['params'][2]['name']} != nullptr ) + { + *${obj['params'][2]['name']} = static_cast(context->platforms.size()); + } + %elif re.match(r"\w+PlatformGet$", th.make_func_name(n, tags, obj)): uint32_t total_platform_handle_count = 0; - for( auto& platform : context->platforms ) + for( uint32_t adapter_index = 0; adapter_index < ${obj['params'][1]['name']}; adapter_index++) { - if(platform.initStatus != ${X}_RESULT_SUCCESS) - continue; + // extract adapter's function pointer table + auto dditable = + reinterpret_cast<${n}_platform_object_t *>( ${obj['params'][0]['name']}[adapter_index])->dditable; - if( ( 0 < ${obj['params'][0]['name']} ) && ( ${obj['params'][0]['name']} == total_platform_handle_count)) + if( ( 0 < ${obj['params'][2]['name']} ) && ( ${obj['params'][2]['name']} == total_platform_handle_count)) break; uint32_t library_platform_handle_count = 0; - result = platform.dditable.${n}.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}( 0, nullptr, &library_platform_handle_count ); + result = dditable->${n}.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}( &${obj['params'][0]['name']}[adapter_index], 1, 0, nullptr, &library_platform_handle_count ); if( ${X}_RESULT_SUCCESS != result ) break; - if( nullptr != ${obj['params'][1]['name']} && ${obj['params'][0]['name']} !=0) + if( nullptr != ${obj['params'][3]['name']} && ${obj['params'][2]['name']} !=0) { - if( total_platform_handle_count + library_platform_handle_count > ${obj['params'][0]['name']}) { - library_platform_handle_count = ${obj['params'][0]['name']} - total_platform_handle_count; + if( total_platform_handle_count + library_platform_handle_count > ${obj['params'][2]['name']}) { + library_platform_handle_count = ${obj['params'][2]['name']} - total_platform_handle_count; } - result = platform.dditable.${n}.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}( library_platform_handle_count, &${obj['params'][1]['name']}[ total_platform_handle_count ], nullptr ); + result = dditable->${n}.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}( &${obj['params'][0]['name']}[adapter_index], 1, library_platform_handle_count, &${obj['params'][3]['name']}[ total_platform_handle_count ], nullptr ); if( ${X}_RESULT_SUCCESS != result ) break; try { for( uint32_t i = 0; i < library_platform_handle_count; ++i ) { uint32_t platform_index = total_platform_handle_count + i; - ${obj['params'][1]['name']}[ platform_index ] = reinterpret_cast<${n}_platform_handle_t>( - ${n}_platform_factory.getInstance( ${obj['params'][1]['name']}[ platform_index ], &platform.dditable ) ); + ${obj['params'][3]['name']}[ platform_index ] = reinterpret_cast<${n}_platform_handle_t>( + ${n}_platform_factory.getInstance( ${obj['params'][3]['name']}[ platform_index ], dditable ) ); } } catch( std::bad_alloc& ) @@ -107,8 +136,8 @@ namespace ur_loader total_platform_handle_count += library_platform_handle_count; } - if( ${X}_RESULT_SUCCESS == result && ${obj['params'][2]['name']} != nullptr ) - *${obj['params'][2]['name']} = total_platform_handle_count; + if( ${X}_RESULT_SUCCESS == result && ${obj['params'][4]['name']} != nullptr ) + *${obj['params'][4]['name']} = total_platform_handle_count; %else: <%param_replacements={}%> diff --git a/source/adapters/null/ur_null.cpp b/source/adapters/null/ur_null.cpp index 5653ca57db..18c8d89ef5 100644 --- a/source/adapters/null/ur_null.cpp +++ b/source/adapters/null/ur_null.cpp @@ -18,7 +18,28 @@ context_t d_context; ////////////////////////////////////////////////////////////////////////// context_t::context_t() { ////////////////////////////////////////////////////////////////////////// - urDdiTable.Platform.pfnGet = [](uint32_t NumEntries, + urDdiTable.Global.pfnAdapterGet = [](uint32_t NumAdapters, + ur_adapter_handle_t *phAdapters, + uint32_t *pNumAdapters) { + if (phAdapters != nullptr && NumAdapters != 1) { + return UR_RESULT_ERROR_INVALID_SIZE; + } + if (pNumAdapters != nullptr) { + *pNumAdapters = 1; + } + if (nullptr != phAdapters) { + *reinterpret_cast(phAdapters) = d_context.get(); + } + + return UR_RESULT_SUCCESS; + }; + ////////////////////////////////////////////////////////////////////////// + urDdiTable.Global.pfnAdapterRelease = [](ur_adapter_handle_t) { + return UR_RESULT_SUCCESS; + }; + ////////////////////////////////////////////////////////////////////////// + urDdiTable.Platform.pfnGet = [](ur_adapter_handle_t *phAdapters, + uint32_t NumAdapters, uint32_t NumEntries, ur_platform_handle_t *phPlatforms, uint32_t *pNumPlatforms) { if (phPlatforms != nullptr && NumEntries != 1) { diff --git a/source/adapters/null/ur_nullddi.cpp b/source/adapters/null/ur_nullddi.cpp index b26735876b..f9b8fb4d11 100644 --- a/source/adapters/null/ur_nullddi.cpp +++ b/source/adapters/null/ur_nullddi.cpp @@ -55,9 +55,144 @@ __urdlllocal ur_result_t UR_APICALL urTearDown( return exceptionToResult(std::current_exception()); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterGet +__urdlllocal ur_result_t UR_APICALL urAdapterGet( + uint32_t + NumEntries, ///< [in] the number of adapters to be added to phAdapters. + ///< If phAdapters is not NULL, then NumEntries should be greater than + ///< zero, otherwise ::UR_RESULT_ERROR_INVALID_SIZE, + ///< will be returned. + ur_adapter_handle_t * + phAdapters, ///< [out][optional][range(0, NumEntries)] array of handle of adapters. + ///< If NumEntries is less than the number of adapters available, then + ///< ::urAdapterGet shall only retrieve that number of platforms. + uint32_t * + pNumAdapters ///< [out][optional] returns the total number of adapters available. + ) try { + ur_result_t result = UR_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnAdapterGet = d_context.urDdiTable.Global.pfnAdapterGet; + if (nullptr != pfnAdapterGet) { + result = pfnAdapterGet(NumEntries, phAdapters, pNumAdapters); + } else { + // generic implementation + for (size_t i = 0; (nullptr != phAdapters) && (i < NumEntries); ++i) { + phAdapters[i] = + reinterpret_cast(d_context.get()); + } + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterRelease +__urdlllocal ur_result_t UR_APICALL urAdapterRelease( + ur_adapter_handle_t hAdapter ///< [in] Adapter handle to release + ) try { + ur_result_t result = UR_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnAdapterRelease = d_context.urDdiTable.Global.pfnAdapterRelease; + if (nullptr != pfnAdapterRelease) { + result = pfnAdapterRelease(hAdapter); + } else { + // generic implementation + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterRetain +__urdlllocal ur_result_t UR_APICALL urAdapterRetain( + ur_adapter_handle_t hAdapter ///< [in] Adapter handle to retain + ) try { + ur_result_t result = UR_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnAdapterRetain = d_context.urDdiTable.Global.pfnAdapterRetain; + if (nullptr != pfnAdapterRetain) { + result = pfnAdapterRetain(hAdapter); + } else { + // generic implementation + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterGetLastError +__urdlllocal ur_result_t UR_APICALL urAdapterGetLastError( + ur_adapter_handle_t hAdapter, ///< [in] handle of the adapter instance + const char ** + ppMessage, ///< [out] pointer to a C string where the adapter specific error message + ///< will be stored. + int32_t * + pError ///< [out] pointer to an integer where the adapter specific error code will + ///< be stored. + ) try { + ur_result_t result = UR_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnAdapterGetLastError = + d_context.urDdiTable.Global.pfnAdapterGetLastError; + if (nullptr != pfnAdapterGetLastError) { + result = pfnAdapterGetLastError(hAdapter, ppMessage, pError); + } else { + // generic implementation + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterGetInfo +__urdlllocal ur_result_t UR_APICALL urAdapterGetInfo( + ur_adapter_handle_t hAdapter, ///< [in] handle of the adapter + ur_adapter_info_t propName, ///< [in] type of the info to retrieve + size_t propSize, ///< [in] the number of bytes pointed to by pPropValue. + void * + pPropValue, ///< [out][optional][typename(propName, propSize)] array of bytes holding + ///< the info. + ///< If Size is not equal to or greater to the real number of bytes needed + ///< to return the info then the ::UR_RESULT_ERROR_INVALID_SIZE error is + ///< returned and pPropValue is not used. + size_t * + pPropSizeRet ///< [out][optional] pointer to the actual number of bytes being queried by pPropValue. + ) try { + ur_result_t result = UR_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnAdapterGetInfo = d_context.urDdiTable.Global.pfnAdapterGetInfo; + if (nullptr != pfnAdapterGetInfo) { + result = pfnAdapterGetInfo(hAdapter, propName, propSize, pPropValue, + pPropSizeRet); + } else { + // generic implementation + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urPlatformGet __urdlllocal ur_result_t UR_APICALL urPlatformGet( + ur_adapter_handle_t * + phAdapters, ///< [in][range(0, NumAdapters)] array of adapters to query for platforms. + uint32_t NumAdapters, ///< [in] number of adapters pointed to by phAdapters uint32_t NumEntries, ///< [in] the number of platforms to be added to phPlatforms. ///< If phPlatforms is not NULL, then NumEntries should be greater than @@ -75,7 +210,8 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGet( // if the driver has created a custom function, then call it instead of using the generic path auto pfnGet = d_context.urDdiTable.Platform.pfnGet; if (nullptr != pfnGet) { - result = pfnGet(NumEntries, phPlatforms, pNumPlatforms); + result = pfnGet(phAdapters, NumAdapters, NumEntries, phPlatforms, + pNumPlatforms); } else { // generic implementation for (size_t i = 0; (nullptr != phPlatforms) && (i < NumEntries); ++i) { @@ -220,32 +356,6 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetBackendOption( return exceptionToResult(std::current_exception()); } -/////////////////////////////////////////////////////////////////////////////// -/// @brief Intercept function for urPlatformGetLastError -__urdlllocal ur_result_t UR_APICALL urPlatformGetLastError( - ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance - const char ** - ppMessage, ///< [out] pointer to a C string where the adapter specific error message - ///< will be stored. - int32_t * - pError ///< [out] pointer to an integer where the adapter specific error code will - ///< be stored. - ) try { - ur_result_t result = UR_RESULT_SUCCESS; - - // if the driver has created a custom function, then call it instead of using the generic path - auto pfnGetLastError = d_context.urDdiTable.Platform.pfnGetLastError; - if (nullptr != pfnGetLastError) { - result = pfnGetLastError(hPlatform, ppMessage, pError); - } else { - // generic implementation - } - - return result; -} catch (...) { - return exceptionToResult(std::current_exception()); -} - /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urDeviceGet __urdlllocal ur_result_t UR_APICALL urDeviceGet( @@ -4946,6 +5056,16 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetGlobalProcAddrTable( pDdiTable->pfnTearDown = driver::urTearDown; + pDdiTable->pfnAdapterGet = driver::urAdapterGet; + + pDdiTable->pfnAdapterRelease = driver::urAdapterRelease; + + pDdiTable->pfnAdapterRetain = driver::urAdapterRetain; + + pDdiTable->pfnAdapterGetLastError = driver::urAdapterGetLastError; + + pDdiTable->pfnAdapterGetInfo = driver::urAdapterGetInfo; + return result; } catch (...) { return exceptionToResult(std::current_exception()); @@ -5429,8 +5549,6 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetPlatformProcAddrTable( pDdiTable->pfnCreateWithNativeHandle = driver::urPlatformCreateWithNativeHandle; - pDdiTable->pfnGetLastError = driver::urPlatformGetLastError; - pDdiTable->pfnGetApiVersion = driver::urPlatformGetApiVersion; pDdiTable->pfnGetBackendOption = driver::urPlatformGetBackendOption; diff --git a/source/common/ur_params.hpp b/source/common/ur_params.hpp index d84bc617fa..8278d36e04 100644 --- a/source/common/ur_params.hpp +++ b/source/common/ur_params.hpp @@ -30,6 +30,10 @@ template <> inline void serializeFlag(std::ostream &os, uint32_t flag); +template <> +inline void serializeTagged(std::ostream &os, const void *ptr, + ur_adapter_info_t value, size_t size); + template <> inline void serializeTagged(std::ostream &os, const void *ptr, ur_platform_info_t value, size_t size); @@ -203,6 +207,9 @@ inline std::ostream &operator<<(std::ostream &os, const struct ur_rect_region_t params); inline std::ostream &operator<<(std::ostream &os, enum ur_device_init_flag_t value); +inline std::ostream &operator<<(std::ostream &os, enum ur_adapter_info_t value); +inline std::ostream &operator<<(std::ostream &os, + enum ur_adapter_backend_t value); inline std::ostream &operator<<(std::ostream &os, enum ur_platform_info_t value); inline std::ostream &operator<<(std::ostream &os, enum ur_api_version_t value); @@ -982,10 +989,6 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_function_t value) { os << "UR_FUNCTION_BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP"; break; - case UR_FUNCTION_PLATFORM_GET_LAST_ERROR: - os << "UR_FUNCTION_PLATFORM_GET_LAST_ERROR"; - break; - case UR_FUNCTION_ENQUEUE_USM_FILL_2D: os << "UR_FUNCTION_ENQUEUE_USM_FILL_2D"; break; @@ -1089,6 +1092,26 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_function_t value) { case UR_FUNCTION_LOADER_CONFIG_ENABLE_LAYER: os << "UR_FUNCTION_LOADER_CONFIG_ENABLE_LAYER"; break; + + case UR_FUNCTION_ADAPTER_RELEASE: + os << "UR_FUNCTION_ADAPTER_RELEASE"; + break; + + case UR_FUNCTION_ADAPTER_GET: + os << "UR_FUNCTION_ADAPTER_GET"; + break; + + case UR_FUNCTION_ADAPTER_RETAIN: + os << "UR_FUNCTION_ADAPTER_RETAIN"; + break; + + case UR_FUNCTION_ADAPTER_GET_LAST_ERROR: + os << "UR_FUNCTION_ADAPTER_GET_LAST_ERROR"; + break; + + case UR_FUNCTION_ADAPTER_GET_INFO: + os << "UR_FUNCTION_ADAPTER_GET_INFO"; + break; default: os << "unknown enumerator"; break; @@ -1983,6 +2006,100 @@ inline void serializeFlag(std::ostream &os, } } } // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, + enum ur_adapter_info_t value) { + switch (value) { + + case UR_ADAPTER_INFO_BACKEND: + os << "UR_ADAPTER_INFO_BACKEND"; + break; + + case UR_ADAPTER_INFO_REFERENCE_COUNT: + os << "UR_ADAPTER_INFO_REFERENCE_COUNT"; + break; + default: + os << "unknown enumerator"; + break; + } + return os; +} +namespace ur_params { +template <> +inline void serializeTagged(std::ostream &os, const void *ptr, + ur_adapter_info_t value, size_t size) { + if (ptr == NULL) { + serializePtr(os, ptr); + return; + } + + switch (value) { + + case UR_ADAPTER_INFO_BACKEND: { + const ur_adapter_backend_t *tptr = (const ur_adapter_backend_t *)ptr; + if (sizeof(ur_adapter_backend_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_adapter_backend_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_ADAPTER_INFO_REFERENCE_COUNT: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + default: + os << "unknown enumerator"; + break; + } +} +} // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, + enum ur_adapter_backend_t value) { + switch (value) { + + case UR_ADAPTER_BACKEND_UNKNOWN: + os << "UR_ADAPTER_BACKEND_UNKNOWN"; + break; + + case UR_ADAPTER_BACKEND_LEVEL_ZERO: + os << "UR_ADAPTER_BACKEND_LEVEL_ZERO"; + break; + + case UR_ADAPTER_BACKEND_OPENCL: + os << "UR_ADAPTER_BACKEND_OPENCL"; + break; + + case UR_ADAPTER_BACKEND_CUDA: + os << "UR_ADAPTER_BACKEND_CUDA"; + break; + + case UR_ADAPTER_BACKEND_HIP: + os << "UR_ADAPTER_BACKEND_HIP"; + break; + + case UR_ADAPTER_BACKEND_NATIVE_CPU: + os << "UR_ADAPTER_BACKEND_NATIVE_CPU"; + break; + default: + os << "unknown enumerator"; + break; + } + return os; +} inline std::ostream &operator<<(std::ostream &os, enum ur_platform_info_t value) { switch (value) { @@ -9751,6 +9868,105 @@ inline std::ostream &operator<<(std::ostream &os, return os; } +inline std::ostream &operator<<(std::ostream &os, + const struct ur_adapter_get_params_t *params) { + + os << ".NumEntries = "; + + os << *(params->pNumEntries); + + os << ", "; + os << ".phAdapters = {"; + for (size_t i = 0; + *(params->pphAdapters) != NULL && i < *params->pNumEntries; ++i) { + if (i != 0) { + os << ", "; + } + + ur_params::serializePtr(os, (*(params->pphAdapters))[i]); + } + os << "}"; + + os << ", "; + os << ".pNumAdapters = "; + + ur_params::serializePtr(os, *(params->ppNumAdapters)); + + return os; +} + +inline std::ostream & +operator<<(std::ostream &os, const struct ur_adapter_release_params_t *params) { + + os << ".hAdapter = "; + + ur_params::serializePtr(os, *(params->phAdapter)); + + return os; +} + +inline std::ostream & +operator<<(std::ostream &os, const struct ur_adapter_retain_params_t *params) { + + os << ".hAdapter = "; + + ur_params::serializePtr(os, *(params->phAdapter)); + + return os; +} + +inline std::ostream & +operator<<(std::ostream &os, + const struct ur_adapter_get_last_error_params_t *params) { + + os << ".hAdapter = "; + + ur_params::serializePtr(os, *(params->phAdapter)); + + os << ", "; + os << ".ppMessage = "; + + ur_params::serializePtr(os, *(params->pppMessage)); + + os << ", "; + os << ".pError = "; + + ur_params::serializePtr(os, *(params->ppError)); + + return os; +} + +inline std::ostream & +operator<<(std::ostream &os, + const struct ur_adapter_get_info_params_t *params) { + + os << ".hAdapter = "; + + ur_params::serializePtr(os, *(params->phAdapter)); + + os << ", "; + os << ".propName = "; + + os << *(params->ppropName); + + os << ", "; + os << ".propSize = "; + + os << *(params->ppropSize); + + os << ", "; + os << ".pPropValue = "; + ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), + *(params->ppropSize)); + + os << ", "; + os << ".pPropSizeRet = "; + + ur_params::serializePtr(os, *(params->ppPropSizeRet)); + + return os; +} + inline std::ostream &operator<<( std::ostream &os, const struct ur_bindless_images_unsampled_image_handle_destroy_exp_params_t @@ -13360,6 +13576,23 @@ operator<<(std::ostream &os, inline std::ostream &operator<<(std::ostream &os, const struct ur_platform_get_params_t *params) { + os << ".phAdapters = {"; + for (size_t i = 0; + *(params->pphAdapters) != NULL && i < *params->pNumAdapters; ++i) { + if (i != 0) { + os << ", "; + } + + ur_params::serializePtr(os, (*(params->pphAdapters))[i]); + } + os << "}"; + + os << ", "; + os << ".NumAdapters = "; + + os << *(params->pNumAdapters); + + os << ", "; os << ".NumEntries = "; os << *(params->pNumEntries); @@ -13452,27 +13685,6 @@ inline std::ostream &operator<<( return os; } -inline std::ostream & -operator<<(std::ostream &os, - const struct ur_platform_get_last_error_params_t *params) { - - os << ".hPlatform = "; - - ur_params::serializePtr(os, *(params->phPlatform)); - - os << ", "; - os << ".ppMessage = "; - - ur_params::serializePtr(os, *(params->pppMessage)); - - os << ", "; - os << ".pError = "; - - ur_params::serializePtr(os, *(params->ppError)); - - return os; -} - inline std::ostream & operator<<(std::ostream &os, const struct ur_platform_get_api_version_params_t *params) { @@ -14933,6 +15145,21 @@ inline int serializeFunctionParams(std::ostream &os, uint32_t function, case UR_FUNCTION_TEAR_DOWN: { os << (const struct ur_tear_down_params_t *)params; } break; + case UR_FUNCTION_ADAPTER_GET: { + os << (const struct ur_adapter_get_params_t *)params; + } break; + case UR_FUNCTION_ADAPTER_RELEASE: { + os << (const struct ur_adapter_release_params_t *)params; + } break; + case UR_FUNCTION_ADAPTER_RETAIN: { + os << (const struct ur_adapter_retain_params_t *)params; + } break; + case UR_FUNCTION_ADAPTER_GET_LAST_ERROR: { + os << (const struct ur_adapter_get_last_error_params_t *)params; + } break; + case UR_FUNCTION_ADAPTER_GET_INFO: { + os << (const struct ur_adapter_get_info_params_t *)params; + } break; case UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_HANDLE_DESTROY_EXP: { os << (const struct ur_bindless_images_unsampled_image_handle_destroy_exp_params_t *) @@ -15280,9 +15507,6 @@ inline int serializeFunctionParams(std::ostream &os, uint32_t function, os << (const struct ur_platform_create_with_native_handle_params_t *) params; } break; - case UR_FUNCTION_PLATFORM_GET_LAST_ERROR: { - os << (const struct ur_platform_get_last_error_params_t *)params; - } break; case UR_FUNCTION_PLATFORM_GET_API_VERSION: { os << (const struct ur_platform_get_api_version_params_t *)params; } break; diff --git a/source/loader/layers/tracing/ur_trcddi.cpp b/source/loader/layers/tracing/ur_trcddi.cpp index bc0c0e8ea0..f30fac3807 100644 --- a/source/loader/layers/tracing/ur_trcddi.cpp +++ b/source/loader/layers/tracing/ur_trcddi.cpp @@ -63,9 +63,157 @@ __urdlllocal ur_result_t UR_APICALL urTearDown( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterGet +__urdlllocal ur_result_t UR_APICALL urAdapterGet( + uint32_t + NumEntries, ///< [in] the number of adapters to be added to phAdapters. + ///< If phAdapters is not NULL, then NumEntries should be greater than + ///< zero, otherwise ::UR_RESULT_ERROR_INVALID_SIZE, + ///< will be returned. + ur_adapter_handle_t * + phAdapters, ///< [out][optional][range(0, NumEntries)] array of handle of adapters. + ///< If NumEntries is less than the number of adapters available, then + ///< ::urAdapterGet shall only retrieve that number of platforms. + uint32_t * + pNumAdapters ///< [out][optional] returns the total number of adapters available. +) { + auto pfnAdapterGet = context.urDdiTable.Global.pfnAdapterGet; + + if (nullptr == pfnAdapterGet) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + ur_adapter_get_params_t params = {&NumEntries, &phAdapters, &pNumAdapters}; + uint64_t instance = + context.notify_begin(UR_FUNCTION_ADAPTER_GET, "urAdapterGet", ¶ms); + + ur_result_t result = pfnAdapterGet(NumEntries, phAdapters, pNumAdapters); + + context.notify_end(UR_FUNCTION_ADAPTER_GET, "urAdapterGet", ¶ms, + &result, instance); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterRelease +__urdlllocal ur_result_t UR_APICALL urAdapterRelease( + ur_adapter_handle_t hAdapter ///< [in] Adapter handle to release +) { + auto pfnAdapterRelease = context.urDdiTable.Global.pfnAdapterRelease; + + if (nullptr == pfnAdapterRelease) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + ur_adapter_release_params_t params = {&hAdapter}; + uint64_t instance = context.notify_begin(UR_FUNCTION_ADAPTER_RELEASE, + "urAdapterRelease", ¶ms); + + ur_result_t result = pfnAdapterRelease(hAdapter); + + context.notify_end(UR_FUNCTION_ADAPTER_RELEASE, "urAdapterRelease", ¶ms, + &result, instance); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterRetain +__urdlllocal ur_result_t UR_APICALL urAdapterRetain( + ur_adapter_handle_t hAdapter ///< [in] Adapter handle to retain +) { + auto pfnAdapterRetain = context.urDdiTable.Global.pfnAdapterRetain; + + if (nullptr == pfnAdapterRetain) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + ur_adapter_retain_params_t params = {&hAdapter}; + uint64_t instance = context.notify_begin(UR_FUNCTION_ADAPTER_RETAIN, + "urAdapterRetain", ¶ms); + + ur_result_t result = pfnAdapterRetain(hAdapter); + + context.notify_end(UR_FUNCTION_ADAPTER_RETAIN, "urAdapterRetain", ¶ms, + &result, instance); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterGetLastError +__urdlllocal ur_result_t UR_APICALL urAdapterGetLastError( + ur_adapter_handle_t hAdapter, ///< [in] handle of the adapter instance + const char ** + ppMessage, ///< [out] pointer to a C string where the adapter specific error message + ///< will be stored. + int32_t * + pError ///< [out] pointer to an integer where the adapter specific error code will + ///< be stored. +) { + auto pfnAdapterGetLastError = + context.urDdiTable.Global.pfnAdapterGetLastError; + + if (nullptr == pfnAdapterGetLastError) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + ur_adapter_get_last_error_params_t params = {&hAdapter, &ppMessage, + &pError}; + uint64_t instance = context.notify_begin(UR_FUNCTION_ADAPTER_GET_LAST_ERROR, + "urAdapterGetLastError", ¶ms); + + ur_result_t result = pfnAdapterGetLastError(hAdapter, ppMessage, pError); + + context.notify_end(UR_FUNCTION_ADAPTER_GET_LAST_ERROR, + "urAdapterGetLastError", ¶ms, &result, instance); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterGetInfo +__urdlllocal ur_result_t UR_APICALL urAdapterGetInfo( + ur_adapter_handle_t hAdapter, ///< [in] handle of the adapter + ur_adapter_info_t propName, ///< [in] type of the info to retrieve + size_t propSize, ///< [in] the number of bytes pointed to by pPropValue. + void * + pPropValue, ///< [out][optional][typename(propName, propSize)] array of bytes holding + ///< the info. + ///< If Size is not equal to or greater to the real number of bytes needed + ///< to return the info then the ::UR_RESULT_ERROR_INVALID_SIZE error is + ///< returned and pPropValue is not used. + size_t * + pPropSizeRet ///< [out][optional] pointer to the actual number of bytes being queried by pPropValue. +) { + auto pfnAdapterGetInfo = context.urDdiTable.Global.pfnAdapterGetInfo; + + if (nullptr == pfnAdapterGetInfo) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + ur_adapter_get_info_params_t params = {&hAdapter, &propName, &propSize, + &pPropValue, &pPropSizeRet}; + uint64_t instance = context.notify_begin(UR_FUNCTION_ADAPTER_GET_INFO, + "urAdapterGetInfo", ¶ms); + + ur_result_t result = pfnAdapterGetInfo(hAdapter, propName, propSize, + pPropValue, pPropSizeRet); + + context.notify_end(UR_FUNCTION_ADAPTER_GET_INFO, "urAdapterGetInfo", + ¶ms, &result, instance); + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urPlatformGet __urdlllocal ur_result_t UR_APICALL urPlatformGet( + ur_adapter_handle_t * + phAdapters, ///< [in][range(0, NumAdapters)] array of adapters to query for platforms. + uint32_t NumAdapters, ///< [in] number of adapters pointed to by phAdapters uint32_t NumEntries, ///< [in] the number of platforms to be added to phPlatforms. ///< If phPlatforms is not NULL, then NumEntries should be greater than @@ -84,12 +232,13 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGet( return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - ur_platform_get_params_t params = {&NumEntries, &phPlatforms, - &pNumPlatforms}; + ur_platform_get_params_t params = {&phAdapters, &NumAdapters, &NumEntries, + &phPlatforms, &pNumPlatforms}; uint64_t instance = context.notify_begin(UR_FUNCTION_PLATFORM_GET, "urPlatformGet", ¶ms); - ur_result_t result = pfnGet(NumEntries, phPlatforms, pNumPlatforms); + ur_result_t result = + pfnGet(phAdapters, NumAdapters, NumEntries, phPlatforms, pNumPlatforms); context.notify_end(UR_FUNCTION_PLATFORM_GET, "urPlatformGet", ¶ms, &result, instance); @@ -249,36 +398,6 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetBackendOption( return result; } -/////////////////////////////////////////////////////////////////////////////// -/// @brief Intercept function for urPlatformGetLastError -__urdlllocal ur_result_t UR_APICALL urPlatformGetLastError( - ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance - const char ** - ppMessage, ///< [out] pointer to a C string where the adapter specific error message - ///< will be stored. - int32_t * - pError ///< [out] pointer to an integer where the adapter specific error code will - ///< be stored. -) { - auto pfnGetLastError = context.urDdiTable.Platform.pfnGetLastError; - - if (nullptr == pfnGetLastError) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; - } - - ur_platform_get_last_error_params_t params = {&hPlatform, &ppMessage, - &pError}; - uint64_t instance = context.notify_begin( - UR_FUNCTION_PLATFORM_GET_LAST_ERROR, "urPlatformGetLastError", ¶ms); - - ur_result_t result = pfnGetLastError(hPlatform, ppMessage, pError); - - context.notify_end(UR_FUNCTION_PLATFORM_GET_LAST_ERROR, - "urPlatformGetLastError", ¶ms, &result, instance); - - return result; -} - /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urDeviceGet __urdlllocal ur_result_t UR_APICALL urDeviceGet( @@ -5715,6 +5834,21 @@ __urdlllocal ur_result_t UR_APICALL urGetGlobalProcAddrTable( dditable.pfnTearDown = pDdiTable->pfnTearDown; pDdiTable->pfnTearDown = ur_tracing_layer::urTearDown; + dditable.pfnAdapterGet = pDdiTable->pfnAdapterGet; + pDdiTable->pfnAdapterGet = ur_tracing_layer::urAdapterGet; + + dditable.pfnAdapterRelease = pDdiTable->pfnAdapterRelease; + pDdiTable->pfnAdapterRelease = ur_tracing_layer::urAdapterRelease; + + dditable.pfnAdapterRetain = pDdiTable->pfnAdapterRetain; + pDdiTable->pfnAdapterRetain = ur_tracing_layer::urAdapterRetain; + + dditable.pfnAdapterGetLastError = pDdiTable->pfnAdapterGetLastError; + pDdiTable->pfnAdapterGetLastError = ur_tracing_layer::urAdapterGetLastError; + + dditable.pfnAdapterGetInfo = pDdiTable->pfnAdapterGetInfo; + pDdiTable->pfnAdapterGetInfo = ur_tracing_layer::urAdapterGetInfo; + return result; } /////////////////////////////////////////////////////////////////////////////// @@ -6342,9 +6476,6 @@ __urdlllocal ur_result_t UR_APICALL urGetPlatformProcAddrTable( pDdiTable->pfnCreateWithNativeHandle = ur_tracing_layer::urPlatformCreateWithNativeHandle; - dditable.pfnGetLastError = pDdiTable->pfnGetLastError; - pDdiTable->pfnGetLastError = ur_tracing_layer::urPlatformGetLastError; - dditable.pfnGetApiVersion = pDdiTable->pfnGetApiVersion; pDdiTable->pfnGetApiVersion = ur_tracing_layer::urPlatformGetApiVersion; diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index 34440491f1..ce88ab6cb1 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -66,9 +66,179 @@ __urdlllocal ur_result_t UR_APICALL urTearDown( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterGet +__urdlllocal ur_result_t UR_APICALL urAdapterGet( + uint32_t + NumEntries, ///< [in] the number of adapters to be added to phAdapters. + ///< If phAdapters is not NULL, then NumEntries should be greater than + ///< zero, otherwise ::UR_RESULT_ERROR_INVALID_SIZE, + ///< will be returned. + ur_adapter_handle_t * + phAdapters, ///< [out][optional][range(0, NumEntries)] array of handle of adapters. + ///< If NumEntries is less than the number of adapters available, then + ///< ::urAdapterGet shall only retrieve that number of platforms. + uint32_t * + pNumAdapters ///< [out][optional] returns the total number of adapters available. +) { + auto pfnAdapterGet = context.urDdiTable.Global.pfnAdapterGet; + + if (nullptr == pfnAdapterGet) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + if (context.enableParameterValidation) { + } + + ur_result_t result = pfnAdapterGet(NumEntries, phAdapters, pNumAdapters); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterRelease +__urdlllocal ur_result_t UR_APICALL urAdapterRelease( + ur_adapter_handle_t hAdapter ///< [in] Adapter handle to release +) { + auto pfnAdapterRelease = context.urDdiTable.Global.pfnAdapterRelease; + + if (nullptr == pfnAdapterRelease) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + if (context.enableParameterValidation) { + if (NULL == hAdapter) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + } + + ur_result_t result = pfnAdapterRelease(hAdapter); + + if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + refCountContext.decrementRefCount(hAdapter); + } + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterRetain +__urdlllocal ur_result_t UR_APICALL urAdapterRetain( + ur_adapter_handle_t hAdapter ///< [in] Adapter handle to retain +) { + auto pfnAdapterRetain = context.urDdiTable.Global.pfnAdapterRetain; + + if (nullptr == pfnAdapterRetain) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + if (context.enableParameterValidation) { + if (NULL == hAdapter) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + } + + ur_result_t result = pfnAdapterRetain(hAdapter); + + if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + refCountContext.incrementRefCount(hAdapter); + } + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterGetLastError +__urdlllocal ur_result_t UR_APICALL urAdapterGetLastError( + ur_adapter_handle_t hAdapter, ///< [in] handle of the adapter instance + const char ** + ppMessage, ///< [out] pointer to a C string where the adapter specific error message + ///< will be stored. + int32_t * + pError ///< [out] pointer to an integer where the adapter specific error code will + ///< be stored. +) { + auto pfnAdapterGetLastError = + context.urDdiTable.Global.pfnAdapterGetLastError; + + if (nullptr == pfnAdapterGetLastError) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + if (context.enableParameterValidation) { + if (NULL == hAdapter) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + + if (NULL == ppMessage) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + + if (NULL == pError) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + } + + ur_result_t result = pfnAdapterGetLastError(hAdapter, ppMessage, pError); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterGetInfo +__urdlllocal ur_result_t UR_APICALL urAdapterGetInfo( + ur_adapter_handle_t hAdapter, ///< [in] handle of the adapter + ur_adapter_info_t propName, ///< [in] type of the info to retrieve + size_t propSize, ///< [in] the number of bytes pointed to by pPropValue. + void * + pPropValue, ///< [out][optional][typename(propName, propSize)] array of bytes holding + ///< the info. + ///< If Size is not equal to or greater to the real number of bytes needed + ///< to return the info then the ::UR_RESULT_ERROR_INVALID_SIZE error is + ///< returned and pPropValue is not used. + size_t * + pPropSizeRet ///< [out][optional] pointer to the actual number of bytes being queried by pPropValue. +) { + auto pfnAdapterGetInfo = context.urDdiTable.Global.pfnAdapterGetInfo; + + if (nullptr == pfnAdapterGetInfo) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + if (context.enableParameterValidation) { + if (NULL == hAdapter) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + + if (propSize != 0 && pPropValue == NULL) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + + if (pPropValue == NULL && pPropSizeRet == NULL) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + + if (UR_ADAPTER_INFO_REFERENCE_COUNT < propName) { + return UR_RESULT_ERROR_INVALID_ENUMERATION; + } + + if (propSize == 0 && pPropValue != NULL) { + return UR_RESULT_ERROR_INVALID_SIZE; + } + } + + ur_result_t result = pfnAdapterGetInfo(hAdapter, propName, propSize, + pPropValue, pPropSizeRet); + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urPlatformGet __urdlllocal ur_result_t UR_APICALL urPlatformGet( + ur_adapter_handle_t * + phAdapters, ///< [in][range(0, NumAdapters)] array of adapters to query for platforms. + uint32_t NumAdapters, ///< [in] number of adapters pointed to by phAdapters uint32_t NumEntries, ///< [in] the number of platforms to be added to phPlatforms. ///< If phPlatforms is not NULL, then NumEntries should be greater than @@ -88,9 +258,13 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGet( } if (context.enableParameterValidation) { + if (NULL == phAdapters) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } } - ur_result_t result = pfnGet(NumEntries, phPlatforms, pNumPlatforms); + ur_result_t result = + pfnGet(phAdapters, NumAdapters, NumEntries, phPlatforms, pNumPlatforms); return result; } @@ -264,42 +438,6 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetBackendOption( return result; } -/////////////////////////////////////////////////////////////////////////////// -/// @brief Intercept function for urPlatformGetLastError -__urdlllocal ur_result_t UR_APICALL urPlatformGetLastError( - ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance - const char ** - ppMessage, ///< [out] pointer to a C string where the adapter specific error message - ///< will be stored. - int32_t * - pError ///< [out] pointer to an integer where the adapter specific error code will - ///< be stored. -) { - auto pfnGetLastError = context.urDdiTable.Platform.pfnGetLastError; - - if (nullptr == pfnGetLastError) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; - } - - if (context.enableParameterValidation) { - if (NULL == hPlatform) { - return UR_RESULT_ERROR_INVALID_NULL_HANDLE; - } - - if (NULL == ppMessage) { - return UR_RESULT_ERROR_INVALID_NULL_POINTER; - } - - if (NULL == pError) { - return UR_RESULT_ERROR_INVALID_NULL_POINTER; - } - } - - ur_result_t result = pfnGetLastError(hPlatform, ppMessage, pError); - - return result; -} - /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urDeviceGet __urdlllocal ur_result_t UR_APICALL urDeviceGet( @@ -7051,6 +7189,22 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetGlobalProcAddrTable( dditable.pfnTearDown = pDdiTable->pfnTearDown; pDdiTable->pfnTearDown = ur_validation_layer::urTearDown; + dditable.pfnAdapterGet = pDdiTable->pfnAdapterGet; + pDdiTable->pfnAdapterGet = ur_validation_layer::urAdapterGet; + + dditable.pfnAdapterRelease = pDdiTable->pfnAdapterRelease; + pDdiTable->pfnAdapterRelease = ur_validation_layer::urAdapterRelease; + + dditable.pfnAdapterRetain = pDdiTable->pfnAdapterRetain; + pDdiTable->pfnAdapterRetain = ur_validation_layer::urAdapterRetain; + + dditable.pfnAdapterGetLastError = pDdiTable->pfnAdapterGetLastError; + pDdiTable->pfnAdapterGetLastError = + ur_validation_layer::urAdapterGetLastError; + + dditable.pfnAdapterGetInfo = pDdiTable->pfnAdapterGetInfo; + pDdiTable->pfnAdapterGetInfo = ur_validation_layer::urAdapterGetInfo; + return result; } @@ -7694,9 +7848,6 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetPlatformProcAddrTable( pDdiTable->pfnCreateWithNativeHandle = ur_validation_layer::urPlatformCreateWithNativeHandle; - dditable.pfnGetLastError = pDdiTable->pfnGetLastError; - pDdiTable->pfnGetLastError = ur_validation_layer::urPlatformGetLastError; - dditable.pfnGetApiVersion = pDdiTable->pfnGetApiVersion; pDdiTable->pfnGetApiVersion = ur_validation_layer::urPlatformGetApiVersion; diff --git a/source/loader/ur_ldrddi.cpp b/source/loader/ur_ldrddi.cpp index ebdd60c739..e192088bbc 100644 --- a/source/loader/ur_ldrddi.cpp +++ b/source/loader/ur_ldrddi.cpp @@ -14,6 +14,7 @@ namespace ur_loader { /////////////////////////////////////////////////////////////////////////////// +ur_adapter_factory_t ur_adapter_factory; ur_platform_factory_t ur_platform_factory; ur_device_factory_t ur_device_factory; ur_context_factory_t ur_context_factory; @@ -67,9 +68,163 @@ __urdlllocal ur_result_t UR_APICALL urTearDown( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterGet +__urdlllocal ur_result_t UR_APICALL urAdapterGet( + uint32_t + NumEntries, ///< [in] the number of adapters to be added to phAdapters. + ///< If phAdapters is not NULL, then NumEntries should be greater than + ///< zero, otherwise ::UR_RESULT_ERROR_INVALID_SIZE, + ///< will be returned. + ur_adapter_handle_t * + phAdapters, ///< [out][optional][range(0, NumEntries)] array of handle of adapters. + ///< If NumEntries is less than the number of adapters available, then + ///< ::urAdapterGet shall only retrieve that number of platforms. + uint32_t * + pNumAdapters ///< [out][optional] returns the total number of adapters available. +) { + ur_result_t result = UR_RESULT_SUCCESS; + + size_t adapterIndex = 0; + if (nullptr != phAdapters && NumEntries != 0) { + for (auto &platform : context->platforms) { + platform.dditable.ur.Global.pfnAdapterGet( + 1, &phAdapters[adapterIndex], nullptr); + try { + phAdapters[adapterIndex] = + reinterpret_cast( + ur_adapter_factory.getInstance(phAdapters[adapterIndex], + &platform.dditable)); + } catch (std::bad_alloc &) { + result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY; + break; + } + adapterIndex++; + } + } + + if (pNumAdapters != nullptr) { + *pNumAdapters = static_cast(context->platforms.size()); + } + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterRelease +__urdlllocal ur_result_t UR_APICALL urAdapterRelease( + ur_adapter_handle_t hAdapter ///< [in] Adapter handle to release +) { + ur_result_t result = UR_RESULT_SUCCESS; + + // extract platform's function pointer table + auto dditable = reinterpret_cast(hAdapter)->dditable; + auto pfnAdapterRelease = dditable->ur.Global.pfnAdapterRelease; + if (nullptr == pfnAdapterRelease) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + // convert loader handle to platform handle + hAdapter = reinterpret_cast(hAdapter)->handle; + + // forward to device-platform + result = pfnAdapterRelease(hAdapter); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterRetain +__urdlllocal ur_result_t UR_APICALL urAdapterRetain( + ur_adapter_handle_t hAdapter ///< [in] Adapter handle to retain +) { + ur_result_t result = UR_RESULT_SUCCESS; + + // extract platform's function pointer table + auto dditable = reinterpret_cast(hAdapter)->dditable; + auto pfnAdapterRetain = dditable->ur.Global.pfnAdapterRetain; + if (nullptr == pfnAdapterRetain) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + // convert loader handle to platform handle + hAdapter = reinterpret_cast(hAdapter)->handle; + + // forward to device-platform + result = pfnAdapterRetain(hAdapter); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterGetLastError +__urdlllocal ur_result_t UR_APICALL urAdapterGetLastError( + ur_adapter_handle_t hAdapter, ///< [in] handle of the adapter instance + const char ** + ppMessage, ///< [out] pointer to a C string where the adapter specific error message + ///< will be stored. + int32_t * + pError ///< [out] pointer to an integer where the adapter specific error code will + ///< be stored. +) { + ur_result_t result = UR_RESULT_SUCCESS; + + // extract platform's function pointer table + auto dditable = reinterpret_cast(hAdapter)->dditable; + auto pfnAdapterGetLastError = dditable->ur.Global.pfnAdapterGetLastError; + if (nullptr == pfnAdapterGetLastError) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + // convert loader handle to platform handle + hAdapter = reinterpret_cast(hAdapter)->handle; + + // forward to device-platform + result = pfnAdapterGetLastError(hAdapter, ppMessage, pError); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterGetInfo +__urdlllocal ur_result_t UR_APICALL urAdapterGetInfo( + ur_adapter_handle_t hAdapter, ///< [in] handle of the adapter + ur_adapter_info_t propName, ///< [in] type of the info to retrieve + size_t propSize, ///< [in] the number of bytes pointed to by pPropValue. + void * + pPropValue, ///< [out][optional][typename(propName, propSize)] array of bytes holding + ///< the info. + ///< If Size is not equal to or greater to the real number of bytes needed + ///< to return the info then the ::UR_RESULT_ERROR_INVALID_SIZE error is + ///< returned and pPropValue is not used. + size_t * + pPropSizeRet ///< [out][optional] pointer to the actual number of bytes being queried by pPropValue. +) { + ur_result_t result = UR_RESULT_SUCCESS; + + // extract platform's function pointer table + auto dditable = reinterpret_cast(hAdapter)->dditable; + auto pfnAdapterGetInfo = dditable->ur.Global.pfnAdapterGetInfo; + if (nullptr == pfnAdapterGetInfo) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + // convert loader handle to platform handle + hAdapter = reinterpret_cast(hAdapter)->handle; + + // forward to device-platform + result = pfnAdapterGetInfo(hAdapter, propName, propSize, pPropValue, + pPropSizeRet); + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urPlatformGet __urdlllocal ur_result_t UR_APICALL urPlatformGet( + ur_adapter_handle_t * + phAdapters, ///< [in][range(0, NumAdapters)] array of adapters to query for platforms. + uint32_t NumAdapters, ///< [in] number of adapters pointed to by phAdapters uint32_t NumEntries, ///< [in] the number of platforms to be added to phPlatforms. ///< If phPlatforms is not NULL, then NumEntries should be greater than @@ -86,10 +241,12 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGet( uint32_t total_platform_handle_count = 0; - for (auto &platform : context->platforms) { - if (platform.initStatus != UR_RESULT_SUCCESS) { - continue; - } + for (uint32_t adapter_index = 0; adapter_index < NumAdapters; + adapter_index++) { + // extract adapter's function pointer table + auto dditable = + reinterpret_cast(phAdapters[adapter_index]) + ->dditable; if ((0 < NumEntries) && (NumEntries == total_platform_handle_count)) { break; @@ -97,8 +254,9 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGet( uint32_t library_platform_handle_count = 0; - result = platform.dditable.ur.Platform.pfnGet( - 0, nullptr, &library_platform_handle_count); + result = dditable->ur.Platform.pfnGet(&phAdapters[adapter_index], 1, 0, + nullptr, + &library_platform_handle_count); if (UR_RESULT_SUCCESS != result) { break; } @@ -109,8 +267,8 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGet( library_platform_handle_count = NumEntries - total_platform_handle_count; } - result = platform.dditable.ur.Platform.pfnGet( - library_platform_handle_count, + result = dditable->ur.Platform.pfnGet( + &phAdapters[adapter_index], 1, library_platform_handle_count, &phPlatforms[total_platform_handle_count], nullptr); if (UR_RESULT_SUCCESS != result) { break; @@ -122,8 +280,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGet( phPlatforms[platform_index] = reinterpret_cast( ur_platform_factory.getInstance( - phPlatforms[platform_index], - &platform.dditable)); + phPlatforms[platform_index], dditable)); } } catch (std::bad_alloc &) { result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY; @@ -311,36 +468,6 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetBackendOption( return result; } -/////////////////////////////////////////////////////////////////////////////// -/// @brief Intercept function for urPlatformGetLastError -__urdlllocal ur_result_t UR_APICALL urPlatformGetLastError( - ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance - const char ** - ppMessage, ///< [out] pointer to a C string where the adapter specific error message - ///< will be stored. - int32_t * - pError ///< [out] pointer to an integer where the adapter specific error code will - ///< be stored. -) { - ur_result_t result = UR_RESULT_SUCCESS; - - // extract platform's function pointer table - auto dditable = - reinterpret_cast(hPlatform)->dditable; - auto pfnGetLastError = dditable->ur.Platform.pfnGetLastError; - if (nullptr == pfnGetLastError) { - return UR_RESULT_ERROR_UNINITIALIZED; - } - - // convert loader handle to platform handle - hPlatform = reinterpret_cast(hPlatform)->handle; - - // forward to device-platform - result = pfnGetLastError(hPlatform, ppMessage, pError); - - return result; -} - /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urDeviceGet __urdlllocal ur_result_t UR_APICALL urDeviceGet( @@ -6869,6 +6996,12 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetGlobalProcAddrTable( // return pointers to loader's DDIs pDdiTable->pfnInit = ur_loader::urInit; pDdiTable->pfnTearDown = ur_loader::urTearDown; + pDdiTable->pfnAdapterGet = ur_loader::urAdapterGet; + pDdiTable->pfnAdapterRelease = ur_loader::urAdapterRelease; + pDdiTable->pfnAdapterRetain = ur_loader::urAdapterRetain; + pDdiTable->pfnAdapterGetLastError = + ur_loader::urAdapterGetLastError; + pDdiTable->pfnAdapterGetInfo = ur_loader::urAdapterGetInfo; } else { // return pointers directly to platform's DDIs *pDdiTable = @@ -7485,7 +7618,6 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetPlatformProcAddrTable( ur_loader::urPlatformGetNativeHandle; pDdiTable->pfnCreateWithNativeHandle = ur_loader::urPlatformCreateWithNativeHandle; - pDdiTable->pfnGetLastError = ur_loader::urPlatformGetLastError; pDdiTable->pfnGetApiVersion = ur_loader::urPlatformGetApiVersion; pDdiTable->pfnGetBackendOption = ur_loader::urPlatformGetBackendOption; diff --git a/source/loader/ur_ldrddi.hpp b/source/loader/ur_ldrddi.hpp index 9ebaeed9d9..4edbabbd8b 100644 --- a/source/loader/ur_ldrddi.hpp +++ b/source/loader/ur_ldrddi.hpp @@ -17,6 +17,10 @@ namespace ur_loader { /////////////////////////////////////////////////////////////////////////////// +using ur_adapter_object_t = object_t; +using ur_adapter_factory_t = + singleton_factory_t; + using ur_platform_object_t = object_t; using ur_platform_factory_t = singleton_factory_t; diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index e5e5b847c3..a31751b254 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -232,7 +232,219 @@ ur_result_t UR_APICALL urTearDown( } /////////////////////////////////////////////////////////////////////////////// -/// @brief Retrieves all available platforms +/// @brief Retrieves all available adapters +/// +/// @details +/// - Adapter implementations must return exactly one adapter handle from +/// this entry point. +/// - The loader may return more than one adapter handle when there are +/// multiple available. +/// - Each returned adapter has its reference count incremented and should +/// be released with a subsequent call to ::urAdapterRelease. +/// - Adapters may perform adapter-specific state initialization when the +/// first reference to them is taken. +/// - An application may call this entry point multiple times to acquire +/// multiple references to the adapter handle(s). +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_SIZE +ur_result_t UR_APICALL urAdapterGet( + uint32_t + NumEntries, ///< [in] the number of adapters to be added to phAdapters. + ///< If phAdapters is not NULL, then NumEntries should be greater than + ///< zero, otherwise ::UR_RESULT_ERROR_INVALID_SIZE, + ///< will be returned. + ur_adapter_handle_t * + phAdapters, ///< [out][optional][range(0, NumEntries)] array of handle of adapters. + ///< If NumEntries is less than the number of adapters available, then + ///< ::urAdapterGet shall only retrieve that number of platforms. + uint32_t * + pNumAdapters ///< [out][optional] returns the total number of adapters available. + ) try { + auto pfnAdapterGet = ur_lib::context->urDdiTable.Global.pfnAdapterGet; + if (nullptr == pfnAdapterGet) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + return pfnAdapterGet(NumEntries, phAdapters, pNumAdapters); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Releases the adapter handle reference indicating end of its usage +/// +/// @details +/// - When the reference count of the adapter reaches zero, the adapter may +/// perform adapter-specififc resource teardown +/// +/// @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 == hAdapter` +ur_result_t UR_APICALL urAdapterRelease( + ur_adapter_handle_t hAdapter ///< [in] Adapter handle to release + ) try { + auto pfnAdapterRelease = + ur_lib::context->urDdiTable.Global.pfnAdapterRelease; + if (nullptr == pfnAdapterRelease) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + return pfnAdapterRelease(hAdapter); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get a reference to the adapter handle. +/// +/// @details +/// - Get a reference to the adapter handle. Increment its reference count +/// +/// @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 == hAdapter` +ur_result_t UR_APICALL urAdapterRetain( + ur_adapter_handle_t hAdapter ///< [in] Adapter handle to retain + ) try { + auto pfnAdapterRetain = ur_lib::context->urDdiTable.Global.pfnAdapterRetain; + if (nullptr == pfnAdapterRetain) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + return pfnAdapterRetain(hAdapter); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get the last adapter specific error. +/// +/// @details +/// To be used after another entry-point has returned +/// ::UR_RESULT_ERROR_ADAPTER_SPECIFIC in order to retrieve a message describing +/// the circumstances of the underlying driver error and the error code +/// returned by the failed driver entry-point. +/// +/// * Implementations *must* store the message and error code in thread-local +/// storage prior to returning ::UR_RESULT_ERROR_ADAPTER_SPECIFIC. +/// +/// * The message and error code storage is will only be valid if a previously +/// called entry-point returned ::UR_RESULT_ERROR_ADAPTER_SPECIFIC. +/// +/// * The memory pointed to by the C string returned in `ppMessage` is owned by +/// the adapter and *must* be null terminated. +/// +/// * The application *may* call this function from simultaneous threads. +/// +/// * The implementation of this function *should* be lock-free. +/// +/// Example usage: +/// +/// ```cpp +/// if (::urQueueCreate(hContext, hDevice, nullptr, &hQueue) == +/// ::UR_RESULT_ERROR_ADAPTER_SPECIFIC) { +/// const char* pMessage; +/// int32_t error; +/// ::urAdapterGetLastError(hAdapter, &pMessage, &error); +/// } +/// ``` +/// +/// @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 == hAdapter` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == ppMessage` +/// + `NULL == pError` +ur_result_t UR_APICALL urAdapterGetLastError( + ur_adapter_handle_t hAdapter, ///< [in] handle of the adapter instance + const char ** + ppMessage, ///< [out] pointer to a C string where the adapter specific error message + ///< will be stored. + int32_t * + pError ///< [out] pointer to an integer where the adapter specific error code will + ///< be stored. + ) try { + auto pfnAdapterGetLastError = + ur_lib::context->urDdiTable.Global.pfnAdapterGetLastError; + if (nullptr == pfnAdapterGetLastError) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + return pfnAdapterGetLastError(hAdapter, ppMessage, pError); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Retrieves information about the adapter +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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 == hAdapter` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_ADAPTER_INFO_REFERENCE_COUNT < propName` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// + If `propName` is not supported by the adapter. +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `propSize == 0 && pPropValue != NULL` +/// + If `propSize` is less than the real number of bytes needed to return the info. +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `propSize != 0 && pPropValue == NULL` +/// + `pPropValue == NULL && pPropSizeRet == NULL` +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY +ur_result_t UR_APICALL urAdapterGetInfo( + ur_adapter_handle_t hAdapter, ///< [in] handle of the adapter + ur_adapter_info_t propName, ///< [in] type of the info to retrieve + size_t propSize, ///< [in] the number of bytes pointed to by pPropValue. + void * + pPropValue, ///< [out][optional][typename(propName, propSize)] array of bytes holding + ///< the info. + ///< If Size is not equal to or greater to the real number of bytes needed + ///< to return the info then the ::UR_RESULT_ERROR_INVALID_SIZE error is + ///< returned and pPropValue is not used. + size_t * + pPropSizeRet ///< [out][optional] pointer to the actual number of bytes being queried by pPropValue. + ) try { + auto pfnAdapterGetInfo = + ur_lib::context->urDdiTable.Global.pfnAdapterGetInfo; + if (nullptr == pfnAdapterGetInfo) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + return pfnAdapterGetInfo(hAdapter, propName, propSize, pPropValue, + pPropSizeRet); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Retrieves all available platforms for the given adapters /// /// @details /// - Multiple calls to this function will return identical platforms @@ -249,8 +461,13 @@ ur_result_t UR_APICALL urTearDown( /// - ::UR_RESULT_ERROR_UNINITIALIZED /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == phAdapters` /// - ::UR_RESULT_ERROR_INVALID_SIZE ur_result_t UR_APICALL urPlatformGet( + ur_adapter_handle_t * + phAdapters, ///< [in][range(0, NumAdapters)] array of adapters to query for platforms. + uint32_t NumAdapters, ///< [in] number of adapters pointed to by phAdapters uint32_t NumEntries, ///< [in] the number of platforms to be added to phPlatforms. ///< If phPlatforms is not NULL, then NumEntries should be greater than @@ -268,7 +485,8 @@ ur_result_t UR_APICALL urPlatformGet( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnGet(NumEntries, phPlatforms, pNumPlatforms); + return pfnGet(phAdapters, NumAdapters, NumEntries, phPlatforms, + pNumPlatforms); } catch (...) { return exceptionToResult(std::current_exception()); } @@ -474,68 +692,6 @@ ur_result_t UR_APICALL urPlatformGetBackendOption( return exceptionToResult(std::current_exception()); } -/////////////////////////////////////////////////////////////////////////////// -/// @brief Get the last adapter specific error. -/// -/// @details -/// To be used after another entry-point has returned -/// ::UR_RESULT_ERROR_ADAPTER_SPECIFIC in order to retrieve a message describing -/// the circumstances of the underlying driver error and the error code -/// returned by the failed driver entry-point. -/// -/// * Implementations *must* store the message and error code in thread-local -/// storage prior to returning ::UR_RESULT_ERROR_ADAPTER_SPECIFIC. -/// -/// * The message and error code storage is will only be valid if a previously -/// called entry-point returned ::UR_RESULT_ERROR_ADAPTER_SPECIFIC. -/// -/// * The memory pointed to by the C string returned in `ppMessage` is owned by -/// the adapter and *must* be null terminated. -/// -/// * The application *may* call this function from simultaneous threads. -/// -/// * The implementation of this function *should* be lock-free. -/// -/// Example usage: -/// -/// ```cpp -/// if (::urQueueCreate(hContext, hDevice, nullptr, &hQueue) == -/// ::UR_RESULT_ERROR_ADAPTER_SPECIFIC) { -/// const char* pMessage; -/// int32_t error; -/// ::urPlatformGetLastError(hPlatform, &pMessage, &error); -/// } -/// ``` -/// -/// @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 == hPlatform` -/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// + `NULL == ppMessage` -/// + `NULL == pError` -ur_result_t UR_APICALL urPlatformGetLastError( - ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance - const char ** - ppMessage, ///< [out] pointer to a C string where the adapter specific error message - ///< will be stored. - int32_t * - pError ///< [out] pointer to an integer where the adapter specific error code will - ///< be stored. - ) try { - auto pfnGetLastError = ur_lib::context->urDdiTable.Platform.pfnGetLastError; - if (nullptr == pfnGetLastError) { - return UR_RESULT_ERROR_UNINITIALIZED; - } - - return pfnGetLastError(hPlatform, ppMessage, pError); -} catch (...) { - return exceptionToResult(std::current_exception()); -} - /////////////////////////////////////////////////////////////////////////////// /// @brief Retrieves devices within a platform /// diff --git a/source/ur_api.cpp b/source/ur_api.cpp index 4ce155ddbb..b63c0975f8 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -202,7 +202,185 @@ ur_result_t UR_APICALL urTearDown( } /////////////////////////////////////////////////////////////////////////////// -/// @brief Retrieves all available platforms +/// @brief Retrieves all available adapters +/// +/// @details +/// - Adapter implementations must return exactly one adapter handle from +/// this entry point. +/// - The loader may return more than one adapter handle when there are +/// multiple available. +/// - Each returned adapter has its reference count incremented and should +/// be released with a subsequent call to ::urAdapterRelease. +/// - Adapters may perform adapter-specific state initialization when the +/// first reference to them is taken. +/// - An application may call this entry point multiple times to acquire +/// multiple references to the adapter handle(s). +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_SIZE +ur_result_t UR_APICALL urAdapterGet( + uint32_t + NumEntries, ///< [in] the number of adapters to be added to phAdapters. + ///< If phAdapters is not NULL, then NumEntries should be greater than + ///< zero, otherwise ::UR_RESULT_ERROR_INVALID_SIZE, + ///< will be returned. + ur_adapter_handle_t * + phAdapters, ///< [out][optional][range(0, NumEntries)] array of handle of adapters. + ///< If NumEntries is less than the number of adapters available, then + ///< ::urAdapterGet shall only retrieve that number of platforms. + uint32_t * + pNumAdapters ///< [out][optional] returns the total number of adapters available. +) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Releases the adapter handle reference indicating end of its usage +/// +/// @details +/// - When the reference count of the adapter reaches zero, the adapter may +/// perform adapter-specififc resource teardown +/// +/// @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 == hAdapter` +ur_result_t UR_APICALL urAdapterRelease( + ur_adapter_handle_t hAdapter ///< [in] Adapter handle to release +) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get a reference to the adapter handle. +/// +/// @details +/// - Get a reference to the adapter handle. Increment its reference count +/// +/// @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 == hAdapter` +ur_result_t UR_APICALL urAdapterRetain( + ur_adapter_handle_t hAdapter ///< [in] Adapter handle to retain +) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get the last adapter specific error. +/// +/// @details +/// To be used after another entry-point has returned +/// ::UR_RESULT_ERROR_ADAPTER_SPECIFIC in order to retrieve a message describing +/// the circumstances of the underlying driver error and the error code +/// returned by the failed driver entry-point. +/// +/// * Implementations *must* store the message and error code in thread-local +/// storage prior to returning ::UR_RESULT_ERROR_ADAPTER_SPECIFIC. +/// +/// * The message and error code storage is will only be valid if a previously +/// called entry-point returned ::UR_RESULT_ERROR_ADAPTER_SPECIFIC. +/// +/// * The memory pointed to by the C string returned in `ppMessage` is owned by +/// the adapter and *must* be null terminated. +/// +/// * The application *may* call this function from simultaneous threads. +/// +/// * The implementation of this function *should* be lock-free. +/// +/// Example usage: +/// +/// ```cpp +/// if (::urQueueCreate(hContext, hDevice, nullptr, &hQueue) == +/// ::UR_RESULT_ERROR_ADAPTER_SPECIFIC) { +/// const char* pMessage; +/// int32_t error; +/// ::urAdapterGetLastError(hAdapter, &pMessage, &error); +/// } +/// ``` +/// +/// @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 == hAdapter` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == ppMessage` +/// + `NULL == pError` +ur_result_t UR_APICALL urAdapterGetLastError( + ur_adapter_handle_t hAdapter, ///< [in] handle of the adapter instance + const char ** + ppMessage, ///< [out] pointer to a C string where the adapter specific error message + ///< will be stored. + int32_t * + pError ///< [out] pointer to an integer where the adapter specific error code will + ///< be stored. +) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Retrieves information about the adapter +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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 == hAdapter` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_ADAPTER_INFO_REFERENCE_COUNT < propName` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// + If `propName` is not supported by the adapter. +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `propSize == 0 && pPropValue != NULL` +/// + If `propSize` is less than the real number of bytes needed to return the info. +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `propSize != 0 && pPropValue == NULL` +/// + `pPropValue == NULL && pPropSizeRet == NULL` +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY +ur_result_t UR_APICALL urAdapterGetInfo( + ur_adapter_handle_t hAdapter, ///< [in] handle of the adapter + ur_adapter_info_t propName, ///< [in] type of the info to retrieve + size_t propSize, ///< [in] the number of bytes pointed to by pPropValue. + void * + pPropValue, ///< [out][optional][typename(propName, propSize)] array of bytes holding + ///< the info. + ///< If Size is not equal to or greater to the real number of bytes needed + ///< to return the info then the ::UR_RESULT_ERROR_INVALID_SIZE error is + ///< returned and pPropValue is not used. + size_t * + pPropSizeRet ///< [out][optional] pointer to the actual number of bytes being queried by pPropValue. +) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Retrieves all available platforms for the given adapters /// /// @details /// - Multiple calls to this function will return identical platforms @@ -219,8 +397,13 @@ ur_result_t UR_APICALL urTearDown( /// - ::UR_RESULT_ERROR_UNINITIALIZED /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == phAdapters` /// - ::UR_RESULT_ERROR_INVALID_SIZE ur_result_t UR_APICALL urPlatformGet( + ur_adapter_handle_t * + phAdapters, ///< [in][range(0, NumAdapters)] array of adapters to query for platforms. + uint32_t NumAdapters, ///< [in] number of adapters pointed to by phAdapters uint32_t NumEntries, ///< [in] the number of platforms to be added to phPlatforms. ///< If phPlatforms is not NULL, then NumEntries should be greater than @@ -404,62 +587,6 @@ ur_result_t UR_APICALL urPlatformGetBackendOption( return result; } -/////////////////////////////////////////////////////////////////////////////// -/// @brief Get the last adapter specific error. -/// -/// @details -/// To be used after another entry-point has returned -/// ::UR_RESULT_ERROR_ADAPTER_SPECIFIC in order to retrieve a message describing -/// the circumstances of the underlying driver error and the error code -/// returned by the failed driver entry-point. -/// -/// * Implementations *must* store the message and error code in thread-local -/// storage prior to returning ::UR_RESULT_ERROR_ADAPTER_SPECIFIC. -/// -/// * The message and error code storage is will only be valid if a previously -/// called entry-point returned ::UR_RESULT_ERROR_ADAPTER_SPECIFIC. -/// -/// * The memory pointed to by the C string returned in `ppMessage` is owned by -/// the adapter and *must* be null terminated. -/// -/// * The application *may* call this function from simultaneous threads. -/// -/// * The implementation of this function *should* be lock-free. -/// -/// Example usage: -/// -/// ```cpp -/// if (::urQueueCreate(hContext, hDevice, nullptr, &hQueue) == -/// ::UR_RESULT_ERROR_ADAPTER_SPECIFIC) { -/// const char* pMessage; -/// int32_t error; -/// ::urPlatformGetLastError(hPlatform, &pMessage, &error); -/// } -/// ``` -/// -/// @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 == hPlatform` -/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// + `NULL == ppMessage` -/// + `NULL == pError` -ur_result_t UR_APICALL urPlatformGetLastError( - ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance - const char ** - ppMessage, ///< [out] pointer to a C string where the adapter specific error message - ///< will be stored. - int32_t * - pError ///< [out] pointer to an integer where the adapter specific error code will - ///< be stored. -) { - ur_result_t result = UR_RESULT_SUCCESS; - return result; -} - /////////////////////////////////////////////////////////////////////////////// /// @brief Retrieves devices within a platform /// diff --git a/test/conformance/platform/CMakeLists.txt b/test/conformance/platform/CMakeLists.txt index 3a9483e2a8..eec1e9bee3 100644 --- a/test/conformance/platform/CMakeLists.txt +++ b/test/conformance/platform/CMakeLists.txt @@ -9,5 +9,4 @@ add_conformance_test(platform urPlatformGetApiVersion.cpp urPlatformGetBackendOption.cpp urPlatformGetInfo.cpp - urPlatformGetLastError.cpp urPlatformGetNativeHandle.cpp) diff --git a/test/conformance/platform/fixtures.h b/test/conformance/platform/fixtures.h index 1558d8d1b3..c8170a4ea2 100644 --- a/test/conformance/platform/fixtures.h +++ b/test/conformance/platform/fixtures.h @@ -20,12 +20,22 @@ struct urTest : ::testing::Test { urLoaderConfigEnableLayer(config, "UR_LAYER_FULL_VALIDATION")); ASSERT_SUCCESS(urInit(device_flags, config)); ASSERT_SUCCESS(urLoaderConfigRelease(config)); + + uint32_t adapter_count; + ASSERT_SUCCESS(urAdapterGet(0, nullptr, &adapter_count)); + adapters.resize(adapter_count); + ASSERT_SUCCESS(urAdapterGet(adapter_count, adapters.data(), nullptr)); } void TearDown() override { + for (auto adapter : adapters) { + ASSERT_SUCCESS(urAdapterRelease(adapter)); + } ur_tear_down_params_t tear_down_params{}; ASSERT_SUCCESS(urTearDown(&tear_down_params)); } + + std::vector adapters; }; struct urPlatformsTest : urTest { @@ -33,10 +43,14 @@ struct urPlatformsTest : urTest { void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urTest::SetUp()); uint32_t count; - ASSERT_SUCCESS(urPlatformGet(0, nullptr, &count)); + ASSERT_SUCCESS(urPlatformGet(adapters.data(), + static_cast(adapters.size()), 0, + nullptr, &count)); ASSERT_NE(count, 0); platforms.resize(count); - ASSERT_SUCCESS(urPlatformGet(count, platforms.data(), nullptr)); + ASSERT_SUCCESS(urPlatformGet(adapters.data(), + static_cast(adapters.size()), + count, platforms.data(), nullptr)); } std::vector platforms; diff --git a/test/conformance/platform/urPlatformGet.cpp b/test/conformance/platform/urPlatformGet.cpp index d7c369e0bd..2f3b28279d 100644 --- a/test/conformance/platform/urPlatformGet.cpp +++ b/test/conformance/platform/urPlatformGet.cpp @@ -9,10 +9,14 @@ using urPlatformGetTest = uur::platform::urTest; TEST_F(urPlatformGetTest, Success) { uint32_t count; - ASSERT_SUCCESS(urPlatformGet(0, nullptr, &count)); + ASSERT_SUCCESS(urPlatformGet(adapters.data(), + static_cast(adapters.size()), 0, + nullptr, &count)); ASSERT_NE(count, 0); std::vector platforms(count); - ASSERT_SUCCESS(urPlatformGet(count, platforms.data(), nullptr)); + ASSERT_SUCCESS(urPlatformGet(adapters.data(), + static_cast(adapters.size()), count, + platforms.data(), nullptr)); for (auto platform : platforms) { ASSERT_NE(nullptr, platform); } @@ -20,8 +24,12 @@ TEST_F(urPlatformGetTest, Success) { TEST_F(urPlatformGetTest, InvalidNumEntries) { uint32_t count; - ASSERT_SUCCESS(urPlatformGet(0, nullptr, &count)); + ASSERT_SUCCESS(urPlatformGet(adapters.data(), + static_cast(adapters.size()), 0, + nullptr, &count)); std::vector platforms(count); ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, - urPlatformGet(0, platforms.data(), nullptr)); + urPlatformGet(adapters.data(), + static_cast(adapters.size()), 0, + platforms.data(), nullptr)); } diff --git a/test/conformance/runtime/CMakeLists.txt b/test/conformance/runtime/CMakeLists.txt index 1eff8db3b7..8c46abd82b 100644 --- a/test/conformance/runtime/CMakeLists.txt +++ b/test/conformance/runtime/CMakeLists.txt @@ -4,5 +4,10 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception add_conformance_test(runtime + urAdapterGet.cpp + urAdapterGetInfo.cpp + urAdapterGetLastError.cpp + urAdapterRetain.cpp + urAdapterRelease.cpp urInit.cpp urTearDown.cpp) diff --git a/test/conformance/runtime/fixtures.h b/test/conformance/runtime/fixtures.h new file mode 100644 index 0000000000..852d6d038c --- /dev/null +++ b/test/conformance/runtime/fixtures.h @@ -0,0 +1,50 @@ +// Copyright (C) 2022-2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +namespace uur { +namespace runtime { + +struct urTest : ::testing::Test { + + void SetUp() override { + ur_device_init_flags_t device_flags = 0; + ur_loader_config_handle_t config; + ASSERT_SUCCESS(urLoaderConfigCreate(&config)); + ASSERT_SUCCESS( + urLoaderConfigEnableLayer(config, "UR_LAYER_FULL_VALIDATION")); + ASSERT_SUCCESS(urInit(device_flags, config)); + ASSERT_SUCCESS(urLoaderConfigRelease(config)); + } + + void TearDown() override { + ur_tear_down_params_t tear_down_params{}; + ASSERT_SUCCESS(urTearDown(&tear_down_params)); + } +}; + +struct urAdapterTest : urTest { + + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE(urTest::SetUp()); + + uint32_t adapter_count; + ASSERT_SUCCESS(urAdapterGet(0, nullptr, &adapter_count)); + adapters.resize(adapter_count); + ASSERT_SUCCESS(urAdapterGet(adapter_count, adapters.data(), nullptr)); + } + + void TearDown() override { + for (auto adapter : adapters) { + ASSERT_SUCCESS(urAdapterRelease(adapter)); + } + UUR_RETURN_ON_FATAL_FAILURE(urTest::TearDown()); + } + + std::vector adapters; +}; + +} // namespace runtime +} // namespace uur diff --git a/test/conformance/runtime/urAdapterGet.cpp b/test/conformance/runtime/urAdapterGet.cpp new file mode 100644 index 0000000000..2c3b62a620 --- /dev/null +++ b/test/conformance/runtime/urAdapterGet.cpp @@ -0,0 +1,22 @@ +// Copyright (C) 2022-2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "fixtures.h" + +using urAdapterGetTest = uur::runtime::urTest; + +TEST_F(urAdapterGetTest, Success) { + uint32_t adapter_count; + ASSERT_SUCCESS(urAdapterGet(0, nullptr, &adapter_count)); + std::vector adapters(adapter_count); + ASSERT_SUCCESS(urAdapterGet(adapter_count, adapters.data(), nullptr)); +} + +TEST_F(urAdapterGetTest, InvalidNumEntries) { + uint32_t adapter_count; + ASSERT_SUCCESS(urAdapterGet(0, nullptr, &adapter_count)); + std::vector adapters(adapter_count); + ASSERT_SUCCESS(urAdapterGet(0, adapters.data(), nullptr)); +} diff --git a/test/conformance/runtime/urAdapterGetInfo.cpp b/test/conformance/runtime/urAdapterGetInfo.cpp new file mode 100644 index 0000000000..6eea5182d8 --- /dev/null +++ b/test/conformance/runtime/urAdapterGetInfo.cpp @@ -0,0 +1,89 @@ +// Copyright (C) 2022-2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "fixtures.h" + +#include + +struct urAdapterGetInfoTest : uur::runtime::urAdapterTest, + ::testing::WithParamInterface { + + void SetUp() { + UUR_RETURN_ON_FATAL_FAILURE(uur::runtime::urAdapterTest::SetUp()); + adapter = adapters[0]; + } + + ur_adapter_handle_t adapter; +}; + +std::unordered_map adapter_info_size_map = { + {UR_ADAPTER_INFO_BACKEND, sizeof(ur_adapter_backend_t)}, + {UR_ADAPTER_INFO_REFERENCE_COUNT, sizeof(uint32_t)}, +}; + +INSTANTIATE_TEST_SUITE_P( + urAdapterGetInfo, urAdapterGetInfoTest, + ::testing::Values(UR_ADAPTER_INFO_BACKEND, UR_ADAPTER_INFO_REFERENCE_COUNT), + [](const ::testing::TestParamInfo &info) { + std::stringstream ss; + ss << info.param; + return ss.str(); + }); + +TEST_P(urAdapterGetInfoTest, Success) { + size_t size = 0; + ur_adapter_info_t info_type = GetParam(); + ASSERT_SUCCESS(urAdapterGetInfo(adapter, info_type, 0, nullptr, &size)); + ASSERT_NE(size, 0); + + if (const auto expected_size = adapter_info_size_map.find(info_type); + expected_size != adapter_info_size_map.end()) { + ASSERT_EQ(expected_size->second, size); + } + + std::vector info_data(size); + ASSERT_SUCCESS( + urAdapterGetInfo(adapter, info_type, size, info_data.data(), nullptr)); +} + +TEST_P(urAdapterGetInfoTest, InvalidNullHandleAdapter) { + size_t size = 0; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urAdapterGetInfo(nullptr, GetParam(), 0, nullptr, &size)); +} + +TEST_F(urAdapterGetInfoTest, InvalidEnumerationAdapterInfoType) { + size_t size = 0; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_ENUMERATION, + urAdapterGetInfo(adapter, UR_ADAPTER_INFO_FORCE_UINT32, 0, + nullptr, &size)); +} + +TEST_F(urAdapterGetInfoTest, InvalidSizeZero) { + ur_adapter_backend_t backend; + ASSERT_EQ_RESULT(urAdapterGetInfo(adapter, UR_ADAPTER_INFO_BACKEND, 0, + &backend, nullptr), + UR_RESULT_ERROR_INVALID_SIZE); +} + +TEST_F(urAdapterGetInfoTest, InvalidSizeSmall) { + ur_adapter_backend_t backend; + ASSERT_EQ_RESULT(urAdapterGetInfo(adapter, UR_ADAPTER_INFO_BACKEND, + sizeof(backend) - 1, &backend, nullptr), + UR_RESULT_ERROR_INVALID_SIZE); +} + +TEST_F(urAdapterGetInfoTest, InvalidNullPointerPropValue) { + ur_adapter_backend_t backend; + ASSERT_EQ_RESULT(urAdapterGetInfo(adapter, UR_ADAPTER_INFO_BACKEND, + sizeof(backend), nullptr, nullptr), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} + +TEST_F(urAdapterGetInfoTest, InvalidNullPointerPropSizeRet) { + ASSERT_EQ_RESULT( + urAdapterGetInfo(adapter, UR_ADAPTER_INFO_BACKEND, 0, nullptr, nullptr), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} diff --git a/test/conformance/platform/urPlatformGetLastError.cpp b/test/conformance/runtime/urAdapterGetLastError.cpp similarity index 57% rename from test/conformance/platform/urPlatformGetLastError.cpp rename to test/conformance/runtime/urAdapterGetLastError.cpp index e4fbc38b21..a82b0664f0 100644 --- a/test/conformance/platform/urPlatformGetLastError.cpp +++ b/test/conformance/runtime/urAdapterGetLastError.cpp @@ -5,31 +5,31 @@ #include "fixtures.h" -struct urPlatformGetLastErrorTest : uur::platform::urPlatformTest { +struct urAdapterGetLastErrorTest : uur::runtime::urAdapterTest { int32_t error; const char *message = nullptr; }; -TEST_F(urPlatformGetLastErrorTest, Success) { +TEST_F(urAdapterGetLastErrorTest, Success) { // We can't reliably generate a UR_RESULT_ERROR_ADAPTER_SPECIFIC error to // test the full functionality of this entry point, so instead do a minimal // smoke test and check that the call returns successfully, even if no // actual error was set. ASSERT_EQ_RESULT(UR_RESULT_SUCCESS, - urPlatformGetLastError(platform, &message, &error)); + urAdapterGetLastError(adapters[0], &message, &error)); } -TEST_F(urPlatformGetLastErrorTest, InvalidHandle) { +TEST_F(urAdapterGetLastErrorTest, InvalidHandle) { ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, - urPlatformGetLastError(nullptr, &message, &error)); + urAdapterGetLastError(nullptr, &message, &error)); } -TEST_F(urPlatformGetLastErrorTest, InvalidMessagePtr) { +TEST_F(urAdapterGetLastErrorTest, InvalidMessagePtr) { ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, - urPlatformGetLastError(platform, nullptr, &error)); + urAdapterGetLastError(adapters[0], nullptr, &error)); } -TEST_F(urPlatformGetLastErrorTest, InvalidErrorPtr) { +TEST_F(urAdapterGetLastErrorTest, InvalidErrorPtr) { ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, - urPlatformGetLastError(platform, &message, nullptr)); + urAdapterGetLastError(adapters[0], &message, nullptr)); } diff --git a/test/conformance/runtime/urAdapterRelease.cpp b/test/conformance/runtime/urAdapterRelease.cpp new file mode 100644 index 0000000000..e7c5bd11ce --- /dev/null +++ b/test/conformance/runtime/urAdapterRelease.cpp @@ -0,0 +1,25 @@ +// Copyright (C) 2022-2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "fixtures.h" + +struct urAdapterReleaseTest : uur::runtime::urAdapterTest { + void SetUp() { + UUR_RETURN_ON_FATAL_FAILURE(uur::runtime::urAdapterTest::SetUp()); + adapter = adapters[0]; + } + + ur_adapter_handle_t adapter; +}; + +TEST_F(urAdapterReleaseTest, Success) { + ASSERT_SUCCESS(urAdapterRetain(adapter)); + EXPECT_SUCCESS(urAdapterRelease(adapter)); +} + +TEST_F(urAdapterReleaseTest, InvalidNullHandleAdapter) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urAdapterRelease(nullptr)); +} diff --git a/test/conformance/runtime/urAdapterRetain.cpp b/test/conformance/runtime/urAdapterRetain.cpp new file mode 100644 index 0000000000..2a5efd0344 --- /dev/null +++ b/test/conformance/runtime/urAdapterRetain.cpp @@ -0,0 +1,25 @@ +// Copyright (C) 2022-2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "fixtures.h" + +struct urAdapterRetainTest : uur::runtime::urAdapterTest { + void SetUp() { + UUR_RETURN_ON_FATAL_FAILURE(uur::runtime::urAdapterTest::SetUp()); + adapter = adapters[0]; + } + + ur_adapter_handle_t adapter; +}; + +TEST_F(urAdapterRetainTest, Success) { + ASSERT_SUCCESS(urAdapterRetain(adapter)); + EXPECT_SUCCESS(urAdapterRelease(adapter)); +} + +TEST_F(urAdapterRetainTest, InvalidNullHandleAdapter) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urAdapterRetain(nullptr)); +} diff --git a/test/conformance/source/environment.cpp b/test/conformance/source/environment.cpp index 43862b0451..287310f679 100644 --- a/test/conformance/source/environment.cpp +++ b/test/conformance/source/environment.cpp @@ -75,8 +75,13 @@ uur::PlatformEnvironment::PlatformEnvironment(int argc, char **argv) return; } + uint32_t adapter_count = 0; + urAdapterGet(0, nullptr, &adapter_count); + adapters.resize(adapter_count); + urAdapterGet(adapter_count, adapters.data(), nullptr); + uint32_t count = 0; - if (urPlatformGet(0, nullptr, &count)) { + if (urPlatformGet(adapters.data(), adapter_count, 0, nullptr, &count)) { error = "urPlatformGet() failed to get number of platforms."; return; } @@ -87,7 +92,8 @@ uur::PlatformEnvironment::PlatformEnvironment(int argc, char **argv) } std::vector platforms(count); - if (urPlatformGet(count, platforms.data(), nullptr)) { + if (urPlatformGet(adapters.data(), adapter_count, count, platforms.data(), + nullptr)) { error = "urPlatformGet failed to get platforms."; return; } @@ -150,6 +156,9 @@ void uur::PlatformEnvironment::TearDown() { if (error == ERROR_NO_ADAPTER) { return; } + for (auto adapter : adapters) { + urAdapterRelease(adapter); + } ur_tear_down_params_t tear_down_params{}; if (urTearDown(&tear_down_params)) { FAIL() << "urTearDown() failed"; diff --git a/test/conformance/testing/include/uur/environment.h b/test/conformance/testing/include/uur/environment.h index f42c5a6436..5cc6756364 100644 --- a/test/conformance/testing/include/uur/environment.h +++ b/test/conformance/testing/include/uur/environment.h @@ -28,6 +28,7 @@ struct PlatformEnvironment : ::testing::Environment { PlatformOptions parsePlatformOptions(int argc, char **argv); PlatformOptions platform_options; + std::vector adapters{}; ur_platform_handle_t platform = nullptr; std::string error; static PlatformEnvironment *instance; diff --git a/test/layers/tracing/hello_world.out.match b/test/layers/tracing/hello_world.out.match index 3df85ca49a..7658650d04 100644 --- a/test/layers/tracing/hello_world.out.match +++ b/test/layers/tracing/hello_world.out.match @@ -1,21 +1,27 @@ function_with_args_begin(1) - urInit(.device_flags = 0); function_with_args_end(1) - urInit(...) -> ur_result_t(0); Platform initialized. -function_with_args_begin(2) - urPlatformGet(unimplemented); -function_with_args_end(2) - urPlatformGet(...) -> ur_result_t(0); -function_with_args_begin(3) - urPlatformGet(unimplemented); -function_with_args_end(3) - urPlatformGet(...) -> ur_result_t(0); -function_with_args_begin(4) - urPlatformGetApiVersion(unimplemented); -function_with_args_end(4) - urPlatformGetApiVersion(...) -> ur_result_t(0); +function_with_args_begin(2) - urAdapterGet(unimplemented); +function_with_args_end(2) - urAdapterGet(...) -> ur_result_t(0); +function_with_args_begin(3) - urAdapterGet(unimplemented); +function_with_args_end(3) - urAdapterGet(...) -> ur_result_t(0); +function_with_args_begin(4) - urPlatformGet(unimplemented); +function_with_args_end(4) - urPlatformGet(...) -> ur_result_t(0); +function_with_args_begin(5) - urPlatformGet(unimplemented); +function_with_args_end(5) - urPlatformGet(...) -> ur_result_t(0); +function_with_args_begin(6) - urPlatformGetApiVersion(unimplemented); +function_with_args_end(6) - urPlatformGetApiVersion(...) -> ur_result_t(0); API version: {{0\.[0-9]+}} -function_with_args_begin(5) - urDeviceGet(unimplemented); -function_with_args_end(5) - urDeviceGet(...) -> ur_result_t(0); -function_with_args_begin(6) - urDeviceGet(unimplemented); -function_with_args_end(6) - urDeviceGet(...) -> ur_result_t(0); -function_with_args_begin(7) - urDeviceGetInfo(unimplemented); -function_with_args_end(7) - urDeviceGetInfo(...) -> ur_result_t(0); -function_with_args_begin(8) - urDeviceGetInfo(unimplemented); -function_with_args_end(8) - urDeviceGetInfo(...) -> ur_result_t(0); +function_with_args_begin(7) - urDeviceGet(unimplemented); +function_with_args_end(7) - urDeviceGet(...) -> ur_result_t(0); +function_with_args_begin(8) - urDeviceGet(unimplemented); +function_with_args_end(8) - urDeviceGet(...) -> ur_result_t(0); +function_with_args_begin(9) - urDeviceGetInfo(unimplemented); +function_with_args_end(9) - urDeviceGetInfo(...) -> ur_result_t(0); +function_with_args_begin(10) - urDeviceGetInfo(unimplemented); +function_with_args_end(10) - urDeviceGetInfo(...) -> ur_result_t(0); Found a Null Device gpu. -function_with_args_begin(9) - urTearDown(unimplemented); -function_with_args_end(9) - urTearDown(...) -> ur_result_t(0); +function_with_args_begin(11) - urAdapterRelease(unimplemented); +function_with_args_end(11) - urAdapterRelease(...) -> ur_result_t(0); +function_with_args_begin(12) - urTearDown(unimplemented); +function_with_args_end(12) - urTearDown(...) -> ur_result_t(0); diff --git a/test/layers/validation/fixtures.hpp b/test/layers/validation/fixtures.hpp index 6af67c6f00..99bc3e5acd 100644 --- a/test/layers/validation/fixtures.hpp +++ b/test/layers/validation/fixtures.hpp @@ -36,14 +36,27 @@ struct valPlatformsTest : urTest { void SetUp() override { urTest::SetUp(); + + uint32_t adapter_count; + ASSERT_EQ(urAdapterGet(0, nullptr, &adapter_count), UR_RESULT_SUCCESS); + adapters.resize(adapter_count); + ASSERT_EQ(urAdapterGet(adapter_count, adapters.data(), nullptr), + UR_RESULT_SUCCESS); + uint32_t count; - ASSERT_EQ(urPlatformGet(0, nullptr, &count), UR_RESULT_SUCCESS); + ASSERT_EQ( + urPlatformGet(adapters.data(), adapter_count, 0, nullptr, &count), + UR_RESULT_SUCCESS); ASSERT_NE(count, 0); platforms.resize(count); - ASSERT_EQ(urPlatformGet(count, platforms.data(), nullptr), + ASSERT_EQ(urPlatformGet(adapters.data(), adapter_count, count, + platforms.data(), nullptr), UR_RESULT_SUCCESS); } + void TearDown() override { urTest::TearDown(); } + + std::vector adapters; std::vector platforms; }; diff --git a/test/loader/platforms/platforms.cpp b/test/loader/platforms/platforms.cpp index c39b0af160..2a665fe8d6 100644 --- a/test/loader/platforms/platforms.cpp +++ b/test/loader/platforms/platforms.cpp @@ -31,10 +31,26 @@ int main(int argc, char *argv[]) { } info("urInit succeeded."); + uint32_t adapterCount = 0; + std::vector adapters; + status = urAdapterGet(0, nullptr, &adapterCount); + if (status != UR_RESULT_SUCCESS) { + error("urAdapterGet failed with return code: {}", status); + return 1; + } + + adapters.resize(adapterCount); + status = urAdapterGet(adapterCount, adapters.data(), nullptr); + if (status != UR_RESULT_SUCCESS) { + error("urAdapterGet failed with return code: {}", status); + return 1; + } + uint32_t platformCount = 0; std::vector platforms; - status = urPlatformGet(1, nullptr, &platformCount); + status = urPlatformGet(adapters.data(), adapterCount, 1, nullptr, + &platformCount); if (status != UR_RESULT_SUCCESS) { error("urPlatformGet failed with return code: {}", status); goto out; @@ -42,7 +58,8 @@ int main(int argc, char *argv[]) { info("urPlatformGet found {} platforms", platformCount); platforms.resize(platformCount); - status = urPlatformGet(platformCount, platforms.data(), nullptr); + status = urPlatformGet(adapters.data(), adapterCount, platformCount, + platforms.data(), nullptr); if (status != UR_RESULT_SUCCESS) { error("urPlatformGet failed with return code: {}", status); goto out; diff --git a/test/tools/urtrace/null_hello.match b/test/tools/urtrace/null_hello.match index 0c76ccac1a..b58a4d8d96 100644 --- a/test/tools/urtrace/null_hello.match +++ b/test/tools/urtrace/null_hello.match @@ -1,7 +1,9 @@ urInit(.device_flags = 0, .hLoaderConfig = nullptr) -> UR_RESULT_SUCCESS; Platform initialized. -urPlatformGet(.NumEntries = 1, .phPlatforms = {}, .pNumPlatforms = {{.*}} (1)) -> UR_RESULT_SUCCESS; -urPlatformGet(.NumEntries = 1, .phPlatforms = {{{.*}}}, .pNumPlatforms = nullptr) -> UR_RESULT_SUCCESS; +urAdapterGet(.NumEntries = 0, .phAdapters = {}, .pNumAdapters = {{.*}} (1)) -> UR_RESULT_SUCCESS; +urAdapterGet(.NumEntries = 1, .phAdapters = {{{.*}}}, .pNumAdapters = nullptr) -> UR_RESULT_SUCCESS; +urPlatformGet(.phAdapters = {{{.*}}}, .NumAdapters = 1, .NumEntries = 1, .phPlatforms = {}, .pNumPlatforms = {{.*}} (1)) -> UR_RESULT_SUCCESS; +urPlatformGet(.phAdapters = {{{.*}}}, .NumAdapters = 1, .NumEntries = 1, .phPlatforms = {{{.*}}}, .pNumPlatforms = nullptr) -> UR_RESULT_SUCCESS; urPlatformGetApiVersion(.hPlatform = {{.*}}, .pVersion = {{.*}} ({{.*}})) -> UR_RESULT_SUCCESS; API version: {{.*}} urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 0, .phDevices = {}, .pNumDevices = {{.*}} (1)) -> UR_RESULT_SUCCESS; @@ -9,4 +11,5 @@ urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_TYPE, .propSize = {{.*}}, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_NAME, .propSize = {{.*}}, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; Found a Null Device gpu. +urAdapterRelease(.hAdapter = {{.*}}) -> UR_RESULT_SUCCESS; urTearDown(.pParams = nullptr) -> UR_RESULT_SUCCESS; diff --git a/test/tools/urtrace/null_hello_begin.match b/test/tools/urtrace/null_hello_begin.match index 114eedfc23..571b01bb89 100644 --- a/test/tools/urtrace/null_hello_begin.match +++ b/test/tools/urtrace/null_hello_begin.match @@ -1,21 +1,27 @@ begin(1) - urInit(.device_flags = 0, .hLoaderConfig = nullptr); end(1) - urInit(.device_flags = 0, .hLoaderConfig = nullptr) -> UR_RESULT_SUCCESS; Platform initialized. -begin(2) - urPlatformGet(.NumEntries = 1, .phPlatforms = {}, .pNumPlatforms = {{.*}} (0)); -end(2) - urPlatformGet(.NumEntries = 1, .phPlatforms = {}, .pNumPlatforms = {{.*}} (1)) -> UR_RESULT_SUCCESS; -begin(3) - urPlatformGet(.NumEntries = 1, .phPlatforms = {nullptr}, .pNumPlatforms = nullptr); -end(3) - urPlatformGet(.NumEntries = 1, .phPlatforms = {{{.*}}}, .pNumPlatforms = nullptr) -> UR_RESULT_SUCCESS; -begin(4) - urPlatformGetApiVersion(.hPlatform = {{.*}}, .pVersion = {{.*}} (0.0)); -end(4) - urPlatformGetApiVersion(.hPlatform = {{.*}}, .pVersion = {{.*}} (0.6)) -> UR_RESULT_SUCCESS; +begin(2) - urAdapterGet(.NumEntries = 0, .phAdapters = {}, .pNumAdapters = {{.*}} (0)); +end(2) - urAdapterGet(.NumEntries = 0, .phAdapters = {}, .pNumAdapters = {{.*}} (1)) -> UR_RESULT_SUCCESS; +begin(3) - urAdapterGet(.NumEntries = 1, .phAdapters = {{{.*}}}, .pNumAdapters = nullptr); +end(3) - urAdapterGet(.NumEntries = 1, .phAdapters = {{{.*}}}, .pNumAdapters = nullptr) -> UR_RESULT_SUCCESS; +begin(4) - urPlatformGet(.phAdapters = {{{.*}}}, .NumAdapters = 1, .NumEntries = 1, .phPlatforms = {}, .pNumPlatforms = {{.*}} (0)); +end(4) - urPlatformGet(.phAdapters = {{{.*}}}, .NumAdapters = 1, .NumEntries = 1, .phPlatforms = {}, .pNumPlatforms = {{.*}} (1)) -> UR_RESULT_SUCCESS; +begin(5) - urPlatformGet(.phAdapters = {{{.*}}}, .NumAdapters = 1, .NumEntries = 1, .phPlatforms = {nullptr}, .pNumPlatforms = nullptr); +end(5) - urPlatformGet(.phAdapters = {{{.*}}}, .NumAdapters = 1, .NumEntries = 1, .phPlatforms = {{{.*}}}, .pNumPlatforms = nullptr) -> UR_RESULT_SUCCESS; +begin(6) - urPlatformGetApiVersion(.hPlatform = {{.*}}, .pVersion = {{.*}} (0.0)); +end(6) - urPlatformGetApiVersion(.hPlatform = {{.*}}, .pVersion = {{.*}} (0.6)) -> UR_RESULT_SUCCESS; API version: {{.*}} -begin(5) - urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 0, .phDevices = {}, .pNumDevices = {{.*}} (0)); -end(5) - urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 0, .phDevices = {}, .pNumDevices = {{.*}} (1)) -> UR_RESULT_SUCCESS; -begin(6) - urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 1, .phDevices = {nullptr}, .pNumDevices = nullptr); -end(6) - urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 1, .phDevices = {{{.*}}}, .pNumDevices = nullptr) -> UR_RESULT_SUCCESS; -begin(7) - urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_TYPE, .propSize = 4, .pPropValue = {{.*}}, .pPropSizeRet = nullptr); -end(7) - urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_TYPE, .propSize = 4, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; -begin(8) - urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_NAME, .propSize = 1023, .pPropValue = {{.*}}, .pPropSizeRet = nullptr); -end(8) - urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_NAME, .propSize = 1023, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; +begin(7) - urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 0, .phDevices = {}, .pNumDevices = {{.*}} (0)); +end(7) - urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 0, .phDevices = {}, .pNumDevices = {{.*}} (1)) -> UR_RESULT_SUCCESS; +begin(8) - urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 1, .phDevices = {nullptr}, .pNumDevices = nullptr); +end(8) - urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 1, .phDevices = {{{.*}}}, .pNumDevices = nullptr) -> UR_RESULT_SUCCESS; +begin(9) - urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_TYPE, .propSize = 4, .pPropValue = {{.*}}, .pPropSizeRet = nullptr); +end(9) - urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_TYPE, .propSize = 4, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; +begin(10) - urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_NAME, .propSize = 1023, .pPropValue = {{.*}}, .pPropSizeRet = nullptr); +end(10) - urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_NAME, .propSize = 1023, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; Found a Null Device gpu. -begin(9) - urTearDown(.pParams = nullptr); -end(9) - urTearDown(.pParams = nullptr) -> UR_RESULT_SUCCESS; +begin(11) - urAdapterRelease(.hAdapter = {{.*}}); +end(11) - urAdapterRelease(.hAdapter = {{.*}}) -> UR_RESULT_SUCCESS; +begin(12) - urTearDown(.pParams = nullptr); +end(12) - urTearDown(.pParams = nullptr) -> UR_RESULT_SUCCESS; diff --git a/test/tools/urtrace/null_hello_json.match b/test/tools/urtrace/null_hello_json.match index 7e7c089f73..9ba4d93f62 100644 --- a/test/tools/urtrace/null_hello_json.match +++ b/test/tools/urtrace/null_hello_json.match @@ -2,8 +2,10 @@ "traceEvents": [ { "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urInit", "args": "(.device_flags = 0, .hLoaderConfig = nullptr)" }, Platform initialized. -{ "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urPlatformGet", "args": "(.NumEntries = 1, .phPlatforms = {}, .pNumPlatforms = {{.*}} (1))" }, -{ "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urPlatformGet", "args": "(.NumEntries = 1, .phPlatforms = {{{.*}}}, .pNumPlatforms = nullptr)" }, +{ "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urAdapterGet", "args": "(.NumEntries = 0, .phAdapters = {}, .pNumAdapters = {{.*}} (1))" }, +{ "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urAdapterGet", "args": "(.NumEntries = 1, .phAdapters = {{{.*}}}, .pNumAdapters = nullptr)" }, +{ "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urPlatformGet", "args": "(.phAdapters = {{{.*}}}, .NumAdapters = 1, .NumEntries = 1, .phPlatforms = {}, .pNumPlatforms = {{.*}} (1))" }, +{ "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urPlatformGet", "args": "(.phAdapters = {{{.*}}}, .NumAdapters = 1, .NumEntries = 1, .phPlatforms = {{{.*}}}, .pNumPlatforms = nullptr)" }, { "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urPlatformGetApiVersion", "args": "(.hPlatform = {{.*}}, .pVersion = {{.*}} (0.6))" }, API version: 0.6 { "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urDeviceGet", "args": "(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 0, .phDevices = {}, .pNumDevices = {{.*}} (1))" }, @@ -11,6 +13,7 @@ API version: 0.6 { "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urDeviceGetInfo", "args": "(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_TYPE, .propSize = 4, .pPropValue = {{.*}} (UR_DEVICE_TYPE_GPU), .pPropSizeRet = nullptr)" }, { "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urDeviceGetInfo", "args": "(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_NAME, .propSize = 1023, .pPropValue = {{.*}} (Null Device), .pPropSizeRet = nullptr)" }, Found a Null Device gpu. +{ "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urAdapterRelease", "args": "(.hAdapter = {{.*}})" }, { "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urTearDown", "args": "(.pParams = nullptr)" }, {"name": "", "cat": "", "ph": "", "pid": "", "tid": "", "ts": ""} ] diff --git a/test/tools/urtrace/null_hello_no_args.match b/test/tools/urtrace/null_hello_no_args.match index b4edbe85f7..e0afcd2868 100644 --- a/test/tools/urtrace/null_hello_no_args.match +++ b/test/tools/urtrace/null_hello_no_args.match @@ -1,5 +1,7 @@ urInit(...) -> UR_RESULT_SUCCESS; Platform initialized. +urAdapterGet(...) -> UR_RESULT_SUCCESS; +urAdapterGet(...) -> UR_RESULT_SUCCESS; urPlatformGet(...) -> UR_RESULT_SUCCESS; urPlatformGet(...) -> UR_RESULT_SUCCESS; urPlatformGetApiVersion(...) -> UR_RESULT_SUCCESS; @@ -9,4 +11,5 @@ urDeviceGet(...) -> UR_RESULT_SUCCESS; urDeviceGetInfo(...) -> UR_RESULT_SUCCESS; urDeviceGetInfo(...) -> UR_RESULT_SUCCESS; Found a Null Device gpu. +urAdapterRelease(...) -> UR_RESULT_SUCCESS; urTearDown(...) -> UR_RESULT_SUCCESS; diff --git a/test/tools/urtrace/null_hello_profiling.match b/test/tools/urtrace/null_hello_profiling.match index 3ad7ae3614..635c3c8784 100644 --- a/test/tools/urtrace/null_hello_profiling.match +++ b/test/tools/urtrace/null_hello_profiling.match @@ -1,7 +1,9 @@ urInit(.device_flags = 0, .hLoaderConfig = nullptr) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) Platform initialized. -urPlatformGet(.NumEntries = 1, .phPlatforms = {}, .pNumPlatforms = {{.*}} (1)) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) -urPlatformGet(.NumEntries = 1, .phPlatforms = {{{.*}}}, .pNumPlatforms = nullptr) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) +urAdapterGet(.NumEntries = 0, .phAdapters = {}, .pNumAdapters = {{.*}} (1)) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) +urAdapterGet(.NumEntries = 1, .phAdapters = {{{.*}}}, .pNumAdapters = nullptr) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) +urPlatformGet(.phAdapters = {{{.*}}}, .NumAdapters = 1, .NumEntries = 1, .phPlatforms = {}, .pNumPlatforms = {{.*}} (1)) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) +urPlatformGet(.phAdapters = {{{.*}}}, .NumAdapters = 1, .NumEntries = 1, .phPlatforms = {{{.*}}}, .pNumPlatforms = nullptr) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) urPlatformGetApiVersion(.hPlatform = {{.*}}, .pVersion = {{.*}} ({{.*}})) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) API version: {{.*}} urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 0, .phDevices = {}, .pNumDevices = {{.*}} (1)) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) @@ -9,4 +11,5 @@ urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_TYPE, .propSize = {{.*}}, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_NAME, .propSize = {{.*}}, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) Found a Null Device gpu. +urAdapterRelease(.hAdapter = {{.*}}) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) urTearDown(.pParams = nullptr) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) diff --git a/test/unit/utils/params.cpp b/test/unit/utils/params.cpp index da87800121..964d117e49 100644 --- a/test/unit/utils/params.cpp +++ b/test/unit/utils/params.cpp @@ -51,13 +51,19 @@ struct UrInitParamsInvalidFlags : UrInitParams { struct UrPlatformGet { ur_platform_get_params_t params; + uint32_t num_adapters; + ur_adapter_handle_t *phAdapters; uint32_t num_entries; uint32_t *pNumPlatforms; ur_platform_handle_t *pPlatforms; UrPlatformGet() { + num_adapters = 0; + phAdapters = nullptr; num_entries = 0; pPlatforms = nullptr; pNumPlatforms = nullptr; + params.pNumAdapters = &num_adapters; + params.pphAdapters = &phAdapters; params.pNumEntries = &num_entries; params.pphPlatforms = &pPlatforms; params.ppNumPlatforms = &pNumPlatforms; @@ -69,7 +75,8 @@ struct UrPlatformGet { struct UrPlatformGetEmptyArray : UrPlatformGet { UrPlatformGetEmptyArray() : UrPlatformGet() {} const char *get_expected() { - return ".NumEntries = 0, .phPlatforms = \\{\\}, .pNumPlatforms = " + return ".phAdapters = \\{\\}, .NumAdapters = 0, .NumEntries = 0, " + ".phPlatforms = \\{\\}, .pNumPlatforms = " "nullptr"; }; }; @@ -85,7 +92,8 @@ struct UrPlatformGetTwoPlatforms : UrPlatformGet { pNumPlatforms = &num_platforms; } const char *get_expected() { - return ".NumEntries = 2, .phPlatforms = \\{.+, .+\\}, " + return ".phAdapters = \\{\\}, .NumAdapters = 0, .NumEntries = 2, " + ".phPlatforms = \\{.+, .+\\}, " ".pNumPlatforms = .+ \\(2\\)"; }; }; From 475b3c6b4b1e8d53a571cbb61c84ee07eebc5267 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Wed, 19 Jul 2023 11:35:48 +0100 Subject: [PATCH 084/104] [ur] Fix leak validation test fixture This patch removes a superflous call to `urLoaderConfigRelease` which resulted in attempting to release and already destroyed `ur_loader_config_handle_t`. --- test/layers/validation/fixtures.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/layers/validation/fixtures.hpp b/test/layers/validation/fixtures.hpp index 6af67c6f00..8c50e181f9 100644 --- a/test/layers/validation/fixtures.hpp +++ b/test/layers/validation/fixtures.hpp @@ -18,7 +18,6 @@ struct urTest : ::testing::Test { UR_RESULT_SUCCESS); ur_device_init_flags_t device_flags = 0; ASSERT_EQ(urInit(device_flags, loader_config), UR_RESULT_SUCCESS); - ASSERT_EQ(urLoaderConfigRelease(loader_config), UR_RESULT_SUCCESS); } void TearDown() override { From 5230505c00b9087fe5298ac8a8a7199de16ce75a Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Wed, 19 Jul 2023 12:05:32 +0100 Subject: [PATCH 085/104] [coverity] Fix 1566353 Resource leak In the `test-runtime` conformance test suite, ensure that the `ur_loader_config_handle_t` is always cleaned up even in the event of assert failures in `SetUp()` by releasing it in `TearDown()`. --- test/conformance/runtime/fixtures.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/test/conformance/runtime/fixtures.h b/test/conformance/runtime/fixtures.h index 852d6d038c..04f72617dd 100644 --- a/test/conformance/runtime/fixtures.h +++ b/test/conformance/runtime/fixtures.h @@ -11,18 +11,21 @@ struct urTest : ::testing::Test { void SetUp() override { ur_device_init_flags_t device_flags = 0; - ur_loader_config_handle_t config; - ASSERT_SUCCESS(urLoaderConfigCreate(&config)); - ASSERT_SUCCESS( - urLoaderConfigEnableLayer(config, "UR_LAYER_FULL_VALIDATION")); - ASSERT_SUCCESS(urInit(device_flags, config)); - ASSERT_SUCCESS(urLoaderConfigRelease(config)); + ASSERT_SUCCESS(urLoaderConfigCreate(&loader_config)); + ASSERT_SUCCESS(urLoaderConfigEnableLayer(loader_config, + "UR_LAYER_FULL_VALIDATION")); + ASSERT_SUCCESS(urInit(device_flags, loader_config)); } void TearDown() override { + if (loader_config) { + ASSERT_SUCCESS(urLoaderConfigRelease(loader_config)); + } ur_tear_down_params_t tear_down_params{}; ASSERT_SUCCESS(urTearDown(&tear_down_params)); } + + ur_loader_config_handle_t loader_config = nullptr; }; struct urAdapterTest : urTest { From 656361b9265bf9d0ad1bfa0d0c87cb70cd9de0b3 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Wed, 19 Jul 2023 12:06:47 +0100 Subject: [PATCH 086/104] [coverity] Fix 1566354 Resource leak In the `test-platform` conformance test suite, ensure that the `ur_loader_config_handle_t` is always cleaned up even in the event of assert failures in `SetUp()` by releasing it in `TearDown()`. --- test/conformance/platform/fixtures.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test/conformance/platform/fixtures.h b/test/conformance/platform/fixtures.h index c8170a4ea2..5b532fb433 100644 --- a/test/conformance/platform/fixtures.h +++ b/test/conformance/platform/fixtures.h @@ -14,12 +14,10 @@ struct urTest : ::testing::Test { void SetUp() override { ur_device_init_flags_t device_flags = 0; - ur_loader_config_handle_t config; - ASSERT_SUCCESS(urLoaderConfigCreate(&config)); - ASSERT_SUCCESS( - urLoaderConfigEnableLayer(config, "UR_LAYER_FULL_VALIDATION")); - ASSERT_SUCCESS(urInit(device_flags, config)); - ASSERT_SUCCESS(urLoaderConfigRelease(config)); + ASSERT_SUCCESS(urLoaderConfigCreate(&loader_config)); + ASSERT_SUCCESS(urLoaderConfigEnableLayer(loader_config, + "UR_LAYER_FULL_VALIDATION")); + ASSERT_SUCCESS(urInit(device_flags, loader_config)); uint32_t adapter_count; ASSERT_SUCCESS(urAdapterGet(0, nullptr, &adapter_count)); @@ -31,10 +29,14 @@ struct urTest : ::testing::Test { for (auto adapter : adapters) { ASSERT_SUCCESS(urAdapterRelease(adapter)); } + if (loader_config) { + ASSERT_SUCCESS(urLoaderConfigRelease(loader_config)); + } ur_tear_down_params_t tear_down_params{}; ASSERT_SUCCESS(urTearDown(&tear_down_params)); } + ur_loader_config_handle_t loader_config = nullptr; std::vector adapters; }; From c1ee9f30fba078ad2eea218eccd68e25fa4bfdff Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Mon, 17 Jul 2023 16:17:34 +0100 Subject: [PATCH 087/104] [ur] Allow native handles to be unsupported Some adapters do not map directly to Unified Runtime's set of API objects and as such are unable to support getting the underlying native handle or creating objects from native handles. This patch adds the `UR_RESULT_ERROR_UNSUPPORTED_FEATURE` to all native handle entry-points and updates the conformance tests to match. --- include/ur_api.h | 38 +++++++++++++++++++ scripts/core/context.yml | 6 +++ scripts/core/device.yml | 6 +++ scripts/core/event.yml | 6 +++ scripts/core/kernel.yml | 6 +++ scripts/core/memory.yml | 9 +++++ scripts/core/platform.yml | 6 +++ scripts/core/program.yml | 6 +++ scripts/core/queue.yml | 6 +++ scripts/core/sampler.yml | 6 +++ source/loader/ur_libapi.cpp | 38 +++++++++++++++++++ source/ur_api.cpp | 38 +++++++++++++++++++ .../urContextCreateWithNativeHandle.cpp | 4 +- .../context/urContextGetNativeHandle.cpp | 4 +- .../device/urDeviceCreateWithNativeHandle.cpp | 4 +- .../device/urDeviceGetNativeHandle.cpp | 4 +- .../event/urEventCreateWithNativeHandle.cpp | 4 +- .../event/urEventGetNativeHandle.cpp | 4 +- .../kernel/urKernelCreateWithNativeHandle.cpp | 4 +- .../kernel/urKernelGetNativeHandle.cpp | 4 +- .../urMemBufferCreateWithNativeHandle.cpp | 4 +- .../memory/urMemGetNativeHandle.cpp | 4 +- .../urMemImageCreateWithNativeHandle.cpp | 4 +- .../urPlatformCreateWithNativeHandle.cpp | 8 +++- .../urProgramCreateWithNativeHandle.cpp | 6 ++- .../program/urProgramGetNativeHandle.cpp | 5 ++- .../queue/urQueueCreateWithNativeHandle.cpp | 4 +- .../queue/urQueueGetNativeHandle.cpp | 4 +- .../urSamplerCreateWithNativeHandle.cpp | 4 +- .../sampler/urSamplerGetNativeHandle.cpp | 4 +- 30 files changed, 230 insertions(+), 20 deletions(-) diff --git a/include/ur_api.h b/include/ur_api.h index 9460f43bd1..9c14872325 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -1071,6 +1071,8 @@ urPlatformGetApiVersion( /// + `NULL == hPlatform` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativePlatform` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urPlatformGetNativeHandle( ur_platform_handle_t hPlatform, ///< [in] handle of the platform. @@ -1105,6 +1107,8 @@ typedef struct ur_platform_native_properties_t { /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phPlatform` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urPlatformCreateWithNativeHandle( ur_native_handle_t hNativePlatform, ///< [in][nocheck] the native handle of the platform. @@ -1822,6 +1826,8 @@ typedef enum ur_device_exec_capability_flag_t { /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeDevice` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetNativeHandle( ur_device_handle_t hDevice, ///< [in] handle of the device. @@ -1858,6 +1864,8 @@ typedef struct ur_device_native_properties_t { /// + `NULL == hPlatform` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phDevice` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urDeviceCreateWithNativeHandle( ur_native_handle_t hNativeDevice, ///< [in][nocheck] the native handle of the device. @@ -2157,6 +2165,8 @@ urContextGetInfo( /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeContext` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urContextGetNativeHandle( ur_context_handle_t hContext, ///< [in] handle of the context. @@ -2192,6 +2202,8 @@ typedef struct ur_context_native_properties_t { /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phDevices` /// + `NULL == phContext` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urContextCreateWithNativeHandle( ur_native_handle_t hNativeContext, ///< [in][nocheck] the native handle of the context. @@ -2633,6 +2645,8 @@ urMemBufferPartition( /// + `NULL == hMem` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeMem` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urMemGetNativeHandle( ur_mem_handle_t hMem, ///< [in] handle of the mem. @@ -2668,6 +2682,8 @@ typedef struct ur_mem_native_properties_t { /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phMem` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( ur_native_handle_t hNativeMem, ///< [in][nocheck] the native handle to the memory. @@ -2695,6 +2711,8 @@ urMemBufferCreateWithNativeHandle( /// + `NULL == pImageFormat` /// + `NULL == pImageDesc` /// + `NULL == phMem` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urMemImageCreateWithNativeHandle( ur_native_handle_t hNativeMem, ///< [in][nocheck] the native handle to the memory. @@ -2993,6 +3011,8 @@ urSamplerGetInfo( /// + `NULL == hSampler` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeSampler` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urSamplerGetNativeHandle( ur_sampler_handle_t hSampler, ///< [in] handle of the sampler. @@ -3029,6 +3049,8 @@ typedef struct ur_sampler_native_properties_t { /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phSampler` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urSamplerCreateWithNativeHandle( ur_native_handle_t hNativeSampler, ///< [in][nocheck] the native handle of the sampler. @@ -4325,6 +4347,8 @@ urProgramSetSpecializationConstants( /// + `NULL == hProgram` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeProgram` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urProgramGetNativeHandle( ur_program_handle_t hProgram, ///< [in] handle of the program. @@ -4361,6 +4385,8 @@ typedef struct ur_program_native_properties_t { /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phProgram` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urProgramCreateWithNativeHandle( ur_native_handle_t hNativeProgram, ///< [in][nocheck] the native handle of the program. @@ -4904,6 +4930,8 @@ urKernelSetSpecializationConstants( /// + `NULL == hKernel` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeKernel` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urKernelGetNativeHandle( ur_kernel_handle_t hKernel, ///< [in] handle of the kernel. @@ -4941,6 +4969,8 @@ typedef struct ur_kernel_native_properties_t { /// + `NULL == hProgram` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phKernel` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urKernelCreateWithNativeHandle( ur_native_handle_t hNativeKernel, ///< [in][nocheck] the native handle of the kernel. @@ -5195,6 +5225,8 @@ typedef struct ur_queue_native_desc_t { /// + `NULL == hQueue` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeQueue` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urQueueGetNativeHandle( ur_queue_handle_t hQueue, ///< [in] handle of the queue. @@ -5233,6 +5265,8 @@ typedef struct ur_queue_native_properties_t { /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phQueue` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urQueueCreateWithNativeHandle( ur_native_handle_t hNativeQueue, ///< [in][nocheck] the native handle of the queue. @@ -5557,6 +5591,8 @@ urEventRelease( /// + `NULL == hEvent` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeEvent` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urEventGetNativeHandle( ur_event_handle_t hEvent, ///< [in] handle of the event. @@ -5593,6 +5629,8 @@ typedef struct ur_event_native_properties_t { /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phEvent` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urEventCreateWithNativeHandle( ur_native_handle_t hNativeEvent, ///< [in][nocheck] the native handle of the event. diff --git a/scripts/core/context.yml b/scripts/core/context.yml index d23c7b1320..fef1161fca 100644 --- a/scripts/core/context.yml +++ b/scripts/core/context.yml @@ -196,6 +196,9 @@ params: name: phNativeContext desc: | [out] a pointer to the native handle of the context. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: struct desc: "Properties for for $xContextCreateWithNativeHandle." @@ -238,6 +241,9 @@ params: name: phContext desc: | [out] pointer to the handle of the context object created. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: fptr_typedef desc: "Context's extended deleter callback function with user data." diff --git a/scripts/core/device.yml b/scripts/core/device.yml index 9efebc5e72..3697095eea 100644 --- a/scripts/core/device.yml +++ b/scripts/core/device.yml @@ -731,6 +731,9 @@ params: name: phNativeDevice desc: | [out] a pointer to the native handle of the device. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: struct desc: "Native device creation properties" @@ -768,6 +771,9 @@ params: - type: "$x_device_handle_t*" name: phDevice desc: "[out] pointer to the handle of the device object created." +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: function desc: "Returns synchronized Host and Device global timestamps." diff --git a/scripts/core/event.yml b/scripts/core/event.yml index 7da347dae2..c20a8e04c9 100644 --- a/scripts/core/event.yml +++ b/scripts/core/event.yml @@ -266,6 +266,9 @@ params: name: phNativeEvent desc: | [out] a pointer to the native handle of the event. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: struct desc: "Properties for for $xEventCreateWithNativeHandle." @@ -305,6 +308,9 @@ params: name: phEvent desc: | [out] pointer to the handle of the event object created. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: enum desc: "Event states for all events." diff --git a/scripts/core/kernel.yml b/scripts/core/kernel.yml index bd444873d5..27481f810f 100644 --- a/scripts/core/kernel.yml +++ b/scripts/core/kernel.yml @@ -487,6 +487,9 @@ params: name: phNativeKernel desc: | [out] a pointer to the native handle of the kernel. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: struct desc: "Properties for for $xKernelCreateWithNativeHandle." @@ -529,3 +532,6 @@ params: name: phKernel desc: | [out] pointer to the handle of the kernel object created. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." diff --git a/scripts/core/memory.yml b/scripts/core/memory.yml index 5a0d6ed6b5..ede16a1913 100644 --- a/scripts/core/memory.yml +++ b/scripts/core/memory.yml @@ -436,6 +436,9 @@ params: name: phNativeMem desc: | [out] a pointer to the native handle of the mem. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: struct desc: "Native memory object creation properties" @@ -473,6 +476,9 @@ params: - type: $x_mem_handle_t* name: phMem desc: "[out] pointer to handle of buffer memory object created." +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: function desc: "Create runtime image memory object from native memory handle." @@ -503,6 +509,9 @@ params: - type: $x_mem_handle_t* name: phMem desc: "[out] pointer to handle of image memory object created." +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: function desc: "Retrieve information about a memory object." diff --git a/scripts/core/platform.yml b/scripts/core/platform.yml index c0c235c354..6a0d350703 100644 --- a/scripts/core/platform.yml +++ b/scripts/core/platform.yml @@ -167,6 +167,9 @@ params: name: phNativePlatform desc: | [out] a pointer to the native handle of the platform. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: struct desc: "Native platform creation properties" @@ -201,6 +204,9 @@ params: - type: "$x_platform_handle_t*" name: phPlatform desc: "[out] pointer to the handle of the platform object created." +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: function desc: "Get the platform specific compiler backend option from a generic frontend option." diff --git a/scripts/core/program.yml b/scripts/core/program.yml index ade7e43541..acab24c3bd 100644 --- a/scripts/core/program.yml +++ b/scripts/core/program.yml @@ -514,6 +514,9 @@ params: name: phNativeProgram desc: | [out] a pointer to the native handle of the program. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: struct desc: "Native program creation properties" @@ -551,3 +554,6 @@ params: - type: "$x_program_handle_t*" name: phProgram desc: "[out] pointer to the handle of the program object created." +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." diff --git a/scripts/core/queue.yml b/scripts/core/queue.yml index 2aa1f936af..88fe153165 100644 --- a/scripts/core/queue.yml +++ b/scripts/core/queue.yml @@ -244,6 +244,9 @@ params: name: phNativeQueue desc: | [out] a pointer to the native handle of the queue. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: struct desc: "Properties for for $xQueueCreateWithNativeHandle." @@ -286,6 +289,9 @@ params: name: phQueue desc: | [out] pointer to the handle of the queue object created. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: function desc: "Blocks until all previously issued commands to the command queue are finished." diff --git a/scripts/core/sampler.yml b/scripts/core/sampler.yml index fd3eb6ebbb..7bb33b357e 100644 --- a/scripts/core/sampler.yml +++ b/scripts/core/sampler.yml @@ -194,6 +194,9 @@ params: name: phNativeSampler desc: | [out] a pointer to the native handle of the sampler. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: struct desc: "Native sampler creation properties" @@ -231,3 +234,6 @@ params: - type: "$x_sampler_handle_t*" name: phSampler desc: "[out] pointer to the handle of the sampler object created." +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index a31751b254..9c7060fdbe 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -597,6 +597,8 @@ ur_result_t UR_APICALL urPlatformGetApiVersion( /// + `NULL == hPlatform` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativePlatform` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urPlatformGetNativeHandle( ur_platform_handle_t hPlatform, ///< [in] handle of the platform. ur_native_handle_t * @@ -629,6 +631,8 @@ ur_result_t UR_APICALL urPlatformGetNativeHandle( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phPlatform` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urPlatformCreateWithNativeHandle( ur_native_handle_t hNativePlatform, ///< [in][nocheck] the native handle of the platform. @@ -996,6 +1000,8 @@ ur_result_t UR_APICALL urDeviceSelectBinary( /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeDevice` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urDeviceGetNativeHandle( ur_device_handle_t hDevice, ///< [in] handle of the device. ur_native_handle_t @@ -1030,6 +1036,8 @@ ur_result_t UR_APICALL urDeviceGetNativeHandle( /// + `NULL == hPlatform` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phDevice` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urDeviceCreateWithNativeHandle( ur_native_handle_t hNativeDevice, ///< [in][nocheck] the native handle of the device. @@ -1282,6 +1290,8 @@ ur_result_t UR_APICALL urContextGetInfo( /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeContext` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urContextGetNativeHandle( ur_context_handle_t hContext, ///< [in] handle of the context. ur_native_handle_t * @@ -1315,6 +1325,8 @@ ur_result_t UR_APICALL urContextGetNativeHandle( /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phDevices` /// + `NULL == phContext` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urContextCreateWithNativeHandle( ur_native_handle_t hNativeContext, ///< [in][nocheck] the native handle of the context. @@ -1613,6 +1625,8 @@ ur_result_t UR_APICALL urMemBufferPartition( /// + `NULL == hMem` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeMem` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urMemGetNativeHandle( ur_mem_handle_t hMem, ///< [in] handle of the mem. ur_native_handle_t @@ -1646,6 +1660,8 @@ ur_result_t UR_APICALL urMemGetNativeHandle( /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phMem` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( ur_native_handle_t hNativeMem, ///< [in][nocheck] the native handle to the memory. @@ -1686,6 +1702,8 @@ ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( /// + `NULL == pImageFormat` /// + `NULL == pImageDesc` /// + `NULL == phMem` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urMemImageCreateWithNativeHandle( ur_native_handle_t hNativeMem, ///< [in][nocheck] the native handle to the memory. @@ -2000,6 +2018,8 @@ ur_result_t UR_APICALL urSamplerGetInfo( /// + `NULL == hSampler` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeSampler` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urSamplerGetNativeHandle( ur_sampler_handle_t hSampler, ///< [in] handle of the sampler. ur_native_handle_t * @@ -2034,6 +2054,8 @@ ur_result_t UR_APICALL urSamplerGetNativeHandle( /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phSampler` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urSamplerCreateWithNativeHandle( ur_native_handle_t hNativeSampler, ///< [in][nocheck] the native handle of the sampler. @@ -3273,6 +3295,8 @@ ur_result_t UR_APICALL urProgramSetSpecializationConstants( /// + `NULL == hProgram` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeProgram` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urProgramGetNativeHandle( ur_program_handle_t hProgram, ///< [in] handle of the program. ur_native_handle_t * @@ -3307,6 +3331,8 @@ ur_result_t UR_APICALL urProgramGetNativeHandle( /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phProgram` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urProgramCreateWithNativeHandle( ur_native_handle_t hNativeProgram, ///< [in][nocheck] the native handle of the program. @@ -3853,6 +3879,8 @@ ur_result_t UR_APICALL urKernelSetSpecializationConstants( /// + `NULL == hKernel` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeKernel` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urKernelGetNativeHandle( ur_kernel_handle_t hKernel, ///< [in] handle of the kernel. ur_native_handle_t @@ -3888,6 +3916,8 @@ ur_result_t UR_APICALL urKernelGetNativeHandle( /// + `NULL == hProgram` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phKernel` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urKernelCreateWithNativeHandle( ur_native_handle_t hNativeKernel, ///< [in][nocheck] the native handle of the kernel. @@ -4096,6 +4126,8 @@ ur_result_t UR_APICALL urQueueRelease( /// + `NULL == hQueue` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeQueue` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urQueueGetNativeHandle( ur_queue_handle_t hQueue, ///< [in] handle of the queue. ur_queue_native_desc_t @@ -4133,6 +4165,8 @@ ur_result_t UR_APICALL urQueueGetNativeHandle( /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phQueue` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urQueueCreateWithNativeHandle( ur_native_handle_t hNativeQueue, ///< [in][nocheck] the native handle of the queue. @@ -4439,6 +4473,8 @@ ur_result_t UR_APICALL urEventRelease( /// + `NULL == hEvent` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeEvent` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urEventGetNativeHandle( ur_event_handle_t hEvent, ///< [in] handle of the event. ur_native_handle_t @@ -4473,6 +4509,8 @@ ur_result_t UR_APICALL urEventGetNativeHandle( /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phEvent` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urEventCreateWithNativeHandle( ur_native_handle_t hNativeEvent, ///< [in][nocheck] the native handle of the event. diff --git a/source/ur_api.cpp b/source/ur_api.cpp index b63c0975f8..c8362e490c 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -513,6 +513,8 @@ ur_result_t UR_APICALL urPlatformGetApiVersion( /// + `NULL == hPlatform` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativePlatform` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urPlatformGetNativeHandle( ur_platform_handle_t hPlatform, ///< [in] handle of the platform. ur_native_handle_t * @@ -538,6 +540,8 @@ ur_result_t UR_APICALL urPlatformGetNativeHandle( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phPlatform` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urPlatformCreateWithNativeHandle( ur_native_handle_t hNativePlatform, ///< [in][nocheck] the native handle of the platform. @@ -854,6 +858,8 @@ ur_result_t UR_APICALL urDeviceSelectBinary( /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeDevice` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urDeviceGetNativeHandle( ur_device_handle_t hDevice, ///< [in] handle of the device. ur_native_handle_t @@ -881,6 +887,8 @@ ur_result_t UR_APICALL urDeviceGetNativeHandle( /// + `NULL == hPlatform` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phDevice` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urDeviceCreateWithNativeHandle( ur_native_handle_t hNativeDevice, ///< [in][nocheck] the native handle of the device. @@ -1094,6 +1102,8 @@ ur_result_t UR_APICALL urContextGetInfo( /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeContext` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urContextGetNativeHandle( ur_context_handle_t hContext, ///< [in] handle of the context. ur_native_handle_t * @@ -1120,6 +1130,8 @@ ur_result_t UR_APICALL urContextGetNativeHandle( /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phDevices` /// + `NULL == phContext` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urContextCreateWithNativeHandle( ur_native_handle_t hNativeContext, ///< [in][nocheck] the native handle of the context. @@ -1371,6 +1383,8 @@ ur_result_t UR_APICALL urMemBufferPartition( /// + `NULL == hMem` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeMem` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urMemGetNativeHandle( ur_mem_handle_t hMem, ///< [in] handle of the mem. ur_native_handle_t @@ -1397,6 +1411,8 @@ ur_result_t UR_APICALL urMemGetNativeHandle( /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phMem` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( ur_native_handle_t hNativeMem, ///< [in][nocheck] the native handle to the memory. @@ -1429,6 +1445,8 @@ ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( /// + `NULL == pImageFormat` /// + `NULL == pImageDesc` /// + `NULL == phMem` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urMemImageCreateWithNativeHandle( ur_native_handle_t hNativeMem, ///< [in][nocheck] the native handle to the memory. @@ -1698,6 +1716,8 @@ ur_result_t UR_APICALL urSamplerGetInfo( /// + `NULL == hSampler` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeSampler` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urSamplerGetNativeHandle( ur_sampler_handle_t hSampler, ///< [in] handle of the sampler. ur_native_handle_t * @@ -1725,6 +1745,8 @@ ur_result_t UR_APICALL urSamplerGetNativeHandle( /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phSampler` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urSamplerCreateWithNativeHandle( ur_native_handle_t hNativeSampler, ///< [in][nocheck] the native handle of the sampler. @@ -2765,6 +2787,8 @@ ur_result_t UR_APICALL urProgramSetSpecializationConstants( /// + `NULL == hProgram` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeProgram` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urProgramGetNativeHandle( ur_program_handle_t hProgram, ///< [in] handle of the program. ur_native_handle_t * @@ -2792,6 +2816,8 @@ ur_result_t UR_APICALL urProgramGetNativeHandle( /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phProgram` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urProgramCreateWithNativeHandle( ur_native_handle_t hNativeProgram, ///< [in][nocheck] the native handle of the program. @@ -3248,6 +3274,8 @@ ur_result_t UR_APICALL urKernelSetSpecializationConstants( /// + `NULL == hKernel` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeKernel` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urKernelGetNativeHandle( ur_kernel_handle_t hKernel, ///< [in] handle of the kernel. ur_native_handle_t @@ -3276,6 +3304,8 @@ ur_result_t UR_APICALL urKernelGetNativeHandle( /// + `NULL == hProgram` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phKernel` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urKernelCreateWithNativeHandle( ur_native_handle_t hNativeKernel, ///< [in][nocheck] the native handle of the kernel. @@ -3452,6 +3482,8 @@ ur_result_t UR_APICALL urQueueRelease( /// + `NULL == hQueue` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeQueue` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urQueueGetNativeHandle( ur_queue_handle_t hQueue, ///< [in] handle of the queue. ur_queue_native_desc_t @@ -3482,6 +3514,8 @@ ur_result_t UR_APICALL urQueueGetNativeHandle( /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phQueue` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urQueueCreateWithNativeHandle( ur_native_handle_t hNativeQueue, ///< [in][nocheck] the native handle of the queue. @@ -3736,6 +3770,8 @@ ur_result_t UR_APICALL urEventRelease( /// + `NULL == hEvent` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeEvent` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urEventGetNativeHandle( ur_event_handle_t hEvent, ///< [in] handle of the event. ur_native_handle_t @@ -3763,6 +3799,8 @@ ur_result_t UR_APICALL urEventGetNativeHandle( /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phEvent` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urEventCreateWithNativeHandle( ur_native_handle_t hNativeEvent, ///< [in][nocheck] the native handle of the event. diff --git a/test/conformance/context/urContextCreateWithNativeHandle.cpp b/test/conformance/context/urContextCreateWithNativeHandle.cpp index 21881169cc..04ef93c0f0 100644 --- a/test/conformance/context/urContextCreateWithNativeHandle.cpp +++ b/test/conformance/context/urContextCreateWithNativeHandle.cpp @@ -10,7 +10,9 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urContextCreateWithNativeHandleTest); TEST_P(urContextCreateWithNativeHandleTest, Success) { ur_native_handle_t native_context = nullptr; - ASSERT_SUCCESS(urContextGetNativeHandle(context, &native_context)); + if (urContextGetNativeHandle(context, &native_context)) { + GTEST_SKIP(); + } // We cannot assume anything about a native_handle, not even if it's // `nullptr` since this could be a valid representation within a backend. diff --git a/test/conformance/context/urContextGetNativeHandle.cpp b/test/conformance/context/urContextGetNativeHandle.cpp index 420379fca4..fda7222568 100644 --- a/test/conformance/context/urContextGetNativeHandle.cpp +++ b/test/conformance/context/urContextGetNativeHandle.cpp @@ -10,7 +10,9 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urContextGetNativeHandleTest); TEST_P(urContextGetNativeHandleTest, Success) { ur_native_handle_t native_context = nullptr; - ASSERT_SUCCESS(urContextGetNativeHandle(context, &native_context)); + if (auto error = urContextGetNativeHandle(context, &native_context)) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_UNSUPPORTED_FEATURE, error); + } } TEST_P(urContextGetNativeHandleTest, InvalidNullHandleContext) { diff --git a/test/conformance/device/urDeviceCreateWithNativeHandle.cpp b/test/conformance/device/urDeviceCreateWithNativeHandle.cpp index 5707a4088b..fbcd5e2f4b 100644 --- a/test/conformance/device/urDeviceCreateWithNativeHandle.cpp +++ b/test/conformance/device/urDeviceCreateWithNativeHandle.cpp @@ -9,7 +9,9 @@ using urDeviceCreateWithNativeHandleTest = uur::urAllDevicesTest; TEST_F(urDeviceCreateWithNativeHandleTest, Success) { for (auto device : devices) { ur_native_handle_t native_handle = nullptr; - ASSERT_SUCCESS(urDeviceGetNativeHandle(device, &native_handle)); + if (urDeviceGetNativeHandle(device, &native_handle)) { + continue; + } // We cannot assume anything about a native_handle, not even if it's // `nullptr` since this could be a valid representation within a backend. diff --git a/test/conformance/device/urDeviceGetNativeHandle.cpp b/test/conformance/device/urDeviceGetNativeHandle.cpp index 301ec16d1d..f6bdec3dd6 100644 --- a/test/conformance/device/urDeviceGetNativeHandle.cpp +++ b/test/conformance/device/urDeviceGetNativeHandle.cpp @@ -9,7 +9,9 @@ using urDeviceGetNativeHandleTest = uur::urAllDevicesTest; TEST_F(urDeviceGetNativeHandleTest, Success) { for (auto device : devices) { ur_native_handle_t native_handle = nullptr; - ASSERT_SUCCESS(urDeviceGetNativeHandle(device, &native_handle)); + if (auto error = urDeviceGetNativeHandle(device, &native_handle)) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_UNSUPPORTED_FEATURE, error); + } } } diff --git a/test/conformance/event/urEventCreateWithNativeHandle.cpp b/test/conformance/event/urEventCreateWithNativeHandle.cpp index 29f1c1b9dc..3a2d6eea84 100644 --- a/test/conformance/event/urEventCreateWithNativeHandle.cpp +++ b/test/conformance/event/urEventCreateWithNativeHandle.cpp @@ -10,7 +10,9 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urEventCreateWithNativeHandleTest); TEST_P(urEventCreateWithNativeHandleTest, Success) { ur_native_handle_t native_event = nullptr; - ASSERT_SUCCESS(urEventGetNativeHandle(event, &native_event)); + if (urEventGetNativeHandle(event, &native_event)) { + GTEST_SKIP(); + } // We cannot assume anything about a native_handle, not even if it's // `nullptr` since this could be a valid representation within a backend. diff --git a/test/conformance/event/urEventGetNativeHandle.cpp b/test/conformance/event/urEventGetNativeHandle.cpp index 6a6003091d..fa2a2cffdf 100644 --- a/test/conformance/event/urEventGetNativeHandle.cpp +++ b/test/conformance/event/urEventGetNativeHandle.cpp @@ -10,7 +10,9 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urEventGetNativeHandleTest); TEST_P(urEventGetNativeHandleTest, Success) { ur_native_handle_t native_event = nullptr; - ASSERT_SUCCESS(urEventGetNativeHandle(event, &native_event)); + if (auto error = urEventGetNativeHandle(event, &native_event)) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_UNSUPPORTED_FEATURE, error); + } } TEST_P(urEventGetNativeHandleTest, InvalidNullHandleEvent) { diff --git a/test/conformance/kernel/urKernelCreateWithNativeHandle.cpp b/test/conformance/kernel/urKernelCreateWithNativeHandle.cpp index 336d44fd45..7575fb309f 100644 --- a/test/conformance/kernel/urKernelCreateWithNativeHandle.cpp +++ b/test/conformance/kernel/urKernelCreateWithNativeHandle.cpp @@ -8,7 +8,9 @@ struct urKernelCreateWithNativeHandleTest : uur::urKernelTest { void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urKernelTest::SetUp()); - ASSERT_SUCCESS(urKernelGetNativeHandle(kernel, &native_kernel_handle)); + if (urKernelGetNativeHandle(kernel, &native_kernel_handle)) { + GTEST_SKIP(); + } } void TearDown() override { diff --git a/test/conformance/kernel/urKernelGetNativeHandle.cpp b/test/conformance/kernel/urKernelGetNativeHandle.cpp index 84249c40b0..39978a9ad9 100644 --- a/test/conformance/kernel/urKernelGetNativeHandle.cpp +++ b/test/conformance/kernel/urKernelGetNativeHandle.cpp @@ -10,7 +10,9 @@ UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urKernelGetNativeHandleTest); TEST_P(urKernelGetNativeHandleTest, Success) { ur_native_handle_t native_kernel_handle = nullptr; - ASSERT_SUCCESS(urKernelGetNativeHandle(kernel, &native_kernel_handle)); + if (auto error = urKernelGetNativeHandle(kernel, &native_kernel_handle)) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_UNSUPPORTED_FEATURE, error); + } } TEST_P(urKernelGetNativeHandleTest, InvalidNullHandleKernel) { diff --git a/test/conformance/memory/urMemBufferCreateWithNativeHandle.cpp b/test/conformance/memory/urMemBufferCreateWithNativeHandle.cpp index ddc4516f46..2d6babd56e 100644 --- a/test/conformance/memory/urMemBufferCreateWithNativeHandle.cpp +++ b/test/conformance/memory/urMemBufferCreateWithNativeHandle.cpp @@ -10,7 +10,9 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urMemBufferCreateWithNativeHandleTest); TEST_P(urMemBufferCreateWithNativeHandleTest, Success) { ur_native_handle_t hNativeMem = nullptr; - ASSERT_SUCCESS(urMemGetNativeHandle(buffer, &hNativeMem)); + if (urMemGetNativeHandle(buffer, &hNativeMem)) { + GTEST_SKIP(); + } // We cannot assume anything about a native_handle, not even if it's // `nullptr` since this could be a valid representation within a backend. diff --git a/test/conformance/memory/urMemGetNativeHandle.cpp b/test/conformance/memory/urMemGetNativeHandle.cpp index f667a9f571..1dbb959c3f 100644 --- a/test/conformance/memory/urMemGetNativeHandle.cpp +++ b/test/conformance/memory/urMemGetNativeHandle.cpp @@ -9,7 +9,9 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urMemGetNativeHandleTest); TEST_P(urMemGetNativeHandleTest, Success) { ur_native_handle_t hNativeMem = nullptr; - ASSERT_SUCCESS(urMemGetNativeHandle(buffer, &hNativeMem)); + if (auto error = urMemGetNativeHandle(buffer, &hNativeMem)) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_UNSUPPORTED_FEATURE, error); + } } TEST_P(urMemGetNativeHandleTest, InvalidNullHandleMem) { diff --git a/test/conformance/memory/urMemImageCreateWithNativeHandle.cpp b/test/conformance/memory/urMemImageCreateWithNativeHandle.cpp index 59331305f1..f22e6c38e5 100644 --- a/test/conformance/memory/urMemImageCreateWithNativeHandle.cpp +++ b/test/conformance/memory/urMemImageCreateWithNativeHandle.cpp @@ -10,7 +10,9 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urMemImageCreateWithNativeHandleTest); TEST_P(urMemImageCreateWithNativeHandleTest, Success) { ur_native_handle_t native_handle = nullptr; - ASSERT_SUCCESS(urMemGetNativeHandle(image, &native_handle)); + if (urMemGetNativeHandle(image, &native_handle)) { + GTEST_SKIP(); + } ur_mem_handle_t mem = nullptr; ASSERT_EQ_RESULT( diff --git a/test/conformance/platform/urPlatformCreateWithNativeHandle.cpp b/test/conformance/platform/urPlatformCreateWithNativeHandle.cpp index 837f1b6c5f..6dd3310f6a 100644 --- a/test/conformance/platform/urPlatformCreateWithNativeHandle.cpp +++ b/test/conformance/platform/urPlatformCreateWithNativeHandle.cpp @@ -10,7 +10,9 @@ using urPlatformCreateWithNativeHandleTest = uur::platform::urPlatformTest; TEST_F(urPlatformCreateWithNativeHandleTest, Success) { for (auto platform : platforms) { ur_native_handle_t native_handle = nullptr; - ASSERT_SUCCESS(urPlatformGetNativeHandle(platform, &native_handle)); + if (urPlatformGetNativeHandle(platform, &native_handle)) { + continue; + }; // We cannot assume anything about a native_handle, not even if it's // `nullptr` since this could be a valid representation within a backend. @@ -31,7 +33,9 @@ TEST_F(urPlatformCreateWithNativeHandleTest, Success) { TEST_F(urPlatformCreateWithNativeHandleTest, InvalidNullPointerPlatform) { for (auto platform : platforms) { ur_native_handle_t native_handle = nullptr; - ASSERT_SUCCESS(urPlatformGetNativeHandle(platform, &native_handle)); + if (urPlatformGetNativeHandle(platform, &native_handle)) { + continue; + } ASSERT_EQ_RESULT( UR_RESULT_ERROR_INVALID_NULL_POINTER, urPlatformCreateWithNativeHandle(native_handle, nullptr, nullptr)); diff --git a/test/conformance/program/urProgramCreateWithNativeHandle.cpp b/test/conformance/program/urProgramCreateWithNativeHandle.cpp index 7970630746..7e0400d294 100644 --- a/test/conformance/program/urProgramCreateWithNativeHandle.cpp +++ b/test/conformance/program/urProgramCreateWithNativeHandle.cpp @@ -25,8 +25,10 @@ struct urProgramCreateWithNativeHandleTest : uur::urProgramTest { UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urProgramCreateWithNativeHandleTest); TEST_P(urProgramCreateWithNativeHandleTest, Success) { - ASSERT_SUCCESS(urProgramCreateWithNativeHandle( - native_program_handle, context, nullptr, &native_program)); + if (urProgramCreateWithNativeHandle(native_program_handle, context, nullptr, + &native_program)) { + GTEST_SKIP(); + } uint32_t ref_count = 0; ASSERT_SUCCESS(urProgramGetInfo(native_program, diff --git a/test/conformance/program/urProgramGetNativeHandle.cpp b/test/conformance/program/urProgramGetNativeHandle.cpp index 193fd2d669..7f176263ad 100644 --- a/test/conformance/program/urProgramGetNativeHandle.cpp +++ b/test/conformance/program/urProgramGetNativeHandle.cpp @@ -10,7 +10,10 @@ UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urProgramGetNativeHandleTest); TEST_P(urProgramGetNativeHandleTest, Success) { ur_native_handle_t native_program_handle = nullptr; - ASSERT_SUCCESS(urProgramGetNativeHandle(program, &native_program_handle)); + if (auto error = + urProgramGetNativeHandle(program, &native_program_handle)) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_UNSUPPORTED_FEATURE, error); + } } TEST_P(urProgramGetNativeHandleTest, InvalidNullHandleProgram) { diff --git a/test/conformance/queue/urQueueCreateWithNativeHandle.cpp b/test/conformance/queue/urQueueCreateWithNativeHandle.cpp index fd12cdaed5..01e7ca16d5 100644 --- a/test/conformance/queue/urQueueCreateWithNativeHandle.cpp +++ b/test/conformance/queue/urQueueCreateWithNativeHandle.cpp @@ -9,7 +9,9 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urQueueCreateWithNativeHandleTest); TEST_P(urQueueCreateWithNativeHandleTest, Success) { ur_native_handle_t native_handle = nullptr; - ASSERT_SUCCESS(urQueueGetNativeHandle(queue, nullptr, &native_handle)); + if (urQueueGetNativeHandle(queue, nullptr, &native_handle)) { + GTEST_SKIP(); + } // We cannot assume anything about a native_handle, not even if it's // `nullptr` since this could be a valid representation within a backend. diff --git a/test/conformance/queue/urQueueGetNativeHandle.cpp b/test/conformance/queue/urQueueGetNativeHandle.cpp index 6d35895fea..914ee21831 100644 --- a/test/conformance/queue/urQueueGetNativeHandle.cpp +++ b/test/conformance/queue/urQueueGetNativeHandle.cpp @@ -9,7 +9,9 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urQueueGetNativeHandleTest); TEST_P(urQueueGetNativeHandleTest, Success) { ur_native_handle_t native_handle = nullptr; - ASSERT_SUCCESS(urQueueGetNativeHandle(queue, nullptr, &native_handle)); + if (auto error = urQueueGetNativeHandle(queue, nullptr, &native_handle)) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_UNSUPPORTED_FEATURE, error); + } } TEST_P(urQueueGetNativeHandleTest, InvalidNullHandleQueue) { diff --git a/test/conformance/sampler/urSamplerCreateWithNativeHandle.cpp b/test/conformance/sampler/urSamplerCreateWithNativeHandle.cpp index 0ea5e3685f..1954b93096 100644 --- a/test/conformance/sampler/urSamplerCreateWithNativeHandle.cpp +++ b/test/conformance/sampler/urSamplerCreateWithNativeHandle.cpp @@ -11,7 +11,9 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urSamplerCreateWithNativeHandleTest); TEST_P(urSamplerCreateWithNativeHandleTest, Success) { ur_native_handle_t native_sampler = nullptr; - ASSERT_SUCCESS(urSamplerGetNativeHandle(sampler, &native_sampler)); + if (urSamplerGetNativeHandle(sampler, &native_sampler)) { + GTEST_SKIP(); + } // We cannot assume anything about a native_handle, not even if it's // `nullptr` since this could be a valid representation within a backend. diff --git a/test/conformance/sampler/urSamplerGetNativeHandle.cpp b/test/conformance/sampler/urSamplerGetNativeHandle.cpp index 24bac6286e..7fcb8a20ad 100644 --- a/test/conformance/sampler/urSamplerGetNativeHandle.cpp +++ b/test/conformance/sampler/urSamplerGetNativeHandle.cpp @@ -11,7 +11,9 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urSamplerGetNativeHandleTest); TEST_P(urSamplerGetNativeHandleTest, Success) { ur_native_handle_t native_sampler = nullptr; - ASSERT_SUCCESS(urSamplerGetNativeHandle(sampler, &native_sampler)); + if (auto error = urSamplerGetNativeHandle(sampler, &native_sampler)) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_UNSUPPORTED_FEATURE, error); + } } TEST_P(urSamplerGetNativeHandleTest, InvalidNullHandleSampler) { From 9bd058a2c3268c57ef050cc19a4d64a56496cbdc Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Thu, 20 Jul 2023 12:59:54 +0100 Subject: [PATCH 088/104] [ur] Match null DDI table entry error code When validation is disabled and an adapter does not sets a DDI table entry to null the loader returns `UR_RESULT_ERROR_UNINITIALIZED` however when validation is enabled `UR_RESULT_ERROR_FEATURE_UNSUPPORTED` is returned. This patch aligns the error codes return by the loader and validation layer when a null DDI table entry is found. --- scripts/templates/valddi.cpp.mako | 5 +- source/loader/layers/validation/ur_valddi.cpp | 338 +++++++++--------- 2 files changed, 172 insertions(+), 171 deletions(-) diff --git a/scripts/templates/valddi.cpp.mako b/scripts/templates/valddi.cpp.mako index 7a6aedaf54..ee931f66f9 100644 --- a/scripts/templates/valddi.cpp.mako +++ b/scripts/templates/valddi.cpp.mako @@ -47,8 +47,9 @@ namespace ur_validation_layer { auto ${th.make_pfn_name(n, tags, obj)} = context.${n}DdiTable.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}; - if( nullptr == ${th.make_pfn_name(n, tags, obj)} ) - return ${X}_RESULT_ERROR_UNSUPPORTED_FEATURE; + if( nullptr == ${th.make_pfn_name(n, tags, obj)} ) { + return ${X}_RESULT_ERROR_UNINITIALIZED; + } if( context.enableParameterValidation ) { diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index ce88ab6cb1..46b0eef491 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -25,7 +25,7 @@ __urdlllocal ur_result_t UR_APICALL urInit( auto pfnInit = context.urDdiTable.Global.pfnInit; if (nullptr == pfnInit) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -47,7 +47,7 @@ __urdlllocal ur_result_t UR_APICALL urTearDown( auto pfnTearDown = context.urDdiTable.Global.pfnTearDown; if (nullptr == pfnTearDown) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -84,7 +84,7 @@ __urdlllocal ur_result_t UR_APICALL urAdapterGet( auto pfnAdapterGet = context.urDdiTable.Global.pfnAdapterGet; if (nullptr == pfnAdapterGet) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -103,7 +103,7 @@ __urdlllocal ur_result_t UR_APICALL urAdapterRelease( auto pfnAdapterRelease = context.urDdiTable.Global.pfnAdapterRelease; if (nullptr == pfnAdapterRelease) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -129,7 +129,7 @@ __urdlllocal ur_result_t UR_APICALL urAdapterRetain( auto pfnAdapterRetain = context.urDdiTable.Global.pfnAdapterRetain; if (nullptr == pfnAdapterRetain) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -162,7 +162,7 @@ __urdlllocal ur_result_t UR_APICALL urAdapterGetLastError( context.urDdiTable.Global.pfnAdapterGetLastError; if (nullptr == pfnAdapterGetLastError) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -202,7 +202,7 @@ __urdlllocal ur_result_t UR_APICALL urAdapterGetInfo( auto pfnAdapterGetInfo = context.urDdiTable.Global.pfnAdapterGetInfo; if (nullptr == pfnAdapterGetInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -254,7 +254,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGet( auto pfnGet = context.urDdiTable.Platform.pfnGet; if (nullptr == pfnGet) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -287,7 +287,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetInfo( auto pfnGetInfo = context.urDdiTable.Platform.pfnGetInfo; if (nullptr == pfnGetInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -327,7 +327,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetApiVersion( auto pfnGetApiVersion = context.urDdiTable.Platform.pfnGetApiVersion; if (nullptr == pfnGetApiVersion) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -355,7 +355,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetNativeHandle( auto pfnGetNativeHandle = context.urDdiTable.Platform.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -387,7 +387,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformCreateWithNativeHandle( context.urDdiTable.Platform.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -415,7 +415,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetBackendOption( auto pfnGetBackendOption = context.urDdiTable.Platform.pfnGetBackendOption; if (nullptr == pfnGetBackendOption) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -458,7 +458,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGet( auto pfnGet = context.urDdiTable.Device.pfnGet; if (nullptr == pfnGet) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -496,7 +496,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetInfo( auto pfnGetInfo = context.urDdiTable.Device.pfnGetInfo; if (nullptr == pfnGetInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -536,7 +536,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceRetain( auto pfnRetain = context.urDdiTable.Device.pfnRetain; if (nullptr == pfnRetain) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -562,7 +562,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceRelease( auto pfnRelease = context.urDdiTable.Device.pfnRelease; if (nullptr == pfnRelease) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -598,7 +598,7 @@ __urdlllocal ur_result_t UR_APICALL urDevicePartition( auto pfnPartition = context.urDdiTable.Device.pfnPartition; if (nullptr == pfnPartition) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -634,7 +634,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceSelectBinary( auto pfnSelectBinary = context.urDdiTable.Device.pfnSelectBinary; if (nullptr == pfnSelectBinary) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -671,7 +671,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetNativeHandle( auto pfnGetNativeHandle = context.urDdiTable.Device.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -704,7 +704,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceCreateWithNativeHandle( context.urDdiTable.Device.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -742,7 +742,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetGlobalTimestamps( context.urDdiTable.Device.pfnGetGlobalTimestamps; if (nullptr == pfnGetGlobalTimestamps) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -771,7 +771,7 @@ __urdlllocal ur_result_t UR_APICALL urContextCreate( auto pfnCreate = context.urDdiTable.Context.pfnCreate; if (nullptr == pfnCreate) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -803,7 +803,7 @@ __urdlllocal ur_result_t UR_APICALL urContextRetain( auto pfnRetain = context.urDdiTable.Context.pfnRetain; if (nullptr == pfnRetain) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -829,7 +829,7 @@ __urdlllocal ur_result_t UR_APICALL urContextRelease( auto pfnRelease = context.urDdiTable.Context.pfnRelease; if (nullptr == pfnRelease) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -867,7 +867,7 @@ __urdlllocal ur_result_t UR_APICALL urContextGetInfo( auto pfnGetInfo = context.urDdiTable.Context.pfnGetInfo; if (nullptr == pfnGetInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -908,7 +908,7 @@ __urdlllocal ur_result_t UR_APICALL urContextGetNativeHandle( auto pfnGetNativeHandle = context.urDdiTable.Context.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -943,7 +943,7 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( context.urDdiTable.Context.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -979,7 +979,7 @@ __urdlllocal ur_result_t UR_APICALL urContextSetExtendedDeleter( context.urDdiTable.Context.pfnSetExtendedDeleter; if (nullptr == pfnSetExtendedDeleter) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1011,7 +1011,7 @@ __urdlllocal ur_result_t UR_APICALL urMemImageCreate( auto pfnImageCreate = context.urDdiTable.Mem.pfnImageCreate; if (nullptr == pfnImageCreate) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1072,7 +1072,7 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreate( auto pfnBufferCreate = context.urDdiTable.Mem.pfnBufferCreate; if (nullptr == pfnBufferCreate) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1121,7 +1121,7 @@ __urdlllocal ur_result_t UR_APICALL urMemRetain( auto pfnRetain = context.urDdiTable.Mem.pfnRetain; if (nullptr == pfnRetain) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1147,7 +1147,7 @@ __urdlllocal ur_result_t UR_APICALL urMemRelease( auto pfnRelease = context.urDdiTable.Mem.pfnRelease; if (nullptr == pfnRelease) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1180,7 +1180,7 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferPartition( auto pfnBufferPartition = context.urDdiTable.Mem.pfnBufferPartition; if (nullptr == pfnBufferPartition) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1221,7 +1221,7 @@ __urdlllocal ur_result_t UR_APICALL urMemGetNativeHandle( auto pfnGetNativeHandle = context.urDdiTable.Mem.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1254,7 +1254,7 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( context.urDdiTable.Mem.pfnBufferCreateWithNativeHandle; if (nullptr == pfnBufferCreateWithNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1291,7 +1291,7 @@ __urdlllocal ur_result_t UR_APICALL urMemImageCreateWithNativeHandle( context.urDdiTable.Mem.pfnImageCreateWithNativeHandle; if (nullptr == pfnImageCreateWithNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1338,7 +1338,7 @@ __urdlllocal ur_result_t UR_APICALL urMemGetInfo( auto pfnGetInfo = context.urDdiTable.Mem.pfnGetInfo; if (nullptr == pfnGetInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1388,7 +1388,7 @@ __urdlllocal ur_result_t UR_APICALL urMemImageGetInfo( auto pfnImageGetInfo = context.urDdiTable.Mem.pfnImageGetInfo; if (nullptr == pfnImageGetInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1430,7 +1430,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerCreate( auto pfnCreate = context.urDdiTable.Sampler.pfnCreate; if (nullptr == pfnCreate) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1474,7 +1474,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerRetain( auto pfnRetain = context.urDdiTable.Sampler.pfnRetain; if (nullptr == pfnRetain) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1501,7 +1501,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerRelease( auto pfnRelease = context.urDdiTable.Sampler.pfnRelease; if (nullptr == pfnRelease) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1535,7 +1535,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetInfo( auto pfnGetInfo = context.urDdiTable.Sampler.pfnGetInfo; if (nullptr == pfnGetInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1576,7 +1576,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetNativeHandle( auto pfnGetNativeHandle = context.urDdiTable.Sampler.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1609,7 +1609,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerCreateWithNativeHandle( context.urDdiTable.Sampler.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1647,7 +1647,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMHostAlloc( auto pfnHostAlloc = context.urDdiTable.USM.pfnHostAlloc; if (nullptr == pfnHostAlloc) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1690,7 +1690,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMDeviceAlloc( auto pfnDeviceAlloc = context.urDdiTable.USM.pfnDeviceAlloc; if (nullptr == pfnDeviceAlloc) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1738,7 +1738,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMSharedAlloc( auto pfnSharedAlloc = context.urDdiTable.USM.pfnSharedAlloc; if (nullptr == pfnSharedAlloc) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1779,7 +1779,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMFree( auto pfnFree = context.urDdiTable.USM.pfnFree; if (nullptr == pfnFree) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1815,7 +1815,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMGetMemAllocInfo( auto pfnGetMemAllocInfo = context.urDdiTable.USM.pfnGetMemAllocInfo; if (nullptr == pfnGetMemAllocInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1850,7 +1850,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolCreate( auto pfnPoolCreate = context.urDdiTable.USM.pfnPoolCreate; if (nullptr == pfnPoolCreate) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1888,7 +1888,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolRetain( auto pfnPoolRetain = context.urDdiTable.USM.pfnPoolRetain; if (nullptr == pfnPoolRetain) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1914,7 +1914,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolRelease( auto pfnPoolRelease = context.urDdiTable.USM.pfnPoolRelease; if (nullptr == pfnPoolRelease) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1947,7 +1947,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolGetInfo( auto pfnPoolGetInfo = context.urDdiTable.USM.pfnPoolGetInfo; if (nullptr == pfnPoolGetInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2001,7 +2001,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemGranularityGetInfo( context.urDdiTable.VirtualMem.pfnGranularityGetInfo; if (nullptr == pfnGranularityGetInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2049,7 +2049,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemReserve( auto pfnReserve = context.urDdiTable.VirtualMem.pfnReserve; if (nullptr == pfnReserve) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2078,7 +2078,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemFree( auto pfnFree = context.urDdiTable.VirtualMem.pfnFree; if (nullptr == pfnFree) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2113,7 +2113,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemMap( auto pfnMap = context.urDdiTable.VirtualMem.pfnMap; if (nullptr == pfnMap) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2151,7 +2151,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemUnmap( auto pfnUnmap = context.urDdiTable.VirtualMem.pfnUnmap; if (nullptr == pfnUnmap) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2182,7 +2182,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemSetAccess( auto pfnSetAccess = context.urDdiTable.VirtualMem.pfnSetAccess; if (nullptr == pfnSetAccess) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2225,7 +2225,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemGetInfo( auto pfnGetInfo = context.urDdiTable.VirtualMem.pfnGetInfo; if (nullptr == pfnGetInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2264,7 +2264,7 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemCreate( auto pfnCreate = context.urDdiTable.PhysicalMem.pfnCreate; if (nullptr == pfnCreate) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2300,7 +2300,7 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemRetain( auto pfnRetain = context.urDdiTable.PhysicalMem.pfnRetain; if (nullptr == pfnRetain) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2327,7 +2327,7 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemRelease( auto pfnRelease = context.urDdiTable.PhysicalMem.pfnRelease; if (nullptr == pfnRelease) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2359,7 +2359,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithIL( auto pfnCreateWithIL = context.urDdiTable.Program.pfnCreateWithIL; if (nullptr == pfnCreateWithIL) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2416,7 +2416,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithBinary( auto pfnCreateWithBinary = context.urDdiTable.Program.pfnCreateWithBinary; if (nullptr == pfnCreateWithBinary) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2468,7 +2468,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramBuild( auto pfnBuild = context.urDdiTable.Program.pfnBuild; if (nullptr == pfnBuild) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2498,7 +2498,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramCompile( auto pfnCompile = context.urDdiTable.Program.pfnCompile; if (nullptr == pfnCompile) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2531,7 +2531,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramLink( auto pfnLink = context.urDdiTable.Program.pfnLink; if (nullptr == pfnLink) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2566,7 +2566,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramRetain( auto pfnRetain = context.urDdiTable.Program.pfnRetain; if (nullptr == pfnRetain) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2592,7 +2592,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramRelease( auto pfnRelease = context.urDdiTable.Program.pfnRelease; if (nullptr == pfnRelease) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2628,7 +2628,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetFunctionPointer( context.urDdiTable.Program.pfnGetFunctionPointer; if (nullptr == pfnGetFunctionPointer) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2674,7 +2674,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetInfo( auto pfnGetInfo = context.urDdiTable.Program.pfnGetInfo; if (nullptr == pfnGetInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2726,7 +2726,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetBuildInfo( auto pfnGetBuildInfo = context.urDdiTable.Program.pfnGetBuildInfo; if (nullptr == pfnGetBuildInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2762,7 +2762,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramSetSpecializationConstants( context.urDdiTable.Program.pfnSetSpecializationConstants; if (nullptr == pfnSetSpecializationConstants) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2795,7 +2795,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetNativeHandle( auto pfnGetNativeHandle = context.urDdiTable.Program.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2828,7 +2828,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithNativeHandle( context.urDdiTable.Program.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2862,7 +2862,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelCreate( auto pfnCreate = context.urDdiTable.Kernel.pfnCreate; if (nullptr == pfnCreate) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2902,7 +2902,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgValue( auto pfnSetArgValue = context.urDdiTable.Kernel.pfnSetArgValue; if (nullptr == pfnSetArgValue) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2934,7 +2934,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgLocal( auto pfnSetArgLocal = context.urDdiTable.Kernel.pfnSetArgLocal; if (nullptr == pfnSetArgLocal) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2969,7 +2969,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetInfo( auto pfnGetInfo = context.urDdiTable.Kernel.pfnGetInfo; if (nullptr == pfnGetInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3018,7 +3018,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetGroupInfo( auto pfnGetGroupInfo = context.urDdiTable.Kernel.pfnGetGroupInfo; if (nullptr == pfnGetGroupInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3059,7 +3059,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetSubGroupInfo( auto pfnGetSubGroupInfo = context.urDdiTable.Kernel.pfnGetSubGroupInfo; if (nullptr == pfnGetSubGroupInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3090,7 +3090,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelRetain( auto pfnRetain = context.urDdiTable.Kernel.pfnRetain; if (nullptr == pfnRetain) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3116,7 +3116,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelRelease( auto pfnRelease = context.urDdiTable.Kernel.pfnRelease; if (nullptr == pfnRelease) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3148,7 +3148,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgPointer( auto pfnSetArgPointer = context.urDdiTable.Kernel.pfnSetArgPointer; if (nullptr == pfnSetArgPointer) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3178,7 +3178,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetExecInfo( auto pfnSetExecInfo = context.urDdiTable.Kernel.pfnSetExecInfo; if (nullptr == pfnSetExecInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3213,7 +3213,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgSampler( auto pfnSetArgSampler = context.urDdiTable.Kernel.pfnSetArgSampler; if (nullptr == pfnSetArgSampler) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3244,7 +3244,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgMemObj( auto pfnSetArgMemObj = context.urDdiTable.Kernel.pfnSetArgMemObj; if (nullptr == pfnSetArgMemObj) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3271,7 +3271,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetSpecializationConstants( context.urDdiTable.Kernel.pfnSetSpecializationConstants; if (nullptr == pfnSetSpecializationConstants) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3304,7 +3304,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetNativeHandle( auto pfnGetNativeHandle = context.urDdiTable.Kernel.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3339,7 +3339,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelCreateWithNativeHandle( context.urDdiTable.Kernel.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3382,7 +3382,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueGetInfo( auto pfnGetInfo = context.urDdiTable.Queue.pfnGetInfo; if (nullptr == pfnGetInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3426,7 +3426,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueCreate( auto pfnCreate = context.urDdiTable.Queue.pfnCreate; if (nullptr == pfnCreate) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3460,7 +3460,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueRetain( auto pfnRetain = context.urDdiTable.Queue.pfnRetain; if (nullptr == pfnRetain) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3486,7 +3486,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueRelease( auto pfnRelease = context.urDdiTable.Queue.pfnRelease; if (nullptr == pfnRelease) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3516,7 +3516,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueGetNativeHandle( auto pfnGetNativeHandle = context.urDdiTable.Queue.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3550,7 +3550,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueCreateWithNativeHandle( context.urDdiTable.Queue.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3585,7 +3585,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueFinish( auto pfnFinish = context.urDdiTable.Queue.pfnFinish; if (nullptr == pfnFinish) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3607,7 +3607,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueFlush( auto pfnFlush = context.urDdiTable.Queue.pfnFlush; if (nullptr == pfnFlush) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3635,7 +3635,7 @@ __urdlllocal ur_result_t UR_APICALL urEventGetInfo( auto pfnGetInfo = context.urDdiTable.Event.pfnGetInfo; if (nullptr == pfnGetInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3683,7 +3683,7 @@ __urdlllocal ur_result_t UR_APICALL urEventGetProfilingInfo( auto pfnGetProfilingInfo = context.urDdiTable.Event.pfnGetProfilingInfo; if (nullptr == pfnGetProfilingInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3717,7 +3717,7 @@ __urdlllocal ur_result_t UR_APICALL urEventWait( auto pfnWait = context.urDdiTable.Event.pfnWait; if (nullptr == pfnWait) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3743,7 +3743,7 @@ __urdlllocal ur_result_t UR_APICALL urEventRetain( auto pfnRetain = context.urDdiTable.Event.pfnRetain; if (nullptr == pfnRetain) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3769,7 +3769,7 @@ __urdlllocal ur_result_t UR_APICALL urEventRelease( auto pfnRelease = context.urDdiTable.Event.pfnRelease; if (nullptr == pfnRelease) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3797,7 +3797,7 @@ __urdlllocal ur_result_t UR_APICALL urEventGetNativeHandle( auto pfnGetNativeHandle = context.urDdiTable.Event.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3830,7 +3830,7 @@ __urdlllocal ur_result_t UR_APICALL urEventCreateWithNativeHandle( context.urDdiTable.Event.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3865,7 +3865,7 @@ __urdlllocal ur_result_t UR_APICALL urEventSetCallback( auto pfnSetCallback = context.urDdiTable.Event.pfnSetCallback; if (nullptr == pfnSetCallback) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3922,7 +3922,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueKernelLaunch( auto pfnKernelLaunch = context.urDdiTable.Enqueue.pfnKernelLaunch; if (nullptr == pfnKernelLaunch) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3976,7 +3976,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueEventsWait( auto pfnEventsWait = context.urDdiTable.Enqueue.pfnEventsWait; if (nullptr == pfnEventsWait) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4018,7 +4018,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueEventsWaitWithBarrier( context.urDdiTable.Enqueue.pfnEventsWaitWithBarrier; if (nullptr == pfnEventsWaitWithBarrier) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4063,7 +4063,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferRead( auto pfnMemBufferRead = context.urDdiTable.Enqueue.pfnMemBufferRead; if (nullptr == pfnMemBufferRead) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4119,7 +4119,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferWrite( auto pfnMemBufferWrite = context.urDdiTable.Enqueue.pfnMemBufferWrite; if (nullptr == pfnMemBufferWrite) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4185,7 +4185,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferReadRect( auto pfnMemBufferReadRect = context.urDdiTable.Enqueue.pfnMemBufferReadRect; if (nullptr == pfnMemBufferReadRect) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4296,7 +4296,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferWriteRect( context.urDdiTable.Enqueue.pfnMemBufferWriteRect; if (nullptr == pfnMemBufferWriteRect) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4391,7 +4391,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferCopy( auto pfnMemBufferCopy = context.urDdiTable.Enqueue.pfnMemBufferCopy; if (nullptr == pfnMemBufferCopy) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4454,7 +4454,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferCopyRect( auto pfnMemBufferCopyRect = context.urDdiTable.Enqueue.pfnMemBufferCopyRect; if (nullptr == pfnMemBufferCopyRect) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4545,7 +4545,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferFill( auto pfnMemBufferFill = context.urDdiTable.Enqueue.pfnMemBufferFill; if (nullptr == pfnMemBufferFill) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4604,7 +4604,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageRead( auto pfnMemImageRead = context.urDdiTable.Enqueue.pfnMemImageRead; if (nullptr == pfnMemImageRead) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4664,7 +4664,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageWrite( auto pfnMemImageWrite = context.urDdiTable.Enqueue.pfnMemImageWrite; if (nullptr == pfnMemImageWrite) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4724,7 +4724,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageCopy( auto pfnMemImageCopy = context.urDdiTable.Enqueue.pfnMemImageCopy; if (nullptr == pfnMemImageCopy) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4780,7 +4780,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferMap( auto pfnMemBufferMap = context.urDdiTable.Enqueue.pfnMemBufferMap; if (nullptr == pfnMemBufferMap) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4836,7 +4836,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemUnmap( auto pfnMemUnmap = context.urDdiTable.Enqueue.pfnMemUnmap; if (nullptr == pfnMemUnmap) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4893,7 +4893,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMFill( auto pfnUSMFill = context.urDdiTable.Enqueue.pfnUSMFill; if (nullptr == pfnUSMFill) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4962,7 +4962,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMMemcpy( auto pfnUSMMemcpy = context.urDdiTable.Enqueue.pfnUSMMemcpy; if (nullptr == pfnUSMMemcpy) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5018,7 +5018,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMPrefetch( auto pfnUSMPrefetch = context.urDdiTable.Enqueue.pfnUSMPrefetch; if (nullptr == pfnUSMPrefetch) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5068,7 +5068,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMAdvise( auto pfnUSMAdvise = context.urDdiTable.Enqueue.pfnUSMAdvise; if (nullptr == pfnUSMAdvise) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5123,7 +5123,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMFill2D( auto pfnUSMFill2D = context.urDdiTable.Enqueue.pfnUSMFill2D; if (nullptr == pfnUSMFill2D) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5213,7 +5213,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMMemcpy2D( auto pfnUSMMemcpy2D = context.urDdiTable.Enqueue.pfnUSMMemcpy2D; if (nullptr == pfnUSMMemcpy2D) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5292,7 +5292,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueDeviceGlobalVariableWrite( context.urDdiTable.Enqueue.pfnDeviceGlobalVariableWrite; if (nullptr == pfnDeviceGlobalVariableWrite) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5355,7 +5355,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueDeviceGlobalVariableRead( context.urDdiTable.Enqueue.pfnDeviceGlobalVariableRead; if (nullptr == pfnDeviceGlobalVariableRead) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5421,7 +5421,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueReadHostPipe( auto pfnReadHostPipe = context.urDdiTable.Enqueue.pfnReadHostPipe; if (nullptr == pfnReadHostPipe) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5487,7 +5487,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueWriteHostPipe( auto pfnWriteHostPipe = context.urDdiTable.Enqueue.pfnWriteHostPipe; if (nullptr == pfnWriteHostPipe) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5547,7 +5547,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPitchedAllocExp( auto pfnPitchedAllocExp = context.urDdiTable.USMExp.pfnPitchedAllocExp; if (nullptr == pfnPitchedAllocExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5597,7 +5597,7 @@ urBindlessImagesUnsampledImageHandleDestroyExp( context.urDdiTable.BindlessImagesExp.pfnUnsampledImageHandleDestroyExp; if (nullptr == pfnUnsampledImageHandleDestroyExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5633,7 +5633,7 @@ urBindlessImagesSampledImageHandleDestroyExp( context.urDdiTable.BindlessImagesExp.pfnSampledImageHandleDestroyExp; if (nullptr == pfnSampledImageHandleDestroyExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5671,7 +5671,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( context.urDdiTable.BindlessImagesExp.pfnImageAllocateExp; if (nullptr == pfnImageAllocateExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5717,7 +5717,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( auto pfnImageFreeExp = context.urDdiTable.BindlessImagesExp.pfnImageFreeExp; if (nullptr == pfnImageFreeExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5757,7 +5757,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( context.urDdiTable.BindlessImagesExp.pfnUnsampledImageCreateExp; if (nullptr == pfnUnsampledImageCreateExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5819,7 +5819,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( context.urDdiTable.BindlessImagesExp.pfnSampledImageCreateExp; if (nullptr == pfnSampledImageCreateExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5904,7 +5904,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp( auto pfnImageCopyExp = context.urDdiTable.BindlessImagesExp.pfnImageCopyExp; if (nullptr == pfnImageCopyExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5957,7 +5957,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( context.urDdiTable.BindlessImagesExp.pfnImageGetInfoExp; if (nullptr == pfnImageGetInfoExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5995,7 +5995,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( context.urDdiTable.BindlessImagesExp.pfnMipmapGetLevelExp; if (nullptr == pfnMipmapGetLevelExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6033,7 +6033,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( context.urDdiTable.BindlessImagesExp.pfnMipmapFreeExp; if (nullptr == pfnMipmapFreeExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6070,7 +6070,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( context.urDdiTable.BindlessImagesExp.pfnImportOpaqueFDExp; if (nullptr == pfnImportOpaqueFDExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6114,7 +6114,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( context.urDdiTable.BindlessImagesExp.pfnMapExternalArrayExp; if (nullptr == pfnMapExternalArrayExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6165,7 +6165,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( context.urDdiTable.BindlessImagesExp.pfnReleaseInteropExp; if (nullptr == pfnReleaseInteropExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6207,7 +6207,7 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( .pfnImportExternalSemaphoreOpaqueFDExp; if (nullptr == pfnImportExternalSemaphoreOpaqueFDExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6246,7 +6246,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( context.urDdiTable.BindlessImagesExp.pfnDestroyExternalSemaphoreExp; if (nullptr == pfnDestroyExternalSemaphoreExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6290,7 +6290,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesWaitExternalSemaphoreExp( context.urDdiTable.BindlessImagesExp.pfnWaitExternalSemaphoreExp; if (nullptr == pfnWaitExternalSemaphoreExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6330,7 +6330,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSignalExternalSemaphoreExp( context.urDdiTable.BindlessImagesExp.pfnSignalExternalSemaphoreExp; if (nullptr == pfnSignalExternalSemaphoreExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6362,7 +6362,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferCreateExp( auto pfnCreateExp = context.urDdiTable.CommandBufferExp.pfnCreateExp; if (nullptr == pfnCreateExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6394,7 +6394,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferRetainExp( auto pfnRetainExp = context.urDdiTable.CommandBufferExp.pfnRetainExp; if (nullptr == pfnRetainExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6421,7 +6421,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferReleaseExp( auto pfnReleaseExp = context.urDdiTable.CommandBufferExp.pfnReleaseExp; if (nullptr == pfnReleaseExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6448,7 +6448,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferFinalizeExp( auto pfnFinalizeExp = context.urDdiTable.CommandBufferExp.pfnFinalizeExp; if (nullptr == pfnFinalizeExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6486,7 +6486,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendKernelLaunchExp( context.urDdiTable.CommandBufferExp.pfnAppendKernelLaunchExp; if (nullptr == pfnAppendKernelLaunchExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6546,7 +6546,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemcpyUSMExp( context.urDdiTable.CommandBufferExp.pfnAppendMemcpyUSMExp; if (nullptr == pfnAppendMemcpyUSMExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6603,7 +6603,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMembufferCopyExp( context.urDdiTable.CommandBufferExp.pfnAppendMembufferCopyExp; if (nullptr == pfnAppendMembufferCopyExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6656,7 +6656,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMembufferWriteExp( context.urDdiTable.CommandBufferExp.pfnAppendMembufferWriteExp; if (nullptr == pfnAppendMembufferWriteExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6708,7 +6708,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMembufferReadExp( context.urDdiTable.CommandBufferExp.pfnAppendMembufferReadExp; if (nullptr == pfnAppendMembufferReadExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6768,7 +6768,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMembufferCopyRectExp( context.urDdiTable.CommandBufferExp.pfnAppendMembufferCopyRectExp; if (nullptr == pfnAppendMembufferCopyRectExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6835,7 +6835,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMembufferWriteRectExp( context.urDdiTable.CommandBufferExp.pfnAppendMembufferWriteRectExp; if (nullptr == pfnAppendMembufferWriteRectExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6900,7 +6900,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMembufferReadRectExp( context.urDdiTable.CommandBufferExp.pfnAppendMembufferReadRectExp; if (nullptr == pfnAppendMembufferReadRectExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6953,7 +6953,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferEnqueueExp( auto pfnEnqueueExp = context.urDdiTable.CommandBufferExp.pfnEnqueueExp; if (nullptr == pfnEnqueueExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6990,7 +6990,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMImportExp( auto pfnImportExp = context.urDdiTable.USMExp.pfnImportExp; if (nullptr == pfnImportExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -7017,7 +7017,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMReleaseExp( auto pfnReleaseExp = context.urDdiTable.USMExp.pfnReleaseExp; if (nullptr == pfnReleaseExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -7050,7 +7050,7 @@ __urdlllocal ur_result_t UR_APICALL urUsmP2PEnablePeerAccessExp( context.urDdiTable.UsmP2PExp.pfnEnablePeerAccessExp; if (nullptr == pfnEnablePeerAccessExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -7079,7 +7079,7 @@ __urdlllocal ur_result_t UR_APICALL urUsmP2PDisablePeerAccessExp( context.urDdiTable.UsmP2PExp.pfnDisablePeerAccessExp; if (nullptr == pfnDisablePeerAccessExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -7119,7 +7119,7 @@ __urdlllocal ur_result_t UR_APICALL urUsmP2PPeerAccessGetInfoExp( context.urDdiTable.UsmP2PExp.pfnPeerAccessGetInfoExp; if (nullptr == pfnPeerAccessGetInfoExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { From 2ed0d342a2ed1d614ee56e917ebd3f74f82e280c Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Thu, 20 Jul 2023 14:19:03 +0100 Subject: [PATCH 089/104] [ur] Fix urPlatformGetNativeHandle test Do not fail the `urPlatformGetNativeHandleTest.Success` test if adapter returns `UR_RESULT_ERROR_FEATURE_UNSUPPORTED` from `urPlatformGetNativeHandle`. --- test/conformance/platform/urPlatformGetNativeHandle.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/conformance/platform/urPlatformGetNativeHandle.cpp b/test/conformance/platform/urPlatformGetNativeHandle.cpp index 7bf4fb4c0b..1a19cf4918 100644 --- a/test/conformance/platform/urPlatformGetNativeHandle.cpp +++ b/test/conformance/platform/urPlatformGetNativeHandle.cpp @@ -10,7 +10,9 @@ using urPlatformGetNativeHandleTest = uur::platform::urPlatformsTest; TEST_F(urPlatformGetNativeHandleTest, Success) { for (auto platform : platforms) { ur_native_handle_t native_handle = nullptr; - ASSERT_SUCCESS(urPlatformGetNativeHandle(platform, &native_handle)); + if (auto error = urPlatformGetNativeHandle(platform, &native_handle)) { + ASSERT_EQ(UR_RESULT_ERROR_UNSUPPORTED_FEATURE, error); + } } } From f5fbb5e913e5ef8df2d8cf5c1a1febb15bca380e Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Thu, 20 Jul 2023 17:19:16 +0100 Subject: [PATCH 090/104] [ur] Add missing virtual memory support query Introduce the missing `UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT` enumeration for use with `urDeviceGetInfo` to determine if the device supports the virtual memory interfaces. --- include/ur.py | 1 + include/ur_api.h | 1 + scripts/core/device.yml | 2 ++ source/common/ur_params.hpp | 18 ++++++++++++++++++ test/conformance/device/urDeviceGetInfo.cpp | 3 ++- 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/include/ur.py b/include/ur.py index 770e1d68a2..f48acbd21b 100644 --- a/include/ur.py +++ b/include/ur.py @@ -826,6 +826,7 @@ class ur_device_info_v(IntEnum): IP_VERSION = 113 ## [uint32_t] The device IP version. The meaning of the device IP version ## is implementation-defined, but newer devices should have a higher ## version than older devices. + VIRTUAL_MEMORY_SUPPORT = 114 ## [::ur_bool_t] return true if the device supports virtual memory. BINDLESS_IMAGES_SUPPORT_EXP = 0x2000 ## [::ur_bool_t] returns true if the device supports the creation of ## bindless images BINDLESS_IMAGES_SHARED_USM_SUPPORT_EXP = 0x2001 ## [::ur_bool_t] returns true if the device supports the creation of diff --git a/include/ur_api.h b/include/ur_api.h index 9c14872325..1ff0ba0905 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -1453,6 +1453,7 @@ typedef enum ur_device_info_t { UR_DEVICE_INFO_IP_VERSION = 113, ///< [uint32_t] The device IP version. The meaning of the device IP version ///< is implementation-defined, but newer devices should have a higher ///< version than older devices. + UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT = 114, ///< [::ur_bool_t] return true if the device supports virtual memory. UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP = 0x2000, ///< [::ur_bool_t] returns true if the device supports the creation of ///< bindless images UR_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT_EXP = 0x2001, ///< [::ur_bool_t] returns true if the device supports the creation of diff --git a/scripts/core/device.yml b/scripts/core/device.yml index 3697095eea..4fd4b09d93 100644 --- a/scripts/core/device.yml +++ b/scripts/core/device.yml @@ -383,6 +383,8 @@ etors: desc: "[uint32_t] The maximum number of registers available per block." - name: IP_VERSION desc: "[uint32_t] The device IP version. The meaning of the device IP version is implementation-defined, but newer devices should have a higher version than older devices." + - name: VIRTUAL_MEMORY_SUPPORT + desc: "[$x_bool_t] return true if the device supports virtual memory." --- #-------------------------------------------------------------------------- type: function desc: "Retrieves various information about device" diff --git a/source/common/ur_params.hpp b/source/common/ur_params.hpp index 8278d36e04..2f9789506e 100644 --- a/source/common/ur_params.hpp +++ b/source/common/ur_params.hpp @@ -2768,6 +2768,10 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_device_info_t value) { os << "UR_DEVICE_INFO_IP_VERSION"; break; + case UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT: + os << "UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT"; + break; + case UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP: os << "UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP"; break; @@ -4392,6 +4396,20 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; + case UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_bool_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + case UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP: { const ur_bool_t *tptr = (const ur_bool_t *)ptr; if (sizeof(ur_bool_t) > size) { diff --git a/test/conformance/device/urDeviceGetInfo.cpp b/test/conformance/device/urDeviceGetInfo.cpp index 3eb73cb53c..e5e9f7c310 100644 --- a/test/conformance/device/urDeviceGetInfo.cpp +++ b/test/conformance/device/urDeviceGetInfo.cpp @@ -231,7 +231,8 @@ INSTANTIATE_TEST_SUITE_P( UR_DEVICE_INFO_ASYNC_BARRIER, // UR_DEVICE_INFO_MEM_CHANNEL_SUPPORT, // UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED, // - UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP // + UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP, // + UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT // ), [](const ::testing::TestParamInfo &info) { std::stringstream ss; From 8ed1cee7925f0f6da0178c33e07fb6ae1f8f2a69 Mon Sep 17 00:00:00 2001 From: "Vinogradov, Sergei" Date: Mon, 24 Jul 2023 09:25:02 -0400 Subject: [PATCH 091/104] Cosmetic changes in UMF --- .../include/umf/memory_pool.h | 2 +- .../include/umf/memory_provider.h | 6 +++--- .../include/umf/memory_provider_ops.h | 14 +++++++------- .../unified_malloc_framework/src/memory_pool.c | 2 +- .../unified_malloc_framework/src/memory_provider.c | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/source/common/unified_malloc_framework/include/umf/memory_pool.h b/source/common/unified_malloc_framework/include/umf/memory_pool.h index 8c3c2241b5..04c390d7a6 100644 --- a/source/common/unified_malloc_framework/include/umf/memory_pool.h +++ b/source/common/unified_malloc_framework/include/umf/memory_pool.h @@ -32,7 +32,7 @@ struct umf_memory_pool_ops_t; /// \param hPool [out] handle to the newly created memory pool /// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure. /// -enum umf_result_t umfPoolCreate(struct umf_memory_pool_ops_t *ops, +enum umf_result_t umfPoolCreate(const struct umf_memory_pool_ops_t *ops, umf_memory_provider_handle_t *providers, size_t numProviders, void *params, umf_memory_pool_handle_t *hPool); diff --git a/source/common/unified_malloc_framework/include/umf/memory_provider.h b/source/common/unified_malloc_framework/include/umf/memory_provider.h index dd4489d5a9..2e50238238 100644 --- a/source/common/unified_malloc_framework/include/umf/memory_provider.h +++ b/source/common/unified_malloc_framework/include/umf/memory_provider.h @@ -28,8 +28,8 @@ typedef struct umf_memory_provider_t *umf_memory_provider_handle_t; /// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure. /// enum umf_result_t -umfMemoryProviderCreate(struct umf_memory_provider_ops_t *ops, void *params, - umf_memory_provider_handle_t *hProvider); +umfMemoryProviderCreate(const struct umf_memory_provider_ops_t *ops, + void *params, umf_memory_provider_handle_t *hProvider); /// /// \brief Destroys memory provider. @@ -110,7 +110,7 @@ umfMemoryProviderGetMinPageSize(umf_memory_provider_handle_t hProvider, /// /// \brief Discard physical pages within the virtual memory mapping associated at given addr and size. -/// This call is asynchronous and may delay puring the pages indefinitely. +/// This call is asynchronous and may delay purging the pages indefinitely. /// \param hProvider handle to the memory provider /// \param ptr beginning of the virtual memory range /// \param size size of the virtual memory range diff --git a/source/common/unified_malloc_framework/include/umf/memory_provider_ops.h b/source/common/unified_malloc_framework/include/umf/memory_provider_ops.h index 1b795cbad8..216be5437b 100644 --- a/source/common/unified_malloc_framework/include/umf/memory_provider_ops.h +++ b/source/common/unified_malloc_framework/include/umf/memory_provider_ops.h @@ -26,16 +26,16 @@ struct umf_memory_provider_ops_t { uint32_t version; /// - /// \brief Initializes memory pool. - /// \param params pool-specific params - /// \param pool returns pointer to the pool + /// \brief Initializes memory provider. + /// \param params provider-specific params + /// \param provider returns pointer to the provider /// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure. - enum umf_result_t (*initialize)(void *params, void **pool); + enum umf_result_t (*initialize)(void *params, void **provider); /// - /// \brief Finalizes memory pool. - /// \param pool pool to finalize - void (*finalize)(void *pool); + /// \brief Finalizes memory provider. + /// \param provider provider to finalize + void (*finalize)(void *provider); /// Refer to memory_provider.h for description of those functions enum umf_result_t (*alloc)(void *provider, size_t size, size_t alignment, diff --git a/source/common/unified_malloc_framework/src/memory_pool.c b/source/common/unified_malloc_framework/src/memory_pool.c index 222d785079..4a1d16b348 100644 --- a/source/common/unified_malloc_framework/src/memory_pool.c +++ b/source/common/unified_malloc_framework/src/memory_pool.c @@ -38,7 +38,7 @@ destroyMemoryProviderWrappers(umf_memory_provider_handle_t *providers, free(providers); } -enum umf_result_t umfPoolCreate(struct umf_memory_pool_ops_t *ops, +enum umf_result_t umfPoolCreate(const struct umf_memory_pool_ops_t *ops, umf_memory_provider_handle_t *providers, size_t numProviders, void *params, umf_memory_pool_handle_t *hPool) { diff --git a/source/common/unified_malloc_framework/src/memory_provider.c b/source/common/unified_malloc_framework/src/memory_provider.c index 54554f3f9e..8a977e37c5 100644 --- a/source/common/unified_malloc_framework/src/memory_provider.c +++ b/source/common/unified_malloc_framework/src/memory_provider.c @@ -20,8 +20,8 @@ struct umf_memory_provider_t { }; enum umf_result_t -umfMemoryProviderCreate(struct umf_memory_provider_ops_t *ops, void *params, - umf_memory_provider_handle_t *hProvider) { +umfMemoryProviderCreate(const struct umf_memory_provider_ops_t *ops, + void *params, umf_memory_provider_handle_t *hProvider) { umf_memory_provider_handle_t provider = malloc(sizeof(struct umf_memory_provider_t)); if (!provider) { From 788e8afc64ee6107c042289c9ad173378fe3a328 Mon Sep 17 00:00:00 2001 From: Aaron Greig Date: Mon, 24 Jul 2023 17:39:11 +0100 Subject: [PATCH 092/104] Correct ur_usm_desc_t initialization in USM alloc conformance tests. --- test/conformance/usm/urUSMDeviceAlloc.cpp | 6 +++--- test/conformance/usm/urUSMHostAlloc.cpp | 6 +++--- test/conformance/usm/urUSMSharedAlloc.cpp | 14 +++++++------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/test/conformance/usm/urUSMDeviceAlloc.cpp b/test/conformance/usm/urUSMDeviceAlloc.cpp index 5b0d834c44..8fd4742d90 100644 --- a/test/conformance/usm/urUSMDeviceAlloc.cpp +++ b/test/conformance/usm/urUSMDeviceAlloc.cpp @@ -40,11 +40,11 @@ TEST_P(urUSMDeviceAllocTest, SuccessWithDescriptors) { ur_usm_device_desc_t usm_device_desc{UR_STRUCTURE_TYPE_USM_DEVICE_DESC, nullptr, - /* device flags*/ 0}; + /* device flags */ 0}; ur_usm_desc_t usm_desc{UR_STRUCTURE_TYPE_USM_DESC, &usm_device_desc, - /* common usm flags */ 0, - /* mem advice flags*/ UR_USM_ADVICE_FLAG_DEFAULT}; + /* mem advice flags */ UR_USM_ADVICE_FLAG_DEFAULT, + /* alignment */ 0}; void *ptr = nullptr; size_t allocation_size = sizeof(int); ASSERT_SUCCESS(urUSMDeviceAlloc(context, device, &usm_desc, nullptr, diff --git a/test/conformance/usm/urUSMHostAlloc.cpp b/test/conformance/usm/urUSMHostAlloc.cpp index ee27cc85cd..48d1e098d0 100644 --- a/test/conformance/usm/urUSMHostAlloc.cpp +++ b/test/conformance/usm/urUSMHostAlloc.cpp @@ -60,11 +60,11 @@ TEST_P(urUSMHostAllocTest, Success) { TEST_P(urUSMHostAllocTest, SuccessWithDescriptors) { ur_usm_host_desc_t usm_host_desc{UR_STRUCTURE_TYPE_USM_HOST_DESC, nullptr, - /* host flags*/ 0}; + /* host flags */ 0}; ur_usm_desc_t usm_desc{UR_STRUCTURE_TYPE_USM_DESC, &usm_host_desc, - /* common usm flags */ 0, - /* mem advice flags*/ UR_USM_ADVICE_FLAG_DEFAULT}; + /* mem advice flags */ UR_USM_ADVICE_FLAG_DEFAULT, + /* alignment */ 0}; void *ptr = nullptr; size_t allocation_size = sizeof(int); ASSERT_SUCCESS( diff --git a/test/conformance/usm/urUSMSharedAlloc.cpp b/test/conformance/usm/urUSMSharedAlloc.cpp index fc8044d517..5e92183500 100644 --- a/test/conformance/usm/urUSMSharedAlloc.cpp +++ b/test/conformance/usm/urUSMSharedAlloc.cpp @@ -43,15 +43,15 @@ TEST_P(urUSMSharedAllocTest, SuccessWithDescriptors) { ur_usm_device_desc_t usm_device_desc{UR_STRUCTURE_TYPE_USM_DEVICE_DESC, nullptr, - /* device flags*/ 0}; + /* device flags */ 0}; ur_usm_host_desc_t usm_host_desc{UR_STRUCTURE_TYPE_USM_HOST_DESC, &usm_device_desc, - /* host flags*/ 0}; + /* host flags */ 0}; ur_usm_desc_t usm_desc{UR_STRUCTURE_TYPE_USM_DESC, &usm_host_desc, - /* common usm flags */ 0, - /* mem advice flags*/ UR_USM_ADVICE_FLAG_DEFAULT}; + /* mem advice flags */ UR_USM_ADVICE_FLAG_DEFAULT, + /* alignment */ 0}; void *ptr = nullptr; size_t allocation_size = sizeof(int); ASSERT_SUCCESS(urUSMSharedAlloc(context, device, &usm_desc, nullptr, @@ -70,9 +70,9 @@ TEST_P(urUSMSharedAllocTest, SuccessWithDescriptors) { TEST_P(urUSMSharedAllocTest, SuccessWithMultipleAdvices) { ur_usm_desc_t usm_desc{ UR_STRUCTURE_TYPE_USM_DESC, nullptr, - /* common usm flags */ 0, - /* mem advice flags*/ UR_USM_ADVICE_FLAG_SET_READ_MOSTLY | - UR_USM_ADVICE_FLAG_BIAS_CACHED}; + /* mem advice flags */ UR_USM_ADVICE_FLAG_SET_READ_MOSTLY | + UR_USM_ADVICE_FLAG_BIAS_CACHED, + /* alignment */ 0}; void *ptr = nullptr; size_t allocation_size = sizeof(int); ASSERT_SUCCESS(urUSMSharedAlloc(context, device, &usm_desc, nullptr, From 1fb8a21e73f60286a4c43970655331eee7d89f93 Mon Sep 17 00:00:00 2001 From: pbalcer Date: Tue, 25 Jul 2023 10:49:24 +0200 Subject: [PATCH 093/104] [umf] fix the last remaining coverity issue --- test/unified_malloc_framework/memoryPool.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unified_malloc_framework/memoryPool.hpp b/test/unified_malloc_framework/memoryPool.hpp index ab9cc3661c..8c7e665541 100644 --- a/test/unified_malloc_framework/memoryPool.hpp +++ b/test/unified_malloc_framework/memoryPool.hpp @@ -117,7 +117,7 @@ TEST_P(umfMultiPoolTest, memoryTracking) { ASSERT_EQ(pool, expectedPool); } - for (auto p : ptrs) { + for (auto &p : ptrs) { umfFree(std::get<0>(p)); } } From a1ec340a7a48175a2a7a7ec1dd4cb2b24b04518b Mon Sep 17 00:00:00 2001 From: Damian Duy Date: Tue, 23 May 2023 12:25:15 +0200 Subject: [PATCH 094/104] [UMA] add more tests for allocations --- .../include/umf/memory_pool.h | 3 +- test/unified_malloc_framework/common/pool.hpp | 45 +++++ test/unified_malloc_framework/memoryPool.hpp | 183 +++++++++++++++++- .../memoryPoolAPI.cpp | 2 +- 4 files changed, 223 insertions(+), 10 deletions(-) diff --git a/source/common/unified_malloc_framework/include/umf/memory_pool.h b/source/common/unified_malloc_framework/include/umf/memory_pool.h index 8c3c2241b5..8fb9e86d31 100644 --- a/source/common/unified_malloc_framework/include/umf/memory_pool.h +++ b/source/common/unified_malloc_framework/include/umf/memory_pool.h @@ -129,7 +129,8 @@ enum umf_result_t umfFree(void *ptr); enum umf_result_t umfPoolGetLastAllocationError(umf_memory_pool_handle_t hPool); /// -/// \brief Retrieve memory pool associated with a given ptr. +/// \brief Retrieve memory pool associated with a given ptr. Only memory allocated +/// with the usage of a memory provider is being tracked. /// \param ptr pointer to memory belonging to a memory pool /// \return Handle to a memory pool that contains ptr or NULL if pointer does not belong to any UMF pool. umf_memory_pool_handle_t umfPoolByPtr(const void *ptr); diff --git a/test/unified_malloc_framework/common/pool.hpp b/test/unified_malloc_framework/common/pool.hpp index 8eb35ad45c..e6e74afb22 100644 --- a/test/unified_malloc_framework/common/pool.hpp +++ b/test/unified_malloc_framework/common/pool.hpp @@ -31,6 +31,46 @@ auto wrapPoolUnique(umf_memory_pool_handle_t hPool) { return umf::pool_unique_handle_t(hPool, &umfPoolDestroy); } +bool isReallocSupported(umf_memory_pool_handle_t hPool) { + static constexpr size_t allocSize = 1; + bool supported; + auto *ptr = umfPoolMalloc(hPool, allocSize); + auto *new_ptr = umfPoolRealloc(hPool, ptr, allocSize * 2); + + if (new_ptr) { + supported = true; + } else if (umfPoolGetLastAllocationError(hPool) == + UMF_RESULT_ERROR_NOT_SUPPORTED) { + supported = false; + } else { + throw std::runtime_error("realloc failed with unexpected error"); + } + + umfPoolFree(hPool, new_ptr); + + return supported; +} + +bool isCallocSupported(umf_memory_pool_handle_t hPool) { + static constexpr size_t num = 1; + static constexpr size_t size = sizeof(int); + bool supported; + auto *ptr = umfPoolCalloc(hPool, num, size); + + if (ptr) { + supported = true; + } else if (umfPoolGetLastAllocationError(hPool) == + UMF_RESULT_ERROR_NOT_SUPPORTED) { + supported = false; + } else { + throw std::runtime_error("calloc failed with unexpected error"); + } + + umfPoolFree(hPool, ptr); + + return supported; +} + struct pool_base { umf_result_t initialize(umf_memory_provider_handle_t *, size_t) noexcept { return UMF_RESULT_SUCCESS; @@ -97,6 +137,8 @@ struct proxy_pool : public pool_base { } void *realloc(void *ptr, size_t size) noexcept { // TODO: not supported + umf::getPoolLastStatusRef() = + UMF_RESULT_ERROR_NOT_SUPPORTED; return nullptr; } void *aligned_malloc(size_t size, size_t alignment) noexcept { @@ -116,6 +158,9 @@ struct proxy_pool : public pool_base { EXPECT_EQ_NOEXCEPT(ret, UMF_RESULT_SUCCESS); return ret; } + enum umf_result_t get_last_allocation_error() { + return umf::getPoolLastStatusRef(); + } umf_memory_provider_handle_t provider; }; diff --git a/test/unified_malloc_framework/memoryPool.hpp b/test/unified_malloc_framework/memoryPool.hpp index ab9cc3661c..facaa7d73d 100644 --- a/test/unified_malloc_framework/memoryPool.hpp +++ b/test/unified_malloc_framework/memoryPool.hpp @@ -5,9 +5,12 @@ #include "pool.hpp" +#include #include #include #include +#include +#include #ifndef UMF_TEST_MEMORY_POOL_OPS_HPP #define UMF_TEST_MEMORY_POOL_OPS_HPP @@ -30,6 +33,7 @@ struct umfPoolTest : umf_test::test, } umf::pool_unique_handle_t pool; + static constexpr int NTHREADS = 5; }; struct umfMultiPoolTest : umfPoolTest { @@ -57,21 +61,43 @@ TEST_P(umfPoolTest, allocFree) { umfPoolFree(pool.get(), ptr); } -TEST_P(umfPoolTest, pow2AlignedAlloc) { -#ifdef _WIN32 - // TODO: implement support for windows - GTEST_SKIP(); -#endif +TEST_P(umfPoolTest, reallocFree) { + if (!umf_test::isReallocSupported(pool.get())) { + GTEST_SKIP(); + } + static constexpr size_t allocSize = 64; + static constexpr size_t multiplier = 3; + auto *ptr = umfPoolMalloc(pool.get(), allocSize); + ASSERT_NE(ptr, nullptr); + auto *new_ptr = umfPoolRealloc(pool.get(), ptr, allocSize * multiplier); + ASSERT_NE(new_ptr, nullptr); + std::memset(new_ptr, 0, allocSize * multiplier); + umfPoolFree(pool.get(), new_ptr); +} +TEST_P(umfPoolTest, callocFree) { + if (!umf_test::isCallocSupported(pool.get())) { + GTEST_SKIP(); + } + static constexpr size_t num = 10; + static constexpr size_t size = sizeof(int); + auto *ptr = umfPoolCalloc(pool.get(), num, size); + ASSERT_NE(ptr, nullptr); + for (size_t i = 0; i < num; ++i) { + ASSERT_EQ(((int *)ptr)[i], 0); + } + umfPoolFree(pool.get(), ptr); +} + +void pow2AlignedAllocHelper(umf_memory_pool_handle_t pool) { static constexpr size_t maxAlignment = (1u << 22); static constexpr size_t numAllocs = 4; - for (size_t alignment = 1; alignment <= maxAlignment; alignment <<= 1) { std::cout << alignment << std::endl; std::vector allocs; for (size_t alloc = 0; alloc < numAllocs; alloc++) { - auto *ptr = umfPoolAlignedMalloc(pool.get(), alignment, alignment); + auto *ptr = umfPoolAlignedMalloc(pool, alignment, alignment); ASSERT_NE(ptr, nullptr); ASSERT_TRUE(reinterpret_cast(ptr) % alignment == 0); std::memset(ptr, 0, alignment); @@ -79,11 +105,152 @@ TEST_P(umfPoolTest, pow2AlignedAlloc) { } for (auto &ptr : allocs) { - umfPoolFree(pool.get(), ptr); + umfPoolFree(pool, ptr); } } } +TEST_P(umfPoolTest, pow2AlignedAlloc) { +#ifdef _WIN32 + // TODO: implement support for windows + GTEST_SKIP(); +#endif + pow2AlignedAllocHelper(pool.get()); +} + +TEST_P(umfPoolTest, freeNullptr) { + void *ptr = nullptr; + auto ret = umfPoolFree(pool.get(), ptr); + ASSERT_EQ(ret, UMF_RESULT_SUCCESS); +} + +TEST_P(umfPoolTest, multiThreadedMallocFree) { + static constexpr size_t allocSize = 64; + auto poolMalloc = [](size_t allocSize, umf_memory_pool_handle_t pool) { + std::vector allocations; + for (size_t i = 0; i <= 10; ++i) { + allocations.emplace_back(umfPoolMalloc(pool, allocSize)); + ASSERT_NE(allocations.back(), nullptr); + } + + for (auto allocation : allocations) { + umfPoolFree(pool, allocation); + } + }; + + std::vector threads; + for (int i = 0; i < NTHREADS; i++) { + threads.emplace_back(poolMalloc, allocSize, pool.get()); + ; + } + + for (auto &thread : threads) { + thread.join(); + } +} + +TEST_P(umfPoolTest, multiThreadedpow2AlignedAlloc) { +#ifdef _WIN32 + // TODO: implement support for windows + GTEST_SKIP(); +#endif + + auto poolpow2AlignedAlloc = [](umf_memory_pool_handle_t pool) { + pow2AlignedAllocHelper(pool); + }; + + std::vector threads; + for (int i = 0; i < NTHREADS; i++) { + threads.emplace_back(poolpow2AlignedAlloc, pool.get()); + } + + for (auto &thread : threads) { + thread.join(); + } +} + +TEST_P(umfPoolTest, multiThreadedReallocFree) { + if (!umf_test::isReallocSupported(pool.get())) { + GTEST_SKIP(); + } + static constexpr size_t allocSize = 64; + static constexpr size_t multiplier = 3; + auto poolRealloc = [](size_t allocSize, size_t multiplier, + umf_memory_pool_handle_t pool) { + std::vector allocations; + for (size_t i = 0; i <= 10; ++i) { + allocations.emplace_back(umfPoolMalloc(pool, allocSize)); + ASSERT_NE(allocations.back(), nullptr); + } + + for (auto allocation : allocations) { + auto *ptr = + umfPoolRealloc(pool, allocation, allocSize * multiplier); + umfPoolFree(pool, ptr); + } + }; + + std::vector threads; + for (int i = 0; i < NTHREADS; i++) { + threads.emplace_back(poolRealloc, allocSize, multiplier, pool.get()); + } + + for (auto &thread : threads) { + thread.join(); + } +} + +TEST_P(umfPoolTest, multiThreadedCallocFree) { + if (!umf_test::isCallocSupported(pool.get())) { + GTEST_SKIP(); + } + static constexpr size_t num = 10; + auto poolCalloc = [](size_t num, size_t size, + umf_memory_pool_handle_t pool) { + std::vector allocations; + for (size_t i = 0; i <= 10; ++i) { + allocations.emplace_back(umfPoolCalloc(pool, num, size)); + ASSERT_NE(allocations.back(), nullptr); + } + + for (auto allocation : allocations) { + umfPoolFree(pool, allocation); + } + }; + + std::vector threads; + for (int i = 0; i < NTHREADS; i++) { + threads.emplace_back(poolCalloc, num, sizeof(int), pool.get()); + } + + for (auto &thread : threads) { + thread.join(); + } +} + +TEST_P(umfPoolTest, multiThreadedMallocFreeRandomSizes) { + auto poolMalloc = [](size_t allocSize, umf_memory_pool_handle_t pool) { + std::vector allocations; + for (size_t i = 0; i <= 10; ++i) { + allocations.emplace_back(umfPoolMalloc(pool, allocSize)); + ASSERT_NE(allocations.back(), nullptr); + } + + for (auto allocation : allocations) { + umfPoolFree(pool, allocation); + } + }; + + std::vector threads; + for (int i = 0; i < NTHREADS; i++) { + threads.emplace_back(poolMalloc, rand() % 64 + 1, pool.get()); + } + + for (auto &thread : threads) { + thread.join(); + } +} + // TODO: add similar tests for realloc/aligned_alloc, etc. // TODO: add multithreaded tests TEST_P(umfMultiPoolTest, memoryTracking) { diff --git a/test/unified_malloc_framework/memoryPoolAPI.cpp b/test/unified_malloc_framework/memoryPoolAPI.cpp index d7fbe8efe2..cfbe068719 100644 --- a/test/unified_malloc_framework/memoryPoolAPI.cpp +++ b/test/unified_malloc_framework/memoryPoolAPI.cpp @@ -82,7 +82,7 @@ TEST_F(test, memoryPoolTrace) { ASSERT_EQ(providerCalls.size(), provider_call_count); ret = umfPoolGetLastAllocationError(tracingPool.get()); - ASSERT_EQ(ret, UMF_RESULT_SUCCESS); + ASSERT_EQ(ret, UMF_RESULT_ERROR_NOT_SUPPORTED); ASSERT_EQ(poolCalls["get_last_native_error"], 1); ASSERT_EQ(poolCalls.size(), ++pool_call_count); From 95a5ab35194036724ba593e150afbee076841d6c Mon Sep 17 00:00:00 2001 From: Aaron Greig Date: Tue, 25 Jul 2023 17:22:37 +0100 Subject: [PATCH 095/104] Fix shadowing in USM pool test fixture, correct assertion in PoolRetain test. --- test/conformance/testing/include/uur/fixtures.h | 1 - test/conformance/usm/urUSMPoolRetain.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/test/conformance/testing/include/uur/fixtures.h b/test/conformance/testing/include/uur/fixtures.h index 4c50c3c927..7765e00ade 100644 --- a/test/conformance/testing/include/uur/fixtures.h +++ b/test/conformance/testing/include/uur/fixtures.h @@ -635,7 +635,6 @@ struct urUSMPoolTest : urContextTest { UUR_RETURN_ON_FATAL_FAILURE(urContextTest::SetUp()); ur_usm_pool_desc_t pool_desc{UR_STRUCTURE_TYPE_USM_POOL_DESC, nullptr, UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK}; - ur_usm_pool_handle_t pool = nullptr; ASSERT_SUCCESS(urUSMPoolCreate(this->context, &pool_desc, &pool)); } diff --git a/test/conformance/usm/urUSMPoolRetain.cpp b/test/conformance/usm/urUSMPoolRetain.cpp index 1e961a5989..17d36308be 100644 --- a/test/conformance/usm/urUSMPoolRetain.cpp +++ b/test/conformance/usm/urUSMPoolRetain.cpp @@ -25,7 +25,7 @@ TEST_P(urUSMPoolRetainTest, Success) { uint32_t afterRefCount = 0; ASSERT_SUCCESS(uur::GetObjectReferenceCount(pool, afterRefCount)); - ASSERT_LT(afterRefCount, prevRefCount); + ASSERT_LT(afterRefCount, refCount); } TEST_P(urUSMPoolRetainTest, InvalidNullHandlePool) { From f09ed0370262cfb883fa432d8991feb3092b7d40 Mon Sep 17 00:00:00 2001 From: Krzysztof Swiecicki Date: Mon, 24 Jul 2023 14:41:20 +0200 Subject: [PATCH 096/104] [umf] Make pool tracking optional This adds a new CMake option 'UMF_ENABLE_POOL_TRACKING' that enables pool tracking in UMF. Pool tracking is turned off by default. The pool tracking tests were wrapped around the compile definition 'UMF_ENABLE_POOL_TRACKING_TESTS'. --- CMakeLists.txt | 1 + .../unified_malloc_framework/CMakeLists.txt | 6 + .../src/memory_pool.c | 118 +---------------- .../src/memory_pool_default.c | 93 +++++++++++++ .../src/memory_pool_internal.h | 37 ++++++ .../src/memory_pool_tracking.c | 122 ++++++++++++++++++ test/unified_malloc_framework/CMakeLists.txt | 3 + test/unified_malloc_framework/memoryPool.hpp | 2 + .../memoryPoolAPI.cpp | 1 + .../umf_pools/disjoint_pool.cpp | 3 +- 10 files changed, 268 insertions(+), 118 deletions(-) create mode 100644 source/common/unified_malloc_framework/src/memory_pool_default.c create mode 100644 source/common/unified_malloc_framework/src/memory_pool_internal.h create mode 100644 source/common/unified_malloc_framework/src/memory_pool_tracking.c diff --git a/CMakeLists.txt b/CMakeLists.txt index fa5f48ea77..84404d1108 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,7 @@ option(UMF_BUILD_SHARED_LIBRARY "Build UMF as shared library" OFF) option(UR_ENABLE_TRACING "enable api tracing through xpti" OFF) option(VAL_USE_LIBBACKTRACE_BACKTRACE "enable libbacktrace validation backtrace for linux" OFF) option(UR_BUILD_TOOLS "build ur tools" ON) +option(UMF_ENABLE_POOL_TRACKING "Build UMF with pool tracking" OFF) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) diff --git a/source/common/unified_malloc_framework/CMakeLists.txt b/source/common/unified_malloc_framework/CMakeLists.txt index e73374d4eb..15744605ec 100644 --- a/source/common/unified_malloc_framework/CMakeLists.txt +++ b/source/common/unified_malloc_framework/CMakeLists.txt @@ -22,6 +22,12 @@ else() ${UMF_SOURCES}) endif() +if (UMF_ENABLE_POOL_TRACKING) + target_sources(unified_malloc_framework PRIVATE src/memory_pool_tracking.c) +else() + target_sources(unified_malloc_framework PRIVATE src/memory_pool_default.c) +endif() + add_library(${PROJECT_NAME}::unified_malloc_framework ALIAS unified_malloc_framework) target_include_directories(unified_malloc_framework PUBLIC include) diff --git a/source/common/unified_malloc_framework/src/memory_pool.c b/source/common/unified_malloc_framework/src/memory_pool.c index 4a1d16b348..7b88b2f7d6 100644 --- a/source/common/unified_malloc_framework/src/memory_pool.c +++ b/source/common/unified_malloc_framework/src/memory_pool.c @@ -8,8 +8,7 @@ * */ -#include "memory_provider_internal.h" -#include "memory_tracker.h" +#include "memory_pool_internal.h" #include #include @@ -17,87 +16,6 @@ #include #include -struct umf_memory_pool_t { - void *pool_priv; - struct umf_memory_pool_ops_t ops; - - // Holds array of memory providers. All providers are wrapped - // by memory tracking providers (owned and released by UMF). - umf_memory_provider_handle_t *providers; - - size_t numProviders; -}; - -static void -destroyMemoryProviderWrappers(umf_memory_provider_handle_t *providers, - size_t numProviders) { - for (size_t i = 0; i < numProviders; i++) { - umfMemoryProviderDestroy(providers[i]); - } - - free(providers); -} - -enum umf_result_t umfPoolCreate(const struct umf_memory_pool_ops_t *ops, - umf_memory_provider_handle_t *providers, - size_t numProviders, void *params, - umf_memory_pool_handle_t *hPool) { - if (!numProviders || !providers) { - return UMF_RESULT_ERROR_INVALID_ARGUMENT; - } - - enum umf_result_t ret = UMF_RESULT_SUCCESS; - umf_memory_pool_handle_t pool = malloc(sizeof(struct umf_memory_pool_t)); - if (!pool) { - return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; - } - - assert(ops->version == UMF_VERSION_CURRENT); - - pool->providers = - calloc(numProviders, sizeof(umf_memory_provider_handle_t)); - if (!pool->providers) { - ret = UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; - goto err_providers_alloc; - } - - size_t providerInd = 0; - pool->numProviders = numProviders; - - // Wrap each provider with memory tracking provider. - for (providerInd = 0; providerInd < numProviders; providerInd++) { - ret = umfTrackingMemoryProviderCreate(providers[providerInd], pool, - &pool->providers[providerInd]); - if (ret != UMF_RESULT_SUCCESS) { - goto err_providers_init; - } - } - - pool->ops = *ops; - ret = ops->initialize(pool->providers, pool->numProviders, params, - &pool->pool_priv); - if (ret != UMF_RESULT_SUCCESS) { - goto err_pool_init; - } - - *hPool = pool; - return UMF_RESULT_SUCCESS; - -err_pool_init: -err_providers_init: - destroyMemoryProviderWrappers(pool->providers, providerInd); -err_providers_alloc: - free(pool); - - return ret; -} - -void umfPoolDestroy(umf_memory_pool_handle_t hPool) { - hPool->ops.finalize(hPool->pool_priv); - destroyMemoryProviderWrappers(hPool->providers, hPool->numProviders); - free(hPool); -} - void *umfPoolMalloc(umf_memory_pool_handle_t hPool, size_t size) { return hPool->ops.malloc(hPool->pool_priv, size); } @@ -123,41 +41,7 @@ enum umf_result_t umfPoolFree(umf_memory_pool_handle_t hPool, void *ptr) { return hPool->ops.free(hPool->pool_priv, ptr); } -enum umf_result_t umfFree(void *ptr) { - umf_memory_pool_handle_t hPool = umfPoolByPtr(ptr); - if (hPool) { - return umfPoolFree(hPool, ptr); - } - return UMF_RESULT_SUCCESS; -} - enum umf_result_t umfPoolGetLastAllocationError(umf_memory_pool_handle_t hPool) { return hPool->ops.get_last_allocation_error(hPool->pool_priv); } - -umf_memory_pool_handle_t umfPoolByPtr(const void *ptr) { - return umfMemoryTrackerGetPool(umfMemoryTrackerGet(), ptr); -} - -enum umf_result_t -umfPoolGetMemoryProviders(umf_memory_pool_handle_t hPool, size_t numProviders, - umf_memory_provider_handle_t *hProviders, - size_t *numProvidersRet) { - if (hProviders && numProviders < hPool->numProviders) { - return UMF_RESULT_ERROR_INVALID_ARGUMENT; - } - - if (numProvidersRet) { - *numProvidersRet = hPool->numProviders; - } - - if (hProviders) { - for (size_t i = 0; i < hPool->numProviders; i++) { - umfTrackingMemoryProviderGetUpstreamProvider( - umfMemoryProviderGetPriv(hPool->providers[i]), hProviders + i); - } - } - - return UMF_RESULT_SUCCESS; -} diff --git a/source/common/unified_malloc_framework/src/memory_pool_default.c b/source/common/unified_malloc_framework/src/memory_pool_default.c new file mode 100644 index 0000000000..2aaa97463a --- /dev/null +++ b/source/common/unified_malloc_framework/src/memory_pool_default.c @@ -0,0 +1,93 @@ +/* + * + * Copyright (C) 2023 Intel Corporation + * + * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. + * See LICENSE.TXT + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + */ + +#include "memory_pool_internal.h" + +#include + +#include +#include + +enum umf_result_t umfPoolCreate(const struct umf_memory_pool_ops_t *ops, + umf_memory_provider_handle_t *providers, + size_t numProviders, void *params, + umf_memory_pool_handle_t *hPool) { + if (!numProviders || !providers) { + return UMF_RESULT_ERROR_INVALID_ARGUMENT; + } + + enum umf_result_t ret = UMF_RESULT_SUCCESS; + umf_memory_pool_handle_t pool = malloc(sizeof(struct umf_memory_pool_t)); + if (!pool) { + return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; + } + + assert(ops->version == UMF_VERSION_CURRENT); + + pool->providers = + calloc(numProviders, sizeof(umf_memory_provider_handle_t)); + if (!pool->providers) { + ret = UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; + goto err_providers_alloc; + } + + size_t providerInd = 0; + pool->numProviders = numProviders; + + for (providerInd = 0; providerInd < numProviders; providerInd++) { + pool->providers[providerInd] = providers[providerInd]; + } + + pool->ops = *ops; + ret = ops->initialize(pool->providers, pool->numProviders, params, + &pool->pool_priv); + if (ret != UMF_RESULT_SUCCESS) { + goto err_pool_init; + } + + *hPool = pool; + return UMF_RESULT_SUCCESS; + +err_pool_init: +err_providers_alloc: + free(pool); + + return ret; +} + +void umfPoolDestroy(umf_memory_pool_handle_t hPool) { + hPool->ops.finalize(hPool->pool_priv); + free(hPool); +} + +enum umf_result_t umfFree(void *ptr) { return UMF_RESULT_ERROR_NOT_SUPPORTED; } + +umf_memory_pool_handle_t umfPoolByPtr(const void *ptr) { return NULL; } + +enum umf_result_t +umfPoolGetMemoryProviders(umf_memory_pool_handle_t hPool, size_t numProviders, + umf_memory_provider_handle_t *hProviders, + size_t *numProvidersRet) { + if (hProviders && numProviders < hPool->numProviders) { + return UMF_RESULT_ERROR_INVALID_ARGUMENT; + } + + if (numProvidersRet) { + *numProvidersRet = hPool->numProviders; + } + + if (hProviders) { + for (size_t i = 0; i < hPool->numProviders; i++) { + hProviders[i] = hPool->providers[i]; + } + } + + return UMF_RESULT_SUCCESS; +} diff --git a/source/common/unified_malloc_framework/src/memory_pool_internal.h b/source/common/unified_malloc_framework/src/memory_pool_internal.h new file mode 100644 index 0000000000..37424fd3bf --- /dev/null +++ b/source/common/unified_malloc_framework/src/memory_pool_internal.h @@ -0,0 +1,37 @@ +/* + * + * Copyright (C) 2023 Intel Corporation + * + * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. + * See LICENSE.TXT + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + */ + +#ifndef UMF_MEMORY_POOL_INTERNAL_H +#define UMF_MEMORY_POOL_INTERNAL_H 1 + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct umf_memory_pool_t { + void *pool_priv; + struct umf_memory_pool_ops_t ops; + + // Holds array of memory providers. All providers are wrapped + // by memory tracking providers (owned and released by UMF). + umf_memory_provider_handle_t *providers; + + size_t numProviders; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* UMF_MEMORY_POOL_INTERNAL_H */ diff --git a/source/common/unified_malloc_framework/src/memory_pool_tracking.c b/source/common/unified_malloc_framework/src/memory_pool_tracking.c new file mode 100644 index 0000000000..033a390fcb --- /dev/null +++ b/source/common/unified_malloc_framework/src/memory_pool_tracking.c @@ -0,0 +1,122 @@ +/* + * + * Copyright (C) 2023 Intel Corporation + * + * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. + * See LICENSE.TXT + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + */ + +#include "memory_pool_internal.h" +#include "memory_provider_internal.h" +#include "memory_tracker.h" + +#include + +#include +#include + +static void +destroyMemoryProviderWrappers(umf_memory_provider_handle_t *providers, + size_t numProviders) { + for (size_t i = 0; i < numProviders; i++) { + umfMemoryProviderDestroy(providers[i]); + } + + free(providers); +} + +enum umf_result_t umfPoolCreate(const struct umf_memory_pool_ops_t *ops, + umf_memory_provider_handle_t *providers, + size_t numProviders, void *params, + umf_memory_pool_handle_t *hPool) { + if (!numProviders || !providers) { + return UMF_RESULT_ERROR_INVALID_ARGUMENT; + } + + enum umf_result_t ret = UMF_RESULT_SUCCESS; + umf_memory_pool_handle_t pool = malloc(sizeof(struct umf_memory_pool_t)); + if (!pool) { + return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; + } + + assert(ops->version == UMF_VERSION_CURRENT); + + pool->providers = + calloc(numProviders, sizeof(umf_memory_provider_handle_t)); + if (!pool->providers) { + ret = UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; + goto err_providers_alloc; + } + + size_t providerInd = 0; + pool->numProviders = numProviders; + + // Wrap each provider with memory tracking provider. + for (providerInd = 0; providerInd < numProviders; providerInd++) { + ret = umfTrackingMemoryProviderCreate(providers[providerInd], pool, + &pool->providers[providerInd]); + if (ret != UMF_RESULT_SUCCESS) { + goto err_providers_init; + } + } + + pool->ops = *ops; + ret = ops->initialize(pool->providers, pool->numProviders, params, + &pool->pool_priv); + if (ret != UMF_RESULT_SUCCESS) { + goto err_pool_init; + } + + *hPool = pool; + return UMF_RESULT_SUCCESS; + +err_pool_init: +err_providers_init: + destroyMemoryProviderWrappers(pool->providers, providerInd); +err_providers_alloc: + free(pool); + + return ret; +} + +void umfPoolDestroy(umf_memory_pool_handle_t hPool) { + hPool->ops.finalize(hPool->pool_priv); + destroyMemoryProviderWrappers(hPool->providers, hPool->numProviders); + free(hPool); +} + +enum umf_result_t umfFree(void *ptr) { + umf_memory_pool_handle_t hPool = umfPoolByPtr(ptr); + if (hPool) { + return umfPoolFree(hPool, ptr); + } + return UMF_RESULT_SUCCESS; +} + +umf_memory_pool_handle_t umfPoolByPtr(const void *ptr) { + return umfMemoryTrackerGetPool(umfMemoryTrackerGet(), ptr); +} + +enum umf_result_t +umfPoolGetMemoryProviders(umf_memory_pool_handle_t hPool, size_t numProviders, + umf_memory_provider_handle_t *hProviders, + size_t *numProvidersRet) { + if (hProviders && numProviders < hPool->numProviders) { + return UMF_RESULT_ERROR_INVALID_ARGUMENT; + } + + if (numProvidersRet) { + *numProvidersRet = hPool->numProviders; + } + + if (hProviders) { + for (size_t i = 0; i < hPool->numProviders; i++) { + umfTrackingMemoryProviderGetUpstreamProvider( + umfMemoryProviderGetPriv(hPool->providers[i]), hProviders + i); + } + } + + return UMF_RESULT_SUCCESS; +} diff --git a/test/unified_malloc_framework/CMakeLists.txt b/test/unified_malloc_framework/CMakeLists.txt index d49082c927..386ea5bdf9 100644 --- a/test/unified_malloc_framework/CMakeLists.txt +++ b/test/unified_malloc_framework/CMakeLists.txt @@ -28,6 +28,9 @@ function(add_umf_test name) COMMAND ${TEST_TARGET_NAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) set_tests_properties(umf-${name} PROPERTIES LABELS "umf") + if (UMF_ENABLE_POOL_TRACKING) + target_compile_definitions(${TEST_TARGET_NAME} PRIVATE UMF_ENABLE_POOL_TRACKING_TESTS=1) + endif() endfunction() add_subdirectory(umf_pools) diff --git a/test/unified_malloc_framework/memoryPool.hpp b/test/unified_malloc_framework/memoryPool.hpp index 813a372b25..006c4b8aed 100644 --- a/test/unified_malloc_framework/memoryPool.hpp +++ b/test/unified_malloc_framework/memoryPool.hpp @@ -251,6 +251,7 @@ TEST_P(umfPoolTest, multiThreadedMallocFreeRandomSizes) { } } +#ifdef UMF_ENABLE_POOL_TRACKING_TESTS // TODO: add similar tests for realloc/aligned_alloc, etc. // TODO: add multithreaded tests TEST_P(umfMultiPoolTest, memoryTracking) { @@ -288,5 +289,6 @@ TEST_P(umfMultiPoolTest, memoryTracking) { umfFree(std::get<0>(p)); } } +#endif /* UMF_ENABLE_POOL_TRACKING_TESTS */ #endif /* UMF_TEST_MEMORY_POOL_OPS_HPP */ diff --git a/test/unified_malloc_framework/memoryPoolAPI.cpp b/test/unified_malloc_framework/memoryPoolAPI.cpp index cfbe068719..99769acab0 100644 --- a/test/unified_malloc_framework/memoryPoolAPI.cpp +++ b/test/unified_malloc_framework/memoryPoolAPI.cpp @@ -148,6 +148,7 @@ INSTANTIATE_TEST_SUITE_P( .second; })); +GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(umfMultiPoolTest); INSTANTIATE_TEST_SUITE_P( mallocMultiPoolTest, umfMultiPoolTest, ::testing::Values([] { return umf::poolMakeUnique( diff --git a/test/unified_malloc_framework/umf_pools/disjoint_pool.cpp b/test/unified_malloc_framework/umf_pools/disjoint_pool.cpp index 5c9584e46d..9e4d4f7ee6 100644 --- a/test/unified_malloc_framework/umf_pools/disjoint_pool.cpp +++ b/test/unified_malloc_framework/umf_pools/disjoint_pool.cpp @@ -64,7 +64,7 @@ TEST_F(test, freeErrorPropagation) { void *ptr = umfPoolMalloc(pool.get(), size); freeReturn = UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC; - auto freeRet = umfFree(ptr); + auto freeRet = umfPoolFree(pool.get(), ptr); EXPECT_EQ(freeRet, freeReturn); } @@ -72,5 +72,6 @@ TEST_F(test, freeErrorPropagation) { INSTANTIATE_TEST_SUITE_P(disjointPoolTests, umfPoolTest, ::testing::Values(makePool)); +GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(umfMultiPoolTest); INSTANTIATE_TEST_SUITE_P(disjointMultiPoolTests, umfMultiPoolTest, ::testing::Values(makePool)); From ff705f5d4f9651faa21aacb604dc4fe8947bd2b7 Mon Sep 17 00:00:00 2001 From: Krzysztof Swiecicki Date: Mon, 24 Jul 2023 15:27:36 +0200 Subject: [PATCH 097/104] Enable UMF pool tracking in github workflows --- .github/workflows/cmake.yml | 7 +++++-- .github/workflows/codeql.yml | 4 ++-- .github/workflows/coverity.yml | 6 +++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index d3fd0e3e5e..8f32e6058b 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -11,6 +11,7 @@ jobs: build_type: [Debug, Release] compiler: [{c: gcc, cxx: g++}] libbacktrace: ['-DVAL_USE_LIBBACKTRACE_BACKTRACE=OFF'] + pool_tracking: ['-DUMF_ENABLE_POOL_TRACKING=ON', '-DUMF_ENABLE_POOL_TRACKING=OFF'] include: - os: 'ubuntu-22.04' build_type: Release @@ -53,9 +54,9 @@ jobs: cd libbacktrace ./configure make - sudo make install + sudo make install cd .. - + - name: Download DPC++ run: | sudo apt install libncurses5 @@ -75,6 +76,7 @@ jobs: -DUR_FORMAT_CPP_STYLE=ON -DUR_DPCXX=${{github.workspace}}/dpcpp_compiler/bin/clang++ ${{matrix.libbacktrace}} + ${{matrix.pool_tracking}} - name: Generate source from spec, check for uncommitted diff if: matrix.os == 'ubuntu-22.04' @@ -153,5 +155,6 @@ jobs: -DCMAKE_BUILD_TYPE=Release -DUR_BUILD_TESTS=ON -DUR_FORMAT_CPP_STYLE=ON + -DUMF_ENABLE_POOL_TRACKING=ON - name: Build run: cmake --build ${{github.workspace}}/build -j $(nproc) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 31bf8d2515..701a3be4a2 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -27,7 +27,7 @@ jobs: run: pip install -r third_party/requirements.txt - name: Configure CMake - run: cmake -B ${{github.workspace}}/build -DUR_DEVELOPER_MODE=ON -DUR_BUILD_TESTS=ON -DUR_ENABLE_TRACING=ON -DUR_BUILD_TOOLS=ON + run: cmake -B ${{github.workspace}}/build -DUR_DEVELOPER_MODE=ON -DUR_BUILD_TESTS=ON -DUR_ENABLE_TRACING=ON -DUR_BUILD_TOOLS=ON -DUMF_ENABLE_POOL_TRACKING=ON - name: Build run: cmake --build ${{github.workspace}}/build -j $(nproc) @@ -61,7 +61,7 @@ jobs: run: python3 -m pip install -r third_party/requirements.txt - name: Configure CMake - run: cmake -B ${{github.workspace}}/build -DCMAKE_POLICY_DEFAULT_CMP0094=NEW -DUR_DEVELOPER_MODE=ON -DUR_BUILD_TESTS=ON -DUR_ENABLE_TRACING=ON -DUR_BUILD_TOOLS=ON + run: cmake -B ${{github.workspace}}/build -DCMAKE_POLICY_DEFAULT_CMP0094=NEW -DUR_DEVELOPER_MODE=ON -DUR_BUILD_TESTS=ON -DUR_ENABLE_TRACING=ON -DUR_BUILD_TOOLS=ON -DUMF_ENABLE_POOL_TRACKING=ON - name: Build run: cmake --build ${{github.workspace}}/build -j $(nproc) --config Release diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index 7d825e92a7..ed6cd31ca9 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -26,7 +26,7 @@ jobs: linux: name: Coverity runs-on: ubuntu-latest - + steps: - name: Clone the git repo uses: actions/checkout@v3 @@ -35,12 +35,12 @@ jobs: run: | sudo apt-get update sudo apt-get install -y doxygen - + - name: Install pip packages run: pip install -r third_party/requirements.txt - name: Configure CMake - run: cmake -B $WORKDIR/build -DUR_ENABLE_TRACING=ON -DUR_DEVELOPER_MODE=ON -DUR_BUILD_TESTS=ON -DUR_FORMAT_CPP_STYLE=ON + run: cmake -B $WORKDIR/build -DUR_ENABLE_TRACING=ON -DUR_DEVELOPER_MODE=ON -DUR_BUILD_TESTS=ON -DUR_FORMAT_CPP_STYLE=ON -DUMF_ENABLE_POOL_TRACKING=ON - name: Generate source from spec, check for uncommitted diff run: | From 3621fbe03745e10073d0fbae8a77e1c43e82ce48 Mon Sep 17 00:00:00 2001 From: Weronika Lewandowska Date: Tue, 25 Jul 2023 14:12:08 +0200 Subject: [PATCH 098/104] Add ThreadSanitizer option --- CMakeLists.txt | 5 +++++ README.md | 1 + source/common/ur_util.hpp | 8 +++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fa5f48ea77..c31e9f8ce8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,7 @@ option(UR_FORMAT_CPP_STYLE "format code style of C++ sources" OFF) option(UR_USE_ASAN "enable AddressSanitizer" OFF) option(UR_USE_UBSAN "enable UndefinedBehaviorSanitizer" OFF) option(UR_USE_MSAN "enable MemorySanitizer" OFF) +option(UR_USE_TSAN "enable ThreadSanitizer" OFF) option(UMF_BUILD_SHARED_LIBRARY "Build UMF as shared library" OFF) option(UR_ENABLE_TRACING "enable api tracing through xpti" OFF) option(VAL_USE_LIBBACKTRACE_BACKTRACE "enable libbacktrace validation backtrace for linux" OFF) @@ -116,6 +117,10 @@ if(UR_USE_UBSAN) add_sanitizer_flag(undefined) endif() +if(UR_USE_TSAN) + add_sanitizer_flag(thread) +endif() + if(UR_USE_MSAN) message(WARNING "MemorySanitizer requires that all code is built with its instrumentation, otherwise false positives are possible. diff --git a/README.md b/README.md index 534a198573..b0583f5ba4 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,7 @@ List of options provided by CMake: | UR_FORMAT_CPP_STYLE | Format code style | ON/OFF | OFF | | UR_DEVELOPER_MODE | Treat warnings as errors and enables additional checks | ON/OFF | OFF | | UR_USE_ASAN | Enable AddressSanitizer | ON/OFF | OFF | +| UR_USE_TSAN | Enable ThreadSanitizer | ON/OFF | OFF | | UR_USE_UBSAN | Enable UndefinedBehavior Sanitizer | ON/OFF | OFF | | UR_USE_MSAN | Enable MemorySanitizer (clang only) | ON/OFF | OFF | | UR_ENABLE_TRACING | Enable XPTI-based tracing layer | ON/OFF | OFF | diff --git a/source/common/ur_util.hpp b/source/common/ur_util.hpp index 54617d7c87..8276d10048 100644 --- a/source/common/ur_util.hpp +++ b/source/common/ur_util.hpp @@ -42,13 +42,19 @@ inline int ur_getpid(void) { return static_cast(getpid()); } #define SANITIZER_ADDRESS #endif +/* define for running with memory sanitizer */ +#if CLANG_HAS_FEATURE(thread_sanitizer) || defined(__SANITIZE_THREAD__) +#define SANITIZER_THREAD +#endif + /* define for running with memory sanitizer */ #if CLANG_HAS_FEATURE(memory_sanitizer) #define SANITIZER_MEMORY #endif /* define for running with any sanitizer runtime */ -#if defined(SANITIZER_MEMORY) || defined(SANITIZER_ADDRESS) +#if defined(SANITIZER_MEMORY) || defined(SANITIZER_ADDRESS) || \ + defined(SANITIZER_THREAD) #define SANITIZER_ANY #endif /////////////////////////////////////////////////////////////////////////////// From 30a9cb359dfad82c882d3d9e9a82e3feced2cc83 Mon Sep 17 00:00:00 2001 From: Igor Chorazewicz Date: Wed, 26 Jul 2023 14:03:01 +0000 Subject: [PATCH 099/104] [umf] fix erors reported by ASAN - memory leak in memory_pool_default.c and tests - allocating memory with alignemnt=8 and size%8 != 0 --- .../src/memory_pool_default.c | 2 ++ test/unified_malloc_framework/common/pool.hpp | 13 +++++++------ test/unified_malloc_framework/memoryPool.hpp | 2 +- test/unified_malloc_framework/memoryPoolAPI.cpp | 2 ++ 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/source/common/unified_malloc_framework/src/memory_pool_default.c b/source/common/unified_malloc_framework/src/memory_pool_default.c index 2aaa97463a..be7c4c9c57 100644 --- a/source/common/unified_malloc_framework/src/memory_pool_default.c +++ b/source/common/unified_malloc_framework/src/memory_pool_default.c @@ -56,6 +56,7 @@ enum umf_result_t umfPoolCreate(const struct umf_memory_pool_ops_t *ops, return UMF_RESULT_SUCCESS; err_pool_init: + free(pool->providers); err_providers_alloc: free(pool); @@ -64,6 +65,7 @@ enum umf_result_t umfPoolCreate(const struct umf_memory_pool_ops_t *ops, void umfPoolDestroy(umf_memory_pool_handle_t hPool) { hPool->ops.finalize(hPool->pool_priv); + free(hPool->providers); free(hPool); } diff --git a/test/unified_malloc_framework/common/pool.hpp b/test/unified_malloc_framework/common/pool.hpp index e6e74afb22..7a7b650e11 100644 --- a/test/unified_malloc_framework/common/pool.hpp +++ b/test/unified_malloc_framework/common/pool.hpp @@ -32,42 +32,43 @@ auto wrapPoolUnique(umf_memory_pool_handle_t hPool) { } bool isReallocSupported(umf_memory_pool_handle_t hPool) { - static constexpr size_t allocSize = 1; + static constexpr size_t allocSize = 8; bool supported; auto *ptr = umfPoolMalloc(hPool, allocSize); auto *new_ptr = umfPoolRealloc(hPool, ptr, allocSize * 2); if (new_ptr) { supported = true; + umfPoolFree(hPool, new_ptr); } else if (umfPoolGetLastAllocationError(hPool) == UMF_RESULT_ERROR_NOT_SUPPORTED) { + umfPoolFree(hPool, ptr); supported = false; } else { + umfPoolFree(hPool, new_ptr); throw std::runtime_error("realloc failed with unexpected error"); } - umfPoolFree(hPool, new_ptr); - return supported; } bool isCallocSupported(umf_memory_pool_handle_t hPool) { - static constexpr size_t num = 1; + static constexpr size_t num = 8; static constexpr size_t size = sizeof(int); bool supported; auto *ptr = umfPoolCalloc(hPool, num, size); if (ptr) { supported = true; + umfPoolFree(hPool, ptr); } else if (umfPoolGetLastAllocationError(hPool) == UMF_RESULT_ERROR_NOT_SUPPORTED) { supported = false; } else { + umfPoolFree(hPool, ptr); throw std::runtime_error("calloc failed with unexpected error"); } - umfPoolFree(hPool, ptr); - return supported; } diff --git a/test/unified_malloc_framework/memoryPool.hpp b/test/unified_malloc_framework/memoryPool.hpp index 006c4b8aed..3470058d58 100644 --- a/test/unified_malloc_framework/memoryPool.hpp +++ b/test/unified_malloc_framework/memoryPool.hpp @@ -243,7 +243,7 @@ TEST_P(umfPoolTest, multiThreadedMallocFreeRandomSizes) { std::vector threads; for (int i = 0; i < NTHREADS; i++) { - threads.emplace_back(poolMalloc, rand() % 64 + 1, pool.get()); + threads.emplace_back(poolMalloc, (rand() % 16) * 8, pool.get()); } for (auto &thread : threads) { diff --git a/test/unified_malloc_framework/memoryPoolAPI.cpp b/test/unified_malloc_framework/memoryPoolAPI.cpp index 99769acab0..d40254fbf0 100644 --- a/test/unified_malloc_framework/memoryPoolAPI.cpp +++ b/test/unified_malloc_framework/memoryPoolAPI.cpp @@ -258,6 +258,7 @@ TEST_F(test, getLastFailedMemoryProvider) { auto ptr = umfPoolMalloc(pool.get(), allocSize); ASSERT_NE(ptr, nullptr); ASSERT_EQ(umfGetLastFailedMemoryProvider(), nullptr); + umfPoolFree(pool.get(), ptr); // make provider return an error during allocation allocResult = UMF_RESULT_ERROR_UNKNOWN; @@ -280,6 +281,7 @@ TEST_F(test, getLastFailedMemoryProvider) { ASSERT_EQ(std::string_view( umfMemoryProviderGetName(umfGetLastFailedMemoryProvider())), "provider2"); + umfPoolFree(pool.get(), ptr); // error in another thread should not impact umfGetLastFailedMemoryProvider on this thread allocResult = UMF_RESULT_ERROR_UNKNOWN; From 53c8cb44fef2db000e244a242f763b943bef1850 Mon Sep 17 00:00:00 2001 From: Igor Chorazewicz Date: Thu, 27 Jul 2023 14:13:46 +0000 Subject: [PATCH 100/104] [umf] use alloc sizes that are multiples of 8 to make ASAN happy. By default we are using alignment == 8 and size needs to be a multiple of that. We might consider adding extra tests, specifically for different sizes. --- test/unified_malloc_framework/memoryPool.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/unified_malloc_framework/memoryPool.hpp b/test/unified_malloc_framework/memoryPool.hpp index 3470058d58..fde5954cf8 100644 --- a/test/unified_malloc_framework/memoryPool.hpp +++ b/test/unified_malloc_framework/memoryPool.hpp @@ -255,8 +255,7 @@ TEST_P(umfPoolTest, multiThreadedMallocFreeRandomSizes) { // TODO: add similar tests for realloc/aligned_alloc, etc. // TODO: add multithreaded tests TEST_P(umfMultiPoolTest, memoryTracking) { - static constexpr int allocSizes[] = {1, 2, 4, 8, 16, 20, - 32, 40, 64, 128, 1024, 4096}; + static constexpr int allocSizes[] = {8, 16, 32, 40, 64, 128, 1024, 4096}; static constexpr auto nAllocs = 256; std::mt19937_64 g(0); From d8922f8523a3aeaa990ca8da489ad7b3b8354688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Stolarczuk?= Date: Tue, 11 Jul 2023 14:08:23 +0200 Subject: [PATCH 101/104] Add first Docker image recipe This image can be used in CI or as a development container. --- .github/docker/README.md | 42 ++++++++++++++++ .github/docker/install_dpcpp.sh | 23 +++++++++ .github/docker/install_libbacktrace.sh | 23 +++++++++ .github/docker/ubuntu-22.04.Dockerfile | 70 ++++++++++++++++++++++++++ 4 files changed, 158 insertions(+) create mode 100644 .github/docker/README.md create mode 100755 .github/docker/install_dpcpp.sh create mode 100755 .github/docker/install_libbacktrace.sh create mode 100644 .github/docker/ubuntu-22.04.Dockerfile diff --git a/.github/docker/README.md b/.github/docker/README.md new file mode 100644 index 0000000000..782dce372e --- /dev/null +++ b/.github/docker/README.md @@ -0,0 +1,42 @@ +# Content + +Dockerfiles and scripts placed in this directory are intended to be used as +development process vehicles and part of continuous integration process. + +Images built out of those recipes may be used with Docker or podman as +development environment. + +# How to build docker image + +To build docker image on local machine execute: + +```sh +docker build -t ur:ubuntu-22.04 -f ./ubuntu-22.04.Dockerfile . +``` + +To set any build time variable (e.g., an optional ARG from docker recipe), add to the command (after `build`), e.g.: + +```sh + --build-arg SKIP_DPCPP_BUILD=1 +``` + +One other example of using these extra build arguments are proxy settings. They are required for accessing network +(e.g., to download dependencies within docker), if a host is using a proxy server. Example usage: + +```sh + --build-arg https_proxy=http://proxy.com:port --build-arg http_proxy=http://proxy.com:port +``` + +# How to use docker image + +To run docker container (using the previously built image) execute: + +```sh +docker run --shm-size=4G -v /your/workspace/path/:/opt/workspace:z -w /opt/workspace/ -it ur:ubuntu-22.04 /bin/bash +``` + +To set (or override) any docker environment variable, add to the command (after `run`): + +```sh + -e ENV_VARIABLE=VALUE +``` diff --git a/.github/docker/install_dpcpp.sh b/.github/docker/install_dpcpp.sh new file mode 100755 index 0000000000..0aac93eee4 --- /dev/null +++ b/.github/docker/install_dpcpp.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# Copyright (C) 2023 Intel Corporation +# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +# See LICENSE.TXT +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +# +# install_dpcpp.sh - unpacks DPC++ in ${DPCPP_PATH}, to be used while building UR +# + +set -e + +if [ "${SKIP_DPCPP_BUILD}" ]; then + echo "Variable 'SKIP_DPCPP_BUILD' is set; skipping building DPC++" + exit +fi + +apt-get install -y --no-install-recommends \ + libncurses5 + +mkdir -p ${DPCPP_PATH} +wget -O ${DPCPP_PATH}/dpcpp_compiler.tar.gz https://github.com/intel/llvm/releases/download/sycl-nightly%2F20230626/dpcpp-compiler.tar.gz +tar -xvf ${DPCPP_PATH}/dpcpp_compiler.tar.gz -C ${DPCPP_PATH}/ diff --git a/.github/docker/install_libbacktrace.sh b/.github/docker/install_libbacktrace.sh new file mode 100755 index 0000000000..ae364ddb13 --- /dev/null +++ b/.github/docker/install_libbacktrace.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# Copyright (C) 2023 Intel Corporation +# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +# See LICENSE.TXT +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +# +# install_libbacktrace.sh - builds and installs tracing library +# + +set -e + +if [ "${SKIP_LIBBACKTRACE_BUILD}" ]; then + echo "Variable 'SKIP_LIBBACKTRACE_BUILD' is set; skipping building libbacktrace" + exit +fi + +git clone https://github.com/ianlancetaylor/libbacktrace.git +pushd libbacktrace +./configure +make -j$(nproc) +make install -j$(nproc) +popd diff --git a/.github/docker/ubuntu-22.04.Dockerfile b/.github/docker/ubuntu-22.04.Dockerfile new file mode 100644 index 0000000000..38161f5b6e --- /dev/null +++ b/.github/docker/ubuntu-22.04.Dockerfile @@ -0,0 +1,70 @@ +# Copyright (C) 2023 Intel Corporation +# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +# See LICENSE.TXT +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +# +# Dockerfile - image with all Unified Runtime dependencies. +# + +# Pull base image +FROM registry.hub.docker.com/library/ubuntu:22.04 + +# Set environment variables +ENV OS ubuntu +ENV OS_VER 22.04 +ENV NOTTY 1 +ENV DEBIAN_FRONTEND noninteractive + +# Additional parameters to build docker without building components. +# These ARGs can be set in docker building phase and are used +# within bash scripts (executed within docker). +ARG SKIP_DPCPP_BUILD +ARG SKIP_LIBBACKTRACE_BUILD + +# Base development packages +ARG BASE_DEPS="\ + build-essential \ + cmake \ + git" + +# Unified Runtime's dependencies +ARG UR_DEPS="\ + doxygen \ + python3 \ + python3-pip" + +# Unified Runtime's dependencies (installed via pip) +ARG UR_PYTHON_DEPS="\ + clang-format==15.0.7" + +# Miscellaneous for our builds/CI (optional) +ARG MISC_DEPS="\ + clang \ + sudo \ + wget \ + whois" + +# Update and install required packages +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + ${BASE_DEPS} \ + ${UR_DEPS} \ + ${MISC_DEPS} \ + && apt-get clean all + +RUN pip3 install ${UR_PYTHON_DEPS} + +# Install DPC++ +COPY install_dpcpp.sh install_dpcpp.sh +ENV DPCPP_PATH=/opt/dpcpp +RUN ./install_dpcpp.sh + +# Install libbacktrace +COPY install_libbacktrace.sh install_libbacktrace.sh +RUN ./install_libbacktrace.sh + +# Add a new (non-root) 'user' +ENV USER user +ENV USERPASS pass +RUN useradd -m $USER -g sudo -p `mkpasswd $USERPASS` From 6bb7b9dbe605a8c8c313a6b793a31527ad638e62 Mon Sep 17 00:00:00 2001 From: Weronika Lewandowska Date: Mon, 31 Jul 2023 11:18:04 +0200 Subject: [PATCH 102/104] Add security compiler and linker flags --- cmake/helpers.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmake/helpers.cmake b/cmake/helpers.cmake index c25806a1f2..f355592370 100644 --- a/cmake/helpers.cmake +++ b/cmake/helpers.cmake @@ -66,6 +66,7 @@ function(add_ur_target_compile_options name) $<$:-fdiagnostics-color=always> $<$:-fcolor-diagnostics> ) + if (CMAKE_BUILD_TYPE STREQUAL "Release") target_compile_definitions(${name} PRIVATE -D_FORTIFY_SOURCE=2) endif() @@ -81,6 +82,13 @@ function(add_ur_target_compile_options name) /MP /W3 /MD$<$:d> + /GS + ) + add_link_options( + /DYNAMICBASE + /HIGHENTROPYVA + /ALLOWISOLATION + /NXCOMPAT ) if(UR_DEVELOPER_MODE) From be7787796e4e8b46f3c3d5fecdf4995937104341 Mon Sep 17 00:00:00 2001 From: Igor Chorazewicz Date: Mon, 31 Jul 2023 19:30:27 +0000 Subject: [PATCH 103/104] [ur] fix ctad-maybe-unsupported warning that appeared on intel/llvm CI --- source/common/logger/ur_sinks.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/common/logger/ur_sinks.hpp b/source/common/logger/ur_sinks.hpp index e9baac0a89..66322e98a6 100644 --- a/source/common/logger/ur_sinks.hpp +++ b/source/common/logger/ur_sinks.hpp @@ -28,7 +28,7 @@ class Sink { format(buffer, fmt, std::forward(args)...); - std::scoped_lock lock(output_mutex); + std::scoped_lock lock(output_mutex); *ostream << buffer.str(); if (level >= flush_level) { ostream->flush(); From 759e7535732df8f19a3134fc77178a90adf11fdf Mon Sep 17 00:00:00 2001 From: pbalcer Date: Tue, 1 Aug 2023 12:11:49 +0200 Subject: [PATCH 104/104] [ADAPTERS] update to latest from sycl --- CMakeLists.txt | 2 +- source/adapters/CMakeLists.txt | 6 ++++-- source/adapters/cuda/CMakeLists.txt | 10 ++++++---- source/adapters/hip/CMakeLists.txt | 10 ++++++---- source/adapters/level_zero/CMakeLists.txt | 10 ++++++---- .../src/memory_provider_get_last_failed.cpp | 2 +- .../src/memory_provider_internal.h | 2 +- 7 files changed, 25 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1107f0ac3e..9971d3f40d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,7 +91,7 @@ if(UR_ENABLE_TRACING) set(XPTI_DIR ${xpti_SOURCE_DIR}) set(XPTI_ENABLE_TESTS OFF CACHE INTERNAL "Turn off xptifw tests") - FetchContentSparse_Declare(xptifw https://github.com/intel/llvm.git "sycl-nightly/20230304" "xptifw") + FetchContentSparse_Declare(xptifw https://github.com/intel/llvm.git "sycl-nightly/20230703" "xptifw") FetchContent_MakeAvailable(xptifw) diff --git a/source/adapters/CMakeLists.txt b/source/adapters/CMakeLists.txt index c003671e0c..8de581ac68 100644 --- a/source/adapters/CMakeLists.txt +++ b/source/adapters/CMakeLists.txt @@ -4,7 +4,7 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception function(add_ur_adapter name) - add_library(${name} ${ARGN}) + add_ur_library(${name} ${ARGN}) if(MSVC) set(TARGET_LIBNAME ${name}) string(TOUPPER ${TARGET_LIBNAME} TARGET_LIBNAME) @@ -15,6 +15,8 @@ function(add_ur_adapter name) set_target_properties(${name} PROPERTIES LINK_FLAGS "/DEF:${ADAPTER_VERSION_SCRIPT}" ) + elseif(APPLE) + target_compile_options(${name} PRIVATE "-fvisibility=hidden") else() set(TARGET_LIBNAME lib${name}_${PROJECT_VERSION_MAJOR}.0) string(TOUPPER ${TARGET_LIBNAME} TARGET_LIBNAME) @@ -31,7 +33,7 @@ add_subdirectory(null) if(UR_BUILD_ADAPTER_L0 OR UR_BUILD_ADAPTER_CUDA OR UR_BUILD_ADAPTER_HIP) # fetch adapter sources from SYCL set(SYCL_ADAPTER_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external") - FetchSource(https://github.com/intel/llvm.git sycl-nightly/20230717 "sycl/plugins/unified_runtime/ur" ${SYCL_ADAPTER_DIR}) + FetchSource(https://github.com/intel/llvm.git nightly-2023-08-01 "sycl/plugins/unified_runtime/ur" ${SYCL_ADAPTER_DIR}) endif() if(UR_BUILD_ADAPTER_L0) diff --git a/source/adapters/cuda/CMakeLists.txt b/source/adapters/cuda/CMakeLists.txt index 29bdc87152..f85d759c09 100644 --- a/source/adapters/cuda/CMakeLists.txt +++ b/source/adapters/cuda/CMakeLists.txt @@ -10,6 +10,10 @@ set(TARGET_NAME ur_adapter_cuda) add_ur_adapter(${TARGET_NAME} SHARED ${CUDA_DIR}/ur_interface_loader.cpp + ${CUDA_DIR}/adapter.hpp + ${CUDA_DIR}/adapter.cpp + ${CUDA_DIR}/command_buffer.hpp + ${CUDA_DIR}/command_buffer.cpp ${CUDA_DIR}/common.hpp ${CUDA_DIR}/common.cpp ${CUDA_DIR}/context.hpp @@ -33,12 +37,9 @@ add_ur_adapter(${TARGET_NAME} ${CUDA_DIR}/sampler.cpp ${CUDA_DIR}/tracing.cpp ${CUDA_DIR}/usm.cpp + ${CUDA_DIR}/usm_p2p.cpp ${CUDA_DIR}/../../ur.cpp ${CUDA_DIR}/../../ur.hpp - ${CUDA_DIR}/../../usm_allocator.cpp - ${CUDA_DIR}/../../usm_allocator.hpp - ${CUDA_DIR}/../../usm_allocator_config.cpp - ${CUDA_DIR}/../../usm_allocator_config.hpp ) set_target_properties(${TARGET_NAME} PROPERTIES @@ -69,6 +70,7 @@ endif() target_link_libraries(${TARGET_NAME} PRIVATE ${PROJECT_NAME}::headers ${PROJECT_NAME}::common + ${PROJECT_NAME}::unified_malloc_framework Threads::Threads cudadrv ) diff --git a/source/adapters/hip/CMakeLists.txt b/source/adapters/hip/CMakeLists.txt index a014725268..2f205d84e6 100644 --- a/source/adapters/hip/CMakeLists.txt +++ b/source/adapters/hip/CMakeLists.txt @@ -45,6 +45,10 @@ set(HIP_HEADERS "${UR_HIP_INCLUDE_DIR};${UR_HIP_HSA_INCLUDE_DIR}") add_ur_adapter(${TARGET_NAME} SHARED ${HIP_DIR}/ur_interface_loader.cpp + ${HIP_DIR}/adapter.hpp + ${HIP_DIR}/adapter.cpp + ${HIP_DIR}/command_buffer.hpp + ${HIP_DIR}/command_buffer.cpp ${HIP_DIR}/common.hpp ${HIP_DIR}/common.cpp ${HIP_DIR}/context.hpp @@ -67,12 +71,9 @@ add_ur_adapter(${TARGET_NAME} ${HIP_DIR}/sampler.hpp ${HIP_DIR}/sampler.cpp ${HIP_DIR}/usm.cpp + ${HIP_DIR}/usm_p2p.cpp ${HIP_DIR}/../../ur.cpp ${HIP_DIR}/../../ur.hpp - ${HIP_DIR}/../../usm_allocator.cpp - ${HIP_DIR}/../../usm_allocator.hpp - ${HIP_DIR}/../../usm_allocator_config.cpp - ${HIP_DIR}/../../usm_allocator_config.hpp ) if(NOT MSVC) @@ -100,6 +101,7 @@ if("${UR_HIP_PLATFORM}" STREQUAL "AMD") target_link_libraries(${TARGET_NAME} PRIVATE ${PROJECT_NAME}::headers ${PROJECT_NAME}::common + ${PROJECT_NAME}::unified_malloc_framework rocmdrv ) diff --git a/source/adapters/level_zero/CMakeLists.txt b/source/adapters/level_zero/CMakeLists.txt index fa089c4b9a..c361c230d3 100644 --- a/source/adapters/level_zero/CMakeLists.txt +++ b/source/adapters/level_zero/CMakeLists.txt @@ -74,6 +74,10 @@ target_include_directories(LevelZeroLoader-Headers add_ur_adapter(${TARGET_NAME} SHARED ${L0_DIR}/ur_interface_loader.cpp + ${L0_DIR}/adapter.hpp + ${L0_DIR}/adapter.cpp + ${L0_DIR}/command_buffer.hpp + ${L0_DIR}/command_buffer.cpp ${L0_DIR}/common.hpp ${L0_DIR}/context.hpp ${L0_DIR}/device.hpp @@ -91,6 +95,7 @@ add_ur_adapter(${TARGET_NAME} ${L0_DIR}/device.cpp ${L0_DIR}/event.cpp ${L0_DIR}/usm.cpp + ${L0_DIR}/usm_p2p.cpp ${L0_DIR}/memory.cpp ${L0_DIR}/kernel.cpp ${L0_DIR}/platform.cpp @@ -98,10 +103,6 @@ add_ur_adapter(${TARGET_NAME} ${L0_DIR}/queue.cpp ${L0_DIR}/sampler.cpp ${L0_DIR}/../../ur.cpp - ${L0_DIR}/../../usm_allocator.cpp - ${L0_DIR}/../../usm_allocator.hpp - ${L0_DIR}/../../usm_allocator_config.cpp - ${L0_DIR}/../../usm_allocator_config.hpp ) set_target_properties(${TARGET_NAME} PROPERTIES @@ -112,6 +113,7 @@ set_target_properties(${TARGET_NAME} PROPERTIES target_link_libraries(${TARGET_NAME} PRIVATE ${PROJECT_NAME}::headers ${PROJECT_NAME}::common + ${PROJECT_NAME}::unified_malloc_framework LevelZeroLoader LevelZeroLoader-Headers ) diff --git a/source/common/unified_malloc_framework/src/memory_provider_get_last_failed.cpp b/source/common/unified_malloc_framework/src/memory_provider_get_last_failed.cpp index c439213a26..f9af93206a 100644 --- a/source/common/unified_malloc_framework/src/memory_provider_get_last_failed.cpp +++ b/source/common/unified_malloc_framework/src/memory_provider_get_last_failed.cpp @@ -14,7 +14,7 @@ extern "C" { static thread_local umf_memory_provider_handle_t lastFailedProvider = nullptr; -umf_memory_provider_handle_t *umfGetLastFailedMemoryProviderPtr() { +umf_memory_provider_handle_t *umfGetLastFailedMemoryProviderPtr(void) { return &lastFailedProvider; } } diff --git a/source/common/unified_malloc_framework/src/memory_provider_internal.h b/source/common/unified_malloc_framework/src/memory_provider_internal.h index 07befd4b4e..2bad161706 100644 --- a/source/common/unified_malloc_framework/src/memory_provider_internal.h +++ b/source/common/unified_malloc_framework/src/memory_provider_internal.h @@ -18,7 +18,7 @@ extern "C" { #endif void *umfMemoryProviderGetPriv(umf_memory_provider_handle_t hProvider); -umf_memory_provider_handle_t *umfGetLastFailedMemoryProviderPtr(); +umf_memory_provider_handle_t *umfGetLastFailedMemoryProviderPtr(void); #ifdef __cplusplus }