mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-09 22:43:00 +08:00
feature: Add debug/release variable prefixes
Resolves: NEO-6357 Signed-off-by: John Falkowski <john.falkowski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
6fca8ee195
commit
ec95d9314a
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "shared/source/os_interface/windows/debug_registry_reader.h"
|
||||
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/helpers/api_specific_config.h"
|
||||
#include "shared/source/os_interface/windows/sys_calls.h"
|
||||
#include "shared/source/os_interface/windows/windows_wrapper.h"
|
||||
#include "shared/source/utilities/debug_settings_reader.h"
|
||||
@@ -43,19 +44,26 @@ const char *RegistryReader::appSpecificLocation(const std::string &name) {
|
||||
return name.c_str();
|
||||
}
|
||||
|
||||
bool RegistryReader::getSetting(const char *settingName, bool defaultValue, DebugVarPrefix &type) {
|
||||
return getSetting(settingName, static_cast<int32_t>(defaultValue), type) ? true : false;
|
||||
}
|
||||
|
||||
bool RegistryReader::getSetting(const char *settingName, bool defaultValue) {
|
||||
return getSetting(settingName, static_cast<int32_t>(defaultValue)) ? true : false;
|
||||
}
|
||||
|
||||
int32_t RegistryReader::getSetting(const char *settingName, int32_t defaultValue, DebugVarPrefix &type) {
|
||||
return static_cast<int32_t>(getSetting(settingName, static_cast<int64_t>(defaultValue), type));
|
||||
}
|
||||
|
||||
int32_t RegistryReader::getSetting(const char *settingName, int32_t defaultValue) {
|
||||
return static_cast<int32_t>(getSetting(settingName, static_cast<int64_t>(defaultValue)));
|
||||
}
|
||||
|
||||
int64_t RegistryReader::getSetting(const char *settingName, int64_t defaultValue) {
|
||||
bool RegistryReader::getSettingIntCommon(const char *settingName, int64_t &value) {
|
||||
HKEY Key{};
|
||||
int64_t value = defaultValue;
|
||||
DWORD success = ERROR_SUCCESS;
|
||||
bool readSettingFromEnv = true;
|
||||
bool retVal = false;
|
||||
|
||||
success = SysCalls::regOpenKeyExA(hkeyType,
|
||||
registryReadRootKey.c_str(),
|
||||
@@ -75,11 +83,44 @@ int64_t RegistryReader::getSetting(const char *settingName, int64_t defaultValue
|
||||
&size);
|
||||
if (ERROR_SUCCESS == success) {
|
||||
value = regData;
|
||||
readSettingFromEnv = false;
|
||||
retVal = true;
|
||||
}
|
||||
RegCloseKey(Key);
|
||||
}
|
||||
if (readSettingFromEnv) {
|
||||
return retVal;
|
||||
}
|
||||
|
||||
int64_t RegistryReader::getSetting(const char *settingName, int64_t defaultValue, DebugVarPrefix &type) {
|
||||
int64_t value = defaultValue;
|
||||
|
||||
if (!(getSettingIntCommon(settingName, value))) {
|
||||
char *envValue;
|
||||
|
||||
const std::vector<const char *> prefixString = ApiSpecificConfig::getPrefixStrings();
|
||||
const std::vector<DebugVarPrefix> prefixType = ApiSpecificConfig::getPrefixTypes();
|
||||
|
||||
char neoFinal[MAX_NEO_KEY_LENGTH];
|
||||
uint32_t i = 0;
|
||||
for (const auto &prefix : prefixString) {
|
||||
strcpy_s(neoFinal, strlen(prefix) + 1, prefix);
|
||||
strcpy_s(neoFinal + strlen(prefix), strlen(settingName) + 1, settingName);
|
||||
envValue = getenv(neoFinal);
|
||||
if (envValue) {
|
||||
value = atoll(envValue);
|
||||
type = prefixType[i];
|
||||
return value;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
type = DebugVarPrefix::None;
|
||||
return value;
|
||||
}
|
||||
|
||||
int64_t RegistryReader::getSetting(const char *settingName, int64_t defaultValue) {
|
||||
int64_t value = defaultValue;
|
||||
|
||||
if (!(getSettingIntCommon(settingName, value))) {
|
||||
const char *envValue = getenv(settingName);
|
||||
if (envValue) {
|
||||
value = atoll(envValue);
|
||||
@@ -89,11 +130,10 @@ int64_t RegistryReader::getSetting(const char *settingName, int64_t defaultValue
|
||||
return value;
|
||||
}
|
||||
|
||||
std::string RegistryReader::getSetting(const char *settingName, const std::string &value) {
|
||||
bool RegistryReader::getSettingStringCommon(const char *settingName, std::string &keyValue) {
|
||||
HKEY Key{};
|
||||
DWORD success = ERROR_SUCCESS;
|
||||
std::string keyValue = value;
|
||||
bool readSettingFromEnv = true;
|
||||
bool retVal = false;
|
||||
|
||||
success = SysCalls::regOpenKeyExA(hkeyType,
|
||||
registryReadRootKey.c_str(),
|
||||
@@ -121,7 +161,7 @@ std::string RegistryReader::getSetting(const char *settingName, const std::strin
|
||||
®Size);
|
||||
if (success == ERROR_SUCCESS) {
|
||||
keyValue.assign(regData.get());
|
||||
readSettingFromEnv = false;
|
||||
retVal = true;
|
||||
}
|
||||
} else if (regType == REG_BINARY) {
|
||||
size_t charCount = regSize / sizeof(wchar_t);
|
||||
@@ -140,14 +180,46 @@ std::string RegistryReader::getSetting(const char *settingName, const std::strin
|
||||
convertedData.get()[charCount] = 0;
|
||||
|
||||
keyValue.assign(convertedData.get());
|
||||
readSettingFromEnv = false;
|
||||
retVal = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
RegCloseKey(Key);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
if (readSettingFromEnv) {
|
||||
std::string RegistryReader::getSetting(const char *settingName, const std::string &value, DebugVarPrefix &type) {
|
||||
std::string keyValue = value;
|
||||
|
||||
if (!(getSettingStringCommon(settingName, keyValue))) {
|
||||
char *envValue;
|
||||
|
||||
const std::vector<const char *> prefixString = ApiSpecificConfig::getPrefixStrings();
|
||||
const std::vector<DebugVarPrefix> prefixType = ApiSpecificConfig::getPrefixTypes();
|
||||
|
||||
char neoFinal[MAX_NEO_KEY_LENGTH];
|
||||
uint32_t i = 0;
|
||||
for (const auto &prefix : prefixString) {
|
||||
strcpy_s(neoFinal, strlen(prefix) + 1, prefix);
|
||||
strcpy_s(neoFinal + strlen(prefix), strlen(settingName) + 1, settingName);
|
||||
envValue = strcmp(processName.c_str(), neoFinal) ? getenv(neoFinal) : getenv("cl_cache_dir");
|
||||
if (envValue) {
|
||||
keyValue.assign(envValue);
|
||||
type = prefixType[i];
|
||||
return keyValue;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
type = DebugVarPrefix::None;
|
||||
return keyValue;
|
||||
}
|
||||
|
||||
std::string RegistryReader::getSetting(const char *settingName, const std::string &value) {
|
||||
std::string keyValue = value;
|
||||
|
||||
if (!(getSettingStringCommon(settingName, keyValue))) {
|
||||
const char *envValue = strcmp(processName.c_str(), settingName) ? getenv(settingName) : getenv("cl_cache_dir");
|
||||
if (envValue) {
|
||||
keyValue.assign(envValue);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2022 Intel Corporation
|
||||
* Copyright (C) 2019-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -15,13 +15,22 @@
|
||||
#include <string>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
enum class DebugVarPrefix : uint8_t;
|
||||
|
||||
class RegistryReader : public SettingsReader {
|
||||
public:
|
||||
RegistryReader() = delete;
|
||||
RegistryReader(bool userScope, const std::string ®Key);
|
||||
bool getSettingIntCommon(const char *settingName, int64_t &value);
|
||||
bool getSettingStringCommon(const char *settingName, std::string &keyValue);
|
||||
int32_t getSetting(const char *settingName, int32_t defaultValue, DebugVarPrefix &type) override;
|
||||
int32_t getSetting(const char *settingName, int32_t defaultValue) override;
|
||||
int64_t getSetting(const char *settingName, int64_t defaultValue, DebugVarPrefix &type) override;
|
||||
int64_t getSetting(const char *settingName, int64_t defaultValue) override;
|
||||
bool getSetting(const char *settingName, bool defaultValue, DebugVarPrefix &type) override;
|
||||
bool getSetting(const char *settingName, bool defaultValue) override;
|
||||
std::string getSetting(const char *settingName, const std::string &value, DebugVarPrefix &type) override;
|
||||
std::string getSetting(const char *settingName, const std::string &value) override;
|
||||
const char *appSpecificLocation(const std::string &name) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user