Skip to content

Commit 359e848

Browse files
Jaime ArteagaCompute-Runtime-Automation
Jaime Arteaga
authored andcommitted
Revert "Fix for task count hang issue"
This reverts commit 340ba8b. Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
1 parent 8812f62 commit 359e848

File tree

8 files changed

+27
-123
lines changed

8 files changed

+27
-123
lines changed

level_zero/core/source/cmdqueue/cmdqueue.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ NEO::SubmissionStatus CommandQueueImp::submitBatchBuffer(size_t offset, NEO::Res
9696
csr->setActivePartitions(partitionCount);
9797
auto ret = csr->submitBatchBuffer(batchBuffer, csr->getResidencyAllocations());
9898
if (ret != NEO::SubmissionStatus::SUCCESS) {
99-
commandStream->getGraphicsAllocation()->updateTaskCount(csr->peekTaskCount(), csr->getOsContext().getContextId());
100-
commandStream->getGraphicsAllocation()->updateResidencyTaskCount(csr->peekTaskCount(), csr->getOsContext().getContextId());
10199
return ret;
102100
}
103101

level_zero/core/source/cmdqueue/cmdqueue_hw.inl

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "shared/source/helpers/hw_info.h"
2323
#include "shared/source/helpers/pipe_control_args.h"
2424
#include "shared/source/helpers/preamble.h"
25-
#include "shared/source/memory_manager/graphics_allocation.h"
2625
#include "shared/source/memory_manager/memory_manager.h"
2726
#include "shared/source/memory_manager/residency_container.h"
2827
#include "shared/source/os_interface/hw_info_config.h"
@@ -476,30 +475,27 @@ ze_result_t CommandQueueHw<gfxCoreFamily>::executeCommandLists(
476475
csr->setLatestFlushedTaskCount(this->taskCount);
477476
}
478477

479-
ze_result_t retVal = ZE_RESULT_SUCCESS;
478+
csr->makeSurfacePackNonResident(csr->getResidencyAllocations());
479+
480480
if (getSynchronousMode() == ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS) {
481481
const auto synchronizeResult = this->synchronize(std::numeric_limits<uint64_t>::max());
482482
if (synchronizeResult == ZE_RESULT_ERROR_DEVICE_LOST) {
483-
retVal = ZE_RESULT_ERROR_DEVICE_LOST;
483+
return ZE_RESULT_ERROR_DEVICE_LOST;
484484
}
485-
} else {
486-
csr->pollForCompletion();
487485
}
486+
488487
this->heapContainer.clear();
489488

490-
if ((ret != NEO::SubmissionStatus::SUCCESS) || (retVal == ZE_RESULT_ERROR_DEVICE_LOST)) {
491-
for (auto &gfx : csr->getResidencyAllocations()) {
492-
gfx->updateTaskCount(csr->peekLatestFlushedTaskCount(), csr->getOsContext().getContextId());
493-
}
494-
if (retVal != ZE_RESULT_ERROR_DEVICE_LOST) {
495-
retVal = ZE_RESULT_ERROR_UNKNOWN;
496-
}
489+
csr->pollForCompletion();
490+
491+
if (ret != NEO::SubmissionStatus::SUCCESS) {
497492
if (ret == NEO::SubmissionStatus::OUT_OF_MEMORY) {
498-
retVal = ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY;
493+
return ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY;
499494
}
495+
return ZE_RESULT_ERROR_UNKNOWN;
500496
}
501-
csr->makeSurfacePackNonResident(csr->getResidencyAllocations());
502-
return retVal;
497+
498+
return ZE_RESULT_SUCCESS;
503499
}
504500

505501
template <GFXCORE_FAMILY gfxCoreFamily>

level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_1.cpp

Lines changed: 4 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -353,15 +353,11 @@ HWTEST_F(CommandQueueCreate, givenContainerWithAllocationsWhenResidencyContainer
353353
false,
354354
returnValue));
355355
ResidencyContainer container;
356-
uint32_t peekTaskCountBefore = commandQueue->csr->peekTaskCount();
357-
uint32_t flushedTaskCountBefore = commandQueue->csr->peekLatestFlushedTaskCount();
358-
NEO::SubmissionStatus ret = commandQueue->submitBatchBuffer(0, container, nullptr, false);
356+
commandQueue->submitBatchBuffer(0, container, nullptr, false);
359357
EXPECT_EQ(csr->makeResidentCalledTimes, 0u);
360-
EXPECT_EQ(ret, NEO::SubmissionStatus::SUCCESS);
361-
EXPECT_EQ((peekTaskCountBefore + 1), commandQueue->csr->peekTaskCount());
362-
EXPECT_EQ((flushedTaskCountBefore + 1), commandQueue->csr->peekLatestFlushedTaskCount());
358+
359+
EXPECT_EQ(commandQueue->commandStream->getGraphicsAllocation()->getTaskCount(commandQueue->csr->getOsContext().getContextId()), commandQueue->csr->peekTaskCount());
363360
EXPECT_EQ(commandQueue->commandStream->getGraphicsAllocation()->getTaskCount(commandQueue->csr->getOsContext().getContextId()), commandQueue->csr->peekTaskCount());
364-
EXPECT_EQ(commandQueue->commandStream->getGraphicsAllocation()->getResidencyTaskCount(commandQueue->csr->getOsContext().getContextId()), commandQueue->csr->peekTaskCount());
365361
commandQueue->destroy();
366362
}
367363

