Added command line option --opencl-devices (hint mode)
This commit is contained in:
parent
3ee3d13f0f
commit
d6f0555771
5 changed files with 69 additions and 2 deletions
|
@ -30,12 +30,16 @@
|
|||
#include "rapidjson/document.h"
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
static const char *kAMD = "AMD";
|
||||
static const char *kCache = "cache";
|
||||
static const char *kCn = "cn";
|
||||
static const char *kCn2 = "cn/2";
|
||||
static const char *kDevicesHint = "devices-hint";
|
||||
static const char *kEnabled = "enabled";
|
||||
static const char *kINTEL = "INTEL";
|
||||
static const char *kLoader = "loader";
|
||||
|
@ -90,6 +94,22 @@ static size_t generate(const char *key, Threads<OclThreads> &threads, const Algo
|
|||
}
|
||||
|
||||
|
||||
static inline std::vector<OclDevice> filterDevices(const std::vector<OclDevice> &devices, const std::vector<uint32_t> &hints)
|
||||
{
|
||||
std::vector<OclDevice> out;
|
||||
out.reserve(std::min(devices.size(), hints.size()));
|
||||
|
||||
for (const auto &device : devices) {
|
||||
auto it = std::find(hints.begin(), hints.end(), device.index());
|
||||
if (it != hints.end()) {
|
||||
out.emplace_back(device);
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -214,6 +234,7 @@ void xmrig::OclConfig::read(const rapidjson::Value &value)
|
|||
m_loader = Json::getString(value, kLoader);
|
||||
|
||||
setPlatform(Json::getValue(value, kPlatform));
|
||||
setDevicesHint(Json::getString(value, kDevicesHint));
|
||||
|
||||
m_threads.read(value);
|
||||
|
||||
|
@ -234,7 +255,7 @@ void xmrig::OclConfig::read(const rapidjson::Value &value)
|
|||
|
||||
void xmrig::OclConfig::generate()
|
||||
{
|
||||
if (!isEnabled()) {
|
||||
if (!isEnabled() || m_threads.has("*")) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -242,7 +263,7 @@ void xmrig::OclConfig::generate()
|
|||
return;
|
||||
}
|
||||
|
||||
const auto devices = platform().devices();
|
||||
const auto devices = m_devicesHint.empty() ? platform().devices() : filterDevices(platform().devices(), m_devicesHint);
|
||||
if (devices.empty()) {
|
||||
return;
|
||||
}
|
||||
|
@ -287,6 +308,21 @@ void xmrig::OclConfig::generate()
|
|||
}
|
||||
|
||||
|
||||
void xmrig::OclConfig::setDevicesHint(const char *devicesHint)
|
||||
{
|
||||
if (devicesHint == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto indexes = String(devicesHint).split(',');
|
||||
m_devicesHint.reserve(indexes.size());
|
||||
|
||||
for (const auto &index : indexes) {
|
||||
m_devicesHint.push_back(strtoul(index, nullptr, 10));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void xmrig::OclConfig::setPlatform(const rapidjson::Value &platform)
|
||||
{
|
||||
if (platform.IsString()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue