Add option to log allocations to std out

Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
Lukasz Jobczyk
2021-12-22 08:43:41 +00:00
committed by Compute-Runtime-Automation
parent 205e2e1957
commit 35f6cd00ee
5 changed files with 69 additions and 6 deletions

View File

@@ -63,6 +63,59 @@ TEST(FileLogger, GivenLogAllocationMemoryPoolFlagThenLogsCorrectInfo) {
}
}
TEST(FileLogger, givenLogAllocationStdoutWhenLogAllocationThenLogToStdoutInsteadOfFileAndDoNotCreateFile) {
std::string testFile = "testfile";
DebugVariables flags;
flags.LogAllocationMemoryPool.set(true);
flags.LogAllocationStdout.set(true);
FullyEnabledFileLogger fileLogger(testFile, flags);
// Log file not created
bool logFileCreated = fileExists(fileLogger.getLogFileName());
EXPECT_FALSE(logFileCreated);
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
DrmMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
MockDrmAllocation allocation(GraphicsAllocation::AllocationType::BUFFER, MemoryPool::System64KBPages);
allocation.setCpuPtrAndGpuAddress(&allocation, 0x12345);
MockBufferObject bo(&drm);
bo.handle = 4;
allocation.bufferObjects[0] = &bo;
testing::internal::CaptureStdout();
fileLogger.logAllocation(&allocation);
std::string output = testing::internal::GetCapturedStdout();
std::thread::id thisThread = std::this_thread::get_id();
std::stringstream threadIDCheck;
threadIDCheck << " ThreadID: " << thisThread;
std::stringstream memoryPoolCheck;
memoryPoolCheck << " MemoryPool: " << allocation.getMemoryPool();
std::stringstream gpuAddressCheck;
gpuAddressCheck << " GPU address: 0x" << std::hex << allocation.getGpuAddress();
std::stringstream rootDeviceIndexCheck;
rootDeviceIndexCheck << " Root device index: " << allocation.getRootDeviceIndex();
EXPECT_TRUE(output.find(threadIDCheck.str()) != std::string::npos);
EXPECT_TRUE(output.find(memoryPoolCheck.str()) != std::string::npos);
EXPECT_TRUE(output.find(gpuAddressCheck.str()) != std::string::npos);
EXPECT_TRUE(output.find(rootDeviceIndexCheck.str()) != std::string::npos);
EXPECT_TRUE(output.find("AllocationType: BUFFER") != std::string::npos);
EXPECT_TRUE(output.find("Handle: 4") != std::string::npos);
EXPECT_TRUE(output.find("\n") != std::string::npos);
logFileCreated = fileExists(fileLogger.getLogFileName());
EXPECT_FALSE(logFileCreated);
}
TEST(FileLogger, GivenDrmAllocationWithoutBOThenNoHandleLogged) {
std::string testFile = "testfile";
DebugVariables flags;

View File

@@ -329,6 +329,7 @@ AllowUnrestrictedSize = 0
DoNotFreeResources = 0
OverrideGmmResourceUsageField = -1
LogAllocationType = 0
LogAllocationStdout = 0
ProgramPipeControlPriorToNonPipelinedStateCommand = -1
ProgramWalkerPartitionSelfCleanup = -1
WparidRegisterProgramming = -1