diff --git a/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl b/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl index 6bf0bc6ba7..99d557d7f3 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl @@ -757,13 +757,16 @@ ze_result_t CommandListCoreFamilyImmediate::appendWaitOnEvents(ui if (allSignaled) { return ZE_RESULT_SUCCESS; } - checkAvailableSpace(numEvents, false, commonImmediateCommandSize); + + if (!skipFlush) { + checkAvailableSpace(numEvents, false, commonImmediateCommandSize); + } auto ret = CommandListCoreFamily::appendWaitOnEvents(numEvents, phWaitEvents, outWaitCmds, relaxedOrderingAllowed, trackDependencies, apiRequest, skipAddingWaitEventsToResidency, false); this->dependenciesPresent = true; if (skipFlush) { - return ZE_RESULT_SUCCESS; + return ret; } return flushImmediate(ret, true, true, false, false, nullptr); @@ -1443,8 +1446,13 @@ template ze_result_t CommandListCoreFamilyImmediate::appendCommandLists(uint32_t numCommandLists, ze_command_list_handle_t *phCommandLists, ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents) { + auto ret = ZE_RESULT_SUCCESS; if (numWaitEvents) { - this->appendWaitOnEvents(numWaitEvents, phWaitEvents, nullptr, false, true, true, true, true); + checkAvailableSpace(numWaitEvents, false, commonImmediateCommandSize); + ret = this->appendWaitOnEvents(numWaitEvents, phWaitEvents, nullptr, false, true, true, true, true); + if (ret != ZE_RESULT_SUCCESS) { + return ret; + } } return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; diff --git a/level_zero/core/source/cmdqueue/cmdqueue_hw.h b/level_zero/core/source/cmdqueue/cmdqueue_hw.h index b3d741fabb..ec4014b288 100644 --- a/level_zero/core/source/cmdqueue/cmdqueue_hw.h +++ b/level_zero/core/source/cmdqueue/cmdqueue_hw.h @@ -15,7 +15,6 @@ namespace NEO { class ScratchSpaceController; -class LinearStream; } // namespace NEO namespace L0 { diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_wait_on_events.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_wait_on_events.cpp index 18b6ae39ce..439c067962 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_wait_on_events.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_wait_on_events.cpp @@ -199,7 +199,7 @@ HWTEST2_F(CommandListAppendWaitOnEvent, givenImmediateCmdListWithDirectSubmissio ASSERT_NE(cmdList.end(), itor); } -HWTEST2_F(CommandListAppendWaitOnEvent, givenImmediateCmdListWithDirectSubmissionAndAppendingRegularCommandlistWithWaitOnEventsThenUseSemaphore, IsAtLeastXeHpcCore) { +HWTEST2_F(CommandListAppendWaitOnEvent, givenImmediateCmdListAndAppendingRegularCommandlistWithWaitOnEventsThenUseSemaphore, IsAtLeastXeHpcCore) { using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT; ze_command_queue_desc_t desc = {}; @@ -207,12 +207,6 @@ HWTEST2_F(CommandListAppendWaitOnEvent, givenImmediateCmdListWithDirectSubmissio ze_result_t returnValue; std::unique_ptr immCommandList(CommandList::createImmediate(productFamily, device, &desc, false, NEO::EngineGroupType::renderCompute, returnValue)); ASSERT_NE(nullptr, immCommandList); - auto whiteBoxCmdList = static_cast(immCommandList.get()); - - auto ultCsr = static_cast *>(whiteBoxCmdList->csr); - - auto directSubmission = new MockDirectSubmissionHw>(*ultCsr); - ultCsr->directSubmission.reset(directSubmission); ze_event_handle_t hEventHandle = event->toHandle(); auto result = immCommandList->appendCommandLists(0u, nullptr, nullptr, 1u, &hEventHandle); @@ -230,6 +224,25 @@ HWTEST2_F(CommandListAppendWaitOnEvent, givenImmediateCmdListWithDirectSubmissio ASSERT_NE(cmdList.end(), itor); } +template +class MockAppendRegularCommandlistWithWaitOnEvents : public MockCommandListImmediateHw { + public: + MockAppendRegularCommandlistWithWaitOnEvents() : MockCommandListImmediateHw() {} + ze_result_t appendWaitOnEvents(uint32_t numEvents, ze_event_handle_t *phEvent, CommandToPatchContainer *outWaitCmds, + bool relaxedOrderingAllowed, bool trackDependencies, bool apiRequest, bool skipAddingWaitEventsToResidency, bool skipFlush) override { + return ZE_RESULT_ERROR_INVALID_ARGUMENT; + }; +}; + +HWTEST2_F(CommandListAppendWaitOnEvent, givenImmediateCmdListAndAppendingRegularCommandlistWithWaitOnEventsAndForceInvalidReturnThenCheckReturnStatus, IsAtLeastXeHpcCore) { + MockAppendRegularCommandlistWithWaitOnEvents cmdList; + cmdList.csr = device->getNEODevice()->getInternalEngine().commandStreamReceiver; + cmdList.initialize(device, NEO::EngineGroupType::compute, 0u); + ze_event_handle_t hEventHandle = event->toHandle(); + auto result = cmdList.appendCommandLists(0u, nullptr, nullptr, 1u, &hEventHandle); + ASSERT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, result); +} + HWTEST2_F(CommandListAppendWaitOnEvent, givenImmediateCmdListWithDirectSubmissionAndRelaxedOrderingWhenAppendingBarrierThenUseSemaphore, IsAtLeastXeHpcCore) { using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT;