Skip to content

Commit 7cd1dfa

Browse files
committed
Advertise KawPow performance with compatible units
1 parent 4e5366b commit 7cd1dfa

4 files changed

Lines changed: 39 additions & 15 deletions

File tree

src/core/MoBenchmark.cpp

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@
3030
#include "net/Network.h"
3131

3232
#include <chrono>
33+
#include <cstring>
3334

3435
namespace xmrig {
3536

36-
MoBenchmark::MoBenchmark() : m_controller(nullptr), m_isNewBenchRun(true) {}
37+
MoBenchmark::MoBenchmark() : m_controller(nullptr), m_isNewBenchRun(true), m_isRawKawPow(false) {}
3738

3839
MoBenchmark::~MoBenchmark() {}
3940

@@ -69,35 +70,43 @@ rapidjson::Value MoBenchmark::toJSON(rapidjson::Document &doc) const
6970

7071
for (const Algorithm a : Algorithm::all()) {
7172
if (algo_perf[a.id()] == 0.0f) continue;
72-
obj.AddMember(StringRef(a.name()), algo_perf[a.id()], allocator);
73+
obj.AddMember(StringRef(poolAlgoName(a)), algo_perf[a.id()], allocator);
7374
}
7475

7576
return obj;
7677
}
7778

7879
void MoBenchmark::flush_perf() {
7980
for (const Algorithm::Id algo : Algorithm::all()) algo_perf[algo] = 0.0f;
81+
m_isRawKawPow = false;
8082
}
8183

