2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2020-02-22 22:21:06 +01:00
|
|
|
* Copyright (C) 2017-2020 Intel Corporation
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
2018-09-18 09:11:08 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "debug_settings_manager.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/debug_settings/definitions/translate_debug_settings.h"
|
|
|
|
|
#include "shared/source/helpers/debug_helpers.h"
|
|
|
|
|
#include "shared/source/helpers/ptr_math.h"
|
|
|
|
|
#include "shared/source/helpers/string.h"
|
|
|
|
|
#include "shared/source/utilities/debug_settings_reader_creator.h"
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
#include <cstdio>
|
2020-03-27 07:47:16 +01:00
|
|
|
#include <iostream>
|
2017-12-21 00:45:38 +01:00
|
|
|
#include <sstream>
|
|
|
|
|
|
2019-04-01 11:25:47 +02:00
|
|
|
namespace std {
|
|
|
|
|
static std::string to_string(const std::string &arg) {
|
|
|
|
|
return arg;
|
|
|
|
|
}
|
|
|
|
|
} // namespace std
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
template <DebugFunctionalityLevel DebugLevel>
|
2019-12-13 16:48:57 +01:00
|
|
|
DebugSettingsManager<DebugLevel>::DebugSettingsManager(const char *registryPath) {
|
2020-06-15 11:16:46 +02:00
|
|
|
readerImpl = SettingsReaderCreator::create(std::string(registryPath));
|
|
|
|
|
injectSettingsFromReader();
|
|
|
|
|
dumpFlags();
|
2019-01-19 01:40:42 +01:00
|
|
|
translateDebugSettings(flags);
|
2020-04-22 10:24:00 +02:00
|
|
|
|
|
|
|
|
while (isLoopAtDriverInitEnabled())
|
|
|
|
|
;
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <DebugFunctionalityLevel DebugLevel>
|
2018-12-13 13:46:32 +01:00
|
|
|
DebugSettingsManager<DebugLevel>::~DebugSettingsManager() = default;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-10-04 12:44:49 +02:00
|
|
|
template <DebugFunctionalityLevel DebugLevel>
|
|
|
|
|
void DebugSettingsManager<DebugLevel>::getHardwareInfoOverride(std::string &hwInfoConfig) {
|
|
|
|
|
std::string str = flags.HardwareInfoOverride.get();
|
|
|
|
|
if (str[0] == '\"') {
|
|
|
|
|
str.pop_back();
|
|
|
|
|
hwInfoConfig = str.substr(1, std::string::npos);
|
|
|
|
|
} else {
|
|
|
|
|
hwInfoConfig = str;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-01 11:25:47 +02:00
|
|
|
template <DebugFunctionalityLevel DebugLevel>
|
|
|
|
|
template <typename DataType>
|
|
|
|
|
void DebugSettingsManager<DebugLevel>::dumpNonDefaultFlag(const char *variableName, const DataType &variableValue, const DataType &defaultValue) {
|
|
|
|
|
if (variableValue != defaultValue) {
|
2019-04-08 12:45:16 +02:00
|
|
|
const auto variableStringValue = std::to_string(variableValue);
|
2019-07-04 14:13:25 +02:00
|
|
|
printDebugString(true, stdout, "Non-default value of debug variable: %s = %s\n", variableName, variableStringValue.c_str());
|
2019-04-01 11:25:47 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <DebugFunctionalityLevel DebugLevel>
|
|
|
|
|
void DebugSettingsManager<DebugLevel>::dumpFlags() const {
|
|
|
|
|
if (flags.PrintDebugSettings.get() == false) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::ofstream settingsDumpFile{settingsDumpFileName, std::ios::out};
|
|
|
|
|
DEBUG_BREAK_IF(!settingsDumpFile.good());
|
|
|
|
|
|
|
|
|
|
#define DECLARE_DEBUG_VARIABLE(dataType, variableName, defaultValue, description) \
|
|
|
|
|
settingsDumpFile << #variableName << " = " << flags.variableName.get() << '\n'; \
|
2020-03-27 07:47:16 +01:00
|
|
|
dumpNonDefaultFlag<dataType>(#variableName, flags.variableName.get(), defaultValue);
|
2020-06-15 11:16:46 +02:00
|
|
|
if (registryReadAvailable()) {
|
2019-04-01 11:25:47 +02:00
|
|
|
#include "debug_variables.inl"
|
2020-06-15 11:16:46 +02:00
|
|
|
}
|
|
|
|
|
#include "release_variables.inl"
|
2019-04-01 11:25:47 +02:00
|
|
|
#undef DECLARE_DEBUG_VARIABLE
|
2019-04-05 08:51:01 +02:00
|
|
|
}
|
2019-04-01 11:25:47 +02:00
|
|
|
|
2018-12-13 13:46:32 +01:00
|
|
|
template <DebugFunctionalityLevel DebugLevel>
|
|
|
|
|
void DebugSettingsManager<DebugLevel>::injectSettingsFromReader() {
|
|
|
|
|
#undef DECLARE_DEBUG_VARIABLE
|
|
|
|
|
#define DECLARE_DEBUG_VARIABLE(dataType, variableName, defaultValue, description) \
|
|
|
|
|
{ \
|
|
|
|
|
dataType tempData = readerImpl->getSetting(#variableName, flags.variableName.get()); \
|
|
|
|
|
flags.variableName.set(tempData); \
|
|
|
|
|
}
|
2020-06-15 11:16:46 +02:00
|
|
|
|
|
|
|
|
if (registryReadAvailable()) {
|
2018-12-13 13:46:32 +01:00
|
|
|
#include "debug_variables.inl"
|
2020-06-15 11:16:46 +02:00
|
|
|
}
|
|
|
|
|
#include "release_variables.inl"
|
2019-01-19 01:40:42 +01:00
|
|
|
#undef DECLARE_DEBUG_VARIABLE
|
2018-12-13 13:46:32 +01:00
|
|
|
}
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
template class DebugSettingsManager<DebugFunctionalityLevel::None>;
|
|
|
|
|
template class DebugSettingsManager<DebugFunctionalityLevel::Full>;
|
|
|
|
|
template class DebugSettingsManager<DebugFunctionalityLevel::RegKeys>;
|
2019-03-26 11:59:46 +01:00
|
|
|
}; // namespace NEO
|