From 6a54bde16452f2a1f39fbacfc1293bdda7d0b704 Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Wed, 20 Jan 2021 12:04:13 +0000 Subject: [PATCH] Improve allocation logging, add gpu address to the log Signed-off-by: Mateusz Jablonski --- opencl/source/utilities/logger.cpp | 3 ++- .../os_interface/linux/file_logger_linux_tests.cpp | 8 +++++++- .../os_interface/windows/file_logger_win_tests.cpp | 7 ++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/opencl/source/utilities/logger.cpp b/opencl/source/utilities/logger.cpp index c404ffbc63..d36c138801 100644 --- a/opencl/source/utilities/logger.cpp +++ b/opencl/source/utilities/logger.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2020 Intel Corporation + * Copyright (C) 2019-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -97,6 +97,7 @@ void FileLogger::logAllocation(GraphicsAllocation const *graphicsAll ss << " ThreadID: " << thisThread; ss << " AllocationType: " << getAllocationTypeString(graphicsAllocation); ss << " MemoryPool: " << graphicsAllocation->getMemoryPool(); + ss << " GPU address: 0x" << std::hex << graphicsAllocation->getGpuAddress(); ss << graphicsAllocation->getAllocationInfoString(); ss << std::endl; diff --git a/opencl/test/unit_test/os_interface/linux/file_logger_linux_tests.cpp b/opencl/test/unit_test/os_interface/linux/file_logger_linux_tests.cpp index 27ebf9666e..54d5ebeb53 100644 --- a/opencl/test/unit_test/os_interface/linux/file_logger_linux_tests.cpp +++ b/opencl/test/unit_test/os_interface/linux/file_logger_linux_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2020 Intel Corporation + * Copyright (C) 2019-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -29,6 +29,8 @@ TEST(FileLogger, GivenLogAllocationMemoryPoolFlagThenLogsCorrectInfo) { MockDrmAllocation allocation(GraphicsAllocation::AllocationType::BUFFER, MemoryPool::System64KBPages); + allocation.setCpuPtrAndGpuAddress(&allocation, 0x12345); + MockBufferObject bo(&drm); bo.handle = 4; @@ -44,10 +46,14 @@ TEST(FileLogger, GivenLogAllocationMemoryPoolFlagThenLogsCorrectInfo) { std::stringstream memoryPoolCheck; memoryPoolCheck << " MemoryPool: " << allocation.getMemoryPool(); + std::stringstream gpuAddressCheck; + gpuAddressCheck << " GPU address: 0x" << std::hex << allocation.getGpuAddress(); + if (fileLogger.wasFileCreated(fileLogger.getLogFileName())) { auto str = fileLogger.getFileString(fileLogger.getLogFileName()); EXPECT_TRUE(str.find(threadIDCheck.str()) != std::string::npos); EXPECT_TRUE(str.find(memoryPoolCheck.str()) != std::string::npos); + EXPECT_TRUE(str.find(gpuAddressCheck.str()) != std::string::npos); EXPECT_TRUE(str.find("AllocationType: BUFFER") != std::string::npos); EXPECT_TRUE(str.find("Handle: 4") != std::string::npos); } diff --git a/opencl/test/unit_test/os_interface/windows/file_logger_win_tests.cpp b/opencl/test/unit_test/os_interface/windows/file_logger_win_tests.cpp index adc2f717cd..16b965a415 100644 --- a/opencl/test/unit_test/os_interface/windows/file_logger_win_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/file_logger_win_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2020 Intel Corporation + * Copyright (C) 2019-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -33,6 +33,7 @@ TEST_F(FileLoggerTests, GivenLogAllocationMemoryPoolFlagThenLogsCorrectInfo) { allocation.setAllocationType(GraphicsAllocation::AllocationType::BUFFER); allocation.memoryPool = MemoryPool::System64KBPages; allocation.getDefaultGmm()->resourceParams.Flags.Info.NonLocalOnly = 0; + allocation.setGpuAddress(0x12345); fileLogger.logAllocation(&allocation); @@ -44,11 +45,15 @@ TEST_F(FileLoggerTests, GivenLogAllocationMemoryPoolFlagThenLogsCorrectInfo) { std::stringstream memoryPoolCheck; memoryPoolCheck << " MemoryPool: " << allocation.getMemoryPool(); + std::stringstream gpuAddressCheck; + gpuAddressCheck << " GPU address: 0x" << std::hex << allocation.getGpuAddress(); + if (fileLogger.wasFileCreated(fileLogger.getLogFileName())) { auto str = fileLogger.getFileString(fileLogger.getLogFileName()); EXPECT_TRUE(str.find(threadIDCheck.str()) != std::string::npos); EXPECT_TRUE(str.find("Handle: 4") != std::string::npos); EXPECT_TRUE(str.find(memoryPoolCheck.str()) != std::string::npos); + EXPECT_TRUE(str.find(gpuAddressCheck.str()) != std::string::npos); EXPECT_TRUE(str.find("AllocationType: BUFFER") != std::string::npos); } }