refactor: add residency parameter to command list append kernel call

Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz 2024-02-13 12:19:57 +00:00 committed by Compute-Runtime-Automation
parent cccd9a3703
commit 186e3d2b83
13 changed files with 60 additions and 28 deletions

View File

@ -97,7 +97,7 @@ struct CommandList : _ze_command_list_handle_t {
ze_event_handle_t *phWaitEvents, bool relaxedOrderingDispatch) = 0;
virtual ze_result_t appendLaunchKernel(ze_kernel_handle_t kernelHandle, const ze_group_count_t &threadGroupDimensions,
ze_event_handle_t hEvent, uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents,
const CmdListKernelLaunchParams &launchParams, bool relaxedOrderingDispatch) = 0;
CmdListKernelLaunchParams &launchParams, bool relaxedOrderingDispatch) = 0;
virtual ze_result_t appendLaunchCooperativeKernel(ze_kernel_handle_t kernelHandle,
const ze_group_count_t &launchKernelArgs,
ze_event_handle_t hSignalEvent,

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Intel Corporation
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -105,7 +105,7 @@ struct CommandListCoreFamily : public CommandListImp {
const ze_group_count_t &threadGroupDimensions,
ze_event_handle_t hEvent, uint32_t numWaitEvents,
ze_event_handle_t *phWaitEvents,
const CmdListKernelLaunchParams &launchParams, bool relaxedOrderingDispatch) override;
CmdListKernelLaunchParams &launchParams, bool relaxedOrderingDispatch) override;
ze_result_t appendLaunchCooperativeKernel(ze_kernel_handle_t kernelHandle,
const ze_group_count_t &launchKernelArgs,
ze_event_handle_t hSignalEvent,
@ -253,18 +253,18 @@ struct CommandListCoreFamily : public CommandListImp {
virtual ze_result_t appendLaunchKernelWithParams(Kernel *kernel,
const ze_group_count_t &threadGroupDimensions,
Event *event,
const CmdListKernelLaunchParams &launchParams);
CmdListKernelLaunchParams &launchParams);
MOCKABLE_VIRTUAL ze_result_t appendLaunchKernelSplit(Kernel *kernel,
const ze_group_count_t &threadGroupDimensions,
Event *event,
const CmdListKernelLaunchParams &launchParams);
CmdListKernelLaunchParams &launchParams);
ze_result_t appendUnalignedFillKernel(bool isStateless,
uint32_t unalignedSize,
const AlignedAllocationData &dstAllocation,
const void *pattern,
Event *signalEvent,
const CmdListKernelLaunchParams &launchParams);
CmdListKernelLaunchParams &launchParams);
void appendWaitOnSingleEvent(Event *event, bool relaxedOrderingAllowed);

View File

