mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-18 13:54:58 +08:00
Add support for cooperative kernels to immediate command lists
Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
0270e0f8a5
commit
add47dc79f
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -266,18 +266,18 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernel(ze_kernel_h
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandListCoreFamily<gfxCoreFamily>::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 = {};
|
||||
|
||||
@@ -118,6 +118,12 @@ struct CommandListCoreFamilyImmediate : public CommandListCoreFamily<gfxCoreFami
|
||||
uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) override;
|
||||
|
||||
ze_result_t 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) override;
|
||||
|
||||
MOCKABLE_VIRTUAL ze_result_t executeCommandListImmediateWithFlushTask(bool performMigration);
|
||||
|
||||
void checkAvailableSpace();
|
||||
|
||||
@@ -501,6 +501,19 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendMemoryRangesBar
|
||||
return flushImmediate(ret, true, hSignalEvent);
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::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<gfxCoreFamily>::appendLaunchCooperativeKernel(kernelHandle, launchKernelArgs, signalEvent, numWaitEvents, waitEventHandles);
|
||||
return flushImmediate(ret, true, signalEvent);
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::flushImmediate(ze_result_t inputRet, bool performMigration, ze_event_handle_t signalEvent) {
|
||||
if (inputRet == ZE_RESULT_SUCCESS) {
|
||||
|
||||
@@ -186,9 +186,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,
|
||||
|
||||
@@ -784,5 +784,35 @@ HWTEST_F(CommandListAppendLaunchKernel, givenInvalidEventListWhenAppendLaunchCoo
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, returnValue);
|
||||
}
|
||||
|
||||
HWTEST2_F(CommandListAppendLaunchKernel, givenImmediateCommandListWhenAppendLaunchCooperativeKernelUsingFlushTaskThenExpectCorrectExecuteCall, IsAtLeastSkl) {
|
||||
createKernel();
|
||||
MockCommandListImmediateHw<gfxCoreFamily> 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<gfxCoreFamily> 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
|
||||
|
||||
Reference in New Issue
Block a user