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

@@ -29,6 +29,7 @@ FileLogger<DebugLevel>::FileLogger(std::string filename, const DebugVariables &f
logApiCalls = flags.LogApiCalls.get();
logAllocationMemoryPool = flags.LogAllocationMemoryPool.get();
logAllocationType = flags.LogAllocationType.get();
logAllocationStdout = flags.LogAllocationStdout.get();
}
template <DebugFunctionalityLevel DebugLevel>
@@ -84,14 +85,10 @@ void FileLogger<DebugLevel>::logAllocation(GraphicsAllocation const *graphicsAll
printDebugString(true, stdout, "Created Graphics Allocation of type %s\n", getAllocationTypeString(graphicsAllocation));
}
if (false == enabled()) {
return;
}
std::stringstream ss;
if (logAllocationMemoryPool || logAllocationType) {
std::thread::id thisThread = std::this_thread::get_id();
std::stringstream ss;
ss << " ThreadID: " << thisThread;
ss << " AllocationType: " << getAllocationTypeString(graphicsAllocation);
ss << " MemoryPool: " << graphicsAllocation->getMemoryPool();
@@ -100,9 +97,19 @@ void FileLogger<DebugLevel>::logAllocation(GraphicsAllocation const *graphicsAll
ss << graphicsAllocation->getAllocationInfoString();
ss << std::endl;
}
auto str = ss.str();
auto str = ss.str();
if (logAllocationStdout) {
printf("%s", str.c_str());
return;
}
if (false == enabled()) {
return;
}
if (logAllocationMemoryPool || logAllocationType) {
writeToFile(logFileName, str.c_str(), str.size(), std::ios::app);
}
}

View File

@@ -142,6 +142,7 @@ class FileLogger {
bool logApiCalls = false;
bool logAllocationMemoryPool = false;
bool logAllocationType = false;
bool logAllocationStdout = false;
// Required for variadic template with 0 args passed
void printInputs(std::stringstream &ss) {}