Fix dumping of cl_cache

- change creatOsReader and constructor of RegistryReader
- move body of constructors of RegistryReader from .h to .cpp

Change-Id: I57cbf51a57cb1cb7f9cd2473af766a79cf2035d2
This commit is contained in:
Katarzyna Cencelewska
2018-11-30 11:51:49 +01:00
committed by sys_ocldev
parent fe228ea5f7
commit a99939b08f
4 changed files with 16 additions and 17 deletions

View File

@@ -53,8 +53,9 @@ const std::string BinaryCache::getCachedFileName(const HardwareInfo &hwInfo, con
}
BinaryCache::BinaryCache() {
std::unique_ptr<SettingsReader> settingsReader(SettingsReader::createOsReader(CL_CACHE_LOCATION));
clCacheLocation = settingsReader->getSetting(settingsReader->appSpecificLocation("cl_cache_dir"), static_cast<std::string>(CL_CACHE_LOCATION));
std::string keyName = "cl_cache_dir";
std::unique_ptr<SettingsReader> settingsReader(SettingsReader::createOsReader(keyName));
clCacheLocation = settingsReader->getSetting(settingsReader->appSpecificLocation(keyName), static_cast<std::string>(CL_CACHE_LOCATION));
};
BinaryCache::~BinaryCache(){};
@@ -64,7 +65,6 @@ bool BinaryCache::cacheBinary(const std::string kernelFileHash, const char *pBin
return false;
}
std::string filePath = clCacheLocation + PATH_SEPARATOR + kernelFileHash + ".cl_cache";
std::lock_guard<std::mutex> lock(cacheAccessMtx);
if (writeDataToFile(
filePath.c_str(),

View File

@@ -17,7 +17,15 @@ SettingsReader *SettingsReader::createOsReader(bool userScope) {
return new RegistryReader(userScope);
}
SettingsReader *SettingsReader::createOsReader(const std::string &regKey) {
return new RegistryReader(regKey);
return new RegistryReader("Software\\Intel\\IGFX\\OCL\\" + regKey);
}
RegistryReader::RegistryReader(bool userScope) {
igdrclHkeyType = userScope ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
setUpProcessName();
}
RegistryReader::RegistryReader(const std::string &regKey) : registryReadRootKey(regKey) {
setUpProcessName();
}
void RegistryReader::setUpProcessName() {
char buff[MAX_PATH];
@@ -75,7 +83,6 @@ std::string RegistryReader::getSetting(const char *settingName, const std::strin
0,
KEY_READ,
&Key);
if (ERROR_SUCCESS == success) {
DWORD regType = REG_NONE;
DWORD regSize = 0;
@@ -86,7 +93,6 @@ std::string RegistryReader::getSetting(const char *settingName, const std::strin
&regType,
NULL,
&regSize);
if (success == ERROR_SUCCESS && regType == REG_SZ) {
char *regData = new char[regSize];
success = RegQueryValueExA(Key,

View File

@@ -19,14 +19,8 @@ class RegistryReader : public SettingsReader {
int32_t getSetting(const char *settingName, int32_t defaultValue) override;
bool getSetting(const char *settingName, bool defaultValue) override;
std::string getSetting(const char *settingName, const std::string &value) override;
RegistryReader(bool userScope) {
igdrclHkeyType = userScope ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
setUpProcessName();
}
RegistryReader(std::string regKey) {
registryReadRootKey.append(std::string(1, PATH_SEPARATOR)).append(regKey);
setUpProcessName();
}
RegistryReader(bool userScope);
RegistryReader(const std::string &regKey);
const char *appSpecificLocation(const std::string &name) override;
protected:

View File

@@ -55,8 +55,7 @@ TEST_F(RegistryReaderTest, givenRegistryReaderWhenRegKeyNotExistThenReturnDefaul
}
TEST_F(RegistryReaderTest, givenRegistryReaderWhenItIsCreatedWithRegKeySpecifiedThenRegKeyIsInitializedAccordingly) {
std::string regKey = "regKey";
std::string defaultKey = "Software\\Intel\\IGFX\\OCL";
std::string regKey = "Software\\Intel\\IGFX\\OCL\\regKey";
TestedRegistryReader registryReader(regKey);
EXPECT_STREQ((defaultKey + "\\" + regKey).c_str(), registryReader.getRegKey());
EXPECT_STREQ(regKey.c_str(), registryReader.getRegKey());
}