From 9dfa38f1e791c20e2d09ee9aa6798f5f57d149b9 Mon Sep 17 00:00:00 2001 From: XMRig Date: Tue, 29 Oct 2019 00:42:49 +0700 Subject: [PATCH] Added command line options --cuda and --cuda-loader. --- README.md | 7 ++++++- src/base/kernel/interfaces/IConfig.h | 2 ++ src/config.json | 6 +++++- src/core/config/ConfigTransform.cpp | 12 ++++++++++++ src/core/config/Config_default.h | 4 ++++ src/core/config/Config_platform.h | 4 ++++ src/core/config/usage.h | 8 +++++++- 7 files changed, 40 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e520a505..cffb28c7 100644 --- a/README.md +++ b/README.md @@ -77,11 +77,16 @@ OpenCL backend: --opencl enable OpenCL mining backend --opencl-devices=N list of OpenCL devices to use --opencl-platform=N OpenCL platform index or name - --opencl-loader=N path to OpenCL-ICD-Loader (OpenCL.dll or libOpenCL.so) + --opencl-loader=PATH path to OpenCL-ICD-Loader (OpenCL.dll or libOpenCL.so) --opencl-no-cache disable OpenCL cache --print-platforms print available OpenCL platforms and exit +CUDA backend: + --cuda enable CUDA mining backend + --cuda-loader=PATH path to CUDA plugin (xmrig-cuda.dll or libxmrig-cuda.so) + Logging: + -S, --syslog use system log for output messages -l, --log-file=FILE log all output to a file --print-time=N print hashrate report every N seconds --no-color disable colored output diff --git a/src/base/kernel/interfaces/IConfig.h b/src/base/kernel/interfaces/IConfig.h index 9f8d9618..ccee47c6 100644 --- a/src/base/kernel/interfaces/IConfig.h +++ b/src/base/kernel/interfaces/IConfig.h @@ -134,6 +134,8 @@ public: CudaLaunchKey = 1204, CudaAffinityKey = 1205, CudaMaxUsageKey = 1206, + CudaKey = 1207, + CudaLoaderKey = 1208 }; virtual ~IConfig() = default; diff --git a/src/config.json b/src/config.json index cb027a27..9c6d459e 100644 --- a/src/config.json +++ b/src/config.json @@ -38,6 +38,10 @@ "cn/0": false, "cn-lite/0": false }, + "cuda": { + "enabled": false, + "loader": null, + }, "donate-level": 5, "donate-over-proxy": 1, "log-file": null, @@ -64,4 +68,4 @@ "syslog": false, "user-agent": null, "watch": true -} \ No newline at end of file +} diff --git a/src/core/config/ConfigTransform.cpp b/src/core/config/ConfigTransform.cpp index ad323212..51f594e8 100644 --- a/src/core/config/ConfigTransform.cpp +++ b/src/core/config/ConfigTransform.cpp @@ -47,6 +47,10 @@ static const char *kRandomX = "randomx"; static const char *kOcl = "opencl"; #endif +#ifdef XMRIG_FEATURE_CUDA +static const char *kCuda = "cuda"; +#endif + static inline uint64_t intensity(uint64_t av) { @@ -181,6 +185,14 @@ void xmrig::ConfigTransform::transform(rapidjson::Document &doc, int key, const return set(doc, kOcl, "platform", arg); # endif +# ifdef XMRIG_FEATURE_CUDA + case IConfig::CudaKey: /* --cuda */ + return set(doc, kCuda, "enabled", true); + + case IConfig::CudaLoaderKey: /* --cuda-loader */ + return set(doc, kCuda, "loader", arg); +# endif + default: break; } diff --git a/src/core/config/Config_default.h b/src/core/config/Config_default.h index 8a284758..e7d39299 100644 --- a/src/core/config/Config_default.h +++ b/src/core/config/Config_default.h @@ -72,6 +72,10 @@ R"===( "cn/0": false, "cn-lite/0": false }, + "cuda": { + "enabled": false, + "loader": null, + }, "donate-level": 5, "donate-over-proxy": 1, "log-file": null, diff --git a/src/core/config/Config_platform.h b/src/core/config/Config_platform.h index a61f1a91..371e58fa 100644 --- a/src/core/config/Config_platform.h +++ b/src/core/config/Config_platform.h @@ -103,6 +103,10 @@ static const option options[] = { { "opencl-platform", 1, nullptr, IConfig::OclPlatformKey }, { "opencl-loader", 1, nullptr, IConfig::OclLoaderKey }, { "opencl-no-cache", 0, nullptr, IConfig::OclCacheKey }, +# endif +# ifdef XMRIG_FEATURE_CUDA + { "cuda", 0, nullptr, IConfig::CudaKey }, + { "cuda-loader", 1, nullptr, IConfig::CudaLoaderKey }, # endif { nullptr, 0, nullptr, 0 } }; diff --git a/src/core/config/usage.h b/src/core/config/usage.h index f5928fe9..c95526f7 100644 --- a/src/core/config/usage.h +++ b/src/core/config/usage.h @@ -103,11 +103,17 @@ static inline const std::string &usage() u += " --opencl enable OpenCL mining backend\n"; u += " --opencl-devices=N list of OpenCL devices to use\n"; u += " --opencl-platform=N OpenCL platform index or name\n"; - u += " --opencl-loader=N path to OpenCL-ICD-Loader (OpenCL.dll or libOpenCL.so)\n"; + u += " --opencl-loader=PATH path to OpenCL-ICD-Loader (OpenCL.dll or libOpenCL.so)\n"; u += " --opencl-no-cache disable OpenCL cache\n"; u += " --print-platforms print available OpenCL platforms and exit\n"; # endif +# ifdef XMRIG_FEATURE_CUDA + u += "\nCUDA backend:\n"; + u += " --cuda enable CUDA mining backend\n"; + u += " --cuda-loader=PATH path to CUDA plugin (xmrig-cuda.dll or libxmrig-cuda.so)\n"; +# endif + u += "\nLogging:\n"; # ifdef HAVE_SYSLOG_H