@ -348,7 +348,7 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernel(ze_kernel_h
ze_event_handle_t hEvent,
uint32_t numWaitEvents,
ze_event_handle_t *phWaitEvents,
const CmdListKernelLaunchParams &launchParams, bool relaxedOrderingDispatch) {
CmdListKernelLaunchParams &launchParams, bool relaxedOrderingDispatch) {
NEO::Device *neoDevice = device->getNEODevice();
uint32_t callId = 0;
@ -1804,7 +1804,7 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendMemoryPrefetch(const voi
}
template <GFXCORE_FAMILY gfxCoreFamily>
ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendUnalignedFillKernel(bool isStateless, uint32_t unalignedSize, const AlignedAllocationData &dstAllocation, const void *pattern, Event *signalEvent, const CmdListKernelLaunchParams &launchParams) {
ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendUnalignedFillKernel(bool isStateless, uint32_t unalignedSize, const AlignedAllocationData &dstAllocation, const void *pattern, Event *signalEvent, CmdListKernelLaunchParams &launchParams) {
const bool isHeapless = this->isHeaplessModeEnabled();
auto builtin = BuiltinTypeHelper::adjustBuiltinType<Builtin::fillBufferImmediateLeftOver>(isStateless, isHeapless);

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Intel Corporation
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -56,7 +56,7 @@ struct CommandListCoreFamilyImmediate : public CommandListCoreFamily<gfxCoreFami
const ze_group_count_t &threadGroupDimensions,
ze_event_handle_t hEvent, uint32_t numWaitEvents,
ze_event_handle_t *phWaitEvents,
const CmdListKernelLaunchParams &launchParams, bool relaxedOrderingDispatch) override;
CmdListKernelLaunchParams &launchParams, bool relaxedOrderingDispatch) override;
ze_result_t appendLaunchKernelIndirect(ze_kernel_handle_t kernelHandle,
const ze_group_count_t &pDispatchArgumentsBuffer,

View File

@ -433,7 +433,7 @@ template <GFXCORE_FAMILY gfxCoreFamily>
ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendLaunchKernel(
ze_kernel_handle_t kernelHandle, const ze_group_count_t &threadGroupDimensions,
ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents,
const CmdListKernelLaunchParams &launchParams, bool relaxedOrderingDispatch) {
CmdListKernelLaunchParams &launchParams, bool relaxedOrderingDispatch) {
relaxedOrderingDispatch = isRelaxedOrderingDispatchAllowed(numWaitEvents);
bool stallingCmdsForRelaxedOrdering = hasStallingCmdsForRelaxedOrdering(numWaitEvents, relaxedOrderingDispatch);

View File

@ -49,7 +49,7 @@ template <GFXCORE_FAMILY gfxCoreFamily>
ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernelWithParams(Kernel *kernel,
const ze_group_count_t &threadGroupDimensions,
Event *event,
const CmdListKernelLaunchParams &launchParams) {
CmdListKernelLaunchParams &launchParams) {
UNRECOVERABLE_IF(kernel == nullptr);
UNRECOVERABLE_IF(launchParams.skipInOrderNonWalkerSignaling);
const auto driverHandle = static_cast<DriverHandleImp *>(device->getDriverHandle());
@ -324,7 +324,7 @@ template <GFXCORE_FAMILY gfxCoreFamily>
ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernelSplit(Kernel *kernel,
const ze_group_count_t &threadGroupDimensions,
Event *event,
const CmdListKernelLaunchParams &launchParams) {
CmdListKernelLaunchParams &launchParams) {
return appendLaunchKernelWithParams(kernel, threadGroupDimensions, nullptr, launchParams);
}

View File

@ -83,7 +83,7 @@ bool CommandListCoreFamily<gfxCoreFamily>::isInOrderNonWalkerSignalingRequired(c
template <GFXCORE_FAMILY gfxCoreFamily>
ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernelWithParams(Kernel *kernel, const ze_group_count_t &threadGroupDimensions, Event *event,
const CmdListKernelLaunchParams &launchParams) {
CmdListKernelLaunchParams &launchParams) {
if (NEO::debugManager.flags.ForcePipeControlPriorToWalker.get()) {
NEO::PipeControlArgs args;
@ -388,11 +388,13 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernelWithParams(K
// Attach kernel residency to our CommandList residency
{
commandContainer.addToResidencyContainer(kernelImmutableData->getIsaGraphicsAllocation());
if (!launchParams.omitAddingKernelResidency) {
auto &residencyContainer = kernel->getResidencyContainer();
for (auto resource : residencyContainer) {
commandContainer.addToResidencyContainer(resource);
}
}
}
// Store PrintfBuffer from a kernel
{
@ -485,7 +487,7 @@ template <GFXCORE_FAMILY gfxCoreFamily>
ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernelSplit(Kernel *kernel,
const ze_group_count_t &threadGroupDimensions,
Event *event,
const CmdListKernelLaunchParams &launchParams) {
CmdListKernelLaunchParams &launchParams) {
if (event) {
if (eventSignalPipeControl(launchParams.isKernelSplitOperation, getDcFlushRequired(event->isSignalScope()))) {
event = nullptr;

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 Intel Corporation
* Copyright (C) 2023-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -27,5 +27,6 @@ struct CmdListKernelLaunchParams {
bool isHostSignalScopeEvent = false;
bool skipInOrderNonWalkerSignaling = false;
bool pipeControlSignalling = false;
bool omitAddingKernelResidency = false;
};
} // namespace L0

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Intel Corporation
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -216,7 +216,7 @@ class AppendFillFixture : public DeviceFixture {
ze_result_t appendLaunchKernelWithParams(Kernel *kernel,
const ze_group_count_t &pThreadGroupDimensions,
L0::Event *event,
const CmdListKernelLaunchParams &launchParams) override {
CmdListKernelLaunchParams &launchParams) override {
if (numberOfCallsToAppendLaunchKernelWithParams == thresholdOfCallsToAppendLaunchKernelWithParamsToFail) {
return ZE_RESULT_ERROR_UNKNOWN;
}

View File

@ -92,6 +92,7 @@ struct ModuleImmutableDataFixture : public DeviceFixture {
using KernelImp::printfBuffer;
using KernelImp::privateMemoryGraphicsAllocation;
using KernelImp::requiredWorkgroupOrder;
using KernelImp::residencyContainer;
using KernelImp::surfaceStateHeapData;
using KernelImp::surfaceStateHeapDataSize;
using KernelImp::unifiedMemoryControls;

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Intel Corporation
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -111,7 +111,7 @@ struct WhiteBox<::L0::CommandListCoreFamily<gfxCoreFamily>>
ze_result_t appendLaunchKernelWithParams(::L0::Kernel *kernel,
const ze_group_count_t &threadGroupDimensions,
::L0::Event *event,
const CmdListKernelLaunchParams &launchParams) override {
CmdListKernelLaunchParams &launchParams) override {
usedKernelLaunchParams = launchParams;
if (launchParams.isKernelSplitOperation && (launchParams.numKernelsExecutedInSplitLaunch == 0)) {
@ -301,7 +301,7 @@ struct MockCommandList : public CommandList {
const ze_group_count_t &threadGroupDimensions,
ze_event_handle_t hEvent, uint32_t numWaitEvents,
ze_event_handle_t *phWaitEvents,
const CmdListKernelLaunchParams &launchParams, bool relaxedOrderingDispatch));
CmdListKernelLaunchParams &launchParams, bool relaxedOrderingDispatch));
ADDMETHOD_NOBASE(appendLaunchCooperativeKernel, ze_result_t, ZE_RESULT_SUCCESS,
(ze_kernel_handle_t kernelHandle,
@ -699,7 +699,7 @@ class MockCommandListForAppendLaunchKernel : public WhiteBox<::L0::CommandListCo
ze_event_handle_t hEvent,
uint32_t numWaitEvents,
ze_event_handle_t *phWaitEvents,
const CmdListKernelLaunchParams &launchParams, bool relaxedOrderingDispatch) override {
CmdListKernelLaunchParams &launchParams, bool relaxedOrderingDispatch) override {
const auto kernel = Kernel::fromHandle(kernelHandle);
cmdListHelper.isaAllocation = kernel->getIsaAllocation();

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 Intel Corporation
* Copyright (C) 2023-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -1273,7 +1273,7 @@ class MockCommandListHwKernelSplit : public WhiteBox<::L0::CommandListCoreFamily
ze_result_t appendLaunchKernelSplit(::L0::Kernel *kernel,
const ze_group_count_t &threadGroupDimensions,
::L0::Event *event,
const CmdListKernelLaunchParams &launchParams) override {
CmdListKernelLaunchParams &launchParams) override {
passedKernel = kernel;
return status;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Intel Corporation
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -17,6 +17,7 @@
#include "shared/test/common/helpers/unit_test_helper.h"
#include "shared/test/common/libult/ult_command_stream_receiver.h"
#include "shared/test/common/mocks/mock_device.h"
#include "shared/test/common/mocks/mock_graphics_allocation.h"
#include "shared/test/common/test_macros/hw_test.h"
#include "level_zero/core/source/cmdlist/cmdlist_hw_immediate.h"
@ -1455,5 +1456,32 @@ HWTEST2_F(CommandListAppendLaunchKernel, whenUpdateStreamPropertiesIsCalledThenC
}
}
HWTEST2_F(CommandListAppendLaunchKernelMockModule,
givenFlagOmitKernelResourcePassToCmdlistResidencyWhenAppendingKernelThenExpectNoKernelArgumentsInCmdlistResidency,
IsAtLeastXeHpCore) {
NEO::MockGraphicsAllocation mockAllocation;
NEO::GraphicsAllocation *allocation = &mockAllocation;
kernel->residencyContainer.push_back(allocation);
ze_group_count_t groupCount{1, 1, 1};
ze_result_t returnValue;
CmdListKernelLaunchParams launchParams = {};
launchParams.omitAddingKernelResidency = true;
returnValue = commandList->appendLaunchKernel(kernel->toHandle(), groupCount, nullptr, 0, nullptr, launchParams, false);
ASSERT_EQ(ZE_RESULT_SUCCESS, returnValue);
auto &cmdlistResidency = commandList->getCmdContainer().getResidencyContainer();
auto kernelAllocationIt = std::find(cmdlistResidency.begin(), cmdlistResidency.end(), allocation);
EXPECT_EQ(kernelAllocationIt, cmdlistResidency.end());
launchParams.omitAddingKernelResidency = false;
returnValue = commandList->appendLaunchKernel(kernel->toHandle(), groupCount, nullptr, 0, nullptr, launchParams, false);
ASSERT_EQ(ZE_RESULT_SUCCESS, returnValue);
kernelAllocationIt = std::find(cmdlistResidency.begin(), cmdlistResidency.end(), allocation);
EXPECT_NE(kernelAllocationIt, cmdlistResidency.end());
}
} // namespace ult
} // namespace L0