diff --git a/level_zero/core/source/cmdlist/cmdlist.h b/level_zero/core/source/cmdlist/cmdlist.h index 7adb31c6dcd8e..65f2bd4879053 100644 --- a/level_zero/core/source/cmdlist/cmdlist.h +++ b/level_zero/core/source/cmdlist/cmdlist.h @@ -99,9 +99,9 @@ struct CommandList : _ze_command_list_handle_t { const CmdListKernelLaunchParams &launchParams) = 0; virtual ze_result_t appendLaunchCooperativeKernel(ze_kernel_handle_t kernelHandle, const ze_group_count_t *launchKernelArgs, - ze_event_handle_t hSignalEvent, + ze_event_handle_t signalEvent, uint32_t numWaitEvents, - ze_event_handle_t *phWaitEvents) = 0; + ze_event_handle_t *waitEventHandles) = 0; virtual ze_result_t appendLaunchKernelIndirect(ze_kernel_handle_t kernelHandle, const ze_group_count_t *pDispatchArgumentsBuffer, ze_event_handle_t hEvent, uint32_t numWaitEvents, diff --git a/level_zero/core/source/cmdlist/cmdlist_hw.h b/level_zero/core/source/cmdlist/cmdlist_hw.h index 7f0d2f5691912..1d8eb8d4295c7 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw.h +++ b/level_zero/core/source/cmdlist/cmdlist_hw.h @@ -88,9 +88,9 @@ struct CommandListCoreFamily : CommandListImp { const CmdListKernelLaunchParams &launchParams) override; ze_result_t appendLaunchCooperativeKernel(ze_kernel_handle_t kernelHandle, const ze_group_count_t *launchKernelArgs, - ze_event_handle_t hSignalEvent, + ze_event_handle_t signalEvent, uint32_t numWaitEvents, - ze_event_handle_t *phWaitEvents) override; + ze_event_handle_t *waitEventHandles) override; ze_result_t appendLaunchKernelIndirect(ze_kernel_handle_t kernelHandle, const ze_group_count_t *pDispatchArgumentsBuffer, ze_event_handle_t hEvent, uint32_t numWaitEvents, diff --git a/level_zero/core/source/cmdlist/cmdlist_hw.inl b/level_zero/core/source/cmdlist/cmdlist_hw.inl index 5285efd93a319..a22ee08446269 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw.inl @@ -253,18 +253,18 @@ ze_result_t CommandListCoreFamily::appendLaunchKernel(ze_kernel_h template ze_result_t CommandListCoreFamily::appendLaunchCooperativeKernel(ze_kernel_handle_t kernelHandle, const ze_group_count_t *launchKernelArgs, - ze_event_handle_t hSignalEvent, + ze_event_handle_t signalEvent, uint32_t numWaitEvents, - ze_event_handle_t *phWaitEvents) { + ze_event_handle_t *waitEventHandles) { - ze_result_t ret = addEventsToCmdList(numWaitEvents, phWaitEvents); + ze_result_t ret = addEventsToCmdList(numWaitEvents, waitEventHandles); if (ret) { return ret; } Event *event = nullptr; - if (hSignalEvent) { - event = Event::fromHandle(hSignalEvent); + if (signalEvent) { + event = Event::fromHandle(signalEvent); } CmdListKernelLaunchParams launchParams = {}; diff --git a/level_zero/core/source/cmdlist/cmdlist_hw_immediate.h b/level_zero/core/source/cmdlist/cmdlist_hw_immediate.h index ce4aeeb28b6ce..92415bcfbb4f8 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw_immediate.h +++ b/level_zero/core/source/cmdlist/cmdlist_hw_immediate.h @@ -118,6 +118,12 @@ struct CommandListCoreFamilyImmediate : public CommandListCoreFamily::appendMemoryRangesBar return flushImmediate(ret, true); } +template +ze_result_t CommandListCoreFamilyImmediate::appendLaunchCooperativeKernel(ze_kernel_handle_t kernelHandle, + const ze_group_count_t *launchKernelArgs, + ze_event_handle_t signalEvent, + uint32_t numWaitEvents, + ze_event_handle_t *waitEventHandles) { + if (this->isFlushTaskSubmissionEnabled) { + checkAvailableSpace(); + } + auto ret = CommandListCoreFamily::appendLaunchCooperativeKernel(kernelHandle, launchKernelArgs, signalEvent, numWaitEvents, waitEventHandles); + return flushImmediate(ret, true); +} + template ze_result_t CommandListCoreFamilyImmediate::flushImmediate(ze_result_t inputRet, bool performMigration) { if (inputRet == ZE_RESULT_SUCCESS) { 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 4a1124079dd6f..778056e1c43c2 100644 --- a/level_zero/core/test/unit_tests/mocks/mock_cmdlist.h +++ b/level_zero/core/test/unit_tests/mocks/mock_cmdlist.h @@ -180,9 +180,9 @@ struct MockCommandList : public CommandList { ADDMETHOD_NOBASE(appendLaunchCooperativeKernel, ze_result_t, ZE_RESULT_SUCCESS, (ze_kernel_handle_t kernelHandle, const ze_group_count_t *launchKernelArgs, - ze_event_handle_t hSignalEvent, + ze_event_handle_t signalEvent, uint32_t numWaitEvents, - ze_event_handle_t *phWaitEvents)); + ze_event_handle_t *waitEventHandles)); ADDMETHOD_NOBASE(appendLaunchKernelIndirect, ze_result_t, ZE_RESULT_SUCCESS, (ze_kernel_handle_t kernelHandle, diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_1.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_1.cpp index 0349f7ac59371..3d429ad06536d 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_1.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_1.cpp @@ -784,5 +784,41 @@ HWTEST_F(CommandListAppendLaunchKernel, givenInvalidEventListWhenAppendLaunchCoo EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, returnValue); } +HWTEST2_F(CommandListAppendLaunchKernel, givenImmediateCommandListWhenAppendLaunchCooperativeKernelUsingFlushTaskThenExpectCorrectExecuteCall, IsAtLeastSkl) { + createKernel(); + + MockCommandListImmediateHw cmdList; + cmdList.isFlushTaskSubmissionEnabled = true; + cmdList.cmdListType = CommandList::CommandListType::TYPE_IMMEDIATE; + cmdList.csr = device->getNEODevice()->getDefaultEngine().commandStreamReceiver; + cmdList.initialize(device, NEO::EngineGroupType::RenderCompute, 0u); + + ze_group_count_t groupCount{1, 1, 1}; + ze_result_t returnValue; + + returnValue = cmdList.appendLaunchCooperativeKernel(kernel->toHandle(), &groupCount, nullptr, 0, nullptr); + EXPECT_EQ(0u, cmdList.executeCommandListImmediateCalledCount); + EXPECT_EQ(1u, cmdList.executeCommandListImmediateWithFlushTaskCalledCount); + EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue); +} + +HWTEST2_F(CommandListAppendLaunchKernel, givenImmediateCommandListWhenAppendLaunchCooperativeKernelNotUsingFlushTaskThenExpectCorrectExecuteCall, IsAtLeastSkl) { + createKernel(); + + MockCommandListImmediateHw cmdList; + cmdList.isFlushTaskSubmissionEnabled = false; + cmdList.cmdListType = CommandList::CommandListType::TYPE_IMMEDIATE; + cmdList.csr = device->getNEODevice()->getDefaultEngine().commandStreamReceiver; + cmdList.initialize(device, NEO::EngineGroupType::RenderCompute, 0u); + + ze_group_count_t groupCount{1, 1, 1}; + ze_result_t returnValue; + + returnValue = cmdList.appendLaunchCooperativeKernel(kernel->toHandle(), &groupCount, nullptr, 0, nullptr); + EXPECT_EQ(1u, cmdList.executeCommandListImmediateCalledCount); + EXPECT_EQ(0u, cmdList.executeCommandListImmediateWithFlushTaskCalledCount); + EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue); +} + } // namespace ult } // namespace L0