diff --git a/level_zero/core/source/device/device_imp.cpp b/level_zero/core/source/device/device_imp.cpp index 0505c02709..0b2ee6242a 100644 --- a/level_zero/core/source/device/device_imp.cpp +++ b/level_zero/core/source/device/device_imp.cpp @@ -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 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; diff --git a/level_zero/core/test/unit_tests/sources/debugger/test_module_with_debug.cpp b/level_zero/core/test/unit_tests/sources/debugger/test_module_with_debug.cpp index e43af47c35..e11a979b61 100644 --- a/level_zero/core/test/unit_tests/sources/debugger/test_module_with_debug.cpp +++ b/level_zero/core/test/unit_tests/sources/debugger/test_module_with_debug.cpp @@ -318,10 +318,12 @@ HWTEST_F(KernelDebugSurfaceTest, givenDebuggerAndBindfulKernelWhenAppendingKerne auto debugger = MockDebuggerL0Hw::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, diff --git a/opencl/source/command_queue/command_queue_hw.h b/opencl/source/command_queue/command_queue_hw.h index d0e354d264..03a30a4a8c 100644 --- a/opencl/source/command_queue/command_queue_hw.h +++ b/opencl/source/command_queue/command_queue_hw.h @@ -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(); diff --git a/opencl/test/unit_test/built_ins/sip_tests.cpp b/opencl/test/unit_test/built_ins/sip_tests.cpp index 4dfd72f7cb..8d86212eae 100644 --- a/opencl/test/unit_test/built_ins/sip_tests.cpp +++ b/opencl/test/unit_test/built_ins/sip_tests.cpp @@ -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::createWithNewExecutionEnvironment(nullptr)); EXPECT_NE(nullptr, mockDevice); diff --git a/opencl/test/unit_test/command_queue/command_queue_tests.cpp b/opencl/test/unit_test/command_queue/command_queue_tests.cpp index aff8ca2588..9734f407a8 100644 --- a/opencl/test/unit_test/command_queue/command_queue_tests.cpp +++ b/opencl/test/unit_test/command_queue/command_queue_tests.cpp @@ -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); diff --git a/opencl/test/unit_test/command_queue/enqueue_debug_kernel_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_debug_kernel_tests.cpp index 19550b4467..cc10e3dc36 100644 --- a/opencl/test/unit_test/command_queue/enqueue_debug_kernel_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_debug_kernel_tests.cpp @@ -175,7 +175,9 @@ HWTEST_F(EnqueueDebugKernelSimpleTest, givenKernelFromProgramWithDebugEnabledWhe std::unique_ptr kernel(MockKernel::create(*pDevice, &program)); kernel->initialize(); std::unique_ptr> mockCmdQ(new MockCommandQueueHwSetupDebugSurface(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)); diff --git a/shared/source/built_ins/sip.cpp b/shared/source/built_ins/sip.cpp index 83e0d42721..c50bcf5d0e 100644 --- a/shared/source/built_ins/sip.cpp +++ b/shared/source/built_ins/sip.cpp @@ -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 readFile(const std::string &fileName, size_t &retSize) { @@ -72,14 +70,17 @@ const std::vector &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(stateSaveAreaHeader.data()); diff --git a/shared/source/built_ins/sip.h b/shared/source/built_ins/sip.h index 82ee958f66..c7c7aa14b9 100644 --- a/shared/source/built_ins/sip.h +++ b/shared/source/built_ins/sip.h @@ -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 &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 { diff --git a/shared/source/helpers/hw_helper.h b/shared/source/helpers/hw_helper.h index d28a20c654..f03802c2a8 100644 --- a/shared/source/helpers/hw_helper.h +++ b/shared/source/helpers/hw_helper.h @@ -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; diff --git a/shared/source/helpers/hw_helper_base.inl b/shared/source/helpers/hw_helper_base.inl index 2b105fd9aa..d5f6e4ab9f 100644 --- a/shared/source/helpers/hw_helper_base.inl +++ b/shared/source/helpers/hw_helper_base.inl @@ -689,6 +689,11 @@ template void HwHelperHw::setSipKernelData(uint32_t *&sipKernelBinary, size_t &kernelBinarySize) const { } +template +size_t HwHelperHw::getSipKernelMaxDbgSurfaceSize(const HardwareInfo &hwInfo) const { + return 0x1800000; +} + template void HwHelperHw::adjustPreemptionSurfaceSize(size_t &csrSize) const { } diff --git a/shared/source/xe_hpc_core/hw_helper_xe_hpc_core.cpp b/shared/source/xe_hpc_core/hw_helper_xe_hpc_core.cpp index cb2c4e35ca..3db19f25a9 100644 --- a/shared/source/xe_hpc_core/hw_helper_xe_hpc_core.cpp +++ b/shared/source/xe_hpc_core/hw_helper_xe_hpc_core.cpp @@ -446,6 +446,11 @@ bool HwHelperHw::isRevisionSpecificBinaryBuiltinRequired() const { return true; } +template <> +size_t HwHelperHw::getSipKernelMaxDbgSurfaceSize(const HardwareInfo &hwInfo) const { + return 0x2800000; +} + } // namespace NEO #include "shared/source/helpers/hw_helper_pvc_and_later.inl" diff --git a/shared/test/unit_test/built_ins/sip_tests.cpp b/shared/test/unit_test/built_ins/sip_tests.cpp index 40d99865a7..c2400f1744 100644 --- a/shared/test/unit_test/built_ins/sip_tests.cpp +++ b/shared/test/unit_test/built_ins/sip_tests.cpp @@ -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; 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;