From cb6823b1bdfd3660960e2b5e297067e4637350b9 Mon Sep 17 00:00:00 2001 From: Raiyan Latif Date: Wed, 27 May 2020 15:46:19 -0700 Subject: [PATCH] Allow for overriding the reported FP64 support in L0 Change-Id: Ib876e00e198c07dbae7b921e1e7dc2b142aee049 Signed-off-by: Raiyan Latif --- level_zero/core/source/device/device_imp.cpp | 17 ++++++-- .../unit_tests/sources/device/test_device.cpp | 39 +++++++++++++++++++ 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/level_zero/core/source/device/device_imp.cpp b/level_zero/core/source/device/device_imp.cpp index ff873fb007..10ba8881e4 100644 --- a/level_zero/core/source/device/device_imp.cpp +++ b/level_zero/core/source/device/device_imp.cpp @@ -42,6 +42,10 @@ #include "hw_helpers.h" +namespace NEO { +bool releaseFP64Override(); +} // namespace NEO + namespace L0 { uint32_t DeviceImp::getRootDeviceIndex() { @@ -286,10 +290,17 @@ ze_result_t DeviceImp::getKernelProperties(ze_device_kernel_properties_t *pKerne pKernelProperties->fp16Supported = true; pKernelProperties->int64AtomicsSupported = hardwareInfo.capabilityTable.ftrSupportsInteger64BitAtomics; - pKernelProperties->fp64Supported = hardwareInfo.capabilityTable.ftrSupportsFP64; pKernelProperties->halfFpCapabilities = defaultFpFlags; - pKernelProperties->singleFpCapabilities = hardwareInfo.capabilityTable.ftrSupports64BitMath ? ZE_FP_CAPS_ROUNDED_DIVIDE_SQRT : ZE_FP_CAPS_NONE; - pKernelProperties->doubleFpCapabilities = hardwareInfo.capabilityTable.ftrSupportsFP64 ? defaultFpFlags : ZE_FP_CAPS_NONE; + + if (NEO::releaseFP64Override() || NEO::DebugManager.flags.OverrideDefaultFP64Settings.get() == 1) { + pKernelProperties->fp64Supported = true; + pKernelProperties->singleFpCapabilities = ZE_FP_CAPS_ROUNDED_DIVIDE_SQRT; + pKernelProperties->doubleFpCapabilities = defaultFpFlags; + } else { + pKernelProperties->fp64Supported = hardwareInfo.capabilityTable.ftrSupportsFP64; + pKernelProperties->singleFpCapabilities = hardwareInfo.capabilityTable.ftrSupports64BitMath ? ZE_FP_CAPS_ROUNDED_DIVIDE_SQRT : ZE_FP_CAPS_NONE; + pKernelProperties->doubleFpCapabilities = hardwareInfo.capabilityTable.ftrSupportsFP64 ? defaultFpFlags : ZE_FP_CAPS_NONE; + } pKernelProperties->nativeKernelSupported.id[0] = 0; diff --git a/level_zero/core/test/unit_tests/sources/device/test_device.cpp b/level_zero/core/test/unit_tests/sources/device/test_device.cpp index 2cdd38ff3d..32a3175541 100644 --- a/level_zero/core/test/unit_tests/sources/device/test_device.cpp +++ b/level_zero/core/test/unit_tests/sources/device/test_device.cpp @@ -156,6 +156,45 @@ TEST_F(DeviceTest, givenDevicePropertiesStructureWhenDevicePropertiesCalledThenA EXPECT_NE(0, memcmp(&deviceProperties.name, &devicePropertiesBefore.name, sizeof(devicePropertiesBefore.name))); } +struct DeviceHasNoDoubleFp64Test : public ::testing::Test { + void SetUp() override { + DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices); + HardwareInfo nonFp64Device = *defaultHwInfo; + nonFp64Device.capabilityTable.ftrSupportsFP64 = false; + nonFp64Device.capabilityTable.ftrSupports64BitMath = false; + neoDevice = NEO::MockDevice::createWithNewExecutionEnvironment(&nonFp64Device, rootDeviceIndex); + NEO::DeviceVector devices; + devices.push_back(std::unique_ptr(neoDevice)); + driverHandle = std::make_unique>(); + driverHandle->initialize(std::move(devices)); + device = driverHandle->devices[0]; + } + + DebugManagerStateRestore restorer; + std::unique_ptr> driverHandle; + NEO::Device *neoDevice = nullptr; + L0::Device *device = nullptr; + const uint32_t rootDeviceIndex = 1u; + const uint32_t numRootDevices = 2u; +}; + +TEST_F(DeviceHasNoDoubleFp64Test, givenDeviceThatDoesntHaveFp64WhenDbgFlagEnablesFp64ThenReportFp64Flags) { + ze_device_kernel_properties_t kernelProperties; + memset(&kernelProperties, std::numeric_limits::max(), sizeof(ze_device_kernel_properties_t)); + + device->getKernelProperties(&kernelProperties); + EXPECT_EQ(ZE_FP_CAPS_NONE, kernelProperties.doubleFpCapabilities); + EXPECT_EQ(ZE_FP_CAPS_NONE, kernelProperties.singleFpCapabilities); + + DebugManagerStateRestore dbgRestorer; + DebugManager.flags.OverrideDefaultFP64Settings.set(1); + + device->getKernelProperties(&kernelProperties); + EXPECT_EQ(true, kernelProperties.fp64Supported); + EXPECT_NE(ZE_FP_CAPS_NONE, kernelProperties.doubleFpCapabilities); + EXPECT_EQ(ZE_FP_CAPS_ROUNDED_DIVIDE_SQRT, kernelProperties.singleFpCapabilities); +} + struct MockMemoryManagerMultiDevice : public MemoryManagerMock { MockMemoryManagerMultiDevice(NEO::ExecutionEnvironment &executionEnvironment) : MemoryManagerMock(const_cast(executionEnvironment)) {} };