mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-27 07:44:16 +08:00
fix: expose single device mode
- return internal engine as default engine when defaultEngineIndex is not yet set - return correct internal engine from Device::getInternalEngine() Resolves: HSD-18043691881 Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
c5384f7c01
commit
08fc0c1e1f
@@ -904,6 +904,9 @@ EngineControl &Device::getInternalEngine() {
|
||||
|
||||
auto engineType = getChosenEngineType(getHardwareInfo());
|
||||
|
||||
if (getRootDeviceEnvironment().isExposeSingleDeviceMode()) {
|
||||
return this->getEngine(engineType, EngineUsage::internal);
|
||||
}
|
||||
return this->getNearestGenericSubDevice(0)->getEngine(engineType, EngineUsage::internal);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ bool RootDevice::createRootDeviceEngine(EngineTypeUsage engineTypeUsage, DeviceB
|
||||
auto engineType = engineTypeUsage.first;
|
||||
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(hwInfo);
|
||||
|
||||
EngineDescriptor engineDescriptor(EngineTypeUsage{engineType, EngineUsage::regular}, deviceBitfield, preemptionMode, deviceBitfield.count() > 1);
|
||||
EngineDescriptor engineDescriptor(engineTypeUsage, deviceBitfield, preemptionMode, deviceBitfield.count() > 1);
|
||||
|
||||
auto &gfxCoreHelper = getGfxCoreHelper();
|
||||
bool isPrimaryEngine = EngineHelpers::isCcs(engineType);
|
||||
|
||||
@@ -1291,6 +1291,15 @@ OsContext *MemoryManager::getDefaultEngineContext(uint32_t rootDeviceIndex, Devi
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!defaultContext && peekExecutionEnvironment().rootDeviceEnvironments[rootDeviceIndex]->isExposeSingleDeviceMode()) {
|
||||
for (auto &engine : getRegisteredEngines(rootDeviceIndex)) {
|
||||
auto osContext = engine.osContext;
|
||||
if (osContext->isInternalEngine() && osContext->getDeviceBitfield() == subdevicesBitfield) {
|
||||
defaultContext = osContext;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!defaultContext) {
|
||||
defaultContext = getRegisteredEngines(rootDeviceIndex)[defaultEngineIndex[rootDeviceIndex]].osContext;
|
||||
}
|
||||
|
||||
@@ -1793,6 +1793,32 @@ HWTEST_F(DeviceTests, givenExposeSingleDeviceAndContextGroupSizeEnabledWhenRootD
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST_F(DeviceTests, givenExposeSingleDeviceWhenGettingInternalEngineThenRootDeviceEngineIsReturned) {
|
||||
if (defaultHwInfo->capabilityTable.defaultEngineType != aub_stream::EngineType::ENGINE_CCS) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
VariableBackup<bool> mockDeviceFlagBackup(&MockDevice::createSingleDevice, false);
|
||||
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
debugManager.flags.CreateMultipleSubDevices.set(2);
|
||||
|
||||
HardwareInfo hwInfo = *defaultHwInfo;
|
||||
hwInfo.featureTable.flags.ftrCCSNode = true;
|
||||
hwInfo.featureTable.ftrBcsInfo = 0b111;
|
||||
hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_CCS;
|
||||
hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 1;
|
||||
hwInfo.capabilityTable.blitterOperationsSupported = true;
|
||||
|
||||
auto executionEnvironment = MockDevice::prepareExecutionEnvironment(&hwInfo, 0);
|
||||
executionEnvironment->rootDeviceEnvironments[0]->setExposeSingleDeviceMode(true);
|
||||
|
||||
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithExecutionEnvironment<MockDevice>(&hwInfo, executionEnvironment, 0));
|
||||
|
||||
auto internalEngine = device->getInternalEngine();
|
||||
EXPECT_EQ(EngineUsage::internal, internalEngine.getEngineUsage());
|
||||
EXPECT_EQ(2u, internalEngine.osContext->getDeviceBitfield().count());
|
||||
}
|
||||
|
||||
HWTEST_F(DeviceTests, givenRootDeviceWithCCSEngineAndContextGroupSizeEnabledWhenDeviceIsCreatedThenSecondaryEnginesAreCreated) {
|
||||
if (defaultHwInfo->capabilityTable.defaultEngineType != aub_stream::EngineType::ENGINE_CCS) {
|
||||
GTEST_SKIP();
|
||||
|
||||
@@ -251,6 +251,43 @@ TEST(MemoryManagerTest, givenMultipleDevicesMemoryManagerWhenGettingDefaultConte
|
||||
executionEnvironment.memoryManager->getDefaultEngineContext(1, 2));
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenSingleDeviceModeWhenGettingDefaultContextThenInternalContextReturnedAsAFallback) {
|
||||
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
debugManager.flags.CreateMultipleSubDevices.set(2);
|
||||
|
||||
auto executionEnvironment = std::unique_ptr<ExecutionEnvironment>(MockDevice::prepareExecutionEnvironment(defaultHwInfo.get(), 0));
|
||||
executionEnvironment->rootDeviceEnvironments[0]->setExposeSingleDeviceMode(true);
|
||||
|
||||
auto mockMemoryManager = new MockMemoryManager(false, false, *executionEnvironment);
|
||||
executionEnvironment->memoryManager.reset(mockMemoryManager);
|
||||
|
||||
{
|
||||
auto csr = std::make_unique<MockCommandStreamReceiver>(*executionEnvironment, 0, 1);
|
||||
auto csr0 = std::make_unique<MockCommandStreamReceiver>(*executionEnvironment, 0, 1);
|
||||
auto csr1 = std::make_unique<MockCommandStreamReceiver>(*executionEnvironment, 0, 1);
|
||||
|
||||
csr->internalAllocationStorage.reset(new MockInternalAllocationStorage(*csr));
|
||||
csr0->internalAllocationStorage.reset(new MockInternalAllocationStorage(*csr0));
|
||||
csr1->internalAllocationStorage.reset(new MockInternalAllocationStorage(*csr1));
|
||||
|
||||
auto osContext = executionEnvironment->memoryManager->createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor({aub_stream::EngineType::ENGINE_RCS, EngineUsage::regular}, DeviceBitfield(0x1)));
|
||||
auto osContext0 = executionEnvironment->memoryManager->createAndRegisterOsContext(csr0.get(), EngineDescriptorHelper::getDefaultDescriptor({aub_stream::EngineType::ENGINE_RCS, EngineUsage::internal}, DeviceBitfield(0x1)));
|
||||
auto osContext1 = executionEnvironment->memoryManager->createAndRegisterOsContext(csr1.get(), EngineDescriptorHelper::getDefaultDescriptor({aub_stream::EngineType::ENGINE_RCS, EngineUsage::internal}, DeviceBitfield(0x2)));
|
||||
|
||||
EXPECT_NE(nullptr, osContext0);
|
||||
EXPECT_NE(nullptr, osContext1);
|
||||
|
||||
EXPECT_EQ(osContext0, executionEnvironment->memoryManager->getDefaultEngineContext(0, 1));
|
||||
EXPECT_EQ(osContext1, executionEnvironment->memoryManager->getDefaultEngineContext(0, 2));
|
||||
|
||||
executionEnvironment->rootDeviceEnvironments[0]->setExposeSingleDeviceMode(false);
|
||||
|
||||
EXPECT_EQ(mockMemoryManager->getRegisteredEngines(0)[mockMemoryManager->defaultEngineIndex[0]].osContext, executionEnvironment->memoryManager->getDefaultEngineContext(0, 1));
|
||||
EXPECT_EQ(osContext, executionEnvironment->memoryManager->getDefaultEngineContext(0, 1));
|
||||
}
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenFailureOnRegisterSystemMemoryAllocationWhenAllocatingMemoryThenNullptrIsReturned) {
|
||||
AllocationProperties properties(mockRootDeviceIndex, true, MemoryConstants::cacheLineSize, AllocationType::buffer, false, mockDeviceBitfield);
|
||||
MockMemoryManager memoryManager;
|
||||
|
||||
Reference in New Issue
Block a user