From b32f726913689206173648c5090a238f923ce180 Mon Sep 17 00:00:00 2001 From: "Neil R. Spruit" Date: Fri, 7 Mar 2025 14:58:25 -0800 Subject: [PATCH] feature: Enable support for reporting bfloat16 conversion support for L0 Related-To: NEO-14316 Signed-off-by: Neil R. Spruit --- .../core/source/driver/driver_handle_imp.cpp | 21 ++++++++++++++++++- .../unit_tests/sources/driver/test_driver.cpp | 8 +++++++ .../test/common/mocks/mock_release_helper.h | 6 +++++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/level_zero/core/source/driver/driver_handle_imp.cpp b/level_zero/core/source/driver/driver_handle_imp.cpp index d5241c85af..530c9b97e9 100644 --- a/level_zero/core/source/driver/driver_handle_imp.cpp +++ b/level_zero/core/source/driver/driver_handle_imp.cpp @@ -23,6 +23,7 @@ #include "shared/source/memory_manager/unified_memory_manager.h" #include "shared/source/os_interface/os_interface.h" #include "shared/source/os_interface/os_library.h" +#include "shared/source/release_helper/release_helper.h" #include "shared/source/utilities/logger.h" #include "level_zero/core/source/builtin/builtin_functions_lib.h" @@ -155,12 +156,30 @@ ze_result_t DriverHandleImp::getExtensionProperties(uint32_t *pCount, std::vector> additionalExtensions; + bool isBfloat16Supported = false; + bool isBindlessHeapsSupported = false; for (const auto device : devices) { + if (device->getNEODevice()->getRootDeviceEnvironment().getReleaseHelper()) { + if (device->getNEODevice()->getRootDeviceEnvironment().getReleaseHelper()->isBFloat16ConversionSupported()) { + isBfloat16Supported = true; + } + } if (device->getNEODevice()->getRootDeviceEnvironment().getBindlessHeapsHelper()) { - additionalExtensions.emplace_back(ZE_BINDLESS_IMAGE_EXP_NAME, ZE_BINDLESS_IMAGE_EXP_VERSION_CURRENT); + isBindlessHeapsSupported = true; + } + if (isBfloat16Supported && isBindlessHeapsSupported) { break; } } + + if (isBindlessHeapsSupported) { + additionalExtensions.emplace_back(ZE_BINDLESS_IMAGE_EXP_NAME, ZE_BINDLESS_IMAGE_EXP_VERSION_CURRENT); + } + + if (isBfloat16Supported) { + additionalExtensions.emplace_back(ZE_BFLOAT16_CONVERSIONS_EXT_NAME, ZE_BFLOAT16_CONVERSIONS_EXT_VERSION_1_0); + } + devices[0]->getL0GfxCoreHelper().appendPlatformSpecificExtensions(additionalExtensions, devices[0]->getProductHelper(), devices[0]->getHwInfo()); if (devices[0]->getL0GfxCoreHelper().synchronizedDispatchSupported() && devices[0]->isImplicitScalingCapable()) { diff --git a/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp b/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp index fcab9cd4a4..33cc8d5c9f 100644 --- a/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp +++ b/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp @@ -25,6 +25,7 @@ #include "shared/test/common/mocks/mock_execution_environment.h" #include "shared/test/common/mocks/mock_io_functions.h" #include "shared/test/common/mocks/mock_os_library.h" +#include "shared/test/common/mocks/mock_release_helper.h" #include "shared/test/common/mocks/mock_sip.h" #include "shared/test/common/mocks/ult_device_factory.h" #include "shared/test/common/test_macros/hw_test.h" @@ -151,6 +152,13 @@ TEST_F(DriverVersionTest, givenCallToGetExtensionPropertiesThenSupportedExtensio if (device->getNEODevice()->getRootDeviceEnvironment().getBindlessHeapsHelper()) { additionalExtensions.emplace_back(ZE_BINDLESS_IMAGE_EXP_NAME, ZE_BINDLESS_IMAGE_EXP_VERSION_CURRENT); } + auto mockReleaseHelperVal = std::unique_ptr(new MockReleaseHelper()); + mockReleaseHelperVal->bFloat16Support = true; + auto &rootDeviceEnvironment = device->getNEODevice()->getRootDeviceEnvironmentRef(); + rootDeviceEnvironment.releaseHelper.reset(mockReleaseHelperVal.release()); + if (device->getNEODevice()->getRootDeviceEnvironment().getReleaseHelper()->isBFloat16ConversionSupported()) { + additionalExtensions.emplace_back(ZE_BFLOAT16_CONVERSIONS_EXT_NAME, ZE_BFLOAT16_CONVERSIONS_EXT_VERSION_1_0); + } if (!device->getProductHelper().isDcFlushAllowed()) { additionalExtensions.emplace_back(ZEX_INTEL_QUEUE_COPY_OPERATIONS_OFFLOAD_HINT_EXP_NAME, ZEX_INTEL_QUEUE_COPY_OPERATIONS_OFFLOAD_HINT_EXP_VERSION_CURRENT); } diff --git a/shared/test/common/mocks/mock_release_helper.h b/shared/test/common/mocks/mock_release_helper.h index 7dfad1d2a0..641b5c8f50 100644 --- a/shared/test/common/mocks/mock_release_helper.h +++ b/shared/test/common/mocks/mock_release_helper.h @@ -21,7 +21,6 @@ class MockReleaseHelper : public ReleaseHelper { ADDMETHOD_CONST_NOBASE(isPipeControlPriorToPipelineSelectWaRequired, bool, false, ()); ADDMETHOD_CONST_NOBASE(isProgramAllStateComputeCommandFieldsWARequired, bool, false, ()); ADDMETHOD_CONST_NOBASE(isSplitMatrixMultiplyAccumulateSupported, bool, false, ()); - ADDMETHOD_CONST_NOBASE(isBFloat16ConversionSupported, bool, false, ()); ADDMETHOD_CONST_NOBASE(isAuxSurfaceModeOverrideRequired, bool, false, ()); ADDMETHOD_CONST_NOBASE(isResolvingSubDeviceIDNeeded, bool, false, ()); ADDMETHOD_CONST_NOBASE(isDirectSubmissionSupported, bool, false, ()); @@ -48,5 +47,10 @@ class MockReleaseHelper : public ReleaseHelper { static SizeToPreferredSlmValueArray sizeToPreferredSlmValue = {}; return sizeToPreferredSlmValue; } + + bool isBFloat16ConversionSupported() const override { + return bFloat16Support; + } + bool bFloat16Support = false; }; } // namespace NEO