Merge branch 'beta' into evo

This commit is contained in:
XMRig 2019-11-13 00:41:58 +07:00
commit 13d256e737
11 changed files with 62 additions and 26 deletions

View file

@ -74,7 +74,7 @@ API:
OpenCL backend: OpenCL backend:
--opencl enable OpenCL mining backend --opencl enable OpenCL mining backend
--opencl-devices=N list of OpenCL devices to use --opencl-devices=N comma separated list of OpenCL devices to use
--opencl-platform=N OpenCL platform index or name --opencl-platform=N OpenCL platform index or name
--opencl-loader=PATH 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 --opencl-no-cache disable OpenCL cache
@ -83,6 +83,7 @@ OpenCL backend:
CUDA backend: CUDA backend:
--cuda enable CUDA mining backend --cuda enable CUDA mining backend
--cuda-loader=PATH path to CUDA plugin (xmrig-cuda.dll or libxmrig-cuda.so) --cuda-loader=PATH path to CUDA plugin (xmrig-cuda.dll or libxmrig-cuda.so)
--cuda-devices=N comma separated list of CUDA devices to use
--no-nvml disable NVML (NVIDIA Management Library) support --no-nvml disable NVML (NVIDIA Management Library) support
Logging: Logging:

View file

@ -155,11 +155,14 @@ public:
return; return;
} }
devices = CudaLib::devices(cuda.bfactor(), cuda.bsleep(), cuda.devicesHint());
if (devices.empty()) {
return printDisabled(kLabel, RED_S " (no devices)");
}
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") WHITE_BOLD("%s") "/" WHITE_BOLD("%s") BLACK_BOLD("/%s"), kLabel, Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") WHITE_BOLD("%s") "/" WHITE_BOLD("%s") BLACK_BOLD("/%s"), kLabel,
CudaLib::version(runtimeVersion).c_str(), CudaLib::version(driverVersion).c_str(), CudaLib::pluginVersion()); CudaLib::version(runtimeVersion).c_str(), CudaLib::version(driverVersion).c_str(), CudaLib::pluginVersion());
devices = CudaLib::devices(cuda.bfactor(), cuda.bsleep());
# ifdef XMRIG_FEATURE_NVML # ifdef XMRIG_FEATURE_NVML
if (cuda.isNvmlEnabled()) { if (cuda.isNvmlEnabled()) {
if (NvmlLib::init(cuda.nvmlLoader())) { if (NvmlLib::init(cuda.nvmlLoader())) {
@ -172,7 +175,7 @@ public:
); );
} }
else { else {
printDisabled(kLabel, RED_S " (failed to load NVML)"); printDisabled(kNvmlLabel, RED_S " (failed to load NVML)");
} }
} }
else { else {

View file

@ -78,6 +78,16 @@ rapidjson::Value xmrig::CudaConfig::toJSON(rapidjson::Document &doc) const
std::vector<xmrig::CudaLaunchData> xmrig::CudaConfig::get(const Miner *miner, const Algorithm &algorithm, const std::vector<CudaDevice> &devices) const std::vector<xmrig::CudaLaunchData> xmrig::CudaConfig::get(const Miner *miner, const Algorithm &algorithm, const std::vector<CudaDevice> &devices) const
{ {
auto deviceIndex = [&devices](uint32_t index) -> int {
for (uint32_t i = 0; i < devices.size(); ++i) {
if (devices[i].index() == index) {
return i;
}
}
return -1;
};
std::vector<CudaLaunchData> out; std::vector<CudaLaunchData> out;
const auto &threads = m_threads.get(algorithm); const auto &threads = m_threads.get(algorithm);
@ -85,15 +95,16 @@ std::vector<xmrig::CudaLaunchData> xmrig::CudaConfig::get(const Miner *miner, co
return out; return out;
} }
out.reserve(threads.count() * 2); out.reserve(threads.count());
for (const auto &thread : threads.data()) { for (const auto &thread : threads.data()) {
if (thread.index() >= devices.size()) { const int index = deviceIndex(thread.index());
if (index == -1) {
LOG_INFO("%s" YELLOW(" skip non-existing device with index ") YELLOW_BOLD("%u"), cuda_tag(), thread.index()); LOG_INFO("%s" YELLOW(" skip non-existing device with index ") YELLOW_BOLD("%u"), cuda_tag(), thread.index());
continue; continue;
} }
out.emplace_back(miner, algorithm, thread, devices[thread.index()]); out.emplace_back(miner, algorithm, thread, devices[static_cast<size_t>(index)]);
} }
return out; return out;
@ -153,7 +164,7 @@ void xmrig::CudaConfig::generate()
return; return;
} }
const auto devices = CudaLib::devices(bfactor(), bsleep()); const auto devices = CudaLib::devices(bfactor(), bsleep(), m_devicesHint);
if (devices.empty()) { if (devices.empty()) {
return; return;
} }

View file

@ -43,16 +43,17 @@ public:
std::vector<CudaLaunchData> get(const Miner *miner, const Algorithm &algorithm, const std::vector<CudaDevice> &devices) const; std::vector<CudaLaunchData> get(const Miner *miner, const Algorithm &algorithm, const std::vector<CudaDevice> &devices) const;
void read(const rapidjson::Value &value); void read(const rapidjson::Value &value);
inline bool isEnabled() const { return m_enabled; } inline bool isEnabled() const { return m_enabled; }
inline bool isShouldSave() const { return m_shouldSave; } inline bool isShouldSave() const { return m_shouldSave; }
inline const String &loader() const { return m_loader; } inline const std::vector<uint32_t> &devicesHint() const { return m_devicesHint; }
inline const Threads<CudaThreads> &threads() const { return m_threads; } inline const String &loader() const { return m_loader; }
inline int32_t bfactor() const { return m_bfactor; } inline const Threads<CudaThreads> &threads() const { return m_threads; }
inline int32_t bsleep() const { return m_bsleep; } inline int32_t bfactor() const { return m_bfactor; }
inline int32_t bsleep() const { return m_bsleep; }
# ifdef XMRIG_FEATURE_NVML # ifdef XMRIG_FEATURE_NVML
inline bool isNvmlEnabled() const { return m_nvml; } inline bool isNvmlEnabled() const { return m_nvml; }
inline const String &nvmlLoader() const { return m_nvmlLoader; } inline const String &nvmlLoader() const { return m_nvmlLoader; }
# endif # endif
private: private:

View file

@ -209,7 +209,7 @@ std::string xmrig::CudaLib::version(uint32_t version)
} }
std::vector<xmrig::CudaDevice> xmrig::CudaLib::devices(int32_t bfactor, int32_t bsleep) noexcept std::vector<xmrig::CudaDevice> xmrig::CudaLib::devices(int32_t bfactor, int32_t bsleep, const std::vector<uint32_t> &hints) noexcept
{ {
const uint32_t count = deviceCount(); const uint32_t count = deviceCount();
if (!count) { if (!count) {
@ -219,10 +219,24 @@ std::vector<xmrig::CudaDevice> xmrig::CudaLib::devices(int32_t bfactor, int32_t
std::vector<CudaDevice> out; std::vector<CudaDevice> out;
out.reserve(count); out.reserve(count);
for (uint32_t i = 0; i < count; ++i) { if (hints.empty()) {
CudaDevice device(i, bfactor, bsleep); for (uint32_t i = 0; i < count; ++i) {
if (device.isValid()) { CudaDevice device(i, bfactor, bsleep);
out.emplace_back(std::move(device)); if (device.isValid()) {
out.emplace_back(std::move(device));
}
}
}
else {
for (const uint32_t i : hints) {
if (i >= count) {
continue;
}
CudaDevice device(i, bfactor, bsleep);
if (device.isValid()) {
out.emplace_back(std::move(device));
}
} }
} }

View file

@ -85,7 +85,7 @@ public:
static int32_t deviceInt(nvid_ctx *ctx, DeviceProperty property) noexcept; static int32_t deviceInt(nvid_ctx *ctx, DeviceProperty property) noexcept;
static nvid_ctx *alloc(uint32_t id, int32_t bfactor, int32_t bsleep) noexcept; static nvid_ctx *alloc(uint32_t id, int32_t bfactor, int32_t bsleep) noexcept;
static std::string version(uint32_t version); static std::string version(uint32_t version);
static std::vector<CudaDevice> devices(int32_t bfactor, int32_t bsleep) noexcept; static std::vector<CudaDevice> devices(int32_t bfactor, int32_t bsleep, const std::vector<uint32_t> &hints) noexcept;
static uint32_t deviceCount() noexcept; static uint32_t deviceCount() noexcept;
static uint32_t deviceUint(nvid_ctx *ctx, DeviceProperty property) noexcept; static uint32_t deviceUint(nvid_ctx *ctx, DeviceProperty property) noexcept;
static uint32_t driverVersion() noexcept; static uint32_t driverVersion() noexcept;

View file

@ -50,7 +50,7 @@ bool xmrig::Json::getBool(const rapidjson::Value &obj, const char *key, bool def
} }
const char *xmrig::Json::getString(const rapidjson::Value &obj, const char *key, const char *defaultValue) const char *xmrig::Json::getString(const rapidjson::Value &obj, const char *key, const char *defaultValue)
{ {
assert(obj.IsObject()); assert(obj.IsObject());

View file

@ -187,10 +187,14 @@ void xmrig::ConfigTransform::transform(rapidjson::Document &doc, int key, const
# ifdef XMRIG_FEATURE_CUDA # ifdef XMRIG_FEATURE_CUDA
case IConfig::CudaKey: /* --cuda */ case IConfig::CudaKey: /* --cuda */
return set(doc, kCuda, "enabled", true); return set(doc, kCuda, kEnabled, true);
case IConfig::CudaLoaderKey: /* --cuda-loader */ case IConfig::CudaLoaderKey: /* --cuda-loader */
return set(doc, kCuda, "loader", arg); return set(doc, kCuda, "loader", arg);
case IConfig::CudaDevicesKey: /* --cuda-devices */
set(doc, kCuda, kEnabled, true);
return set(doc, kCuda, "devices-hint", arg);
# endif # endif
# ifdef XMRIG_FEATURE_NVML # ifdef XMRIG_FEATURE_NVML

View file

@ -107,6 +107,7 @@ static const option options[] = {
# ifdef XMRIG_FEATURE_CUDA # ifdef XMRIG_FEATURE_CUDA
{ "cuda", 0, nullptr, IConfig::CudaKey }, { "cuda", 0, nullptr, IConfig::CudaKey },
{ "cuda-loader", 1, nullptr, IConfig::CudaLoaderKey }, { "cuda-loader", 1, nullptr, IConfig::CudaLoaderKey },
{ "cuda-devices", 1, nullptr, IConfig::CudaDevicesKey },
# endif # endif
# ifdef XMRIG_FEATURE_NVML # ifdef XMRIG_FEATURE_NVML
{ "no-nvml", 0, nullptr, IConfig::NvmlKey }, { "no-nvml", 0, nullptr, IConfig::NvmlKey },

View file

@ -101,7 +101,7 @@ static inline const std::string &usage()
# ifdef XMRIG_FEATURE_OPENCL # ifdef XMRIG_FEATURE_OPENCL
u += "\nOpenCL backend:\n"; u += "\nOpenCL backend:\n";
u += " --opencl enable OpenCL mining backend\n"; u += " --opencl enable OpenCL mining backend\n";
u += " --opencl-devices=N list of OpenCL devices to use\n"; u += " --opencl-devices=N comma separated list of OpenCL devices to use\n";
u += " --opencl-platform=N OpenCL platform index or name\n"; u += " --opencl-platform=N OpenCL platform index or name\n";
u += " --opencl-loader=PATH 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 += " --opencl-no-cache disable OpenCL cache\n";
@ -112,6 +112,7 @@ static inline const std::string &usage()
u += "\nCUDA backend:\n"; u += "\nCUDA backend:\n";
u += " --cuda enable CUDA mining 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"; u += " --cuda-loader=PATH path to CUDA plugin (xmrig-cuda.dll or libxmrig-cuda.so)\n";
u += " --cuda-devices=N comma separated list of CUDA devices to use\n";
# endif # endif
# ifdef XMRIG_FEATURE_NVML # ifdef XMRIG_FEATURE_NVML
u += " --no-nvml disable NVML (NVIDIA Management Library) support\n"; u += " --no-nvml disable NVML (NVIDIA Management Library) support\n";

View file

@ -28,7 +28,7 @@
#define APP_ID "xmrig" #define APP_ID "xmrig"
#define APP_NAME "XMRig" #define APP_NAME "XMRig"
#define APP_DESC "XMRig miner" #define APP_DESC "XMRig miner"
#define APP_VERSION "4.6.1-evo" #define APP_VERSION "4.6.1-beta"
#define APP_DOMAIN "xmrig.com" #define APP_DOMAIN "xmrig.com"
#define APP_SITE "www.xmrig.com" #define APP_SITE "www.xmrig.com"
#define APP_COPYRIGHT "Copyright (C) 2016-2019 xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2019 xmrig.com"