feature: Add gfxCoreHelper for StateSip required

Related-to: NEO-12967

Signed-off-by: Brandon Yates <brandon.yates@intel.com>
This commit is contained in:
Brandon Yates
2025-03-04 13:59:54 +00:00
committed by Compute-Runtime-Automation
parent 566e52f72b
commit 64b027f71c
4 changed files with 36 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2024 Intel Corporation
* Copyright (C) 2018-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -41,6 +41,10 @@ void PreemptionHelper::programCsrBaseAddressCmd(LinearStream &preambleCmdStream,
template <typename GfxFamily>
void PreemptionHelper::programStateSip(LinearStream &preambleCmdStream, Device &device, OsContext *context) {
auto &helper = device.getGfxCoreHelper();
if (!helper.isStateSipRequired()) {
return;
}
bool debuggingEnabled = device.getDebugger() != nullptr;
bool isMidThreadPreemption = device.getPreemptionMode() == PreemptionMode::MidThread;
@@ -108,6 +112,10 @@ size_t PreemptionHelper::getRequiredPreambleSize(const Device &device) {
template <typename GfxFamily>
size_t PreemptionHelper::getRequiredStateSipCmdSize(Device &device, bool isRcs) {
auto &helper = device.getGfxCoreHelper();
if (!helper.isStateSipRequired()) {
return 0;
}
size_t size = 0;
bool isMidThreadPreemption = device.getPreemptionMode() == PreemptionMode::MidThread;
bool debuggingEnabled = device.getDebugger() != nullptr;

View File

@@ -180,6 +180,8 @@ class GfxCoreHelper {
virtual void initializeFromProductHelper(const ProductHelper &productHelper) = 0;
virtual bool is48ResourceNeededForCmdBuffer() const = 0;
virtual bool isStateSipRequired() const = 0;
virtual uint32_t getKernelPrivateMemSize(const KernelDescriptor &kernelDescriptor) const = 0;
virtual bool singleTileExecImplicitScalingRequired(bool cooperativeKernel) const = 0;
@@ -419,6 +421,7 @@ class GfxCoreHelperHw : public GfxCoreHelper {
void initializeFromProductHelper(const ProductHelper &productHelper) override;
bool is48ResourceNeededForCmdBuffer() const override;
bool isStateSipRequired() const override;
uint32_t getKernelPrivateMemSize(const KernelDescriptor &kernelDescriptor) const override;

View File

@@ -737,6 +737,11 @@ bool GfxCoreHelperHw<GfxFamily>::is48ResourceNeededForCmdBuffer() const {
return true;
}
template <typename GfxFamily>
bool GfxCoreHelperHw<GfxFamily>::isStateSipRequired() const {
return true;
}
template <typename GfxFamily>
bool GfxCoreHelperHw<GfxFamily>::singleTileExecImplicitScalingRequired(bool cooperativeKernel) const {
return EncodeDispatchKernel<GfxFamily>::singleTileExecImplicitScalingRequired(cooperativeKernel);

View File

@@ -10,6 +10,7 @@
#include "shared/source/memory_manager/memory_allocation.h"
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
#include "shared/test/common/cmd_parse/hw_parse.h"
#include "shared/test/common/helpers/raii_gfx_core_helper.h"
#include "shared/test/common/mocks/mock_csr.h"
#include "shared/test/common/mocks/mock_debugger.h"
#include "shared/test/common/mocks/mock_device.h"
@@ -142,3 +143,21 @@ HWTEST2_F(Xe2MidThreadPreemptionTests, whenProgramStateSipIsCalledThenStateSipCm
PreemptionHelper::programStateSip<FamilyType>(cmdStream, *device, nullptr);
EXPECT_NE(0U, cmdStream.getUsed());
}
HWTEST2_F(Xe2MidThreadPreemptionTests, GivenStateSipNotRequiredWhenProgramStateSipIsCalledThenStateSipIsNotAddedAndSizeIsZero, IsAtLeastXe2HpgCore) {
struct MockGfxCoreHelper : NEO::GfxCoreHelperHw<FamilyType> {
bool isStateSipRequired() const override {
return false;
}
};
RAIIGfxCoreHelperFactory<MockGfxCoreHelper> raii(*this->device->getExecutionEnvironment()->rootDeviceEnvironments[0]);
size_t requiredSize = PreemptionHelper::getRequiredStateSipCmdSize<FamilyType>(*device, false);
EXPECT_EQ(0U, requiredSize);
constexpr auto bufferSize = 128u;
uint64_t buffer[bufferSize];
LinearStream cmdStream{buffer, bufferSize * sizeof(uint64_t)};
PreemptionHelper::programStateSip<FamilyType>(cmdStream, *device, nullptr);
EXPECT_EQ(0U, cmdStream.getUsed());
}