From f53d9103ad06d4985c9179363c2af23662c65447 Mon Sep 17 00:00:00 2001 From: "Yates, Brandon" Date: Fri, 27 Jan 2023 21:01:48 +0000 Subject: [PATCH] Fix(L0Debug): Fix thread creation on dg2 128EU Not enough EUThread objects were being created resulting in a crash during breeakpoint processing Related-to: LOCI-3937 Signed-off-by: Yates, Brandon --- .../tools/source/debug/debug_session_imp.cpp | 2 +- .../sources/debug/debug_session_tests.cpp | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/level_zero/tools/source/debug/debug_session_imp.cpp b/level_zero/tools/source/debug/debug_session_imp.cpp index cafb3f928b..87df3424ae 100644 --- a/level_zero/tools/source/debug/debug_session_imp.cpp +++ b/level_zero/tools/source/debug/debug_session_imp.cpp @@ -47,7 +47,7 @@ void DebugSession::createEuThreads() { tileIndex = Math::log2(static_cast(connectedDevice->getNEODevice()->getDeviceBitfield().to_ulong())); } - for (uint32_t sliceID = 0; sliceID < hwInfo.gtSystemInfo.MaxSlicesSupported; sliceID++) { + for (uint32_t sliceID = 0; sliceID < NEO::GfxCoreHelper::getHighestEnabledSlice(hwInfo); sliceID++) { for (uint32_t subsliceID = 0; subsliceID < numSubslicesPerSlice; subsliceID++) { for (uint32_t euID = 0; euID < numEuPerSubslice; euID++) { 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 86ed6f9a01..5903c0c084 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 @@ -30,6 +30,29 @@ namespace ult { using DebugSessionTest = ::testing::Test; +TEST(DeviceWithDebugSessionTest, GivenSlicesEnabledWithEarlierSlicesDisabledThenAllThreadsIsPopulatedCorrectly) { + auto hwInfo = *NEO::defaultHwInfo; + hwInfo.gtSystemInfo.MaxSlicesSupported = 2; + hwInfo.gtSystemInfo.MaxEuPerSubSlice = 8; + hwInfo.gtSystemInfo.MaxSubSlicesSupported = 64; + hwInfo.gtSystemInfo.MaxDualSubSlicesSupported = 32; + hwInfo.gtSystemInfo.IsDynamicallyPopulated = true; + hwInfo.gtSystemInfo.MaxSlicesSupported = 2; + for (int i = 0; i < GT_MAX_SLICE; i++) { + hwInfo.gtSystemInfo.SliceInfo[i].Enabled = false; + } + hwInfo.gtSystemInfo.SliceInfo[2].Enabled = true; + hwInfo.gtSystemInfo.SliceInfo[3].Enabled = true; + + NEO::MockDevice *neoDevice(NEO::MockDevice::createWithNewExecutionEnvironment(&hwInfo, 0)); + Mock deviceImp(neoDevice, neoDevice->getExecutionEnvironment()); + auto sessionMock = std::make_unique(zet_debug_config_t{0x1234}, &deviceImp); + const uint32_t numSubslicesPerSlice = hwInfo.gtSystemInfo.MaxDualSubSlicesSupported / hwInfo.gtSystemInfo.MaxSlicesSupported; + EXPECT_EQ(1u, sessionMock->allThreads.count(EuThread::ThreadId(0, 0, numSubslicesPerSlice - 1, 0, 0))); + EXPECT_EQ(1u, sessionMock->allThreads.count(EuThread::ThreadId(0, 1, numSubslicesPerSlice - 1, 7, 0))); + EXPECT_EQ(1u, sessionMock->allThreads.count(EuThread::ThreadId(0, 2, numSubslicesPerSlice - 1, 0, 0))); +} + TEST(DeviceWithDebugSessionTest, GivenDeviceWithDebugSessionWhenCallingReleaseResourcesThenCloseConnectionIsCalled) { ze_result_t returnValue = ZE_RESULT_SUCCESS; std::unique_ptr driverHandle(new DriverHandleImp);