mirror of
https://github.com/xmrig/xmrig.git
synced 2025-03-21 06:38:56 +00:00
Implemented OclLaunchData creation.
This commit is contained in:
parent
55e12fb34b
commit
797d90c4dd
7 changed files with 53 additions and 52 deletions
|
@ -263,7 +263,7 @@ void xmrig::CpuBackend::setJob(const Job &job)
|
||||||
const CpuConfig &cpu = d_ptr->controller->config()->cpu();
|
const CpuConfig &cpu = d_ptr->controller->config()->cpu();
|
||||||
|
|
||||||
std::vector<CpuLaunchData> threads = cpu.get(d_ptr->controller->miner(), job.algorithm());
|
std::vector<CpuLaunchData> threads = cpu.get(d_ptr->controller->miner(), job.algorithm());
|
||||||
if (d_ptr->threads.size() == threads.size() && std::equal(d_ptr->threads.begin(), d_ptr->threads.end(), threads.begin())) {
|
if (!d_ptr->threads.empty() && d_ptr->threads.size() == threads.size() && std::equal(d_ptr->threads.begin(), d_ptr->threads.end(), threads.begin())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,11 +271,9 @@ void xmrig::CpuBackend::setJob(const Job &job)
|
||||||
d_ptr->profileName = cpu.threads().profileName(job.algorithm());
|
d_ptr->profileName = cpu.threads().profileName(job.algorithm());
|
||||||
|
|
||||||
if (d_ptr->profileName.isNull() || threads.empty()) {
|
if (d_ptr->profileName.isNull() || threads.empty()) {
|
||||||
d_ptr->workers.stop();
|
LOG_WARN("%s " RED_BOLD("disabled") YELLOW(" (no suitable configuration found)"), tag);
|
||||||
|
|
||||||
LOG_WARN(YELLOW_BOLD_S "CPU disabled, no suitable configuration for algo %s", job.algorithm().shortName());
|
return stop();
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
d_ptr->threads = std::move(threads);
|
d_ptr->threads = std::move(threads);
|
||||||
|
@ -314,6 +312,10 @@ void xmrig::CpuBackend::start(IWorker *worker)
|
||||||
|
|
||||||
void xmrig::CpuBackend::stop()
|
void xmrig::CpuBackend::stop()
|
||||||
{
|
{
|
||||||
|
if (d_ptr->threads.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const uint64_t ts = Chrono::steadyMSecs();
|
const uint64_t ts = Chrono::steadyMSecs();
|
||||||
|
|
||||||
d_ptr->workers.stop();
|
d_ptr->workers.stop();
|
||||||
|
|
|
@ -121,7 +121,7 @@ std::vector<xmrig::CpuLaunchData> xmrig::CpuConfig::get(const Miner *miner, cons
|
||||||
out.reserve(threads.count());
|
out.reserve(threads.count());
|
||||||
|
|
||||||
for (const CpuThread &thread : threads.data()) {
|
for (const CpuThread &thread : threads.data()) {
|
||||||
out.push_back(CpuLaunchData(miner, algorithm, *this, thread));
|
out.emplace_back(miner, algorithm, *this, thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
|
|
|
@ -74,7 +74,6 @@ public:
|
||||||
pages = 0;
|
pages = 0;
|
||||||
started = 0;
|
started = 0;
|
||||||
threads = 0;
|
threads = 0;
|
||||||
ways = 0;
|
|
||||||
ts = Chrono::steadyMSecs();
|
ts = Chrono::steadyMSecs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +82,6 @@ public:
|
||||||
size_t pages = 0;
|
size_t pages = 0;
|
||||||
size_t started = 0;
|
size_t started = 0;
|
||||||
size_t threads = 0;
|
size_t threads = 0;
|
||||||
size_t ways = 0;
|
|
||||||
uint64_t ts = 0;
|
uint64_t ts = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -161,19 +159,7 @@ public:
|
||||||
status.memory = algo.l3();
|
status.memory = algo.l3();
|
||||||
status.threads = threads.size();
|
status.threads = threads.size();
|
||||||
|
|
||||||
for (const OclLaunchData &data : threads) {
|
//workers.start(threads); // FIXME
|
||||||
status.ways += static_cast<size_t>(data.intensity);
|
|
||||||
}
|
|
||||||
|
|
||||||
workers.start(threads);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
size_t ways()
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(mutex);
|
|
||||||
|
|
||||||
return status.ways;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -256,7 +242,7 @@ void xmrig::OclBackend::printHashrate(bool details)
|
||||||
for (const OclLaunchData &data : d_ptr->threads) {
|
for (const OclLaunchData &data : d_ptr->threads) {
|
||||||
Log::print("| %13zu | %8" PRId64 " | %7s | %7s | %7s |",
|
Log::print("| %13zu | %8" PRId64 " | %7s | %7s | %7s |",
|
||||||
i,
|
i,
|
||||||
data.affinity,
|
data.thread.affinity(),
|
||||||
Hashrate::format(hashrate()->calc(i, Hashrate::ShortInterval), num, sizeof num / 3),
|
Hashrate::format(hashrate()->calc(i, Hashrate::ShortInterval), num, sizeof num / 3),
|
||||||
Hashrate::format(hashrate()->calc(i, Hashrate::MediumInterval), num + 8, sizeof num / 3),
|
Hashrate::format(hashrate()->calc(i, Hashrate::MediumInterval), num + 8, sizeof num / 3),
|
||||||
Hashrate::format(hashrate()->calc(i, Hashrate::LargeInterval), num + 8 * 2, sizeof num / 3)
|
Hashrate::format(hashrate()->calc(i, Hashrate::LargeInterval), num + 8 * 2, sizeof num / 3)
|
||||||
|
@ -275,21 +261,19 @@ void xmrig::OclBackend::setJob(const Job &job)
|
||||||
|
|
||||||
const OclConfig &cl = d_ptr->controller->config()->cl();
|
const OclConfig &cl = d_ptr->controller->config()->cl();
|
||||||
|
|
||||||
std::vector<OclLaunchData> threads = cl.get(d_ptr->controller->miner(), job.algorithm());
|
std::vector<OclLaunchData> threads = cl.get(d_ptr->controller->miner(), job.algorithm(), d_ptr->devices, tag);
|
||||||
// if (d_ptr->threads.size() == threads.size() && std::equal(d_ptr->threads.begin(), d_ptr->threads.end(), threads.begin())) {
|
if (!d_ptr->threads.empty() && d_ptr->threads.size() == threads.size() && std::equal(d_ptr->threads.begin(), d_ptr->threads.end(), threads.begin())) {
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
d_ptr->algo = job.algorithm();
|
d_ptr->algo = job.algorithm();
|
||||||
d_ptr->profileName = cl.threads().profileName(job.algorithm());
|
d_ptr->profileName = cl.threads().profileName(job.algorithm());
|
||||||
|
|
||||||
// if (d_ptr->profileName.isNull() || threads.empty()) {
|
if (d_ptr->profileName.isNull() || threads.empty()) {
|
||||||
// d_ptr->workers.stop();
|
LOG_WARN("%s " RED_BOLD("disabled") YELLOW(" (no suitable configuration found)"), tag);
|
||||||
|
|
||||||
// LOG_WARN(YELLOW_BOLD_S "CPU disabled, no suitable configuration for algo %s", job.algorithm().shortName());
|
return stop();
|
||||||
|
}
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
d_ptr->threads = std::move(threads);
|
d_ptr->threads = std::move(threads);
|
||||||
d_ptr->start();
|
d_ptr->start();
|
||||||
|
@ -355,8 +339,8 @@ rapidjson::Value xmrig::OclBackend::toJSON(rapidjson::Document &doc) const
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
for (const OclLaunchData &data : d_ptr->threads) {
|
for (const OclLaunchData &data : d_ptr->threads) {
|
||||||
Value thread(kObjectType);
|
Value thread(kObjectType);
|
||||||
thread.AddMember("intensity", data.intensity, allocator);
|
thread.AddMember("intensity", data.thread.intensity(), allocator);
|
||||||
thread.AddMember("affinity", data.affinity, allocator);
|
thread.AddMember("affinity", data.thread.affinity(), allocator);
|
||||||
|
|
||||||
Value hashrate(kArrayType);
|
Value hashrate(kArrayType);
|
||||||
hashrate.PushBack(Hashrate::normalize(hr->calc(i, Hashrate::ShortInterval)), allocator);
|
hashrate.PushBack(Hashrate::normalize(hr->calc(i, Hashrate::ShortInterval)), allocator);
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "backend/opencl/OclConfig.h"
|
#include "backend/opencl/OclConfig.h"
|
||||||
#include "backend/opencl/wrappers/OclLib.h"
|
#include "backend/opencl/wrappers/OclLib.h"
|
||||||
#include "base/io/json/Json.h"
|
#include "base/io/json/Json.h"
|
||||||
|
#include "base/io/log/Log.h"
|
||||||
#include "rapidjson/document.h"
|
#include "rapidjson/document.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,12 +35,12 @@ namespace xmrig {
|
||||||
static const char *kAMD = "AMD";
|
static const char *kAMD = "AMD";
|
||||||
static const char *kCache = "cache";
|
static const char *kCache = "cache";
|
||||||
static const char *kCn = "cn";
|
static const char *kCn = "cn";
|
||||||
|
static const char *kCn2 = "cn/2";
|
||||||
static const char *kEnabled = "enabled";
|
static const char *kEnabled = "enabled";
|
||||||
static const char *kINTEL = "INTEL";
|
static const char *kINTEL = "INTEL";
|
||||||
static const char *kLoader = "loader";
|
static const char *kLoader = "loader";
|
||||||
static const char *kNVIDIA = "NVIDIA";
|
static const char *kNVIDIA = "NVIDIA";
|
||||||
static const char *kPlatform = "platform";
|
static const char *kPlatform = "platform";
|
||||||
static const char *kCn2 = "cn/2";
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef XMRIG_ALGO_CN_GPU
|
#ifdef XMRIG_ALGO_CN_GPU
|
||||||
|
@ -148,9 +149,25 @@ rapidjson::Value xmrig::OclConfig::toJSON(rapidjson::Document &doc) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<xmrig::OclLaunchData> xmrig::OclConfig::get(const Miner *miner, const Algorithm &algorithm) const
|
std::vector<xmrig::OclLaunchData> xmrig::OclConfig::get(const Miner *miner, const Algorithm &algorithm, const std::vector<OclDevice> &devices, const char *tag) const
|
||||||
{
|
{
|
||||||
std::vector<OclLaunchData> out;
|
std::vector<OclLaunchData> out;
|
||||||
|
const OclThreads &threads = m_threads.get(algorithm);
|
||||||
|
|
||||||
|
if (threads.isEmpty()) {
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
out.reserve(threads.count());
|
||||||
|
|
||||||
|
for (const OclThread &thread : threads.data()) {
|
||||||
|
if (thread.index() >= devices.size()) {
|
||||||
|
LOG_INFO("%s" YELLOW(" skip non-existing device with index ") YELLOW_BOLD("%u"), tag, thread.index());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
out.emplace_back(miner, algorithm, *this, thread, devices[thread.index()]);
|
||||||
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ public:
|
||||||
|
|
||||||
OclPlatform platform() const;
|
OclPlatform platform() const;
|
||||||
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
||||||
std::vector<OclLaunchData> get(const Miner *miner, const Algorithm &algorithm) const;
|
std::vector<OclLaunchData> get(const Miner *miner, const Algorithm &algorithm, const std::vector<OclDevice> &devices, const char *tag) const;
|
||||||
void read(const rapidjson::Value &value);
|
void read(const rapidjson::Value &value);
|
||||||
|
|
||||||
inline bool isCacheEnabled() const { return m_cache; }
|
inline bool isCacheEnabled() const { return m_cache; }
|
||||||
|
|
|
@ -28,21 +28,18 @@
|
||||||
#include "backend/opencl/OclConfig.h"
|
#include "backend/opencl/OclConfig.h"
|
||||||
|
|
||||||
|
|
||||||
xmrig::OclLaunchData::OclLaunchData(const Miner *miner, const Algorithm &algorithm, const OclConfig &config, const OclThread &thread) :
|
xmrig::OclLaunchData::OclLaunchData(const Miner *miner, const Algorithm &algorithm, const OclConfig &config, const OclThread &thread, const OclDevice &device) :
|
||||||
algorithm(algorithm),
|
algorithm(algorithm),
|
||||||
intensity(thread.intensity()),
|
cache(config.isCacheEnabled()),
|
||||||
priority(-1),
|
miner(miner),
|
||||||
affinity(thread.affinity()),
|
device(device),
|
||||||
miner(miner)
|
thread(thread)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::OclLaunchData::isEqual(const OclLaunchData &other) const
|
bool xmrig::OclLaunchData::isEqual(const OclLaunchData &other) const
|
||||||
{
|
{
|
||||||
return (algorithm.l3() == other.algorithm.l3()
|
return (other.algorithm.l3() == algorithm.l3() &&
|
||||||
&& intensity == other.intensity
|
other.thread == thread);
|
||||||
&& priority == other.priority
|
|
||||||
&& affinity == other.affinity
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
#define XMRIG_OCLLAUNCHDATA_H
|
#define XMRIG_OCLLAUNCHDATA_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "backend/opencl/OclThread.h"
|
||||||
|
#include "backend/opencl/wrappers/OclDevice.h"
|
||||||
#include "crypto/common/Algorithm.h"
|
#include "crypto/common/Algorithm.h"
|
||||||
#include "crypto/common/Nonce.h"
|
#include "crypto/common/Nonce.h"
|
||||||
|
|
||||||
|
@ -35,14 +37,13 @@ namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
class OclConfig;
|
class OclConfig;
|
||||||
class OclThread;
|
|
||||||
class Miner;
|
class Miner;
|
||||||
|
|
||||||
|
|
||||||
class OclLaunchData
|
class OclLaunchData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OclLaunchData(const Miner *miner, const Algorithm &algorithm, const OclConfig &config, const OclThread &thread);
|
OclLaunchData(const Miner *miner, const Algorithm &algorithm, const OclConfig &config, const OclThread &thread, const OclDevice &device);
|
||||||
|
|
||||||
bool isEqual(const OclLaunchData &other) const;
|
bool isEqual(const OclLaunchData &other) const;
|
||||||
|
|
||||||
|
@ -52,10 +53,10 @@ public:
|
||||||
inline bool operator==(const OclLaunchData &other) const { return isEqual(other); }
|
inline bool operator==(const OclLaunchData &other) const { return isEqual(other); }
|
||||||
|
|
||||||
const Algorithm algorithm;
|
const Algorithm algorithm;
|
||||||
const int intensity;
|
const bool cache;
|
||||||
const int priority;
|
|
||||||
const int64_t affinity;
|
|
||||||
const Miner *miner;
|
const Miner *miner;
|
||||||
|
const OclDevice device;
|
||||||
|
const OclThread thread;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue