fix: setup proper preemption surface size when forcing builtin SIP

when getting SIP kernel from IGC, setup related surface size based on IGC data

Related-To: NEO-8188
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2024-07-15 13:00:16 +00:00
committed by Compute-Runtime-Automation
parent bd8fc07bb7
commit 789a008470
8 changed files with 65 additions and 8 deletions

View File

@@ -16,6 +16,7 @@
#include "shared/source/helpers/aligned_memory.h"
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/helpers/file_io.h"
#include "shared/source/helpers/hw_info.h"
#include "shared/source/memory_manager/allocation_properties.h"
#include "shared/source/memory_manager/memory_manager.h"
#include "shared/source/os_interface/os_context.h"
@@ -71,6 +72,10 @@ const SipKernel &BuiltIns::getSipKernel(SipKernelType type, Device &device) {
if (rootDeviceEnvironment.executionEnvironment.getDebuggingMode() == DebuggingMode::offline) {
sipBuiltIn.first->parseBinaryForContextId();
}
if (debugManager.flags.ForceSipClass.get() == static_cast<uint32_t>(SipClassType::builtins) && type == SipKernelType::csr) {
rootDeviceEnvironment.getMutableHardwareInfo()->capabilityTable.requiredPreemptionSurfaceSize = sipBuiltIn.first->getStateSaveAreaSize(&device);
}
};
std::call_once(sipBuiltIn.second, initializer);
UNRECOVERABLE_IF(sipBuiltIn.first == nullptr);

View File

@@ -163,8 +163,7 @@ int ProductHelper::configureHwInfoDrm(const HardwareInfo *inHwInfo, HardwareInfo
static_cast<bool>(outHwInfo->featureTable.flags.ftrGpGpuThreadGroupLevelPreempt) && preemption,
static_cast<bool>(outHwInfo->featureTable.flags.ftrGpGpuMidBatchPreempt) && preemption);
outHwInfo->capabilityTable.requiredPreemptionSurfaceSize = outHwInfo->gtSystemInfo.CsrSizeInMb * MemoryConstants::megaByte;
gfxCoreHelper.adjustPreemptionSurfaceSize(outHwInfo->capabilityTable.requiredPreemptionSurfaceSize, rootDeviceEnvironment);
setupPreemptionSurfaceSize(*outHwInfo, rootDeviceEnvironment);
auto &kmdNotifyProperties = outHwInfo->capabilityTable.kmdNotifyProperties;
KmdNotifyHelper::overrideFromDebugVariable(debugManager.flags.OverrideEnableKmdNotify.get(), kmdNotifyProperties.enableKmdNotify);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2023 Intel Corporation
* Copyright (C) 2021-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -7,8 +7,29 @@
#include "shared/source/os_interface/product_helper.h"
#include "shared/source/built_ins/sip_kernel_type.h"
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/helpers/constants.h"
#include "shared/source/helpers/gfx_core_helper.h"
#include "shared/source/helpers/hw_info.h"
namespace NEO {
ProductHelperCreateFunctionType productHelperFactory[IGFX_MAX_PRODUCT] = {};
void ProductHelper::setupPreemptionSurfaceSize(HardwareInfo &hwInfo, const RootDeviceEnvironment &rootDeviceEnvironment) {
if (debugManager.flags.OverridePreemptionSurfaceSizeInMb.get() >= 0) {
hwInfo.gtSystemInfo.CsrSizeInMb = static_cast<uint32_t>(debugManager.flags.OverridePreemptionSurfaceSizeInMb.get());
}
if (debugManager.flags.ForceSipClass.get() == static_cast<uint32_t>(SipClassType::builtins)) {
return;
}
auto &gfxCoreHelper = rootDeviceEnvironment.getHelper<GfxCoreHelper>();
hwInfo.capabilityTable.requiredPreemptionSurfaceSize = hwInfo.gtSystemInfo.CsrSizeInMb * MemoryConstants::megaByte;
gfxCoreHelper.adjustPreemptionSurfaceSize(hwInfo.capabilityTable.requiredPreemptionSurfaceSize, rootDeviceEnvironment);
}
} // namespace NEO

View File

@@ -247,5 +247,6 @@ class ProductHelper {
virtual LocalMemoryAccessMode getDefaultLocalMemoryAccessMode(const HardwareInfo &hwInfo) const = 0;
virtual void fillScmPropertiesSupportStructureBase(StateComputeModePropertiesSupport &propertiesSupport) const = 0;
static void setupPreemptionSurfaceSize(HardwareInfo &hwInfo, const RootDeviceEnvironment &rootDeviceEnvironment);
};
} // namespace NEO

View File

