Skip to content
Snippets Groups Projects
Unverified Commit bf977fad authored by fireice-uk's avatar fireice-uk Committed by GitHub
Browse files

Merge pull request #2332 from psychocrypt/topic-amdCacheDirOption

add cli option `amdCacheDir`
parents 203a1c06 f33d2e56
No related branches found
No related tags found
No related merge requests found
......@@ -48,25 +48,12 @@
#ifdef _WIN32
#include <windows.h>
#include <Shlobj.h>
static inline void create_directory(std::string dirname)
{
_mkdir(dirname.data());
}
static inline std::string get_home()
{
char path[MAX_PATH + 1];
// get folder "appdata\local"
if (SHGetSpecialFolderPathA(HWND_DESKTOP, path, CSIDL_LOCAL_APPDATA, FALSE))
{
return path;
}
else
return ".";
}
static inline void port_sleep(size_t sec)
{
Sleep(sec * 1000);
......@@ -80,16 +67,6 @@ static inline void create_directory(std::string dirname)
mkdir(dirname.data(), 0744);
}
static inline std::string get_home()
{
const char *home = ".";
if ((home = getenv("HOME")) == nullptr)
home = getpwuid(getuid())->pw_dir;
return home;
}
static inline void port_sleep(size_t sec)
{
sleep(sec);
......@@ -339,7 +316,7 @@ size_t InitOpenCLGpu(cl_context opencl_ctx, GpuContext* ctx, const char* source_
isWindowsOs = 1;
#endif
options += " -DIS_WINDOWS_OS=" + std::to_string(isWindowsOs);
if(miner_algo == cryptonight_gpu)
options += " -cl-fp32-correctly-rounded-divide-sqrt";
......@@ -358,7 +335,9 @@ size_t InitOpenCLGpu(cl_context opencl_ctx, GpuContext* ctx, const char* source_
std::string hash_hex_str;
picosha2::hash256_hex_string(src_str, hash_hex_str);
std::string cache_file = get_home() + "/.openclcache/" + hash_hex_str + ".openclbin";
const std::string cache_dir = xmrstak::params::inst().rootAMDCacheDir;
std::string cache_file = cache_dir + hash_hex_str + ".openclbin";
std::ifstream clBinFile(cache_file, std::ofstream::in | std::ofstream::binary);
if(xmrstak::params::inst().AMDCache == false || !clBinFile.good())
{
......@@ -854,7 +833,8 @@ size_t InitOpenCL(GpuContext* ctx, size_t num_gpus, size_t platform_idx)
source_code = std::regex_replace(source_code, std::regex("XMRSTAK_INCLUDE_CN_GPU"), cryptonight_gpu);
// create a directory for the OpenCL compile cache
create_directory(get_home() + "/.openclcache");
const std::string cache_dir = xmrstak::params::inst().rootAMDCacheDir;
create_directory(cache_dir);
std::vector<std::shared_ptr<InterleaveData>> interleaveData(num_gpus, nullptr);
......
......@@ -84,6 +84,7 @@ void help()
cout<<" --noAMDCache disable the AMD(OpenCL) cache for precompiled binaries"<<endl;
cout<<" --openCLVendor VENDOR use OpenCL driver of VENDOR and devices [AMD,NVIDIA]"<<endl;
cout<<" default: AMD"<<endl;
cout<<" --amdCacheDir DIRECTORY directory to store AMD binary files"<<endl;
cout<<" --amd FILE AMD backend miner config file"<<endl;
#endif
#ifndef CONF_NO_CUDA
......@@ -502,6 +503,17 @@ int main(int argc, char *argv[])
}
params::inst().configFileAMD = argv[i];
}
else if(opName.compare("--amdCacheDir") == 0)
{
++i;
if( i >=argc )
{
printer::inst()->print_msg(L0, "No argument for parameter '--amdCacheDir' given");
win_exit();
return 1;
}
params::inst().rootAMDCacheDir = std::string(argv[i]) + "/";
}
else if(opName.compare("--nvidia") == 0)
{
++i;
......
#pragma once
#include <string>
#ifdef _WIN32
#include <WinSock2.h>
#include <Shlobj.h>
namespace
{
inline std::string get_home()
{
char path[MAX_PATH + 1];
// get folder "appdata\local"
if (SHGetSpecialFolderPathA(HWND_DESKTOP, path, CSIDL_LOCAL_APPDATA, FALSE))
{
return path;
}
else
return ".";
}
} // namespace anonymous
#else
#include <unistd.h>
#include <pwd.h>
#include <cstdlib>
namespace
{
inline std::string get_home()
{
const char *home = ".";
if ((home = getenv("HOME")) == nullptr)
home = getpwuid(getuid())->pw_dir;
return home;
}
} // namespace anonymous
#endif // _WIN32
#pragma once
#include "xmrstak/misc/environment.hpp"
#include "xmrstak/misc/home_dir.hpp"
#include <string>
......@@ -45,6 +46,7 @@ struct params
std::string configFile;
std::string configFilePools;
std::string configFileAMD;
std::string rootAMDCacheDir;
std::string configFileNVIDIA;
std::string configFileCPU;
......@@ -68,6 +70,7 @@ struct params
configFile("config.txt"),
configFilePools("pools.txt"),
configFileAMD("amd.txt"),
rootAMDCacheDir(get_home() + "/.openclcache/"),
configFileCPU("cpu.txt"),
configFileNVIDIA("nvidia.txt")
{}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment