Skip to content

Commit 394c0e9

Browse files
Return error when failing on submission
Signed-off-by: Raiyan Latif <[email protected]>
1 parent 38f9df2 commit 394c0e9

File tree

45 files changed

+668
-128
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+668
-128
lines changed

level_zero/core/source/cmdqueue/cmdqueue.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ void CommandQueueImp::reserveLinearStreamSize(size_t size) {
7272
}
7373
}
7474

75-
int CommandQueueImp::submitBatchBuffer(size_t offset, NEO::ResidencyContainer &residencyContainer, void *endingCmdPtr,
76-
bool isCooperative) {
75+
NEO::SubmissionStatus CommandQueueImp::submitBatchBuffer(size_t offset, NEO::ResidencyContainer &residencyContainer, void *endingCmdPtr,
76+
bool isCooperative) {
7777
UNRECOVERABLE_IF(csr == nullptr);
7878

7979
NEO::BatchBuffer batchBuffer(commandStream->getGraphicsAllocation(), offset, 0u, nullptr, false, false,
@@ -85,7 +85,7 @@ int CommandQueueImp::submitBatchBuffer(size_t offset, NEO::ResidencyContainer &r
8585

8686
csr->setActivePartitions(partitionCount);
8787
auto ret = csr->submitBatchBuffer(batchBuffer, csr->getResidencyAllocations());
88-
if (ret) {
88+
if (ret != NEO::SubmissionStatus::SUCCESS) {
8989
return ret;
9090
}
9191

level_zero/core/source/cmdqueue/cmdqueue_hw.inl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2021 Intel Corporation
2+
* Copyright (C) 2020-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -14,6 +14,7 @@
1414
#include "shared/source/command_stream/command_stream_receiver_hw.h"
1515
#include "shared/source/command_stream/linear_stream.h"
1616
#include "shared/source/command_stream/preemption.h"
17+
#include "shared/source/command_stream/submission_status.h"
1718
#include "shared/source/command_stream/thread_arbitration_policy.h"
1819
#include "shared/source/device/device.h"
1920
#include "shared/source/helpers/hw_helper.h"
@@ -480,7 +481,11 @@ ze_result_t CommandQueueHw<gfxCoreFamily>::executeCommandLists(
480481
this->heapContainer.clear();
481482

482483
csr->pollForCompletion();
483-
if (ret) {
484+
485+
if (ret != NEO::SubmissionStatus::SUCCESS) {
486+
if (ret == NEO::SubmissionStatus::OUT_OF_MEMORY) {
487+
return ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY;
488+
}
484489
return ZE_RESULT_ERROR_UNKNOWN;
485490
}
486491

level_zero/core/source/cmdqueue/cmdqueue_imp.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2021 Intel Corporation
2+
* Copyright (C) 2020-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -8,6 +8,7 @@
88
#pragma once
99

1010
#include "shared/source/command_stream/csr_definitions.h"
11+
#include "shared/source/command_stream/submission_status.h"
1112
#include "shared/source/command_stream/submissions_aggregator.h"
1213
#include "shared/source/helpers/constants.h"
1314
#include "shared/source/indirect_heap/indirect_heap.h"
@@ -83,8 +84,8 @@ struct CommandQueueImp : public CommandQueue {
8384
virtual bool getPreemptionCmdProgramming() = 0;
8485

8586
protected:
86-
MOCKABLE_VIRTUAL int submitBatchBuffer(size_t offset, NEO::ResidencyContainer &residencyContainer, void *endingCmdPtr,
87-
bool isCooperative);
87+
MOCKABLE_VIRTUAL NEO::SubmissionStatus submitBatchBuffer(size_t offset, NEO::ResidencyContainer &residencyContainer, void *endingCmdPtr,
88+
bool isCooperative);
8889

8990
ze_result_t synchronizeByPollingForTaskCount(uint64_t timeout);
9091

level_zero/core/test/unit_tests/mocks/mock_cmdqueue.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2021 Intel Corporation
2+
* Copyright (C) 2020-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -72,7 +72,7 @@ struct MockCommandQueueHw : public L0::CommandQueueHw<gfxCoreFamily> {
7272
return ZE_RESULT_SUCCESS;
7373
}
7474

75-
int submitBatchBuffer(size_t offset, NEO::ResidencyContainer &residencyContainer, void *endingCmdPtr, bool isCooperative) override {
75+
NEO::SubmissionStatus submitBatchBuffer(size_t offset, NEO::ResidencyContainer &residencyContainer, void *endingCmdPtr, bool isCooperative) override {
7676
residencyContainerSnapshot = residencyContainer;
7777
return BaseClass::submitBatchBuffer(offset, residencyContainer, endingCmdPtr, isCooperative);
7878
}

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

Lines changed: 89 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2021 Intel Corporation
2+
* Copyright (C) 2020-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -291,8 +291,27 @@ HWTEST_F(CommandQueueCreate, givenCommandStreamReceiverFailsThenSubmitBatchBuffe
291291
false,
292292
returnValue));
293293
ResidencyContainer container;
294-
int ret = commandQueue->submitBatchBuffer(0, container, nullptr, false);
295-
EXPECT_NE(ret, 0);
294+
NEO::SubmissionStatus ret = commandQueue->submitBatchBuffer(0, container, nullptr, false);
295+
EXPECT_EQ(ret, NEO::SubmissionStatus::FAILED);
296+
297+
commandQueue->destroy();
298+
}
299+
300+
HWTEST_F(CommandQueueCreate, givenOutOfMemoryThenSubmitBatchBufferReturnsOutOfMemoryError) {
301+
auto csr = std::make_unique<MockCommandStreamReceiverWithOutOfMemorySubmitBatch>(*neoDevice->getExecutionEnvironment(), 0, neoDevice->getDeviceBitfield());
302+
csr->setupContext(*neoDevice->getDefaultEngine().osContext);
303+
const ze_command_queue_desc_t desc = {};
304+
ze_result_t returnValue;
305+
auto commandQueue = whitebox_cast(CommandQueue::create(productFamily,
306+
device,
307+
csr.get(),
308+
&desc,
309+
false,
310+
false,
311+
returnValue));
312+
ResidencyContainer container;
313+
NEO::SubmissionStatus ret = commandQueue->submitBatchBuffer(0, container, nullptr, false);
314+
EXPECT_EQ(ret, NEO::SubmissionStatus::OUT_OF_MEMORY);
296315

297316
commandQueue->destroy();
298317
}
@@ -1064,6 +1083,73 @@ HWTEST2_F(ExecuteCommandListTests, givenExecuteCommandListWhenItReturnsThenConta
10641083
alignedFree(alloc);
10651084
}
10661085

1086+
template <GFXCORE_FAMILY gfxCoreFamily>
1087+
class MockCommandQueueSubmitBatchBuffer : public MockCommandQueue<gfxCoreFamily> {
1088+
public:
1089+
MockCommandQueueSubmitBatchBuffer(L0::Device *device, NEO::CommandStreamReceiver *csr, const ze_command_queue_desc_t *desc) : MockCommandQueue<gfxCoreFamily>(device, csr, desc) {}
1090+
1091+
ADDMETHOD_NOBASE(submitBatchBuffer, NEO::SubmissionStatus, NEO::SubmissionStatus::SUCCESS,
1092+
(size_t offset, NEO::ResidencyContainer &residencyContainer, void *endingCmdPtr,
1093+
bool isCooperative));
1094+
};
1095+
1096+
HWTEST2_F(ExecuteCommandListTests, givenOutOfMemorySubmitBatchBufferThenExecuteCommandListReturnsOutOfMemoryError, IsAtLeastSkl) {
1097+
ze_command_queue_desc_t desc = {};
1098+
NEO::CommandStreamReceiver *csr;
1099+
device->getCsrForOrdinalAndIndex(&csr, 0u, 0u);
1100+
auto commandQueue = new MockCommandQueueSubmitBatchBuffer<gfxCoreFamily>(device, csr, &desc);
1101+
commandQueue->submitBatchBufferResult = NEO::SubmissionStatus::OUT_OF_MEMORY;
1102+
1103+
commandQueue->initialize(false, false);
1104+
auto commandList = new CommandListCoreFamily<gfxCoreFamily>();
1105+
commandList->initialize(device, NEO::EngineGroupType::Compute, 0u);
1106+
auto commandListHandle = commandList->toHandle();
1107+
1108+
auto res = commandQueue->executeCommandLists(1, &commandListHandle, nullptr, false);
1109+
EXPECT_EQ(ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY, res);
1110+
1111+
commandQueue->destroy();
1112+
commandList->destroy();
1113+
}
1114+
1115+
HWTEST2_F(ExecuteCommandListTests, givenFailingSubmitBatchBufferThenExecuteCommandListReturnsErrorUnknown, IsAtLeastSkl) {
1116+
ze_command_queue_desc_t desc = {};
1117+
NEO::CommandStreamReceiver *csr;
1118+
device->getCsrForOrdinalAndIndex(&csr, 0u, 0u);
1119+
auto commandQueue = new MockCommandQueueSubmitBatchBuffer<gfxCoreFamily>(device, csr, &desc);
1120+
commandQueue->submitBatchBufferResult = NEO::SubmissionStatus::FAILED;
1121+
1122+
commandQueue->initialize(false, false);
1123+
auto commandList = new CommandListCoreFamily<gfxCoreFamily>();
1124+
commandList->initialize(device, NEO::EngineGroupType::Compute, 0u);
1125+
auto commandListHandle = commandList->toHandle();
1126+
1127+
auto res = commandQueue->executeCommandLists(1, &commandListHandle, nullptr, false);
1128+
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, res);
1129+
1130+
commandQueue->destroy();
1131+
commandList->destroy();
1132+
}
1133+
1134+
HWTEST2_F(ExecuteCommandListTests, givenSuccessfulSubmitBatchBufferThenExecuteCommandListReturnsSuccess, IsAtLeastSkl) {
1135+
ze_command_queue_desc_t desc = {};
1136+
NEO::CommandStreamReceiver *csr;
1137+
device->getCsrForOrdinalAndIndex(&csr, 0u, 0u);
1138+
auto commandQueue = new MockCommandQueueSubmitBatchBuffer<gfxCoreFamily>(device, csr, &desc);
1139+
commandQueue->submitBatchBufferResult = NEO::SubmissionStatus::SUCCESS;
1140+
1141+
commandQueue->initialize(false, false);
1142+
auto commandList = new CommandListCoreFamily<gfxCoreFamily>();
1143+
commandList->initialize(device, NEO::EngineGroupType::Compute, 0u);
1144+
auto commandListHandle = commandList->toHandle();
1145+
1146+
auto res = commandQueue->executeCommandLists(1, &commandListHandle, nullptr, false);
1147+
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
1148+
1149+
commandQueue->destroy();
1150+
commandList->destroy();
1151+
}
1152+
10671153
HWTEST2_F(ExecuteCommandListTests, givenCommandQueueHavingTwoB2BCommandListsThenMVSDirtyFlagAndGSBADirtyFlagAreSetOnlyOnce, IsAtLeastSkl) {
10681154
ze_command_queue_desc_t desc = {};
10691155
NEO::CommandStreamReceiver *csr;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2021 Intel Corporation
2+
* Copyright (C) 2020-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -510,7 +510,7 @@ HWTEST2_F(CommandQueueExecuteCommandLists, givenCommandListsWithCooperativeAndNo
510510
HWTEST2_F(CommandQueueExecuteCommandLists, givenCommandListWithCooperativeKernelsWhenExecuteCommandListsIsCalledThenCorrectBatchBufferIsSubmitted, IsAtLeastXeHpCore) {
511511
struct MockCsr : NEO::CommandStreamReceiverHw<FamilyType> {
512512
using NEO::CommandStreamReceiverHw<FamilyType>::CommandStreamReceiverHw;
513-
int submitBatchBuffer(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override {
513+
NEO::SubmissionStatus submitBatchBuffer(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override {
514514
useSingleSubdeviceValue = batchBuffer.useSingleSubdevice;
515515
submitBatchBufferCalled++;
516516
return NEO::CommandStreamReceiver::submitBatchBuffer(batchBuffer, allocationsForResidency);

opencl/test/unit_test/command_queue/blit_enqueue_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2021 Intel Corporation
2+
* Copyright (C) 2019-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -1285,7 +1285,7 @@ struct BlitEnqueueFlushTests : public BlitEnqueueTests<1> {
12851285
public:
12861286
using UltCommandStreamReceiver<FamilyType>::UltCommandStreamReceiver;
12871287

1288-
bool flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override {
1288+
SubmissionStatus flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override {
12891289
latestFlushedCounter = ++(*flushCounter);
12901290
return UltCommandStreamReceiver<FamilyType>::flush(batchBuffer, allocationsForResidency);
12911291
}

opencl/test/unit_test/command_queue/enqueue_thread_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2021 Intel Corporation
2+
* Copyright (C) 2018-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -38,7 +38,7 @@ class CommandStreamReceiverMock : public UltCommandStreamReceiver<FamilyType> {
3838
this->pClDevice = pDevice->getSpecializedDevice<ClDevice>();
3939
}
4040

41-
bool flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override {
41+
SubmissionStatus flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override {
4242
EXPECT_NE(nullptr, batchBuffer.commandBufferAllocation->getUnderlyingBuffer());
4343

4444
toFree.push_back(batchBuffer.commandBufferAllocation);
@@ -47,7 +47,7 @@ class CommandStreamReceiverMock : public UltCommandStreamReceiver<FamilyType> {
4747

4848
EXPECT_TRUE(this->ownershipMutex.try_lock());
4949
this->ownershipMutex.unlock();
50-
return true;
50+
return SubmissionStatus::SUCCESS;
5151
}
5252

5353
~CommandStreamReceiverMock() override {

opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_1_tests.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2021 Intel Corporation
2+
* Copyright (C) 2018-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -247,11 +247,11 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInDefaultModeAndMidThreadP
247247
HWTEST_F(CommandStreamReceiverFlushTaskTests, whenFlushThenCommandBufferAlreadyHasProperTaskCountsAndIsNotIncludedInResidencyVector) {
248248
struct MockCsrFlushCmdBuffer : public MockCommandStreamReceiver {
249249
using MockCommandStreamReceiver::MockCommandStreamReceiver;
250-
bool flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override {
250+
NEO::SubmissionStatus flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override {
251251
EXPECT_EQ(batchBuffer.commandBufferAllocation->getResidencyTaskCount(this->osContext->getContextId()), this->taskCount + 1);
252252
EXPECT_EQ(batchBuffer.commandBufferAllocation->getTaskCount(this->osContext->getContextId()), this->taskCount + 1);
253253
EXPECT_EQ(std::find(allocationsForResidency.begin(), allocationsForResidency.end(), batchBuffer.commandBufferAllocation), allocationsForResidency.end());
254-
return true;
254+
return NEO::SubmissionStatus::SUCCESS;
255255
}
256256
};
257257

@@ -1050,9 +1050,9 @@ struct CommandStreamReceiverHwLog : public UltCommandStreamReceiver<FamilyType>
10501050
flushCount(0) {
10511051
}
10521052

1053-
bool flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override {
1053+
SubmissionStatus flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override {
10541054
++flushCount;
1055-
return true;
1055+
return SubmissionStatus::SUCCESS;
10561056
}
10571057

10581058
int flushCount;

opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_3_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2021 Intel Corporation
2+
* Copyright (C) 2018-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -1873,8 +1873,8 @@ class MockCsrWithFailingFlush : public CommandStreamReceiverHw<GfxFamily> {
18731873
this->dispatchMode = DispatchMode::BatchedDispatch;
18741874
this->tagAddress = &tag;
18751875
}
1876-
bool flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override {
1877-
return false;
1876+
SubmissionStatus flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override {
1877+
return SubmissionStatus::FAILED;
18781878
}
18791879
uint32_t tag = 0;
18801880
};

opencl/test/unit_test/command_stream/command_stream_receiver_with_aub_dump_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2021 Intel Corporation
2+
* Copyright (C) 2018-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -42,14 +42,14 @@ struct MyMockCsr : UltCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> {
4242
: UltCommandStreamReceiver(executionEnvironment, rootDeviceIndex, deviceBitfield) {
4343
}
4444

45-
bool flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override {
45+
SubmissionStatus flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override {
4646
flushParametrization.wasCalled = true;
4747
flushParametrization.receivedBatchBuffer = &batchBuffer;
4848
flushParametrization.receivedEngine = osContext->getEngineType();
4949
flushParametrization.receivedAllocationsForResidency = &allocationsForResidency;
5050
processResidency(allocationsForResidency, 0u);
5151
flushStamp->setStamp(flushParametrization.flushStampToReturn);
52-
return true;
52+
return SubmissionStatus::SUCCESS;
5353
}
5454

5555
void makeResident(GraphicsAllocation &gfxAllocation) override {

opencl/test/unit_test/kernel/kernel_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,8 @@ class CommandStreamReceiverMock : public CommandStreamReceiver {
483483
}
484484
}
485485

486-
bool flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override {
487-
return true;
486+
NEO::SubmissionStatus flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override {
487+
return NEO::SubmissionStatus::SUCCESS;
488488
}
489489

490490
void waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool quickKmdSleep, bool forcePowerSavingMode) override {

0 commit comments

Comments
 (0)