mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 05:56:36 +08:00
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:
committed by
Compute-Runtime-Automation
parent
599553d86c
commit
53a3cd2cdd
@@ -162,8 +162,6 @@ struct CommandListCoreFamily : CommandListImp {
|
|||||||
ze_result_t executeCommandListImmediate(bool performMigration) override;
|
ze_result_t executeCommandListImmediate(bool performMigration) override;
|
||||||
size_t getReserveSshSize();
|
size_t getReserveSshSize();
|
||||||
|
|
||||||
virtual NEO::LogicalStateHelper *getLogicalStateHelper() const { return nonImmediateLogicalStateHelper.get(); }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MOCKABLE_VIRTUAL ze_result_t appendMemoryCopyKernelWithGA(void *dstPtr, NEO::GraphicsAllocation *dstPtrAlloc,
|
MOCKABLE_VIRTUAL ze_result_t appendMemoryCopyKernelWithGA(void *dstPtr, NEO::GraphicsAllocation *dstPtrAlloc,
|
||||||
uint64_t dstOffset, void *srcPtr,
|
uint64_t dstOffset, void *srcPtr,
|
||||||
@@ -258,7 +256,6 @@ struct CommandListCoreFamily : CommandListImp {
|
|||||||
|
|
||||||
virtual void createLogicalStateHelper();
|
virtual void createLogicalStateHelper();
|
||||||
|
|
||||||
std::unique_ptr<NEO::LogicalStateHelper> nonImmediateLogicalStateHelper;
|
|
||||||
size_t cmdListCurrentStartOffset = 0;
|
size_t cmdListCurrentStartOffset = 0;
|
||||||
bool containsAnyKernel = false;
|
bool containsAnyKernel = false;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "shared/source/command_stream/linear_stream.h"
|
#include "shared/source/command_stream/linear_stream.h"
|
||||||
#include "shared/source/device/device.h"
|
#include "shared/source/device/device.h"
|
||||||
#include "shared/source/helpers/engine_node_helper.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 "shared/source/indirect_heap/indirect_heap.h"
|
||||||
|
|
||||||
#include "level_zero/core/source/cmdqueue/cmdqueue.h"
|
#include "level_zero/core/source/cmdqueue/cmdqueue.h"
|
||||||
|
|||||||
@@ -6,9 +6,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "level_zero/core/source/cmdlist/cmdlist.h"
|
#include "level_zero/core/source/cmdlist/cmdlist.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace NEO {
|
||||||
|
class LogicalStateHelper;
|
||||||
|
}
|
||||||
|
|
||||||
namespace L0 {
|
namespace L0 {
|
||||||
|
|
||||||
struct CommandListImp : CommandList {
|
struct CommandListImp : CommandList {
|
||||||
@@ -25,7 +30,11 @@ struct CommandListImp : CommandList {
|
|||||||
virtual void appendMultiPartitionPrologue(uint32_t partitionDataSize) = 0;
|
virtual void appendMultiPartitionPrologue(uint32_t partitionDataSize) = 0;
|
||||||
virtual void appendMultiPartitionEpilogue() = 0;
|
virtual void appendMultiPartitionEpilogue() = 0;
|
||||||
|
|
||||||
|
virtual NEO::LogicalStateHelper *getLogicalStateHelper() const { return nonImmediateLogicalStateHelper.get(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
std::unique_ptr<NEO::LogicalStateHelper> nonImmediateLogicalStateHelper;
|
||||||
|
|
||||||
~CommandListImp() override = default;
|
~CommandListImp() override = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -434,6 +434,11 @@ ze_result_t CommandQueueHw<gfxCoreFamily>::executeCommandLists(
|
|||||||
printfFunctionContainer.insert(printfFunctionContainer.end(),
|
printfFunctionContainer.insert(printfFunctionContainer.end(),
|
||||||
commandList->getPrintfFunctionContainer().begin(),
|
commandList->getPrintfFunctionContainer().begin(),
|
||||||
commandList->getPrintfFunctionContainer().end());
|
commandList->getPrintfFunctionContainer().end());
|
||||||
|
|
||||||
|
auto commandListImp = static_cast<CommandListImp *>(commandList);
|
||||||
|
if (!immediateMode && commandListImp->getLogicalStateHelper()) {
|
||||||
|
csr->getLogicalStateHelper()->mergePipelinedState(*commandListImp->getLogicalStateHelper());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (performMigration) {
|
if (performMigration) {
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ struct WhiteBox<::L0::CommandList> : public ::L0::CommandListImp {
|
|||||||
using BaseClass::commandListPreemptionMode;
|
using BaseClass::commandListPreemptionMode;
|
||||||
using BaseClass::csr;
|
using BaseClass::csr;
|
||||||
using BaseClass::initialize;
|
using BaseClass::initialize;
|
||||||
|
using BaseClass::nonImmediateLogicalStateHelper;
|
||||||
using BaseClass::partitionCount;
|
using BaseClass::partitionCount;
|
||||||
|
|
||||||
WhiteBox(Device *device);
|
WhiteBox(Device *device);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "shared/test/common/libult/ult_command_stream_receiver.h"
|
#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_bindless_heaps_helper.h"
|
||||||
#include "shared/test/common/mocks/mock_command_stream_receiver.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/mocks/ult_device_factory.h"
|
||||||
#include "shared/test/common/test_macros/hw_test.h"
|
#include "shared/test/common/test_macros/hw_test.h"
|
||||||
|
|
||||||
@@ -281,6 +282,79 @@ HWTEST_F(CommandQueueCreate, given100CmdListsWhenExecutingThenCommandStreamIsNot
|
|||||||
commandQueue->destroy();
|
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) {
|
HWTEST2_F(CommandQueueCreate, givenGpuHangInReservingLinearStreamWhenExecutingCommandListsThenDeviceLostIsReturned, IsSKL) {
|
||||||
const ze_command_queue_desc_t desc = {};
|
const ze_command_queue_desc_t desc = {};
|
||||||
MockCommandQueueHw<gfxCoreFamily> commandQueue(device, neoDevice->getDefaultEngine().commandStreamReceiver, &desc);
|
MockCommandQueueHw<gfxCoreFamily> commandQueue(device, neoDevice->getDefaultEngine().commandStreamReceiver, &desc);
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ HWTEST_F(EnqueueHandlerTest, givenLogicalStateHelperWhenDispatchingCommandsThenA
|
|||||||
|
|
||||||
auto mockCmdQ = std::make_unique<MockCommandQueueHw<FamilyType>>(context, pClDevice, nullptr);
|
auto mockCmdQ = std::make_unique<MockCommandQueueHw<FamilyType>>(context, pClDevice, nullptr);
|
||||||
auto logicalStateHelper = new LogicalStateHelperMock<FamilyType>();
|
auto logicalStateHelper = new LogicalStateHelperMock<FamilyType>();
|
||||||
|
logicalStateHelper->makeFakeStreamWrite = true;
|
||||||
|
|
||||||
auto &ultCsr = static_cast<UltCommandStreamReceiver<FamilyType> &>(mockCmdQ->getGpgpuCommandStreamReceiver());
|
auto &ultCsr = static_cast<UltCommandStreamReceiver<FamilyType> &>(mockCmdQ->getGpgpuCommandStreamReceiver());
|
||||||
ultCsr.logicalStateHelper.reset(logicalStateHelper);
|
ultCsr.logicalStateHelper.reset(logicalStateHelper);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class LogicalStateHelper {
|
|||||||
virtual ~LogicalStateHelper() = default;
|
virtual ~LogicalStateHelper() = default;
|
||||||
|
|
||||||
virtual void writeStreamInline(LinearStream &linearStream, bool pipelinedState) = 0;
|
virtual void writeStreamInline(LinearStream &linearStream, bool pipelinedState) = 0;
|
||||||
|
virtual void mergePipelinedState(const LogicalStateHelper &inputLogicalStateHelper) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
LogicalStateHelper() = default;
|
LogicalStateHelper() = default;
|
||||||
|
|||||||
@@ -21,11 +21,22 @@ class LogicalStateHelperMock : public GfxFamily::LogicalStateHelperHw {
|
|||||||
void writeStreamInline(LinearStream &linearStream, bool pipelinedState) override {
|
void writeStreamInline(LinearStream &linearStream, bool pipelinedState) override {
|
||||||
writeStreamInlineCalledCounter++;
|
writeStreamInlineCalledCounter++;
|
||||||
|
|
||||||
auto cmd = linearStream.getSpaceForCmd<typename GfxFamily::MI_NOOP>();
|
if (makeFakeStreamWrite) {
|
||||||
*cmd = GfxFamily::cmdInitNoop;
|
auto cmd = linearStream.getSpaceForCmd<typename GfxFamily::MI_NOOP>();
|
||||||
cmd->setIdentificationNumber(0x123);
|
*cmd = GfxFamily::cmdInitNoop;
|
||||||
|
cmd->setIdentificationNumber(0x123);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mergePipelinedState(const LogicalStateHelper &inputLogicalStateHelper) override {
|
||||||
|
mergePipelinedStateCounter++;
|
||||||
|
|
||||||
|
latestInputLogicalStateHelperForMerge = &inputLogicalStateHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
const LogicalStateHelper *latestInputLogicalStateHelperForMerge = nullptr;
|
||||||
uint32_t writeStreamInlineCalledCounter = 0;
|
uint32_t writeStreamInlineCalledCounter = 0;
|
||||||
|
uint32_t mergePipelinedStateCounter = 0;
|
||||||
|
bool makeFakeStreamWrite = false;
|
||||||
};
|
};
|
||||||
} // namespace NEO
|
} // namespace NEO
|
||||||
|
|||||||
Reference in New Issue
Block a user