mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-10 12:53:42 +08:00
Add platform specific getter of debug surface size
For different platforms based on number of available threads and debug surface layout, calculate max debug surface size. Related-To: NEO-6676 Signed-off-by: Jitendra Sharma <jitendra.sharma@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
fec738208a
commit
f52f3df274
@ -836,7 +836,7 @@ Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, bool
|
||||
auto osInterface = neoDevice->getRootDeviceEnvironment().osInterface.get();
|
||||
device->driverInfo.reset(NEO::DriverInfo::create(&hwInfo, osInterface));
|
||||
|
||||
auto debugSurfaceSize = NEO::SipKernel::maxDbgSurfaceSize;
|
||||
auto debugSurfaceSize = hwHelper.getSipKernelMaxDbgSurfaceSize(hwInfo);
|
||||
std::vector<char> stateSaveAreaHeader;
|
||||
|
||||
if (neoDevice->getCompilerInterface()) {
|
||||
@ -845,7 +845,7 @@ Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, bool
|
||||
UNRECOVERABLE_IF(!ret);
|
||||
|
||||
stateSaveAreaHeader = NEO::SipKernel::getSipKernel(*neoDevice).getStateSaveAreaHeader();
|
||||
debugSurfaceSize = NEO::SipKernel::getSipKernel(*neoDevice).getStateSaveAreaSize();
|
||||
debugSurfaceSize = NEO::SipKernel::getSipKernel(*neoDevice).getStateSaveAreaSize(neoDevice);
|
||||
}
|
||||
} else {
|
||||
*returnValue = ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE;
|
||||
|
@ -318,10 +318,12 @@ HWTEST_F(KernelDebugSurfaceTest, givenDebuggerAndBindfulKernelWhenAppendingKerne
|
||||
auto debugger = MockDebuggerL0Hw<FamilyType>::allocate(neoDevice);
|
||||
|
||||
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->debugger.reset(debugger);
|
||||
|
||||
auto &hwInfo = *NEO::defaultHwInfo.get();
|
||||
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
|
||||
auto maxDbgSurfaceSize = hwHelper.getSipKernelMaxDbgSurfaceSize(hwInfo);
|
||||
auto debugSurface = neoDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties(
|
||||
{device->getRootDeviceIndex(), true,
|
||||
NEO::SipKernel::maxDbgSurfaceSize,
|
||||
maxDbgSurfaceSize,
|
||||
NEO::AllocationType::DEBUG_CONTEXT_SAVE_AREA,
|
||||
false,
|
||||
false,
|
||||
|
@ -85,7 +85,8 @@ class CommandQueueHw : public CommandQueue {
|
||||
}
|
||||
|
||||
if (device->getDevice().getDebugger() && !getGpgpuCommandStreamReceiver().getDebugSurfaceAllocation()) {
|
||||
auto debugSurface = getGpgpuCommandStreamReceiver().allocateDebugSurface(SipKernel::maxDbgSurfaceSize);
|
||||
auto maxDbgSurfaceSize = hwHelper.getSipKernelMaxDbgSurfaceSize(hwInfo);
|
||||
auto debugSurface = getGpgpuCommandStreamReceiver().allocateDebugSurface(maxDbgSurfaceSize);
|
||||
memset(debugSurface->getUnderlyingBuffer(), 0, debugSurface->getUnderlyingBufferSize());
|
||||
|
||||
auto &stateSaveAreaHeader = SipKernel::getSipKernel(device->getDevice()).getStateSaveAreaHeader();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@ -35,10 +35,6 @@ TEST(Sip, WhenGettingTypeThenCorrectTypeIsReturned) {
|
||||
EXPECT_EQ(SipKernelType::COUNT, undefined.getType());
|
||||
}
|
||||
|
||||
TEST(Sip, givenSipKernelClassWhenAskedForMaxDebugSurfaceSizeThenCorrectValueIsReturned) {
|
||||
EXPECT_EQ(0x1800000u, SipKernel::maxDbgSurfaceSize);
|
||||
}
|
||||
|
||||
TEST(Sip, givenDebuggingInactiveWhenSipTypeIsQueriedThenCsrSipTypeIsReturned) {
|
||||
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
|
||||
EXPECT_NE(nullptr, mockDevice);
|
||||
|
@ -1378,7 +1378,9 @@ HWTEST_F(CommandQueueCommandStreamTest, givenDebugKernelWhenSetupDebugSurfaceIsC
|
||||
kernel->setSshLocal(nullptr, sizeof(RENDER_SURFACE_STATE) + systemThreadSurfaceAddress);
|
||||
auto &commandStreamReceiver = cmdQ.getGpgpuCommandStreamReceiver();
|
||||
|
||||
cmdQ.getGpgpuCommandStreamReceiver().allocateDebugSurface(SipKernel::maxDbgSurfaceSize);
|
||||
auto &hwInfo = *NEO::defaultHwInfo.get();
|
||||
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
|
||||
cmdQ.getGpgpuCommandStreamReceiver().allocateDebugSurface(hwHelper.getSipKernelMaxDbgSurfaceSize(hwInfo));
|
||||
cmdQ.setupDebugSurface(kernel.get());
|
||||
|
||||
auto debugSurface = commandStreamReceiver.getDebugSurfaceAllocation();
|
||||
@ -1397,7 +1399,9 @@ HWTEST_F(CommandQueueCommandStreamTest, givenCsrWithDebugSurfaceAllocatedWhenSet
|
||||
const auto &systemThreadSurfaceAddress = kernel->getAllocatedKernelInfo()->kernelDescriptor.payloadMappings.implicitArgs.systemThreadSurfaceAddress.bindful;
|
||||
kernel->setSshLocal(nullptr, sizeof(RENDER_SURFACE_STATE) + systemThreadSurfaceAddress);
|
||||
auto &commandStreamReceiver = cmdQ.getGpgpuCommandStreamReceiver();
|
||||
commandStreamReceiver.allocateDebugSurface(SipKernel::maxDbgSurfaceSize);
|
||||
auto hwInfo = *NEO::defaultHwInfo.get();
|
||||
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
|
||||
commandStreamReceiver.allocateDebugSurface(hwHelper.getSipKernelMaxDbgSurfaceSize(hwInfo));
|
||||
auto debugSurface = commandStreamReceiver.getDebugSurfaceAllocation();
|
||||
ASSERT_NE(nullptr, debugSurface);
|
||||
|
||||
|
@ -175,7 +175,9 @@ HWTEST_F(EnqueueDebugKernelSimpleTest, givenKernelFromProgramWithDebugEnabledWhe
|
||||
std::unique_ptr<MockDebugKernel> kernel(MockKernel::create<MockDebugKernel>(*pDevice, &program));
|
||||
kernel->initialize();
|
||||
std::unique_ptr<MockCommandQueueHwSetupDebugSurface<FamilyType>> mockCmdQ(new MockCommandQueueHwSetupDebugSurface<FamilyType>(context, pClDevice, 0));
|
||||
mockCmdQ->getGpgpuCommandStreamReceiver().allocateDebugSurface(SipKernel::maxDbgSurfaceSize);
|
||||
auto hwInfo = *NEO::defaultHwInfo.get();
|
||||
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
|
||||
mockCmdQ->getGpgpuCommandStreamReceiver().allocateDebugSurface(hwHelper.getSipKernelMaxDbgSurfaceSize(hwInfo));
|
||||
mockCmdQ->setupDebugSurfaceParamsPassed.clear();
|
||||
|
||||
EXPECT_TRUE(isValidOffset(kernel->getKernelInfo().kernelDescriptor.payloadMappings.implicitArgs.systemThreadSurfaceAddress.bindful));
|
||||
|
@ -25,8 +25,6 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
const size_t SipKernel::maxDbgSurfaceSize = 0x1800000; // proper value should be taken from compiler when it's ready
|
||||
|
||||
SipClassType SipKernel::classType = SipClassType::Init;
|
||||
|
||||
std::vector<char> readFile(const std::string &fileName, size_t &retSize) {
|
||||
@ -72,14 +70,17 @@ const std::vector<char> &SipKernel::getStateSaveAreaHeader() const {
|
||||
return stateSaveAreaHeader;
|
||||
}
|
||||
|
||||
size_t SipKernel::getStateSaveAreaSize() const {
|
||||
size_t SipKernel::getStateSaveAreaSize(Device *device) const {
|
||||
auto &hwInfo = device->getHardwareInfo();
|
||||
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
|
||||
auto maxDbgSurfaceSize = hwHelper.getSipKernelMaxDbgSurfaceSize(hwInfo);
|
||||
auto stateSaveAreaHeader = getStateSaveAreaHeader();
|
||||
if (stateSaveAreaHeader.empty()) {
|
||||
return SipKernel::maxDbgSurfaceSize;
|
||||
return maxDbgSurfaceSize;
|
||||
}
|
||||
|
||||
if (strcmp(stateSaveAreaHeader.data(), "tssarea")) {
|
||||
return SipKernel::maxDbgSurfaceSize;
|
||||
return maxDbgSurfaceSize;
|
||||
}
|
||||
|
||||
auto hdr = reinterpret_cast<const SIP::StateSaveAreaHeader *>(stateSaveAreaHeader.data());
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@ -34,7 +34,7 @@ class SipKernel {
|
||||
|
||||
MOCKABLE_VIRTUAL GraphicsAllocation *getSipAllocation() const;
|
||||
MOCKABLE_VIRTUAL const std::vector<char> &getStateSaveAreaHeader() const;
|
||||
MOCKABLE_VIRTUAL size_t getStateSaveAreaSize() const;
|
||||
MOCKABLE_VIRTUAL size_t getStateSaveAreaSize(Device *device) const;
|
||||
|
||||
static bool initSipKernel(SipKernelType type, Device &device);
|
||||
static void freeSipKernels(RootDeviceEnvironment *rootDeviceEnvironment, MemoryManager *memoryManager);
|
||||
@ -43,8 +43,6 @@ class SipKernel {
|
||||
static const SipKernel &getBindlessDebugSipKernel(Device &device);
|
||||
static SipKernelType getSipKernelType(Device &device);
|
||||
static SipKernelType getSipKernelType(Device &device, bool debuggingEnable);
|
||||
|
||||
static const size_t maxDbgSurfaceSize;
|
||||
static SipClassType classType;
|
||||
|
||||
enum class COMMAND : uint32_t {
|
||||
|
@ -114,6 +114,7 @@ class HwHelper {
|
||||
virtual uint32_t adjustMaxWorkGroupCount(uint32_t maxWorkGroupCount, const EngineGroupType engineGroupType,
|
||||
const HardwareInfo &hwInfo, bool isEngineInstanced) const = 0;
|
||||
virtual size_t getMaxFillPaternSizeForCopyEngine() const = 0;
|
||||
virtual size_t getSipKernelMaxDbgSurfaceSize(const HardwareInfo &hwInfo) const = 0;
|
||||
virtual bool isCopyOnlyEngineType(EngineGroupType type) const = 0;
|
||||
virtual bool isSipWANeeded(const HardwareInfo &hwInfo) const = 0;
|
||||
virtual bool isCpuImageTransferPreferred(const HardwareInfo &hwInfo) const = 0;
|
||||
@ -335,6 +336,8 @@ class HwHelperHw : public HwHelper {
|
||||
|
||||
size_t getMaxFillPaternSizeForCopyEngine() const override;
|
||||
|
||||
size_t getSipKernelMaxDbgSurfaceSize(const HardwareInfo &hwInfo) const override;
|
||||
|
||||
bool isKmdMigrationSupported(const HardwareInfo &hwInfo) const override;
|
||||
|
||||
bool isCooperativeEngineSupported(const HardwareInfo &hwInfo) const override;
|
||||
|
@ -689,6 +689,11 @@ template <typename GfxFamily>
|
||||
void HwHelperHw<GfxFamily>::setSipKernelData(uint32_t *&sipKernelBinary, size_t &kernelBinarySize) const {
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
size_t HwHelperHw<GfxFamily>::getSipKernelMaxDbgSurfaceSize(const HardwareInfo &hwInfo) const {
|
||||
return 0x1800000;
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
void HwHelperHw<GfxFamily>::adjustPreemptionSurfaceSize(size_t &csrSize) const {
|
||||
}
|
||||
|
@ -446,6 +446,11 @@ bool HwHelperHw<Family>::isRevisionSpecificBinaryBuiltinRequired() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
template <>
|
||||
size_t HwHelperHw<Family>::getSipKernelMaxDbgSurfaceSize(const HardwareInfo &hwInfo) const {
|
||||
return 0x2800000;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
#include "shared/source/helpers/hw_helper_pvc_and_later.inl"
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@ -338,22 +338,26 @@ using StateSaveAreaSipTest = Test<RawBinarySipFixture>;
|
||||
TEST_F(StateSaveAreaSipTest, givenEmptyStateSaveAreaHeaderWhenGetStateSaveAreaSizeCalledThenMaxDbgSurfaceSizeIsReturned) {
|
||||
MockSipData::useMockSip = true;
|
||||
MockSipData::mockSipKernel->mockStateSaveAreaHeader.clear();
|
||||
EXPECT_EQ(SipKernel::maxDbgSurfaceSize, SipKernel::getSipKernel(*pDevice).getStateSaveAreaSize());
|
||||
auto hwInfo = *NEO::defaultHwInfo.get();
|
||||
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
|
||||
EXPECT_EQ(hwHelper.getSipKernelMaxDbgSurfaceSize(hwInfo), SipKernel::getSipKernel(*pDevice).getStateSaveAreaSize(pDevice));
|
||||
}
|
||||
|
||||
TEST_F(StateSaveAreaSipTest, givenCorruptedStateSaveAreaHeaderWhenGetStateSaveAreaSizeCalledThenMaxDbgSurfaceSizeIsReturned) {
|
||||
MockSipData::useMockSip = true;
|
||||
MockSipData::mockSipKernel->mockStateSaveAreaHeader = {'g', 'a', 'r', 'b', 'a', 'g', 'e'};
|
||||
EXPECT_EQ(SipKernel::maxDbgSurfaceSize, SipKernel::getSipKernel(*pDevice).getStateSaveAreaSize());
|
||||
auto hwInfo = *NEO::defaultHwInfo.get();
|
||||
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
|
||||
EXPECT_EQ(hwHelper.getSipKernelMaxDbgSurfaceSize(hwInfo), SipKernel::getSipKernel(*pDevice).getStateSaveAreaSize(pDevice));
|
||||
}
|
||||
|
||||
TEST_F(StateSaveAreaSipTest, givenCorrectStateSaveAreaHeaderWhenGetStateSaveAreaSizeCalledThenCorrectDbgSurfaceSizeIsReturned) {
|
||||
MockSipData::useMockSip = true;
|
||||
MockSipData::mockSipKernel->mockStateSaveAreaHeader = MockSipData::createStateSaveAreaHeader(1);
|
||||
EXPECT_EQ(0x3F1000u, SipKernel::getSipKernel(*pDevice).getStateSaveAreaSize());
|
||||
EXPECT_EQ(0x3F1000u, SipKernel::getSipKernel(*pDevice).getStateSaveAreaSize(pDevice));
|
||||
|
||||
MockSipData::mockSipKernel->mockStateSaveAreaHeader = MockSipData::createStateSaveAreaHeader(2);
|
||||
EXPECT_EQ(0x1800u * 1 * 8 * 7 + alignUp(sizeof(SIP::StateSaveAreaHeader), MemoryConstants::pageSize), SipKernel::getSipKernel(*pDevice).getStateSaveAreaSize());
|
||||
EXPECT_EQ(0x1800u * 1 * 8 * 7 + alignUp(sizeof(SIP::StateSaveAreaHeader), MemoryConstants::pageSize), SipKernel::getSipKernel(*pDevice).getStateSaveAreaSize(pDevice));
|
||||
}
|
||||
TEST(DebugBindlessSip, givenActiveDebuggerAndUseBindlessDebugSipWhenGettingSipTypeThenDebugBindlessTypeIsReturned) {
|
||||
DebugManagerStateRestore restorer;
|
||||
|
Reference in New Issue
Block a user