Cleanup MoneroOcean patchset
This commit is contained in:
parent
42235a56da
commit
30fdc92884
28 changed files with 6138 additions and 6122 deletions
|
@ -24,6 +24,7 @@ option(WITH_NVML "Enable NVML (NVIDIA Management Library) support (on
|
|||
option(WITH_ADL "Enable ADL (AMD Display Library) or sysfs support (only if OpenCL backend enabled)" ON)
|
||||
option(WITH_STRICT_CACHE "Enable strict checks for OpenCL cache" ON)
|
||||
option(WITH_INTERLEAVE_DEBUG_LOG "Enable debug log for threads interleave" OFF)
|
||||
option(WITH_BENCHMARK "Enable Benchmark module and algo-perf feature (for MoneroOcean)" ON)
|
||||
|
||||
option(BUILD_STATIC "Build static binary" OFF)
|
||||
option(ARM_TARGET "Force use specific ARM target 8 or 7" 0)
|
||||
|
@ -100,7 +101,6 @@ set(SOURCES
|
|||
src/core/config/ConfigTransform.cpp
|
||||
src/core/Controller.cpp
|
||||
src/core/Miner.cpp
|
||||
src/core/Benchmark.cpp
|
||||
src/net/JobResults.cpp
|
||||
src/net/Network.cpp
|
||||
src/net/strategies/DonateStrategy.cpp
|
||||
|
@ -121,6 +121,13 @@ set(SOURCES_CRYPTO
|
|||
src/crypto/common/VirtualMemory.cpp
|
||||
)
|
||||
|
||||
if (WITH_BENCHMARK)
|
||||
list(APPEND SOURCES
|
||||
src/core/Benchmark.cpp
|
||||
)
|
||||
add_definitions(/DXMRIG_FEATURE_BENCHMARK)
|
||||
endif()
|
||||
|
||||
if (WITH_HWLOC)
|
||||
list(APPEND HEADERS_CRYPTO
|
||||
src/crypto/common/NUMAMemoryPool.h
|
||||
|
|
|
@ -40,11 +40,8 @@ if (WITH_RANDOMX)
|
|||
src/crypto/rx/RxDataset.cpp
|
||||
src/crypto/rx/RxQueue.cpp
|
||||
src/crypto/rx/RxVm.cpp
|
||||
|
||||
src/crypto/defyx/align.h
|
||||
src/crypto/defyx/brg_endian.h
|
||||
src/crypto/defyx/defyx.cpp
|
||||
src/crypto/defyx/defyx.h
|
||||
src/crypto/defyx/KangarooTwelve.c
|
||||
src/crypto/defyx/KangarooTwelve.h
|
||||
src/crypto/defyx/KeccakP-1600-reference.c
|
||||
|
|
|
@ -91,6 +91,7 @@ int xmrig::App::exec()
|
|||
return 0;
|
||||
}
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
m_controller->pre_start();
|
||||
m_controller->config()->benchmark().set_controller(m_controller);
|
||||
|
||||
|
@ -99,6 +100,9 @@ int xmrig::App::exec()
|
|||
} else {
|
||||
m_controller->start();
|
||||
}
|
||||
# else
|
||||
m_controller->start();
|
||||
# endif
|
||||
|
||||
rc = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
||||
uv_loop_close(uv_default_loop());
|
||||
|
|
|
@ -138,8 +138,8 @@ size_t inline generate<Algorithm::RANDOM_X>(Threads<CpuThreads> &threads, uint32
|
|||
count += threads.move("rx/wow", std::move(wow));
|
||||
}
|
||||
|
||||
if (!threads.isExist(Algorithm::DEFYX)) {
|
||||
count += generate("defyx", threads, Algorithm::DEFYX, limit);
|
||||
if (!threads.isExist(Algorithm::RX_DEFYX)) {
|
||||
count += generate("defyx", threads, Algorithm::RX_DEFYX, limit);
|
||||
}
|
||||
|
||||
count += generate("rx", threads, Algorithm::RX_0, limit);
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
|
||||
#ifdef XMRIG_ALGO_RANDOMX
|
||||
# include "crypto/randomx/randomx.h"
|
||||
# include "crypto/defyx/defyx.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -253,29 +252,24 @@ void xmrig::CpuWorker<N>::start()
|
|||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
if (job.algorithm().family() == Algorithm::RANDOM_X) {
|
||||
|
||||
if (job.algorithm() == Algorithm::DEFYX) {
|
||||
if (first) {
|
||||
first = false;
|
||||
defyx_calculate_hash_first(m_vm, tempHash, m_job.blob(), job.size());
|
||||
if (job.algorithm() == Algorithm::RX_DEFYX) {
|
||||
defyx_calculate_hash_first(m_vm, tempHash, m_job.blob(), job.size());
|
||||
} else {
|
||||
randomx_calculate_hash_first(m_vm, tempHash, m_job.blob(), job.size());
|
||||
}
|
||||
}
|
||||
|
||||
if (!nextRound(m_job)) {
|
||||
break;
|
||||
}
|
||||
|
||||
defyx_calculate_hash_next(m_vm, tempHash, m_job.blob(), job.size(), m_hash);
|
||||
} else {
|
||||
if (first) {
|
||||
first = false;
|
||||
randomx_calculate_hash_first(m_vm, tempHash, m_job.blob(), job.size());
|
||||
if (job.algorithm() == Algorithm::RX_DEFYX) {
|
||||
defyx_calculate_hash_next(m_vm, tempHash, m_job.blob(), job.size(), m_hash);
|
||||
} else {
|
||||
randomx_calculate_hash_next(m_vm, tempHash, m_job.blob(), job.size(), m_hash);
|
||||
}
|
||||
|
||||
if (!nextRound(m_job)) {
|
||||
break;
|
||||
}
|
||||
|
||||
randomx_calculate_hash_next(m_vm, tempHash, m_job.blob(), job.size(), m_hash);
|
||||
}
|
||||
}
|
||||
else
|
||||
# endif
|
||||
|
|
|
@ -24,10 +24,11 @@
|
|||
#define ALGO_RX_ARQMA 23
|
||||
#define ALGO_RX_SFX 24
|
||||
#define ALGO_RX_KEVA 25
|
||||
#define ALGO_AR2_CHUKWA 26
|
||||
#define ALGO_AR2_WRKZ 27
|
||||
#define ALGO_ASTROBWT_DERO 28
|
||||
#define ALGO_KAWPOW_RVN 29
|
||||
#define ALGO_RX_DEFYX 26
|
||||
#define ALGO_AR2_CHUKWA 27
|
||||
#define ALGO_AR2_WRKZ 28
|
||||
#define ALGO_ASTROBWT_DERO 29
|
||||
#define ALGO_KAWPOW_RVN 30
|
||||
|
||||
#define FAMILY_UNKNOWN 0
|
||||
#define FAMILY_CN 1
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -111,13 +111,14 @@ static AlgoName const algorithm_names[] = {
|
|||
{ "RandomWOW", nullptr, Algorithm::RX_WOW },
|
||||
{ "randomx/loki", "rx/loki", Algorithm::RX_LOKI },
|
||||
{ "RandomXL", nullptr, Algorithm::RX_LOKI },
|
||||
{ "DefyX", "defyx", Algorithm::DEFYX },
|
||||
{ "randomx/arq", "rx/arq", Algorithm::RX_ARQ },
|
||||
{ "RandomARQ", nullptr, Algorithm::RX_ARQ },
|
||||
{ "randomx/sfx", "rx/sfx", Algorithm::RX_SFX },
|
||||
{ "RandomSFX", nullptr, Algorithm::RX_SFX },
|
||||
{ "randomx/keva", "rx/keva", Algorithm::RX_KEVA },
|
||||
{ "RandomKEVA", nullptr, Algorithm::RX_KEVA },
|
||||
{ "defyx", "defyx", Algorithm::RX_DEFYX },
|
||||
{ "DefyX", nullptr, Algorithm::RX_DEFYX },
|
||||
# endif
|
||||
# ifdef XMRIG_ALGO_ARGON2
|
||||
{ "argon2/chukwa", nullptr, Algorithm::AR2_CHUKWA },
|
||||
|
@ -159,9 +160,7 @@ size_t xmrig::Algorithm::l2() const
|
|||
|
||||
case RX_WOW:
|
||||
case RX_KEVA:
|
||||
return 0x20000;
|
||||
|
||||
case DEFYX:
|
||||
case RX_DEFYX:
|
||||
return 0x20000;
|
||||
|
||||
case RX_ARQ:
|
||||
|
@ -212,10 +211,8 @@ size_t xmrig::Algorithm::l3() const
|
|||
case RX_KEVA:
|
||||
return oneMiB;
|
||||
|
||||
case DEFYX:
|
||||
return oneMiB / 4;
|
||||
|
||||
case RX_ARQ:
|
||||
case RX_DEFYX:
|
||||
return oneMiB / 4;
|
||||
|
||||
default:
|
||||
|
@ -340,10 +337,10 @@ xmrig::Algorithm::Family xmrig::Algorithm::family(Id id)
|
|||
case RX_0:
|
||||
case RX_WOW:
|
||||
case RX_LOKI:
|
||||
case DEFYX:
|
||||
case RX_ARQ:
|
||||
case RX_SFX:
|
||||
case RX_KEVA:
|
||||
case RX_DEFYX:
|
||||
return RANDOM_X;
|
||||
# endif
|
||||
|
||||
|
|
|
@ -68,10 +68,10 @@ public:
|
|||
RX_0, // "rx/0" RandomX (reference configuration).
|
||||
RX_WOW, // "rx/wow" RandomWOW (Wownero).
|
||||
RX_LOKI, // "rx/loki" RandomXL (Loki).
|
||||
DEFYX, // "defyx" DefyX (Scala).
|
||||
RX_ARQ, // "rx/arq" RandomARQ (Arqma).
|
||||
RX_SFX, // "rx/sfx" RandomSFX (Safex Cash).
|
||||
RX_KEVA, // "rx/keva" RandomKEVA (Keva).
|
||||
RX_DEFYX, // "defyx" DefyX (Scala).
|
||||
AR2_CHUKWA, // "argon2/chukwa" Argon2id (Chukwa).
|
||||
AR2_WRKZ, // "argon2/wrkz" Argon2id (WRKZ)
|
||||
ASTROBWT_DERO, // "astrobwt" AstroBWT (Dero)
|
||||
|
|
|
@ -52,20 +52,32 @@
|
|||
namespace xmrig {
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_BENCHMARK
|
||||
const char *BaseConfig::kAlgoPerf = "algo-perf";
|
||||
#endif
|
||||
const char *BaseConfig::kApi = "api";
|
||||
const char *BaseConfig::kApiId = "id";
|
||||
const char *BaseConfig::kApiWorkerId = "worker-id";
|
||||
const char *BaseConfig::kAutosave = "autosave";
|
||||
const char *BaseConfig::kBackground = "background";
|
||||
#ifdef XMRIG_FEATURE_BENCHMARK
|
||||
const char *BaseConfig::kBenchAlgoTime = "bench-algo-time";
|
||||
#endif
|
||||
const char *BaseConfig::kColors = "colors";
|
||||
const char *BaseConfig::kDryRun = "dry-run";
|
||||
const char *BaseConfig::kHttp = "http";
|
||||
const char *BaseConfig::kLogFile = "log-file";
|
||||
const char *BaseConfig::kPrintTime = "print-time";
|
||||
#ifdef XMRIG_FEATURE_BENCHMARK
|
||||
const char *BaseConfig::kRebenchAlgo = "rebench-algo";
|
||||
#endif
|
||||
const char *BaseConfig::kSyslog = "syslog";
|
||||
const char *BaseConfig::kTitle = "title";
|
||||
const char *BaseConfig::kUserAgent = "user-agent";
|
||||
const char *BaseConfig::kVerbose = "verbose";
|
||||
#ifdef XMRIG_FEATURE_BENCHMARK
|
||||
const char *BaseConfig::kVersion = "version";
|
||||
#endif
|
||||
const char *BaseConfig::kWatch = "watch";
|
||||
|
||||
|
||||
|
@ -88,6 +100,9 @@ bool xmrig::BaseConfig::read(const IJsonReader &reader, const char *fileName)
|
|||
m_autoSave = reader.getBool(kAutosave, m_autoSave);
|
||||
m_background = reader.getBool(kBackground, m_background);
|
||||
m_dryRun = reader.getBool(kDryRun, m_dryRun);
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
m_rebenchAlgo = reader.getBool(kRebenchAlgo, m_rebenchAlgo);
|
||||
# endif
|
||||
m_syslog = reader.getBool(kSyslog, m_syslog);
|
||||
m_watch = reader.getBool(kWatch, m_watch);
|
||||
m_logFile = reader.getString(kLogFile);
|
||||
|
@ -95,14 +110,15 @@ bool xmrig::BaseConfig::read(const IJsonReader &reader, const char *fileName)
|
|||
m_printTime = std::min(reader.getUint(kPrintTime, m_printTime), 3600U);
|
||||
m_title = reader.getValue(kTitle);
|
||||
|
||||
m_rebenchAlgo = reader.getBool("rebench-algo", m_rebenchAlgo);
|
||||
m_benchAlgoTime = reader.getInt("bench-algo-time", m_benchAlgoTime);
|
||||
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
m_tls = reader.getValue(kTls);
|
||||
# endif
|
||||
|
||||
Log::setColors(reader.getBool(kColors, Log::isColors()));
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
m_version = reader.getUint(kVersion);
|
||||
m_benchAlgoTime = reader.getInt(kBenchAlgoTime, m_benchAlgoTime);
|
||||
# endif
|
||||
setVerbose(reader.getValue(kVerbose));
|
||||
|
||||
const auto &api = reader.getObject(kApi);
|
||||
|
|
|
@ -46,20 +46,32 @@ class IJsonReader;
|
|||
class BaseConfig : public IConfig
|
||||
{
|
||||
public:
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
static const char *kAlgoPerf;
|
||||
# endif
|
||||
static const char *kApi;
|
||||
static const char *kApiId;
|
||||
static const char *kApiWorkerId;
|
||||
static const char *kAutosave;
|
||||
static const char *kBackground;
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
static const char *kBenchAlgoTime;
|
||||
# endif
|
||||
static const char *kColors;
|
||||
static const char *kDryRun;
|
||||
static const char *kHttp;
|
||||
static const char *kLogFile;
|
||||
static const char *kPrintTime;
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
static const char *kRebenchAlgo;
|
||||
# endif
|
||||
static const char *kSyslog;
|
||||
static const char *kTitle;
|
||||
static const char *kUserAgent;
|
||||
static const char *kVerbose;
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
static const char *kVersion;
|
||||
# endif
|
||||
static const char *kWatch;
|
||||
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
|
@ -81,8 +93,10 @@ public:
|
|||
inline const Title &title() const { return m_title; }
|
||||
inline uint32_t printTime() const { return m_printTime; }
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
inline bool isRebenchAlgo() const { return m_rebenchAlgo; }
|
||||
inline int benchAlgoTime() const { return m_benchAlgoTime; }
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
inline const TlsConfig &tls() const { return m_tls; }
|
||||
|
@ -114,8 +128,11 @@ protected:
|
|||
Title m_title;
|
||||
uint32_t m_printTime = 60;
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
uint32_t m_version = 0;
|
||||
bool m_rebenchAlgo = false;
|
||||
int m_benchAlgoTime = 10;
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
TlsConfig m_tls;
|
||||
|
|
|
@ -235,20 +235,30 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch
|
|||
case IConfig::PrintTimeKey: /* --print-time */
|
||||
case IConfig::HttpPort: /* --http-port */
|
||||
case IConfig::DonateLevelKey: /* --donate-level */
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
case IConfig::DaemonPollKey: /* --daemon-poll-interval */
|
||||
# endif
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
case IConfig::BenchAlgoTimeKey: /* --bench-algo-time */
|
||||
# endif
|
||||
return transformUint64(doc, key, static_cast<uint64_t>(strtol(arg, nullptr, 10)));
|
||||
|
||||
case IConfig::BackgroundKey: /* --background */
|
||||
case IConfig::SyslogKey: /* --syslog */
|
||||
case IConfig::KeepAliveKey: /* --keepalive */
|
||||
case IConfig::NicehashKey: /* --nicehash */
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
case IConfig::TlsKey: /* --tls */
|
||||
# endif
|
||||
case IConfig::DryRunKey: /* --dry-run */
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
case IConfig::HttpEnabledKey: /* --http-enabled */
|
||||
case IConfig::DaemonKey: /* --daemon */
|
||||
case IConfig::RebenchAlgoKey: /* --rebench-algo */
|
||||
# endif
|
||||
case IConfig::VerboseKey: /* --verbose */
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
case IConfig::RebenchAlgoKey: /* --rebench-algo */
|
||||
# endif
|
||||
return transformBoolean(doc, key, true);
|
||||
|
||||
case IConfig::ColorKey: /* --no-color */
|
||||
|
@ -343,8 +353,10 @@ void xmrig::BaseTransform::transformUint64(rapidjson::Document &doc, int key, ui
|
|||
return add(doc, Pools::kPools, Pool::kDaemonPollInterval, arg);
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
case IConfig::BenchAlgoTimeKey: /* --bench-algo-time */
|
||||
return set(doc, "bench-algo-time", arg);
|
||||
# endif
|
||||
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -82,8 +82,10 @@ public:
|
|||
NicehashKey = 1006,
|
||||
PrintTimeKey = 1007,
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
RebenchAlgoKey = 10001,
|
||||
BenchAlgoTimeKey = 10002,
|
||||
# endif
|
||||
|
||||
// xmrig cpu
|
||||
CPUKey = 1024,
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
"restricted": true
|
||||
},
|
||||
"autosave": true,
|
||||
"rebench-algo": false,
|
||||
"bench-algo-time": 10,
|
||||
"background": false,
|
||||
"colors": true,
|
||||
"title": true,
|
||||
|
@ -92,5 +90,7 @@
|
|||
},
|
||||
"user-agent": null,
|
||||
"verbose": 0,
|
||||
"watch": true
|
||||
"watch": true,
|
||||
"rebench-algo": false,
|
||||
"bench-algo-time": 10
|
||||
}
|
||||
|
|
|
@ -26,9 +26,10 @@
|
|||
#include "net/Network.h"
|
||||
#include "rapidjson/document.h"
|
||||
#include "backend/common/interfaces/IBackend.h"
|
||||
#include "backend/common/Hashrate.h"
|
||||
#include <chrono>
|
||||
|
||||
namespace xmrig {
|
||||
namespace xmrig {
|
||||
|
||||
Benchmark::Benchmark() : m_controller(nullptr), m_isNewBenchRun(true) {
|
||||
for (BenchAlgo bench_algo = static_cast<BenchAlgo>(0); bench_algo != BenchAlgo::MAX; bench_algo = static_cast<BenchAlgo>(bench_algo + 1)) {
|
||||
|
@ -59,6 +60,7 @@ void Benchmark::finish() {
|
|||
}
|
||||
m_bench_algo = BenchAlgo::INVALID;
|
||||
m_controller->miner()->pause(); // do not compute anything before job from the pool
|
||||
JobResults::stop();
|
||||
JobResults::setListener(m_controller->network(), m_controller->config()->cpu().isHwAES());
|
||||
m_controller->start();
|
||||
}
|
||||
|
@ -104,33 +106,39 @@ void Benchmark::read(const rapidjson::Value &value)
|
|||
}
|
||||
}
|
||||
|
||||
float Benchmark::get_algo_perf(Algorithm::Id algo) const {
|
||||
double Benchmark::get_algo_perf(Algorithm::Id algo) const {
|
||||
switch (algo) {
|
||||
case Algorithm::CN_0: return m_bench_algo_perf[BenchAlgo::CN_R];
|
||||
case Algorithm::CN_CCX: return m_bench_algo_perf[BenchAlgo::CN_CCX];
|
||||
case Algorithm::CN_0: return m_bench_algo_perf[BenchAlgo::CN_CCX] / 2;
|
||||
case Algorithm::CN_1: return m_bench_algo_perf[BenchAlgo::CN_R];
|
||||
case Algorithm::CN_2: return m_bench_algo_perf[BenchAlgo::CN_R];
|
||||
case Algorithm::CN_R: return m_bench_algo_perf[BenchAlgo::CN_R];
|
||||
case Algorithm::CN_RTO: return m_bench_algo_perf[BenchAlgo::CN_R];
|
||||
case Algorithm::CN_XAO: return m_bench_algo_perf[BenchAlgo::CN_R];
|
||||
case Algorithm::CN_FAST: return m_bench_algo_perf[BenchAlgo::CN_R] * 2;
|
||||
case Algorithm::CN_HALF: return m_bench_algo_perf[BenchAlgo::CN_R] * 2;
|
||||
case Algorithm::CN_XAO: return m_bench_algo_perf[BenchAlgo::CN_R];
|
||||
case Algorithm::CN_RTO: return m_bench_algo_perf[BenchAlgo::CN_R];
|
||||
case Algorithm::CN_RWZ: return m_bench_algo_perf[BenchAlgo::CN_R] / 3 * 4;
|
||||
case Algorithm::CN_ZLS: return m_bench_algo_perf[BenchAlgo::CN_R] / 3 * 4;
|
||||
case Algorithm::CN_DOUBLE: return m_bench_algo_perf[BenchAlgo::CN_R] / 2;
|
||||
case Algorithm::CN_GPU: return m_bench_algo_perf[BenchAlgo::CN_GPU];
|
||||
case Algorithm::CN_LITE_0: return m_bench_algo_perf[BenchAlgo::CN_LITE_1];
|
||||
case Algorithm::CN_LITE_1: return m_bench_algo_perf[BenchAlgo::CN_LITE_1];
|
||||
case Algorithm::CN_HEAVY_0: return m_bench_algo_perf[BenchAlgo::CN_HEAVY_TUBE];
|
||||
case Algorithm::CN_HEAVY_TUBE: return m_bench_algo_perf[BenchAlgo::CN_HEAVY_TUBE];
|
||||
case Algorithm::CN_HEAVY_XHV: return m_bench_algo_perf[BenchAlgo::CN_HEAVY_TUBE];
|
||||
case Algorithm::CN_PICO_0: return m_bench_algo_perf[BenchAlgo::CN_PICO_0];
|
||||
case Algorithm::RX_LOKI: return m_bench_algo_perf[BenchAlgo::RX_0];
|
||||
case Algorithm::RX_WOW: return m_bench_algo_perf[BenchAlgo::RX_WOW];
|
||||
case Algorithm::RX_0: return m_bench_algo_perf[BenchAlgo::RX_0];
|
||||
case Algorithm::DEFYX: return m_bench_algo_perf[BenchAlgo::DEFYX];
|
||||
case Algorithm::RX_ARQ: return m_bench_algo_perf[BenchAlgo::RX_ARQ];
|
||||
case Algorithm::CN_PICO_TLO: return m_bench_algo_perf[BenchAlgo::CN_PICO_0];
|
||||
case Algorithm::CN_GPU: return m_bench_algo_perf[BenchAlgo::CN_GPU];
|
||||
case Algorithm::AR2_CHUKWA: return m_bench_algo_perf[BenchAlgo::AR2_CHUKWA];
|
||||
case Algorithm::AR2_WRKZ: return m_bench_algo_perf[BenchAlgo::AR2_WRKZ];
|
||||
case Algorithm::ASTROBWT_DERO: return m_bench_algo_perf[BenchAlgo::ASTROBWT_DERO];
|
||||
case Algorithm::KAWPOW_RVN: return m_bench_algo_perf[BenchAlgo::KAWPOW_RVN];
|
||||
case Algorithm::RX_0: return m_bench_algo_perf[BenchAlgo::RX_0];
|
||||
case Algorithm::RX_LOKI: return m_bench_algo_perf[BenchAlgo::RX_0];
|
||||
case Algorithm::RX_SFX: return m_bench_algo_perf[BenchAlgo::RX_0];
|
||||
case Algorithm::RX_WOW: return m_bench_algo_perf[BenchAlgo::RX_WOW];
|
||||
case Algorithm::RX_ARQ: return m_bench_algo_perf[BenchAlgo::RX_ARQ];
|
||||
case Algorithm::RX_KEVA: return m_bench_algo_perf[BenchAlgo::RX_KEVA];
|
||||
case Algorithm::RX_DEFYX: return m_bench_algo_perf[BenchAlgo::RX_DEFYX];
|
||||
default: return 0.0f;
|
||||
}
|
||||
}
|
||||
|
@ -189,9 +197,23 @@ void Benchmark::onJobResult(const JobResult& result) {
|
|||
LOG_ALERT(" ===> Starting benchmark of %s algo", Algorithm(ba2a[m_bench_algo]).shortName());
|
||||
m_bench_start = now; // time of measurements start (in ms)
|
||||
} else if (now - m_bench_start > static_cast<unsigned>(m_controller->config()->benchAlgoTime()*1000)) { // end of benchmark round for m_bench_algo
|
||||
const float hashrate = static_cast<float>(m_hash_count) * result.diff / (now - m_bench_start) * 1000.0f;
|
||||
double t[3] = { 0.0 };
|
||||
for (auto backend : m_controller->miner()->backends()) {
|
||||
const Hashrate *hr = backend->hashrate();
|
||||
if (!hr) {
|
||||
continue;
|
||||
}
|
||||
t[0] += hr->calc(Hashrate::ShortInterval);
|
||||
t[1] += hr->calc(Hashrate::MediumInterval);
|
||||
t[2] += hr->calc(Hashrate::LargeInterval);
|
||||
}
|
||||
double hashrate = 0.0f;
|
||||
if (!(hashrate = t[2]))
|
||||
if (!(hashrate = t[1]))
|
||||
if (!(hashrate = t[0]))
|
||||
hashrate = static_cast<double>(m_hash_count) * result.diff / (now - m_bench_start) * 1000.0f;
|
||||
m_bench_algo_perf[m_bench_algo] = hashrate; // store hashrate result
|
||||
LOG_ALERT(" ===> %s hasrate: %f", Algorithm(ba2a[m_bench_algo]).shortName(), hashrate);
|
||||
LOG_ALERT(" ===> %s hashrate: %f", Algorithm(ba2a[m_bench_algo]).shortName(), hashrate);
|
||||
run_next_bench_algo(m_bench_algo);
|
||||
}
|
||||
}
|
||||
|
@ -201,4 +223,4 @@ uint64_t Benchmark::get_now() const { // get current time in ms
|
|||
return time_point_cast<milliseconds>(high_resolution_clock::now()).time_since_epoch().count();
|
||||
}
|
||||
|
||||
} // namespace xmrig
|
||||
} // namespace xmrig
|
||||
|
|
|
@ -31,38 +31,46 @@ class Job;
|
|||
class Benchmark : public IJobResultListener {
|
||||
|
||||
enum BenchAlgo : int {
|
||||
AR2_CHUKWA, // "argon2/chukwa"
|
||||
RX_0, // "rx/0" RandomX (Monero).
|
||||
RX_WOW, // "rx/wow" RandomWOW (Wownero).
|
||||
DEFYX, // "defyx DefyX.
|
||||
RX_ARQ, // "rx/arq" RandomARQ (Arqma).
|
||||
CN_R, // "cn/r" CryptoNightR (Monero's variant 4).
|
||||
CN_GPU, // "cn/gpu" CryptoNight-GPU (Ryo).
|
||||
CN_LITE_1, // "cn-lite/1" CryptoNight-Lite variant 1.
|
||||
CN_HEAVY_TUBE, // "cn-heavy/tube" CryptoNight-Heavy (modified, TUBE only).
|
||||
CN_PICO_0, // "cn-pico" CryptoNight Turtle (TRTL)
|
||||
ASTROBWT_DERO, // "astrobwt" AstroBWT (Dero)
|
||||
CN_PICO_0, // "cn-pico" CryptoNight-Pico.
|
||||
CN_CCX, // "cn/ccx" Conceal (CCX).
|
||||
CN_GPU, // "cn/gpu" CryptoNight-GPU (Ryo).
|
||||
AR2_CHUKWA, // "argon2/chukwa" Argon2id (Chukwa).
|
||||
AR2_WRKZ, // "argon2/wrkz" Argon2id (WRKZ).
|
||||
ASTROBWT_DERO, // "astrobwt" AstroBWT (Dero).
|
||||
KAWPOW_RVN, // "kawpow/rvn" KawPow (RVN).
|
||||
RX_0, // "rx/0" RandomX (Monero).
|
||||
RX_WOW, // "rx/wow" RandomWOW (Wownero).
|
||||
RX_ARQ, // "rx/arq" RandomARQ (Arqma).
|
||||
RX_KEVA, // "rx/keva" RandomKEVA (Keva).
|
||||
RX_DEFYX, // "defyx DefyX.
|
||||
MAX,
|
||||
MIN = 0,
|
||||
INVALID = -1,
|
||||
};
|
||||
|
||||
const Algorithm::Id ba2a[BenchAlgo::MAX] = {
|
||||
Algorithm::AR2_CHUKWA,
|
||||
Algorithm::RX_0,
|
||||
Algorithm::RX_WOW,
|
||||
Algorithm::DEFYX,
|
||||
Algorithm::RX_ARQ,
|
||||
Algorithm::CN_R,
|
||||
Algorithm::CN_GPU,
|
||||
Algorithm::CN_LITE_1,
|
||||
Algorithm::CN_HEAVY_TUBE,
|
||||
Algorithm::CN_PICO_0,
|
||||
Algorithm::CN_CCX,
|
||||
Algorithm::CN_GPU,
|
||||
Algorithm::AR2_CHUKWA,
|
||||
Algorithm::AR2_WRKZ,
|
||||
Algorithm::ASTROBWT_DERO,
|
||||
Algorithm::KAWPOW_RVN,
|
||||
Algorithm::RX_0,
|
||||
Algorithm::RX_WOW,
|
||||
Algorithm::RX_ARQ,
|
||||
Algorithm::RX_KEVA,
|
||||
Algorithm::RX_DEFYX,
|
||||
};
|
||||
|
||||
Job* m_bench_job[BenchAlgo::MAX];
|
||||
float m_bench_algo_perf[BenchAlgo::MAX];
|
||||
double m_bench_algo_perf[BenchAlgo::MAX];
|
||||
|
||||
Controller* m_controller; // to get access to config and network
|
||||
bool m_isNewBenchRun; // true if benchmark is need to be executed or was executed
|
||||
|
@ -74,7 +82,7 @@ class Benchmark : public IJobResultListener {
|
|||
std::set<uint32_t> m_backends_started; // id of backend started for benchmark
|
||||
|
||||
uint64_t get_now() const; // get current time in ms
|
||||
float get_algo_perf(Algorithm::Id algo) const; // get algo perf based on m_bench_algo_perf
|
||||
double get_algo_perf(Algorithm::Id algo) const; // get algo perf based on m_bench_algo_perf
|
||||
void start(const Benchmark::BenchAlgo); // start benchmark for specified perf algo
|
||||
void finish(); // end of benchmarks, switch to jobs from the pool (network), fill algo_perf
|
||||
void onJobResult(const JobResult&) override; // onJobResult is called after each computed benchmark hash
|
||||
|
@ -89,7 +97,7 @@ class Benchmark : public IJobResultListener {
|
|||
void start(); // start benchmarks
|
||||
|
||||
bool isNewBenchRun() const { return m_isNewBenchRun; }
|
||||
float algo_perf[Algorithm::MAX];
|
||||
double algo_perf[Algorithm::MAX];
|
||||
|
||||
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
||||
void read(const rapidjson::Value &value);
|
||||
|
|
|
@ -59,15 +59,20 @@ int xmrig::Controller::init()
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef XMRIG_FEATURE_BENCHMARK
|
||||
void xmrig::Controller::pre_start()
|
||||
{
|
||||
m_miner = new Miner(this);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void xmrig::Controller::start()
|
||||
{
|
||||
Base::start();
|
||||
#ifndef XMRIG_FEATURE_BENCHMARK
|
||||
m_miner = new Miner(this);
|
||||
#endif
|
||||
network()->connect();
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,9 @@ public:
|
|||
~Controller() override;
|
||||
|
||||
int init() override;
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
void pre_start();
|
||||
# endif
|
||||
void start() override;
|
||||
void stop() override;
|
||||
|
||||
|
|
|
@ -166,7 +166,13 @@ bool xmrig::Config::isShouldSave() const
|
|||
}
|
||||
# endif
|
||||
|
||||
return (m_upgrade || cpu().isShouldSave() || m_benchmark.isNewBenchRun());
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
if (m_benchmark.isNewBenchRun()) {
|
||||
return true;
|
||||
}
|
||||
# endif
|
||||
|
||||
return (m_upgrade || cpu().isShouldSave());
|
||||
}
|
||||
|
||||
|
||||
|
@ -177,7 +183,6 @@ bool xmrig::Config::read(const IJsonReader &reader, const char *fileName)
|
|||
}
|
||||
|
||||
d_ptr->cpu.read(reader.getValue(kCPU));
|
||||
m_benchmark.read(reader.getValue("algo-perf"));
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
if (!d_ptr->rx.read(reader.getValue(kRandomX))) {
|
||||
|
@ -197,6 +202,10 @@ bool xmrig::Config::read(const IJsonReader &reader, const char *fileName)
|
|||
d_ptr->healthPrintTime = reader.getUint(kHealthPrintTime, d_ptr->healthPrintTime);
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
m_benchmark.read(reader.getValue(kAlgoPerf));
|
||||
# endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -254,7 +263,9 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
|
|||
doc.AddMember(StringRef(kVerbose), Log::verbose(), allocator);
|
||||
doc.AddMember(StringRef(kWatch), m_watch, allocator);
|
||||
|
||||
doc.AddMember("algo-perf", m_benchmark.toJSON(doc), allocator);
|
||||
doc.AddMember("rebench-algo", isRebenchAlgo(), allocator);
|
||||
doc.AddMember("bench-algo-time", benchAlgoTime(), allocator);
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
doc.AddMember(StringRef(kRebenchAlgo), isRebenchAlgo(), allocator);
|
||||
doc.AddMember(StringRef(kBenchAlgoTime), benchAlgoTime(), allocator);
|
||||
doc.AddMember(StringRef(kAlgoPerf), m_benchmark.toJSON(doc), allocator);
|
||||
# endif
|
||||
}
|
||||
|
|
|
@ -33,7 +33,9 @@
|
|||
#include "backend/cpu/CpuConfig.h"
|
||||
#include "base/kernel/config/BaseConfig.h"
|
||||
#include "base/tools/Object.h"
|
||||
#ifdef XMRIG_FEATURE_BENCHMARK
|
||||
#include "core/Benchmark.h"
|
||||
#endif
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
@ -59,7 +61,6 @@ public:
|
|||
# ifdef XMRIG_FEATURE_OPENCL
|
||||
const OclConfig &cl() const;
|
||||
# endif
|
||||
inline Benchmark &benchmark() { return m_benchmark; }
|
||||
|
||||
# ifdef XMRIG_FEATURE_CUDA
|
||||
const CudaConfig &cuda() const;
|
||||
|
@ -79,9 +80,15 @@ public:
|
|||
bool read(const IJsonReader &reader, const char *fileName) override;
|
||||
void getJSON(rapidjson::Document &doc) const override;
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
inline Benchmark &benchmark() { return m_benchmark; }
|
||||
# endif
|
||||
|
||||
private:
|
||||
ConfigPrivate *d_ptr;
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
Benchmark m_benchmark;
|
||||
# endif
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1,134 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2018-2019, tevador <tevador@gmail.com>
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the copyright holder nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "defyx.h"
|
||||
#include "crypto/randomx/blake2/blake2.h"
|
||||
#include "crypto/randomx/vm_interpreted.hpp"
|
||||
#include "crypto/randomx/vm_interpreted_light.hpp"
|
||||
#include "crypto/randomx/vm_compiled.hpp"
|
||||
#include "crypto/randomx/vm_compiled_light.hpp"
|
||||
#include "crypto/randomx/jit_compiler_x86_static.hpp"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
extern "C" {
|
||||
#include "yescrypt.h"
|
||||
#include "KangarooTwelve.h"
|
||||
}
|
||||
|
||||
#define YESCRYPT_FLAGS YESCRYPT_RW
|
||||
#define YESCRYPT_BASE_N 2048
|
||||
#define YESCRYPT_R 8
|
||||
#define YESCRYPT_P 1
|
||||
|
||||
RandomX_ConfigurationScala::RandomX_ConfigurationScala()
|
||||
{
|
||||
ArgonMemory = 131072;
|
||||
ArgonIterations = 2;
|
||||
ArgonSalt = "DefyXScala\x13";
|
||||
CacheAccesses = 2;
|
||||
DatasetBaseSize = 33554432;
|
||||
ProgramSize = 64;
|
||||
ProgramIterations = 1024;
|
||||
ProgramCount = 4;
|
||||
ScratchpadL3_Size = 262144;
|
||||
ScratchpadL2_Size = 131072;
|
||||
ScratchpadL1_Size = 65536;
|
||||
|
||||
RANDOMX_FREQ_IADD_RS = 25;
|
||||
RANDOMX_FREQ_CBRANCH = 16;
|
||||
}
|
||||
|
||||
RandomX_ConfigurationScala RandomX_ScalaConfig;
|
||||
|
||||
int sipesh(void *out, size_t outlen, const void *in, size_t inlen, const void *salt, size_t saltlen, unsigned int t_cost, unsigned int m_cost)
|
||||
{
|
||||
yescrypt_local_t local;
|
||||
int retval;
|
||||
|
||||
if (yescrypt_init_local(&local))
|
||||
return -1;
|
||||
retval = yescrypt_kdf(NULL, &local, (const uint8_t*)in, inlen, (const uint8_t*)salt, saltlen,
|
||||
(uint64_t)YESCRYPT_BASE_N << m_cost, YESCRYPT_R, YESCRYPT_P,
|
||||
t_cost, 0, YESCRYPT_FLAGS, (uint8_t*)out, outlen);
|
||||
if (yescrypt_free_local(&local))
|
||||
return -1;
|
||||
return retval;
|
||||
}
|
||||
|
||||
int k12(const void *data, size_t length, void *hash)
|
||||
{
|
||||
|
||||
int kDo = KangarooTwelve((const unsigned char *)data, length, (unsigned char *)hash, 32, 0, 0);
|
||||
return kDo;
|
||||
}
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
void defyx_calculate_hash(randomx_vm *machine, const void *input, size_t inputSize, void *output) {
|
||||
assert(machine != nullptr);
|
||||
assert(inputSize == 0 || input != nullptr);
|
||||
assert(output != nullptr);
|
||||
alignas(16) uint64_t tempHash[8];
|
||||
//rx_blake2b(tempHash, sizeof(tempHash), input, inputSize, nullptr, 0);
|
||||
sipesh(tempHash, sizeof(tempHash), input, inputSize, input, inputSize, 0, 0);
|
||||
k12(input, inputSize, tempHash);
|
||||
machine->initScratchpad(&tempHash);
|
||||
machine->resetRoundingMode();
|
||||
for (uint32_t chain = 0; chain < RandomX_CurrentConfig.ProgramCount - 1; ++chain) {
|
||||
machine->run(&tempHash);
|
||||
rx_blake2b(tempHash, sizeof(tempHash), machine->getRegisterFile(), sizeof(randomx::RegisterFile), nullptr, 0);
|
||||
}
|
||||
machine->run(&tempHash);
|
||||
machine->getFinalResult(output, RANDOMX_HASH_SIZE);
|
||||
}
|
||||
|
||||
void defyx_calculate_hash_first(randomx_vm* machine, uint64_t (&tempHash)[8], const void* input, size_t inputSize) {
|
||||
//rx_blake2b(tempHash, sizeof(tempHash), input, inputSize, nullptr, 0);
|
||||
sipesh(tempHash, sizeof(tempHash), input, inputSize, input, inputSize, 0, 0);
|
||||
k12(input, inputSize, tempHash);
|
||||
machine->initScratchpad(tempHash);
|
||||
}
|
||||
|
||||
void defyx_calculate_hash_next(randomx_vm* machine, uint64_t (&tempHash)[8], const void* nextInput, size_t nextInputSize, void* output) {
|
||||
machine->resetRoundingMode();
|
||||
for (uint32_t chain = 0; chain < RandomX_CurrentConfig.ProgramCount - 1; ++chain) {
|
||||
machine->run(&tempHash);
|
||||
rx_blake2b(tempHash, sizeof(tempHash), machine->getRegisterFile(), sizeof(randomx::RegisterFile), nullptr, 0);
|
||||
}
|
||||
machine->run(&tempHash);
|
||||
|
||||
// Finish current hash and fill the scratchpad for the next hash at the same time
|
||||
//rx_blake2b(tempHash, sizeof(tempHash), nextInput, nextInputSize, nullptr, 0);
|
||||
sipesh(tempHash, sizeof(tempHash), nextInput, nextInputSize, nextInput, nextInputSize, 0, 0);
|
||||
k12(nextInput, nextInputSize, tempHash);
|
||||
machine->hashAndFill(output, RANDOMX_HASH_SIZE, tempHash);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2018-2019, tevador <tevador@gmail.com>
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the copyright holder nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef DEFYX_H
|
||||
#define DEFYX_H
|
||||
|
||||
#include "crypto/randomx/randomx.h"
|
||||
|
||||
struct RandomX_ConfigurationScala : public RandomX_ConfigurationBase { RandomX_ConfigurationScala(); };
|
||||
|
||||
extern RandomX_ConfigurationScala RandomX_ScalaConfig;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Calculates a RandomX hash value.
|
||||
*
|
||||
* @param machine is a pointer to a randomx_vm structure. Must not be NULL.
|
||||
* @param input is a pointer to memory to be hashed. Must not be NULL.
|
||||
* @param inputSize is the number of bytes to be hashed.
|
||||
* @param output is a pointer to memory where the hash will be stored. Must not
|
||||
* be NULL and at least RANDOMX_HASH_SIZE bytes must be available for writing.
|
||||
*/
|
||||
RANDOMX_EXPORT void defyx_calculate_hash(randomx_vm *machine, const void *input, size_t inputSize, void *output);
|
||||
|
||||
RANDOMX_EXPORT void defyx_calculate_hash_first(randomx_vm* machine, uint64_t (&tempHash)[8], const void* input, size_t inputSize);
|
||||
RANDOMX_EXPORT void defyx_calculate_hash_next(randomx_vm* machine, uint64_t (&tempHash)[8], const void* nextInput, size_t nextInputSize, void* output);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -47,6 +47,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <cassert>
|
||||
|
||||
extern "C" {
|
||||
#include "crypto/defyx/yescrypt.h"
|
||||
#include "crypto/defyx/KangarooTwelve.h"
|
||||
}
|
||||
#define YESCRYPT_FLAGS YESCRYPT_RW
|
||||
#define YESCRYPT_BASE_N 2048
|
||||
#define YESCRYPT_R 8
|
||||
#define YESCRYPT_P 1
|
||||
|
||||
RandomX_ConfigurationWownero::RandomX_ConfigurationWownero()
|
||||
{
|
||||
ArgonSalt = "RandomWOW\x01";
|
||||
|
@ -108,6 +117,24 @@ RandomX_ConfigurationKeva::RandomX_ConfigurationKeva()
|
|||
ScratchpadL3_Size = 1048576;
|
||||
}
|
||||
|
||||
RandomX_ConfigurationScala::RandomX_ConfigurationScala()
|
||||
{
|
||||
ArgonMemory = 131072;
|
||||
ArgonIterations = 2;
|
||||
ArgonSalt = "DefyXScala\x13";
|
||||
CacheAccesses = 2;
|
||||
DatasetBaseSize = 33554432;
|
||||
ScratchpadL1_Size = 65536;
|
||||
ScratchpadL2_Size = 131072;
|
||||
ScratchpadL3_Size = 262144;
|
||||
ProgramSize = 64;
|
||||
ProgramIterations = 1024;
|
||||
ProgramCount = 4;
|
||||
|
||||
RANDOMX_FREQ_IADD_RS = 25;
|
||||
RANDOMX_FREQ_CBRANCH = 16;
|
||||
}
|
||||
|
||||
RandomX_ConfigurationBase::RandomX_ConfigurationBase()
|
||||
: ArgonMemory(262144)
|
||||
, ArgonIterations(3)
|
||||
|
@ -311,11 +338,37 @@ RandomX_ConfigurationLoki RandomX_LokiConfig;
|
|||
RandomX_ConfigurationArqma RandomX_ArqmaConfig;
|
||||
RandomX_ConfigurationSafex RandomX_SafexConfig;
|
||||
RandomX_ConfigurationKeva RandomX_KevaConfig;
|
||||
RandomX_ConfigurationScala RandomX_ScalaConfig;
|
||||
|
||||
alignas(64) RandomX_ConfigurationBase RandomX_CurrentConfig;
|
||||
|
||||
static std::mutex vm_pool_mutex;
|
||||
|
||||
int sipesh(void *out, size_t outlen, const void *in, size_t inlen)
|
||||
{
|
||||
const void *salt = in;
|
||||
size_t saltlen = inlen;
|
||||
unsigned int t_cost = 0;
|
||||
unsigned int m_cost = 0;
|
||||
yescrypt_local_t local;
|
||||
int retval;
|
||||
|
||||
if (yescrypt_init_local(&local))
|
||||
return -1;
|
||||
retval = yescrypt_kdf(NULL, &local, (const uint8_t*)in, inlen, (const uint8_t*)salt, saltlen,
|
||||
(uint64_t)YESCRYPT_BASE_N << m_cost, YESCRYPT_R, YESCRYPT_P,
|
||||
t_cost, 0, YESCRYPT_FLAGS, (uint8_t*)out, outlen);
|
||||
if (yescrypt_free_local(&local))
|
||||
return -1;
|
||||
return retval;
|
||||
}
|
||||
|
||||
int k12(void *hash, const void *data, size_t length)
|
||||
{
|
||||
int kDo = KangarooTwelve((const unsigned char *)data, length, (unsigned char *)hash, 32, 0, 0);
|
||||
return kDo;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
randomx_cache *randomx_create_cache(randomx_flags flags, uint8_t *memory) {
|
||||
|
@ -550,4 +603,40 @@ extern "C" {
|
|||
machine->hashAndFill(output, RANDOMX_HASH_SIZE, tempHash);
|
||||
}
|
||||
|
||||
void defyx_calculate_hash(randomx_vm *machine, const void *input, size_t inputSize, void *output) {
|
||||
assert(machine != nullptr);
|
||||
assert(inputSize == 0 || input != nullptr);
|
||||
assert(output != nullptr);
|
||||
alignas(16) uint64_t tempHash[8];
|
||||
sipesh(tempHash, sizeof(tempHash), input, inputSize);
|
||||
k12(tempHash, input, inputSize);
|
||||
machine->initScratchpad(&tempHash);
|
||||
machine->resetRoundingMode();
|
||||
for (uint32_t chain = 0; chain < RandomX_CurrentConfig.ProgramCount - 1; ++chain) {
|
||||
machine->run(&tempHash);
|
||||
rx_blake2b(tempHash, sizeof(tempHash), machine->getRegisterFile(), sizeof(randomx::RegisterFile), nullptr, 0);
|
||||
}
|
||||
machine->run(&tempHash);
|
||||
machine->getFinalResult(output, RANDOMX_HASH_SIZE);
|
||||
}
|
||||
|
||||
void defyx_calculate_hash_first(randomx_vm* machine, uint64_t (&tempHash)[8], const void* input, size_t inputSize) {
|
||||
sipesh(tempHash, sizeof(tempHash), input, inputSize);
|
||||
k12(tempHash, input, inputSize);
|
||||
machine->initScratchpad(tempHash);
|
||||
}
|
||||
|
||||
void defyx_calculate_hash_next(randomx_vm* machine, uint64_t (&tempHash)[8], const void* nextInput, size_t nextInputSize, void* output) {
|
||||
machine->resetRoundingMode();
|
||||
for (uint32_t chain = 0; chain < RandomX_CurrentConfig.ProgramCount - 1; ++chain) {
|
||||
machine->run(&tempHash);
|
||||
rx_blake2b(tempHash, sizeof(tempHash), machine->getRegisterFile(), sizeof(randomx::RegisterFile), nullptr, 0);
|
||||
}
|
||||
machine->run(&tempHash);
|
||||
|
||||
// Finish current hash and fill the scratchpad for the next hash at the same time
|
||||
sipesh(tempHash, sizeof(tempHash), nextInput, nextInputSize);
|
||||
k12(tempHash, nextInput, nextInputSize);
|
||||
machine->hashAndFill(output, RANDOMX_HASH_SIZE, tempHash);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -184,6 +184,7 @@ struct RandomX_ConfigurationLoki : public RandomX_ConfigurationBase { RandomX_Co
|
|||
struct RandomX_ConfigurationArqma : public RandomX_ConfigurationBase { RandomX_ConfigurationArqma(); };
|
||||
struct RandomX_ConfigurationSafex : public RandomX_ConfigurationBase { RandomX_ConfigurationSafex(); };
|
||||
struct RandomX_ConfigurationKeva : public RandomX_ConfigurationBase { RandomX_ConfigurationKeva(); };
|
||||
struct RandomX_ConfigurationScala : public RandomX_ConfigurationBase { RandomX_ConfigurationScala(); };
|
||||
|
||||
extern RandomX_ConfigurationMonero RandomX_MoneroConfig;
|
||||
extern RandomX_ConfigurationWownero RandomX_WowneroConfig;
|
||||
|
@ -191,6 +192,7 @@ extern RandomX_ConfigurationLoki RandomX_LokiConfig;
|
|||
extern RandomX_ConfigurationArqma RandomX_ArqmaConfig;
|
||||
extern RandomX_ConfigurationSafex RandomX_SafexConfig;
|
||||
extern RandomX_ConfigurationKeva RandomX_KevaConfig;
|
||||
extern RandomX_ConfigurationScala RandomX_ScalaConfig;
|
||||
|
||||
extern RandomX_ConfigurationBase RandomX_CurrentConfig;
|
||||
|
||||
|
@ -350,6 +352,20 @@ RANDOMX_EXPORT void randomx_calculate_hash(randomx_vm *machine, const void *inpu
|
|||
RANDOMX_EXPORT void randomx_calculate_hash_first(randomx_vm* machine, uint64_t (&tempHash)[8], const void* input, size_t inputSize);
|
||||
RANDOMX_EXPORT void randomx_calculate_hash_next(randomx_vm* machine, uint64_t (&tempHash)[8], const void* nextInput, size_t nextInputSize, void* output);
|
||||
|
||||
/**
|
||||
* Calculates a RandomX hash value (Scala variant).
|
||||
*
|
||||
* @param machine is a pointer to a randomx_vm structure. Must not be NULL.
|
||||
* @param input is a pointer to memory to be hashed. Must not be NULL.
|
||||
* @param inputSize is the number of bytes to be hashed.
|
||||
* @param output is a pointer to memory where the hash will be stored. Must not
|
||||
* be NULL and at least RANDOMX_HASH_SIZE bytes must be available for writing.
|
||||
*/
|
||||
RANDOMX_EXPORT void defyx_calculate_hash(randomx_vm *machine, const void *input, size_t inputSize, void *output);
|
||||
|
||||
RANDOMX_EXPORT void defyx_calculate_hash_first(randomx_vm* machine, uint64_t (&tempHash)[8], const void* input, size_t inputSize);
|
||||
RANDOMX_EXPORT void defyx_calculate_hash_next(randomx_vm* machine, uint64_t (&tempHash)[8], const void* nextInput, size_t nextInputSize, void* output);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
|
||||
#include "crypto/randomx/randomx.h"
|
||||
#include "crypto/defyx/defyx.h"
|
||||
#include "crypto/rx/RxAlgo.h"
|
||||
|
||||
|
||||
|
@ -50,16 +49,15 @@ const RandomX_ConfigurationBase *xmrig::RxAlgo::base(Algorithm::Id algorithm)
|
|||
case Algorithm::RX_ARQ:
|
||||
return &RandomX_ArqmaConfig;
|
||||
|
||||
case Algorithm::DEFYX:
|
||||
return &RandomX_ScalaConfig;
|
||||
break;
|
||||
|
||||
case Algorithm::RX_SFX:
|
||||
return &RandomX_SafexConfig;
|
||||
|
||||
case Algorithm::RX_KEVA:
|
||||
return &RandomX_KevaConfig;
|
||||
|
||||
case Algorithm::RX_DEFYX:
|
||||
return &RandomX_ScalaConfig;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -318,7 +318,7 @@ void xmrig::JobResults::done(const Job &job)
|
|||
|
||||
void xmrig::JobResults::setListener(IJobResultListener *listener, bool hwAES)
|
||||
{
|
||||
//assert(handler == nullptr);
|
||||
assert(handler == nullptr);
|
||||
|
||||
handler = new JobResultsPrivate(listener, hwAES);
|
||||
}
|
||||
|
|
|
@ -175,13 +175,17 @@ void xmrig::Network::onLogin(IStrategy *, IClient *client, rapidjson::Document &
|
|||
|
||||
params.AddMember("algo", algo, allocator);
|
||||
|
||||
Value algo_perf(kObjectType);
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
if (strstr(client->pool().host(), "moneroocean.stream")) {
|
||||
Value algo_perf(kObjectType);
|
||||
|
||||
for (const auto &a : algorithms) {
|
||||
algo_perf.AddMember(StringRef(a.shortName()), m_controller->config()->benchmark().algo_perf[a.id()], allocator);
|
||||
for (const auto &a : algorithms) {
|
||||
algo_perf.AddMember(StringRef(a.shortName()), m_controller->config()->benchmark().algo_perf[a.id()], allocator);
|
||||
}
|
||||
|
||||
params.AddMember("algo-perf", algo_perf, allocator);
|
||||
}
|
||||
|
||||
params.AddMember("algo-perf", algo_perf, allocator);
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue