Resubmit fix for task count hang

Signed-off-by: John Falkowski <john.falkowski@intel.com>
This commit is contained in:
John Falkowski
2022-05-27 03:58:07 +00:00
committed by Compute-Runtime-Automation
parent c303c218be
commit 620bb970f4
18 changed files with 203 additions and 50 deletions

View File

@@ -98,6 +98,8 @@ NEO::SubmissionStatus CommandQueueImp::submitBatchBuffer(size_t offset, NEO::Res
csr->setActivePartitions(partitionCount);
auto ret = csr->submitBatchBuffer(batchBuffer, csr->getResidencyAllocations());
if (ret != NEO::SubmissionStatus::SUCCESS) {
commandStream->getGraphicsAllocation()->updateTaskCount(csr->peekTaskCount(), csr->getOsContext().getContextId());
commandStream->getGraphicsAllocation()->updateResidencyTaskCount(csr->peekTaskCount(), csr->getOsContext().getContextId());
return ret;
}

View File

@@ -23,6 +23,7 @@
#include "shared/source/helpers/hw_info.h"
#include "shared/source/helpers/pipe_control_args.h"
#include "shared/source/helpers/preamble.h"
#include "shared/source/memory_manager/graphics_allocation.h"
#include "shared/source/memory_manager/memory_manager.h"
#include "shared/source/memory_manager/residency_container.h"
#include "shared/source/os_interface/hw_info_config.h"
@@ -476,27 +477,37 @@ ze_result_t CommandQueueHw<gfxCoreFamily>::executeCommandLists(
csr->setLatestFlushedTaskCount(this->taskCount);
}
csr->makeSurfacePackNonResident(csr->getResidencyAllocations());
csr->makeSurfacePackNonResident(csr->getResidencyAllocations(), false);
ze_result_t retVal = ZE_RESULT_SUCCESS;
if (getSynchronousMode() == ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS) {
const auto synchronizeResult = this->synchronize(std::numeric_limits<uint64_t>::max());
if (synchronizeResult == ZE_RESULT_ERROR_DEVICE_LOST) {
return ZE_RESULT_ERROR_DEVICE_LOST;
retVal = ZE_RESULT_ERROR_DEVICE_LOST;
}
} else {
csr->pollForCompletion();
}
this->heapContainer.clear();
csr->pollForCompletion();
if (ret != NEO::SubmissionStatus::SUCCESS) {
if (ret == NEO::SubmissionStatus::OUT_OF_MEMORY) {
return ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY;
if ((ret != NEO::SubmissionStatus::SUCCESS) || (retVal == ZE_RESULT_ERROR_DEVICE_LOST)) {
for (auto &gfx : csr->getResidencyAllocations()) {
if (csr->peekLatestFlushedTaskCount() == 0) {
gfx->releaseUsageInOsContext(csr->getOsContext().getContextId());
} else {
gfx->updateTaskCount(csr->peekLatestFlushedTaskCount(), csr->getOsContext().getContextId());
}
}
if (retVal != ZE_RESULT_ERROR_DEVICE_LOST) {
retVal = ZE_RESULT_ERROR_UNKNOWN;
}
if (ret == NEO::SubmissionStatus::OUT_OF_MEMORY) {
retVal = ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY;
}
return ZE_RESULT_ERROR_UNKNOWN;
}
return ZE_RESULT_SUCCESS;
csr->getResidencyAllocations().clear();
return retVal;
}
template <GFXCORE_FAMILY gfxCoreFamily>

View File

@@ -356,11 +356,15 @@ HWTEST_F(CommandQueueCreate, givenContainerWithAllocationsWhenResidencyContainer
false,
returnValue));
ResidencyContainer container;
commandQueue->submitBatchBuffer(0, container, nullptr, false);
uint32_t peekTaskCountBefore = commandQueue->csr->peekTaskCount();
uint32_t flushedTaskCountBefore = commandQueue->csr->peekLatestFlushedTaskCount();
NEO::SubmissionStatus ret = commandQueue->submitBatchBuffer(0, container, nullptr, false);
EXPECT_EQ(csr->makeResidentCalledTimes, 0u);
EXPECT_EQ(commandQueue->commandStream->getGraphicsAllocation()->getTaskCount(commandQueue->csr->getOsContext().getContextId()), commandQueue->csr->peekTaskCount());
EXPECT_EQ(ret, NEO::SubmissionStatus::SUCCESS);
EXPECT_EQ((peekTaskCountBefore + 1), commandQueue->csr->peekTaskCount());
EXPECT_EQ((flushedTaskCountBefore + 1), commandQueue->csr->peekLatestFlushedTaskCount());
EXPECT_EQ(commandQueue->commandStream->getGraphicsAllocation()->getTaskCount(commandQueue->csr->getOsContext().getContextId()), commandQueue->csr->peekTaskCount());
EXPECT_EQ(commandQueue->commandStream->getGraphicsAllocation()->getResidencyTaskCount(commandQueue->csr->getOsContext().getContextId()), commandQueue->csr->peekTaskCount());
commandQueue->destroy();
}
@@ -377,9 +381,14 @@ HWTEST_F(CommandQueueCreate, givenCommandStreamReceiverFailsThenSubmitBatchBuffe
false,
returnValue));
ResidencyContainer container;
uint32_t peekTaskCountBefore = commandQueue->csr->peekTaskCount();
uint32_t flushedTaskCountBefore = commandQueue->csr->peekLatestFlushedTaskCount();
NEO::SubmissionStatus ret = commandQueue->submitBatchBuffer(0, container, nullptr, false);
EXPECT_EQ(ret, NEO::SubmissionStatus::FAILED);
EXPECT_EQ(peekTaskCountBefore, commandQueue->csr->peekTaskCount());
EXPECT_EQ(flushedTaskCountBefore, commandQueue->csr->peekLatestFlushedTaskCount());
EXPECT_EQ(commandQueue->commandStream->getGraphicsAllocation()->getTaskCount(commandQueue->csr->getOsContext().getContextId()), commandQueue->csr->peekTaskCount());
EXPECT_EQ(commandQueue->commandStream->getGraphicsAllocation()->getResidencyTaskCount(commandQueue->csr->getOsContext().getContextId()), commandQueue->csr->peekTaskCount());
commandQueue->destroy();
}
@@ -1537,6 +1546,87 @@ HWTEST2_F(ExecuteCommandListTests, givenFailingSubmitBatchBufferThenExecuteComma
commandList->destroy();
}
HWTEST2_F(ExecuteCommandListTests, givenFailingSubmitBatchBufferThenResetGraphicsTaskCountsLatestFlushedTaskCountZero, IsAtLeastSkl) {
ze_command_queue_desc_t desc = {};
NEO::CommandStreamReceiver *csr;
device->getCsrForOrdinalAndIndex(&csr, 0u, 0u);
auto commandQueue = new MockCommandQueueSubmitBatchBuffer<gfxCoreFamily>(device, csr, &desc);
commandQueue->submitBatchBufferResult = NEO::SubmissionStatus::FAILED;
commandQueue->initialize(false, false);
auto commandList = new CommandListCoreFamily<gfxCoreFamily>();
commandList->initialize(device, NEO::EngineGroupType::Compute, 0u);
auto commandListHandle = commandList->toHandle();
void *alloc = alignedMalloc(0x100, 0x100);
NEO::GraphicsAllocation graphicsAllocation1(0, NEO::AllocationType::BUFFER, alloc, 0u, 0u, 1u, MemoryPool::System4KBPages, 1u);
NEO::GraphicsAllocation graphicsAllocation2(0, NEO::AllocationType::BUFFER, alloc, 0u, 0u, 1u, MemoryPool::System4KBPages, 1u);
commandList->commandContainer.addToResidencyContainer(&graphicsAllocation1);
commandList->commandContainer.addToResidencyContainer(&graphicsAllocation2);
static_cast<NEO::UltCommandStreamReceiver<FamilyType> *>(csr)->taskCount = 0;
auto res = commandQueue->executeCommandLists(1, &commandListHandle, nullptr, false);
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, res);
EXPECT_EQ(NEO::GraphicsAllocation::objectNotUsed, graphicsAllocation1.getTaskCount(csr->getOsContext().getContextId()));
EXPECT_EQ(NEO::GraphicsAllocation::objectNotUsed, graphicsAllocation2.getTaskCount(csr->getOsContext().getContextId()));
commandQueue->destroy();
commandList->destroy();
alignedFree(alloc);
}
HWTEST2_F(ExecuteCommandListTests, givenFailingSubmitBatchBufferThenResetGraphicsTaskCountsLatestFlushedTaskCountNonZero, IsAtLeastSkl) {
ze_command_queue_desc_t desc = {};
NEO::CommandStreamReceiver *csr;
device->getCsrForOrdinalAndIndex(&csr, 0u, 0u);
auto commandQueue = new MockCommandQueueSubmitBatchBuffer<gfxCoreFamily>(device, csr, &desc);
commandQueue->submitBatchBufferResult = NEO::SubmissionStatus::FAILED;
commandQueue->initialize(false, false);
auto commandList = new CommandListCoreFamily<gfxCoreFamily>();
commandList->initialize(device, NEO::EngineGroupType::Compute, 0u);
auto commandListHandle = commandList->toHandle();
void *alloc = alignedMalloc(0x100, 0x100);
NEO::GraphicsAllocation graphicsAllocation1(0, NEO::AllocationType::BUFFER, alloc, 0u, 0u, 1u, MemoryPool::System4KBPages, 1u);
NEO::GraphicsAllocation graphicsAllocation2(0, NEO::AllocationType::BUFFER, alloc, 0u, 0u, 1u, MemoryPool::System4KBPages, 1u);
commandList->commandContainer.addToResidencyContainer(&graphicsAllocation1);
commandList->commandContainer.addToResidencyContainer(&graphicsAllocation2);
static_cast<NEO::UltCommandStreamReceiver<FamilyType> *>(csr)->taskCount = 2;
auto res = commandQueue->executeCommandLists(1, &commandListHandle, nullptr, false);
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, res);
EXPECT_EQ(2u, graphicsAllocation1.getTaskCount(csr->getOsContext().getContextId()));
EXPECT_EQ(2u, graphicsAllocation2.getTaskCount(csr->getOsContext().getContextId()));
commandQueue->destroy();
commandList->destroy();
alignedFree(alloc);
}
HWTEST2_F(ExecuteCommandListTests, givenFailingSubmitBatchBufferThenWaitForCompletionFalse, IsAtLeastSkl) {
ze_command_queue_desc_t desc = {};
NEO::CommandStreamReceiver *csr;
device->getCsrForOrdinalAndIndex(&csr, 0u, 0u);
auto commandQueue = new MockCommandQueueSubmitBatchBuffer<gfxCoreFamily>(device, csr, &desc);
commandQueue->submitBatchBufferResult = NEO::SubmissionStatus::FAILED;
commandQueue->initialize(false, false);
auto commandList = new CommandListCoreFamily<gfxCoreFamily>();
commandList->initialize(device, NEO::EngineGroupType::Compute, 0u);
auto commandListHandle = commandList->toHandle();
uint32_t flushedTaskCountPrior = csr->peekTaskCount();
csr->setLatestFlushedTaskCount(flushedTaskCountPrior);
auto res = commandQueue->executeCommandLists(1, &commandListHandle, nullptr, false);
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, res);
EXPECT_EQ(csr->peekLatestFlushedTaskCount(), flushedTaskCountPrior);
commandQueue->destroy();
commandList->destroy();
}
HWTEST2_F(ExecuteCommandListTests, givenSuccessfulSubmitBatchBufferThenExecuteCommandListReturnsSuccess, IsAtLeastSkl) {
ze_command_queue_desc_t desc = {};
NEO::CommandStreamReceiver *csr;