Return submission status from flushHandler function

Related-To: NEO-7412
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2022-11-07 11:50:09 +00:00
committed by Compute-Runtime-Automation
parent 6cbb3cfb05
commit 5b11a4a5fa
5 changed files with 84 additions and 4 deletions

View File

@ -10,6 +10,7 @@
#include "shared/source/command_container/command_encoder.h"
#include "shared/source/command_stream/command_stream_receiver_hw.h"
#include "shared/source/command_stream/wait_status.h"
#include "shared/source/helpers/completion_stamp.h"
#include "shared/source/helpers/hw_helper.h"
#include "shared/source/helpers/hw_info.h"
#include "shared/source/helpers/logical_state_helper.h"
@ -189,6 +190,13 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::executeCommandListImm
dispatchFlags,
*(this->device->getNEODevice()));
if (completionStamp.taskCount > NEO::CompletionStamp::notReady) {
if (completionStamp.taskCount == NEO::CompletionStamp::outOfHostMemory) {
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
}
return ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY;
}
if (this->isSyncModeQueue) {
auto timeoutMicroseconds = NEO::TimeoutControls::maxTimeout;
const auto waitStatus = this->csr->waitForCompletionWithTimeout(NEO::WaitParams{false, false, timeoutMicroseconds}, completionStamp.taskCount);

View File

@ -132,6 +132,40 @@ HWTEST2_F(CommandListExecuteImmediate, whenExecutingCommandListImmediateWithFlus
EXPECT_FALSE(commandListImmediate.containsAnyKernel);
}
HWTEST2_F(CommandListExecuteImmediate, whenExecutingCommandListImmediateWithFlushTaskThenSuccessIsReturned, IsAtLeastSkl) {
std::unique_ptr<L0::CommandList> commandList;
const ze_command_queue_desc_t desc = {};
ze_result_t returnValue;
commandList.reset(CommandList::createImmediate(productFamily, device, &desc, false, NEO::EngineGroupType::RenderCompute, returnValue));
auto &commandListImmediate = static_cast<MockCommandListImmediate<gfxCoreFamily> &>(*commandList);
EXPECT_EQ(ZE_RESULT_SUCCESS, commandListImmediate.executeCommandListImmediateWithFlushTask(false));
}
HWTEST2_F(CommandListExecuteImmediate, givenOutOfHostMemoryErrorOnFlushWhenExecutingCommandListImmediateWithFlushTaskThenProperErrorIsReturned, IsAtLeastSkl) {
std::unique_ptr<L0::CommandList> commandList;
const ze_command_queue_desc_t desc = {};
ze_result_t returnValue;
commandList.reset(CommandList::createImmediate(productFamily, device, &desc, false, NEO::EngineGroupType::RenderCompute, returnValue));
auto &commandListImmediate = static_cast<MockCommandListImmediate<gfxCoreFamily> &>(*commandList);
auto &commandStreamReceiver = neoDevice->getUltCommandStreamReceiver<FamilyType>();
commandStreamReceiver.flushReturnValue = SubmissionStatus::OUT_OF_HOST_MEMORY;
EXPECT_EQ(ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY, commandListImmediate.executeCommandListImmediateWithFlushTask(false));
}
HWTEST2_F(CommandListExecuteImmediate, givenOutOfDeviceMemoryErrorOnFlushWhenExecutingCommandListImmediateWithFlushTaskThenProperErrorIsReturned, IsAtLeastSkl) {
std::unique_ptr<L0::CommandList> commandList;
const ze_command_queue_desc_t desc = {};
ze_result_t returnValue;
commandList.reset(CommandList::createImmediate(productFamily, device, &desc, false, NEO::EngineGroupType::RenderCompute, returnValue));
auto &commandListImmediate = static_cast<MockCommandListImmediate<gfxCoreFamily> &>(*commandList);
auto &commandStreamReceiver = neoDevice->getUltCommandStreamReceiver<FamilyType>();
commandStreamReceiver.flushReturnValue = SubmissionStatus::OUT_OF_MEMORY;
EXPECT_EQ(ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY, commandListImmediate.executeCommandListImmediateWithFlushTask(false));
}
using CommandListTest = Test<DeviceFixture>;
using IsDcFlushSupportedPlatform = IsWithinGfxCore<IGFX_GEN9_CORE, IGFX_XE_HP_CORE>;

View File

@ -104,7 +104,7 @@ class CommandStreamReceiverHw : public CommandStreamReceiver {
void flushPipeControl();
void flushSmallTask(LinearStream &commandStreamTask,
size_t commandStreamStartTask);
void flushHandler(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency);
SubmissionStatus flushHandler(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency);
bool isUpdateTagFromWaitEnabled() override;
void updateTagFromWait() override;

View File

@ -608,7 +608,11 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
if (submitCSR || submitTask) {
if (this->dispatchMode == DispatchMode::ImmediateDispatch) {
flushHandler(batchBuffer, this->getResidencyAllocations());
auto submissionStatus = flushHandler(batchBuffer, this->getResidencyAllocations());
if (submissionStatus != SubmissionStatus::SUCCESS) {
CompletionStamp completionStamp = {CompletionStamp::getTaskCountFromSubmissionStatusError(submissionStatus)};
return completionStamp;
}
if (dispatchFlags.blocking || dispatchFlags.dcFlush || dispatchFlags.guardCommandBufferWithPipeControl) {
this->latestFlushedTaskCount = this->taskCount + 1;
}
@ -1273,9 +1277,10 @@ void CommandStreamReceiverHw<GfxFamily>::flushSmallTask(LinearStream &commandStr
}
template <typename GfxFamily>
inline void CommandStreamReceiverHw<GfxFamily>::flushHandler(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) {
flush(batchBuffer, allocationsForResidency);
inline SubmissionStatus CommandStreamReceiverHw<GfxFamily>::flushHandler(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) {
auto status = flush(batchBuffer, allocationsForResidency);
makeSurfacePackNonResident(allocationsForResidency, true);
return status;
}
template <typename GfxFamily>

View File

@ -2345,3 +2345,36 @@ HWTEST_F(CommandStreamReceiverHwTest, givenFailureOnFlushWhenFlushingBcsTaskThen
commandStreamReceiver.flushReturnValue = SubmissionStatus::OUT_OF_MEMORY;
EXPECT_EQ(CompletionStamp::outOfDeviceMemory, commandStreamReceiver.flushBcsTask(container, true, false, *pDevice));
}
HWTEST_F(CommandStreamReceiverHwTest, givenOutOfHostMemoryFailureOnFlushWhenFlushingTaskThenErrorIsPropagated) {
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
commandStreamReceiver.flushReturnValue = SubmissionStatus::OUT_OF_HOST_MEMORY;
auto completionStamp = commandStreamReceiver.flushTask(commandStream,
0,
&dsh,
&ioh,
nullptr,
taskLevel,
flushTaskFlags,
*pDevice);
EXPECT_EQ(CompletionStamp::outOfHostMemory, completionStamp.taskCount);
}
HWTEST_F(CommandStreamReceiverHwTest, givenOutOfDeviceMemoryFailureOnFlushWhenFlushingTaskThenErrorIsPropagated) {
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
commandStreamReceiver.flushReturnValue = SubmissionStatus::OUT_OF_MEMORY;
auto completionStamp = commandStreamReceiver.flushTask(commandStream,
0,
&dsh,
&ioh,
nullptr,
taskLevel,
flushTaskFlags,
*pDevice);
EXPECT_EQ(CompletionStamp::outOfDeviceMemory, completionStamp.taskCount);
}