@@ -378,14 +374,9 @@ HWTEST_F(CommandQueueCreate, givenCommandStreamReceiverFailsThenSubmitBatchBuffe
378374
false,
379375
returnValue));
380376
ResidencyContainer container;
381-
uint32_t peekTaskCountBefore = commandQueue->csr->peekTaskCount();
382-
uint32_t flushedTaskCountBefore = commandQueue->csr->peekLatestFlushedTaskCount();
383377
NEO::SubmissionStatus ret = commandQueue->submitBatchBuffer(0, container, nullptr, false);
384378
EXPECT_EQ(ret, NEO::SubmissionStatus::FAILED);
385-
EXPECT_EQ(peekTaskCountBefore, commandQueue->csr->peekTaskCount());
386-
EXPECT_EQ(flushedTaskCountBefore, commandQueue->csr->peekLatestFlushedTaskCount());
387-
EXPECT_EQ(commandQueue->commandStream->getGraphicsAllocation()->getTaskCount(commandQueue->csr->getOsContext().getContextId()), commandQueue->csr->peekTaskCount());
388-
EXPECT_EQ(commandQueue->commandStream->getGraphicsAllocation()->getResidencyTaskCount(commandQueue->csr->getOsContext().getContextId()), commandQueue->csr->peekTaskCount());
379+
389380
commandQueue->destroy();
390381
}
391382

@@ -1526,57 +1517,6 @@ HWTEST2_F(ExecuteCommandListTests, givenFailingSubmitBatchBufferThenExecuteComma
15261517
commandList->destroy();
15271518
}
15281519

