Skip to content

Commit f52f3df

Browse files
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>
1 parent fec7382 commit f52f3df

File tree

12 files changed

+48
-27
lines changed

12 files changed

+48
-27
lines changed

level_zero/core/source/device/device_imp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, bool
836836
auto osInterface = neoDevice->getRootDeviceEnvironment().osInterface.get();
837837
device->driverInfo.reset(NEO::DriverInfo::create(&hwInfo, osInterface));
838838

839-
auto debugSurfaceSize = NEO::SipKernel::maxDbgSurfaceSize;
839+
auto debugSurfaceSize = hwHelper.getSipKernelMaxDbgSurfaceSize(hwInfo);
840840
std::vector<char> stateSaveAreaHeader;
841841

842842
if (neoDevice->getCompilerInterface()) {
@@ -845,7 +845,7 @@ Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, bool
845845
UNRECOVERABLE_IF(!ret);
846846

847847
stateSaveAreaHeader = NEO::SipKernel::getSipKernel(*neoDevice).getStateSaveAreaHeader();
848-
debugSurfaceSize = NEO::SipKernel::getSipKernel(*neoDevice).getStateSaveAreaSize();
848+
debugSurfaceSize = NEO::SipKernel::getSipKernel(*neoDevice).getStateSaveAreaSize(neoDevice);
849849
}
850850
} else {
851851
*returnValue = ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE;

level_zero/core/test/unit_tests/sources/debugger/test_module_with_debug.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,12 @@ HWTEST_F(KernelDebugSurfaceTest, givenDebuggerAndBindfulKernelWhenAppendingKerne
318318
auto debugger = MockDebuggerL0Hw<FamilyType>::allocate(neoDevice);
319319

320320
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->debugger.reset(debugger);
321-
321+
auto &hwInfo = *NEO::defaultHwInfo.get();
322+
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
323+
auto maxDbgSurfaceSize = hwHelper.getSipKernelMaxDbgSurfaceSize(hwInfo);
322324
auto debugSurface = neoDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties(
323325
{device->getRootDeviceIndex(), true,
324-
NEO::SipKernel::maxDbgSurfaceSize,
326+
maxDbgSurfaceSize,
325327
NEO::AllocationType::DEBUG_CONTEXT_SAVE_AREA,
326328
false,
327329
false,

opencl/source/command_queue/command_queue_hw.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ class CommandQueueHw : public CommandQueue {
8585
}
8686

8787
if (device->getDevice().getDebugger() && !getGpgpuCommandStreamReceiver().getDebugSurfaceAllocation()) {
88-
auto debugSurface = getGpgpuCommandStreamReceiver().allocateDebugSurface(SipKernel::maxDbgSurfaceSize);
88+
auto maxDbgSurfaceSize = hwHelper.getSipKernelMaxDbgSurfaceSize(hwInfo);
89+
auto debugSurface = getGpgpuCommandStreamReceiver().allocateDebugSurface(maxDbgSurfaceSize);
8990
memset(debugSurface->getUnderlyingBuffer(), 0, debugSurface->getUnderlyingBufferSize());
9091

9192
auto &stateSaveAreaHeader = SipKernel::getSipKernel(device->getDevice()).getStateSaveAreaHeader();

opencl/test/unit_test/built_ins/sip_tests.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2021 Intel Corporation
2+
* Copyright (C) 2018-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -35,10 +35,6 @@ TEST(Sip, WhenGettingTypeThenCorrectTypeIsReturned) {
3535
EXPECT_EQ(SipKernelType::COUNT, undefined.getType());
3636
}
3737

38-
TEST(Sip, givenSipKernelClassWhenAskedForMaxDebugSurfaceSizeThenCorrectValueIsReturned) {
39-
EXPECT_EQ(0x1800000u, SipKernel::maxDbgSurfaceSize);
40-
}
41-
4238
TEST(Sip, givenDebuggingInactiveWhenSipTypeIsQueriedThenCsrSipTypeIsReturned) {
4339
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
4440
EXPECT_NE(nullptr, mockDevice);

opencl/test/unit_test/command_queue/command_queue_tests.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,9 @@ HWTEST_F(CommandQueueCommandStreamTest, givenDebugKernelWhenSetupDebugSurfaceIsC
13781378
kernel->setSshLocal(nullptr, sizeof(RENDER_SURFACE_STATE) + systemThreadSurfaceAddress);
13791379
auto &commandStreamReceiver = cmdQ.getGpgpuCommandStreamReceiver();
13801380

1381-
cmdQ.getGpgpuCommandStreamReceiver().allocateDebugSurface(SipKernel::maxDbgSurfaceSize);
1381+
auto &hwInfo = *NEO::defaultHwInfo.get();
1382+
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
1383+
cmdQ.getGpgpuCommandStreamReceiver().allocateDebugSurface(hwHelper.getSipKernelMaxDbgSurfaceSize(hwInfo));
13821384
cmdQ.setupDebugSurface(kernel.get());
13831385

13841386
auto debugSurface = commandStreamReceiver.getDebugSurfaceAllocation();
@@ -1397,7 +1399,9 @@ HWTEST_F(CommandQueueCommandStreamTest, givenCsrWithDebugSurfaceAllocatedWhenSet
13971399
const auto &systemThreadSurfaceAddress = kernel->getAllocatedKernelInfo()->kernelDescriptor.payloadMappings.implicitArgs.systemThreadSurfaceAddress.bindful;
13981400
kernel->setSshLocal(nullptr, sizeof(RENDER_SURFACE_STATE) + systemThreadSurfaceAddress);
13991401
auto &commandStreamReceiver = cmdQ.getGpgpuCommandStreamReceiver();
1400-
commandStreamReceiver.allocateDebugSurface(SipKernel::maxDbgSurfaceSize);
1402+
auto hwInfo = *NEO::defaultHwInfo.get();
1403+
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
1404+
commandStreamReceiver.allocateDebugSurface(hwHelper.getSipKernelMaxDbgSurfaceSize(hwInfo));
14011405
auto debugSurface = commandStreamReceiver.getDebugSurfaceAllocation();
14021406
ASSERT_NE(nullptr, debugSurface);
14031407

opencl/test/unit_test/command_queue/enqueue_debug_kernel_tests.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@ HWTEST_F(EnqueueDebugKernelSimpleTest, givenKernelFromProgramWithDebugEnabledWhe
175175
std::unique_ptr<MockDebugKernel> kernel(MockKernel::create<MockDebugKernel>(*pDevice, &program));
176176
kernel->initialize();
177177
std::unique_ptr<MockCommandQueueHwSetupDebugSurface<FamilyType>> mockCmdQ(new MockCommandQueueHwSetupDebugSurface<FamilyType>(context, pClDevice, 0));
178-
mockCmdQ->getGpgpuCommandStreamReceiver().allocateDebugSurface(SipKernel::maxDbgSurfaceSize);
178+
auto hwInfo = *NEO::defaultHwInfo.get();
179+
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
180+
mockCmdQ->getGpgpuCommandStreamReceiver().allocateDebugSurface(hwHelper.getSipKernelMaxDbgSurfaceSize(hwInfo));
179181
mockCmdQ->setupDebugSurfaceParamsPassed.clear();
180182

181183
EXPECT_TRUE(isValidOffset(kernel->getKernelInfo().kernelDescriptor.payloadMappings.implicitArgs.systemThreadSurfaceAddress.bindful));

shared/source/built_ins/sip.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525

2626
namespace NEO {
2727

28-
const size_t SipKernel::maxDbgSurfaceSize = 0x1800000; // proper value should be taken from compiler when it's ready
29-
3028
SipClassType SipKernel::classType = SipClassType::Init;
3129

3230
std::vector<char> readFile(const std::string &fileName, size_t &retSize) {
@@ -72,14 +70,17 @@ const std::vector<char> &SipKernel::getStateSaveAreaHeader() const {
7270
return stateSaveAreaHeader;
7371
}
7472

75-
size_t SipKernel::getStateSaveAreaSize() const {
73+
size_t SipKernel::getStateSaveAreaSize(Device *device) const {
74+
auto &hwInfo = device->getHardwareInfo();
75+
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
76+
auto maxDbgSurfaceSize = hwHelper.getSipKernelMaxDbgSurfaceSize(hwInfo);
7677
auto stateSaveAreaHeader = getStateSaveAreaHeader();
7778
if (stateSaveAreaHeader.empty()) {
78-
return SipKernel::maxDbgSurfaceSize;
79+
return maxDbgSurfaceSize;
7980
}
8081

8182
if (strcmp(stateSaveAreaHeader.data(), "tssarea")) {
82-
return SipKernel::maxDbgSurfaceSize;
83+
return maxDbgSurfaceSize;
8384
}
8485

8586
auto hdr = reinterpret_cast<const SIP::StateSaveAreaHeader *>(stateSaveAreaHeader.data());

shared/source/built_ins/sip.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2021 Intel Corporation
2+
* Copyright (C) 2018-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -34,7 +34,7 @@ class SipKernel {
3434

3535
MOCKABLE_VIRTUAL GraphicsAllocation *getSipAllocation() const;
3636
MOCKABLE_VIRTUAL const std::vector<char> &getStateSaveAreaHeader() const;
37-
MOCKABLE_VIRTUAL size_t getStateSaveAreaSize() const;
37+
MOCKABLE_VIRTUAL size_t getStateSaveAreaSize(Device *device) const;
3838

3939
static bool initSipKernel(SipKernelType type, Device &device);
4040
static void freeSipKernels(RootDeviceEnvironment *rootDeviceEnvironment, MemoryManager *memoryManager);
@@ -43,8 +43,6 @@ class SipKernel {
4343
static const SipKernel &getBindlessDebugSipKernel(Device &device);
4444
static SipKernelType getSipKernelType(Device &device);
4545
static SipKernelType getSipKernelType(Device &device, bool debuggingEnable);
46-
47-
static const size_t maxDbgSurfaceSize;
4846
static SipClassType classType;
4947

5048
enum class COMMAND : uint32_t {

shared/source/helpers/hw_helper.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ class HwHelper {
114114
virtual uint32_t adjustMaxWorkGroupCount(uint32_t maxWorkGroupCount, const EngineGroupType engineGroupType,
115115
const HardwareInfo &hwInfo, bool isEngineInstanced) const = 0;
116116
virtual size_t getMaxFillPaternSizeForCopyEngine() const = 0;
117+
virtual size_t getSipKernelMaxDbgSurfaceSize(const HardwareInfo &hwInfo) const = 0;
117118
virtual bool isCopyOnlyEngineType(EngineGroupType type) const = 0;
118119
virtual bool isSipWANeeded(const HardwareInfo &hwInfo) const = 0;
119120
virtual bool isCpuImageTransferPreferred(const HardwareInfo &hwInfo) const = 0;
@@ -335,6 +336,8 @@ class HwHelperHw : public HwHelper {
335336

336337
size_t getMaxFillPaternSizeForCopyEngine() const override;
337338

339+
size_t getSipKernelMaxDbgSurfaceSize(const HardwareInfo &hwInfo) const override;
340+
338341
bool isKmdMigrationSupported(const HardwareInfo &hwInfo) const override;
339342

340343
bool isCooperativeEngineSupported(const HardwareInfo &hwInfo) const override;

shared/source/helpers/hw_helper_base.inl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,11 @@ template <typename GfxFamily>
689689
void HwHelperHw<GfxFamily>::setSipKernelData(uint32_t *&sipKernelBinary, size_t &kernelBinarySize) const {
690690
}
691691

692+
template <typename GfxFamily>
693+
size_t HwHelperHw<GfxFamily>::getSipKernelMaxDbgSurfaceSize(const HardwareInfo &hwInfo) const {
694+
return 0x1800000;
695+
}
696+
692697
template <typename GfxFamily>
693698
void HwHelperHw<GfxFamily>::adjustPreemptionSurfaceSize(size_t &csrSize) const {
694699
}

0 commit comments

Comments
 (0)