Fill devices from api thread

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2021-09-21 18:18:16 +00:00
committed by Compute-Runtime-Automation
parent 5c1c96fa94
commit b0ec436b3e
4 changed files with 61 additions and 0 deletions

View File

@@ -157,6 +157,23 @@ bool DebugSession::areRequestedThreadsStopped(ze_device_thread_t thread) {
return requestedThreadsStopped;
}
void DebugSession::fillDevicesFromThread(ze_device_thread_t thread, std::vector<uint8_t> &devices) {
auto deviceCount = std::max(1u, connectedDevice->getNEODevice()->getNumSubDevices());
UNRECOVERABLE_IF(devices.size() < deviceCount);
uint32_t deviceIndex = 0;
convertToPhysical(thread, deviceIndex);
bool singleDevice = (thread.slice != UINT32_MAX && deviceCount > 1) || deviceCount == 1;
if (singleDevice) {
devices[deviceIndex] = 1;
} else {
for (uint32_t i = 0; i < deviceCount; i++) {
devices[i] = 1;
}
}
}
bool DebugSession::isBindlessSystemRoutine() {
if (debugArea.reserved1 &= 1) {
return true;

View File

@@ -80,6 +80,8 @@ struct DebugSession : _zet_debug_session_handle_t {
virtual bool isBindlessSystemRoutine();
virtual bool readModuleDebugArea() = 0;
void fillDevicesFromThread(ze_device_thread_t thread, std::vector<uint8_t> &devices);
std::vector<EuThread::ThreadId> getSingleThreadsForDevice(uint32_t deviceIndex, ze_device_thread_t physicalThread, const NEO::HardwareInfo &hwInfo);
DebugAreaHeader debugArea;

View File

@@ -372,6 +372,20 @@ TEST(DebugSession, givenSomeStoppedThreadsWhenAreRequestedThreadsStoppedCalledTh
EXPECT_FALSE(sessionMock->areRequestedThreadsStopped(apiThread));
}
TEST(DebugSession, givenApiThreadAndSingleTileWhenFillingDevicesThenVectorEntryIsSet) {
auto hwInfo = *NEO::defaultHwInfo.get();
NEO::Device *neoDevice(NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(&hwInfo, 0));
Mock<L0::DeviceImp> deviceImp(neoDevice, neoDevice->getExecutionEnvironment());
auto debugSession = std::make_unique<DebugSessionMock>(zet_debug_config_t{0x1234}, &deviceImp);
ze_device_thread_t thread = {hwInfo.gtSystemInfo.SliceCount - 1, hwInfo.gtSystemInfo.SubSliceCount - 1, 0, 0};
std::vector<uint8_t> devices(1);
debugSession->fillDevicesFromThread(thread, devices);
EXPECT_EQ(1u, devices[0]);
}
using DebugSessionMultiTile = Test<MultipleDevicesWithCustomHwInfo>;
TEST_F(DebugSessionMultiTile, givenApiThreadAndMultipleTilesWhenConvertingToPhysicalThenCorrectValueReturned) {
@@ -462,5 +476,32 @@ TEST_F(DebugSessionMultiTile, WhenConvertingToThreadIdAndBackThenCorrectThreadId
EXPECT_EQ(thread.thread, apiThread.thread);
}
TEST_F(DebugSessionMultiTile, givenApiThreadAndMultiTileWhenFillingDevicesThenVectorEntriesAreSet) {
L0::Device *device = driverHandle->devices[0];
auto debugSession = std::make_unique<DebugSessionMock>(zet_debug_config_t{0x1234}, device);
ze_device_thread_t thread = {UINT32_MAX, 0, 0, 0};
std::vector<uint8_t> devices(numSubDevices);
debugSession->fillDevicesFromThread(thread, devices);
EXPECT_EQ(1u, devices[0]);
EXPECT_EQ(1u, devices[1]);
}
TEST_F(DebugSessionMultiTile, givenApiThreadAndSingleTileWhenFillingDevicesThenVectorEntryIsSet) {
L0::Device *device = driverHandle->devices[0];
auto debugSession = std::make_unique<DebugSessionMock>(zet_debug_config_t{0x1234}, device);
ze_device_thread_t thread = {sliceCount * numSubDevices - 1, 0, 0, 0};
std::vector<uint8_t> devices(numSubDevices);
debugSession->fillDevicesFromThread(thread, devices);
EXPECT_EQ(0u, devices[0]);
EXPECT_EQ(1u, devices[1]);
}
} // namespace ult
} // namespace L0

View File

@@ -26,6 +26,7 @@ class OsInterfaceWithDebugAttach : public NEO::OSInterface {
struct DebugSessionMock : public L0::DebugSession {
using L0::DebugSession::allThreads;
using L0::DebugSession::debugArea;
using L0::DebugSession::fillDevicesFromThread;
using L0::DebugSession::getSingleThreadsForDevice;
using L0::DebugSession::isBindlessSystemRoutine;