mirror of
https://github.com/intel/compute-runtime.git
synced 2025-11-10 05:49:51 +08:00
Add DebugSession::areRequestedThreadsStopped() helper
Signed-off-by: Igor Venevtsev <igor.venevtsev@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
4586238c0e
commit
d49d294ba9
@@ -139,6 +139,25 @@ std::vector<ze_device_thread_t> DebugSession::getSingleThreads(ze_device_thread_
|
|||||||
return threads;
|
return threads;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
bool requestedThreadsStopped = true;
|
||||||
|
|
||||||
|
for (auto &thread : singleThreads) {
|
||||||
|
EuThread::ThreadId threadId = {deviceIndex, thread.slice, thread.subslice, thread.eu, thread.thread};
|
||||||
|
|
||||||
|
if (allThreads[threadId]->isStopped()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
requestedThreadsStopped = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestedThreadsStopped;
|
||||||
|
}
|
||||||
|
|
||||||
bool DebugSession::isBindlessSystemRoutine() {
|
bool DebugSession::isBindlessSystemRoutine() {
|
||||||
if (debugArea.reserved1 &= 1) {
|
if (debugArea.reserved1 &= 1) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ struct DebugSession : _zet_debug_session_handle_t {
|
|||||||
virtual ze_result_t readRegisters(ze_device_thread_t thread, uint32_t type, uint32_t start, uint32_t count, void *pRegisterValues) = 0;
|
virtual ze_result_t readRegisters(ze_device_thread_t thread, uint32_t type, uint32_t start, uint32_t count, void *pRegisterValues) = 0;
|
||||||
virtual ze_result_t writeRegisters(ze_device_thread_t thread, uint32_t type, uint32_t start, uint32_t count, void *pRegisterValues) = 0;
|
virtual ze_result_t writeRegisters(ze_device_thread_t thread, uint32_t type, uint32_t start, uint32_t count, void *pRegisterValues) = 0;
|
||||||
static ze_result_t getRegisterSetProperties(Device *device, uint32_t *pCount, zet_debug_regset_properties_t *pRegisterSetProperties);
|
static ze_result_t getRegisterSetProperties(Device *device, uint32_t *pCount, zet_debug_regset_properties_t *pRegisterSetProperties);
|
||||||
|
MOCKABLE_VIRTUAL bool areRequestedThreadsStopped(ze_device_thread_t thread);
|
||||||
|
|
||||||
Device *getConnectedDevice() { return connectedDevice; }
|
Device *getConnectedDevice() { return connectedDevice; }
|
||||||
|
|
||||||
|
|||||||
@@ -328,6 +328,46 @@ TEST(DebugSession, givenApiThreadAndSingleTileWhenConvertingThenCorrectValuesRet
|
|||||||
EXPECT_EQ(convertedThread.slice, thread.slice);
|
EXPECT_EQ(convertedThread.slice, thread.slice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(DebugSession, givenAllStoppedThreadsWhenAreRequestedThreadsStoppedCalledThenTrueReturned) {
|
||||||
|
zet_debug_config_t config = {};
|
||||||
|
config.pid = 0x1234;
|
||||||
|
auto hwInfo = *NEO::defaultHwInfo.get();
|
||||||
|
|
||||||
|
NEO::MockDevice *neoDevice(NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(&hwInfo, 0));
|
||||||
|
Mock<L0::DeviceImp> deviceImp(neoDevice, neoDevice->getExecutionEnvironment());
|
||||||
|
|
||||||
|
auto sessionMock = std::make_unique<DebugSessionMock>(config, &deviceImp);
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < hwInfo.gtSystemInfo.ThreadCount / hwInfo.gtSystemInfo.EUCount; i++) {
|
||||||
|
EuThread::ThreadId thread(0, 0, 0, 0, i);
|
||||||
|
sessionMock->allThreads[thread]->stopThread();
|
||||||
|
}
|
||||||
|
|
||||||
|
ze_device_thread_t apiThread = {0, 0, 0, UINT32_MAX};
|
||||||
|
EXPECT_TRUE(sessionMock->areRequestedThreadsStopped(apiThread));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(DebugSession, givenSomeStoppedThreadsWhenAreRequestedThreadsStoppedCalledThenFalseReturned) {
|
||||||
|
zet_debug_config_t config = {};
|
||||||
|
config.pid = 0x1234;
|
||||||
|
auto hwInfo = *NEO::defaultHwInfo.get();
|
||||||
|
|
||||||
|
NEO::MockDevice *neoDevice(NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(&hwInfo, 0));
|
||||||
|
Mock<L0::DeviceImp> deviceImp(neoDevice, neoDevice->getExecutionEnvironment());
|
||||||
|
|
||||||
|
auto sessionMock = std::make_unique<DebugSessionMock>(config, &deviceImp);
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < hwInfo.gtSystemInfo.ThreadCount / hwInfo.gtSystemInfo.EUCount; i++) {
|
||||||
|
EuThread::ThreadId thread(0, 0, 0, 0, i);
|
||||||
|
if (i % 2) {
|
||||||
|
sessionMock->allThreads[thread]->stopThread();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ze_device_thread_t apiThread = {0, 0, 0, UINT32_MAX};
|
||||||
|
EXPECT_FALSE(sessionMock->areRequestedThreadsStopped(apiThread));
|
||||||
|
}
|
||||||
|
|
||||||
using DebugSessionMultiTile = Test<MultipleDevicesWithCustomHwInfo>;
|
using DebugSessionMultiTile = Test<MultipleDevicesWithCustomHwInfo>;
|
||||||
|
|
||||||
TEST_F(DebugSessionMultiTile, givenApiThreadAndMultipleTilesWhenConvertingToPhysicalThenCorrectValueReturned) {
|
TEST_F(DebugSessionMultiTile, givenApiThreadAndMultipleTilesWhenConvertingToPhysicalThenCorrectValueReturned) {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class OsInterfaceWithDebugAttach : public NEO::OSInterface {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct DebugSessionMock : public L0::DebugSession {
|
struct DebugSessionMock : public L0::DebugSession {
|
||||||
|
using L0::DebugSession::allThreads;
|
||||||
using L0::DebugSession::debugArea;
|
using L0::DebugSession::debugArea;
|
||||||
using L0::DebugSession::getSingleThreads;
|
using L0::DebugSession::getSingleThreads;
|
||||||
using L0::DebugSession::isBindlessSystemRoutine;
|
using L0::DebugSession::isBindlessSystemRoutine;
|
||||||
|
|||||||
Reference in New Issue
Block a user