diff --git a/level_zero/api/core/ze_cmdlist_api_entrypoints.h b/level_zero/api/core/ze_cmdlist_api_entrypoints.h index 8c2ccba922..a2ac5c131e 100644 --- a/level_zero/api/core/ze_cmdlist_api_entrypoints.h +++ b/level_zero/api/core/ze_cmdlist_api_entrypoints.h @@ -94,6 +94,16 @@ ze_result_t zeCommandListIsImmediate( return L0::CommandList::fromHandle(hCommandList)->isImmediate(pIsImmediate); } +ze_result_t zeCommandListImmediateAppendCommandLists( + ze_command_list_handle_t hCommandListImmediate, + uint32_t numCommandLists, + ze_command_list_handle_t *phCommandLists, + ze_event_handle_t hSignalEvent, + uint32_t numWaitEvents, + ze_event_handle_t *phWaitEvents) { + return L0::CommandList::fromHandle(hCommandListImmediate)->appendCommandLists(numCommandLists, phCommandLists, hSignalEvent, numWaitEvents, phWaitEvents); +} + } // namespace L0 extern "C" { @@ -192,4 +202,20 @@ ZE_APIEXPORT ze_result_t ZE_APICALL zeCommandListIsImmediate( hCommandList, pIsImmediate); } + +ZE_APIEXPORT ze_result_t ZE_APICALL zeCommandListImmediateAppendCommandLists( + ze_command_list_handle_t hCommandListImmediate, + uint32_t numCommandLists, + ze_command_list_handle_t *phCommandLists, + ze_event_handle_t hSignalEvent, + uint32_t numWaitEvents, + ze_event_handle_t *phWaitEvents) { + return L0::zeCommandListImmediateAppendCommandLists( + hCommandListImmediate, + numCommandLists, + phCommandLists, + hSignalEvent, + numWaitEvents, + phWaitEvents); } +} \ No newline at end of file diff --git a/level_zero/api/core/ze_core_loader.cpp b/level_zero/api/core/ze_core_loader.cpp index 803d334e67..992599ffef 100644 --- a/level_zero/api/core/ze_core_loader.cpp +++ b/level_zero/api/core/ze_core_loader.cpp @@ -385,6 +385,21 @@ zeGetCommandListProcAddrTable( return result; } +ZE_APIEXPORT ze_result_t ZE_APICALL +zeGetCommandListExpProcAddrTable( + ze_api_version_t version, + ze_command_list_exp_dditable_t *pDdiTable) { + if (nullptr == pDdiTable) + return ZE_RESULT_ERROR_INVALID_ARGUMENT; + if (ZE_MAJOR_VERSION(driverDdiTable.version) != ZE_MAJOR_VERSION(version) || + ZE_MINOR_VERSION(driverDdiTable.version) > ZE_MINOR_VERSION(version)) + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + + ze_result_t result = ZE_RESULT_SUCCESS; + fillDdiEntry(pDdiTable->pfnImmediateAppendCommandListsExp, L0::zeCommandListImmediateAppendCommandLists, version, ZE_API_VERSION_1_9); + return result; +} + ZE_APIEXPORT ze_result_t ZE_APICALL zeGetFenceProcAddrTable( ze_api_version_t version, diff --git a/level_zero/core/source/cmdlist/cmdlist.h b/level_zero/core/source/cmdlist/cmdlist.h index c79ac54ff4..5c2600ebb1 100644 --- a/level_zero/core/source/cmdlist/cmdlist.h +++ b/level_zero/core/source/cmdlist/cmdlist.h @@ -175,6 +175,9 @@ struct CommandList : _ze_command_list_handle_t { virtual ze_result_t getImmediateIndex(uint32_t *pIndex) = 0; virtual ze_result_t isImmediate(ze_bool_t *pIsImmediate) = 0; + virtual ze_result_t appendCommandLists(uint32_t numCommandLists, ze_command_list_handle_t *phCommandLists, + ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents) = 0; + static CommandList *create(uint32_t productFamily, Device *device, NEO::EngineGroupType engineGroupType, ze_command_list_flags_t flags, ze_result_t &resultValue, bool internalUsage); diff --git a/level_zero/core/source/cmdlist/cmdlist_hw.h b/level_zero/core/source/cmdlist/cmdlist_hw.h index 5988cc6cc7..004cd39a09 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw.h +++ b/level_zero/core/source/cmdlist/cmdlist_hw.h @@ -203,6 +203,8 @@ struct CommandListCoreFamily : public CommandListImp { MOCKABLE_VIRTUAL void appendSynchronizedDispatchInitializationSection(); MOCKABLE_VIRTUAL void appendSynchronizedDispatchCleanupSection(); + ze_result_t appendCommandLists(uint32_t numCommandLists, ze_command_list_handle_t *phCommandLists, + ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents) override; ze_result_t reserveSpace(size_t size, void **ptr) override; ze_result_t reset() override; diff --git a/level_zero/core/source/cmdlist/cmdlist_hw.inl b/level_zero/core/source/cmdlist/cmdlist_hw.inl index 865be2416f..738f378e84 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw.inl @@ -4103,4 +4103,11 @@ void CommandListCoreFamily::appendCopyOperationFence(Event *signa } } +template +ze_result_t CommandListCoreFamily::appendCommandLists(uint32_t numCommandLists, ze_command_list_handle_t *phCommandLists, + ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents) { + + return ZE_RESULT_ERROR_INVALID_ARGUMENT; +} + } // namespace L0 diff --git a/level_zero/core/source/cmdlist/cmdlist_hw_immediate.h b/level_zero/core/source/cmdlist/cmdlist_hw_immediate.h index eb3c3e447e..57d8ed7559 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw_immediate.h +++ b/level_zero/core/source/cmdlist/cmdlist_hw_immediate.h @@ -184,6 +184,8 @@ struct CommandListCoreFamilyImmediate : public CommandListCoreFamily::allocateOrReuseKernelPrivate } } +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) { + + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + } // namespace L0 diff --git a/level_zero/core/test/unit_tests/mocks/mock_cmdlist.h b/level_zero/core/test/unit_tests/mocks/mock_cmdlist.h index ced179b779..922181f10d 100644 --- a/level_zero/core/test/unit_tests/mocks/mock_cmdlist.h +++ b/level_zero/core/test/unit_tests/mocks/mock_cmdlist.h @@ -566,6 +566,9 @@ struct MockCommandList : public CommandList { ADDMETHOD_NOBASE_VOIDRETURN(appendMultiPartitionEpilogue, (void)); ADDMETHOD_NOBASE(hostSynchronize, ze_result_t, ZE_RESULT_SUCCESS, (uint64_t timeout)); + ADDMETHOD_NOBASE(appendCommandLists, ze_result_t, ZE_RESULT_SUCCESS, + (uint32_t numCommandLists, ze_command_list_handle_t *phCommandLists, + ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents)); uint8_t *batchBuffer = nullptr; NEO::GraphicsAllocation *mockAllocation = nullptr; diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp index 0ea32fc206..1417756537 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp @@ -2048,6 +2048,27 @@ TEST_F(CommandListCreate, givenImmediateCommandListWhenThereIsNoEnoughSpaceForIm whiteBoxCmdList->csr->getInternalAllocationStorage()->getTemporaryAllocations().freeAllGraphicsAllocations(device->getNEODevice()); } +TEST_F(CommandListCreate, whenCreatingImmediateCommandListAndAppendCommandListsThenReturnsUnsupported) { + const ze_command_queue_desc_t desc = {}; + ze_result_t returnValue; + std::unique_ptr commandList(CommandList::createImmediate(productFamily, device, &desc, false, NEO::EngineGroupType::renderCompute, returnValue)); + ASSERT_NE(nullptr, commandList); + + EXPECT_TRUE(commandList->isImmediateType()); + auto result = commandList->appendCommandLists(0u, nullptr, nullptr, 0u, nullptr); + EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); +} + +TEST_F(CommandListCreate, givenCreatingRegularCommandlistAndppendCommandListsThenReturnInvalidArgument) { + ze_result_t returnValue; + std::unique_ptr commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::renderCompute, 0u, returnValue, false)); + ASSERT_NE(nullptr, commandList); + + EXPECT_FALSE(commandList->isImmediateType()); + auto result = commandList->appendCommandLists(0u, nullptr, nullptr, 0u, nullptr); + EXPECT_EQ(result, ZE_RESULT_ERROR_INVALID_ARGUMENT); +} + HWTEST2_F(CommandListCreate, GivenGpuHangOnSynchronizingWhenCreatingImmediateCommandListAndWaitingOnEventsThenDeviceLostIsReturned, IsSKL) { DebugManagerStateRestore restorer;