Skip to content

Commit 6a54bde

Browse files
Improve allocation logging, add gpu address to the log
Signed-off-by: Mateusz Jablonski <[email protected]>
1 parent 824dd62 commit 6a54bde

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

opencl/source/utilities/logger.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 Intel Corporation
2+
* Copyright (C) 2019-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -97,6 +97,7 @@ void FileLogger<DebugLevel>::logAllocation(GraphicsAllocation const *graphicsAll
9797
ss << " ThreadID: " << thisThread;
9898
ss << " AllocationType: " << getAllocationTypeString(graphicsAllocation);
9999
ss << " MemoryPool: " << graphicsAllocation->getMemoryPool();
100+
ss << " GPU address: 0x" << std::hex << graphicsAllocation->getGpuAddress();
100101
ss << graphicsAllocation->getAllocationInfoString();
101102
ss << std::endl;
102103

opencl/test/unit_test/os_interface/linux/file_logger_linux_tests.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 Intel Corporation
2+
* Copyright (C) 2019-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -29,6 +29,8 @@ TEST(FileLogger, GivenLogAllocationMemoryPoolFlagThenLogsCorrectInfo) {
2929

3030
MockDrmAllocation allocation(GraphicsAllocation::AllocationType::BUFFER, MemoryPool::System64KBPages);
3131

32+
allocation.setCpuPtrAndGpuAddress(&allocation, 0x12345);
33+
3234
MockBufferObject bo(&drm);
3335
bo.handle = 4;
3436

@@ -44,10 +46,14 @@ TEST(FileLogger, GivenLogAllocationMemoryPoolFlagThenLogsCorrectInfo) {
4446
std::stringstream memoryPoolCheck;
4547
memoryPoolCheck << " MemoryPool: " << allocation.getMemoryPool();
4648

49+
std::stringstream gpuAddressCheck;
50+
gpuAddressCheck << " GPU address: 0x" << std::hex << allocation.getGpuAddress();
51+
4752
if (fileLogger.wasFileCreated(fileLogger.getLogFileName())) {
4853
auto str = fileLogger.getFileString(fileLogger.getLogFileName());
4954
EXPECT_TRUE(str.find(threadIDCheck.str()) != std::string::npos);
5055
EXPECT_TRUE(str.find(memoryPoolCheck.str()) != std::string::npos);
56+
EXPECT_TRUE(str.find(gpuAddressCheck.str()) != std::string::npos);
5157
EXPECT_TRUE(str.find("AllocationType: BUFFER") != std::string::npos);
5258
EXPECT_TRUE(str.find("Handle: 4") != std::string::npos);
5359
}

opencl/test/unit_test/os_interface/windows/file_logger_win_tests.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 Intel Corporation
2+
* Copyright (C) 2019-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -33,6 +33,7 @@ TEST_F(FileLoggerTests, GivenLogAllocationMemoryPoolFlagThenLogsCorrectInfo) {
3333
allocation.setAllocationType(GraphicsAllocation::AllocationType::BUFFER);
3434
allocation.memoryPool = MemoryPool::System64KBPages;
3535
allocation.getDefaultGmm()->resourceParams.Flags.Info.NonLocalOnly = 0;
36+
allocation.setGpuAddress(0x12345);
3637

3738
fileLogger.logAllocation(&allocation);
3839

@@ -44,11 +45,15 @@ TEST_F(FileLoggerTests, GivenLogAllocationMemoryPoolFlagThenLogsCorrectInfo) {
4445
std::stringstream memoryPoolCheck;
4546
memoryPoolCheck << " MemoryPool: " << allocation.getMemoryPool();
4647

48+
std::stringstream gpuAddressCheck;
49+
gpuAddressCheck << " GPU address: 0x" << std::hex << allocation.getGpuAddress();
50+
4751
if (fileLogger.wasFileCreated(fileLogger.getLogFileName())) {
4852
auto str = fileLogger.getFileString(fileLogger.getLogFileName());
4953
EXPECT_TRUE(str.find(threadIDCheck.str()) != std::string::npos);
5054
EXPECT_TRUE(str.find("Handle: 4") != std::string::npos);
5155
EXPECT_TRUE(str.find(memoryPoolCheck.str()) != std::string::npos);
56+
EXPECT_TRUE(str.find(gpuAddressCheck.str()) != std::string::npos);
5257
EXPECT_TRUE(str.find("AllocationType: BUFFER") != std::string::npos);
5358
}
5459
}

0 commit comments

Comments
 (0)