mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 23:03:02 +08:00
fix: use productHelper in getPatIndexInfoString() on Windows
Fix the PAT-index reporting in logger as currently on Windows reported values are simply wrong. The changed logic dependends on `RootDeviceEnvironment` and in order to avoid introducing such dependencies into logger.[ch] the `logAllocation()` is no longer a member of `FileLogger` but a free-function instead (and a separate .cpp file). This is important because the source files `logger.[ch]` are also used by ocloc library and there is no point to contaminate ocloc code structure with unnecessary dependencies. Related-To: NEO-9421 Signed-off-by: Maciej Bielski <maciej.bielski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
f76d480e8a
commit
45e78fea76
@@ -8,6 +8,7 @@
|
||||
#include "shared/source/utilities/logger.h"
|
||||
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/execution_environment/execution_environment.h"
|
||||
#include "shared/source/helpers/timestamp_packet.h"
|
||||
#include "shared/source/memory_manager/memory_manager.h"
|
||||
#include "shared/source/utilities/io_functions.h"
|
||||
@@ -93,48 +94,6 @@ void FileLogger<debugLevel>::logApiCall(const char *function, bool enter, int32_
|
||||
}
|
||||
}
|
||||
|
||||
template <DebugFunctionalityLevel debugLevel>
|
||||
void FileLogger<debugLevel>::logAllocation(GraphicsAllocation const *graphicsAllocation, MemoryManager const *memoryManager) {
|
||||
if (logAllocationType) {
|
||||
printDebugString(true, stdout, "Created Graphics Allocation of type %s\n", getAllocationTypeString(graphicsAllocation));
|
||||
}
|
||||
|
||||
if (false == enabled() && !logAllocationStdout) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (logAllocationMemoryPool || logAllocationType) {
|
||||
std::stringstream ss;
|
||||
std::thread::id thisThread = std::this_thread::get_id();
|
||||
|
||||
ss << " ThreadID: " << thisThread;
|
||||
ss << " Type: " << getAllocationTypeString(graphicsAllocation);
|
||||
ss << " Pool: " << getMemoryPoolString(graphicsAllocation);
|
||||
ss << " Root index: " << graphicsAllocation->getRootDeviceIndex();
|
||||
ss << " Size: " << graphicsAllocation->getUnderlyingBufferSize();
|
||||
ss << " GPU VA: 0x" << std::hex << graphicsAllocation->getGpuAddress() << " - 0x" << std::hex << graphicsAllocation->getGpuAddress() + graphicsAllocation->getUnderlyingBufferSize() - 1;
|
||||
|
||||
ss << graphicsAllocation->getAllocationInfoString();
|
||||
ss << graphicsAllocation->getPatIndexInfoString();
|
||||
|
||||
if (memoryManager) {
|
||||
ss << " Total sys mem allocated: " << std::dec << memoryManager->getUsedSystemMemorySize();
|
||||
ss << " Total lmem allocated: " << std::dec << memoryManager->getUsedLocalMemorySize(graphicsAllocation->getRootDeviceIndex());
|
||||
}
|
||||
|
||||
ss << std::endl;
|
||||
auto str = ss.str();
|
||||
if (logAllocationStdout) {
|
||||
printf("%s", str.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (enabled()) {
|
||||
writeToFile(logFileName, str.c_str(), str.size(), std::ios::app);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <DebugFunctionalityLevel debugLevel>
|
||||
size_t FileLogger<debugLevel>::getInput(const size_t *input, int32_t index) {
|
||||
if (enabled() == false)
|
||||
|
||||
@@ -41,7 +41,6 @@ class FileLogger {
|
||||
|
||||
void dumpKernel(const std::string &name, const std::string &src);
|
||||
void logApiCall(const char *function, bool enter, int32_t errorCode);
|
||||
void logAllocation(GraphicsAllocation const *graphicsAllocation, MemoryManager const *memoryManager);
|
||||
size_t getInput(const size_t *input, int32_t index);
|
||||
|
||||
MOCKABLE_VIRTUAL void writeToFile(std::string filename, const char *str, size_t length, std::ios_base::openmode mode);
|
||||
@@ -135,15 +134,15 @@ class FileLogger {
|
||||
|
||||
void logDebugString(bool enableLog, std::string_view debugString);
|
||||
|
||||
const char *getLogFileName() {
|
||||
return logFileName.c_str();
|
||||
}
|
||||
const char *getLogFileName() { return logFileName.c_str(); }
|
||||
std::string getLogFileNameString() { return logFileName; }
|
||||
|
||||
void setLogFileName(std::string filename) {
|
||||
logFileName = std::move(filename);
|
||||
}
|
||||
void setLogFileName(std::string filename) { logFileName = std::move(filename); }
|
||||
|
||||
bool peekLogApiCalls() { return logApiCalls; }
|
||||
bool shouldLogAllocationType() { return logAllocationType; }
|
||||
bool shouldLogAllocationToStdout() { return logAllocationStdout; }
|
||||
bool shouldLogAllocationMemoryPool() { return logAllocationMemoryPool; }
|
||||
|
||||
protected:
|
||||
std::mutex mutex;
|
||||
|
||||
70
shared/source/utilities/logger_neo_only.h
Normal file
70
shared/source/utilities/logger_neo_only.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/execution_environment/execution_environment.h"
|
||||
#include "shared/source/execution_environment/root_device_environment.h"
|
||||
#include "shared/source/memory_manager/graphics_allocation.h"
|
||||
#include "shared/source/memory_manager/memory_manager.h"
|
||||
#include "shared/source/utilities/logger.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
/* Should not be used outside of NEO (e.g. with ocloc) because of dependencies towards other NEO structures */
|
||||
namespace NEO {
|
||||
|
||||
template <DebugFunctionalityLevel level>
|
||||
void logAllocation(FileLogger<level> &logger, GraphicsAllocation const *graphicsAllocation, MemoryManager const *memoryManager) {
|
||||
if (logger.shouldLogAllocationType()) {
|
||||
printDebugString(true, stdout, "Created Graphics Allocation of type %s\n", getAllocationTypeString(graphicsAllocation));
|
||||
}
|
||||
|
||||
if (!logger.enabled() && !logger.shouldLogAllocationToStdout()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (logger.shouldLogAllocationMemoryPool() || logger.shouldLogAllocationType()) {
|
||||
std::stringstream ss;
|
||||
std::thread::id thisThread = std::this_thread::get_id();
|
||||
|
||||
ss << " ThreadID: " << thisThread;
|
||||
ss << " Type: " << getAllocationTypeString(graphicsAllocation);
|
||||
ss << " Pool: " << getMemoryPoolString(graphicsAllocation);
|
||||
ss << " Root index: " << graphicsAllocation->getRootDeviceIndex();
|
||||
ss << " Size: " << graphicsAllocation->getUnderlyingBufferSize();
|
||||
ss << " GPU VA: 0x" << std::hex << graphicsAllocation->getGpuAddress() << " - 0x" << std::hex << graphicsAllocation->getGpuAddress() + graphicsAllocation->getUnderlyingBufferSize() - 1;
|
||||
|
||||
ss << graphicsAllocation->getAllocationInfoString();
|
||||
|
||||
if (memoryManager) {
|
||||
auto *rootDeviceEnvironment{[graphicsAllocation, memoryManager]() {
|
||||
auto &rootDeviceEnvironments{memoryManager->peekExecutionEnvironment().rootDeviceEnvironments};
|
||||
auto indexOfAllocation = graphicsAllocation->getRootDeviceIndex();
|
||||
return (indexOfAllocation < rootDeviceEnvironments.size()) ? rootDeviceEnvironments[indexOfAllocation].get() : nullptr;
|
||||
}()};
|
||||
if (rootDeviceEnvironment) {
|
||||
ss << graphicsAllocation->getPatIndexInfoString(rootDeviceEnvironment->getProductHelper());
|
||||
}
|
||||
|
||||
ss << " Total sys mem allocated: " << std::dec << memoryManager->getUsedSystemMemorySize();
|
||||
ss << " Total lmem allocated: " << std::dec << memoryManager->getUsedLocalMemorySize(graphicsAllocation->getRootDeviceIndex());
|
||||
}
|
||||
|
||||
ss << std::endl;
|
||||
auto str = ss.str();
|
||||
if (logger.shouldLogAllocationToStdout()) {
|
||||
printf("%s", str.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (logger.enabled()) {
|
||||
logger.writeToFile(logger.getLogFileNameString(), str.c_str(), str.size(), std::ios::app);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
Reference in New Issue
Block a user