diff --git a/unified-runtime/source/adapters/level_zero/common/device.cpp b/unified-runtime/source/adapters/level_zero/common/device.cpp index 660946b21be2e..4b1ebef052da5 100644 --- a/unified-runtime/source/adapters/level_zero/common/device.cpp +++ b/unified-runtime/source/adapters/level_zero/common/device.cpp @@ -1551,8 +1551,13 @@ ur_result_t urDeviceGetInfo( } case UR_DEVICE_INFO_KERNEL_LAUNCH_CAPABILITIES: return ReturnValue(UR_KERNEL_LAUNCH_PROPERTIES_FLAG_COOPERATIVE); - case UR_DEVICE_INFO_MEMORY_EXPORT_EXPORTABLE_DEVICE_MEM_EXP: - return ReturnValue(true); + case UR_DEVICE_INFO_MEMORY_EXPORT_EXPORTABLE_DEVICE_MEM_EXP: { + // Only report support if the driver can export device allocations as at + // least one external memory type. + return ReturnValue( + Device->ZeDeviceExternalMemoryProperties->memoryAllocationExportTypes != + 0); + } case UR_DEVICE_INFO_LUID: case UR_DEVICE_INFO_NODE_MASK: { // LUID and Device node mask are only available on Windows. @@ -2126,6 +2131,14 @@ ur_result_t ur_device_handle_t_::initialize(int SubSubDeviceOrdinal, (ZeDevice, &Properties)); }; + ZeDeviceExternalMemoryProperties.Compute = + [ZeDevice](ze_device_external_memory_properties_t &Properties) { + // If the query fails, the export types remain zero-initialized and + // no export support is reported. + ZE_CALL_NOCHECK(zeDeviceGetExternalMemoryProperties, + (ZeDevice, &Properties)); + }; + ZeDeviceCacheProperties.Compute = [ZeDevice](ze_device_cache_properties_t &Properties) { // TODO: Since v1.0 there can be multiple cache properties. diff --git a/unified-runtime/source/adapters/level_zero/common/device.hpp b/unified-runtime/source/adapters/level_zero/common/device.hpp index bca35786d8d51..28c7e8ec0479d 100644 --- a/unified-runtime/source/adapters/level_zero/common/device.hpp +++ b/unified-runtime/source/adapters/level_zero/common/device.hpp @@ -346,6 +346,8 @@ struct ur_device_handle_t_ : ur::level_zero::ur_object_t { ZeDeviceMemoryProperties; ZeCache> ZeDeviceMemoryAccessProperties; + ZeCache> + ZeDeviceExternalMemoryProperties; ZeCache> ZeDeviceCacheProperties; ZeCache> ZeDeviceCacheLinePropertiesExt; diff --git a/unified-runtime/source/adapters/level_zero/common/helpers/shared_helpers.cpp b/unified-runtime/source/adapters/level_zero/common/helpers/shared_helpers.cpp index 2b612b2ee3d5e..b3b132e890d5e 100644 --- a/unified-runtime/source/adapters/level_zero/common/helpers/shared_helpers.cpp +++ b/unified-runtime/source/adapters/level_zero/common/helpers/shared_helpers.cpp @@ -320,6 +320,11 @@ template <> ze_structure_type_t getZeStructureType() { return ZE_STRUCTURE_TYPE_DEVICE_MEMORY_ACCESS_PROPERTIES; } +template <> +ze_structure_type_t +getZeStructureType() { + return ZE_STRUCTURE_TYPE_DEVICE_EXTERNAL_MEMORY_PROPERTIES; +} template <> ze_structure_type_t getZeStructureType() { return ZE_STRUCTURE_TYPE_MODULE_PROPERTIES; }