Merge branch 'master' into mo
This commit is contained in:
commit
f5dc226717
8 changed files with 55 additions and 55 deletions
|
@ -141,7 +141,9 @@ int App::exec()
|
||||||
: " >>>>> STARTING ALGO PERFORMANCE CALIBRATION (with %i seconds round)",
|
: " >>>>> STARTING ALGO PERFORMANCE CALIBRATION (with %i seconds round)",
|
||||||
m_controller->config()->calibrateAlgoTime()
|
m_controller->config()->calibrateAlgoTime()
|
||||||
);
|
);
|
||||||
benchmark.start_perf_bench(xmrig::PerfAlgo::PA_CN); // start benchmarking from first PerfAlgo in the list
|
// start benchmarking from first PerfAlgo in the list
|
||||||
|
if (m_controller->config()->get_algo_perf(xmrig::PA_CN) == 0.0f) benchmark.should_save_config();
|
||||||
|
benchmark.start_perf_bench(xmrig::PerfAlgo::PA_CN);
|
||||||
} else {
|
} else {
|
||||||
m_controller->network()->connect();
|
m_controller->network()->connect();
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public:
|
||||||
m_variant(VARIANT_AUTO)
|
m_variant(VARIANT_AUTO)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
inline Algorithm(Algo algo, Variant variant) :
|
inline Algorithm(Algo algo, Variant variant = VARIANT_AUTO) :
|
||||||
m_variant(variant)
|
m_variant(variant)
|
||||||
{
|
{
|
||||||
setAlgo(algo);
|
setAlgo(algo);
|
||||||
|
|
|
@ -34,7 +34,8 @@ enum Algo {
|
||||||
INVALID_ALGO = -1,
|
INVALID_ALGO = -1,
|
||||||
CRYPTONIGHT, /* CryptoNight (Monero) */
|
CRYPTONIGHT, /* CryptoNight (Monero) */
|
||||||
CRYPTONIGHT_LITE, /* CryptoNight-Lite (AEON) */
|
CRYPTONIGHT_LITE, /* CryptoNight-Lite (AEON) */
|
||||||
CRYPTONIGHT_HEAVY /* CryptoNight-Heavy (SUMO) */
|
CRYPTONIGHT_HEAVY, /* CryptoNight-Heavy (SUMO) */
|
||||||
|
ALGO_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
// algorithms that can has different performance
|
// algorithms that can has different performance
|
||||||
|
|
|
@ -46,7 +46,6 @@ static char affinity_tmp[20] = { 0 };
|
||||||
|
|
||||||
|
|
||||||
xmrig::Config::Config() : xmrig::CommonConfig(),
|
xmrig::Config::Config() : xmrig::CommonConfig(),
|
||||||
m_shouldSave(false),
|
|
||||||
m_aesMode(AES_AUTO),
|
m_aesMode(AES_AUTO),
|
||||||
m_algoVariant(AV_AUTO),
|
m_algoVariant(AV_AUTO),
|
||||||
m_hugePages(true),
|
m_hugePages(true),
|
||||||
|
@ -124,20 +123,20 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
|
||||||
|
|
||||||
// save extended "threads" based on m_threads
|
// save extended "threads" based on m_threads
|
||||||
Value threads(kObjectType);
|
Value threads(kObjectType);
|
||||||
for (int a = 0; a != xmrig::PerfAlgo::PA_MAX; ++ a) {
|
for (int a = 0; a != xmrig::Algo::ALGO_MAX; ++ a) {
|
||||||
const xmrig::PerfAlgo pa = static_cast<xmrig::PerfAlgo>(a);
|
const xmrig::Algo algo = static_cast<xmrig::Algo>(a);
|
||||||
Value key(xmrig::Algorithm::perfAlgoName(pa), allocator);
|
Value key(xmrig::Algorithm::perfAlgoName(xmrig::Algorithm(algo).perf_algo()), allocator);
|
||||||
if (threadsMode(pa) == Advanced) {
|
if (threadsMode(algo) == Advanced) {
|
||||||
Value threads2(kArrayType);
|
Value threads2(kArrayType);
|
||||||
|
|
||||||
for (const IThread *thread : m_threads[pa].list) {
|
for (const IThread *thread : m_threads[algo].list) {
|
||||||
threads2.PushBack(thread->toConfig(doc), allocator);
|
threads2.PushBack(thread->toConfig(doc), allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
threads.AddMember(key, threads2, allocator);
|
threads.AddMember(key, threads2, allocator);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
threads.AddMember(key, threadsMode(pa) == Automatic ? Value(kNullType) : Value(threadsCount(pa)), allocator);
|
threads.AddMember(key, threadsMode(algo) == Automatic ? Value(kNullType) : Value(threadsCount(algo)), allocator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
doc.AddMember("threads", threads, allocator);
|
doc.AddMember("threads", threads, allocator);
|
||||||
|
@ -181,33 +180,33 @@ bool xmrig::Config::finalize()
|
||||||
}
|
}
|
||||||
|
|
||||||
// auto configure m_threads
|
// auto configure m_threads
|
||||||
for (int a = 0; a != xmrig::PerfAlgo::PA_MAX; ++ a) {
|
for (int a = 0; a != xmrig::Algo::ALGO_MAX; ++ a) {
|
||||||
const xmrig::PerfAlgo pa = static_cast<xmrig::PerfAlgo>(a);
|
const xmrig::Algo algo = static_cast<xmrig::Algo>(a);
|
||||||
if (!m_threads[pa].cpu.empty()) {
|
if (!m_threads[algo].cpu.empty()) {
|
||||||
m_threads[pa].mode = Advanced;
|
m_threads[algo].mode = Advanced;
|
||||||
const bool softAES = (m_aesMode == AES_AUTO ? (Cpu::hasAES() ? AES_HW : AES_SOFT) : m_aesMode) == AES_SOFT;
|
const bool softAES = (m_aesMode == AES_AUTO ? (Cpu::hasAES() ? AES_HW : AES_SOFT) : m_aesMode) == AES_SOFT;
|
||||||
|
|
||||||
for (size_t i = 0; i < m_threads[pa].cpu.size(); ++i) {
|
for (size_t i = 0; i < m_threads[algo].cpu.size(); ++i) {
|
||||||
m_threads[pa].list.push_back(CpuThread::createFromData(i, xmrig::Algorithm(pa).algo(), m_threads[pa].cpu[i], m_priority, softAES));
|
m_threads[algo].list.push_back(CpuThread::createFromData(i, algo, m_threads[algo].cpu[i], m_priority, softAES));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const AlgoVariant av = getAlgoVariant();
|
const AlgoVariant av = getAlgoVariant();
|
||||||
m_threads[pa].mode = m_threads[pa].count ? Simple : Automatic;
|
m_threads[algo].mode = m_threads[algo].count ? Simple : Automatic;
|
||||||
|
|
||||||
const size_t size = CpuThread::multiway(av) * cn_select_memory(xmrig::Algorithm(pa).algo()) / 1024;
|
const size_t size = CpuThread::multiway(av) * cn_select_memory(algo) / 1024;
|
||||||
|
|
||||||
if (!m_threads[pa].count) {
|
if (!m_threads[algo].count) {
|
||||||
m_threads[pa].count = Cpu::optimalThreadsCount(size, m_maxCpuUsage);
|
m_threads[algo].count = Cpu::optimalThreadsCount(size, m_maxCpuUsage);
|
||||||
}
|
}
|
||||||
else if (m_safe) {
|
else if (m_safe) {
|
||||||
const size_t count = Cpu::optimalThreadsCount(size, m_maxCpuUsage);
|
const size_t count = Cpu::optimalThreadsCount(size, m_maxCpuUsage);
|
||||||
if (m_threads[pa].count > count) {
|
if (m_threads[algo].count > count) {
|
||||||
m_threads[pa].count = count;
|
m_threads[algo].count = count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < m_threads[pa].count; ++i) {
|
for (size_t i = 0; i < m_threads[algo].count; ++i) {
|
||||||
m_threads[pa].list.push_back(CpuThread::createFromAV(i, xmrig::Algorithm(pa).algo(), av, m_threads[pa].mask, m_priority));
|
m_threads[algo].list.push_back(CpuThread::createFromAV(i, algo, av, m_threads[algo].mask, m_priority));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -263,7 +262,7 @@ bool xmrig::Config::parseString(int key, const char *arg)
|
||||||
|
|
||||||
case ThreadsKey: /* --threads */
|
case ThreadsKey: /* --threads */
|
||||||
if (strncmp(arg, "all", 3) == 0) {
|
if (strncmp(arg, "all", 3) == 0) {
|
||||||
m_threads[m_algorithm.perf_algo()].count = Cpu::threads(); // sets default algo threads
|
m_threads[m_algorithm.algo()].count = Cpu::threads(); // sets default algo threads
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,7 +291,7 @@ bool xmrig::Config::parseUint64(int key, uint64_t arg)
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case CPUAffinityKey: /* --cpu-affinity */
|
case CPUAffinityKey: /* --cpu-affinity */
|
||||||
if (arg) {
|
if (arg) {
|
||||||
m_threads[m_algorithm.perf_algo()].mask = arg; // sets default algo threads
|
m_threads[m_algorithm.algo()].mask = arg; // sets default algo threads
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -305,7 +304,7 @@ bool xmrig::Config::parseUint64(int key, uint64_t arg)
|
||||||
|
|
||||||
|
|
||||||
// parse specific perf algo (or generic) threads config
|
// parse specific perf algo (or generic) threads config
|
||||||
void xmrig::Config::parseThreadsJSON(const rapidjson::Value &threads, const xmrig::PerfAlgo pa)
|
void xmrig::Config::parseThreadsJSON(const rapidjson::Value &threads, const xmrig::Algo algo)
|
||||||
{
|
{
|
||||||
for (const rapidjson::Value &value : threads.GetArray()) {
|
for (const rapidjson::Value &value : threads.GetArray()) {
|
||||||
if (!value.IsObject()) {
|
if (!value.IsObject()) {
|
||||||
|
@ -316,7 +315,7 @@ void xmrig::Config::parseThreadsJSON(const rapidjson::Value &threads, const xmri
|
||||||
auto data = CpuThread::parse(value);
|
auto data = CpuThread::parse(value);
|
||||||
|
|
||||||
if (data.valid) {
|
if (data.valid) {
|
||||||
m_threads[pa].cpu.push_back(std::move(data));
|
m_threads[algo].cpu.push_back(std::move(data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -328,14 +327,14 @@ void xmrig::Config::parseJSON(const rapidjson::Document &doc)
|
||||||
|
|
||||||
if (threads.IsArray()) {
|
if (threads.IsArray()) {
|
||||||
// parse generic (old) threads
|
// parse generic (old) threads
|
||||||
parseThreadsJSON(threads, m_algorithm.perf_algo());
|
parseThreadsJSON(threads, m_algorithm.algo());
|
||||||
} else if (threads.IsObject()) {
|
} else if (threads.IsObject()) {
|
||||||
// parse new specific perf algo threads
|
// parse new specific perf algo threads
|
||||||
for (int a = 0; a != xmrig::PerfAlgo::PA_MAX; ++ a) {
|
for (int a = 0; a != xmrig::Algo::ALGO_MAX; ++ a) {
|
||||||
const xmrig::PerfAlgo pa = static_cast<xmrig::PerfAlgo>(a);
|
const xmrig::Algo algo = static_cast<xmrig::Algo>(a);
|
||||||
const rapidjson::Value &threads2 = threads[xmrig::Algorithm::perfAlgoName(pa)];
|
const rapidjson::Value &threads2 = threads[xmrig::Algorithm::perfAlgoName(xmrig::Algorithm(algo).perf_algo())];
|
||||||
if (threads2.IsArray()) {
|
if (threads2.IsArray()) {
|
||||||
parseThreadsJSON(threads2, pa);
|
parseThreadsJSON(threads2, algo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -350,8 +349,6 @@ void xmrig::Config::parseJSON(const rapidjson::Document &doc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_algo_perf[xmrig::PA_CN] == 0.0f) m_shouldSave = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -360,7 +357,7 @@ bool xmrig::Config::parseInt(int key, int arg)
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case ThreadsKey: /* --threads */
|
case ThreadsKey: /* --threads */
|
||||||
if (arg >= 0 && arg < 1024) {
|
if (arg >= 0 && arg < 1024) {
|
||||||
m_threads[m_algorithm.perf_algo()].count = arg; // sets default algo threads
|
m_threads[m_algorithm.algo()].count = arg; // sets default algo threads
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -76,24 +76,23 @@ public:
|
||||||
|
|
||||||
void getJSON(rapidjson::Document &doc) const override;
|
void getJSON(rapidjson::Document &doc) const override;
|
||||||
|
|
||||||
inline bool isShouldSave() const { return m_shouldSave; }
|
|
||||||
inline AesMode aesMode() const { return m_aesMode; }
|
inline AesMode aesMode() const { return m_aesMode; }
|
||||||
inline AlgoVariant algoVariant() const { return m_algoVariant; }
|
inline AlgoVariant algoVariant() const { return m_algoVariant; }
|
||||||
inline bool isHugePages() const { return m_hugePages; }
|
inline bool isHugePages() const { return m_hugePages; }
|
||||||
inline int priority() const { return m_priority; }
|
inline int priority() const { return m_priority; }
|
||||||
|
|
||||||
// access to m_threads taking into accoun that it is now separated for each perf algo
|
// access to m_threads taking into accoun that it is now separated for each perf algo
|
||||||
inline const std::vector<IThread *> &threads(const xmrig::PerfAlgo pa = PA_INVALID) const {
|
inline const std::vector<IThread *> &threads(const xmrig::Algo algo = INVALID_ALGO) const {
|
||||||
return m_threads[pa == PA_INVALID ? m_algorithm.perf_algo() : pa].list;
|
return m_threads[algo == INVALID_ALGO ? m_algorithm.algo() : algo].list;
|
||||||
}
|
}
|
||||||
inline int threadsCount(const xmrig::PerfAlgo pa = PA_INVALID) const {
|
inline int threadsCount(const xmrig::Algo algo = INVALID_ALGO) const {
|
||||||
return m_threads[pa == PA_INVALID ? m_algorithm.perf_algo() : pa].list.size();
|
return m_threads[algo == INVALID_ALGO ? m_algorithm.algo() : algo].list.size();
|
||||||
}
|
}
|
||||||
inline int64_t affinity(const xmrig::PerfAlgo pa = PA_INVALID) const {
|
inline int64_t affinity(const xmrig::Algo algo = INVALID_ALGO) const {
|
||||||
return m_threads[pa == PA_INVALID ? m_algorithm.perf_algo() : pa].mask;
|
return m_threads[algo == INVALID_ALGO ? m_algorithm.algo() : algo].mask;
|
||||||
}
|
}
|
||||||
inline ThreadsMode threadsMode(const xmrig::PerfAlgo pa = PA_INVALID) const {
|
inline ThreadsMode threadsMode(const xmrig::Algo algo = INVALID_ALGO) const {
|
||||||
return m_threads[pa == PA_INVALID ? m_algorithm.perf_algo() : pa].mode;
|
return m_threads[algo == INVALID_ALGO ? m_algorithm.algo() : algo].mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
// access to perf algo results
|
// access to perf algo results
|
||||||
|
@ -109,7 +108,7 @@ protected:
|
||||||
bool parseUint64(int key, uint64_t arg) override;
|
bool parseUint64(int key, uint64_t arg) override;
|
||||||
void parseJSON(const rapidjson::Document &doc) override;
|
void parseJSON(const rapidjson::Document &doc) override;
|
||||||
// parse specific perf algo (or generic) threads config
|
// parse specific perf algo (or generic) threads config
|
||||||
void parseThreadsJSON(const rapidjson::Value &threads, xmrig::PerfAlgo);
|
void parseThreadsJSON(const rapidjson::Value &threads, xmrig::Algo);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool parseInt(int key, int arg);
|
bool parseInt(int key, int arg);
|
||||||
|
@ -132,15 +131,14 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
bool m_shouldSave;
|
|
||||||
AesMode m_aesMode;
|
AesMode m_aesMode;
|
||||||
AlgoVariant m_algoVariant;
|
AlgoVariant m_algoVariant;
|
||||||
bool m_hugePages;
|
bool m_hugePages;
|
||||||
bool m_safe;
|
bool m_safe;
|
||||||
int m_maxCpuUsage;
|
int m_maxCpuUsage;
|
||||||
int m_priority;
|
int m_priority;
|
||||||
// threads config for each perf algo
|
// threads config for each algo
|
||||||
Threads m_threads[xmrig::PerfAlgo::PA_MAX];
|
Threads m_threads[xmrig::Algo::ALGO_MAX];
|
||||||
// perf algo hashrate results
|
// perf algo hashrate results
|
||||||
float m_algo_perf[xmrig::PerfAlgo::PA_MAX];
|
float m_algo_perf[xmrig::PerfAlgo::PA_MAX];
|
||||||
};
|
};
|
||||||
|
|
|
@ -80,7 +80,7 @@ void Benchmark::onJobResult(const JobResult& result) {
|
||||||
start_perf_bench(next_pa);
|
start_perf_bench(next_pa);
|
||||||
} else { // end of benchmarks and switching to jobs from the pool (network)
|
} else { // end of benchmarks and switching to jobs from the pool (network)
|
||||||
m_pa = xmrig::PA_INVALID;
|
m_pa = xmrig::PA_INVALID;
|
||||||
if (m_controller->config()->isShouldSave()) m_controller->config()->save(); // save config with measured algo-perf
|
if (m_shouldSaveConfig) m_controller->config()->save(); // save config with measured algo-perf
|
||||||
Workers::pause(); // do not compute anything before job from the pool
|
Workers::pause(); // do not compute anything before job from the pool
|
||||||
m_controller->network()->connect();
|
m_controller->network()->connect();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "core/Controller.h"
|
#include "core/Controller.h"
|
||||||
|
|
||||||
class Benchmark : public IJobResultListener {
|
class Benchmark : public IJobResultListener {
|
||||||
|
bool m_shouldSaveConfig; // should save config after all benchmark rounds
|
||||||
xmrig::PerfAlgo m_pa; // current perf algo we benchmark
|
xmrig::PerfAlgo m_pa; // current perf algo we benchmark
|
||||||
uint64_t m_hash_count; // number of hashes calculated for current perf algo
|
uint64_t m_hash_count; // number of hashes calculated for current perf algo
|
||||||
uint64_t m_time_start; // time of measurements start for current perf algo (in ms)
|
uint64_t m_time_start; // time of measurements start for current perf algo (in ms)
|
||||||
|
@ -41,9 +42,10 @@ class Benchmark : public IJobResultListener {
|
||||||
void onJobResult(const JobResult&) override; // onJobResult is called after each computed benchmark hash
|
void onJobResult(const JobResult&) override; // onJobResult is called after each computed benchmark hash
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Benchmark() {}
|
Benchmark() : m_shouldSaveConfig(false) {}
|
||||||
virtual ~Benchmark() {}
|
virtual ~Benchmark() {}
|
||||||
|
|
||||||
void set_controller(xmrig::Controller* controller) { m_controller = controller; }
|
void set_controller(xmrig::Controller* controller) { m_controller = controller; }
|
||||||
|
void should_save_config() { m_shouldSaveConfig = true; }
|
||||||
void start_perf_bench(const xmrig::PerfAlgo); // start benchmark for specified perf algo
|
void start_perf_bench(const xmrig::PerfAlgo); // start benchmark for specified perf algo
|
||||||
};
|
};
|
||||||
|
|
|
@ -223,7 +223,7 @@ void Workers::switch_algo(const xmrig::Algorithm& algorithm)
|
||||||
m_sequence = 1;
|
m_sequence = 1;
|
||||||
m_paused = 1;
|
m_paused = 1;
|
||||||
|
|
||||||
const std::vector<xmrig::IThread *> &threads = m_controller->config()->threads(algorithm.perf_algo());
|
const std::vector<xmrig::IThread *> &threads = m_controller->config()->threads(algorithm.algo());
|
||||||
m_status.algo = algorithm.algo();
|
m_status.algo = algorithm.algo();
|
||||||
m_status.threads = threads.size();
|
m_status.threads = threads.size();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue