fix: choose proper csr for low priority immediate command lists

Resolves: NEO-10168

Signed-off-by: Michal Mrozek <michal.mrozek@intel.com>
Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Michal Mrozek
2024-01-25 14:25:15 +00:00
committed by Compute-Runtime-Automation
parent 07bac479ab
commit 64232ec370
7 changed files with 50 additions and 12 deletions

View File

@@ -309,7 +309,7 @@ ze_result_t DeviceImp::createCommandQueue(const ze_command_queue_desc_t *desc,
bool isCopyOnly = NEO::EngineHelper::isCopyOnlyEngineType(
getEngineGroupTypeForOrdinal(commandQueueDesc.ordinal));
if (commandQueueDesc.priority == ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_LOW && !isCopyOnly) {
if (isSuitableForLowPriority(commandQueueDesc.priority, isCopyOnly)) {
getCsrForLowPriority(&csr);
} else {
auto ret = getCsrForOrdinalAndIndexWithPriority(&csr, commandQueueDesc.ordinal, commandQueueDesc.index, commandQueueDesc.priority);
@@ -1715,6 +1715,9 @@ ze_result_t DeviceImp::getCsrForOrdinalAndIndexWithPriority(NEO::CommandStreamRe
}
}
}
} else if (isSuitableForLowPriority(priority, NEO::EngineHelper::isCopyOnlyEngineType(
getEngineGroupTypeForOrdinal(ordinal)))) {
return getCsrForLowPriority(csr);
}
return getCsrForOrdinalAndIndex(csr, ordinal, index);
@@ -1739,6 +1742,10 @@ ze_result_t DeviceImp::getCsrForLowPriority(NEO::CommandStreamReceiver **csr) {
return ZE_RESULT_ERROR_UNKNOWN;
}
bool DeviceImp::isSuitableForLowPriority(ze_command_queue_priority_t priority, bool copyOnly) {
return (priority == ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_LOW && !copyOnly);
}
DebugSession *DeviceImp::getDebugSession(const zet_debug_config_t &config) {
return debugSession.get();
}

View File

