diff --git a/level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper.h b/level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper.h index 6d601d30f9..3911cf971a 100644 --- a/level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper.h +++ b/level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper.h @@ -10,6 +10,7 @@ #include "shared/source/helpers/api_gfx_core_helper.h" #include "shared/source/helpers/heap_base_address_model.h" +#include "level_zero/include/zet_intel_gpu_debug.h" #include "level_zero/tools/source/debug/eu_thread.h" #include @@ -78,6 +79,7 @@ class L0GfxCoreHelper : public NEO::ApiGfxCoreHelper { virtual NEO::HeapAddressModel getPlatformHeapAddressModel() const = 0; virtual std::vector getSupportedNumGrfs() const = 0; virtual bool platformSupportsImmediateComputeFlushTask() const = 0; + virtual zet_debug_regset_type_intel_gpu_t getRegsetTypeForLargeGrfDetection() const = 0; protected: L0GfxCoreHelper() = default; @@ -115,6 +117,7 @@ class L0GfxCoreHelperHw : public L0GfxCoreHelper { NEO::HeapAddressModel getPlatformHeapAddressModel() const override; std::vector getSupportedNumGrfs() const override; bool platformSupportsImmediateComputeFlushTask() const override; + zet_debug_regset_type_intel_gpu_t getRegsetTypeForLargeGrfDetection() const override; protected: L0GfxCoreHelperHw() = default; diff --git a/level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper_base.inl b/level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper_base.inl index 00837b4fd6..cc485c9b74 100644 --- a/level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper_base.inl +++ b/level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper_base.inl @@ -39,4 +39,9 @@ bool L0GfxCoreHelperHw::multiTileCapablePlatform() const { return false; } +template +zet_debug_regset_type_intel_gpu_t L0GfxCoreHelperHw::getRegsetTypeForLargeGrfDetection() const { + return ZET_DEBUG_REGSET_TYPE_INVALID_INTEL_GPU; +} + } // namespace L0 diff --git a/level_zero/core/source/xe_hp_core/l0_gfx_core_helper_xe_hp_core.cpp b/level_zero/core/source/xe_hp_core/l0_gfx_core_helper_xe_hp_core.cpp index 23a413b1c8..71543b6685 100644 --- a/level_zero/core/source/xe_hp_core/l0_gfx_core_helper_xe_hp_core.cpp +++ b/level_zero/core/source/xe_hp_core/l0_gfx_core_helper_xe_hp_core.cpp @@ -42,6 +42,11 @@ bool L0GfxCoreHelperHw::platformSupportsRayTracing() const { return true; } +template <> +zet_debug_regset_type_intel_gpu_t L0GfxCoreHelperHw::getRegsetTypeForLargeGrfDetection() const { + return ZET_DEBUG_REGSET_TYPE_CR_INTEL_GPU; +} + template class L0GfxCoreHelperHw; } // namespace L0 diff --git a/level_zero/core/source/xe_hpc_core/l0_gfx_core_helper_xe_hpc_core.cpp b/level_zero/core/source/xe_hpc_core/l0_gfx_core_helper_xe_hpc_core.cpp index 4b4e5842cd..7fd00a2a63 100644 --- a/level_zero/core/source/xe_hpc_core/l0_gfx_core_helper_xe_hpc_core.cpp +++ b/level_zero/core/source/xe_hpc_core/l0_gfx_core_helper_xe_hpc_core.cpp @@ -35,6 +35,11 @@ bool L0GfxCoreHelperHw::platformSupportsStateBaseAddressTracking() const return true; } +template <> +zet_debug_regset_type_intel_gpu_t L0GfxCoreHelperHw::getRegsetTypeForLargeGrfDetection() const { + return ZET_DEBUG_REGSET_TYPE_CR_INTEL_GPU; +} + template class L0GfxCoreHelperHw; } // namespace L0 diff --git a/level_zero/core/source/xe_hpg_core/l0_gfx_core_helper_xe_hpg_core.cpp b/level_zero/core/source/xe_hpg_core/l0_gfx_core_helper_xe_hpg_core.cpp index 7c5a95e28a..f5df9ecc54 100644 --- a/level_zero/core/source/xe_hpg_core/l0_gfx_core_helper_xe_hpg_core.cpp +++ b/level_zero/core/source/xe_hpg_core/l0_gfx_core_helper_xe_hpg_core.cpp @@ -18,6 +18,11 @@ namespace L0 { using Family = NEO::XeHpgCoreFamily; static auto gfxCore = IGFX_XE_HPG_CORE; +template <> +zet_debug_regset_type_intel_gpu_t L0GfxCoreHelperHw::getRegsetTypeForLargeGrfDetection() const { + return ZET_DEBUG_REGSET_TYPE_CR_INTEL_GPU; +} + #include "level_zero/core/source/helpers/l0_gfx_core_helper_factory_init.inl" template class L0GfxCoreHelperHw; diff --git a/level_zero/core/test/unit_tests/gen12lp/test_l0_gfx_core_helper_gen12lp.cpp b/level_zero/core/test/unit_tests/gen12lp/test_l0_gfx_core_helper_gen12lp.cpp index 95772507b4..60f17db918 100644 --- a/level_zero/core/test/unit_tests/gen12lp/test_l0_gfx_core_helper_gen12lp.cpp +++ b/level_zero/core/test/unit_tests/gen12lp/test_l0_gfx_core_helper_gen12lp.cpp @@ -23,6 +23,11 @@ HWTEST_EXCLUDE_PRODUCT(L0GfxCoreHelperTest, givenBitmaskWithAttentionBitsForHalf using L0GfxCoreHelperTestGen12Lp = Test; +GEN12LPTEST_F(L0GfxCoreHelperTestGen12Lp, GivenGen12LpWhenGetRegsetTypeForLargeGrfDetectionIsCalledThenInvalidRegsetTypeIsRetuned) { + auto &l0GfxCoreHelper = getHelper(); + EXPECT_EQ(ZET_DEBUG_REGSET_TYPE_INVALID_INTEL_GPU, l0GfxCoreHelper.getRegsetTypeForLargeGrfDetection()); +} + GEN12LPTEST_F(L0GfxCoreHelperTestGen12Lp, GivenGen12LpWhenCheckingL0HelperForCmdListHeapSharingSupportThenReturnFalse) { auto &l0GfxCoreHelper = getHelper(); diff --git a/level_zero/core/test/unit_tests/xe_hpc_core/test_l0_gfx_core_helper_xe_hpc_core.cpp b/level_zero/core/test/unit_tests/xe_hpc_core/test_l0_gfx_core_helper_xe_hpc_core.cpp index 8cd03275ae..cff693b39e 100644 --- a/level_zero/core/test/unit_tests/xe_hpc_core/test_l0_gfx_core_helper_xe_hpc_core.cpp +++ b/level_zero/core/test/unit_tests/xe_hpc_core/test_l0_gfx_core_helper_xe_hpc_core.cpp @@ -74,5 +74,10 @@ XE_HPC_CORETEST_F(L0GfxCoreHelperTestXeHpc, GivenXeHpcWhenCheckingL0HelperForPla EXPECT_TRUE(l0GfxCoreHelper.platformSupportsImmediateComputeFlushTask()); } +XE_HPC_CORETEST_F(L0GfxCoreHelperTestXeHpc, GivenXeHpcWhenGetRegsetTypeForLargeGrfDetectionIsCalledThenCrRegsetTypeIsRetuned) { + auto &l0GfxCoreHelper = getHelper(); + EXPECT_EQ(ZET_DEBUG_REGSET_TYPE_CR_INTEL_GPU, l0GfxCoreHelper.getRegsetTypeForLargeGrfDetection()); +} + } // namespace ult } // namespace L0 diff --git a/level_zero/core/test/unit_tests/xe_hpg_core/test_l0_gfx_core_helper_xe_hpg_core.cpp b/level_zero/core/test/unit_tests/xe_hpg_core/test_l0_gfx_core_helper_xe_hpg_core.cpp index 0106ab5abd..cff6b39766 100644 --- a/level_zero/core/test/unit_tests/xe_hpg_core/test_l0_gfx_core_helper_xe_hpg_core.cpp +++ b/level_zero/core/test/unit_tests/xe_hpg_core/test_l0_gfx_core_helper_xe_hpg_core.cpp @@ -31,6 +31,11 @@ XE_HPG_CORETEST_F(L0GfxCoreHelperTestXeHpg, GivenXeHpgWhenCheckingL0HelperForMul EXPECT_FALSE(l0GfxCoreHelper.multiTileCapablePlatform()); } +XE_HPG_CORETEST_F(L0GfxCoreHelperTestXeHpg, GivenXeHpgWhenGetRegsetTypeForLargeGrfDetectionIsCalledThenCrRegsetTypeIsRetuned) { + auto &l0GfxCoreHelper = getHelper(); + EXPECT_EQ(ZET_DEBUG_REGSET_TYPE_CR_INTEL_GPU, l0GfxCoreHelper.getRegsetTypeForLargeGrfDetection()); +} + XE_HPG_CORETEST_F(L0GfxCoreHelperTestXeHpg, GivenXeHpgWhenCheckingL0HelperForCmdListHeapSharingSupportThenReturnTrue) { auto &l0GfxCoreHelper = getHelper(); EXPECT_TRUE(l0GfxCoreHelper.platformSupportsCmdListHeapSharing()); diff --git a/level_zero/tools/source/debug/debug_session.h b/level_zero/tools/source/debug/debug_session.h index 4eb3f7ec73..b4d6618a28 100644 --- a/level_zero/tools/source/debug/debug_session.h +++ b/level_zero/tools/source/debug/debug_session.h @@ -110,6 +110,9 @@ struct DebugSession : _zet_debug_session_handle_t { protected: DebugSession(const zet_debug_config_t &config, Device *device); void createEuThreads(); + void updateGrfRegisterSetProperties(EuThread::ThreadId thread, uint32_t *pCount, zet_debug_regset_properties_t *pRegisterSetProperties); + virtual uint32_t getRegisterSize(uint32_t type) = 0; + virtual ze_result_t readRegistersImp(EuThread::ThreadId thread, uint32_t type, uint32_t start, uint32_t count, void *pRegisterValues) = 0; virtual void startAsyncThread() = 0; diff --git a/level_zero/tools/source/debug/debug_session_imp.cpp b/level_zero/tools/source/debug/debug_session_imp.cpp index 15ac868f5d..72fd007d2c 100644 --- a/level_zero/tools/source/debug/debug_session_imp.cpp +++ b/level_zero/tools/source/debug/debug_session_imp.cpp @@ -1160,6 +1160,40 @@ ze_result_t DebugSessionImp::readSbaRegisters(EuThread::ThreadId threadId, uint3 return ZE_RESULT_SUCCESS; } +void DebugSession::updateGrfRegisterSetProperties(EuThread::ThreadId thread, uint32_t *pCount, zet_debug_regset_properties_t *pRegisterSetProperties) { + if (pRegisterSetProperties == nullptr) { + return; + } + + auto &gfxCoreHelper = this->connectedDevice->getGfxCoreHelper(); + if (!gfxCoreHelper.largeGrfModeSupported()) { + return; + } + + // update GRF, if large GRF is enabled + auto &l0GfxCoreHelper = connectedDevice->getNEODevice()->getRootDeviceEnvironment().getHelper(); + auto regsetType = l0GfxCoreHelper.getRegsetTypeForLargeGrfDetection(); + bool largeGrfModeEnabled = false; + const auto regSize = std::max(getRegisterSize(regsetType), 64u); + auto reg = std::make_unique(regSize / sizeof(uint32_t)); + memset(reg.get(), 0, regSize); + readRegistersImp(thread, regsetType, 0, 1, reg.get()); + auto regPtr = reg.get(); + if (regsetType == ZET_DEBUG_REGSET_TYPE_CR_INTEL_GPU) { + largeGrfModeEnabled = regPtr[0] & 0x2000; + } else if (regsetType == ZET_DEBUG_REGSET_TYPE_SR_INTEL_GPU) { + largeGrfModeEnabled = regPtr[1] & 0x6000; + } + + if (!largeGrfModeEnabled) { + for (uint32_t i = 0; i < *pCount; i++) { + if (pRegisterSetProperties[i].type == ZET_DEBUG_REGSET_TYPE_GRF_INTEL_GPU) { + pRegisterSetProperties[i].count = 128; + } + } + } +} + ze_result_t DebugSession::getThreadRegisterSetProperties(ze_device_thread_t thread, uint32_t *pCount, zet_debug_regset_properties_t *pRegisterSetProperties) { if (!isSingleThread(thread)) { return ZE_RESULT_ERROR_NOT_AVAILABLE; @@ -1170,7 +1204,13 @@ ze_result_t DebugSession::getThreadRegisterSetProperties(ze_device_thread_t thre return ZE_RESULT_ERROR_NOT_AVAILABLE; } - return getRegisterSetProperties(this->connectedDevice, pCount, pRegisterSetProperties); + auto ret = getRegisterSetProperties(this->connectedDevice, pCount, pRegisterSetProperties); + if (ret != ZE_RESULT_SUCCESS) { + return ret; + } + + updateGrfRegisterSetProperties(threadId, pCount, pRegisterSetProperties); + return ret; } ze_result_t DebugSession::getRegisterSetProperties(Device *device, uint32_t *pCount, zet_debug_regset_properties_t *pRegisterSetProperties) { @@ -1193,7 +1233,6 @@ ze_result_t DebugSession::getRegisterSetProperties(Device *device, uint32_t *pCo auto parseRegsetDesc = [&](const SIP::regset_desc ®setDesc, zet_debug_regset_type_intel_gpu_t regsetType) { if (regsetDesc.num) { if (totalRegsetNum < *pCount) { - uint16_t num = (regsetType == ZET_DEBUG_REGSET_TYPE_GRF_INTEL_GPU) ? 128 : regsetDesc.num; zet_debug_regset_properties_t regsetProps = { ZET_STRUCTURE_TYPE_DEBUG_REGSET_PROPERTIES, nullptr, @@ -1201,7 +1240,7 @@ ze_result_t DebugSession::getRegisterSetProperties(Device *device, uint32_t *pCo 0, DebugSessionImp::typeToRegsetFlags(regsetType), 0, - num, + regsetDesc.num, regsetDesc.bits, regsetDesc.bytes, }; diff --git a/level_zero/tools/source/debug/debug_session_imp.h b/level_zero/tools/source/debug/debug_session_imp.h index 9d90a5e0b5..d40296c764 100644 --- a/level_zero/tools/source/debug/debug_session_imp.h +++ b/level_zero/tools/source/debug/debug_session_imp.h @@ -71,7 +71,7 @@ struct DebugSessionImp : DebugSession { using ApiEventQueue = std::queue; protected: - MOCKABLE_VIRTUAL ze_result_t readRegistersImp(EuThread::ThreadId thread, uint32_t type, uint32_t start, uint32_t count, void *pRegisterValues); + ze_result_t readRegistersImp(EuThread::ThreadId thread, uint32_t type, uint32_t start, uint32_t count, void *pRegisterValues) override; MOCKABLE_VIRTUAL ze_result_t writeRegistersImp(EuThread::ThreadId thread, uint32_t type, uint32_t start, uint32_t count, void *pRegisterValues); Error resumeThreadsWithinDevice(uint32_t deviceIndex, ze_device_thread_t physicalThread); MOCKABLE_VIRTUAL bool writeResumeCommand(const std::vector &threadIds); @@ -120,7 +120,7 @@ struct DebugSessionImp : DebugSession { MOCKABLE_VIRTUAL ze_result_t waitForCmdReady(EuThread::ThreadId threadId, uint16_t retryCount); const SIP::regset_desc *typeToRegsetDesc(uint32_t type); - uint32_t getRegisterSize(uint32_t type); + uint32_t getRegisterSize(uint32_t type) override; size_t calculateThreadSlotOffset(EuThread::ThreadId threadId); size_t calculateRegisterOffsetInThreadSlot(const SIP::regset_desc *const regdesc, uint32_t start); diff --git a/level_zero/tools/test/unit_tests/sources/debug/CMakeLists.txt b/level_zero/tools/test/unit_tests/sources/debug/CMakeLists.txt index 5ffb8e51fc..a526faeb37 100644 --- a/level_zero/tools/test/unit_tests/sources/debug/CMakeLists.txt +++ b/level_zero/tools/test/unit_tests/sources/debug/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2021-2022 Intel Corporation +# Copyright (C) 2021-2023 Intel Corporation # # SPDX-License-Identifier: MIT # @@ -13,6 +13,7 @@ target_sources(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/test_debug_api.cpp ${CMAKE_CURRENT_SOURCE_DIR}/debug_session_common.h ${CMAKE_CURRENT_SOURCE_DIR}/debug_session_common.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/debug_session_registers_access.h ) add_subdirectories() diff --git a/level_zero/tools/test/unit_tests/sources/debug/debug_session_registers_access.h b/level_zero/tools/test/unit_tests/sources/debug/debug_session_registers_access.h new file mode 100644 index 0000000000..5204105293 --- /dev/null +++ b/level_zero/tools/test/unit_tests/sources/debug/debug_session_registers_access.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2022-2023 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h" +#include "level_zero/tools/test/unit_tests/sources/debug/mock_debug_session.h" + +#include "common/StateSaveAreaHeader.h" + +namespace L0 { +namespace ult { + +struct DebugSessionRegistersAccess { + void setUp() { + zet_debug_config_t config = {}; + config.pid = 0x1234; + auto hwInfo = *NEO::defaultHwInfo.get(); + + neoDevice = NEO::MockDevice::createWithNewExecutionEnvironment(&hwInfo, 0); + deviceImp = std::make_unique>(neoDevice, neoDevice->getExecutionEnvironment()); + + session = std::make_unique(config, deviceImp.get()); + + session->allThreads[stoppedThreadId]->stopThread(1u); + session->allThreads[stoppedThreadId]->reportAsStopped(); + } + + void tearDown() { + } + + void dumpRegisterState() { + if (session->stateSaveAreaHeader.size() == 0) { + return; + } + auto pStateSaveAreaHeader = reinterpret_cast(session->stateSaveAreaHeader.data()); + + for (uint32_t thread = 0; thread < pStateSaveAreaHeader->regHeader.num_threads_per_eu; thread++) { + EuThread::ThreadId threadId(0, 0, 0, 0, thread); + auto threadSlotOffset = session->calculateThreadSlotOffset(threadId); + + auto srMagicOffset = threadSlotOffset + pStateSaveAreaHeader->regHeader.sr_magic_offset; + SIP::sr_ident srMagic; + srMagic.count = 1; + srMagic.version.major = pStateSaveAreaHeader->versionHeader.version.major; + + session->writeGpuMemory(0, reinterpret_cast(&srMagic), sizeof(srMagic), reinterpret_cast(pStateSaveAreaHeader) + srMagicOffset); + } + } + + ze_device_thread_t stoppedThread = {0, 0, 0, 0}; + EuThread::ThreadId stoppedThreadId{0, stoppedThread}; + std::unique_ptr session; + std::unique_ptr> deviceImp; + NEO::MockDevice *neoDevice = nullptr; +}; + +} // namespace ult +} // namespace L0 diff --git a/level_zero/tools/test/unit_tests/sources/debug/debug_session_tests.cpp b/level_zero/tools/test/unit_tests/sources/debug/debug_session_tests.cpp index de272bb6ee..aef2f35c31 100644 --- a/level_zero/tools/test/unit_tests/sources/debug/debug_session_tests.cpp +++ b/level_zero/tools/test/unit_tests/sources/debug/debug_session_tests.cpp @@ -20,7 +20,7 @@ #include "level_zero/core/test/unit_tests/mocks/mock_device.h" #include "level_zero/include/zet_intel_gpu_debug.h" #include "level_zero/tools/source/debug/debug_session_imp.h" -#include "level_zero/tools/test/unit_tests/sources/debug/mock_debug_session.h" +#include "level_zero/tools/test/unit_tests/sources/debug/debug_session_registers_access.h" #include "common/StateSaveAreaHeader.h" #include "encode_surface_state_args.h" @@ -2228,50 +2228,6 @@ TEST_F(MultiTileDebugSessionTest, GivenMultitileDeviceWhenCallingAreRequestedThr EXPECT_TRUE(stopped); } -struct DebugSessionRegistersAccess { - void setUp() { - zet_debug_config_t config = {}; - config.pid = 0x1234; - auto hwInfo = *NEO::defaultHwInfo.get(); - - neoDevice = NEO::MockDevice::createWithNewExecutionEnvironment(&hwInfo, 0); - deviceImp = std::make_unique>(neoDevice, neoDevice->getExecutionEnvironment()); - - session = std::make_unique(config, deviceImp.get()); - - session->allThreads[stoppedThreadId]->stopThread(1u); - session->allThreads[stoppedThreadId]->reportAsStopped(); - } - - void tearDown() { - } - - void dumpRegisterState() { - if (session->stateSaveAreaHeader.size() == 0) { - return; - } - auto pStateSaveAreaHeader = reinterpret_cast(session->stateSaveAreaHeader.data()); - - for (uint32_t thread = 0; thread < pStateSaveAreaHeader->regHeader.num_threads_per_eu; thread++) { - EuThread::ThreadId threadId(0, 0, 0, 0, thread); - auto threadSlotOffset = session->calculateThreadSlotOffset(threadId); - - auto srMagicOffset = threadSlotOffset + pStateSaveAreaHeader->regHeader.sr_magic_offset; - SIP::sr_ident srMagic; - srMagic.count = 1; - srMagic.version.major = pStateSaveAreaHeader->versionHeader.version.major; - - session->writeGpuMemory(0, reinterpret_cast(&srMagic), sizeof(srMagic), reinterpret_cast(pStateSaveAreaHeader) + srMagicOffset); - } - } - - ze_device_thread_t stoppedThread = {0, 0, 0, 0}; - EuThread::ThreadId stoppedThreadId{0, stoppedThread}; - std::unique_ptr session; - std::unique_ptr> deviceImp; - NEO::MockDevice *neoDevice = nullptr; -}; - using DebugSessionRegistersAccessTest = Test; TEST_F(DebugSessionRegistersAccessTest, givenTypeToRegsetDescCalledThenCorrectRegdescIsReturned) { @@ -2319,6 +2275,72 @@ TEST_F(DebugSessionRegistersAccessTest, givenGetThreadRegisterSetPropertiesCalle EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, zetDebugGetThreadRegisterSetProperties(session->toHandle(), stoppedThread, &threadCount, nullptr)); } +TEST_F(DebugSessionRegistersAccessTest, + givenNonZeroCountAndNullRegsetPointerWhenGetThreadRegisterSetPropertiesCalledTheniInvalidNullPointerIsReturned) { + uint32_t threadCount = 10; + ze_device_thread_t thread = stoppedThread; + EXPECT_EQ(ZE_RESULT_ERROR_INVALID_NULL_POINTER, + zetDebugGetThreadRegisterSetProperties(session->toHandle(), thread, &threadCount, nullptr)); +} + +HWTEST2_F(DebugSessionRegistersAccessTest, + givenGetThreadRegisterSetPropertiesCalledWhenLargeGrfIsSetThen256GrfRegisterCountIsReported, + IsXeHpOrXeHpcOrXeHpgCore) { + auto mockBuiltins = new MockBuiltins(); + mockBuiltins->stateSaveAreaHeader = MockSipData::createStateSaveAreaHeader(2, 256); + neoDevice->executionEnvironment->rootDeviceEnvironments[0]->builtins.reset(mockBuiltins); + + { + auto pStateSaveAreaHeader = reinterpret_cast(session->stateSaveAreaHeader.data()); + auto size = pStateSaveAreaHeader->versionHeader.size * 8 + + pStateSaveAreaHeader->regHeader.state_area_offset + + pStateSaveAreaHeader->regHeader.state_save_size * 16; + session->stateSaveAreaHeader.resize(size); + } + + ze_device_thread_t thread = stoppedThread; + + auto *regdesc = &(reinterpret_cast(session->stateSaveAreaHeader.data()))->regHeader.cr; + uint32_t cr0[8] = {0, 0, 0, 0, 0, 0, 0, 0}; + cr0[0] = 0x80002000; + session->registersAccessHelper(session->allThreads[stoppedThreadId].get(), regdesc, 0, 1, cr0, true); + + uint32_t threadCount = 0; + EXPECT_EQ(ZE_RESULT_SUCCESS, zetDebugGetThreadRegisterSetProperties(session->toHandle(), thread, &threadCount, nullptr)); + std::vector threadRegsetProps(threadCount); + ASSERT_EQ(ZE_RESULT_SUCCESS, zetDebugGetThreadRegisterSetProperties(session->toHandle(), thread, &threadCount, threadRegsetProps.data())); + EXPECT_EQ(256u, threadRegsetProps[0].count); +} + +HWTEST2_F(DebugSessionRegistersAccessTest, + givenGetThreadRegisterSetPropertiesCalledWhenLargeGrfIsNotSetThen128GrfRegisterCountIsReported, + IsXeHpOrXeHpcOrXeHpgCore) { + auto mockBuiltins = new MockBuiltins(); + mockBuiltins->stateSaveAreaHeader = MockSipData::createStateSaveAreaHeader(2, 256); + neoDevice->executionEnvironment->rootDeviceEnvironments[0]->builtins.reset(mockBuiltins); + + { + auto pStateSaveAreaHeader = reinterpret_cast(session->stateSaveAreaHeader.data()); + auto size = pStateSaveAreaHeader->versionHeader.size * 8 + + pStateSaveAreaHeader->regHeader.state_area_offset + + pStateSaveAreaHeader->regHeader.state_save_size * 16; + session->stateSaveAreaHeader.resize(size); + } + + ze_device_thread_t thread = stoppedThread; + + auto *regdesc = &(reinterpret_cast(session->stateSaveAreaHeader.data()))->regHeader.cr; + uint32_t cr0[8] = {0, 0, 0, 0, 0, 0, 0, 0}; + cr0[0] = 0x80000000; + session->registersAccessHelper(session->allThreads[stoppedThreadId].get(), regdesc, 0, 1, cr0, true); + + uint32_t threadCount = 0; + EXPECT_EQ(ZE_RESULT_SUCCESS, zetDebugGetThreadRegisterSetProperties(session->toHandle(), thread, &threadCount, nullptr)); + std::vector threadRegsetProps(threadCount); + ASSERT_EQ(ZE_RESULT_SUCCESS, zetDebugGetThreadRegisterSetProperties(session->toHandle(), thread, &threadCount, threadRegsetProps.data())); + EXPECT_EQ(128u, threadRegsetProps[0].count); +} + TEST_F(DebugSessionRegistersAccessTest, givenGetThreadRegisterSetPropertiesCalledPropertieAreTheSameAsgetRegisterSetProperties) { auto mockBuiltins = new MockBuiltins(); diff --git a/level_zero/tools/test/unit_tests/sources/debug/mock_debug_session.h b/level_zero/tools/test/unit_tests/sources/debug/mock_debug_session.h index 0bf4d8b3f6..e6648fcc9d 100644 --- a/level_zero/tools/test/unit_tests/sources/debug/mock_debug_session.h +++ b/level_zero/tools/test/unit_tests/sources/debug/mock_debug_session.h @@ -116,6 +116,14 @@ struct DebugSessionMock : public L0::DebugSession { return true; } + ze_result_t readRegistersImp(EuThread::ThreadId thread, uint32_t type, uint32_t start, uint32_t count, void *pRegisterValues) override { + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + uint32_t getRegisterSize(uint32_t type) override { + return 0; + } + void detachTileDebugSession(DebugSession *tileSession) override {} bool areAllTileDebugSessionDetached() override { return true; } diff --git a/level_zero/tools/test/unit_tests/sources/debug/test_debug_api.cpp b/level_zero/tools/test/unit_tests/sources/debug/test_debug_api.cpp index d5c8804ead..cb851e369f 100644 --- a/level_zero/tools/test/unit_tests/sources/debug/test_debug_api.cpp +++ b/level_zero/tools/test/unit_tests/sources/debug/test_debug_api.cpp @@ -334,21 +334,6 @@ TEST_F(DebugApiTest, givenSIPHeaderHasZeroSizeMMEThenNotExposedAsRegset) { } } -TEST_F(DebugApiTest, givenSIPHeaderGRFCountNotEqualTo128ThenGetRegisterSetPropertiesReturns128) { - mockBuiltins = new MockBuiltins(); - mockBuiltins->stateSaveAreaHeader = MockSipData::createStateSaveAreaHeader(2, 256); - neoDevice->executionEnvironment->rootDeviceEnvironments[0]->builtins.reset(mockBuiltins); - uint32_t count = 0; - EXPECT_EQ(ZE_RESULT_SUCCESS, zetDebugGetRegisterSetProperties(device->toHandle(), &count, nullptr)); - EXPECT_EQ(13u, count); - - std::vector regsetProps(count); - EXPECT_EQ(ZE_RESULT_SUCCESS, zetDebugGetRegisterSetProperties(device->toHandle(), &count, regsetProps.data())); - - EXPECT_EQ(13u, count); - EXPECT_EQ(128u, regsetProps[0].count); -} - TEST_F(DebugApiTest, givenGetRegisterSetPropertiesCalledCorrectPropertiesReturned) { uint32_t count = 0; EXPECT_EQ(ZE_RESULT_SUCCESS, zetDebugGetRegisterSetProperties(device->toHandle(), &count, nullptr)); diff --git a/shared/source/helpers/gfx_core_helper.h b/shared/source/helpers/gfx_core_helper.h index bb2b7cfbf1..c1ad205a94 100644 --- a/shared/source/helpers/gfx_core_helper.h +++ b/shared/source/helpers/gfx_core_helper.h @@ -96,6 +96,7 @@ class GfxCoreHelper { virtual uint8_t getBarriersCountFromHasBarriers(uint8_t hasBarriers) const = 0; virtual uint32_t calculateAvailableThreadCount(const HardwareInfo &hwInfo, uint32_t grfCount) const = 0; virtual uint32_t calculateMaxWorkGroupSize(const KernelDescriptor &kernelDescriptor, uint32_t defaultMaxGroupSize) const = 0; + virtual bool largeGrfModeSupported() const = 0; virtual uint32_t alignSlmSize(uint32_t slmSize) const = 0; virtual uint32_t computeSlmValues(const HardwareInfo &hwInfo, uint32_t slmSize) const = 0; @@ -273,6 +274,7 @@ class GfxCoreHelperHw : public GfxCoreHelper { uint32_t calculateAvailableThreadCount(const HardwareInfo &hwInfo, uint32_t grfCount) const override; uint32_t calculateMaxWorkGroupSize(const KernelDescriptor &kernelDescriptor, uint32_t defaultMaxGroupSize) const override; + bool largeGrfModeSupported() const override; uint32_t alignSlmSize(uint32_t slmSize) const override; diff --git a/shared/source/helpers/gfx_core_helper_base.inl b/shared/source/helpers/gfx_core_helper_base.inl index 0d1e200c54..c92ed3dc20 100644 --- a/shared/source/helpers/gfx_core_helper_base.inl +++ b/shared/source/helpers/gfx_core_helper_base.inl @@ -664,6 +664,11 @@ bool GfxCoreHelperHw::isChipsetUniqueUUIDSupported() const { return false; } +template +bool GfxCoreHelperHw::largeGrfModeSupported() const { + return false; +} + template bool GfxCoreHelperHw::isTimestampShiftRequired() const { return true; diff --git a/shared/source/helpers/gfx_core_helper_xehp_and_later.inl b/shared/source/helpers/gfx_core_helper_xehp_and_later.inl index d768963fab..fac3f18a43 100644 --- a/shared/source/helpers/gfx_core_helper_xehp_and_later.inl +++ b/shared/source/helpers/gfx_core_helper_xehp_and_later.inl @@ -232,4 +232,9 @@ bool GfxCoreHelperHw::isChipsetUniqueUUIDSupported() const { return true; } +template <> +bool GfxCoreHelperHw::largeGrfModeSupported() const { + return true; +} + } // namespace NEO diff --git a/shared/test/common/helpers/sip_init.cpp b/shared/test/common/helpers/sip_init.cpp index 0be41cbbdc..4f5229780c 100644 --- a/shared/test/common/helpers/sip_init.cpp +++ b/shared/test/common/helpers/sip_init.cpp @@ -33,7 +33,7 @@ std::vector createStateSaveAreaHeader(uint32_t version) { } std::vector createStateSaveAreaHeader(uint32_t version, uint16_t grfNum) { - return createStateSaveAreaHeader(version, 128, 1); + return createStateSaveAreaHeader(version, grfNum, 1); } std::vector createStateSaveAreaHeader(uint32_t version, uint16_t grfNum, uint16_t mmeNum) { diff --git a/shared/test/common/test_macros/header/common_matchers.h b/shared/test/common/test_macros/header/common_matchers.h index 78b76d31ec..7f39e008c1 100644 --- a/shared/test/common/test_macros/header/common_matchers.h +++ b/shared/test/common/test_macros/header/common_matchers.h @@ -44,6 +44,7 @@ using IsAtMostXeHpcCore = IsAtMostGfxCore; using IsXeHpOrXeHpgCore = IsAnyGfxCores; using IsXeHpOrXeHpcCore = IsAnyGfxCores; using IsXeHpcOrXeHpgCore = IsAnyGfxCores; +using IsXeHpOrXeHpcOrXeHpgCore = IsAnyGfxCores; using IsNotXeHpOrXeHpgCore = IsNotAnyGfxCores; using IsNotXeHpOrXeHpcCore = IsNotAnyGfxCores; diff --git a/shared/test/unit_test/gen12lp/dg1/gfx_core_helper_tests_dg1.cpp b/shared/test/unit_test/gen12lp/dg1/gfx_core_helper_tests_dg1.cpp index 2bd56c480f..a8851be9f6 100644 --- a/shared/test/unit_test/gen12lp/dg1/gfx_core_helper_tests_dg1.cpp +++ b/shared/test/unit_test/gen12lp/dg1/gfx_core_helper_tests_dg1.cpp @@ -19,6 +19,11 @@ using GfxCoreHelperTestDg1 = GfxCoreHelperTest; +DG1TEST_F(GfxCoreHelperTestDg1, givenDg1SteppingWhenLargeGrfModeSupportedIsQueriedThenFalseIsReturned) { + auto &gfxCoreHelper = getHelper(); + EXPECT_FALSE(gfxCoreHelper.largeGrfModeSupported()); +} + DG1TEST_F(GfxCoreHelperTestDg1, givenDg1SteppingA0WhenAdjustDefaultEngineTypeCalledThenRcsIsReturned) { auto &gfxCoreHelper = getHelper(); const auto &productHelper = getHelper();