Override engine type used by device in Device ctor

AUB tests do not use DeviceFactory class to create Device objects but still
need to have a functionality to override default engine type

Change-Id: I6841cb0a9c5726ac4308c742c78cf7a61829f168
This commit is contained in:
Zdanowicz, Zbigniew
2018-02-12 11:48:31 +01:00
committed by sys_ocldev
parent b5dab07aa2
commit 5a175cf1cf
6 changed files with 21 additions and 29 deletions

View File

@ -80,6 +80,9 @@ Device::Device(const HardwareInfo &hwInfo,
memset(&deviceInfo, 0, sizeof(deviceInfo));
deviceExtensions.reserve(1000);
preemptionMode = PreemptionHelper::getDefaultPreemptionMode(hwInfo);
deviceEngineType = DebugManager.flags.NodeOrdinal.get() == -1
? hwInfo.capabilityTable.defaultEngineType
: static_cast<EngineType>(DebugManager.flags.NodeOrdinal.get());
}
Device::~Device() {
@ -179,10 +182,6 @@ const HardwareInfo *Device::getDeviceInitHwInfo(const HardwareInfo *pHwInfoIn) {
const HardwareInfo &Device::getHardwareInfo() const { return hwInfo; }
EngineType Device::getEngineType() const {
return hwInfo.capabilityTable.defaultEngineType;
}
const WorkaroundTable *Device::getWaTable() const { return hwInfo.pWaTable; }
const DeviceInfo &Device::getDeviceInfo() const {

View File

@ -81,7 +81,9 @@ class Device : public BaseObject<_cl_device_id> {
const DeviceInfo &getDeviceInfo() const;
DeviceInfo *getMutableDeviceInfo();
MOCKABLE_VIRTUAL const WorkaroundTable *getWaTable() const;
EngineType getEngineType() const;
EngineType getEngineType() const {
return deviceEngineType;
}
void *getSLMWindowStartAddress();
void prepareSLMWindow();
@ -164,6 +166,7 @@ class Device : public BaseObject<_cl_device_id> {
std::string exposedBuiltinKernels = "";
PreemptionMode preemptionMode;
EngineType deviceEngineType;
};
template <cl_device_info Param>

View File

@ -167,10 +167,6 @@ int HwInfoConfig::configureHwInfo(const HardwareInfo *inHwInfo, HardwareInfo *ou
hwHelper.setCapabilityCoherencyFlag(const_cast<const HardwareInfo *>(outHwInfo), platformCoherency);
outHwInfo->capabilityTable.ftrSupportsCoherency = (platformCoherency && drm->peekCoherencyDisablePatchActive());
outHwInfo->capabilityTable.defaultEngineType = DebugManager.flags.NodeOrdinal.get() == -1
? outHwInfo->capabilityTable.defaultEngineType
: static_cast<EngineType>(DebugManager.flags.NodeOrdinal.get());
outHwInfo->capabilityTable.instrumentationEnabled = false;
outHwInfo->capabilityTable.ftrCompression = false;

View File

@ -71,9 +71,6 @@ bool DeviceFactory::getDevices(HardwareInfo **pHWInfos, size_t &numDevices) {
HwHelper &hwHelper = HwHelper::get(adapterInfo->GfxPlatform.eRenderCoreFamily);
hwHelper.adjustDefaultEngineType(&tempHwInfos[devNum]);
tempHwInfos[devNum].capabilityTable.defaultEngineType = DebugManager.flags.NodeOrdinal.get() == -1
? tempHwInfos[devNum].capabilityTable.defaultEngineType
: static_cast<EngineType>(DebugManager.flags.NodeOrdinal.get());
hwHelper.setCapabilityCoherencyFlag(&tempHwInfos[devNum], tempHwInfos[devNum].capabilityTable.ftrSupportsCoherency);

View File

@ -118,6 +118,19 @@ TEST_F(DeviceTest, getEngineTypeDefault) {
EXPECT_EQ(defaultEngineType, actualEngineType);
}
TEST_F(DeviceTest, givenDebugVariableOverrideEngineTypeWhenDeviceIsCreatedThenUseDebugNotDefaul) {
EngineType expectedEngine = EngineType::ENGINE_VCS;
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.NodeOrdinal.set(static_cast<int32_t>(expectedEngine));
auto pTestDevice = std::unique_ptr<Device>(createWithUsDeviceId(0));
EngineType actualEngineType = pTestDevice->getEngineType();
EngineType defaultEngineType = hwInfoHelper.capabilityTable.defaultEngineType;
EXPECT_NE(defaultEngineType, actualEngineType);
EXPECT_EQ(expectedEngine, actualEngineType);
}
struct SmallMockDevice : public Device {
SmallMockDevice(const HardwareInfo &hwInfo, bool isRootDevice = true)
: Device(hwInfo, isRootDevice) {}
@ -129,4 +142,4 @@ TEST(DeviceCreation, givenDeviceWithUsedTagAllocationWhenItIsDestroyedThenThereA
std::unique_ptr<SmallMockDevice> device(Device::create<SmallMockDevice>(platformDevices[0]));
auto tagAllocation = device->peekTagAllocation();
tagAllocation->taskCount = 1;
}
}

View File

@ -116,19 +116,3 @@ TEST_F(DeviceFactoryTest, overrideKmdNotifySettings) {
DeviceFactory::releaseDevices();
}
TEST_F(DeviceFactoryTest, getEngineTypeDebugOverride) {
DebugManagerStateRestore dbgRestorer;
int32_t debugEngineType = 2;
DebugManager.flags.NodeOrdinal.set(debugEngineType);
HardwareInfo *hwInfoOverriden = nullptr;
size_t numDevices = 0;
bool success = DeviceFactory::getDevices(&hwInfoOverriden, numDevices);
ASSERT_TRUE(success);
ASSERT_NE(nullptr, hwInfoOverriden);
int32_t actualEngineType = static_cast<int32_t>(hwInfoOverriden->capabilityTable.defaultEngineType);
EXPECT_EQ(debugEngineType, actualEngineType);
DeviceFactory::releaseDevices();
}