@@ -114,6 +114,7 @@ struct DeviceImp : public Device, NEO::NonCopyableOrMovableClass {
ze_result_t getCsrForOrdinalAndIndex(NEO::CommandStreamReceiver **csr, uint32_t ordinal, uint32_t index) override;
ze_result_t getCsrForOrdinalAndIndexWithPriority(NEO::CommandStreamReceiver **csr, uint32_t ordinal, uint32_t index, ze_command_queue_priority_t priority) override;
ze_result_t getCsrForLowPriority(NEO::CommandStreamReceiver **csr) override;
bool isSuitableForLowPriority(ze_command_queue_priority_t priority, bool copyOnly);
NEO::GraphicsAllocation *obtainReusableAllocation(size_t requiredSize, NEO::AllocationType type) override;
void storeReusableAllocation(NEO::GraphicsAllocation &alloc) override;
NEO::Device *getActiveDevice() const;

View File

@@ -879,6 +879,28 @@ TEST_F(DeferredContextCreationDeviceCreateCommandQueueTest, givenLowPriorityEngi
commandQueue->destroy();
}
using DeviceCreateCommandQueueTest = Test<DeviceFixture>;
TEST_F(DeviceCreateCommandQueueTest, givenLowPriorityDescWhenCreateImmediateCommandListThenLowPriorityCsrIsAssigned) {
ze_command_queue_desc_t desc{};
desc.ordinal = 0u;
desc.index = 0u;
desc.priority = ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_LOW;
ze_command_list_handle_t commandListHandle = {};
ze_result_t res = device->createCommandListImmediate(&desc, &commandListHandle);
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
auto commandList = static_cast<CommandListImp *>(L0::CommandList::fromHandle(commandListHandle));
EXPECT_NE(commandList, nullptr);
EXPECT_TRUE(commandList->getCsr()->getOsContext().isLowPriority());
NEO::CommandStreamReceiver *csr = nullptr;
device->getCsrForLowPriority(&csr);
EXPECT_EQ(commandList->getCsr(), csr);
commandList->destroy();
}
TEST_F(DeviceCreateCommandQueueTest, givenNormalPriorityDescWhenCreateCommandQueueIsCalledWithValidArgumentThenCsrIsAssignedWithOrdinalAndIndex) {
ze_command_queue_desc_t desc{};
desc.ordinal = 0u;

View File

@@ -57,7 +57,7 @@ void CommandStreamReceiverSimulatedCommonHw<GfxFamily>::setupContext(OsContext &
flags |= static_cast<uint32_t>(debugManager.flags.AppendAubStreamContextFlags.get());
}
if (aubManager && !osContext.isLowPriority()) {
if (aubManager) {
hardwareContextController = std::make_unique<HardwareContextController>(*aubManager, osContext, flags);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2023 Intel Corporation
* Copyright (C) 2018-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -80,6 +80,7 @@ void TbxCommandStreamReceiverHw<GfxFamily>::initializeEngine() {
hardwareContextController->initialize();
return;
}
DEBUG_BREAK_IF(this->aubManager);
auto csTraits = this->getCsTraits(osContext->getEngineType());

View File

@@ -217,7 +217,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCsrAndHighPriorityContextWhenOsC
EXPECT_TRUE(aub_stream::hardwareContextFlags::highPriority & mockManager->contextFlags);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCsrWhenLowPriorityOsContextIsSetThenDontCreateHardwareContext) {
HWTEST_F(AubCommandStreamReceiverTests, givenAubCsrWhenLowPriorityOsContextIsSetThenCreateHardwareContext) {
MockOsContext osContext(0, EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_RCS, EngineUsage::lowPriority}));
std::string fileName = "file_name.aub";
MockAubManager *mockManager = new MockAubManager();
@@ -229,7 +229,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCsrWhenLowPriorityOsContextIsSet
EXPECT_EQ(nullptr, aubCsr->hardwareContextController.get());
aubCsr->setupContext(osContext);
EXPECT_EQ(nullptr, aubCsr->hardwareContextController.get());
EXPECT_NE(nullptr, aubCsr->hardwareContextController.get());
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptureModeWhenItIsCreatedThenFileIsNotCreated) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2023 Intel Corporation
* Copyright (C) 2018-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -582,19 +582,26 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenHardwareContextIsCreatedThenTbxSt
HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenOsContextIsSetThenCreateHardwareContext) {
auto &gfxCoreHelper = pDevice->getGfxCoreHelper();
MockOsContext osContext(0, EngineDescriptorHelper::getDefaultDescriptor(gfxCoreHelper.getGpgpuEngineInstances(pDevice->getRootDeviceEnvironment())[0], pDevice->getDeviceBitfield()));
std::string fileName = "";
MockAubManager *mockManager = new MockAubManager();
MockAubCenter *mockAubCenter = new MockAubCenter(pDevice->getRootDeviceEnvironment(), false, fileName, CommandStreamReceiverType::CSR_TBX);
mockAubCenter->aubManager = std::unique_ptr<MockAubManager>(mockManager);
pDevice->executionEnvironment->rootDeviceEnvironments[0]->aubCenter = std::unique_ptr<MockAubCenter>(mockAubCenter);
std::unique_ptr<TbxCommandStreamReceiverHw<FamilyType>> tbxCsr(reinterpret_cast<TbxCommandStreamReceiverHw<FamilyType> *>(TbxCommandStreamReceiver::create(fileName, false, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield())));
EXPECT_EQ(nullptr, tbxCsr->hardwareContextController.get());
EngineUsage engineUsageModes[] = {EngineUsage::lowPriority, EngineUsage::regular, EngineUsage::highPriority};
tbxCsr->setupContext(osContext);
EXPECT_NE(nullptr, tbxCsr->hardwareContextController.get());
for (auto mode : engineUsageModes) {
auto engineDescriptor = EngineDescriptorHelper::getDefaultDescriptor(gfxCoreHelper.getGpgpuEngineInstances(pDevice->getRootDeviceEnvironment())[0], pDevice->getDeviceBitfield());
engineDescriptor.engineTypeUsage.second = mode;
MockOsContext osContext(0, engineDescriptor);
std::unique_ptr<TbxCommandStreamReceiverHw<FamilyType>> tbxCsr(reinterpret_cast<TbxCommandStreamReceiverHw<FamilyType> *>(TbxCommandStreamReceiver::create(fileName, false, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield())));
EXPECT_EQ(nullptr, tbxCsr->hardwareContextController.get());
tbxCsr->setupContext(osContext);
EXPECT_NE(nullptr, tbxCsr->hardwareContextController.get());
}
}
HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenPollForCompletionImplIsCalledThenSimulatedCsrMethodIsCalled) {