From a27b8399763177921532eb8f2f0d73cb07b57f95 Mon Sep 17 00:00:00 2001 From: Mateusz Hoppe Date: Mon, 13 Sep 2021 13:53:11 +0000 Subject: [PATCH] Refactor getSingleThreads() - return ThreadIds for chosen device index from ze_device_thread_t Signed-off-by: Mateusz Hoppe --- level_zero/tools/source/debug/debug_session.cpp | 11 +++++------ level_zero/tools/source/debug/debug_session.h | 2 +- .../sources/debug/debug_session_tests.cpp | 14 +++++++++----- .../unit_tests/sources/debug/mock_debug_session.h | 2 +- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/level_zero/tools/source/debug/debug_session.cpp b/level_zero/tools/source/debug/debug_session.cpp index a364cb9216..7a28cb7549 100644 --- a/level_zero/tools/source/debug/debug_session.cpp +++ b/level_zero/tools/source/debug/debug_session.cpp @@ -83,14 +83,14 @@ DebugSession::DebugSession(const zet_debug_config_t &config, Device *device) : c } } -std::vector DebugSession::getSingleThreads(ze_device_thread_t physicalThread, const NEO::HardwareInfo &hwInfo) { +std::vector DebugSession::getSingleThreadsForDevice(uint32_t deviceIndex, ze_device_thread_t physicalThread, const NEO::HardwareInfo &hwInfo) { const uint32_t numSubslicesPerSlice = hwInfo.gtSystemInfo.MaxSubSlicesSupported / hwInfo.gtSystemInfo.MaxSlicesSupported; const uint32_t numEuPerSubslice = hwInfo.gtSystemInfo.MaxEuPerSubSlice; const uint32_t numThreadsPerEu = (hwInfo.gtSystemInfo.ThreadCount / hwInfo.gtSystemInfo.EUCount); UNRECOVERABLE_IF(numThreadsPerEu > 8); - std::vector threads; + std::vector threads; const uint32_t slice = physicalThread.slice; const uint32_t subslice = physicalThread.subslice; @@ -116,7 +116,7 @@ std::vector DebugSession::getSingleThreads(ze_device_thread_ if (thread != UINT32_MAX) { threadID = thread; } - threads.push_back({sliceID, subsliceID, euID, threadID}); + threads.push_back({deviceIndex, sliceID, subsliceID, euID, threadID}); if (thread != UINT32_MAX) { break; @@ -143,11 +143,10 @@ bool DebugSession::areRequestedThreadsStopped(ze_device_thread_t thread) { auto hwInfo = connectedDevice->getHwInfo(); uint32_t deviceIndex = 0; auto physicalThread = convertToPhysical(thread, deviceIndex); - auto singleThreads = getSingleThreads(physicalThread, hwInfo); + auto singleThreads = getSingleThreadsForDevice(deviceIndex, physicalThread, hwInfo); bool requestedThreadsStopped = true; - for (auto &thread : singleThreads) { - EuThread::ThreadId threadId = {deviceIndex, thread.slice, thread.subslice, thread.eu, thread.thread}; + for (auto &threadId : singleThreads) { if (allThreads[threadId]->isStopped()) { continue; diff --git a/level_zero/tools/source/debug/debug_session.h b/level_zero/tools/source/debug/debug_session.h index 760dac0750..75abbfb87a 100644 --- a/level_zero/tools/source/debug/debug_session.h +++ b/level_zero/tools/source/debug/debug_session.h @@ -80,7 +80,7 @@ struct DebugSession : _zet_debug_session_handle_t { virtual bool isBindlessSystemRoutine(); virtual bool readModuleDebugArea() = 0; - std::vector getSingleThreads(ze_device_thread_t physicalThread, const NEO::HardwareInfo &hwInfo); + std::vector getSingleThreadsForDevice(uint32_t deviceIndex, ze_device_thread_t physicalThread, const NEO::HardwareInfo &hwInfo); DebugAreaHeader debugArea; 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 f85369c9ed..f0dd6aecd7 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 @@ -168,9 +168,11 @@ TEST(DebugSession, givenSingleThreadWhenGettingSingleThreadsThenCorrectThreadIsR auto subslice = hwInfo.gtSystemInfo.MaxSubSlicesSupported / hwInfo.gtSystemInfo.MaxSlicesSupported - 1; ze_device_thread_t physicalThread = {0, subslice, 2, 3}; - auto threads = debugSession->getSingleThreads(physicalThread, hwInfo); + auto threads = debugSession->getSingleThreadsForDevice(0, physicalThread, hwInfo); EXPECT_EQ(1u, threads.size()); + + EXPECT_EQ(0u, threads[0].tileIndex); EXPECT_EQ(0u, threads[0].slice); EXPECT_EQ(subslice, threads[0].subslice); EXPECT_EQ(2u, threads[0].eu); @@ -190,11 +192,12 @@ TEST(DebugSession, givenAllThreadsWhenGettingSingleThreadsThenCorrectThreadsAreR ze_device_thread_t physicalThread = {0, subslice, 2, UINT32_MAX}; const uint32_t numThreadsPerEu = (hwInfo.gtSystemInfo.ThreadCount / hwInfo.gtSystemInfo.EUCount); - auto threads = debugSession->getSingleThreads(physicalThread, hwInfo); + auto threads = debugSession->getSingleThreadsForDevice(0, physicalThread, hwInfo); EXPECT_EQ(numThreadsPerEu, threads.size()); for (uint32_t i = 0; i < numThreadsPerEu; i++) { + EXPECT_EQ(0u, threads[i].tileIndex); EXPECT_EQ(0u, threads[i].slice); EXPECT_EQ(subslice, threads[i].subslice); EXPECT_EQ(2u, threads[i].eu); @@ -215,7 +218,7 @@ TEST(DebugSession, givenAllEUsWhenGettingSingleThreadsThenCorrectThreadsAreRetur ze_device_thread_t physicalThread = {0, subslice, UINT32_MAX, 0}; const uint32_t numEuPerSubslice = hwInfo.gtSystemInfo.MaxEuPerSubSlice; - auto threads = debugSession->getSingleThreads(physicalThread, hwInfo); + auto threads = debugSession->getSingleThreadsForDevice(0, physicalThread, hwInfo); EXPECT_EQ(numEuPerSubslice, threads.size()); @@ -239,7 +242,7 @@ TEST(DebugSession, givenAllSubslicesWhenGettingSingleThreadsThenCorrectThreadsAr ze_device_thread_t physicalThread = {0, UINT32_MAX, 0, 0}; const uint32_t numSubslicesPerSlice = hwInfo.gtSystemInfo.MaxSubSlicesSupported / hwInfo.gtSystemInfo.MaxSlicesSupported; - auto threads = debugSession->getSingleThreads(physicalThread, hwInfo); + auto threads = debugSession->getSingleThreadsForDevice(0, physicalThread, hwInfo); EXPECT_EQ(numSubslicesPerSlice, threads.size()); @@ -263,11 +266,12 @@ TEST(DebugSession, givenAllSlicesWhenGettingSingleThreadsThenCorrectThreadsAreRe ze_device_thread_t physicalThread = {UINT32_MAX, 0, 0, 0}; const uint32_t numSlices = hwInfo.gtSystemInfo.MaxSlicesSupported; - auto threads = debugSession->getSingleThreads(physicalThread, hwInfo); + auto threads = debugSession->getSingleThreadsForDevice(0, physicalThread, hwInfo); EXPECT_EQ(numSlices, threads.size()); for (uint32_t i = 0; i < numSlices; i++) { + EXPECT_EQ(0u, threads[i].tileIndex); EXPECT_EQ(i, threads[i].slice); EXPECT_EQ(0u, threads[i].subslice); EXPECT_EQ(0u, threads[i].eu); 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 6ebf75d4e7..92eaec8336 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 @@ -26,7 +26,7 @@ class OsInterfaceWithDebugAttach : public NEO::OSInterface { struct DebugSessionMock : public L0::DebugSession { using L0::DebugSession::allThreads; using L0::DebugSession::debugArea; - using L0::DebugSession::getSingleThreads; + using L0::DebugSession::getSingleThreadsForDevice; using L0::DebugSession::isBindlessSystemRoutine; DebugSessionMock(const zet_debug_config_t &config, L0::Device *device) : DebugSession(config, device), config(config){};