mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-26 15:03:02 +08:00
Add memoryHandle to EuThread
Signed-off-by: Igor Venevtsev <igor.venevtsev@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
603250a5f0
commit
f3eb4e3ddf
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <level_zero/ze_api.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <limits>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
@@ -64,7 +65,8 @@ class EuThread {
|
||||
|
||||
EuThread(ThreadId threadId) : threadId(threadId) {}
|
||||
|
||||
bool stopThread() {
|
||||
bool stopThread(uint64_t memHandle) {
|
||||
memoryHandle = memHandle;
|
||||
if (state == State::Stopped) {
|
||||
return false;
|
||||
}
|
||||
@@ -113,6 +115,7 @@ class EuThread {
|
||||
}
|
||||
|
||||
bool resumeThread() {
|
||||
memoryHandle = invalidHandle;
|
||||
if (state != State::Stopped) {
|
||||
return false;
|
||||
}
|
||||
@@ -143,10 +146,16 @@ class EuThread {
|
||||
return threadId;
|
||||
}
|
||||
|
||||
uint64_t getMemoryHandle() { return memoryHandle; }
|
||||
|
||||
public:
|
||||
static constexpr uint64_t invalidHandle = std::numeric_limits<uint64_t>::max();
|
||||
|
||||
protected:
|
||||
ThreadId threadId;
|
||||
State state = State::Unavailable;
|
||||
uint8_t systemRoutineCounter = 0;
|
||||
std::atomic<uint64_t> memoryHandle = invalidHandle;
|
||||
};
|
||||
|
||||
static_assert(sizeof(EuThread::ThreadId) == sizeof(uint64_t));
|
||||
|
||||
@@ -344,7 +344,7 @@ TEST(DebugSession, givenAllStoppedThreadsWhenAreRequestedThreadsStoppedCalledThe
|
||||
|
||||
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();
|
||||
sessionMock->allThreads[thread]->stopThread(1u);
|
||||
}
|
||||
|
||||
ze_device_thread_t apiThread = {0, 0, 0, UINT32_MAX};
|
||||
@@ -364,7 +364,7 @@ TEST(DebugSession, givenSomeStoppedThreadsWhenAreRequestedThreadsStoppedCalledTh
|
||||
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();
|
||||
sessionMock->allThreads[thread]->stopThread(1u);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,19 +56,22 @@ TEST(EuThread, GivenEuThreadWhenChangingAndQueryingStatesThenStateIsChanged) {
|
||||
EXPECT_FALSE(euThread.isStopped());
|
||||
EXPECT_TRUE(euThread.isRunning());
|
||||
|
||||
bool result = euThread.stopThread();
|
||||
bool result = euThread.stopThread(0x1234);
|
||||
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_TRUE(euThread.isStopped());
|
||||
EXPECT_FALSE(euThread.isRunning());
|
||||
EXPECT_EQ(0x1234u, euThread.getMemoryHandle());
|
||||
|
||||
result = euThread.stopThread();
|
||||
result = euThread.stopThread(0x5678);
|
||||
|
||||
EXPECT_FALSE(result);
|
||||
EXPECT_TRUE(euThread.isStopped());
|
||||
EXPECT_FALSE(euThread.isRunning());
|
||||
EXPECT_EQ(0x5678u, euThread.getMemoryHandle());
|
||||
|
||||
result = euThread.resumeThread();
|
||||
EXPECT_EQ(EuThread::invalidHandle, euThread.getMemoryHandle());
|
||||
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_FALSE(euThread.isStopped());
|
||||
@@ -79,6 +82,7 @@ TEST(EuThread, GivenEuThreadWhenChangingAndQueryingStatesThenStateIsChanged) {
|
||||
EXPECT_FALSE(result);
|
||||
EXPECT_FALSE(euThread.isStopped());
|
||||
EXPECT_TRUE(euThread.isRunning());
|
||||
EXPECT_EQ(EuThread::invalidHandle, euThread.getMemoryHandle());
|
||||
}
|
||||
|
||||
TEST(EuThread, GivenEuThreadWhenToStringCalledThenCorrectStringReturned) {
|
||||
@@ -106,7 +110,7 @@ TEST(EuThread, GivenThreadStateStoppedWhenVerifyingStopWithOddCounterThenTrueRet
|
||||
EuThread euThread(threadId);
|
||||
|
||||
euThread.verifyStopped(1);
|
||||
euThread.stopThread();
|
||||
euThread.stopThread(1u);
|
||||
|
||||
EXPECT_TRUE(euThread.verifyStopped(1));
|
||||
EXPECT_TRUE(euThread.isStopped());
|
||||
@@ -118,7 +122,7 @@ TEST(EuThread, GivenThreadStateStoppedWhenVerifyingStopWithEvenCounterThenFalseR
|
||||
EuThread euThread(threadId);
|
||||
|
||||
euThread.verifyStopped(1);
|
||||
euThread.stopThread();
|
||||
euThread.stopThread(1u);
|
||||
|
||||
EXPECT_FALSE(euThread.verifyStopped(2));
|
||||
EXPECT_TRUE(euThread.isRunning());
|
||||
@@ -134,7 +138,7 @@ TEST(EuThread, GivenEnabledErrorLogsWhenThreadStateStoppedAndVerifyingStopWithEv
|
||||
EuThread euThread(threadId);
|
||||
|
||||
euThread.verifyStopped(1);
|
||||
euThread.stopThread();
|
||||
euThread.stopThread(1u);
|
||||
|
||||
::testing::internal::CaptureStderr();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user