Add method to merge LSH pipelined state during cmd list execution

Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
Dunajski, Bartosz
2022-07-26 17:34:13 +00:00
committed by Compute-Runtime-Automation
parent 599553d86c
commit 53a3cd2cdd
9 changed files with 107 additions and 7 deletions

View File

@ -162,8 +162,6 @@ struct CommandListCoreFamily : CommandListImp {
ze_result_t executeCommandListImmediate(bool performMigration) override;
size_t getReserveSshSize();
virtual NEO::LogicalStateHelper *getLogicalStateHelper() const { return nonImmediateLogicalStateHelper.get(); }
protected:
MOCKABLE_VIRTUAL ze_result_t appendMemoryCopyKernelWithGA(void *dstPtr, NEO::GraphicsAllocation *dstPtrAlloc,
uint64_t dstOffset, void *srcPtr,
@ -258,7 +256,6 @@ struct CommandListCoreFamily : CommandListImp {
virtual void createLogicalStateHelper();
std::unique_ptr<NEO::LogicalStateHelper> nonImmediateLogicalStateHelper;
size_t cmdListCurrentStartOffset = 0;
bool containsAnyKernel = false;
};

View File

@ -11,6 +11,7 @@
#include "shared/source/command_stream/linear_stream.h"
#include "shared/source/device/device.h"
#include "shared/source/helpers/engine_node_helper.h"
#include "shared/source/helpers/logical_state_helper.h"
#include "shared/source/indirect_heap/indirect_heap.h"
#include "level_zero/core/source/cmdqueue/cmdqueue.h"

View File

@ -6,9 +6,14 @@
*/
#pragma once
#include "level_zero/core/source/cmdlist/cmdlist.h"
#include <memory>
namespace NEO {
class LogicalStateHelper;
}
namespace L0 {
struct CommandListImp : CommandList {
@ -25,7 +30,11 @@ struct CommandListImp : CommandList {
virtual void appendMultiPartitionPrologue(uint32_t partitionDataSize) = 0;
virtual void appendMultiPartitionEpilogue() = 0;
virtual NEO::LogicalStateHelper *getLogicalStateHelper() const { return nonImmediateLogicalStateHelper.get(); }
protected:
std::unique_ptr<NEO::LogicalStateHelper> nonImmediateLogicalStateHelper;
~CommandListImp() override = default;
};

View File

@ -434,6 +434,11 @@ ze_result_t CommandQueueHw<gfxCoreFamily>::executeCommandLists(
printfFunctionContainer.insert(printfFunctionContainer.end(),
commandList->getPrintfFunctionContainer().begin(),
commandList->getPrintfFunctionContainer().end());
auto commandListImp = static_cast<CommandListImp *>(commandList);
if (!immediateMode && commandListImp->getLogicalStateHelper()) {
csr->getLogicalStateHelper()->mergePipelinedState(*commandListImp->getLogicalStateHelper());
}
}
if (performMigration) {

View File

@ -140,6 +140,7 @@ struct WhiteBox<::L0::CommandList> : public ::L0::CommandListImp {
using BaseClass::commandListPreemptionMode;
using BaseClass::csr;
using BaseClass::initialize;
using BaseClass::nonImmediateLogicalStateHelper;
using BaseClass::partitionCount;
WhiteBox(Device *device);

View File

@ -11,6 +11,7 @@
#include "shared/test/common/libult/ult_command_stream_receiver.h"
#include "shared/test/common/mocks/mock_bindless_heaps_helper.h"
#include "shared/test/common/mocks/mock_command_stream_receiver.h"
#include "shared/test/common/mocks/mock_logical_state_helper.h"
#include "shared/test/common/mocks/ult_device_factory.h"
#include "shared/test/common/test_macros/hw_test.h"
@ -281,6 +282,79 @@ HWTEST_F(CommandQueueCreate, given100CmdListsWhenExecutingThenCommandStreamIsNot
commandQueue->destroy();
}
HWTEST_F(CommandQueueCreate, givenLogicalStateHelperWhenExecutingThenMergeStates) {
const ze_command_queue_desc_t desc = {};
ze_result_t returnValue;
auto mockCsrLogicalStateHelper = new NEO::LogicalStateHelperMock<FamilyType>();
auto mockCmdListLogicalStateHelper = new NEO::LogicalStateHelperMock<FamilyType>();
auto commandQueue = whiteboxCast(CommandQueue::create(productFamily,
device,
neoDevice->getDefaultEngine().commandStreamReceiver,
&desc,
false,
false,
returnValue));
auto ultCsr = static_cast<UltCommandStreamReceiver<FamilyType> *>(commandQueue->getCsr());
ultCsr->logicalStateHelper.reset(mockCsrLogicalStateHelper);
Mock<Kernel> kernel;
kernel.immutableData.device = device;
auto commandList = std::unique_ptr<L0::ult::CommandList>(whiteboxCast(CommandList::create(productFamily, device, NEO::EngineGroupType::RenderCompute, 0u, returnValue)));
commandList->nonImmediateLogicalStateHelper.reset(mockCmdListLogicalStateHelper);
ze_group_count_t dispatchFunctionArguments{1, 1, 1};
CmdListKernelLaunchParams launchParams = {};
commandList->appendLaunchKernel(kernel.toHandle(), &dispatchFunctionArguments, nullptr, 0, nullptr, launchParams);
ze_command_list_handle_t cmdListHandles = commandList->toHandle();
commandQueue->executeCommandLists(1, &cmdListHandles, nullptr, false);
EXPECT_EQ(1u, mockCsrLogicalStateHelper->mergePipelinedStateCounter);
EXPECT_EQ(mockCmdListLogicalStateHelper, mockCsrLogicalStateHelper->latestInputLogicalStateHelperForMerge);
EXPECT_EQ(0u, mockCmdListLogicalStateHelper->mergePipelinedStateCounter);
commandQueue->destroy();
}
HWTEST_F(CommandQueueCreate, givenLogicalStateHelperAndImmediateCmdListWhenExecutingThenMergeStates) {
const ze_command_queue_desc_t desc = {};
ze_result_t returnValue;
auto mockCsrLogicalStateHelper = new NEO::LogicalStateHelperMock<FamilyType>();
auto commandQueue = whiteboxCast(CommandQueue::create(productFamily,
device,
neoDevice->getDefaultEngine().commandStreamReceiver,
&desc,
false,
false,
returnValue));
auto ultCsr = static_cast<UltCommandStreamReceiver<FamilyType> *>(commandQueue->getCsr());
ultCsr->logicalStateHelper.reset(mockCsrLogicalStateHelper);
Mock<Kernel> kernel;
kernel.immutableData.device = device;
auto commandList = std::unique_ptr<L0::ult::CommandList>(whiteboxCast(CommandList::createImmediate(productFamily, device, &desc, false, NEO::EngineGroupType::RenderCompute, returnValue)));
ze_group_count_t dispatchFunctionArguments{1, 1, 1};
CmdListKernelLaunchParams launchParams = {};
commandList->appendLaunchKernel(kernel.toHandle(), &dispatchFunctionArguments, nullptr, 0, nullptr, launchParams);
ze_command_list_handle_t cmdListHandles = commandList->toHandle();
commandQueue->executeCommandLists(1, &cmdListHandles, nullptr, false);
EXPECT_EQ(0u, mockCsrLogicalStateHelper->mergePipelinedStateCounter);
EXPECT_EQ(nullptr, mockCsrLogicalStateHelper->latestInputLogicalStateHelperForMerge);
commandQueue->destroy();
}
HWTEST2_F(CommandQueueCreate, givenGpuHangInReservingLinearStreamWhenExecutingCommandListsThenDeviceLostIsReturned, IsSKL) {
const ze_command_queue_desc_t desc = {};
MockCommandQueueHw<gfxCoreFamily> commandQueue(device, neoDevice->getDefaultEngine().commandStreamReceiver, &desc);