L0Debug refactor: Replace ze_device_thread_t with EuThread::ThreadId

- ThreadId is preferred beacuse it uniquely identifies thread and is
not related to device topology

Related-To: NEO-5784

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2022-07-14 18:14:46 +00:00
committed by Compute-Runtime-Automation
parent b89ebb3dd2
commit bd07b3ec97
14 changed files with 124 additions and 100 deletions

View File

@@ -307,7 +307,7 @@ DebugSessionImp::Error DebugSessionImp::resumeThreadsWithinDevice(uint32_t devic
[[maybe_unused]] auto sipCommandResult = writeResumeCommand(resumeThreadIds);
DEBUG_BREAK_IF(sipCommandResult != true);
auto result = resumeImp(resumeThreads, deviceIndex);
auto result = resumeImp(resumeThreadIds, deviceIndex);
for (auto &threadID : resumeThreadIds) {
while (checkThreadIsResumed(threadID) == false)
@@ -689,10 +689,10 @@ void DebugSessionImp::resumeAccidentallyStoppedThreads(const std::vector<EuThrea
for (uint32_t i = 0; i < 4; i++) {
std::unique_lock<std::mutex> lock(threadStateMutex);
if (threads[i].size() > 0) {
if (threadIdsPerDevice[i].size() > 0) {
[[maybe_unused]] auto writeSipCommandResult = writeResumeCommand(threadIdsPerDevice[i]);
DEBUG_BREAK_IF(writeSipCommandResult != true);
resumeImp(threads[i], i);
resumeImp(threadIdsPerDevice[i], i);
}
for (auto &threadID : threadIdsPerDevice[i]) {

View File

@@ -49,7 +49,7 @@ struct DebugSessionImp : DebugSession {
MOCKABLE_VIRTUAL bool writeResumeCommand(const std::vector<EuThread::ThreadId> &threadIds);
MOCKABLE_VIRTUAL bool checkThreadIsResumed(const EuThread::ThreadId &threadID);
virtual ze_result_t resumeImp(std::vector<ze_device_thread_t> threads, uint32_t deviceIndex) = 0;
virtual ze_result_t resumeImp(const std::vector<EuThread::ThreadId> &threads, uint32_t deviceIndex) = 0;
virtual ze_result_t interruptImp(uint32_t deviceIndex) = 0;
virtual ze_result_t readGpuMemory(uint64_t memoryHandle, char *output, size_t size, uint64_t gpuVa) = 0;

View File

@@ -8,6 +8,7 @@
#pragma once
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/helpers/debug_helpers.h"
#include <level_zero/ze_api.h>

View File

@@ -1006,14 +1006,13 @@ void DebugSessionLinux::handleAttentionEvent(prelim_drm_i915_debug_event_eu_atte
auto hwInfo = connectedDevice->getHwInfo();
auto &l0HwHelper = L0HwHelper::get(hwInfo.platform.eRenderCoreFamily);
auto threadsWithAttention = l0HwHelper.getThreadsFromAttentionBitmask(hwInfo, attention->bitmask, attention->bitmask_size);
auto threadsWithAttention = l0HwHelper.getThreadsFromAttentionBitmask(hwInfo, tileIndex, attention->bitmask, attention->bitmask_size);
printBitmask(attention->bitmask, attention->bitmask_size);
PRINT_DEBUGGER_THREAD_LOG("ATTENTION for tile = %d thread count = %d\n", tileIndex, (int)threadsWithAttention.size());
for (auto &thread : threadsWithAttention) {
EuThread::ThreadId threadId = {tileIndex, thread.slice, thread.subslice, thread.eu, thread.thread};
for (auto &threadId : threadsWithAttention) {
PRINT_DEBUGGER_THREAD_LOG("ATTENTION event for thread: %s\n", EuThread::toString(threadId).c_str());
markPendingInterruptsOrAddToNewlyStoppedFromRaisedAttention(threadId, vmHandle);
@@ -1090,7 +1089,7 @@ uint64_t DebugSessionLinux::extractVaFromUuidString(std::string &uuid) {
return parts[0];
}
int DebugSessionLinux::threadControl(std::vector<ze_device_thread_t> threads, uint32_t tile, ThreadControlCmd threadCmd, std::unique_ptr<uint8_t[]> &bitmaskOut, size_t &bitmaskSizeOut) {
int DebugSessionLinux::threadControl(const std::vector<EuThread::ThreadId> &threads, uint32_t tile, ThreadControlCmd threadCmd, std::unique_ptr<uint8_t[]> &bitmaskOut, size_t &bitmaskSizeOut) {
auto hwInfo = connectedDevice->getHwInfo();
auto classInstance = DrmHelper::getEngineInstance(connectedDevice, tile, hwInfo.capabilityTable.defaultEngineType);
@@ -1164,7 +1163,7 @@ int DebugSessionLinux::threadControl(std::vector<ze_device_thread_t> threads, ui
return res;
}
ze_result_t DebugSessionLinux::resumeImp(std::vector<ze_device_thread_t> threads, uint32_t deviceIndex) {
ze_result_t DebugSessionLinux::resumeImp(const std::vector<EuThread::ThreadId> &threads, uint32_t deviceIndex) {
std::unique_ptr<uint8_t[]> bitmask;
size_t bitmaskSize;

View File

@@ -170,7 +170,7 @@ struct DebugSessionLinux : DebugSessionImp {
MOCKABLE_VIRTUAL void handleEvent(prelim_drm_i915_debug_event *event);
bool checkAllEventsCollected();
ze_result_t readEventImp(prelim_drm_i915_debug_event *drmDebugEvent);
ze_result_t resumeImp(std::vector<ze_device_thread_t> threads, uint32_t deviceIndex) override;
ze_result_t resumeImp(const std::vector<EuThread::ThreadId> &threads, uint32_t deviceIndex) override;
ze_result_t interruptImp(uint32_t deviceIndex) override;
void enqueueApiEvent(zet_debug_event_t &debugEvent) override {
@@ -235,7 +235,7 @@ struct DebugSessionLinux : DebugSessionImp {
bool readSystemRoutineIdent(EuThread *thread, uint64_t vmHandle, SIP::sr_ident &srIdent) override;
MOCKABLE_VIRTUAL int threadControl(std::vector<ze_device_thread_t> threads, uint32_t tile, ThreadControlCmd threadCmd, std::unique_ptr<uint8_t[]> &bitmask, size_t &bitmaskSize);
MOCKABLE_VIRTUAL int threadControl(const std::vector<EuThread::ThreadId> &threads, uint32_t tile, ThreadControlCmd threadCmd, std::unique_ptr<uint8_t[]> &bitmask, size_t &bitmaskSize);
uint64_t getContextStateSaveAreaGpuVa(uint64_t memoryHandle) override;
uint64_t getSbaBufferGpuVa(uint64_t memoryHandle);

View File

@@ -399,7 +399,7 @@ ze_result_t DebugSessionWindows::acknowledgeEvent(const zet_debug_event_t *event
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
ze_result_t DebugSessionWindows::resumeImp(std::vector<ze_device_thread_t> threads, uint32_t deviceIndex) {
ze_result_t DebugSessionWindows::resumeImp(const std::vector<EuThread::ThreadId> &threads, uint32_t deviceIndex) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

View File

@@ -37,7 +37,7 @@ struct DebugSessionWindows : DebugSessionImp {
static ze_result_t translateEscapeReturnStatusToZeResult(uint32_t escapeErrorStatus);
protected:
ze_result_t resumeImp(std::vector<ze_device_thread_t> threads, uint32_t deviceIndex) override;
ze_result_t resumeImp(const std::vector<EuThread::ThreadId> &threads, uint32_t deviceIndex) override;
ze_result_t interruptImp(uint32_t deviceIndex) override;
ze_result_t readGpuMemory(uint64_t memoryHandle, char *output, size_t size, uint64_t gpuVa) override;

View File

@@ -112,7 +112,7 @@ struct MockDebugSession : public L0::DebugSessionImp {
readStateSaveAreaHeaderCalled++;
DebugSessionImp::readStateSaveAreaHeader();
}
ze_result_t resumeImp(std::vector<ze_device_thread_t> threads, uint32_t deviceIndex) override {
ze_result_t resumeImp(const std::vector<EuThread::ThreadId> &threads, uint32_t deviceIndex) override {
resumeImpCalled++;
resumeThreadCount = threads.size();
resumedThreads.push_back(std::move(threads));
@@ -244,7 +244,7 @@ struct MockDebugSession : public L0::DebugSessionImp {
std::vector<zet_debug_event_t> events;
std::vector<uint32_t> interruptedDevices;
std::vector<uint32_t> resumedDevices;
std::vector<std::vector<ze_device_thread_t>> resumedThreads;
std::vector<std::vector<EuThread::ThreadId>> resumedThreads;
NEO::SbaTrackedAddresses sba;
uint64_t readMemoryBuffer[64];

View File

@@ -317,7 +317,7 @@ struct MockDebugSessionLinux : public L0::DebugSessionLinux {
return L0::DebugSessionLinux::getTimeDifferenceMilliseconds(time);
}
int threadControl(std::vector<ze_device_thread_t> threads, uint32_t tile, ThreadControlCmd threadCmd, std::unique_ptr<uint8_t[]> &bitmask, size_t &bitmaskSize) override {
int threadControl(const std::vector<EuThread::ThreadId> &threads, uint32_t tile, ThreadControlCmd threadCmd, std::unique_ptr<uint8_t[]> &bitmask, size_t &bitmaskSize) override {
numThreadsPassedToThreadControl = threads.size();
return L0::DebugSessionLinux::threadControl(threads, tile, threadCmd, bitmask, bitmaskSize);
}
@@ -333,7 +333,7 @@ struct MockDebugSessionLinux : public L0::DebugSessionLinux {
return L0::DebugSessionLinux::writeRegisters(thread, type, start, count, pRegisterValues);
}
ze_result_t resumeImp(std::vector<ze_device_thread_t> threads, uint32_t deviceIndex) override {
ze_result_t resumeImp(const std::vector<EuThread::ThreadId> &threads, uint32_t deviceIndex) override {
resumedThreads.push_back(threads);
resumedDevices.push_back(deviceIndex);
return L0::DebugSessionLinux::resumeImp(threads, deviceIndex);
@@ -410,7 +410,7 @@ struct MockDebugSessionLinux : public L0::DebugSessionLinux {
uint32_t checkThreadIsResumedCalled = 0;
std::vector<uint32_t> resumedDevices;
std::vector<std::vector<ze_device_thread_t>> resumedThreads;
std::vector<std::vector<EuThread::ThreadId>> resumedThreads;
std::unordered_map<uint64_t, uint8_t> stoppedThreads;
@@ -5056,7 +5056,7 @@ TEST_F(DebugApiLinuxTest, WhenCallingThreadControlForInterruptThenProperIoctlsIs
auto handler = new MockIoctlHandler;
sessionMock->ioctlHandler.reset(handler);
std::vector<ze_device_thread_t> threads({});
std::vector<EuThread::ThreadId> threads({});
std::unique_ptr<uint8_t[]> bitmaskOut;
size_t bitmaskSizeOut = 0;
@@ -5097,7 +5097,7 @@ TEST_F(DebugApiLinuxTest, GivenErrorFromIoctlWhenCallingThreadControlForInterrup
auto handler = new MockIoctlHandler;
sessionMock->ioctlHandler.reset(handler);
std::vector<ze_device_thread_t> threads({});
std::vector<EuThread::ThreadId> threads({});
std::unique_ptr<uint8_t[]> bitmaskOut;
size_t bitmaskSizeOut = 0;
@@ -5121,7 +5121,7 @@ TEST_F(DebugApiLinuxTest, WhenCallingThreadControlForResumeThenProperIoctlsIsCal
auto handler = new MockIoctlHandler;
sessionMock->ioctlHandler.reset(handler);
std::vector<ze_device_thread_t> threads({});
std::vector<EuThread::ThreadId> threads({});
std::unique_ptr<uint8_t[]> bitmaskOut;
size_t bitmaskSizeOut = 0;
@@ -5255,7 +5255,7 @@ TEST_F(DebugApiLinuxTest, WhenCallingThreadControlForThreadStoppedThenProperIoct
auto handler = new MockIoctlHandler;
sessionMock->ioctlHandler.reset(handler);
std::vector<ze_device_thread_t> threads({});
std::vector<EuThread::ThreadId> threads({});
std::unique_ptr<uint8_t[]> bitmaskOut;
size_t bitmaskSizeOut = 0;
@@ -5361,17 +5361,17 @@ TEST_F(DebugApiLinuxAttentionTest, GivenEuAttentionEventForThreadsWhenHandlingEv
auto &hwInfo = neoDevice->getHardwareInfo();
auto &l0HwHelper = L0HwHelper::get(hwInfo.platform.eRenderCoreFamily);
std::vector<ze_device_thread_t> threads{
{0, 0, 0, 0},
{0, 0, 0, 1},
{0, 0, 0, 2},
{0, 0, 0, 3},
{0, 0, 0, 4},
{0, 0, 0, 5},
{0, 0, 0, 6}};
std::vector<EuThread::ThreadId> threads{
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 1},
{0, 0, 0, 0, 2},
{0, 0, 0, 0, 3},
{0, 0, 0, 0, 4},
{0, 0, 0, 0, 5},
{0, 0, 0, 0, 6}};
for (auto thread : threads) {
sessionMock->stoppedThreads[EuThread::ThreadId(0, thread).packed] = 1;
sessionMock->stoppedThreads[thread.packed] = 1;
}
l0HwHelper.getAttentionBitmaskForSingleThreads(threads, hwInfo, bitmask, bitmaskSize);
@@ -5409,14 +5409,14 @@ TEST_F(DebugApiLinuxAttentionTest, GivenEuAttentionEventWithInvalidClientWhenHan
auto &hwInfo = neoDevice->getHardwareInfo();
auto &l0HwHelper = L0HwHelper::get(hwInfo.platform.eRenderCoreFamily);
std::vector<ze_device_thread_t> threads{
{0, 0, 0, 0},
{0, 0, 0, 1},
{0, 0, 0, 2},
{0, 0, 0, 3},
{0, 0, 0, 4},
{0, 0, 0, 5},
{0, 0, 0, 6}};
std::vector<EuThread::ThreadId> threads{
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 1},
{0, 0, 0, 0, 2},
{0, 0, 0, 0, 3},
{0, 0, 0, 0, 4},
{0, 0, 0, 0, 5},
{0, 0, 0, 0, 6}};
l0HwHelper.getAttentionBitmaskForSingleThreads(threads, hwInfo, bitmask, bitmaskSize);
@@ -5501,10 +5501,10 @@ TEST_F(DebugApiLinuxAttentionTest, GivenInterruptedThreadsWhenOnlySomeThreadsRai
auto &hwInfo = neoDevice->getHardwareInfo();
auto &l0HwHelper = L0HwHelper::get(hwInfo.platform.eRenderCoreFamily);
std::vector<ze_device_thread_t> threads{
{0, 0, 0, 0}};
std::vector<EuThread::ThreadId> threads{
{0, 0, 0, 0, 0}};
sessionMock->stoppedThreads[EuThread::ThreadId(0, threads[0]).packed] = 1;
sessionMock->stoppedThreads[threads[0].packed] = 1;
if (hwInfo.gtSystemInfo.MaxEuPerSubSlice > 8) {
sessionMock->allThreads[EuThread::ThreadId(0, 0, 0, 4, 0)]->stopThread(1u);
@@ -5606,14 +5606,14 @@ TEST_F(DebugApiLinuxAttentionTest, GivenEventSeqnoLowerEqualThanSentInterruptWhe
auto &hwInfo = neoDevice->getHardwareInfo();
auto &l0HwHelper = L0HwHelper::get(hwInfo.platform.eRenderCoreFamily);
std::vector<ze_device_thread_t> threads{
{0, 0, 0, 0},
{0, 0, 0, 1},
{0, 0, 0, 2},
{0, 0, 0, 3},
{0, 0, 0, 4},
{0, 0, 0, 5},
{0, 0, 0, 6}};
std::vector<EuThread::ThreadId> threads{
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 1},
{0, 0, 0, 0, 2},
{0, 0, 0, 0, 3},
{0, 0, 0, 0, 4},
{0, 0, 0, 0, 5},
{0, 0, 0, 0, 6}};
l0HwHelper.getAttentionBitmaskForSingleThreads(threads, hwInfo, bitmask, bitmaskSize);