Allow for overriding the reported FP64 support in L0

Change-Id: Ib876e00e198c07dbae7b921e1e7dc2b142aee049
Signed-off-by: Raiyan Latif <raiyan.latif@intel.com>
This commit is contained in:
Raiyan Latif
2020-05-27 15:46:19 -07:00
committed by sys_ocldev
parent f0ef0d4d78
commit cb6823b1bd
2 changed files with 53 additions and 3 deletions

View File

@@ -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;

View File

@@ -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<NEO::MockDevice>(&nonFp64Device, rootDeviceIndex);
NEO::DeviceVector devices;
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
driverHandle = std::make_unique<Mock<L0::DriverHandleImp>>();
driverHandle->initialize(std::move(devices));
device = driverHandle->devices[0];
}
DebugManagerStateRestore restorer;
std::unique_ptr<Mock<L0::DriverHandleImp>> 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<int>::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<NEO::ExecutionEnvironment &>(executionEnvironment)) {}
};