From 193ed131708fe9327885f0b73189d37b76535c3f Mon Sep 17 00:00:00 2001 From: Dmitry Vodoypanov Date: Wed, 14 Jun 2023 08:45:53 -0400 Subject: [PATCH 01/15] [SYCL][UR] Update Unified Runtime tag to support UR_DEVICE_INFO_IP_VERSION This should have been an obvious update of Unified Runtime sources to support UR_DEVICE_INFO_IP_VERSION, required in https://github.com/intel/llvm/pull/9843, but this update brought many API breaks mostly caused by this patch: https://github.com/oneapi-src/unified-runtime/pull/536 --- sycl/plugins/unified_runtime/CMakeLists.txt | 2 +- sycl/plugins/unified_runtime/pi2ur.hpp | 38 ++++++++++++------- .../level_zero/ur_level_zero_device.cpp | 36 +++++++++--------- 3 files changed, 44 insertions(+), 32 deletions(-) diff --git a/sycl/plugins/unified_runtime/CMakeLists.txt b/sycl/plugins/unified_runtime/CMakeLists.txt index e829d012e55b4..c11f7f73cbdfb 100755 --- a/sycl/plugins/unified_runtime/CMakeLists.txt +++ b/sycl/plugins/unified_runtime/CMakeLists.txt @@ -4,7 +4,7 @@ if (NOT DEFINED UNIFIED_RUNTIME_LIBRARY OR NOT DEFINED UNIFIED_RUNTIME_INCLUDE_D include(FetchContent) set(UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git") - set(UNIFIED_RUNTIME_TAG 4a9e53b0d7b15d9b0239864d13999f32e6c73bac) + set(UNIFIED_RUNTIME_TAG 9a9c05762ac672ecaf2c1bca815c54444a6ae457) message(STATUS "Will fetch Unified Runtime from ${UNIFIED_RUNTIME_REPO}") FetchContent_Declare(unified-runtime diff --git a/sycl/plugins/unified_runtime/pi2ur.hpp b/sycl/plugins/unified_runtime/pi2ur.hpp index 4ba4104ce6c3a..70c4247ca1a84 100644 --- a/sycl/plugins/unified_runtime/pi2ur.hpp +++ b/sycl/plugins/unified_runtime/pi2ur.hpp @@ -285,13 +285,13 @@ inline pi_result ur2piDeviceInfoValue(ur_device_info_t ParamName, return Value.convertBitSet(ConvertFunc); } else if (ParamName == UR_DEVICE_INFO_PARTITION_TYPE) { - auto ConvertFunc = [](ur_device_partition_property_t UrValue) { + auto ConvertFunc = [](ur_device_partition_t UrValue) { switch (UrValue) { case UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN: return PI_DEVICE_PARTITION_BY_AFFINITY_DOMAIN; case UR_DEVICE_PARTITION_BY_CSLICE: return PI_EXT_INTEL_DEVICE_PARTITION_BY_CSLICE; - case (ur_device_partition_property_t) + case (ur_device_partition_t) UR_DEVICE_AFFINITY_DOMAIN_FLAG_NEXT_PARTITIONABLE: return (pi_device_partition_property) PI_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE; @@ -299,21 +299,23 @@ inline pi_result ur2piDeviceInfoValue(ur_device_info_t ParamName, die("UR_DEVICE_INFO_PARTITION_TYPE: unhandled value"); } }; - return Value.convertArray(ConvertFunc); - } else if (ParamName == UR_DEVICE_INFO_PARTITION_PROPERTIES) { - auto ConvertFunc = [](ur_device_partition_property_t UrValue) { + return Value + .convertArray( + ConvertFunc); + } else if (ParamName == UR_DEVICE_INFO_SUPPORTED_PARTITIONS) { + auto ConvertFunc = [](ur_device_partition_t UrValue) { switch (UrValue) { case UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN: return PI_DEVICE_PARTITION_BY_AFFINITY_DOMAIN; case UR_DEVICE_PARTITION_BY_CSLICE: return PI_EXT_INTEL_DEVICE_PARTITION_BY_CSLICE; default: - die("UR_DEVICE_INFO_PARTITION_PROPERTIES: unhandled value"); + die("UR_DEVICE_INFO_SUPPORTED_PARTITIONS: unhandled value"); } }; - return Value.convertArray(ConvertFunc); + return Value + .convertArray( + ConvertFunc); } else if (ParamName == UR_DEVICE_INFO_LOCAL_MEM_TYPE) { auto ConvertFunc = [](ur_device_local_mem_type_t UrValue) { switch (UrValue) { @@ -777,7 +779,7 @@ inline pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName, InfoType = UR_DEVICE_INFO_REFERENCE_COUNT; break; case PI_DEVICE_INFO_PARTITION_PROPERTIES: - InfoType = UR_DEVICE_INFO_PARTITION_PROPERTIES; + InfoType = UR_DEVICE_INFO_SUPPORTED_PARTITIONS; break; case PI_DEVICE_INFO_PARTITION_AFFINITY_DOMAIN: InfoType = UR_DEVICE_INFO_PARTITION_AFFINITY_DOMAIN; @@ -1080,7 +1082,7 @@ inline pi_result piDevicePartition( if (!Properties || !Properties[0]) return PI_ERROR_INVALID_VALUE; - ur_device_partition_property_t Property; + ur_device_partition_t Property; switch (Properties[0]) { case PI_DEVICE_PARTITION_EQUALLY: Property = UR_DEVICE_PARTITION_EQUALLY; @@ -1120,12 +1122,20 @@ inline pi_result piDevicePartition( // TODO: correctly terminate the UR properties, see: // https://github.com/oneapi-src/unified-runtime/issues/183 // - ur_device_partition_property_t UrProperties[] = { - ur_device_partition_property_t(Property), Value, 0}; + ur_device_partition_property_t UrProperty; + UrProperty.type = Property; + UrProperty.value.equally = Value; + + ur_device_partition_properties_t UrProperties{ + UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES, + nullptr, + &UrProperty, + 1, + }; auto UrDevice = reinterpret_cast(Device); auto UrSubDevices = reinterpret_cast(SubDevices); - HANDLE_ERRORS(urDevicePartition(UrDevice, UrProperties, NumEntries, + HANDLE_ERRORS(urDevicePartition(UrDevice, &UrProperties, NumEntries, UrSubDevices, NumSubDevices)); return PI_SUCCESS; } diff --git a/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp b/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp index dc21c0f79399f..db75f07f562a7 100644 --- a/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp +++ b/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp @@ -281,7 +281,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( } case UR_DEVICE_INFO_REFERENCE_COUNT: return ReturnValue(uint32_t{Device->RefCount.load()}); - case UR_DEVICE_INFO_PARTITION_PROPERTIES: { + case UR_DEVICE_INFO_SUPPORTED_PARTITIONS: { // SYCL spec says: if this SYCL device cannot be partitioned into at least // two sub devices then the returned vector must be empty. auto Res = Device->Platform->populateDeviceCacheIfNeeded(); @@ -291,7 +291,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( uint32_t ZeSubDeviceCount = Device->SubDevices.size(); if (ZeSubDeviceCount < 2) { - return ReturnValue((ur_device_partition_property_t)0); + return ReturnValue((ur_device_partition_t)0); } bool PartitionedByCSlice = Device->SubDevices[0]->isCCS(); @@ -299,7 +299,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( struct { ur_device_partition_property_t Arr[sizeof...(Partitions) + 1]; } PartitionProperties = { - {Partitions..., ur_device_partition_property_t(0)}}; + {Partitions..., ur_device_partition_t(0)}}; return ReturnValue(PartitionProperties); }; @@ -324,13 +324,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( case UR_DEVICE_INFO_PARTITION_TYPE: { // For root-device there is no partitioning to report. if (!Device->isSubDevice()) - return ReturnValue(ur_device_partition_property_t(0)); + return ReturnValue(ur_device_partition_t(0)); if (Device->isCCS()) { struct { ur_device_partition_property_t Arr[2]; } PartitionProperties = { - {UR_DEVICE_PARTITION_BY_CSLICE, ur_device_partition_property_t(0)}}; + {UR_DEVICE_PARTITION_BY_CSLICE, ur_device_partition_t(0)}}; return ReturnValue(PartitionProperties); } @@ -338,9 +338,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( ur_device_partition_property_t Arr[3]; } PartitionProperties = { {UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, - (ur_device_partition_property_t) + (ur_device_partition_t) UR_DEVICE_AFFINITY_DOMAIN_FLAG_NEXT_PARTITIONABLE, - ur_device_partition_property_t(0)}}; + ur_device_partition_t(0)}}; return ReturnValue(PartitionProperties); } @@ -1088,9 +1088,8 @@ void ZeUSMImportExtension::doZeUSMRelease(ze_driver_handle_t DriverHandle, UR_APIEXPORT ur_result_t UR_APICALL urDevicePartition( ur_device_handle_t Device, ///< [in] handle of the device to partition. - const ur_device_partition_property_t - *Properties, ///< [in] null-terminated array of <$_device_partition_t - ///< enum, value> pairs. + const ur_device_partition_properties_t + *Properties, ///< [in] Device partition properties. uint32_t NumDevices, ///< [in] the number of sub-devices. ur_device_handle_t *OutDevices, ///< [out][optional][range(0, NumDevices)] array of handle @@ -1102,13 +1101,15 @@ UR_APIEXPORT ur_result_t UR_APICALL urDevicePartition( ///< according to the partitioning property. ) { // Other partitioning ways are not supported by Level Zero - if (Properties[0] == UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN) { - if ((Properties[1] != UR_DEVICE_AFFINITY_DOMAIN_FLAG_NEXT_PARTITIONABLE && - Properties[1] != UR_DEVICE_AFFINITY_DOMAIN_FLAG_NUMA)) { + if (Properties->pProperties->type == UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN) { + if ((Properties->pProperties->value.affinity_domain != + UR_DEVICE_AFFINITY_DOMAIN_FLAG_NEXT_PARTITIONABLE && + Properties->pProperties->value.affinity_domain != + UR_DEVICE_AFFINITY_DOMAIN_FLAG_NUMA)) { return UR_RESULT_ERROR_INVALID_VALUE; } - } else if (Properties[0] == UR_DEVICE_PARTITION_BY_CSLICE) { - if (Properties[1] != 0) { + } else if (Properties->pProperties->type == UR_DEVICE_PARTITION_BY_CSLICE) { + if (Properties->pProperties->value.affinity_domain != 0) { return UR_RESULT_ERROR_INVALID_VALUE; } } else { @@ -1132,13 +1133,14 @@ UR_APIEXPORT ur_result_t UR_APICALL urDevicePartition( // UR_L0_EXPOSE_CSLICE_IN_AFFINITY_PARTITIONING overrides that // still expose CSlices in partitioning by affinity domain for compatibility // reasons. - if (Properties[0] == UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN && + if (Properties->pProperties->type == + UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN && !ExposeCSliceInAffinityPartitioning) { if (Device->isSubDevice()) { return 0; } } - if (Properties[0] == UR_DEVICE_PARTITION_BY_CSLICE) { + if (Properties->pProperties->type == UR_DEVICE_PARTITION_BY_CSLICE) { // Not a CSlice-based partitioning. if (!Device->SubDevices[0]->isCCS()) { return 0; From 98cd4389dc286f5e22ab0f632fd8049cfc12062a Mon Sep 17 00:00:00 2001 From: Dmitry Vodoypanov Date: Thu, 15 Jun 2023 08:50:58 -0400 Subject: [PATCH 02/15] Remove UR_DEVICE_AFFINITY_DOMAIN_FLAG_NEXT_PARTITIONABLE case --- sycl/plugins/unified_runtime/pi2ur.hpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sycl/plugins/unified_runtime/pi2ur.hpp b/sycl/plugins/unified_runtime/pi2ur.hpp index 70c4247ca1a84..b7442188f6e50 100644 --- a/sycl/plugins/unified_runtime/pi2ur.hpp +++ b/sycl/plugins/unified_runtime/pi2ur.hpp @@ -291,10 +291,6 @@ inline pi_result ur2piDeviceInfoValue(ur_device_info_t ParamName, return PI_DEVICE_PARTITION_BY_AFFINITY_DOMAIN; case UR_DEVICE_PARTITION_BY_CSLICE: return PI_EXT_INTEL_DEVICE_PARTITION_BY_CSLICE; - case (ur_device_partition_t) - UR_DEVICE_AFFINITY_DOMAIN_FLAG_NEXT_PARTITIONABLE: - return (pi_device_partition_property) - PI_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE; default: die("UR_DEVICE_INFO_PARTITION_TYPE: unhandled value"); } From e714f1ce6f490ea397810e94cc46787305de9f10 Mon Sep 17 00:00:00 2001 From: Dmitry Vodoypanov Date: Thu, 15 Jun 2023 10:55:18 -0400 Subject: [PATCH 03/15] New replace UR_DEVICE_INFO_PARTITION_PROPERTIES -> UR_DEVICE_INFO_SUPPORTED_PARTITIONS --- sycl/plugins/unified_runtime/ur/adapters/cuda/device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/plugins/unified_runtime/ur/adapters/cuda/device.cpp b/sycl/plugins/unified_runtime/ur/adapters/cuda/device.cpp index c364c6f384a49..833e233ea171e 100644 --- a/sycl/plugins/unified_runtime/ur/adapters/cuda/device.cpp +++ b/sycl/plugins/unified_runtime/ur/adapters/cuda/device.cpp @@ -690,7 +690,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, case UR_DEVICE_INFO_PARTITION_MAX_SUB_DEVICES: { return ReturnValue(0u); } - case UR_DEVICE_INFO_PARTITION_PROPERTIES: { + case UR_DEVICE_INFO_SUPPORTED_PARTITIONS: { return ReturnValue(static_cast(0u)); } case UR_DEVICE_INFO_PARTITION_AFFINITY_DOMAIN: { From a68ccaed66a7cef8133808b377930fc3fd9447fc Mon Sep 17 00:00:00 2001 From: Dmitry Vodoypanov Date: Thu, 15 Jun 2023 11:04:57 -0400 Subject: [PATCH 04/15] Fix new formatting --- .../ur/adapters/level_zero/ur_level_zero_device.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp b/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp index db75f07f562a7..60a0ed42d7f6c 100644 --- a/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp +++ b/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp @@ -298,8 +298,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( auto ReturnHelper = [&](auto... Partitions) { struct { ur_device_partition_property_t Arr[sizeof...(Partitions) + 1]; - } PartitionProperties = { - {Partitions..., ur_device_partition_t(0)}}; + } PartitionProperties = {{Partitions..., ur_device_partition_t(0)}}; return ReturnValue(PartitionProperties); }; From 1651402333d7e126aa311cebe2a43a5b045ed840 Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Fri, 16 Jun 2023 16:15:02 +0100 Subject: [PATCH 05/15] Fix cuda adapter after UR bump --- sycl/plugins/unified_runtime/ur/adapters/cuda/device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/plugins/unified_runtime/ur/adapters/cuda/device.cpp b/sycl/plugins/unified_runtime/ur/adapters/cuda/device.cpp index 833e233ea171e..016454c742bb9 100644 --- a/sycl/plugins/unified_runtime/ur/adapters/cuda/device.cpp +++ b/sycl/plugins/unified_runtime/ur/adapters/cuda/device.cpp @@ -1019,7 +1019,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceRetain(ur_device_handle_t hDevice) { } UR_APIEXPORT ur_result_t UR_APICALL -urDevicePartition(ur_device_handle_t, const ur_device_partition_property_t *, +urDevicePartition(ur_device_handle_t, const ur_device_partition_properties_t *, uint32_t, ur_device_handle_t *, uint32_t *) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } From ff5c0fd3f6c40a50f7129cde3766da9bf4c73a66 Mon Sep 17 00:00:00 2001 From: Jaime Arteaga Date: Fri, 16 Jun 2023 12:56:23 -0700 Subject: [PATCH 06/15] Update UR loader Signed-off-by: Jaime Arteaga --- sycl/plugins/unified_runtime/CMakeLists.txt | 2 +- sycl/plugins/unified_runtime/pi2ur.hpp | 4 +++- .../ur/adapters/level_zero/ur_level_zero_kernel.cpp | 3 +++ .../ur/adapters/level_zero/ur_level_zero_platform.cpp | 10 +++++++--- .../ur/adapters/level_zero/ur_loader_interface.cpp | 2 +- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/sycl/plugins/unified_runtime/CMakeLists.txt b/sycl/plugins/unified_runtime/CMakeLists.txt index c4d7e9f86baaa..318059da5eaf9 100755 --- a/sycl/plugins/unified_runtime/CMakeLists.txt +++ b/sycl/plugins/unified_runtime/CMakeLists.txt @@ -4,7 +4,7 @@ if (NOT DEFINED UNIFIED_RUNTIME_LIBRARY OR NOT DEFINED UNIFIED_RUNTIME_INCLUDE_D include(FetchContent) set(UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git") - set(UNIFIED_RUNTIME_TAG 9a9c05762ac672ecaf2c1bca815c54444a6ae457) + set(UNIFIED_RUNTIME_TAG 4136fbb19c37a8aa9d368559a738e2e7cc35033e) message(STATUS "Will fetch Unified Runtime from ${UNIFIED_RUNTIME_REPO}") FetchContent_Declare(unified-runtime diff --git a/sycl/plugins/unified_runtime/pi2ur.hpp b/sycl/plugins/unified_runtime/pi2ur.hpp index e524e01944da5..01db3230385b4 100644 --- a/sycl/plugins/unified_runtime/pi2ur.hpp +++ b/sycl/plugins/unified_runtime/pi2ur.hpp @@ -1920,6 +1920,8 @@ inline pi_result piextKernelSetArgMemObj(pi_kernel Kernel, pi_uint32 ArgIndex, if (ArgValue) UrMemory = reinterpret_cast(*ArgValue); + ur_kernel_arg_mem_obj_properties_t Properties {}; + // We don't yet know the device where this kernel will next be run on. // Thus we can't know the actual memory allocation that needs to be used. // Remember the memory object being used as an argument for this kernel @@ -1931,7 +1933,7 @@ inline pi_result piextKernelSetArgMemObj(pi_kernel Kernel, pi_uint32 ArgIndex, // ur_kernel_handle_t UrKernel = reinterpret_cast(Kernel); - HANDLE_ERRORS(urKernelSetArgMemObj(UrKernel, ArgIndex, UrMemory)); + HANDLE_ERRORS(urKernelSetArgMemObj(UrKernel, ArgIndex, &Properties, UrMemory)); return PI_SUCCESS; } diff --git a/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_kernel.cpp b/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_kernel.cpp index 73111abeb475a..f773850408014 100644 --- a/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_kernel.cpp +++ b/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_kernel.cpp @@ -670,8 +670,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelSetArgSampler( UR_APIEXPORT ur_result_t UR_APICALL urKernelSetArgMemObj( ur_kernel_handle_t Kernel, ///< [in] handle of the kernel object uint32_t ArgIndex, ///< [in] argument index in range [0, num args - 1] + const ur_kernel_arg_mem_obj_properties_t *Properties, ///< [in][optional] pointer to Memory object properties. ur_mem_handle_t ArgValue ///< [in][optional] handle of Memory object. ) { + std::ignore = Properties; + std::scoped_lock Guard(Kernel->Mutex); // The ArgValue may be a NULL pointer in which case a NULL value is used for // the kernel argument declared as a pointer to global or constant memory. diff --git a/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_platform.cpp b/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_platform.cpp index ef2a2bad10b36..c5ad88e6b55b5 100644 --- a/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_platform.cpp +++ b/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_platform.cpp @@ -341,13 +341,17 @@ UR_APIEXPORT ur_result_t UR_APICALL urPlatformCreateWithNativeHandle( return UR_RESULT_ERROR_INVALID_VALUE; } -UR_APIEXPORT ur_result_t UR_APICALL urGetLastResult( +UR_APIEXPORT ur_result_t UR_APICALL +urPlatformGetLastError( ur_platform_handle_t Platform, ///< [in] handle of the platform instance - const char **Message ///< [out] pointer to a string containing adapter - ///< specific result in string representation. + const char **Message, ///< [out] pointer to a C string where the adapter specific error message + ///< will be stored. + int32_t *Error ///< [out] pointer to an integer where the adapter specific error code will + ///< be stored. ) { std::ignore = Platform; std::ignore = Message; + std::ignore = Error; urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } diff --git a/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_loader_interface.cpp b/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_loader_interface.cpp index 0e2c5bc85bf71..280c9d025d702 100644 --- a/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_loader_interface.cpp +++ b/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_loader_interface.cpp @@ -32,7 +32,6 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetGlobalProcAddrTable( } pDdiTable->pfnInit = urInit; - pDdiTable->pfnGetLastResult = urGetLastResult; pDdiTable->pfnTearDown = urTearDown; return retVal; @@ -183,6 +182,7 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetPlatformProcAddrTable( pDdiTable->pfnCreateWithNativeHandle = urPlatformCreateWithNativeHandle; pDdiTable->pfnGetApiVersion = urPlatformGetApiVersion; pDdiTable->pfnGetBackendOption = urPlatformGetBackendOption; + pDdiTable->pfnGetLastError = urPlatformGetLastError; return retVal; } From b74e9a993832f310b5c42463193e66a69a6c3c9a Mon Sep 17 00:00:00 2001 From: Dmitry Vodoypanov Date: Mon, 19 Jun 2023 07:16:26 -0400 Subject: [PATCH 07/15] Fix clang-format --- sycl/plugins/unified_runtime/pi2ur.hpp | 5 +++-- .../ur/adapters/level_zero/ur_level_zero_kernel.cpp | 5 +++-- .../ur/adapters/level_zero/ur_level_zero_platform.cpp | 11 +++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/sycl/plugins/unified_runtime/pi2ur.hpp b/sycl/plugins/unified_runtime/pi2ur.hpp index 01db3230385b4..d757d18a270da 100644 --- a/sycl/plugins/unified_runtime/pi2ur.hpp +++ b/sycl/plugins/unified_runtime/pi2ur.hpp @@ -1920,7 +1920,7 @@ inline pi_result piextKernelSetArgMemObj(pi_kernel Kernel, pi_uint32 ArgIndex, if (ArgValue) UrMemory = reinterpret_cast(*ArgValue); - ur_kernel_arg_mem_obj_properties_t Properties {}; + ur_kernel_arg_mem_obj_properties_t Properties{}; // We don't yet know the device where this kernel will next be run on. // Thus we can't know the actual memory allocation that needs to be used. @@ -1933,7 +1933,8 @@ inline pi_result piextKernelSetArgMemObj(pi_kernel Kernel, pi_uint32 ArgIndex, // ur_kernel_handle_t UrKernel = reinterpret_cast(Kernel); - HANDLE_ERRORS(urKernelSetArgMemObj(UrKernel, ArgIndex, &Properties, UrMemory)); + HANDLE_ERRORS( + urKernelSetArgMemObj(UrKernel, ArgIndex, &Properties, UrMemory)); return PI_SUCCESS; } diff --git a/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_kernel.cpp b/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_kernel.cpp index f773850408014..110d40e8695b6 100644 --- a/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_kernel.cpp +++ b/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_kernel.cpp @@ -669,8 +669,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelSetArgSampler( UR_APIEXPORT ur_result_t UR_APICALL urKernelSetArgMemObj( ur_kernel_handle_t Kernel, ///< [in] handle of the kernel object - uint32_t ArgIndex, ///< [in] argument index in range [0, num args - 1] - const ur_kernel_arg_mem_obj_properties_t *Properties, ///< [in][optional] pointer to Memory object properties. + uint32_t ArgIndex, ///< [in] argument index in range [0, num args - 1] + const ur_kernel_arg_mem_obj_properties_t + *Properties, ///< [in][optional] pointer to Memory object properties. ur_mem_handle_t ArgValue ///< [in][optional] handle of Memory object. ) { std::ignore = Properties; diff --git a/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_platform.cpp b/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_platform.cpp index c5ad88e6b55b5..8bb66da26c9cc 100644 --- a/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_platform.cpp +++ b/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_platform.cpp @@ -341,13 +341,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urPlatformCreateWithNativeHandle( return UR_RESULT_ERROR_INVALID_VALUE; } -UR_APIEXPORT ur_result_t UR_APICALL -urPlatformGetLastError( +UR_APIEXPORT ur_result_t UR_APICALL urPlatformGetLastError( ur_platform_handle_t Platform, ///< [in] handle of the platform instance - const char **Message, ///< [out] pointer to a C string where the adapter specific error message - ///< will be stored. - int32_t *Error ///< [out] pointer to an integer where the adapter specific error code will - ///< be stored. + const char **Message, ///< [out] pointer to a C string where the adapter + ///< specific error message will be stored. + int32_t *Error ///< [out] pointer to an integer where the adapter specific + ///< error code will be stored. ) { std::ignore = Platform; std::ignore = Message; From 78cc1847922f58b7e694c89f2813fd41c8dd58fa Mon Sep 17 00:00:00 2001 From: Dmitry Vodoypanov Date: Mon, 19 Jun 2023 07:42:25 -0400 Subject: [PATCH 08/15] Remove faulty line --- .../unified_runtime/ur/adapters/cuda/ur_interface_loader.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/sycl/plugins/unified_runtime/ur/adapters/cuda/ur_interface_loader.cpp b/sycl/plugins/unified_runtime/ur/adapters/cuda/ur_interface_loader.cpp index c7258ad241373..f8e806b0626a0 100644 --- a/sycl/plugins/unified_runtime/ur/adapters/cuda/ur_interface_loader.cpp +++ b/sycl/plugins/unified_runtime/ur/adapters/cuda/ur_interface_loader.cpp @@ -200,7 +200,6 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetGlobalProcAddrTable( if (UR_RESULT_SUCCESS != result) { return result; } - pDdiTable->pfnGetLastResult = urGetLastResult; pDdiTable->pfnInit = urInit; pDdiTable->pfnTearDown = urTearDown; return UR_RESULT_SUCCESS; From fda70e8cf222cc8bbeb5989c7332cdda2fcfea24 Mon Sep 17 00:00:00 2001 From: Dmitry Vodoypanov Date: Mon, 19 Jun 2023 08:07:40 -0400 Subject: [PATCH 09/15] Fix CUDA part --- sycl/plugins/unified_runtime/ur/adapters/cuda/kernel.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sycl/plugins/unified_runtime/ur/adapters/cuda/kernel.cpp b/sycl/plugins/unified_runtime/ur/adapters/cuda/kernel.cpp index e1d6f9f9a2cd3..f35d23a85e26f 100644 --- a/sycl/plugins/unified_runtime/ur/adapters/cuda/kernel.cpp +++ b/sycl/plugins/unified_runtime/ur/adapters/cuda/kernel.cpp @@ -295,8 +295,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelSetArgPointer( return UR_RESULT_SUCCESS; } -UR_APIEXPORT ur_result_t UR_APICALL urKernelSetArgMemObj( - ur_kernel_handle_t hKernel, uint32_t argIndex, ur_mem_handle_t hArgValue) { +UR_APIEXPORT ur_result_t UR_APICALL +urKernelSetArgMemObj(ur_kernel_handle_t hKernel, uint32_t argIndex, + const ur_kernel_arg_mem_obj_properties_t *Properties, + ur_mem_handle_t hArgValue) { UR_ASSERT(hKernel, UR_RESULT_ERROR_INVALID_NULL_HANDLE); From 6f05d77bcf56420f620bf1426467f35c74893a0a Mon Sep 17 00:00:00 2001 From: Dmitry Vodoypanov Date: Mon, 19 Jun 2023 09:05:00 -0400 Subject: [PATCH 10/15] Try to fix warning on Windows --- .../ur/adapters/level_zero/ur_level_zero_device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp b/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp index 60a0ed42d7f6c..91726a6e7962a 100644 --- a/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp +++ b/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp @@ -298,7 +298,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( auto ReturnHelper = [&](auto... Partitions) { struct { ur_device_partition_property_t Arr[sizeof...(Partitions) + 1]; - } PartitionProperties = {{Partitions..., ur_device_partition_t(0)}}; + } PartitionProperties = {{Partitions..., (ur_device_partition_t)0}}; return ReturnValue(PartitionProperties); }; From bcb001af954e440583831eb4cac727c05ccee5bd Mon Sep 17 00:00:00 2001 From: Dmitry Vodoypanov Date: Mon, 19 Jun 2023 09:34:20 -0400 Subject: [PATCH 11/15] Try to fix warning on Windows --- .../ur/adapters/level_zero/ur_level_zero_device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp b/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp index 91726a6e7962a..163adc82588d7 100644 --- a/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp +++ b/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp @@ -298,7 +298,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( auto ReturnHelper = [&](auto... Partitions) { struct { ur_device_partition_property_t Arr[sizeof...(Partitions) + 1]; - } PartitionProperties = {{Partitions..., (ur_device_partition_t)0}}; + } PartitionProperties = {Partitions...}; return ReturnValue(PartitionProperties); }; From f63349f698066bf6803dfbd7bde0858ff1798eb4 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Tue, 20 Jun 2023 13:04:47 +0200 Subject: [PATCH 12/15] Update ur_level_zero_device.cpp --- .../ur/adapters/level_zero/ur_level_zero_device.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp b/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp index 163adc82588d7..f3dff416b20cf 100644 --- a/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp +++ b/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp @@ -297,8 +297,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( auto ReturnHelper = [&](auto... Partitions) { struct { - ur_device_partition_property_t Arr[sizeof...(Partitions) + 1]; - } PartitionProperties = {Partitions...}; + ur_device_partition_t Arr[sizeof...(Partitions) + 1]; + } PartitionProperties = { + {Partitions..., ur_device_partition_property_t(0)}}; return ReturnValue(PartitionProperties); }; From 7de3364ddc851eaefa1f8e9b0ab5e03f0f5581e3 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Tue, 20 Jun 2023 13:06:03 +0200 Subject: [PATCH 13/15] Update ur_level_zero_device.cpp --- .../ur/adapters/level_zero/ur_level_zero_device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp b/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp index f3dff416b20cf..6f496c71420b9 100644 --- a/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp +++ b/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp @@ -299,7 +299,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( struct { ur_device_partition_t Arr[sizeof...(Partitions) + 1]; } PartitionProperties = { - {Partitions..., ur_device_partition_property_t(0)}}; + {Partitions..., ur_device_partition_t(0)}}; return ReturnValue(PartitionProperties); }; From e06e7b7d1b42c824289b00ff9006ce97e19fccdc Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Tue, 20 Jun 2023 13:17:12 +0200 Subject: [PATCH 14/15] Update ur_level_zero_device.cpp --- .../ur/adapters/level_zero/ur_level_zero_device.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp b/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp index 6f496c71420b9..0be520e2928b6 100644 --- a/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp +++ b/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp @@ -298,8 +298,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( auto ReturnHelper = [&](auto... Partitions) { struct { ur_device_partition_t Arr[sizeof...(Partitions) + 1]; - } PartitionProperties = { - {Partitions..., ur_device_partition_t(0)}}; + } PartitionProperties = {{Partitions..., ur_device_partition_t(0)}}; return ReturnValue(PartitionProperties); }; From 0f3fc479436a041a281ff9c503a2e041b6f19b50 Mon Sep 17 00:00:00 2001 From: Dmitry Vodoypanov Date: Wed, 21 Jun 2023 12:11:04 -0400 Subject: [PATCH 15/15] Fix a warning in pi2ur.hpp --- sycl/plugins/unified_runtime/pi2ur.hpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sycl/plugins/unified_runtime/pi2ur.hpp b/sycl/plugins/unified_runtime/pi2ur.hpp index d757d18a270da..7c0c4e75a31a7 100644 --- a/sycl/plugins/unified_runtime/pi2ur.hpp +++ b/sycl/plugins/unified_runtime/pi2ur.hpp @@ -286,14 +286,15 @@ inline pi_result ur2piDeviceInfoValue(ur_device_info_t ParamName, pi_device_affinity_domain>(ConvertFunc); } else if (ParamName == UR_DEVICE_INFO_PARTITION_TYPE) { auto ConvertFunc = [](ur_device_partition_t UrValue) { - switch (UrValue) { - case UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN: + if (UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN == UrValue) return PI_DEVICE_PARTITION_BY_AFFINITY_DOMAIN; - case UR_DEVICE_PARTITION_BY_CSLICE: + else if (UR_DEVICE_PARTITION_BY_CSLICE == UrValue) return PI_EXT_INTEL_DEVICE_PARTITION_BY_CSLICE; - default: - die("UR_DEVICE_INFO_PARTITION_TYPE: unhandled value"); - } + else if ((ur_device_partition_t) + UR_DEVICE_AFFINITY_DOMAIN_FLAG_NEXT_PARTITIONABLE == UrValue) + return (pi_device_partition_property) + PI_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE; + die("UR_DEVICE_INFO_PARTITION_TYPE: unhandled value"); }; return Value .convertArray(