1529-
HWTEST2_F(ExecuteCommandListTests, givenFailingSubmitBatchBufferThenResetGraphicsTaskCounts, IsAtLeastSkl) {
1530-
ze_command_queue_desc_t desc = {};
1531-
NEO::CommandStreamReceiver *csr;
1532-
device->getCsrForOrdinalAndIndex(&csr, 0u, 0u);
1533-
auto commandQueue = new MockCommandQueueSubmitBatchBuffer<gfxCoreFamily>(device, csr, &desc);
1534-
commandQueue->submitBatchBufferResult = NEO::SubmissionStatus::FAILED;
1535-
1536-
commandQueue->initialize(false, false);
1537-
auto commandList = new CommandListCoreFamily<gfxCoreFamily>();
1538-
commandList->initialize(device, NEO::EngineGroupType::Compute, 0u);
1539-
auto commandListHandle = commandList->toHandle();
1540-
1541-
void *alloc = alignedMalloc(0x100, 0x100);
1542-
NEO::GraphicsAllocation graphicsAllocation1(0, NEO::AllocationType::BUFFER, alloc, 0u, 0u, 1u, MemoryPool::System4KBPages, 1u);
1543-
NEO::GraphicsAllocation graphicsAllocation2(0, NEO::AllocationType::BUFFER, alloc, 0u, 0u, 1u, MemoryPool::System4KBPages, 1u);
1544-
graphicsAllocation1.updateTaskCount(3, csr->getOsContext().getContextId());
1545-
graphicsAllocation2.updateTaskCount(3, csr->getOsContext().getContextId());
1546-
commandList->commandContainer.addToResidencyContainer(&graphicsAllocation1);
1547-
commandList->commandContainer.addToResidencyContainer(&graphicsAllocation2);
1548-
auto res = commandQueue->executeCommandLists(1, &commandListHandle, nullptr, false);
1549-
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, res);
1550-
1551-
EXPECT_EQ(0u, graphicsAllocation1.getTaskCount(csr->getOsContext().getContextId()));
1552-
EXPECT_EQ(0u, graphicsAllocation2.getTaskCount(csr->getOsContext().getContextId()));
1553-
1554-
commandQueue->destroy();
1555-
commandList->destroy();
1556-
alignedFree(alloc);
1557-
}
1558-
1559-
HWTEST2_F(ExecuteCommandListTests, givenFailingSubmitBatchBufferThenWaitForCompletionFalse, IsAtLeastSkl) {
1560-
ze_command_queue_desc_t desc = {};
1561-
NEO::CommandStreamReceiver *csr;
1562-
device->getCsrForOrdinalAndIndex(&csr, 0u, 0u);
1563-
auto commandQueue = new MockCommandQueueSubmitBatchBuffer<gfxCoreFamily>(device, csr, &desc);
1564-
commandQueue->submitBatchBufferResult = NEO::SubmissionStatus::FAILED;
1565-
1566-
commandQueue->initialize(false, false);
1567-
auto commandList = new CommandListCoreFamily<gfxCoreFamily>();
1568-
commandList->initialize(device, NEO::EngineGroupType::Compute, 0u);
1569-
auto commandListHandle = commandList->toHandle();
1570-
uint32_t flushedTaskCountPrior = csr->peekTaskCount();
1571-
csr->setLatestFlushedTaskCount(flushedTaskCountPrior);
1572-
auto res = commandQueue->executeCommandLists(1, &commandListHandle, nullptr, false);
1573-
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, res);
1574-
EXPECT_EQ(csr->peekLatestFlushedTaskCount(), flushedTaskCountPrior);
1575-
1576-
commandQueue->destroy();
1577-
commandList->destroy();
1578-
}
1579-
15801520
HWTEST2_F(ExecuteCommandListTests, givenSuccessfulSubmitBatchBufferThenExecuteCommandListReturnsSuccess, IsAtLeastSkl) {
15811521
ze_command_queue_desc_t desc = {};
15821522
NEO::CommandStreamReceiver *csr;

shared/source/command_stream/command_stream_receiver.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,6 @@ SubmissionStatus CommandStreamReceiver::submitBatchBuffer(BatchBuffer &batchBuff
103103
this->latestSentTaskCount = taskCount + 1;
104104

105105
SubmissionStatus retVal = this->flush(batchBuffer, allocationsForResidency);
106-
107-
if (retVal != NEO::SubmissionStatus::SUCCESS) {
108-
return retVal;
109-
}
110106
if (!isUpdateTagFromWaitEnabled()) {
111107
this->latestFlushedTaskCount = taskCount + 1;
112108
}

shared/source/os_interface/linux/drm_command_stream.inl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,9 @@ int DrmCommandStreamReceiver<GfxFamily>::exec(const BatchBuffer &batchBuffer, ui
246246

247247
template <typename GfxFamily>
248248
void DrmCommandStreamReceiver<GfxFamily>::processResidency(const ResidencyContainer &inputAllocationsForResidency, uint32_t handleId) {
249-
250-
if ((!drm->isVmBindAvailable()) || (DebugManager.flags.PassBoundBOToExec.get() == 1)) {
251-
for (auto &alloc : inputAllocationsForResidency) {
252-
auto drmAlloc = static_cast<DrmAllocation *>(alloc);
253-
drmAlloc->makeBOsResident(osContext, handleId, &this->residency, false);
254-
}
249+
for (auto &alloc : inputAllocationsForResidency) {
250+
auto drmAlloc = static_cast<DrmAllocation *>(alloc);
251+
drmAlloc->makeBOsResident(osContext, handleId, &this->residency, false);
255252
}
256253
}
257254

shared/source/os_interface/linux/drm_memory_operations_handler_bind.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ MemoryOperationsStatus DrmMemoryOperationsHandlerBind::isResident(Device *device
104104
}
105105

106106
MemoryOperationsStatus DrmMemoryOperationsHandlerBind::mergeWithResidencyContainer(OsContext *osContext, ResidencyContainer &residencyContainer) {
107-
108107
if (DebugManager.flags.MakeEachAllocationResident.get() == 2) {
109108
auto memoryManager = static_cast<DrmMemoryManager *>(this->rootDeviceEnvironment.executionEnvironment.memoryManager.get());
110109

@@ -118,6 +117,15 @@ MemoryOperationsStatus DrmMemoryOperationsHandlerBind::mergeWithResidencyContain
118117
return retVal;
119118
}
120119

120+
auto clearContainer = true;
121+
122+
if (DebugManager.flags.PassBoundBOToExec.get() != -1) {
123+
clearContainer = !DebugManager.flags.PassBoundBOToExec.get();
124+
}
125+
126+
if (clearContainer) {
127+
residencyContainer.clear();
128+
}
121129
return MemoryOperationsStatus::SUCCESS;
122130
}
123131

shared/test/common/mocks/mock_command_stream_receiver.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,6 @@ class MockCommandStreamReceiverWithOutOfMemorySubmitBatch : public MockCommandSt
197197
}
198198
};
199199

200-
class MockCommandStreamReceiverWithFailingFlush : public MockCommandStreamReceiver {
201-
public:
202-
MockCommandStreamReceiverWithFailingFlush(ExecutionEnvironment &executionEnvironment, uint32_t rootDeviceIndex, const DeviceBitfield deviceBitfield)
203-
: MockCommandStreamReceiver(executionEnvironment, rootDeviceIndex, deviceBitfield) {}
204-
SubmissionStatus flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override {
205-
return SubmissionStatus::FAILED;
206-
}
207-
};
208-
209200
template <typename GfxFamily>
210201
class MockCsrHw2 : public CommandStreamReceiverHw<GfxFamily> {
211202
public:

shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -492,28 +492,6 @@ TEST(CommandStreamReceiverSimpleTest, givenCsrWhenSubmitiingBatchBufferThenTaskC
492492
executionEnvironment.memoryManager->freeGraphicsMemoryImpl(commandBuffer);
493493
}
494494

495-
TEST(CommandStreamReceiverSimpleTest, givenCsrWhenSubmittingBatchBufferAndFlushFailThenTaskCountIsNotIncremented) {
496-
MockExecutionEnvironment executionEnvironment;
497-
executionEnvironment.prepareRootDeviceEnvironments(1);
498-
executionEnvironment.initializeMemoryManager();
499-
DeviceBitfield deviceBitfield(1);
500-
MockCommandStreamReceiverWithFailingFlush csr(executionEnvironment, 0, deviceBitfield);
501-
GraphicsAllocation *commandBuffer = executionEnvironment.memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr.getRootDeviceIndex(), MemoryConstants::pageSize});
502-
ASSERT_NE(nullptr, commandBuffer);
503-
LinearStream cs(commandBuffer);
504-
505-
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
506-
ResidencyContainer residencyList;
507-
508-
auto expectedTaskCount = csr.peekTaskCount();
509-
csr.submitBatchBuffer(batchBuffer, residencyList);
510-
511-
EXPECT_EQ(expectedTaskCount, csr.peekTaskCount());
512-
EXPECT_EQ(expectedTaskCount, csr.peekLatestFlushedTaskCount());
513-
514-
executionEnvironment.memoryManager->freeGraphicsMemoryImpl(commandBuffer);
515-
}
516-
517495
HWTEST_F(CommandStreamReceiverTest, givenUpdateTaskCountFromWaitWhenSubmitiingBatchBufferThenTaskCountIsIncrementedAndLatestsValuesSetCorrectly) {
518496
DebugManagerStateRestore restorer;
519497
DebugManager.flags.UpdateTaskCountFromWait.set(3);

0 commit comments

Comments
 (0)