DebugSession - add printBitmask()

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2021-11-15 11:52:19 +00:00
committed by Compute-Runtime-Automation
parent e1a1e96110
commit 35795357e9
3 changed files with 47 additions and 0 deletions

View File

@@ -213,4 +213,19 @@ size_t DebugSession::getPerThreadScratchOffset(size_t ptss, EuThread::ThreadId t
return threadOffset;
}
void DebugSession::printBitmask(uint8_t *bitmask, size_t bitmaskSize) {
if (NEO::DebugManager.flags.DebuggerLogBitmask.get() & NEO::DebugVariables::DEBUGGER_LOG_BITMASK::LOG_INFO) {
DEBUG_BREAK_IF(bitmaskSize % sizeof(uint64_t) != 0);
PRINT_DEBUGGER_LOG(stdout, "\nINFO: Bitmask: ", "");
for (size_t i = 0; i < bitmaskSize / sizeof(uint64_t); i++) {
uint64_t bitmask64 = 0;
memcpy_s(&bitmask64, sizeof(uint64_t), &bitmask[i * sizeof(uint64_t)], sizeof(uint64_t));
PRINT_DEBUGGER_LOG(stdout, "\n [%lu] = %#018" PRIx64, static_cast<uint64_t>(i), bitmask64);
}
}
}
} // namespace L0

View File

@@ -69,6 +69,8 @@ struct DebugSession : _zet_debug_session_handle_t {
return threadMatch && euMatch && subsliceMatch && sliceMatch;
}
static void printBitmask(uint8_t *bitmask, size_t bitmaskSize);
virtual ze_device_thread_t convertToPhysical(ze_device_thread_t thread, uint32_t &deviceIndex);
virtual EuThread::ThreadId convertToThreadId(ze_device_thread_t thread);
virtual ze_device_thread_t convertToApi(EuThread::ThreadId threadId);

View File

@@ -453,6 +453,36 @@ TEST(DebugSession, givenDifferentThreadsWhenGettingPerThreadScratchOffsetThenCor
EXPECT_EQ(2 * ptss + ptss * hwInfo.gtSystemInfo.MaxEuPerSubSlice * numThreadsPerEu, size);
}
TEST(DebugSession, GivenLogsEnabledWhenPrintBitmaskCalledThenBitmaskIsPrinted) {
DebugManagerStateRestore restorer;
NEO::DebugManager.flags.DebuggerLogBitmask.set(255);
::testing::internal::CaptureStdout();
uint64_t bitmask[2] = {0x404080808080, 0x1111ffff1111ffff};
DebugSession::printBitmask(reinterpret_cast<uint8_t *>(bitmask), sizeof(bitmask));
auto output = ::testing::internal::GetCapturedStdout();
EXPECT_THAT(output, testing::HasSubstr(std::string("\nINFO: Bitmask: ")));
EXPECT_THAT(output, testing::HasSubstr(std::string("[0] = 0x0000404080808080")));
EXPECT_THAT(output, testing::HasSubstr(std::string("[1] = 0x1111ffff1111ffff")));
}
TEST(DebugSession, GivenLogsDisabledWhenPrintBitmaskCalledThenBitmaskIsNotPrinted) {
DebugManagerStateRestore restorer;
NEO::DebugManager.flags.DebuggerLogBitmask.set(0);
::testing::internal::CaptureStdout();
uint64_t bitmask[2] = {0x404080808080, 0x1111ffff1111ffff};
DebugSession::printBitmask(reinterpret_cast<uint8_t *>(bitmask), sizeof(bitmask));
auto output = ::testing::internal::GetCapturedStdout();
EXPECT_EQ(0u, output.size());
}
using DebugSessionMultiTile = Test<MultipleDevicesWithCustomHwInfo>;
TEST_F(DebugSessionMultiTile, givenApiThreadAndMultipleTilesWhenConvertingToPhysicalThenCorrectValueReturned) {