8284
void MoBenchmark::read(const rapidjson::Value &value)
8385
{
8486
flush_perf();
8587
if (value.IsObject()) {
8688
for (auto &member : value.GetObject()) {
87-
const Algorithm algo(member.name.GetString());
89+
const bool rawKawPow = strcmp(member.name.GetString(), "kawpow1") == 0;
90+
const Algorithm algo(rawKawPow ? "kawpow" : member.name.GetString());
8891
if (!algo.isValid()) {
8992
LOG_INFO("%s " BRIGHT_BLACK_BG(MAGENTA_BOLD_S " Ignoring wrong name for algo-perf[%s] "), Tags::benchmark(), member.name.GetString());
9093
continue;
9194
}
92-
if (member.value.IsDouble()) {
93-
algo_perf[algo.id()] = member.value.GetDouble();
95+
double perf = 0.0;
96+
if (member.value.IsDouble()) perf = member.value.GetDouble();
97+
else if (member.value.IsInt()) perf = member.value.GetInt();
98+
else {
99+
LOG_INFO("%s " BRIGHT_BLACK_BG(MAGENTA_BOLD_S " Ignoring wrong value for algo-perf[%s] "), Tags::benchmark(), member.name.GetString());
94100
continue;
95101
}
96-
if (member.value.IsInt()) {
97-
algo_perf[algo.id()] = member.value.GetInt();
98-
continue;
102+
# ifdef XMRIG_ALGO_KAWPOW
103+
if (algo.id() == Algorithm::KAWPOW_RVN) {
104+
if (!rawKawPow && m_isRawKawPow) continue;
105+
m_isRawKawPow = rawKawPow;
99106
}
100-
LOG_INFO("%s " BRIGHT_BLACK_BG(MAGENTA_BOLD_S " Ignoring wrong value for algo-perf[%s] "), Tags::benchmark(), member.name.GetString());
107+
# endif
108+
algo_perf[algo.id()] = perf;
109+
continue;
101110
}
102111
}
103112
m_isNewBenchRun = false;
@@ -108,6 +117,13 @@ void MoBenchmark::read(const rapidjson::Value &value)
108117
}
109118
}
110119

120+
const char *MoBenchmark::poolAlgoName(const Algorithm &algo) const {
121+
# ifdef XMRIG_ALGO_KAWPOW
122+
if (algo.id() == Algorithm::KAWPOW_RVN && m_isRawKawPow) return "kawpow1";
123+
# endif
124+
return algo.name();
125+
}
126+
111127
double MoBenchmark::get_algo_perf(Algorithm::Id algo) const {
112128
switch (algo) {
113129
case Algorithm::CN_0: return algo_perf[Algorithm::CN_CCX] / 2;
@@ -140,6 +156,9 @@ void MoBenchmark::start() {
140156
run_next_bench_algo();
141157
return;
142158
}
159+
# ifdef XMRIG_ALGO_KAWPOW
160+
if (algo.id() == Algorithm::KAWPOW_RVN) m_isRawKawPow = true;
161+
# endif
143162
// calculate number of active miner backends in m_enabled_backend_count
144163
m_enabled_backend_count = 0;
145164
for (auto backend : m_controller->miner()->backends()) if (backend->isEnabled() && backend->isEnabled(algo)) ++ m_enabled_backend_count;
@@ -229,9 +248,6 @@ void MoBenchmark::onJobResult(const JobResult& result) {
229248
if (!(hashrate = t[1]))
230249
if (!(hashrate = t[0]))
231250
hashrate = static_cast<double>(m_hash_count) * result.diff / (now - m_bench_start) * 1000.0f;
232-
# ifdef XMRIG_ALGO_KAWPOW
233-
if (algo.id() == Algorithm::KAWPOW_RVN) hashrate /= ((double)0xFFFFFFFFFFFFFFFF) / 0xFF000000;
234-
# endif
235251
algo_perf[algo.id()] = hashrate; // store hashrate result
236252
LOG_INFO("%s " BRIGHT_BLACK_BG(WHITE_BOLD_S " Algo " MAGENTA_BOLD_S "%s" WHITE_BOLD_S " hashrate: " CYAN_BOLD_S "%f "), Tags::benchmark(), algo.name(), hashrate);
237253
run_next_bench_algo();

src/core/MoBenchmark.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class MoBenchmark : public IJobResultListener {
7474

7575
Controller *m_controller; // to get access to config and network
7676
bool m_isNewBenchRun; // true if benchmark is need to be executed or was executed
77+
bool m_isRawKawPow; // true when KawPow perf was measured in raw H/s
7778
uint64_t m_bench_algo; // current perf algo number we benchmark (in bench_algos array)
7879
uint64_t m_hash_count; // number of hashes calculated for current perf algo
7980
uint64_t m_time_start; // time of the first resultt for current perf algo (in ms)
@@ -98,6 +99,7 @@ class MoBenchmark : public IJobResultListener {
9899
void flush_perf();
99100

100101
bool isNewBenchRun() const { return m_isNewBenchRun; }
102+
const char *poolAlgoName(const Algorithm &algo) const;
101103
mutable std::map<Algorithm::Id, double> algo_perf;
102104

103105
rapidjson::Value toJSON(rapidjson::Document &doc) const;

src/net/Network.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,12 @@ void xmrig::Network::onLogin(IStrategy *, IClient *client, rapidjson::Document &
201201
Value algo(kArrayType);
202202

203203
for (const auto &a : algorithms) {
204-
algo.PushBack(StringRef(a.name()), allocator);
204+
# ifdef XMRIG_FEATURE_MO_BENCHMARK
205+
const char *name = m_controller->config()->benchmark().poolAlgoName(a);
206+
# else
207+
const char *name = a.name();
208+
# endif
209+
algo.PushBack(StringRef(name), allocator);
205210
}
206211

207212
params.AddMember("algo", algo, allocator);
@@ -211,7 +216,8 @@ void xmrig::Network::onLogin(IStrategy *, IClient *client, rapidjson::Document &
211216
Value algo_perf(kObjectType);
212217

213218
for (const auto &a : algorithms) {
214-
algo_perf.AddMember(StringRef(a.name()), m_controller->config()->benchmark().algo_perf[a.id()], allocator);
219+
const char *name = m_controller->config()->benchmark().poolAlgoName(a);
220+
algo_perf.AddMember(StringRef(name), m_controller->config()->benchmark().algo_perf[a.id()], allocator);
215221
}
216222

217223
params.AddMember("algo-perf", algo_perf, allocator);

tests/common/miner_harness.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const ALGO_PERF = {
6262
"cn/ccx": 1,
6363
"cn/gpu": 1,
6464
"argon2/chukwav2": 1,
65-
"kawpow": 1,
65+
"kawpow1": 1,
6666
"ghostrider": 1,
6767
"flex": 1,
6868
"cn-heavy/xhv": 1,

0 commit comments

Comments
 (0)