@@ -34,11 +34,7 @@ int ProductHelper::configureHwInfoWddm(const HardwareInfo *inHwInfo, HardwareInf
static_cast<bool>(outHwInfo->featureTable.flags.ftrGpGpuThreadGroupLevelPreempt),
static_cast<bool>(outHwInfo->featureTable.flags.ftrGpGpuMidBatchPreempt));
if (debugManager.flags.OverridePreemptionSurfaceSizeInMb.get() >= 0) {
outHwInfo->gtSystemInfo.CsrSizeInMb = static_cast<uint32_t>(debugManager.flags.OverridePreemptionSurfaceSizeInMb.get());
}
outHwInfo->capabilityTable.requiredPreemptionSurfaceSize = outHwInfo->gtSystemInfo.CsrSizeInMb * MemoryConstants::megaByte;
gfxCoreHelper.adjustPreemptionSurfaceSize(outHwInfo->capabilityTable.requiredPreemptionSurfaceSize, rootDeviceEnvironment);
setupPreemptionSurfaceSize(*outHwInfo, rootDeviceEnvironment);
auto &kmdNotifyProperties = outHwInfo->capabilityTable.kmdNotifyProperties;
KmdNotifyHelper::overrideFromDebugVariable(debugManager.flags.OverrideEnableKmdNotify.get(), kmdNotifyProperties.enableKmdNotify);

View File

@@ -13,6 +13,7 @@
namespace NEO {
struct MockProductHelper : ProductHelperHw<IGFX_UNKNOWN> {
using ProductHelper::setupPreemptionSurfaceSize;
MockProductHelper() = default;
ADDMETHOD_CONST_NOBASE(is48bResourceNeededForRayTracing, bool, true, ());

View File

@@ -782,4 +782,25 @@ TEST_F(DebugBuiltinSipTest, givenDumpSipHeaderFileWhenGettingSipKernelThenSipHea
EXPECT_EQ(1u, NEO::virtualFileList.size());
EXPECT_TRUE(NEO::virtualFileList.find("sip_header.bin") != NEO::virtualFileList.end());
}
TEST(SipTest, whenForcingBuiltinSipClassThenPreemptionSurfaceSizeIsSetBasedOnStateSaveAreaHeader) {
DebugManagerStateRestore restorer;
debugManager.flags.ForceSipClass.set(static_cast<int32_t>(SipClassType::builtins));
auto executionEnvironment = MockDevice::prepareExecutionEnvironment(defaultHwInfo.get(), 0u);
auto &rootDeviceEnvironment = *executionEnvironment->rootDeviceEnvironments[0];
constexpr uint32_t initialPreemptionSurfaceSize = 0xdeadbeef;
rootDeviceEnvironment.getMutableHardwareInfo()->capabilityTable.requiredPreemptionSurfaceSize = initialPreemptionSurfaceSize;
auto builtIns = new NEO::MockBuiltins();
builtIns->callBaseGetSipKernel = true;
MockRootDeviceEnvironment::resetBuiltins(&rootDeviceEnvironment, builtIns);
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, 0u));
EXPECT_NE(nullptr, mockDevice);
auto &sipKernel = rootDeviceEnvironment.builtins->getSipKernel(NEO::SipKernelType::csr, *mockDevice);
auto preemptionSurfaceSize = rootDeviceEnvironment.getHardwareInfo()->capabilityTable.requiredPreemptionSurfaceSize;
EXPECT_NE(initialPreemptionSurfaceSize, preemptionSurfaceSize);
EXPECT_EQ(sipKernel.getStateSaveAreaSize(mockDevice.get()), preemptionSurfaceSize);
}

View File

@@ -25,6 +25,7 @@
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "shared/test/common/mocks/mock_gmm.h"
#include "shared/test/common/mocks/mock_graphics_allocation.h"
#include "shared/test/common/mocks/mock_product_helper.h"
#include "shared/test/common/test_macros/hw_test.h"
#include "gtest/gtest.h"
@@ -957,4 +958,16 @@ HWTEST2_F(ProductHelperTest, givenPatIndexWhenCheckIsCoherentAllocationThenRetur
for (auto patIndex : listOfCoherentPatIndexes) {
EXPECT_EQ(std::nullopt, productHelper->isCoherentAllocation(patIndex));
}
}
TEST(ProductHelperPreemptionSettingTest, whenSipClassIsForcedToBuiltinThenRequiredPreemptionSizeIsNotAdjusted) {
MockExecutionEnvironment executionEnvironment{};
DebugManagerStateRestore restorer;
debugManager.flags.ForceSipClass.set(static_cast<int32_t>(SipClassType::builtins));
auto hwInfo = *defaultHwInfo;
hwInfo.gtSystemInfo.CsrSizeInMb = 1;
constexpr uint32_t initialPreemptionSurfaceSize = 0xdeadbeef;
hwInfo.capabilityTable.requiredPreemptionSurfaceSize = initialPreemptionSurfaceSize;
MockProductHelper::setupPreemptionSurfaceSize(hwInfo, *executionEnvironment.rootDeviceEnvironments[0]);
EXPECT_EQ(initialPreemptionSurfaceSize, hwInfo.capabilityTable.requiredPreemptionSurfaceSize);
}