mirror of
https://github.com/xmrig/xmrig.git
synced 2025-12-07 07:55:04 -05:00
Compare commits
40 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a9965c5580 | ||
|
|
dca6d3f1ff | ||
|
|
91979dc4dd | ||
|
|
87195ed237 | ||
|
|
d557fe7f39 | ||
|
|
13ee9d09a8 | ||
|
|
f16d1837f8 | ||
|
|
096b09bf4d | ||
|
|
bbcf8e2be3 | ||
|
|
fb9d2b9e7c | ||
|
|
58711aa666 | ||
|
|
c7236d2cf0 | ||
|
|
25da0cba57 | ||
|
|
fb721edc20 | ||
|
|
d2a4fa367a | ||
|
|
8686e08336 | ||
|
|
09b68f3cdb | ||
|
|
05a2054057 | ||
|
|
4e59f90495 | ||
|
|
19f0476efb | ||
|
|
edf7885172 | ||
|
|
6cd7f3e053 | ||
|
|
f1ae81c6ae | ||
|
|
8cbf90d35b | ||
|
|
48eaf11026 | ||
|
|
75f18c9b31 | ||
|
|
302fe70f6b | ||
|
|
a2a0defeef | ||
|
|
e2ea11ffeb | ||
|
|
d8f9501ac8 | ||
|
|
12a1365b5d | ||
|
|
8f3a2a63ba | ||
|
|
f7f07ce42c | ||
|
|
c1d99bfa09 | ||
|
|
be8245fc92 | ||
|
|
926871cbe1 | ||
|
|
ee677ef5c9 | ||
|
|
c10ec90b60 | ||
|
|
0d3c2752c9 | ||
|
|
eaa44a1547 |
15
CHANGELOG.md
15
CHANGELOG.md
@@ -1,3 +1,18 @@
|
||||
# v6.6.2
|
||||
- [#1958](https://github.com/xmrig/xmrig/pull/1958) Added example mining scripts to help new miners.
|
||||
- [#1959](https://github.com/xmrig/xmrig/pull/1959) Optimized JIT compiler.
|
||||
- [#1960](https://github.com/xmrig/xmrig/pull/1960) Fixed RandomX init when switching to other algo and back.
|
||||
|
||||
# v6.6.1
|
||||
- Fixed, benchmark validation on NUMA hardware produced incorrect results in some conditions.
|
||||
|
||||
# v6.6.0
|
||||
- Online benchmark protocol upgraded to v2, validation not compatible with previous versions.
|
||||
- Single thread benchmark now is cheat-resistant, not possible speedup it with multiple threads.
|
||||
- RandomX dataset is now always initialized with static seed, to prevent time cheat by report slow dataset initialization.
|
||||
- Zero delay online submission, to make time validation much more precise and strict.
|
||||
- DNS cache for online benchmark to prevent unexpected delays.
|
||||
|
||||
# v6.5.3
|
||||
- [#1946](https://github.com/xmrig/xmrig/pull/1946) Fixed MSR mod names in JSON API (v6.5.2 affected).
|
||||
|
||||
|
||||
@@ -212,6 +212,8 @@ if (WIN32)
|
||||
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/bin/WinRing0/WinRing0x64.sys" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>)
|
||||
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/scripts/benchmark_1M.cmd" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>)
|
||||
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/scripts/benchmark_10M.cmd" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>)
|
||||
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/scripts/pool_mine_example.cmd" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>)
|
||||
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/scripts/solo_mine_example.cmd" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>)
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES Clang AND CMAKE_BUILD_TYPE STREQUAL Release)
|
||||
|
||||
19
scripts/pool_mine_example.cmd
Normal file
19
scripts/pool_mine_example.cmd
Normal file
@@ -0,0 +1,19 @@
|
||||
:: Example batch file for mining Monero at a pool
|
||||
::
|
||||
:: Format:
|
||||
:: xmrig.exe -o <pool address>:<pool port> -u <pool username/wallet> -p <pool password>
|
||||
::
|
||||
:: Fields:
|
||||
:: pool address The host name of the pool stratum or its IP address, for example pool.hashvault.pro
|
||||
:: pool port The port of the pool's stratum to connect to, for example 3333. Check your pool's getting started page.
|
||||
:: pool username/wallet For most pools, this is the wallet address you want to mine to. Some pools require a username
|
||||
:: pool password For most pools this can be just 'x'. For pools using usernames, you may need to provide a password as configured on the pool.
|
||||
::
|
||||
:: List of Monero mining pools:
|
||||
:: https://miningpoolstats.stream/monero
|
||||
::
|
||||
:: Choose pools outside of top 5 to help Monero network be more decentralized!
|
||||
:: Smaller pools also often have smaller fees/payout limits.
|
||||
|
||||
xmrig.exe -o pool.hashvault.pro:3333 -u 48edfHu7V9Z84YzzMa6fUueoELZ9ZRXq9VetWzYGzKt52XU5xvqgzYnDK9URnRoJMk1j8nLwEVsaSWJ4fhdUyZijBGUicoD -p x
|
||||
pause
|
||||
15
scripts/solo_mine_example.cmd
Normal file
15
scripts/solo_mine_example.cmd
Normal file
@@ -0,0 +1,15 @@
|
||||
:: Example batch file for mining Monero solo
|
||||
::
|
||||
:: Format:
|
||||
:: xmrig.exe -o <node address>:<node port> -a rx/0 -u <wallet address> --daemon
|
||||
::
|
||||
:: Fields:
|
||||
:: node address The host name of your monerod node or its IP address. It can also be a public node with RPC enabled, for example node.xmr.to
|
||||
:: node port The RPC port of your monerod node to connect to, usually 18081.
|
||||
:: wallet address Check your Monero CLI or GUI wallet to see your wallet's address.
|
||||
::
|
||||
:: Mining solo is the best way to help Monero network be more decentralized!
|
||||
:: But you will only get a payout when you find a block which can take more than a year for a single low-end PC.
|
||||
|
||||
xmrig.exe -o node.xmr.to:18081 -a rx/0 -u 48edfHu7V9Z84YzzMa6fUueoELZ9ZRXq9VetWzYGzKt52XU5xvqgzYnDK9URnRoJMk1j8nLwEVsaSWJ4fhdUyZijBGUicoD --daemon
|
||||
pause
|
||||
@@ -1,244 +0,0 @@
|
||||
/* XMRig
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "backend/common/Benchmark.h"
|
||||
#include "3rdparty/fmt/core.h"
|
||||
#include "backend/common/interfaces/IBackend.h"
|
||||
#include "backend/common/interfaces/IWorker.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/io/log/Tags.h"
|
||||
#include "base/net/http/Fetch.h"
|
||||
#include "base/net/http/HttpData.h"
|
||||
#include "base/net/http/HttpListener.h"
|
||||
#include "base/net/stratum/benchmark/BenchConfig.h"
|
||||
#include "base/net/stratum/Job.h"
|
||||
#include "base/tools/Chrono.h"
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
static const std::map<int, std::map<uint32_t, uint64_t> > hashCheck = {
|
||||
{ Algorithm::RX_0, {
|
||||
{ 250000U, 0x7D6054757BB08A63ULL },
|
||||
{ 500000U, 0x96607546DE1F5ECCULL },
|
||||
{ 1000000U, 0x898B6E0431C28A6BULL },
|
||||
{ 2000000U, 0xEE9468F8B40926BCULL },
|
||||
{ 3000000U, 0xC2BC5D11724813C0ULL },
|
||||
{ 4000000U, 0x3A2C7B285B87F941ULL },
|
||||
{ 5000000U, 0x3B5BD2C3A16B450EULL },
|
||||
{ 6000000U, 0x5CD0602F20C5C7C4ULL },
|
||||
{ 7000000U, 0x101DE939474B6812ULL },
|
||||
{ 8000000U, 0x52B765A1B156C6ECULL },
|
||||
{ 9000000U, 0x323935102AB6B45CULL },
|
||||
{ 10000000U, 0xB5231262E2792B26ULL }
|
||||
}},
|
||||
{ Algorithm::RX_WOW, {
|
||||
{ 250000U, 0xC7F712C9603E2603ULL },
|
||||
{ 500000U, 0x21A0E5AAE6DA7D8DULL },
|
||||
{ 1000000U, 0x0F3E5400B39EA96AULL },
|
||||
{ 2000000U, 0x85944CCFA2752D1FULL },
|
||||
{ 3000000U, 0x64AFFCAE991811BAULL },
|
||||
{ 4000000U, 0x3E4D0B836D3B13BAULL },
|
||||
{ 5000000U, 0xEB7417D621271166ULL },
|
||||
{ 6000000U, 0x97FFE10C0949FFA5ULL },
|
||||
{ 7000000U, 0x84CAC0F8879A4BA1ULL },
|
||||
{ 8000000U, 0xA1B79F031DA2459FULL },
|
||||
{ 9000000U, 0x9B65226DA873E65DULL },
|
||||
{ 10000000U, 0x0F9E00C5A511C200ULL }
|
||||
}}
|
||||
};
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
xmrig::Benchmark::Benchmark(const Job &job, size_t workers, const IBackend *backend) :
|
||||
m_algo(job.algorithm()),
|
||||
m_backend(backend),
|
||||
m_workers(workers),
|
||||
m_id(job.id()),
|
||||
m_token(job.benchToken()),
|
||||
m_end(job.benchSize()),
|
||||
m_hash(job.benchHash())
|
||||
{
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
if (!m_token.isEmpty()) {
|
||||
m_httpListener = std::make_shared<HttpListener>(this, Tags::bench());
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::Benchmark::finish(uint64_t totalHashCount)
|
||||
{
|
||||
m_reset = true;
|
||||
m_current = totalHashCount;
|
||||
|
||||
if (m_done < m_workers) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const double dt = static_cast<double>(m_doneTime - m_startTime) / 1000.0;
|
||||
uint64_t checkData = referenceHash();
|
||||
const char *color = checkData ? ((m_data == checkData) ? GREEN_BOLD_S : RED_BOLD_S) : BLACK_BOLD_S;
|
||||
|
||||
LOG_NOTICE("%s " WHITE_BOLD("benchmark finished in ") CYAN_BOLD("%.3f seconds") WHITE_BOLD_S " hash sum = " CLEAR "%s%016" PRIX64 CLEAR, Tags::bench(), dt, color, m_data);
|
||||
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
if (!m_token.isEmpty()) {
|
||||
using namespace rapidjson;
|
||||
|
||||
Document doc(kObjectType);
|
||||
auto &allocator = doc.GetAllocator();
|
||||
|
||||
doc.AddMember("steady_done_ts", m_doneTime, allocator);
|
||||
doc.AddMember(StringRef(BenchConfig::kHash), Value(fmt::format("{:016X}", m_data).c_str(), allocator), allocator);
|
||||
doc.AddMember("backend", m_backend->toJSON(doc), allocator);
|
||||
|
||||
send(doc);
|
||||
}
|
||||
else
|
||||
# endif
|
||||
{
|
||||
printExit();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Benchmark::start()
|
||||
{
|
||||
m_startTime = Chrono::steadyMSecs();
|
||||
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
if (!m_token.isEmpty()) {
|
||||
using namespace rapidjson;
|
||||
|
||||
Document doc(kObjectType);
|
||||
doc.AddMember("steady_start_ts", m_startTime, doc.GetAllocator());
|
||||
|
||||
send(doc);
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Benchmark::printProgress() const
|
||||
{
|
||||
if (!m_startTime || !m_current) {
|
||||
return;
|
||||
}
|
||||
|
||||
const double dt = static_cast<double>(Chrono::steadyMSecs() - m_startTime) / 1000.0;
|
||||
const double percent = static_cast<double>(m_current) / m_end * 100.0;
|
||||
|
||||
LOG_NOTICE("%s " MAGENTA_BOLD("%5.2f%% ") CYAN_BOLD("%" PRIu64) CYAN("/%" PRIu64) BLACK_BOLD(" (%.3fs)"), Tags::bench(), percent, m_current, m_end, dt);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Benchmark::tick(IWorker *worker)
|
||||
{
|
||||
if (m_reset) {
|
||||
m_data = 0;
|
||||
m_done = 0;
|
||||
m_reset = false;
|
||||
}
|
||||
|
||||
const uint64_t doneTime = worker->benchDoneTime();
|
||||
if (!doneTime) {
|
||||
return;
|
||||
}
|
||||
|
||||
++m_done;
|
||||
m_data ^= worker->benchData();
|
||||
m_doneTime = std::max(doneTime, m_doneTime);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Benchmark::onHttpData(const HttpData &data)
|
||||
{
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
rapidjson::Document doc;
|
||||
|
||||
try {
|
||||
doc = data.json();
|
||||
} catch (const std::exception &ex) {
|
||||
return setError(ex.what());
|
||||
}
|
||||
|
||||
if (data.status != 200) {
|
||||
return setError(data.statusName());
|
||||
}
|
||||
|
||||
if (m_doneTime) {
|
||||
LOG_NOTICE("%s " WHITE_BOLD("benchmark submitted ") CYAN_BOLD("https://xmrig.com/benchmark/%s"), Tags::bench(), m_id.data());
|
||||
printExit();
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
uint64_t xmrig::Benchmark::referenceHash() const
|
||||
{
|
||||
if (m_hash) {
|
||||
return m_hash;
|
||||
}
|
||||
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
if (!m_token.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
# endif
|
||||
|
||||
uint64_t hash = 0;
|
||||
|
||||
try {
|
||||
hash = hashCheck.at(m_algo).at(m_end);
|
||||
} catch (const std::exception &ex) {}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Benchmark::printExit()
|
||||
{
|
||||
LOG_INFO("%s " WHITE_BOLD("press ") MAGENTA_BOLD("Ctrl+C") WHITE_BOLD(" to exit"), Tags::bench());
|
||||
}
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_HTTP
|
||||
void xmrig::Benchmark::send(const rapidjson::Value &body)
|
||||
{
|
||||
FetchRequest req(HTTP_PATCH, BenchConfig::kApiHost, BenchConfig::kApiPort, fmt::format("/1/benchmark/{}", m_id).c_str(), body, BenchConfig::kApiTLS, true);
|
||||
req.headers.insert({ "Authorization", fmt::format("Bearer {}", m_token)});
|
||||
|
||||
fetch(std::move(req), m_httpListener);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Benchmark::setError(const char *message)
|
||||
{
|
||||
LOG_ERR("%s " RED("benchmark failed ") RED_BOLD("\"%s\""), Tags::bench(), message);
|
||||
}
|
||||
#endif
|
||||
@@ -6,8 +6,8 @@
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -28,7 +28,6 @@
|
||||
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
#include "backend/common/interfaces/IWorker.h"
|
||||
@@ -49,11 +48,6 @@ public:
|
||||
|
||||
void getHashrateData(uint64_t& hashCount, uint64_t& timeStamp) const override;
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
inline uint64_t benchData() const override { return m_benchData; }
|
||||
inline uint64_t benchDoneTime() const override { return m_benchDoneTime; }
|
||||
# endif
|
||||
|
||||
protected:
|
||||
void storeStats();
|
||||
|
||||
@@ -64,11 +58,6 @@ protected:
|
||||
uint64_t m_count = 0;
|
||||
uint64_t m_hashCount[2] = {};
|
||||
uint64_t m_timestamp[2] = {};
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
uint64_t m_benchData = 0;
|
||||
uint64_t m_benchDoneTime = 0;
|
||||
# endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_BENCHMARK
|
||||
# include "backend/common/Benchmark.h"
|
||||
# include "backend/common/benchmark/Benchmark.h"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -124,12 +124,6 @@ bool xmrig::Workers<T>::tick(uint64_t)
|
||||
totalAvailable = false;
|
||||
}
|
||||
totalHashCount += n;
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
if (d_ptr->benchmark) {
|
||||
d_ptr->benchmark->tick(worker);
|
||||
}
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
143
src/backend/common/benchmark/BenchState.cpp
Normal file
143
src/backend/common/benchmark/BenchState.cpp
Normal file
@@ -0,0 +1,143 @@
|
||||
/* XMRig
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "backend/common/benchmark/BenchState.h"
|
||||
#include "backend/common/benchmark/BenchState_test.h"
|
||||
#include "backend/common/interfaces/IBenchListener.h"
|
||||
#include "base/io/Async.h"
|
||||
#include "base/tools/Chrono.h"
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class BenchStatePrivate
|
||||
{
|
||||
public:
|
||||
BenchStatePrivate(IBenchListener *listener, uint32_t size) :
|
||||
listener(listener),
|
||||
size(size)
|
||||
{}
|
||||
|
||||
|
||||
IBenchListener *listener;
|
||||
std::mutex mutex;
|
||||
std::shared_ptr<Async> async;
|
||||
uint32_t remaining = 0;
|
||||
uint32_t size;
|
||||
uint64_t doneTime = 0;
|
||||
};
|
||||
|
||||
|
||||
static BenchStatePrivate *d_ptr = nullptr;
|
||||
std::atomic<uint64_t> BenchState::m_data{};
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
|
||||
bool xmrig::BenchState::isDone()
|
||||
{
|
||||
return d_ptr == nullptr;
|
||||
}
|
||||
|
||||
|
||||
uint32_t xmrig::BenchState::size()
|
||||
{
|
||||
return d_ptr ? d_ptr->size : 0U;
|
||||
}
|
||||
|
||||
|
||||
uint64_t xmrig::BenchState::referenceHash(const Algorithm &algo, uint32_t size, uint32_t threads)
|
||||
{
|
||||
uint64_t hash = 0;
|
||||
|
||||
try {
|
||||
const auto &h = (threads == 1) ? hashCheck1T : hashCheck;
|
||||
hash = h.at(algo).at(size);
|
||||
} catch (const std::exception &ex) {}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
uint64_t xmrig::BenchState::start(size_t threads, const IBackend *backend)
|
||||
{
|
||||
assert(d_ptr != nullptr);
|
||||
|
||||
d_ptr->remaining = static_cast<uint32_t>(threads);
|
||||
|
||||
d_ptr->async = std::make_shared<Async>([] {
|
||||
d_ptr->listener->onBenchDone(m_data, 0, d_ptr->doneTime);
|
||||
|
||||
destroy();
|
||||
});
|
||||
|
||||
const uint64_t ts = Chrono::steadyMSecs();
|
||||
d_ptr->listener->onBenchReady(ts, d_ptr->remaining, backend);
|
||||
|
||||
return ts;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::BenchState::destroy()
|
||||
{
|
||||
delete d_ptr;
|
||||
d_ptr = nullptr;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::BenchState::done()
|
||||
{
|
||||
assert(d_ptr != nullptr && d_ptr->async && d_ptr->remaining > 0);
|
||||
|
||||
const uint64_t ts = Chrono::steadyMSecs();
|
||||
|
||||
std::lock_guard<std::mutex> lock(d_ptr->mutex);
|
||||
|
||||
d_ptr->doneTime = std::max(d_ptr->doneTime, ts);
|
||||
--d_ptr->remaining;
|
||||
|
||||
if (d_ptr->remaining == 0) {
|
||||
d_ptr->async->send();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void xmrig::BenchState::init(IBenchListener *listener, uint32_t size)
|
||||
{
|
||||
assert(d_ptr == nullptr);
|
||||
|
||||
d_ptr = new BenchStatePrivate(listener, size);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::BenchState::setSize(uint32_t size)
|
||||
{
|
||||
assert(d_ptr != nullptr);
|
||||
|
||||
d_ptr->size = size;
|
||||
}
|
||||
59
src/backend/common/benchmark/BenchState.h
Normal file
59
src/backend/common/benchmark/BenchState.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/* XMRig
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_BENCHSTATE_H
|
||||
#define XMRIG_BENCHSTATE_H
|
||||
|
||||
|
||||
#include <atomic>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class Algorithm;
|
||||
class IBackend;
|
||||
class IBenchListener;
|
||||
|
||||
|
||||
class BenchState
|
||||
{
|
||||
public:
|
||||
static bool isDone();
|
||||
static uint32_t size();
|
||||
static uint64_t referenceHash(const Algorithm &algo, uint32_t size, uint32_t threads);
|
||||
static uint64_t start(size_t threads, const IBackend *backend);
|
||||
static void destroy();
|
||||
static void done();
|
||||
static void init(IBenchListener *listener, uint32_t size);
|
||||
static void setSize(uint32_t size);
|
||||
|
||||
inline static uint64_t data() { return m_data; }
|
||||
inline static void add(uint64_t value) { m_data.fetch_xor(value, std::memory_order_relaxed); }
|
||||
|
||||
private:
|
||||
static std::atomic<uint64_t> m_data;
|
||||
};
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
#endif /* XMRIG_BENCHSTATE_H */
|
||||
116
src/backend/common/benchmark/BenchState_test.h
Normal file
116
src/backend/common/benchmark/BenchState_test.h
Normal file
@@ -0,0 +1,116 @@
|
||||
/* XMRig
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_BENCHSTATE_TEST_H
|
||||
#define XMRIG_BENCHSTATE_TEST_H
|
||||
|
||||
|
||||
#include "base/crypto/Algorithm.h"
|
||||
|
||||
|
||||
#include <map>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
static const std::map<int, std::map<uint32_t, uint64_t> > hashCheck = {
|
||||
{ Algorithm::RX_0, {
|
||||
# ifndef NDEBUG
|
||||
{ 10000U, 0x4A597463865ACF0EULL },
|
||||
{ 20000U, 0xC82B490C757DA738ULL },
|
||||
# endif
|
||||
{ 250000U, 0x7D6054757BB08A63ULL },
|
||||
{ 500000U, 0x96607546DE1F5ECCULL },
|
||||
{ 1000000U, 0x898B6E0431C28A6BULL },
|
||||
{ 2000000U, 0xEE9468F8B40926BCULL },
|
||||
{ 3000000U, 0xC2BC5D11724813C0ULL },
|
||||
{ 4000000U, 0x3A2C7B285B87F941ULL },
|
||||
{ 5000000U, 0x3B5BD2C3A16B450EULL },
|
||||
{ 6000000U, 0x5CD0602F20C5C7C4ULL },
|
||||
{ 7000000U, 0x101DE939474B6812ULL },
|
||||
{ 8000000U, 0x52B765A1B156C6ECULL },
|
||||
{ 9000000U, 0x323935102AB6B45CULL },
|
||||
{ 10000000U, 0xB5231262E2792B26ULL }
|
||||
}},
|
||||
{ Algorithm::RX_WOW, {
|
||||
# ifndef NDEBUG
|
||||
{ 10000U, 0x6B0918757100B338ULL },
|
||||
{ 20000U, 0x0B55785C1837F41BULL },
|
||||
# endif
|
||||
{ 250000U, 0xC7F712C9603E2603ULL },
|
||||
{ 500000U, 0x21A0E5AAE6DA7D8DULL },
|
||||
{ 1000000U, 0x0F3E5400B39EA96AULL },
|
||||
{ 2000000U, 0x85944CCFA2752D1FULL },
|
||||
{ 3000000U, 0x64AFFCAE991811BAULL },
|
||||
{ 4000000U, 0x3E4D0B836D3B13BAULL },
|
||||
{ 5000000U, 0xEB7417D621271166ULL },
|
||||
{ 6000000U, 0x97FFE10C0949FFA5ULL },
|
||||
{ 7000000U, 0x84CAC0F8879A4BA1ULL },
|
||||
{ 8000000U, 0xA1B79F031DA2459FULL },
|
||||
{ 9000000U, 0x9B65226DA873E65DULL },
|
||||
{ 10000000U, 0x0F9E00C5A511C200ULL }
|
||||
}}
|
||||
};
|
||||
|
||||
|
||||
static const std::map<int, std::map<uint32_t, uint64_t> > hashCheck1T = {
|
||||
{ Algorithm::RX_0, {
|
||||
# ifndef NDEBUG
|
||||
{ 10000U, 0xADFC3A66F79BFE7FULL },
|
||||
{ 20000U, 0x8ED578A60D55C0DBULL },
|
||||
# endif
|
||||
{ 250000U, 0x90A15B799486F3EBULL },
|
||||
{ 500000U, 0xAA83118FEE570F9AULL },
|
||||
{ 1000000U, 0x3DF47B0A427C93D9ULL },
|
||||
{ 2000000U, 0xED4D639B0AEB85C6ULL },
|
||||
{ 3000000U, 0x2D4F9B4275A713C3ULL },
|
||||
{ 4000000U, 0xA9EBE4888377F8D3ULL },
|
||||
{ 5000000U, 0xB92F81851E180454ULL },
|
||||
{ 6000000U, 0xFB9F98F63C2F1B7DULL },
|
||||
{ 7000000U, 0x2CC3D7A779D5AB35ULL },
|
||||
{ 8000000U, 0x2EEF833EA462F4B1ULL },
|
||||
{ 9000000U, 0xC6D39EF59213A07CULL },
|
||||
{ 10000000U, 0x95E6BAE68DD779CDULL }
|
||||
}},
|
||||
{ Algorithm::RX_WOW, {
|
||||
# ifndef NDEBUG
|
||||
{ 10000U, 0x9EC1B9B8C8C7F082ULL },
|
||||
{ 20000U, 0xF1DA44FA2A20D730ULL },
|
||||
# endif
|
||||
{ 250000U, 0x7B409F096C863207ULL },
|
||||
{ 500000U, 0x70B7B80D15654216ULL },
|
||||
{ 1000000U, 0x31301CC550306A59ULL },
|
||||
{ 2000000U, 0x92F65E9E31116361ULL },
|
||||
{ 3000000U, 0x7FE8DF6F43BA5285ULL },
|
||||
{ 4000000U, 0xD6CDA54FE4D9BBF7ULL },
|
||||
{ 5000000U, 0x73AF673E1A38E2B4ULL },
|
||||
{ 6000000U, 0x81FDC5C4B45D84E4ULL },
|
||||
{ 7000000U, 0xAA08CA57666DC874ULL },
|
||||
{ 8000000U, 0x9DCEFB833FC875BCULL },
|
||||
{ 9000000U, 0x862F051352CFCA1FULL },
|
||||
{ 10000000U, 0xC403F220189E8430ULL }
|
||||
}}
|
||||
};
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
|
||||
#endif /* XMRIG_BENCHSTATE_TEST_H */
|
||||
61
src/backend/common/benchmark/Benchmark.cpp
Normal file
61
src/backend/common/benchmark/Benchmark.cpp
Normal file
@@ -0,0 +1,61 @@
|
||||
/* XMRig
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "backend/common/benchmark/Benchmark.h"
|
||||
#include "backend/common/benchmark/BenchState.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/io/log/Tags.h"
|
||||
#include "base/tools/Chrono.h"
|
||||
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
|
||||
xmrig::Benchmark::Benchmark(size_t workers, const IBackend *backend) :
|
||||
m_backend(backend),
|
||||
m_workers(workers)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::Benchmark::finish(uint64_t totalHashCount)
|
||||
{
|
||||
m_current = totalHashCount;
|
||||
|
||||
return BenchState::isDone();
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Benchmark::start()
|
||||
{
|
||||
m_startTime = BenchState::start(m_workers, m_backend);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Benchmark::printProgress() const
|
||||
{
|
||||
if (!m_startTime || !m_current) {
|
||||
return;
|
||||
}
|
||||
|
||||
const double dt = static_cast<double>(Chrono::steadyMSecs() - m_startTime) / 1000.0;
|
||||
const double percent = static_cast<double>(m_current) / BenchState::size() * 100.0;
|
||||
|
||||
LOG_NOTICE("%s " MAGENTA_BOLD("%5.2f%% ") CYAN_BOLD("%" PRIu64) CYAN("/%u") BLACK_BOLD(" (%.3fs)"), Tags::bench(), percent, m_current, BenchState::size(), dt);
|
||||
}
|
||||
@@ -20,61 +20,31 @@
|
||||
#define XMRIG_BENCHMARK_H
|
||||
|
||||
|
||||
#include "base/crypto/Algorithm.h"
|
||||
#include "base/kernel/interfaces/IHttpListener.h"
|
||||
#include "base/tools/Object.h"
|
||||
#include "base/tools/String.h"
|
||||
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class IBackend;
|
||||
class IWorker;
|
||||
class Job;
|
||||
|
||||
|
||||
class Benchmark : public IHttpListener
|
||||
class Benchmark
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(Benchmark)
|
||||
|
||||
Benchmark(const Job &job, size_t workers, const IBackend *backend);
|
||||
~Benchmark() override = default;
|
||||
Benchmark(size_t workers, const IBackend *backend);
|
||||
~Benchmark() = default;
|
||||
|
||||
bool finish(uint64_t totalHashCount);
|
||||
void printProgress() const;
|
||||
void start();
|
||||
void tick(IWorker *worker);
|
||||
|
||||
protected:
|
||||
void onHttpData(const HttpData &data) override;
|
||||
|
||||
private:
|
||||
uint64_t referenceHash() const;
|
||||
void printExit();
|
||||
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
void send(const rapidjson::Value &body);
|
||||
void setError(const char *message);
|
||||
# endif
|
||||
|
||||
bool m_reset = false;
|
||||
const Algorithm m_algo;
|
||||
const IBackend *m_backend;
|
||||
const size_t m_workers;
|
||||
const String m_id;
|
||||
const String m_token;
|
||||
const uint64_t m_end;
|
||||
const uint64_t m_hash;
|
||||
std::shared_ptr<IHttpListener> m_httpListener;
|
||||
uint32_t m_done = 0;
|
||||
uint64_t m_current = 0;
|
||||
uint64_t m_data = 0;
|
||||
uint64_t m_doneTime = 0;
|
||||
uint64_t m_startTime = 0;
|
||||
};
|
||||
|
||||
@@ -23,6 +23,15 @@ set(SOURCES_BACKEND_COMMON
|
||||
)
|
||||
|
||||
if (WITH_RANDOMX AND WITH_BENCHMARK)
|
||||
list(APPEND HEADERS_BACKEND_COMMON src/backend/common/Benchmark.h)
|
||||
list(APPEND SOURCES_BACKEND_COMMON src/backend/common/Benchmark.cpp)
|
||||
list(APPEND HEADERS_BACKEND_COMMON
|
||||
src/backend/common/benchmark/Benchmark.h
|
||||
src/backend/common/benchmark/BenchState_test.h
|
||||
src/backend/common/benchmark/BenchState.h
|
||||
src/backend/common/interfaces/IBenchListener.h
|
||||
)
|
||||
|
||||
list(APPEND SOURCES_BACKEND_COMMON
|
||||
src/backend/common/benchmark/Benchmark.cpp
|
||||
src/backend/common/benchmark/BenchState.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
48
src/backend/common/interfaces/IBenchListener.h
Normal file
48
src/backend/common/interfaces/IBenchListener.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/* XMRig
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_IBENCHLISTENER_H
|
||||
#define XMRIG_IBENCHLISTENER_H
|
||||
|
||||
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class IBackend;
|
||||
|
||||
|
||||
class IBenchListener
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE(IBenchListener)
|
||||
|
||||
IBenchListener() = default;
|
||||
virtual ~IBenchListener() = default;
|
||||
|
||||
virtual void onBenchDone(uint64_t result, uint64_t diff, uint64_t ts) = 0;
|
||||
virtual void onBenchReady(uint64_t ts, uint32_t threads, const IBackend *backend) = 0;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif // XMRIG_IBENCHLISTENER_H
|
||||
@@ -5,8 +5,8 @@
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -26,6 +26,9 @@
|
||||
#define XMRIG_IWORKER_H
|
||||
|
||||
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
@@ -40,7 +43,10 @@ class Job;
|
||||
class IWorker
|
||||
{
|
||||
public:
|
||||
virtual ~IWorker() = default;
|
||||
XMRIG_DISABLE_COPY_MOVE(IWorker)
|
||||
|
||||
IWorker() = default;
|
||||
virtual ~IWorker() = default;
|
||||
|
||||
virtual bool selfTest() = 0;
|
||||
virtual const VirtualMemory *memory() const = 0;
|
||||
@@ -50,11 +56,6 @@ public:
|
||||
virtual void getHashrateData(uint64_t&, uint64_t&) const = 0;
|
||||
virtual void start() = 0;
|
||||
virtual void jobEarlyNotification(const Job&) = 0;
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
virtual uint64_t benchData() const = 0;
|
||||
virtual uint64_t benchDoneTime() const = 0;
|
||||
# endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -56,7 +56,8 @@
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_BENCHMARK
|
||||
# include "backend/common/Benchmark.h"
|
||||
# include "backend/common/benchmark/Benchmark.h"
|
||||
# include "backend/common/benchmark/BenchState.h"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -346,13 +347,7 @@ void xmrig::CpuBackend::setJob(const Job &job)
|
||||
|
||||
const auto &cpu = d_ptr->controller->config()->cpu();
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
uint32_t benchSize = job.benchSize();
|
||||
# else
|
||||
constexpr uint32_t benchSize = 0;
|
||||
# endif
|
||||
|
||||
auto threads = cpu.get(d_ptr->controller->miner(), job.algorithm(), benchSize);
|
||||
auto threads = cpu.get(d_ptr->controller->miner(), job.algorithm());
|
||||
if (!d_ptr->threads.empty() && d_ptr->threads.size() == threads.size() && std::equal(d_ptr->threads.begin(), d_ptr->threads.end(), threads.begin())) {
|
||||
return;
|
||||
}
|
||||
@@ -369,8 +364,8 @@ void xmrig::CpuBackend::setJob(const Job &job)
|
||||
stop();
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
if (benchSize) {
|
||||
d_ptr->benchmark = std::make_shared<Benchmark>(job, threads.size(), this);
|
||||
if (BenchState::size()) {
|
||||
d_ptr->benchmark = std::make_shared<Benchmark>(threads.size(), this);
|
||||
}
|
||||
# endif
|
||||
|
||||
|
||||
@@ -113,19 +113,20 @@ size_t xmrig::CpuConfig::memPoolSize() const
|
||||
}
|
||||
|
||||
|
||||
std::vector<xmrig::CpuLaunchData> xmrig::CpuConfig::get(const Miner *miner, const Algorithm &algorithm, uint32_t benchSize) const
|
||||
std::vector<xmrig::CpuLaunchData> xmrig::CpuConfig::get(const Miner *miner, const Algorithm &algorithm) const
|
||||
{
|
||||
std::vector<CpuLaunchData> out;
|
||||
const CpuThreads &threads = m_threads.get(algorithm);
|
||||
const auto &threads = m_threads.get(algorithm);
|
||||
|
||||
if (threads.isEmpty()) {
|
||||
return out;
|
||||
}
|
||||
|
||||
out.reserve(threads.count());
|
||||
const size_t count = threads.count();
|
||||
out.reserve(count);
|
||||
|
||||
for (const CpuThread &thread : threads.data()) {
|
||||
out.emplace_back(miner, algorithm, *this, thread, benchSize);
|
||||
for (const auto &thread : threads.data()) {
|
||||
out.emplace_back(miner, algorithm, *this, thread, count);
|
||||
}
|
||||
|
||||
return out;
|
||||
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
bool isHwAES() const;
|
||||
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
||||
size_t memPoolSize() const;
|
||||
std::vector<CpuLaunchData> get(const Miner *miner, const Algorithm &algorithm, uint32_t benchSize) const;
|
||||
std::vector<CpuLaunchData> get(const Miner *miner, const Algorithm &algorithm) const;
|
||||
void read(const rapidjson::Value &value);
|
||||
|
||||
inline bool isEnabled() const { return m_enabled; }
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
xmrig::CpuLaunchData::CpuLaunchData(const Miner *miner, const Algorithm &algorithm, const CpuConfig &config, const CpuThread &thread, uint32_t benchSize) :
|
||||
xmrig::CpuLaunchData::CpuLaunchData(const Miner *miner, const Algorithm &algorithm, const CpuConfig &config, const CpuThread &thread, size_t threads) :
|
||||
algorithm(algorithm),
|
||||
assembly(config.assembly()),
|
||||
astrobwtAVX2(config.astrobwtAVX2()),
|
||||
@@ -43,7 +43,7 @@ xmrig::CpuLaunchData::CpuLaunchData(const Miner *miner, const Algorithm &algorit
|
||||
priority(config.priority()),
|
||||
affinity(thread.affinity()),
|
||||
miner(miner),
|
||||
benchSize(benchSize),
|
||||
threads(threads),
|
||||
intensity(std::min<uint32_t>(thread.intensity(), algorithm.maxIntensity()))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class Miner;
|
||||
class CpuLaunchData
|
||||
{
|
||||
public:
|
||||
CpuLaunchData(const Miner *miner, const Algorithm &algorithm, const CpuConfig &config, const CpuThread &thread, uint32_t benchSize);
|
||||
CpuLaunchData(const Miner *miner, const Algorithm &algorithm, const CpuConfig &config, const CpuThread &thread, size_t threads);
|
||||
|
||||
bool isEqual(const CpuLaunchData &other) const;
|
||||
CnHash::AlgoVariant av() const;
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
const int priority;
|
||||
const int64_t affinity;
|
||||
const Miner *miner;
|
||||
const uint32_t benchSize;
|
||||
const size_t threads;
|
||||
const uint32_t intensity;
|
||||
};
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
#include "backend/cpu/CpuWorker.h"
|
||||
#include "base/tools/Chrono.h"
|
||||
#include "core/config/Config.h"
|
||||
#include "core/Miner.h"
|
||||
#include "crypto/cn/CnCtx.h"
|
||||
#include "crypto/cn/CryptoNight_test.h"
|
||||
@@ -52,24 +53,15 @@
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_BENCHMARK
|
||||
# include "backend/common/benchmark/BenchState.h"
|
||||
#endif
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
static constexpr uint32_t kReserveCount = 32768;
|
||||
|
||||
|
||||
template<size_t N>
|
||||
inline bool nextRound(WorkerJob<N> &job, uint32_t benchSize)
|
||||
{
|
||||
if (!job.nextRound(benchSize ? 1 : kReserveCount, 1)) {
|
||||
JobResults::done(job.currentJob());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
@@ -85,7 +77,7 @@ xmrig::CpuWorker<N>::CpuWorker(size_t id, const CpuLaunchData &data) :
|
||||
m_av(data.av()),
|
||||
m_astrobwtMaxSize(data.astrobwtMaxSize * 1000),
|
||||
m_miner(data.miner),
|
||||
m_benchSize(data.benchSize),
|
||||
m_threads(data.threads),
|
||||
m_ctx()
|
||||
{
|
||||
m_memory = new VirtualMemory(m_algorithm.l3() * N, data.hugePages, false, true, m_node);
|
||||
@@ -231,6 +223,19 @@ void xmrig::CpuWorker<N>::start()
|
||||
current_job_nonces[i] = *m_job.nonce(i);
|
||||
}
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
if (m_benchSize) {
|
||||
if (current_job_nonces[0] >= m_benchSize) {
|
||||
return BenchState::done();
|
||||
}
|
||||
|
||||
// Make each hash dependent on the previous one in single thread benchmark to prevent cheating with multiple threads
|
||||
if (m_threads == 1) {
|
||||
*(uint64_t*)(m_job.blob()) ^= BenchState::data();
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
bool valid = true;
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
@@ -240,7 +245,7 @@ void xmrig::CpuWorker<N>::start()
|
||||
randomx_calculate_hash_first(m_vm, tempHash, m_job.blob(), job.size());
|
||||
}
|
||||
|
||||
if (!nextRound(m_job, m_benchSize)) {
|
||||
if (!nextRound()) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -260,7 +265,7 @@ void xmrig::CpuWorker<N>::start()
|
||||
fn(job.algorithm())(m_job.blob(), job.size(), m_hash, m_ctx, job.height());
|
||||
}
|
||||
|
||||
if (!nextRound(m_job, m_benchSize)) {
|
||||
if (!nextRound()) {
|
||||
break;
|
||||
};
|
||||
}
|
||||
@@ -272,11 +277,7 @@ void xmrig::CpuWorker<N>::start()
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
if (m_benchSize) {
|
||||
if (current_job_nonces[i] < m_benchSize) {
|
||||
m_benchData ^= value;
|
||||
}
|
||||
else {
|
||||
m_benchDoneTime = Chrono::steadyMSecs();
|
||||
return;
|
||||
BenchState::add(value);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -298,6 +299,25 @@ void xmrig::CpuWorker<N>::start()
|
||||
}
|
||||
|
||||
|
||||
template<size_t N>
|
||||
bool xmrig::CpuWorker<N>::nextRound()
|
||||
{
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
const uint32_t count = m_benchSize ? 1U : kReserveCount;
|
||||
# else
|
||||
constexpr uint32_t count = kReserveCount;
|
||||
# endif
|
||||
|
||||
if (!m_job.nextRound(count, 1)) {
|
||||
JobResults::done(m_job.currentJob());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template<size_t N>
|
||||
bool xmrig::CpuWorker<N>::verify(const Algorithm &algorithm, const uint8_t *referenceValue)
|
||||
{
|
||||
@@ -378,7 +398,16 @@ void xmrig::CpuWorker<N>::consumeJob()
|
||||
return;
|
||||
}
|
||||
|
||||
m_job.add(m_miner->job(), m_benchSize ? 1 : kReserveCount, Nonce::CPU);
|
||||
auto job = m_miner->job();
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
m_benchSize = job.benchSize();
|
||||
const uint32_t count = m_benchSize ? 1U : kReserveCount;
|
||||
# else
|
||||
constexpr uint32_t count = kReserveCount;
|
||||
# endif
|
||||
|
||||
m_job.add(job, count, Nonce::CPU);
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
if (m_job.currentJob().algorithm().family() == Algorithm::RANDOM_X) {
|
||||
|
||||
@@ -68,6 +68,7 @@ private:
|
||||
void allocateRandomX_VM();
|
||||
# endif
|
||||
|
||||
bool nextRound();
|
||||
bool verify(const Algorithm &algorithm, const uint8_t *referenceValue);
|
||||
bool verify2(const Algorithm &algorithm, const uint8_t *referenceValue);
|
||||
void allocateCnCtx();
|
||||
@@ -82,13 +83,17 @@ private:
|
||||
const CnHash::AlgoVariant m_av;
|
||||
const int m_astrobwtMaxSize;
|
||||
const Miner *m_miner;
|
||||
const uint32_t m_benchSize;
|
||||
const size_t m_threads;
|
||||
cryptonight_ctx *m_ctx[N];
|
||||
VirtualMemory *m_memory = nullptr;
|
||||
WorkerJob<N> m_job;
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
randomx_vm *m_vm = nullptr;
|
||||
randomx_vm *m_vm = nullptr;
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
uint32_t m_benchSize = 0;
|
||||
# endif
|
||||
};
|
||||
|
||||
|
||||
@@ -119,6 +119,7 @@ namespace xmrig {
|
||||
class AsyncPrivate
|
||||
{
|
||||
public:
|
||||
Async::Callback callback;
|
||||
IAsyncListener *listener = nullptr;
|
||||
uv_async_t *async = nullptr;
|
||||
};
|
||||
@@ -127,6 +128,16 @@ public:
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
xmrig::Async::Async(Callback callback) : d_ptr(new AsyncPrivate())
|
||||
{
|
||||
d_ptr->callback = std::move(callback);
|
||||
d_ptr->async = new uv_async_t;
|
||||
d_ptr->async->data = this;
|
||||
|
||||
uv_async_init(uv_default_loop(), d_ptr->async, [](uv_async_t *handle) { static_cast<Async *>(handle->data)->d_ptr->callback(); });
|
||||
}
|
||||
|
||||
|
||||
xmrig::Async::Async(IAsyncListener *listener) : d_ptr(new AsyncPrivate())
|
||||
{
|
||||
d_ptr->listener = listener;
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
#include <functional>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
@@ -37,6 +40,9 @@ class Async
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(Async)
|
||||
|
||||
using Callback = std::function<void()>;
|
||||
|
||||
Async(Callback callback);
|
||||
Async(IAsyncListener *listener);
|
||||
~Async();
|
||||
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -72,7 +66,7 @@ static void createVariables()
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
xmrig::String xmrig::Env::expand(const char *in)
|
||||
xmrig::String xmrig::Env::expand(const char *in, const std::map<String, String> &extra)
|
||||
{
|
||||
# ifdef XMRIG_FEATURE_ENV
|
||||
if (in == nullptr) {
|
||||
@@ -96,7 +90,7 @@ xmrig::String xmrig::Env::expand(const char *in)
|
||||
continue;
|
||||
}
|
||||
|
||||
vars.insert({ var, get(m[1].str().c_str()) });
|
||||
vars.insert({ var, get(m[1].str().c_str(), extra) });
|
||||
}
|
||||
|
||||
for (const auto &kv : vars) {
|
||||
@@ -118,15 +112,23 @@ xmrig::String xmrig::Env::expand(const char *in)
|
||||
}
|
||||
|
||||
|
||||
xmrig::String xmrig::Env::get(const String &name)
|
||||
xmrig::String xmrig::Env::get(const String &name, const std::map<String, String> &extra)
|
||||
{
|
||||
# ifdef XMRIG_FEATURE_ENV
|
||||
if (variables.empty()) {
|
||||
createVariables();
|
||||
}
|
||||
|
||||
if (variables.count(name)) {
|
||||
return variables.at(name);
|
||||
const auto it = variables.find(name);
|
||||
if (it != variables.end()) {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
if (!extra.empty()) {
|
||||
const auto it = extra.find(name);
|
||||
if (it != extra.end()) {
|
||||
return it->second;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -29,14 +23,17 @@
|
||||
#include "base/tools/String.h"
|
||||
|
||||
|
||||
#include <map>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class Env
|
||||
{
|
||||
public:
|
||||
static String expand(const char *in);
|
||||
static String get(const String &name);
|
||||
static String expand(const char *in, const std::map<String, String> &extra = {});
|
||||
static String get(const String &name, const std::map<String, String> &extra = {});
|
||||
static String hostname();
|
||||
};
|
||||
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -52,7 +46,7 @@ public:
|
||||
static void setProcessPriority(int priority);
|
||||
static void setThreadPriority(int priority);
|
||||
|
||||
static inline const char *userAgent() { return m_userAgent; }
|
||||
static inline const String &userAgent() { return m_userAgent; }
|
||||
|
||||
static bool isOnBatteryPower();
|
||||
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -26,12 +20,18 @@
|
||||
#define XMRIG_ICONSOLELISTENER_H
|
||||
|
||||
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class IConsoleListener
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE(IConsoleListener)
|
||||
|
||||
IConsoleListener() = default;
|
||||
virtual ~IConsoleListener() = default;
|
||||
|
||||
virtual void onConsoleCommand(char command) = 0;
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -26,6 +20,9 @@
|
||||
#define XMRIG_IDNSLISTENER_H
|
||||
|
||||
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
@@ -35,6 +32,9 @@ class Dns;
|
||||
class IDnsListener
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE(IDnsListener)
|
||||
|
||||
IDnsListener() = default;
|
||||
virtual ~IDnsListener() = default;
|
||||
|
||||
virtual void onResolved(const Dns &dns, int status) = 0;
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -26,6 +20,9 @@
|
||||
#define XMRIG_IHTTPLISTENER_H
|
||||
|
||||
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
@@ -36,7 +33,10 @@ class HttpResponse;
|
||||
class IHttpListener
|
||||
{
|
||||
public:
|
||||
virtual ~IHttpListener() = default;
|
||||
XMRIG_DISABLE_COPY_MOVE(IHttpListener)
|
||||
|
||||
IHttpListener() = default;
|
||||
virtual ~IHttpListener() = default;
|
||||
|
||||
virtual void onHttpData(const HttpData &data) = 0;
|
||||
};
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -26,6 +20,9 @@
|
||||
#define XMRIG_ISIGNALLISTENER_H
|
||||
|
||||
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
@@ -35,7 +32,10 @@ class String;
|
||||
class ISignalListener
|
||||
{
|
||||
public:
|
||||
virtual ~ISignalListener() = default;
|
||||
XMRIG_DISABLE_COPY_MOVE(ISignalListener)
|
||||
|
||||
ISignalListener() = default;
|
||||
virtual ~ISignalListener() = default;
|
||||
|
||||
virtual void onSignal(int signum) = 0;
|
||||
};
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -26,6 +20,9 @@
|
||||
#define XMRIG_ITIMERLISTENER_H
|
||||
|
||||
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
@@ -35,7 +32,10 @@ class Timer;
|
||||
class ITimerListener
|
||||
{
|
||||
public:
|
||||
virtual ~ITimerListener() = default;
|
||||
XMRIG_DISABLE_COPY_MOVE(ITimerListener)
|
||||
|
||||
ITimerListener() = default;
|
||||
virtual ~ITimerListener() = default;
|
||||
|
||||
virtual void onTimer(const Timer *timer) = 0;
|
||||
};
|
||||
|
||||
@@ -95,7 +95,7 @@ void xmrig::HttpClient::handshake()
|
||||
{
|
||||
headers.insert({ "Host", host() });
|
||||
headers.insert({ "Connection", "close" });
|
||||
headers.insert({ "User-Agent", Platform::userAgent() });
|
||||
headers.insert({ "User-Agent", Platform::userAgent().data() });
|
||||
|
||||
if (!body.empty()) {
|
||||
headers.insert({ "Content-Length", std::to_string(body.size()) });
|
||||
|
||||
@@ -176,9 +176,7 @@ void xmrig::Job::copy(const Job &other)
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
m_benchSize = other.m_benchSize;
|
||||
m_benchHash = other.m_benchHash;
|
||||
m_benchToken = other.m_benchToken;
|
||||
m_benchSize = other.m_benchSize;
|
||||
# endif
|
||||
}
|
||||
|
||||
@@ -213,8 +211,6 @@ void xmrig::Job::move(Job &&other)
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
m_benchSize = other.m_benchSize;
|
||||
m_benchHash = other.m_benchHash;
|
||||
m_benchToken = std::move(other.m_benchToken);
|
||||
m_benchSize = other.m_benchSize;
|
||||
# endif
|
||||
}
|
||||
|
||||
@@ -112,12 +112,8 @@ public:
|
||||
inline Job &operator=(Job &&other) noexcept { move(std::move(other)); return *this; }
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
inline const String &benchToken() const { return m_benchToken; }
|
||||
inline uint32_t benchSize() const { return m_benchSize; }
|
||||
inline uint64_t benchHash() const { return m_benchHash; }
|
||||
inline void setBenchHash(uint64_t benchHash) { m_benchHash = benchHash; }
|
||||
inline void setBenchSize(uint32_t size) { m_benchSize = size; }
|
||||
inline void setBenchToken(const String &token) { m_benchToken = token; }
|
||||
# endif
|
||||
|
||||
private:
|
||||
@@ -146,9 +142,7 @@ private:
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
String m_benchToken;
|
||||
uint32_t m_benchSize = 0;
|
||||
uint64_t m_benchHash = 0;
|
||||
# endif
|
||||
};
|
||||
|
||||
|
||||
@@ -19,11 +19,14 @@
|
||||
#include "base/net/stratum/benchmark/BenchClient.h"
|
||||
#include "3rdparty/fmt/core.h"
|
||||
#include "3rdparty/rapidjson/document.h"
|
||||
#include "backend/common/benchmark/BenchState.h"
|
||||
#include "backend/common/interfaces/IBackend.h"
|
||||
#include "backend/cpu/Cpu.h"
|
||||
#include "base/io/json/Json.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/io/log/Tags.h"
|
||||
#include "base/kernel/interfaces/IClientListener.h"
|
||||
#include "base/net/dns/Dns.h"
|
||||
#include "base/net/http/Fetch.h"
|
||||
#include "base/net/http/HttpData.h"
|
||||
#include "base/net/http/HttpListener.h"
|
||||
@@ -33,7 +36,8 @@
|
||||
|
||||
xmrig::BenchClient::BenchClient(const std::shared_ptr<BenchConfig> &benchmark, IClientListener* listener) :
|
||||
m_listener(listener),
|
||||
m_benchmark(benchmark)
|
||||
m_benchmark(benchmark),
|
||||
m_hash(benchmark->hash())
|
||||
{
|
||||
std::vector<char> blob(112 * 2 + 1, '0');
|
||||
blob.back() = '\0';
|
||||
@@ -42,8 +46,12 @@ xmrig::BenchClient::BenchClient(const std::shared_ptr<BenchConfig> &benchmark, I
|
||||
m_job.setAlgorithm(m_benchmark->algorithm());
|
||||
m_job.setDiff(std::numeric_limits<uint64_t>::max());
|
||||
m_job.setHeight(1);
|
||||
m_job.setBenchSize(m_benchmark->size());
|
||||
m_job.setBenchHash(m_benchmark->hash());
|
||||
m_job.setId("00000000");
|
||||
|
||||
blob[Job::kMaxSeedSize * 2] = '\0';
|
||||
m_job.setSeedHash(blob.data());
|
||||
|
||||
BenchState::init(this, m_benchmark->size());
|
||||
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
if (m_benchmark->isSubmit()) {
|
||||
@@ -54,43 +62,45 @@ xmrig::BenchClient::BenchClient(const std::shared_ptr<BenchConfig> &benchmark, I
|
||||
|
||||
if (!m_benchmark->id().isEmpty()) {
|
||||
m_job.setId(m_benchmark->id());
|
||||
m_job.setBenchToken(m_benchmark->token());
|
||||
m_mode = ONLINE_VERIFY;
|
||||
m_token = m_benchmark->token();
|
||||
m_mode = ONLINE_VERIFY;
|
||||
|
||||
return;
|
||||
}
|
||||
# endif
|
||||
|
||||
m_job.setId("00000000");
|
||||
|
||||
if (m_job.benchHash() && m_job.setSeedHash(m_benchmark->seed())) {
|
||||
if (m_hash && setSeed(m_benchmark->seed())) {
|
||||
m_mode = STATIC_VERIFY;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
blob[Job::kMaxSeedSize * 2] = '\0';
|
||||
m_job.setSeedHash(blob.data());
|
||||
m_job.setBenchSize(m_benchmark->size());
|
||||
|
||||
}
|
||||
|
||||
|
||||
xmrig::BenchClient::~BenchClient()
|
||||
{
|
||||
BenchState::destroy();
|
||||
}
|
||||
|
||||
|
||||
const char *xmrig::BenchClient::tag() const
|
||||
{
|
||||
return Tags::bench();
|
||||
}
|
||||
|
||||
|
||||
void xmrig::BenchClient::connect()
|
||||
{
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
switch (m_mode) {
|
||||
case STATIC_BENCH:
|
||||
case STATIC_VERIFY:
|
||||
return start();
|
||||
|
||||
case ONLINE_BENCH:
|
||||
return createBench();
|
||||
|
||||
case ONLINE_VERIFY:
|
||||
return getBench();
|
||||
if (m_mode == ONLINE_BENCH || m_mode == ONLINE_VERIFY) {
|
||||
return resolve();
|
||||
}
|
||||
# else
|
||||
start();
|
||||
# endif
|
||||
|
||||
start();
|
||||
}
|
||||
|
||||
|
||||
@@ -100,6 +110,43 @@ void xmrig::BenchClient::setPool(const Pool &pool)
|
||||
}
|
||||
|
||||
|
||||
void xmrig::BenchClient::onBenchDone(uint64_t result, uint64_t diff, uint64_t ts)
|
||||
{
|
||||
m_result = result;
|
||||
m_diff = diff;
|
||||
m_doneTime = ts;
|
||||
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
if (!m_token.isEmpty()) {
|
||||
send(DONE_BENCH);
|
||||
}
|
||||
# endif
|
||||
|
||||
const uint64_t ref = referenceHash();
|
||||
const char *color = ref ? ((result == ref) ? GREEN_BOLD_S : RED_BOLD_S) : BLACK_BOLD_S;
|
||||
|
||||
LOG_NOTICE("%s " WHITE_BOLD("benchmark finished in ") CYAN_BOLD("%.3f seconds") WHITE_BOLD_S " hash sum = " CLEAR "%s%016" PRIX64 CLEAR, tag(), static_cast<double>(ts - m_readyTime) / 1000.0, color, result);
|
||||
|
||||
if (m_token.isEmpty()) {
|
||||
printExit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void xmrig::BenchClient::onBenchReady(uint64_t ts, uint32_t threads, const IBackend *backend)
|
||||
{
|
||||
m_readyTime = ts;
|
||||
m_threads = threads;
|
||||
m_backend = backend;
|
||||
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
if (m_mode == ONLINE_BENCH) {
|
||||
send(CREATE_BENCH);
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
void xmrig::BenchClient::onHttpData(const HttpData &data)
|
||||
{
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
@@ -115,18 +162,99 @@ void xmrig::BenchClient::onHttpData(const HttpData &data)
|
||||
return setError(data.statusName());
|
||||
}
|
||||
|
||||
if (m_mode == ONLINE_BENCH) {
|
||||
startBench(doc);
|
||||
}
|
||||
else {
|
||||
startVerify(doc);
|
||||
switch (m_request) {
|
||||
case GET_BENCH:
|
||||
return onGetReply(doc);
|
||||
|
||||
case CREATE_BENCH:
|
||||
return onCreateReply(doc);
|
||||
|
||||
case DONE_BENCH:
|
||||
return onDoneReply(doc);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
void xmrig::BenchClient::onResolved(const Dns &dns, int status)
|
||||
{
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
assert(!m_httpListener);
|
||||
|
||||
if (status < 0) {
|
||||
return setError(dns.error(), "DNS error");
|
||||
}
|
||||
|
||||
m_ip = dns.get().ip();
|
||||
m_httpListener = std::make_shared<HttpListener>(this, tag());
|
||||
|
||||
if (m_mode == ONLINE_BENCH) {
|
||||
start();
|
||||
}
|
||||
else {
|
||||
send(GET_BENCH);
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::BenchClient::setSeed(const char *seed)
|
||||
{
|
||||
if (!seed) {
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t size = strlen(seed);
|
||||
if (size % 2 != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
size /= 2;
|
||||
if (size < 4 || size >= m_job.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Buffer::fromHex(seed, size * 2, m_job.blob())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_job.setBenchSize(BenchState::size());
|
||||
|
||||
LOG_NOTICE("%s " WHITE_BOLD("seed ") BLACK_BOLD("%s"), tag(), seed);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
uint64_t xmrig::BenchClient::referenceHash() const
|
||||
{
|
||||
if (m_hash || m_mode == ONLINE_BENCH) {
|
||||
return m_hash;
|
||||
}
|
||||
|
||||
return BenchState::referenceHash(m_job.algorithm(), BenchState::size(), m_threads);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::BenchClient::printExit()
|
||||
{
|
||||
LOG_INFO("%s " WHITE_BOLD("press ") MAGENTA_BOLD("Ctrl+C") WHITE_BOLD(" to exit"), tag());
|
||||
}
|
||||
|
||||
|
||||
void xmrig::BenchClient::start()
|
||||
{
|
||||
const uint32_t size = BenchState::size();
|
||||
|
||||
LOG_NOTICE("%s " MAGENTA_BOLD("start benchmark ") "hashes " CYAN_BOLD("%u%s") " algo " WHITE_BOLD("%s"),
|
||||
tag(),
|
||||
size < 1000000 ? size / 1000 : size / 1000000,
|
||||
size < 1000000 ? "K" : "M",
|
||||
m_job.algorithm().shortName());
|
||||
|
||||
m_listener->onLoginSuccess(this);
|
||||
m_listener->onJobReceived(this, m_job, rapidjson::Value());
|
||||
}
|
||||
@@ -134,69 +262,118 @@ void xmrig::BenchClient::start()
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_HTTP
|
||||
void xmrig::BenchClient::createBench()
|
||||
void xmrig::BenchClient::onCreateReply(const rapidjson::Value &value)
|
||||
{
|
||||
createHttpListener();
|
||||
m_startTime = Chrono::steadyMSecs();
|
||||
m_token = Json::getString(value, BenchConfig::kToken);
|
||||
|
||||
m_job.setId(Json::getString(value, BenchConfig::kId));
|
||||
setSeed(Json::getString(value, BenchConfig::kSeed));
|
||||
|
||||
m_listener->onJobReceived(this, m_job, rapidjson::Value());
|
||||
|
||||
send(START_BENCH);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::BenchClient::onDoneReply(const rapidjson::Value &)
|
||||
{
|
||||
LOG_NOTICE("%s " WHITE_BOLD("benchmark submitted ") CYAN_BOLD("https://xmrig.com/benchmark/%s"), tag(), m_job.id().data());
|
||||
printExit();
|
||||
}
|
||||
|
||||
|
||||
void xmrig::BenchClient::onGetReply(const rapidjson::Value &value)
|
||||
{
|
||||
const char *hash = Json::getString(value, BenchConfig::kHash);
|
||||
if (hash) {
|
||||
m_hash = strtoull(hash, nullptr, 16);
|
||||
}
|
||||
|
||||
BenchState::setSize(Json::getUint(value, BenchConfig::kSize));
|
||||
|
||||
m_job.setAlgorithm(Json::getString(value, BenchConfig::kAlgo));
|
||||
setSeed(Json::getString(value, BenchConfig::kSeed));
|
||||
|
||||
start();
|
||||
}
|
||||
|
||||
|
||||
void xmrig::BenchClient::resolve()
|
||||
{
|
||||
m_dns = std::make_shared<Dns>(this);
|
||||
|
||||
if (!m_dns->resolve(BenchConfig::kApiHost)) {
|
||||
setError(m_dns->error(), "getaddrinfo error");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void xmrig::BenchClient::send(Request request)
|
||||
{
|
||||
using namespace rapidjson;
|
||||
|
||||
Document doc(kObjectType);
|
||||
auto &allocator = doc.GetAllocator();
|
||||
m_request = request;
|
||||
|
||||
doc.AddMember(StringRef(BenchConfig::kSize), m_benchmark->size(), allocator);
|
||||
doc.AddMember(StringRef(BenchConfig::kAlgo), m_benchmark->algorithm().toJSON(), allocator);
|
||||
doc.AddMember("version", APP_VERSION, allocator);
|
||||
doc.AddMember("cpu", Cpu::toJSON(doc), allocator);
|
||||
switch (m_request) {
|
||||
case GET_BENCH:
|
||||
{
|
||||
FetchRequest req(HTTP_GET, m_ip, BenchConfig::kApiPort, fmt::format("/1/benchmark/{}", m_job.id()).c_str(), BenchConfig::kApiTLS, true);
|
||||
fetch(std::move(req), m_httpListener);
|
||||
}
|
||||
break;
|
||||
|
||||
FetchRequest req(HTTP_POST, BenchConfig::kApiHost, BenchConfig::kApiPort, "/1/benchmark", doc, BenchConfig::kApiTLS, true);
|
||||
fetch(std::move(req), m_httpListener);
|
||||
}
|
||||
case CREATE_BENCH:
|
||||
{
|
||||
doc.AddMember(StringRef(BenchConfig::kSize), m_benchmark->size(), allocator);
|
||||
doc.AddMember(StringRef(BenchConfig::kAlgo), m_benchmark->algorithm().toJSON(), allocator);
|
||||
doc.AddMember("version", APP_VERSION, allocator);
|
||||
doc.AddMember("threads", m_threads, allocator);
|
||||
doc.AddMember("steady_ready_ts", m_readyTime, allocator);
|
||||
doc.AddMember("cpu", Cpu::toJSON(doc), allocator);
|
||||
|
||||
FetchRequest req(HTTP_POST, m_ip, BenchConfig::kApiPort, "/1/benchmark", doc, BenchConfig::kApiTLS, true);
|
||||
fetch(std::move(req), m_httpListener);
|
||||
}
|
||||
break;
|
||||
|
||||
void xmrig::BenchClient::createHttpListener()
|
||||
{
|
||||
if (!m_httpListener) {
|
||||
m_httpListener = std::make_shared<HttpListener>(this, Tags::bench());
|
||||
case START_BENCH:
|
||||
doc.AddMember("steady_start_ts", m_startTime, allocator);
|
||||
update(doc);
|
||||
break;
|
||||
|
||||
case DONE_BENCH:
|
||||
doc.AddMember("steady_done_ts", m_doneTime, allocator);
|
||||
doc.AddMember("hash", Value(fmt::format("{:016X}", m_result).c_str(), allocator), allocator);
|
||||
doc.AddMember("diff", m_diff, allocator);
|
||||
doc.AddMember("backend", m_backend->toJSON(doc), allocator);
|
||||
update(doc);
|
||||
break;
|
||||
|
||||
case NO_REQUEST:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void xmrig::BenchClient::getBench()
|
||||
void xmrig::BenchClient::setError(const char *message, const char *label)
|
||||
{
|
||||
createHttpListener();
|
||||
LOG_ERR("%s " RED("%s: ") RED_BOLD("\"%s\""), tag(), label ? label : "benchmark failed", message);
|
||||
printExit();
|
||||
|
||||
BenchState::destroy();
|
||||
}
|
||||
|
||||
|
||||
void xmrig::BenchClient::update(const rapidjson::Value &body)
|
||||
{
|
||||
assert(!m_token.isEmpty());
|
||||
|
||||
FetchRequest req(HTTP_PATCH, m_ip, BenchConfig::kApiPort, fmt::format("/1/benchmark/{}", m_job.id()).c_str(), body, BenchConfig::kApiTLS, true);
|
||||
req.headers.insert({ "Authorization", fmt::format("Bearer {}", m_token)});
|
||||
|
||||
FetchRequest req(HTTP_GET, BenchConfig::kApiHost, BenchConfig::kApiPort, fmt::format("/1/benchmark/{}", m_job.id()).c_str(), BenchConfig::kApiTLS, true);
|
||||
fetch(std::move(req), m_httpListener);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::BenchClient::setError(const char *message)
|
||||
{
|
||||
LOG_ERR("%s " RED("benchmark failed ") RED_BOLD("\"%s\""), Tags::bench(), message);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::BenchClient::startBench(const rapidjson::Value &value)
|
||||
{
|
||||
m_job.setId(Json::getString(value, BenchConfig::kId));
|
||||
m_job.setSeedHash(Json::getString(value, BenchConfig::kSeed));
|
||||
m_job.setBenchToken(Json::getString(value, BenchConfig::kToken));
|
||||
|
||||
start();
|
||||
}
|
||||
|
||||
|
||||
void xmrig::BenchClient::startVerify(const rapidjson::Value &value)
|
||||
{
|
||||
const char *hash = Json::getString(value, BenchConfig::kHash);
|
||||
if (hash) {
|
||||
m_job.setBenchHash(strtoull(hash, nullptr, 16));
|
||||
}
|
||||
|
||||
m_job.setAlgorithm(Json::getString(value, BenchConfig::kAlgo));
|
||||
m_job.setSeedHash(Json::getString(value, BenchConfig::kSeed));
|
||||
m_job.setBenchSize(Json::getUint(value, BenchConfig::kSize));
|
||||
|
||||
start();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -20,27 +20,28 @@
|
||||
#define XMRIG_BENCHCLIENT_H
|
||||
|
||||
|
||||
#include "base/net/stratum/Client.h"
|
||||
#include "backend/common/interfaces/IBenchListener.h"
|
||||
#include "base/kernel/interfaces/IDnsListener.h"
|
||||
#include "base/kernel/interfaces/IHttpListener.h"
|
||||
#include "base/net/stratum/Client.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class BenchClient : public IClient, public IHttpListener
|
||||
class BenchClient : public IClient, public IHttpListener, public IBenchListener, public IDnsListener
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(BenchClient)
|
||||
|
||||
BenchClient(const std::shared_ptr<BenchConfig> &benchmark, IClientListener* listener);
|
||||
~BenchClient() override = default;
|
||||
~BenchClient() override;
|
||||
|
||||
inline bool disconnect() override { return true; }
|
||||
inline bool hasExtension(Extension) const noexcept override { return false; }
|
||||
inline bool isEnabled() const override { return true; }
|
||||
inline bool isTLS() const override { return false; }
|
||||
inline const char *mode() const override { return "benchmark"; }
|
||||
inline const char *tag() const override { return "null"; }
|
||||
inline const char *tlsFingerprint() const override { return nullptr; }
|
||||
inline const char *tlsVersion() const override { return nullptr; }
|
||||
inline const Job &job() const override { return m_job; }
|
||||
@@ -52,7 +53,7 @@ public:
|
||||
inline int64_t sequence() const override { return 0; }
|
||||
inline int64_t submit(const JobResult &) override { return 0; }
|
||||
inline void connect(const Pool &pool) override { setPool(pool); }
|
||||
inline void deleteLater() override {}
|
||||
inline void deleteLater() override { delete this; }
|
||||
inline void setAlgo(const Algorithm &algo) override {}
|
||||
inline void setEnabled(bool enabled) override {}
|
||||
inline void setProxy(const ProxyUrl &proxy) override {}
|
||||
@@ -61,11 +62,15 @@ public:
|
||||
inline void setRetryPause(uint64_t ms) override {}
|
||||
inline void tick(uint64_t now) override {}
|
||||
|
||||
const char *tag() const override;
|
||||
void connect() override;
|
||||
void setPool(const Pool &pool) override;
|
||||
|
||||
protected:
|
||||
void onBenchDone(uint64_t result, uint64_t diff, uint64_t ts) override;
|
||||
void onBenchReady(uint64_t ts, uint32_t threads, const IBackend *backend) override;
|
||||
void onHttpData(const HttpData &data) override;
|
||||
void onResolved(const Dns &dns, int status) override;
|
||||
|
||||
private:
|
||||
enum Mode : uint32_t {
|
||||
@@ -75,24 +80,47 @@ private:
|
||||
ONLINE_VERIFY
|
||||
};
|
||||
|
||||
enum Request : uint32_t {
|
||||
NO_REQUEST,
|
||||
GET_BENCH,
|
||||
CREATE_BENCH,
|
||||
START_BENCH,
|
||||
DONE_BENCH
|
||||
};
|
||||
|
||||
bool setSeed(const char *seed);
|
||||
uint64_t referenceHash() const;
|
||||
void printExit();
|
||||
void start();
|
||||
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
void createBench();
|
||||
void createHttpListener();
|
||||
void getBench();
|
||||
void setError(const char *message);
|
||||
void startBench(const rapidjson::Value &value);
|
||||
void startVerify(const rapidjson::Value &value);
|
||||
void onCreateReply(const rapidjson::Value &value);
|
||||
void onDoneReply(const rapidjson::Value &value);
|
||||
void onGetReply(const rapidjson::Value &value);
|
||||
void resolve();
|
||||
void send(Request request);
|
||||
void setError(const char *message, const char *label = nullptr);
|
||||
void update(const rapidjson::Value &body);
|
||||
# endif
|
||||
|
||||
const IBackend *m_backend = nullptr;
|
||||
IClientListener* m_listener;
|
||||
Job m_job;
|
||||
Mode m_mode = STATIC_BENCH;
|
||||
Pool m_pool;
|
||||
Request m_request = NO_REQUEST;
|
||||
std::shared_ptr<BenchConfig> m_benchmark;
|
||||
std::shared_ptr<Dns> m_dns;
|
||||
std::shared_ptr<IHttpListener> m_httpListener;
|
||||
String m_ip;
|
||||
Mode m_mode = STATIC_BENCH;
|
||||
String m_token;
|
||||
uint32_t m_threads = 0;
|
||||
uint64_t m_diff = 0;
|
||||
uint64_t m_doneTime = 0;
|
||||
uint64_t m_hash = 0;
|
||||
uint64_t m_readyTime = 0;
|
||||
uint64_t m_result = 0;
|
||||
uint64_t m_startTime = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -137,5 +137,9 @@ uint32_t xmrig::BenchConfig::getSize(const char *benchmark)
|
||||
return strcasecmp(benchmark, fmt::format("{}K", size).c_str()) == 0 ? size * 1000 : 0;
|
||||
}
|
||||
|
||||
# ifndef NDEBUG
|
||||
return size >= 10000 ? size : 0;
|
||||
# else
|
||||
return 0;
|
||||
# endif
|
||||
}
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -30,6 +24,21 @@
|
||||
#include <cctype>
|
||||
|
||||
|
||||
xmrig::String::String(const char *str, size_t size) :
|
||||
m_size(size)
|
||||
{
|
||||
if (str == nullptr) {
|
||||
m_size = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
m_data = new char[m_size + 1];
|
||||
memcpy(m_data, str, m_size);
|
||||
m_data[m_size] = '\0';
|
||||
}
|
||||
|
||||
|
||||
xmrig::String::String(const char *str) :
|
||||
m_size(str == nullptr ? 0 : strlen(str))
|
||||
{
|
||||
@@ -42,17 +51,18 @@ xmrig::String::String(const char *str) :
|
||||
}
|
||||
|
||||
|
||||
xmrig::String::String(const char *str, size_t size) :
|
||||
m_size(size)
|
||||
xmrig::String::String(const rapidjson::Value &value)
|
||||
{
|
||||
if (str == nullptr) {
|
||||
m_size = 0;
|
||||
if (!value.IsString()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((m_size = value.GetStringLength()) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_data = new char[m_size + 1];
|
||||
memcpy(m_data, str, m_size);
|
||||
memcpy(m_data, value.GetString(), m_size);
|
||||
m_data[m_size] = '\0';
|
||||
}
|
||||
|
||||
@@ -103,8 +113,10 @@ rapidjson::Value xmrig::String::toJSON(rapidjson::Document &doc) const
|
||||
|
||||
std::vector<xmrig::String> xmrig::String::split(char sep) const
|
||||
{
|
||||
std::vector<xmrig::String> out;
|
||||
std::vector<String> out;
|
||||
if (m_size == 0) {
|
||||
out.emplace_back(*this);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -50,8 +44,9 @@ public:
|
||||
inline String(char *str) : m_data(str), m_size(str == nullptr ? 0 : strlen(str)) {}
|
||||
inline String(String &&other) noexcept : m_data(other.m_data), m_size(other.m_size) { other.m_data = nullptr; other.m_size = 0; }
|
||||
|
||||
String(const char *str);
|
||||
String(const char *str, size_t size);
|
||||
String(const char *str);
|
||||
String(const rapidjson::Value &value);
|
||||
String(const String &other);
|
||||
|
||||
inline ~String() { delete [] m_data; }
|
||||
@@ -66,6 +61,7 @@ public:
|
||||
|
||||
inline bool isEmpty() const { return size() == 0; }
|
||||
inline bool isNull() const { return m_data == nullptr; }
|
||||
inline bool isValid() const { return m_data != nullptr; }
|
||||
inline char *data() { return m_data; }
|
||||
inline const char *data() const { return m_data; }
|
||||
inline size_t size() const { return m_size; }
|
||||
@@ -73,7 +69,7 @@ public:
|
||||
|
||||
inline bool operator!=(const char *str) const { return !isEqual(str); }
|
||||
inline bool operator!=(const String &other) const { return !isEqual(other); }
|
||||
inline bool operator<(const String &str) const { return strcmp(data(), str.data()) < 0; }
|
||||
inline bool operator<(const String &str) const { return !isEmpty() && !str.isEmpty() && strcmp(data(), str.data()) < 0; }
|
||||
inline bool operator==(const char *str) const { return isEqual(str); }
|
||||
inline bool operator==(const String &other) const { return isEqual(other); }
|
||||
inline operator const char*() const { return m_data; }
|
||||
|
||||
@@ -163,7 +163,7 @@ public:
|
||||
|
||||
reply.AddMember("version", APP_VERSION, allocator);
|
||||
reply.AddMember("kind", APP_KIND, allocator);
|
||||
reply.AddMember("ua", StringRef(Platform::userAgent()), allocator);
|
||||
reply.AddMember("ua", Platform::userAgent().toJSON(), allocator);
|
||||
reply.AddMember("cpu", Cpu::toJSON(doc), allocator);
|
||||
reply.AddMember("donate_level", controller->config()->pools().donateLevel(), allocator);
|
||||
reply.AddMember("paused", !enabled, allocator);
|
||||
|
||||
@@ -297,7 +297,7 @@ namespace randomx {
|
||||
}
|
||||
|
||||
void JitCompilerX86::generateProgramPrologue(Program& prog, ProgramConfiguration& pcfg) {
|
||||
codePos = ((uint8_t*)randomx_program_prologue_first_load) - ((uint8_t*)randomx_program_prologue);
|
||||
codePos = ADDR(randomx_program_prologue_first_load) - ADDR(randomx_program_prologue);
|
||||
code[codePos + 2] = 0xc0 + pcfg.readReg0;
|
||||
code[codePos + 5] = 0xc0 + pcfg.readReg1;
|
||||
*(uint32_t*)(code + codePos + 10) = RandomX_CurrentConfig.ScratchpadL3Mask64_Calculated;
|
||||
@@ -495,12 +495,10 @@ namespace randomx {
|
||||
|
||||
emit32(instr.getImm32(), code, codePos);
|
||||
emitByte(0x25, code, codePos);
|
||||
if (instr.getModCond() < StoreL3Condition) {
|
||||
emit32(AddressMask[instr.getModMem()], code, codePos);
|
||||
}
|
||||
else {
|
||||
emit32(ScratchpadL3Mask, code, codePos);
|
||||
}
|
||||
|
||||
const uint32_t mask1 = AddressMask[instr.getModMem()];
|
||||
const uint32_t mask2 = ScratchpadL3Mask;
|
||||
emit32((instr.mod < (StoreL3Condition << 4)) ? mask1 : mask2, code, codePos);
|
||||
}
|
||||
|
||||
FORCE_INLINE void JitCompilerX86::genAddressImm(const Instruction& instr, uint8_t* code, uint32_t& codePos) {
|
||||
|
||||
@@ -104,10 +104,6 @@ bool xmrig::Rx::init(const T &seed, const RxConfig &config, const CpuConfig &cpu
|
||||
randomx_set_scratchpad_prefetch_mode(config.scratchpadPrefetchMode());
|
||||
randomx_set_huge_pages_jit(cpu.isHugePagesJit());
|
||||
|
||||
if (isReady(seed)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!msrInitialized) {
|
||||
msrEnabled = msrInit(config, cpu.threads().get(seed.algorithm()).data());
|
||||
msrInitialized = true;
|
||||
@@ -121,6 +117,10 @@ bool xmrig::Rx::init(const T &seed, const RxConfig &config, const CpuConfig &cpu
|
||||
osInitialized = true;
|
||||
}
|
||||
|
||||
if (isReady(seed)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
d_ptr->queue.enqueue(seed, config.nodeset(), config.threads(cpu.limit()), cpu.isHugePages(), config.isOneGbPages(), config.mode(), cpu.priority());
|
||||
|
||||
return false;
|
||||
|
||||
@@ -51,6 +51,11 @@
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_BENCHMARK
|
||||
# include "backend/common/benchmark/BenchState.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <cinttypes>
|
||||
#include <ctime>
|
||||
@@ -260,24 +265,13 @@ void xmrig::Network::onRequest(IApiRequest &request)
|
||||
|
||||
void xmrig::Network::setJob(IClient *client, const Job &job, bool donate)
|
||||
{
|
||||
uint64_t diff = job.diff();;
|
||||
const char *scale = NetworkState::scaleDiff(diff);
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
const uint32_t size = job.benchSize();
|
||||
if (size) {
|
||||
LOG_NOTICE("%s " MAGENTA_BOLD("start benchmark ") "hashes " CYAN_BOLD("%u%s") " algo " WHITE_BOLD("%s") " print_time " CYAN_BOLD("%us"),
|
||||
Tags::bench(),
|
||||
size < 1000000 ? size / 1000 : size / 1000000,
|
||||
size < 1000000 ? "K" : "M",
|
||||
job.algorithm().shortName(),
|
||||
m_controller->config()->printTime());
|
||||
|
||||
LOG_NOTICE("%s " WHITE_BOLD("seed ") BLACK_BOLD("%s"), Tags::bench(), job.seed().toHex().data());
|
||||
}
|
||||
else
|
||||
if (!BenchState::size())
|
||||
# endif
|
||||
{
|
||||
uint64_t diff = job.diff();;
|
||||
const char *scale = NetworkState::scaleDiff(diff);
|
||||
|
||||
LOG_INFO("%s " MAGENTA_BOLD("new job") " from " WHITE_BOLD("%s:%d") " diff " WHITE_BOLD("%" PRIu64 "%s") " algo " WHITE_BOLD("%s") " height " WHITE_BOLD("%" PRIu64),
|
||||
Tags::network(), client->pool().host().data(), client->pool().port(), diff, scale, job.algorithm().shortName(), job.height());
|
||||
}
|
||||
|
||||
@@ -28,15 +28,15 @@
|
||||
#define APP_ID "xmrig"
|
||||
#define APP_NAME "XMRig"
|
||||
#define APP_DESC "XMRig miner"
|
||||
#define APP_VERSION "6.5.3"
|
||||
#define APP_VERSION "6.6.2"
|
||||
#define APP_DOMAIN "xmrig.com"
|
||||
#define APP_SITE "www.xmrig.com"
|
||||
#define APP_COPYRIGHT "Copyright (C) 2016-2020 xmrig.com"
|
||||
#define APP_KIND "miner"
|
||||
|
||||
#define APP_VER_MAJOR 6
|
||||
#define APP_VER_MINOR 5
|
||||
#define APP_VER_PATCH 3
|
||||
#define APP_VER_MINOR 6
|
||||
#define APP_VER_PATCH 2
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# if (_MSC_VER >= 1920)
|
||||
|
||||
Reference in New Issue
Block a user