2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2022-05-16 22:06:56 +08:00
|
|
|
* Copyright (C) 2018-2022 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "debug_settings_manager.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2020-08-20 18:10:51 +08:00
|
|
|
#include "shared/source/debug_settings/debug_variables_helper.h"
|
2020-02-24 05:44:01 +08: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 07:45:38 +08:00
|
|
|
|
|
|
|
#include <cstdio>
|
2022-05-18 03:04:23 +08:00
|
|
|
#include <fstream>
|
2020-03-27 14:47:16 +08:00
|
|
|
#include <iostream>
|
2017-12-21 07:45:38 +08:00
|
|
|
#include <sstream>
|
|
|
|
|
2019-04-01 17:25:47 +08:00
|
|
|
namespace std {
|
2022-05-16 22:06:56 +08:00
|
|
|
static std::string to_string(const std::string &arg) { // NOLINT(readability-identifier-naming)
|
2019-04-01 17:25:47 +08:00
|
|
|
return arg;
|
|
|
|
}
|
|
|
|
} // namespace std
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
template <DebugFunctionalityLevel DebugLevel>
|
2019-12-13 23:48:57 +08:00
|
|
|
DebugSettingsManager<DebugLevel>::DebugSettingsManager(const char *registryPath) {
|
2020-06-15 17:16:46 +08:00
|
|
|
readerImpl = SettingsReaderCreator::create(std::string(registryPath));
|
|
|
|
injectSettingsFromReader();
|
|
|
|
dumpFlags();
|
2019-01-19 08:40:42 +08:00
|
|
|
translateDebugSettings(flags);
|
2020-04-22 16:24:00 +08:00
|
|
|
|
|
|
|
while (isLoopAtDriverInitEnabled())
|
|
|
|
;
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <DebugFunctionalityLevel DebugLevel>
|
2020-07-30 18:28:19 +08:00
|
|
|
DebugSettingsManager<DebugLevel>::~DebugSettingsManager() {
|
|
|
|
readerImpl.reset();
|
|
|
|
};
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-10-04 18:44:49 +08: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 17:25:47 +08: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 18:45:16 +08:00
|
|
|
const auto variableStringValue = std::to_string(variableValue);
|
2020-09-25 17:24:15 +08:00
|
|
|
PRINT_DEBUG_STRING(true, stdout, "Non-default value of debug variable: %s = %s\n", variableName, variableStringValue.c_str());
|
2019-04-01 17:25:47 +08: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());
|
|
|
|
|
2021-01-11 04:36:01 +08:00
|
|
|
#define DECLARE_DEBUG_VARIABLE(dataType, variableName, defaultValue, description) \
|
|
|
|
settingsDumpFile << getNonReleaseKeyName(#variableName) << " = " << flags.variableName.get() << '\n'; \
|
|
|
|
dumpNonDefaultFlag<dataType>(getNonReleaseKeyName(#variableName), flags.variableName.get(), defaultValue);
|
|
|
|
|
2020-08-20 18:10:51 +08:00
|
|
|
if (registryReadAvailable() || isDebugKeysReadEnabled()) {
|
2019-04-01 17:25:47 +08:00
|
|
|
#include "debug_variables.inl"
|
2020-06-15 17:16:46 +08:00
|
|
|
}
|
2021-01-11 04:36:01 +08:00
|
|
|
#undef DECLARE_DEBUG_VARIABLE
|
|
|
|
|
|
|
|
#define DECLARE_DEBUG_VARIABLE(dataType, variableName, defaultValue, description) \
|
|
|
|
settingsDumpFile << #variableName << " = " << flags.variableName.get() << '\n'; \
|
|
|
|
dumpNonDefaultFlag<dataType>(#variableName, flags.variableName.get(), defaultValue);
|
2020-06-15 17:16:46 +08:00
|
|
|
#include "release_variables.inl"
|
2019-04-01 17:25:47 +08:00
|
|
|
#undef DECLARE_DEBUG_VARIABLE
|
2019-04-05 14:51:01 +08:00
|
|
|
}
|
2019-04-01 17:25:47 +08:00
|
|
|
|
2018-12-13 20:46:32 +08:00
|
|
|
template <DebugFunctionalityLevel DebugLevel>
|
|
|
|
void DebugSettingsManager<DebugLevel>::injectSettingsFromReader() {
|
|
|
|
#undef DECLARE_DEBUG_VARIABLE
|
2021-01-11 04:36:01 +08:00
|
|
|
#define DECLARE_DEBUG_VARIABLE(dataType, variableName, defaultValue, description) \
|
|
|
|
{ \
|
|
|
|
dataType tempData = readerImpl->getSetting(getNonReleaseKeyName(#variableName), flags.variableName.get()); \
|
|
|
|
flags.variableName.set(tempData); \
|
2018-12-13 20:46:32 +08:00
|
|
|
}
|
2020-06-15 17:16:46 +08:00
|
|
|
|
2020-08-20 18:10:51 +08:00
|
|
|
if (registryReadAvailable() || isDebugKeysReadEnabled()) {
|
2018-12-13 20:46:32 +08:00
|
|
|
#include "debug_variables.inl"
|
2020-06-15 17:16:46 +08:00
|
|
|
}
|
2021-01-11 04:36:01 +08:00
|
|
|
|
|
|
|
#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 17:16:46 +08:00
|
|
|
#include "release_variables.inl"
|
2019-01-19 08:40:42 +08:00
|
|
|
#undef DECLARE_DEBUG_VARIABLE
|
2018-12-13 20:46:32 +08:00
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
template class DebugSettingsManager<DebugFunctionalityLevel::None>;
|
|
|
|
template class DebugSettingsManager<DebugFunctionalityLevel::Full>;
|
|
|
|
template class DebugSettingsManager<DebugFunctionalityLevel::RegKeys>;
|
2019-03-26 18:59:46 +08:00
|
|
|
}; // namespace NEO
|