Improve allocation type logging.
- allow to do this in release builds. - allow to capture thise on stdout. Signed-off-by: Michal Mrozek <michal.mrozek@intel.com>
This commit is contained in:
parent
d8a98acafd
commit
b5d5784b81
|
@ -35,6 +35,7 @@ FileLogger<DebugLevel>::FileLogger(std::string filename, const DebugVariables &f
|
|||
dumpKernelArgsEnabled = flags.DumpKernelArgs.get();
|
||||
logApiCalls = flags.LogApiCalls.get();
|
||||
logAllocationMemoryPool = flags.LogAllocationMemoryPool.get();
|
||||
logAllocationType = flags.LogAllocationType.get();
|
||||
}
|
||||
|
||||
template <DebugFunctionalityLevel DebugLevel>
|
||||
|
@ -86,6 +87,10 @@ void FileLogger<DebugLevel>::logApiCall(const char *function, bool enter, int32_
|
|||
|
||||
template <DebugFunctionalityLevel DebugLevel>
|
||||
void FileLogger<DebugLevel>::logAllocation(GraphicsAllocation const *graphicsAllocation) {
|
||||
if (logAllocationType) {
|
||||
printDebugString(true, stdout, "Created Graphics Allocation of type %s\n", getAllocationTypeString(graphicsAllocation));
|
||||
}
|
||||
|
||||
if (false == enabled()) {
|
||||
return;
|
||||
}
|
||||
|
@ -244,12 +249,7 @@ void FileLogger<DebugLevel>::dumpKernelArgs(const MultiDispatchInfo *multiDispat
|
|||
}
|
||||
}
|
||||
|
||||
template <DebugFunctionalityLevel DebugLevel>
|
||||
const char *FileLogger<DebugLevel>::getAllocationTypeString(GraphicsAllocation const *graphicsAllocation) {
|
||||
if (false == enabled()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char *getAllocationTypeString(GraphicsAllocation const *graphicsAllocation) {
|
||||
auto type = graphicsAllocation->getAllocationType();
|
||||
|
||||
switch (type) {
|
||||
|
|
|
@ -20,6 +20,8 @@ namespace NEO {
|
|||
class Kernel;
|
||||
struct MultiDispatchInfo;
|
||||
|
||||
const char *getAllocationTypeString(GraphicsAllocation const *graphicsAllocation);
|
||||
|
||||
template <DebugFunctionalityLevel DebugLevel>
|
||||
class FileLogger {
|
||||
public:
|
||||
|
@ -137,7 +139,6 @@ class FileLogger {
|
|||
logFileName = filename;
|
||||
}
|
||||
|
||||
const char *getAllocationTypeString(GraphicsAllocation const *graphicsAllocation);
|
||||
bool peekLogApiCalls() { return logApiCalls; }
|
||||
|
||||
protected:
|
||||
|
@ -147,6 +148,7 @@ class FileLogger {
|
|||
bool dumpKernelArgsEnabled = false;
|
||||
bool logApiCalls = false;
|
||||
bool logAllocationMemoryPool = false;
|
||||
bool logAllocationType = false;
|
||||
|
||||
// Required for variadic template with 0 args passed
|
||||
void printInputs(std::stringstream &ss) {}
|
||||
|
|
|
@ -320,3 +320,4 @@ SkipFlushingEventsOnGetStatusCalls = 0
|
|||
AllowUnrestrictedSize = 0
|
||||
DoNotFreeResources = 0
|
||||
OverrideGmmResourceUsageField = -1
|
||||
LogAllocationType = 0
|
||||
|
|
|
@ -906,7 +906,7 @@ TEST_P(AllocationTypeLogging, givenGraphicsAllocationTypeWhenConvertingToStringT
|
|||
|
||||
GraphicsAllocation graphicsAllocation(0, input.type, nullptr, 0ull, 0ull, 0, MemoryPool::MemoryNull);
|
||||
|
||||
auto result = fileLogger.getAllocationTypeString(&graphicsAllocation);
|
||||
auto result = getAllocationTypeString(&graphicsAllocation);
|
||||
|
||||
EXPECT_STREQ(result, input.str);
|
||||
}
|
||||
|
@ -922,7 +922,7 @@ TEST(AllocationTypeLoggingSingle, givenGraphicsAllocationTypeWhenConvertingToStr
|
|||
|
||||
GraphicsAllocation graphicsAllocation(0, static_cast<GraphicsAllocation::AllocationType>(999), nullptr, 0ull, 0ull, 0, MemoryPool::MemoryNull);
|
||||
|
||||
auto result = fileLogger.getAllocationTypeString(&graphicsAllocation);
|
||||
auto result = getAllocationTypeString(&graphicsAllocation);
|
||||
|
||||
EXPECT_STREQ(result, "ILLEGAL_VALUE");
|
||||
}
|
||||
|
@ -937,20 +937,26 @@ TEST(AllocationTypeLoggingSingle, givenAllocationTypeWhenConvertingToStringThenS
|
|||
for (uint32_t i = 0; i < static_cast<uint32_t>(GraphicsAllocation::AllocationType::COUNT); i++) {
|
||||
graphicsAllocation.setAllocationType(static_cast<GraphicsAllocation::AllocationType>(i));
|
||||
|
||||
auto result = fileLogger.getAllocationTypeString(&graphicsAllocation);
|
||||
auto result = getAllocationTypeString(&graphicsAllocation);
|
||||
|
||||
EXPECT_STRNE(result, "ILLEGAL_VALUE");
|
||||
}
|
||||
}
|
||||
|
||||
TEST(AllocationTypeLoggingSingle, givenDisabledDebugFunctionalityWhenGettingGraphicsAllocationTypeThenNullptrReturned) {
|
||||
TEST(AllocationTypeLoggingSingle, givenDebugVariableToCaptureAllocationTypeWhenFunctionIsCalledThenProperAllocationTypeIsPrinted) {
|
||||
std::string testFile = "testfile";
|
||||
DebugVariables flags;
|
||||
FullyDisabledFileLogger fileLogger(testFile, flags);
|
||||
flags.LogAllocationType.set(1);
|
||||
|
||||
GraphicsAllocation graphicsAllocation(0, GraphicsAllocation::AllocationType::BUFFER, nullptr, 0ull, 0ull, 0, MemoryPool::MemoryNull);
|
||||
FullyEnabledFileLogger fileLogger(testFile, flags);
|
||||
|
||||
auto result = fileLogger.getAllocationTypeString(&graphicsAllocation);
|
||||
GraphicsAllocation graphicsAllocation(0, GraphicsAllocation::AllocationType::COMMAND_BUFFER, nullptr, 0ull, 0ull, 0, MemoryPool::MemoryNull);
|
||||
|
||||
EXPECT_STREQ(result, nullptr);
|
||||
testing::internal::CaptureStdout();
|
||||
fileLogger.logAllocation(&graphicsAllocation);
|
||||
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
std::string expectedOutput = "Created Graphics Allocation of type COMMAND_BUFFER\n";
|
||||
|
||||
EXPECT_STREQ(output.c_str(), expectedOutput.c_str());
|
||||
}
|
||||
|
|
|
@ -172,6 +172,7 @@ DECLARE_DEBUG_VARIABLE(bool, LogPatchTokens, false, "Enables logging patch token
|
|||
DECLARE_DEBUG_VARIABLE(bool, LogTaskCounts, false, "Enables logging taskCounts and taskLevels to file")
|
||||
DECLARE_DEBUG_VARIABLE(bool, LogAlignedAllocations, false, "Logs alignedMalloc and alignedFree allocations")
|
||||
DECLARE_DEBUG_VARIABLE(bool, LogAllocationMemoryPool, false, "Logs memory pool for allocations")
|
||||
DECLARE_DEBUG_VARIABLE(bool, LogAllocationType, false, "Logs allocation type to sdout")
|
||||
DECLARE_DEBUG_VARIABLE(bool, LogMemoryObject, false, "Logs memory object ptrs, sizes and operations")
|
||||
DECLARE_DEBUG_VARIABLE(bool, LogWaitingForCompletion, false, "Logs waiting for completion")
|
||||
DECLARE_DEBUG_VARIABLE(bool, ResidencyDebugEnable, false, "enables debug messages and checks for Residency Model")
|
||||
|
|
Loading…
Reference in New Issue