1
0
mirror of https://github.com/xmrig/xmrig.git synced 2025-12-26 14:02:53 -05:00

Compare commits

...

54 Commits

Author SHA1 Message Date
Artem Zuikov
07d81c6587 Merge ab5be0b773 into e32731b60b 2024-10-20 18:07:59 +03:00
4ertus2
ab5be0b773 replace new/delete with sp 2024-10-20 18:03:25 +03:00
XMRig
e32731b60b Update deps 2024-10-20 09:49:06 +07:00
xmrig
e1ae367084 Merge pull request #3540 from SChernykh/dev
Detect AMD engineering samples in randomx_boost.sh
2024-08-29 19:50:43 +07:00
SChernykh
bc1c8358c4 Detect AMD engineering samples in randomx_boost.sh 2024-08-29 14:47:30 +02:00
xmrig
e0af8f0c6b Merge pull request #3539 from SChernykh/dev
Added Zen5 to randomx_boost.sh
2024-08-28 18:51:39 +07:00
SChernykh
29f9c8cf4c Added Zen5 to randomx_boost.sh 2024-08-28 13:49:27 +02:00
xmrig
26f4936f6f Merge pull request #3535 from SChernykh/dev
RandomX: tweaks for Zen5
2024-08-20 06:47:30 +07:00
SChernykh
a411ee3565 RandomX: tweaks for Zen5 2024-08-19 21:01:49 +02:00
xmrig
01bd0d48a1 Merge pull request #3534 from SChernykh/dev
Fixed threads auto-config on Zen5
2024-08-17 06:23:49 +07:00
SChernykh
20d555668b Fixed threads auto-config on Zen5 2024-08-16 23:36:22 +02:00
xmrig
56baec762f Merge pull request #3531 from SChernykh/dev
Always reset nonce on RandomX dataset change
2024-08-14 22:16:34 +07:00
SChernykh
17a52fb418 Always reset nonce on RandomX dataset change
Also never get a new job when mining is paused
2024-08-14 16:41:03 +02:00
XMRig
7e4caa8929 Merge remote-tracking branch 'remotes/origin/master' into dev 2024-08-12 03:02:19 +07:00
xmrig
ef14d55aa5 Merge pull request #3529 from eltociear/patch-1
docs: update ghostrider/README.md
2024-08-12 03:01:13 +07:00
XMRig
5776fdcc20 v6.22.1-dev 2024-08-12 02:15:08 +07:00
XMRig
fe0f69031b Merge branch 'master' into dev 2024-08-12 02:14:40 +07:00
Ikko Eltociear Ashimine
e682f89298 docs: update ghostrider/README.md
nubmer -> number
2024-08-12 03:54:26 +09:00
XMRig
544c393f78 v6.22.0 2024-08-12 01:13:51 +07:00
XMRig
9da6ea07bd Merge branch 'dev' 2024-08-12 01:13:29 +07:00
XMRig
62bcd6e5dc v6.22.0-dev 2024-08-10 22:00:42 +07:00
xmrig
c5f98fc5c7 Merge pull request #3528 from SChernykh/dev
Added rx/yada OpenCL support
2024-08-07 13:36:55 +07:00
SChernykh
ecb3ec0317 Added rx/yada OpenCL support 2024-08-07 00:18:51 +02:00
XMRig
3dfeed475f Sync changes with the proxy. 2024-08-06 23:32:20 +07:00
XMRig
98c775703e Don't generate "rx/yada" profile, use the "rx" profile by default. 2024-08-04 20:00:12 +07:00
XMRig
8da49f2650 More clean target parse. 2024-08-04 19:51:11 +07:00
xmrig
4570187459 Merge pull request #3525 from SChernykh/dev
Added Zen5 detection
2024-08-03 22:58:00 +07:00
SChernykh
748365d6e3 Added Zen5 detection
Preliminary Zen5 support, MSR mod is not ready yet.
2024-08-03 11:01:18 +02:00
xmrig
dd7e0e520d Merge pull request #3524 from SChernykh/dev
Fixed ARMv8 compilation
2024-08-02 23:47:21 +07:00
SChernykh
ef6fb728b5 Fixed ARMv8 compilation 2024-08-02 17:51:08 +02:00
xmrig
92ffcd34d6 Merge pull request #2411 from pdxwebdev/feature/yadacoin
Added support for Yada (rx/yada algorithm)
2024-08-02 16:22:50 +07:00
Matthew Vogel
b108845627 fix yada nonce offset 2024-08-01 15:10:20 -07:00
Matthew Vogel
046b2a17d3 finish updating for yadacoin 2024-08-01 00:01:09 -07:00
Matthew Vogel
5342f25fbf update constants for yadacoin 2024-07-31 23:45:34 -07:00
Matthew Vogel
5f6bcfe949 add yada constants 2024-07-31 23:26:37 -07:00
xmrig
ecef382326 Merge pull request #3522 from SChernykh/dev
Removed rx/keva
2024-07-31 15:41:25 +07:00
SChernykh
86f5db19d2 Removed rx/keva
Keva coin is too small now.
2024-07-31 08:28:05 +02:00
xmrig
b4a47d6ed0 Merge pull request #3518 from SChernykh/dev
Make Json::normalize more strict
2024-07-29 22:27:29 +07:00
SChernykh
f5095247e8 Make Json::normalize more strict
Rounding a regular FP value can give an invalid result - check the result too.
2024-07-29 17:14:21 +02:00
XMRig
2bb07fe633 #3515 Update build scripts for OpenSSL. 2024-07-24 21:02:53 +07:00
XMRig
a7be8cb80c Remove chdir call after fork. 2024-06-05 03:45:37 +07:00
XMRig
2ce16df423 Create signal handles after fork() call, replace #3492. 2024-06-05 03:23:58 +07:00
XMRig
5eaa6c152e v6.21.4-dev 2024-04-23 16:51:58 +07:00
XMRig
6972f727c1 Merge branch 'master' into dev 2024-04-23 16:50:58 +07:00
XMRig
7897f10c48 v6.21.3 2024-04-23 16:27:24 +07:00
XMRig
da2fb331b3 Merge branch 'dev' 2024-04-23 16:26:18 +07:00
xmrig
57f3e9c3da Update CHANGELOG.md 2024-04-23 16:17:26 +07:00
xmrig
1efe7e9562 Merge pull request #3462 from SChernykh/dev
RandomX: correct memcpy size for JIT initialization
2024-04-14 17:01:16 +07:00
SChernykh
caae7c64f0 RandomX: correct memcpy size for JIT initialization
No buffer overflow, better fix for `_FORTIFY_SOURCE`
2024-04-14 09:13:00 +02:00
xmrig
9fbdcc0ef0 Merge pull request #3461 from SChernykh/dev
RandomX: check pointer sizes during JIT initialization
2024-04-14 05:38:53 +07:00
SChernykh
c7c26d97fe RandomX: check pointer sizes during JIT initialization 2024-04-13 20:32:16 +02:00
XMRig
1f7e635b04 Use internal logger for error message. 2024-03-26 21:46:18 +07:00
XMRig
1c5786e3c5 v6.21.3-dev 2024-03-23 16:21:54 +07:00
XMRig
44eb4f0038 Merge branch 'master' into dev 2024-03-23 16:20:24 +07:00
122 changed files with 4766 additions and 4678 deletions

View File

@@ -1,3 +1,14 @@
# v6.22.0
- [#2411](https://github.com/xmrig/xmrig/pull/2411) Added support for [Yada](https://yadacoin.io/) (`rx/yada` algorithm).
- [#3492](https://github.com/xmrig/xmrig/pull/3492) Fixed `--background` option on Unix systems.
- [#3518](https://github.com/xmrig/xmrig/pull/3518) Possible fix for corrupted API output in rare cases.
- [#3522](https://github.com/xmrig/xmrig/pull/3522) Removed `rx/keva` algorithm.
- [#3525](https://github.com/xmrig/xmrig/pull/3525) Added Zen5 detection.
- [#3528](https://github.com/xmrig/xmrig/pull/3528) Added `rx/yada` OpenCL support.
# v6.21.3
- [#3462](https://github.com/xmrig/xmrig/pull/3462) RandomX: correct memcpy size for JIT initialization.
# v6.21.2
- The dependencies of all prebuilt releases have been updated. Support for old Ubuntu releases has been dropped.
- [#2800](https://github.com/xmrig/xmrig/issues/2800) Fixed donation with GhostRider algorithm for builds without KawPow algorithm.

View File

@@ -13,7 +13,6 @@ Option `coin` useful for pools without [algorithm negotiation](https://xmrig.com
| Name | Memory | Version | Description | Notes |
|------|--------|---------|-------------|-------|
| `kawpow` | - | 6.0.0+ | KawPow (Ravencoin) | GPU only |
| `rx/keva` | 1 MB | 5.9.0+ | RandomKEVA (RandomX variant for Keva). | |
| `astrobwt` | 20 MB | 5.8.0+ | AstroBWT (Dero). | |
| `cn-pico/tlo` | 256 KB | 5.5.0+ | CryptoNight-Pico (Talleo). | |
| `rx/sfx` | 2 MB | 5.4.0+ | RandomSFX (RandomX variant for Safex). | |

View File

@@ -1,8 +1,8 @@
#!/bin/sh -e
HWLOC_VERSION_MAJOR="2"
HWLOC_VERSION_MINOR="10"
HWLOC_VERSION_PATCH="0"
HWLOC_VERSION_MINOR="11"
HWLOC_VERSION_PATCH="2"
HWLOC_VERSION="${HWLOC_VERSION_MAJOR}.${HWLOC_VERSION_MINOR}.${HWLOC_VERSION_PATCH}"

View File

@@ -1,6 +1,6 @@
#!/bin/sh -e
OPENSSL_VERSION="1.1.1s"
OPENSSL_VERSION="1.1.1u"
mkdir -p deps
mkdir -p deps/include
@@ -8,7 +8,7 @@ mkdir -p deps/lib
mkdir -p build && cd build
wget https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz -O openssl-${OPENSSL_VERSION}.tar.gz
wget https://openssl.org/source/old/1.1.1/openssl-${OPENSSL_VERSION}.tar.gz -O openssl-${OPENSSL_VERSION}.tar.gz
tar -xzf openssl-${OPENSSL_VERSION}.tar.gz
cd openssl-${OPENSSL_VERSION}

View File

@@ -1,6 +1,6 @@
#!/bin/sh -e
OPENSSL_VERSION="3.0.13"
OPENSSL_VERSION="3.0.15"
mkdir -p deps
mkdir -p deps/include
@@ -8,7 +8,7 @@ mkdir -p deps/lib
mkdir -p build && cd build
wget https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz -O openssl-${OPENSSL_VERSION}.tar.gz
wget https://github.com/openssl/openssl/releases/download/openssl-${OPENSSL_VERSION}/openssl-${OPENSSL_VERSION}.tar.gz -O openssl-${OPENSSL_VERSION}.tar.gz
tar -xzf openssl-${OPENSSL_VERSION}.tar.gz
cd openssl-${OPENSSL_VERSION}

View File

@@ -1,6 +1,6 @@
#!/bin/sh -e
UV_VERSION="1.48.0"
UV_VERSION="1.49.2"
mkdir -p deps
mkdir -p deps/include

View File

@@ -50,7 +50,6 @@ function rx()
'randomx_constants_monero.h',
'randomx_constants_wow.h',
'randomx_constants_arqma.h',
'randomx_constants_keva.h',
'randomx_constants_graft.h',
'aes.cl',
'blake2b.cl',

View File

@@ -8,7 +8,7 @@ else
modprobe msr allow_writes=on
fi
if grep -E 'AMD Ryzen|AMD EPYC' /proc/cpuinfo > /dev/null;
if grep -E 'AMD Ryzen|AMD EPYC|AuthenticAMD' /proc/cpuinfo > /dev/null;
then
if grep "cpu family[[:space:]]\{1,\}:[[:space:]]25" /proc/cpuinfo > /dev/null;
then
@@ -28,6 +28,14 @@ if grep -E 'AMD Ryzen|AMD EPYC' /proc/cpuinfo > /dev/null;
wrmsr -a 0xc001102b 0x2000cc10
echo "MSR register values for Zen3 applied"
fi
elif grep "cpu family[[:space:]]\{1,\}:[[:space:]]26" /proc/cpuinfo > /dev/null;
then
echo "Detected Zen5 CPU"
wrmsr -a 0xc0011020 0x4400000000000
wrmsr -a 0xc0011021 0x4000000000040
wrmsr -a 0xc0011022 0x8680000401570000
wrmsr -a 0xc001102b 0x2040cc10
echo "MSR register values for Zen5 applied"
else
echo "Detected Zen1/Zen2 CPU"
wrmsr -a 0xc0011020 0

View File

@@ -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-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2024 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2024 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
@@ -23,7 +23,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <cstdlib>
#include <uv.h>
@@ -61,13 +60,13 @@ int xmrig::App::exec()
return 2;
}
m_signals = std::make_shared<Signals>(this);
int rc = 0;
if (background(rc)) {
return rc;
}
m_signals = std::make_shared<Signals>(this);
rc = m_controller->init();
if (rc != 0) {
return rc;

View File

@@ -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-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2024 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2024 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
@@ -22,7 +22,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <cstdlib>
#include <csignal>
#include <cerrno>
@@ -53,16 +52,9 @@ bool xmrig::App::background(int &rc)
return true;
}
i = setsid();
if (i < 0) {
if (setsid() < 0) {
LOG_ERR("setsid() failed (errno = %d)", errno);
}
i = chdir("/");
if (i < 0) {
LOG_ERR("chdir() failed (errno = %d)", errno);
}
return false;
}

View File

@@ -65,22 +65,22 @@ public:
}
}
# else
inline ~Thread() { m_thread.join(); delete m_worker; }
inline ~Thread() { m_thread.join(); }
inline void start(void *(*callback)(void *)) { m_thread = std::thread(callback, this); }
# endif
inline const T &config() const { return m_config; }
inline IBackend *backend() const { return m_backend; }
inline IWorker *worker() const { return m_worker; }
inline IWorker* worker() const { return m_worker.get(); }
inline size_t id() const { return m_id; }
inline void setWorker(IWorker *worker) { m_worker = worker; }
inline void setWorker(std::shared_ptr<IWorker> worker) { m_worker = worker; }
private:
const size_t m_id = 0;
const T m_config;
IBackend *m_backend;
IWorker *m_worker = nullptr;
std::shared_ptr<IWorker> m_worker;
#ifdef XMRIG_OS_APPLE
pthread_t m_thread{};

View File

@@ -62,19 +62,12 @@ public:
template<class T>
xmrig::Workers<T>::Workers() :
d_ptr(new WorkersPrivate())
d_ptr(std::make_shared<WorkersPrivate>())
{
}
template<class T>
xmrig::Workers<T>::~Workers()
{
delete d_ptr;
}
template<class T>
bool xmrig::Workers<T>::tick(uint64_t)
{
@@ -88,7 +81,7 @@ bool xmrig::Workers<T>::tick(uint64_t)
uint64_t hashCount = 0;
uint64_t rawHashes = 0;
for (Thread<T> *handle : m_workers) {
for (auto& handle : m_workers) {
IWorker *worker = handle->worker();
if (worker) {
worker->hashrateData(hashCount, ts, rawHashes);
@@ -135,10 +128,6 @@ void xmrig::Workers<T>::stop()
Nonce::stop(T::backend());
# endif
for (Thread<T> *worker : m_workers) {
delete worker;
}
m_workers.clear();
# ifdef XMRIG_MINER_PROJECT
@@ -166,7 +155,7 @@ void xmrig::Workers<T>::start(const std::vector<T> &data, const std::shared_ptr<
template<class T>
xmrig::IWorker *xmrig::Workers<T>::create(Thread<T> *)
std::shared_ptr<xmrig::IWorker> xmrig::Workers<T>::create(Thread<T> *)
{
return nullptr;
}
@@ -177,22 +166,21 @@ void *xmrig::Workers<T>::onReady(void *arg)
{
auto handle = static_cast<Thread<T>* >(arg);
IWorker *worker = create(handle);
assert(worker != nullptr);
std::shared_ptr<IWorker> worker = create(handle);
assert(worker);
if (!worker || !worker->selfTest()) {
LOG_ERR("%s " RED("thread ") RED_BOLD("#%zu") RED(" self-test failed"), T::tag(), worker ? worker->id() : 0);
handle->backend()->start(worker, false);
delete worker;
worker.reset();
handle->backend()->start(worker.get(), false);
return nullptr;
}
assert(handle->backend() != nullptr);
handle->setWorker(worker);
handle->backend()->start(worker, true);
handle->backend()->start(worker.get(), true);
return nullptr;
}
@@ -202,7 +190,7 @@ template<class T>
void xmrig::Workers<T>::start(const std::vector<T> &data, bool /*sleep*/)
{
for (const auto &item : data) {
m_workers.push_back(new Thread<T>(d_ptr->backend, m_workers.size(), item));
m_workers.emplace_back(std::make_shared<Thread<T>>(d_ptr->backend, m_workers.size(), item));
}
d_ptr->hashrate = std::make_shared<Hashrate>(m_workers.size());
@@ -211,7 +199,7 @@ void xmrig::Workers<T>::start(const std::vector<T> &data, bool /*sleep*/)
Nonce::touch(T::backend());
# endif
for (auto worker : m_workers) {
for (auto& worker : m_workers) {
worker->start(Workers<T>::onReady);
}
}
@@ -221,34 +209,34 @@ namespace xmrig {
template<>
xmrig::IWorker *xmrig::Workers<CpuLaunchData>::create(Thread<CpuLaunchData> *handle)
std::shared_ptr<xmrig::IWorker> Workers<CpuLaunchData>::create(Thread<CpuLaunchData> *handle)
{
# ifdef XMRIG_MINER_PROJECT
switch (handle->config().intensity) {
case 1:
return new CpuWorker<1>(handle->id(), handle->config());
return std::make_shared<CpuWorker<1>>(handle->id(), handle->config());
case 2:
return new CpuWorker<2>(handle->id(), handle->config());
return std::make_shared<CpuWorker<2>>(handle->id(), handle->config());
case 3:
return new CpuWorker<3>(handle->id(), handle->config());
return std::make_shared<CpuWorker<3>>(handle->id(), handle->config());
case 4:
return new CpuWorker<4>(handle->id(), handle->config());
return std::make_shared<CpuWorker<4>>(handle->id(), handle->config());
case 5:
return new CpuWorker<5>(handle->id(), handle->config());
return std::make_shared<CpuWorker<5>>(handle->id(), handle->config());
case 8:
return new CpuWorker<8>(handle->id(), handle->config());
return std::make_shared<CpuWorker<8>>(handle->id(), handle->config());
}
return nullptr;
# else
assert(handle->config().intensity == 1);
return new CpuWorker<1>(handle->id(), handle->config());
return std::make_shared<CpuWorker<1>>(handle->id(), handle->config());
# endif
}
@@ -258,9 +246,9 @@ template class Workers<CpuLaunchData>;
#ifdef XMRIG_FEATURE_OPENCL
template<>
xmrig::IWorker *xmrig::Workers<OclLaunchData>::create(Thread<OclLaunchData> *handle)
std::shared_ptr<xmrig::IWorker> Workers<OclLaunchData>::create(Thread<OclLaunchData> *handle)
{
return new OclWorker(handle->id(), handle->config());
return std::make_shared<OclWorker>(handle->id(), handle->config());
}
@@ -270,9 +258,9 @@ template class Workers<OclLaunchData>;
#ifdef XMRIG_FEATURE_CUDA
template<>
xmrig::IWorker *xmrig::Workers<CudaLaunchData>::create(Thread<CudaLaunchData> *handle)
std::shared_ptr<xmrig::IWorker> Workers<CudaLaunchData>::create(Thread<CudaLaunchData> *handle)
{
return new CudaWorker(handle->id(), handle->config());
return std::make_shared<CudaWorker>(handle->id(), handle->config());
}

View File

@@ -52,7 +52,6 @@ public:
XMRIG_DISABLE_COPY_MOVE(Workers)
Workers();
~Workers();
inline void start(const std::vector<T> &data) { start(data, true); }
@@ -67,20 +66,20 @@ public:
# endif
private:
static IWorker *create(Thread<T> *handle);
static std::shared_ptr<IWorker> create(Thread<T> *handle);
static void *onReady(void *arg);
void start(const std::vector<T> &data, bool sleep);
std::vector<Thread<T> *> m_workers;
WorkersPrivate *d_ptr;
std::vector<std::shared_ptr<Thread<T>>> m_workers;
std::shared_ptr<WorkersPrivate> d_ptr;
};
template<class T>
void xmrig::Workers<T>::jobEarlyNotification(const Job &job)
{
for (Thread<T>* t : m_workers) {
for (auto& t : m_workers) {
if (t->worker()) {
t->worker()->jobEarlyNotification(job);
}
@@ -89,20 +88,20 @@ void xmrig::Workers<T>::jobEarlyNotification(const Job &job)
template<>
IWorker *Workers<CpuLaunchData>::create(Thread<CpuLaunchData> *handle);
std::shared_ptr<IWorker> Workers<CpuLaunchData>::create(Thread<CpuLaunchData> *handle);
extern template class Workers<CpuLaunchData>;
#ifdef XMRIG_FEATURE_OPENCL
template<>
IWorker *Workers<OclLaunchData>::create(Thread<OclLaunchData> *handle);
std::shared_ptr<IWorker> Workers<OclLaunchData>::create(Thread<OclLaunchData> *handle);
extern template class Workers<OclLaunchData>;
#endif
#ifdef XMRIG_FEATURE_CUDA
template<>
IWorker *Workers<CudaLaunchData>::create(Thread<CudaLaunchData> *handle);
std::shared_ptr<IWorker> Workers<CudaLaunchData>::create(Thread<CudaLaunchData> *handle);
extern template class Workers<CudaLaunchData>;
#endif

View File

@@ -51,7 +51,7 @@ public:
};
static BenchStatePrivate *d_ptr = nullptr;
static std::shared_ptr<BenchStatePrivate> d_ptr;
std::atomic<uint64_t> BenchState::m_data{};
@@ -61,7 +61,7 @@ std::atomic<uint64_t> BenchState::m_data{};
bool xmrig::BenchState::isDone()
{
return d_ptr == nullptr;
return !d_ptr;
}
@@ -105,14 +105,13 @@ uint64_t xmrig::BenchState::start(size_t threads, const IBackend *backend)
void xmrig::BenchState::destroy()
{
delete d_ptr;
d_ptr = nullptr;
d_ptr.reset();
}
void xmrig::BenchState::done()
{
assert(d_ptr != nullptr && d_ptr->async && d_ptr->remaining > 0);
assert(d_ptr && d_ptr->async && d_ptr->remaining > 0);
const uint64_t ts = Chrono::steadyMSecs();
@@ -129,15 +128,15 @@ void xmrig::BenchState::done()
void xmrig::BenchState::init(IBenchListener *listener, uint32_t size)
{
assert(d_ptr == nullptr);
assert(!d_ptr);
d_ptr = new BenchStatePrivate(listener, size);
d_ptr = std::make_shared<BenchStatePrivate>(listener, size);
}
void xmrig::BenchState::setSize(uint32_t size)
{
assert(d_ptr != nullptr);
assert(d_ptr);
d_ptr->size = size;
}

View File

@@ -31,20 +31,20 @@
#endif
static xmrig::ICpuInfo *cpuInfo = nullptr;
static std::shared_ptr<xmrig::ICpuInfo> cpuInfo;
xmrig::ICpuInfo *xmrig::Cpu::info()
{
if (cpuInfo == nullptr) {
if (!cpuInfo) {
# if defined(XMRIG_FEATURE_HWLOC)
cpuInfo = new HwlocCpuInfo();
cpuInfo = std::make_shared<HwlocCpuInfo>();
# else
cpuInfo = new BasicCpuInfo();
cpuInfo = std::make_shared<BasicCpuInfo>();
# endif
}
return cpuInfo;
return cpuInfo.get();
}
@@ -56,6 +56,5 @@ rapidjson::Value xmrig::Cpu::toJSON(rapidjson::Document &doc)
void xmrig::Cpu::release()
{
delete cpuInfo;
cpuInfo = nullptr;
cpuInfo.reset();
}

View File

@@ -242,7 +242,7 @@ const char *xmrig::cpu_tag()
xmrig::CpuBackend::CpuBackend(Controller *controller) :
d_ptr(new CpuBackendPrivate(controller))
d_ptr(std::make_shared<CpuBackendPrivate>(controller))
{
d_ptr->workers.setBackend(this);
}
@@ -250,7 +250,6 @@ xmrig::CpuBackend::CpuBackend(Controller *controller) :
xmrig::CpuBackend::~CpuBackend()
{
delete d_ptr;
}

View File

@@ -70,7 +70,7 @@ protected:
# endif
private:
CpuBackendPrivate *d_ptr;
std::shared_ptr<CpuBackendPrivate> d_ptr;
};

View File

@@ -1,6 +1,6 @@
/* XMRig
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2024 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2024 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
@@ -122,17 +122,6 @@ size_t inline generate<Algorithm::RANDOM_X>(Threads<CpuThreads> &threads, uint32
}
}
if (!threads.isExist(Algorithm::RX_KEVA)) {
auto keva = cpuInfo->threads(Algorithm::RX_KEVA, limit);
if (keva == wow) {
threads.setAlias(Algorithm::RX_KEVA, Algorithm::kRX_WOW);
++count;
}
else {
count += threads.move(Algorithm::kRX_KEVA, std::move(keva));
}
}
if (!threads.isExist(Algorithm::RX_WOW)) {
count += threads.move(Algorithm::kRX_WOW, std::move(wow));
}

View File

@@ -57,7 +57,7 @@ static constexpr uint32_t kReserveCount = 32768;
#ifdef XMRIG_ALGO_CN_HEAVY
static std::mutex cn_heavyZen3MemoryMutex;
VirtualMemory* cn_heavyZen3Memory = nullptr;
std::shared_ptr<VirtualMemory> cn_heavyZen3Memory;
#endif
} // namespace xmrig
@@ -87,14 +87,14 @@ xmrig::CpuWorker<N>::CpuWorker(size_t id, const CpuLaunchData &data) :
if (!cn_heavyZen3Memory) {
// Round up number of threads to the multiple of 8
const size_t num_threads = ((m_threads + 7) / 8) * 8;
cn_heavyZen3Memory = new VirtualMemory(m_algorithm.l3() * num_threads, data.hugePages, false, false, node());
cn_heavyZen3Memory = std::make_shared<VirtualMemory>(m_algorithm.l3() * num_threads, data.hugePages, false, false, node());
}
m_memory = cn_heavyZen3Memory;
}
else
# endif
{
m_memory = new VirtualMemory(m_algorithm.l3() * N, data.hugePages, false, true, node());
m_memory = std::make_shared<VirtualMemory>(m_algorithm.l3() * N, data.hugePages, false, true, node());
}
# ifdef XMRIG_ALGO_GHOSTRIDER
@@ -107,7 +107,7 @@ template<size_t N>
xmrig::CpuWorker<N>::~CpuWorker()
{
# ifdef XMRIG_ALGO_RANDOMX
RxVm::destroy(m_vm);
m_vm.reset();
# endif
CnCtx::release(m_ctx, N);
@@ -116,7 +116,7 @@ xmrig::CpuWorker<N>::~CpuWorker()
if (m_memory != cn_heavyZen3Memory)
# endif
{
delete m_memory;
m_memory.reset();
}
# ifdef XMRIG_ALGO_GHOSTRIDER
@@ -148,7 +148,7 @@ void xmrig::CpuWorker<N>::allocateRandomX_VM()
}
else if (!dataset->get() && (m_job.currentJob().seed() != m_seed)) {
// Update RandomX light VM with the new seed
randomx_vm_set_cache(m_vm, dataset->cache()->get());
randomx_vm_set_cache(m_vm.get(), dataset->cache()->get());
}
m_seed = m_job.currentJob().seed();
}
@@ -296,7 +296,7 @@ void xmrig::CpuWorker<N>::start()
if (job.hasMinerSignature()) {
job.generateMinerSignature(m_job.blob(), job.size(), miner_signature_ptr);
}
randomx_calculate_hash_first(m_vm, tempHash, m_job.blob(), job.size());
randomx_calculate_hash_first(m_vm.get(), tempHash, m_job.blob(), job.size());
}
if (!nextRound()) {
@@ -307,7 +307,7 @@ void xmrig::CpuWorker<N>::start()
memcpy(miner_signature_saved, miner_signature_ptr, sizeof(miner_signature_saved));
job.generateMinerSignature(m_job.blob(), job.size(), miner_signature_ptr);
}
randomx_calculate_hash_next(m_vm, tempHash, m_job.blob(), job.size(), m_hash);
randomx_calculate_hash_next(m_vm.get(), tempHash, m_job.blob(), job.size(), m_hash);
}
else
# endif
@@ -359,7 +359,9 @@ void xmrig::CpuWorker<N>::start()
}
}
consumeJob();
if (!Nonce::isPaused()) {
consumeJob();
}
}
}

View File

@@ -66,7 +66,7 @@ protected:
void hashrateData(uint64_t &hashCount, uint64_t &timeStamp, uint64_t &rawHashes) const override;
void start() override;
inline const VirtualMemory *memory() const override { return m_memory; }
inline const VirtualMemory* memory() const override { return m_memory.get(); }
inline size_t intensity() const override { return N; }
inline void jobEarlyNotification(const Job&) override {}
@@ -92,11 +92,11 @@ private:
const Miner *m_miner;
const size_t m_threads;
cryptonight_ctx *m_ctx[N];
VirtualMemory *m_memory = nullptr;
std::shared_ptr<VirtualMemory> m_memory;
WorkerJob<N> m_job;
# ifdef XMRIG_ALGO_RANDOMX
randomx_vm *m_vm = nullptr;
std::shared_ptr<randomx_vm> m_vm;
Buffer m_seed;
# endif

View File

@@ -52,7 +52,8 @@ public:
ARCH_ZEN_PLUS,
ARCH_ZEN2,
ARCH_ZEN3,
ARCH_ZEN4
ARCH_ZEN4,
ARCH_ZEN5
};
enum MsrMod : uint32_t {
@@ -60,12 +61,13 @@ public:
MSR_MOD_RYZEN_17H,
MSR_MOD_RYZEN_19H,
MSR_MOD_RYZEN_19H_ZEN4,
MSR_MOD_RYZEN_1AH_ZEN5,
MSR_MOD_INTEL,
MSR_MOD_CUSTOM,
MSR_MOD_MAX
};
# define MSR_NAMES_LIST "none", "ryzen_17h", "ryzen_19h", "ryzen_19h_zen4", "intel", "custom"
# define MSR_NAMES_LIST "none", "ryzen_17h", "ryzen_19h", "ryzen_19h_zen4", "ryzen_1Ah_zen5", "intel", "custom"
enum Flag : uint32_t {
FLAG_AES,

View File

@@ -64,7 +64,7 @@ static_assert(kCpuFlagsSize == ICpuInfo::FLAG_MAX, "kCpuFlagsSize and FLAG_MAX m
#ifdef XMRIG_FEATURE_MSR
constexpr size_t kMsrArraySize = 6;
constexpr size_t kMsrArraySize = 7;
static const std::array<const char *, kMsrArraySize> msrNames = { MSR_NAMES_LIST };
static_assert(kMsrArraySize == ICpuInfo::MSR_MOD_MAX, "kMsrArraySize and MSR_MOD_MAX mismatch");
#endif
@@ -260,6 +260,11 @@ xmrig::BasicCpuInfo::BasicCpuInfo() :
}
break;
case 0x1a:
m_arch = ARCH_ZEN5;
m_msrMod = MSR_MOD_RYZEN_1AH_ZEN5;
break;
default:
m_msrMod = MSR_MOD_NONE;
break;

View File

@@ -326,7 +326,8 @@ void xmrig::HwlocCpuInfo::processTopLevelCache(hwloc_obj_t cache, const Algorith
}
}
if (scratchpad == 2 * oneMiB) {
// This code is supposed to run only on Intel CPUs
if ((vendor() == VENDOR_INTEL) && (scratchpad == 2 * oneMiB)) {
if (L2 && (cores.size() * oneMiB) == L2 && L2_associativity == 16 && L3 >= L2) {
L3 = L2;
extra = L2;

View File

@@ -114,7 +114,6 @@ size_t inline generate<Algorithm::RANDOM_X>(Threads<CudaThreads> &threads, const
auto rx = CudaThreads(devices, Algorithm::RX_0);
auto wow = CudaThreads(devices, Algorithm::RX_WOW);
auto arq = CudaThreads(devices, Algorithm::RX_ARQ);
auto kva = CudaThreads(devices, Algorithm::RX_KEVA);
if (!threads.isExist(Algorithm::RX_WOW) && wow != rx) {
count += threads.move(Algorithm::kRX_WOW, std::move(wow));
@@ -124,10 +123,6 @@ size_t inline generate<Algorithm::RANDOM_X>(Threads<CudaThreads> &threads, const
count += threads.move(Algorithm::kRX_ARQ, std::move(arq));
}
if (!threads.isExist(Algorithm::RX_KEVA) && kva != rx) {
count += threads.move(Algorithm::kRX_KEVA, std::move(kva));
}
count += threads.move(Algorithm::kRX, std::move(rx));
return count;

View File

@@ -158,7 +158,7 @@ void xmrig::CudaWorker::start()
std::this_thread::yield();
}
if (!consumeJob()) {
if (isReady() && !consumeJob()) {
return;
}
}

View File

@@ -283,7 +283,7 @@ const char *xmrig::ocl_tag()
xmrig::OclBackend::OclBackend(Controller *controller) :
d_ptr(new OclBackendPrivate(controller))
d_ptr(std::make_shared<OclBackendPrivate>(controller))
{
d_ptr->workers.setBackend(this);
}
@@ -291,7 +291,7 @@ xmrig::OclBackend::OclBackend(Controller *controller) :
xmrig::OclBackend::~OclBackend()
{
delete d_ptr;
d_ptr.reset();
OclLib::close();

View File

@@ -70,7 +70,7 @@ protected:
# endif
private:
OclBackendPrivate *d_ptr;
std::shared_ptr<OclBackendPrivate> d_ptr;
};

View File

@@ -170,7 +170,7 @@ void xmrig::OclWorker::start()
const uint64_t t = Chrono::steadyMSecs();
try {
m_runner->run(readUnaligned(m_job.nonce()), results);
m_runner->run(readUnaligned(m_job.nonce()), m_job.nonceOffset(), results);
}
catch (std::exception &ex) {
printError(id(), ex.what());
@@ -190,7 +190,7 @@ void xmrig::OclWorker::start()
std::this_thread::yield();
}
if (!consumeJob()) {
if (isReady() && !consumeJob()) {
return;
}
}

View File

@@ -22,8 +22,8 @@
#define ALGO_RX_WOW 0x72141177
#define ALGO_RX_ARQMA 0x72121061
#define ALGO_RX_SFX 0x72151273
#define ALGO_RX_KEVA 0x7214116b
#define ALGO_RX_GRAFT 0x72151267
#define ALGO_RX_YADA 0x72151279
#define ALGO_AR2_CHUKWA 0x61130000
#define ALGO_AR2_CHUKWA_V2 0x61140000
#define ALGO_AR2_WRKZ 0x61120000

View File

@@ -34,9 +34,9 @@ static const char cryptonight_cl[61447] = {
0x31,0x35,0x31,0x32,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x57,0x4f,0x57,0x20,0x30,0x78,0x37,0x32,0x31,
0x34,0x31,0x31,0x37,0x37,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x41,0x52,0x51,0x4d,0x41,0x20,0x30,0x78,0x37,0x32,
0x31,0x32,0x31,0x30,0x36,0x31,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x53,0x46,0x58,0x20,0x30,0x78,0x37,0x32,0x31,
0x35,0x31,0x32,0x37,0x33,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x4b,0x45,0x56,0x41,0x20,0x30,0x78,0x37,0x32,0x31,
0x34,0x31,0x31,0x36,0x62,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x47,0x52,0x41,0x46,0x54,0x20,0x30,0x78,0x37,0x32,
0x31,0x35,0x31,0x32,0x36,0x37,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x41,0x52,0x32,0x5f,0x43,0x48,0x55,0x4b,0x57,0x41,0x20,0x30,
0x35,0x31,0x32,0x37,0x33,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x47,0x52,0x41,0x46,0x54,0x20,0x30,0x78,0x37,0x32,
0x31,0x35,0x31,0x32,0x36,0x37,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x59,0x41,0x44,0x41,0x20,0x30,0x78,0x37,0x32,
0x31,0x35,0x31,0x32,0x37,0x39,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x41,0x52,0x32,0x5f,0x43,0x48,0x55,0x4b,0x57,0x41,0x20,0x30,
0x78,0x36,0x31,0x31,0x33,0x30,0x30,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x41,0x52,0x32,0x5f,0x43,0x48,0x55,0x4b,0x57,
0x41,0x5f,0x56,0x32,0x20,0x30,0x78,0x36,0x31,0x31,0x34,0x30,0x30,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x41,0x52,0x32,
0x5f,0x57,0x52,0x4b,0x5a,0x20,0x30,0x78,0x36,0x31,0x31,0x32,0x30,0x30,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x4b,0x41,

View File

@@ -225,6 +225,110 @@ __kernel void blake2b_initial_hash_double(__global void *out, __global const voi
t[7] = hash[7];
}
void blake2b_512_process_big_block(ulong *out, __global const ulong* in, uint in_len, uint out_len, uint nonce, uint nonce_offset)
{
ulong h[8] = { iv0 ^ (0x01010000u | out_len), iv1, iv2, iv3, iv4, iv5, iv6, iv7 };
for (uint t = 128; t < in_len; t += 128, in += 16) {
ulong m[16] = { in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7], in[8], in[9], in[10], in[11], in[12], in[13], in[14], in[15] };
const uint k0 = (nonce_offset + 0) - (t - 128);
const uint k1 = (nonce_offset + 1) - (t - 128);
const uint k2 = (nonce_offset + 2) - (t - 128);
const uint k3 = (nonce_offset + 3) - (t - 128);
if (k0 < 128) m[k0 / 8] |= (ulong)((nonce >> 0) & 255) << ((k0 % 8) * 8);
if (k1 < 128) m[k1 / 8] |= (ulong)((nonce >> 8) & 255) << ((k1 % 8) * 8);
if (k2 < 128) m[k2 / 8] |= (ulong)((nonce >> 16) & 255) << ((k2 % 8) * 8);
if (k3 < 128) m[k3 / 8] |= (ulong)((nonce >> 24) & 255) << ((k3 % 8) * 8);
ulong v[16] = { h[0], h[1], h[2], h[3], h[4], h[5], h[6], h[7], iv0, iv1, iv2, iv3, iv4 ^ t, iv5, iv6, iv7 };
BLAKE2B_ROUNDS();
h[0] ^= v[0] ^ v[ 8];
h[1] ^= v[1] ^ v[ 9];
h[2] ^= v[2] ^ v[10];
h[3] ^= v[3] ^ v[11];
h[4] ^= v[4] ^ v[12];
h[5] ^= v[5] ^ v[13];
h[6] ^= v[6] ^ v[14];
h[7] ^= v[7] ^ v[15];
}
uint k = in_len & 127;
if (k == 0) k = 128;
ulong m[16] = {
(k > 0) ? in[ 0] : 0,
(k > 8) ? in[ 1] : 0,
(k > 16) ? in[ 2] : 0,
(k > 24) ? in[ 3] : 0,
(k > 32) ? in[ 4] : 0,
(k > 40) ? in[ 5] : 0,
(k > 48) ? in[ 6] : 0,
(k > 56) ? in[ 7] : 0,
(k > 64) ? in[ 8] : 0,
(k > 72) ? in[ 9] : 0,
(k > 80) ? in[10] : 0,
(k > 88) ? in[11] : 0,
(k > 96) ? in[12] : 0,
(k > 104) ? in[13] : 0,
(k > 112) ? in[14] : 0,
(k > 120) ? in[15] : 0
};
const uint t = in_len - k;
const uint k0 = nonce_offset + 0 - t;
const uint k1 = nonce_offset + 1 - t;
const uint k2 = nonce_offset + 2 - t;
const uint k3 = nonce_offset + 3 - t;
if (k0 < k) m[k0 / 8] |= (ulong)((nonce >> 0) & 255) << ((k0 % 8) * 8);
if (k1 < k) m[k1 / 8] |= (ulong)((nonce >> 8) & 255) << ((k1 % 8) * 8);
if (k2 < k) m[k2 / 8] |= (ulong)((nonce >> 16) & 255) << ((k2 % 8) * 8);
if (k3 < k) m[k3 / 8] |= (ulong)((nonce >> 24) & 255) << ((k3 % 8) * 8);
if (k % 8) {
m[k / 8] &= (ulong)(-1) >> (64 - (k % 8) * 8);
}
ulong v[16] = { h[0], h[1], h[2], h[3], h[4], h[5], h[6], h[7], iv0, iv1, iv2, iv3, iv4 ^ in_len, iv5, ~iv6, iv7 };
BLAKE2B_ROUNDS();
if (out_len > 0) out[0] = h[0] ^ v[0] ^ v[8];
if (out_len > 8) out[1] = h[1] ^ v[1] ^ v[9];
if (out_len > 16) out[2] = h[2] ^ v[2] ^ v[10];
if (out_len > 24) out[3] = h[3] ^ v[3] ^ v[11];
if (out_len > 32) out[4] = h[4] ^ v[4] ^ v[12];
if (out_len > 40) out[5] = h[5] ^ v[5] ^ v[13];
if (out_len > 48) out[6] = h[6] ^ v[6] ^ v[14];
if (out_len > 56) out[7] = h[7] ^ v[7] ^ v[15];
}
__attribute__((reqd_work_group_size(64, 1, 1)))
__kernel void blake2b_initial_hash_big(__global void *out, __global const void* blockTemplate, uint blockTemplateSize, uint start_nonce, uint nonce_offset)
{
const uint global_index = get_global_id(0);
__global const ulong* p = (__global const ulong*) blockTemplate;
ulong hash[8];
blake2b_512_process_big_block(hash, p, blockTemplateSize, 64, start_nonce + global_index, nonce_offset);
__global ulong* t = ((__global ulong*) out) + global_index * 8;
t[0] = hash[0];
t[1] = hash[1];
t[2] = hash[2];
t[3] = hash[3];
t[4] = hash[4];
t[5] = hash[5];
t[6] = hash[6];
t[7] = hash[7];
}
#define in_len 256
#define out_len 32

View File

@@ -1,13 +1,11 @@
#include "../cn/algorithm.cl"
#if (ALGO == ALGO_RX_0)
#if ((ALGO == ALGO_RX_0) || (ALGO == ALGO_RX_YADA))
#include "randomx_constants_monero.h"
#elif (ALGO == ALGO_RX_WOW)
#include "randomx_constants_wow.h"
#elif (ALGO == ALGO_RX_ARQMA)
#include "randomx_constants_arqma.h"
#elif (ALGO == ALGO_RX_KEVA)
#include "randomx_constants_keva.h"
#elif (ALGO == ALGO_RX_GRAFT)
#include "randomx_constants_graft.h"
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,96 +0,0 @@
/*
Copyright (c) 2019 SChernykh
This file is part of RandomX OpenCL.
RandomX OpenCL 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.
RandomX OpenCL 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 RandomX OpenCL. If not, see <http://www.gnu.org/licenses/>.
*/
//Dataset base size in bytes. Must be a power of 2.
#define RANDOMX_DATASET_BASE_SIZE 2147483648
//Dataset extra size. Must be divisible by 64.
#define RANDOMX_DATASET_EXTRA_SIZE 33554368
//Scratchpad L3 size in bytes. Must be a power of 2.
#define RANDOMX_SCRATCHPAD_L3 1048576
//Scratchpad L2 size in bytes. Must be a power of two and less than or equal to RANDOMX_SCRATCHPAD_L3.
#define RANDOMX_SCRATCHPAD_L2 131072
//Scratchpad L1 size in bytes. Must be a power of two (minimum 64) and less than or equal to RANDOMX_SCRATCHPAD_L2.
#define RANDOMX_SCRATCHPAD_L1 16384
//Jump condition mask size in bits.
#define RANDOMX_JUMP_BITS 8
//Jump condition mask offset in bits. The sum of RANDOMX_JUMP_BITS and RANDOMX_JUMP_OFFSET must not exceed 16.
#define RANDOMX_JUMP_OFFSET 8
//Integer instructions
#define RANDOMX_FREQ_IADD_RS 16
#define RANDOMX_FREQ_IADD_M 7
#define RANDOMX_FREQ_ISUB_R 16
#define RANDOMX_FREQ_ISUB_M 7
#define RANDOMX_FREQ_IMUL_R 16
#define RANDOMX_FREQ_IMUL_M 4
#define RANDOMX_FREQ_IMULH_R 4
#define RANDOMX_FREQ_IMULH_M 1
#define RANDOMX_FREQ_ISMULH_R 4
#define RANDOMX_FREQ_ISMULH_M 1
#define RANDOMX_FREQ_IMUL_RCP 8
#define RANDOMX_FREQ_INEG_R 2
#define RANDOMX_FREQ_IXOR_R 15
#define RANDOMX_FREQ_IXOR_M 5
#define RANDOMX_FREQ_IROR_R 8
#define RANDOMX_FREQ_IROL_R 2
#define RANDOMX_FREQ_ISWAP_R 4
//Floating point instructions
#define RANDOMX_FREQ_FSWAP_R 4
#define RANDOMX_FREQ_FADD_R 16
#define RANDOMX_FREQ_FADD_M 5
#define RANDOMX_FREQ_FSUB_R 16
#define RANDOMX_FREQ_FSUB_M 5
#define RANDOMX_FREQ_FSCAL_R 6
#define RANDOMX_FREQ_FMUL_R 32
#define RANDOMX_FREQ_FDIV_M 4
#define RANDOMX_FREQ_FSQRT_R 6
//Control instructions
#define RANDOMX_FREQ_CBRANCH 25
#define RANDOMX_FREQ_CFROUND 1
//Store instruction
#define RANDOMX_FREQ_ISTORE 16
//No-op instruction
#define RANDOMX_FREQ_NOP 0
#define RANDOMX_DATASET_ITEM_SIZE 64
#define RANDOMX_PROGRAM_SIZE 256
#define HASH_SIZE 64
#define ENTROPY_SIZE (128 + RANDOMX_PROGRAM_SIZE * 8)
#define REGISTERS_SIZE 256
#define IMM_BUF_SIZE (RANDOMX_PROGRAM_SIZE * 4 - REGISTERS_SIZE)
#define IMM_INDEX_COUNT ((IMM_BUF_SIZE / 4) - 2)
#define VM_STATE_SIZE (REGISTERS_SIZE + IMM_BUF_SIZE + RANDOMX_PROGRAM_SIZE * 4)
#define ROUNDING_MODE (RANDOMX_FREQ_CFROUND ? -1 : 0)
// Scratchpad L1/L2/L3 bits
#define LOC_L1 (32 - 14)
#define LOC_L2 (32 - 17)
#define LOC_L3 (32 - 20)

View File

@@ -64,7 +64,7 @@ public:
virtual uint32_t deviceIndex() const = 0;
virtual void build() = 0;
virtual void init() = 0;
virtual void run(uint32_t nonce, uint32_t *hashOutput) = 0;
virtual void run(uint32_t nonce, uint32_t nonce_offset, uint32_t *hashOutput) = 0;
virtual void set(const Job &job, uint8_t *blob) = 0;
virtual void jobEarlyNotification(const Job&) = 0;

View File

@@ -0,0 +1,59 @@
/* 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>
*
* 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/opencl/kernels/rx/Blake2bInitialHashBigKernel.h"
#include "backend/opencl/wrappers/OclLib.h"
void xmrig::Blake2bInitialHashBigKernel::enqueue(cl_command_queue queue, size_t threads)
{
const size_t gthreads = threads;
static const size_t lthreads = 64;
enqueueNDRange(queue, 1, nullptr, &gthreads, &lthreads);
}
// __kernel void blake2b_initial_hash_double(__global void *out, __global const void* blockTemplate, uint blockTemplateSize, uint start_nonce)
void xmrig::Blake2bInitialHashBigKernel::setArgs(cl_mem out, cl_mem blockTemplate)
{
setArg(0, sizeof(cl_mem), &out);
setArg(1, sizeof(cl_mem), &blockTemplate);
}
void xmrig::Blake2bInitialHashBigKernel::setBlobSize(size_t size)
{
const uint32_t s = size;
setArg(2, sizeof(uint32_t), &s);
}
void xmrig::Blake2bInitialHashBigKernel::setNonce(uint32_t nonce, uint32_t nonce_offset)
{
setArg(3, sizeof(uint32_t), &nonce);
setArg(4, sizeof(uint32_t), &nonce_offset);
}

View File

@@ -0,0 +1,50 @@
/* 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>
*
* 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_BLAKE2BINITIALHASHBIGKERNEL_H
#define XMRIG_BLAKE2BINITIALHASHBIGKERNEL_H
#include "backend/opencl/wrappers/OclKernel.h"
namespace xmrig {
class Blake2bInitialHashBigKernel : public OclKernel
{
public:
inline Blake2bInitialHashBigKernel(cl_program program) : OclKernel(program, "blake2b_initial_hash_big") {}
void enqueue(cl_command_queue queue, size_t threads);
void setArgs(cl_mem out, cl_mem blockTemplate);
void setBlobSize(size_t size);
void setNonce(uint32_t nonce, uint32_t nonce_offset);
};
} // namespace xmrig
#endif /* XMRIG_BLAKE2BINITIALHASHBIGKERNEL_H */

View File

@@ -80,6 +80,7 @@ if (WITH_OPENCL)
if (WITH_RANDOMX)
list(APPEND HEADERS_BACKEND_OPENCL
src/backend/opencl/kernels/rx/Blake2bHashRegistersKernel.h
src/backend/opencl/kernels/rx/Blake2bInitialHashBigKernel.h
src/backend/opencl/kernels/rx/Blake2bInitialHashDoubleKernel.h
src/backend/opencl/kernels/rx/Blake2bInitialHashKernel.h
src/backend/opencl/kernels/rx/ExecuteVmKernel.h
@@ -97,6 +98,7 @@ if (WITH_OPENCL)
list(APPEND SOURCES_BACKEND_OPENCL
src/backend/opencl/generators/ocl_generic_rx_generator.cpp
src/backend/opencl/kernels/rx/Blake2bHashRegistersKernel.cpp
src/backend/opencl/kernels/rx/Blake2bInitialHashBigKernel.cpp
src/backend/opencl/kernels/rx/Blake2bInitialHashDoubleKernel.cpp
src/backend/opencl/kernels/rx/Blake2bInitialHashKernel.cpp
src/backend/opencl/kernels/rx/ExecuteVmKernel.cpp

View File

@@ -87,7 +87,7 @@ size_t xmrig::OclCnRunner::bufferSize() const
}
void xmrig::OclCnRunner::run(uint32_t nonce, uint32_t *hashOutput)
void xmrig::OclCnRunner::run(uint32_t nonce, uint32_t /*nonce_offset*/, uint32_t *hashOutput)
{
static const cl_uint zero = 0;

View File

@@ -42,7 +42,7 @@ public:
protected:
size_t bufferSize() const override;
void run(uint32_t nonce, uint32_t *hashOutput) override;
void run(uint32_t nonce, uint32_t nonce_offset, uint32_t *hashOutput) override;
void set(const Job &job, uint8_t *blob) override;
void build() override;
void init() override;

View File

@@ -75,7 +75,7 @@ OclKawPowRunner::~OclKawPowRunner()
}
void OclKawPowRunner::run(uint32_t nonce, uint32_t *hashOutput)
void OclKawPowRunner::run(uint32_t nonce, uint32_t /*nonce_offset*/, uint32_t *hashOutput)
{
const size_t local_work_size = m_workGroupSize;
const size_t global_work_offset = nonce;

View File

@@ -40,7 +40,7 @@ public:
~OclKawPowRunner() override;
protected:
void run(uint32_t nonce, uint32_t *hashOutput) override;
void run(uint32_t nonce, uint32_t nonce_offset, uint32_t *hashOutput) override;
void set(const Job &job, uint8_t *blob) override;
void build() override;
void init() override;

View File

@@ -26,6 +26,7 @@
#include "backend/opencl/kernels/rx/Blake2bHashRegistersKernel.h"
#include "backend/opencl/kernels/rx/Blake2bInitialHashKernel.h"
#include "backend/opencl/kernels/rx/Blake2bInitialHashDoubleKernel.h"
#include "backend/opencl/kernels/rx/Blake2bInitialHashBigKernel.h"
#include "backend/opencl/kernels/rx/FillAesKernel.h"
#include "backend/opencl/kernels/rx/FindSharesKernel.h"
#include "backend/opencl/kernels/rx/HashAesKernel.h"
@@ -73,6 +74,7 @@ xmrig::OclRxBaseRunner::~OclRxBaseRunner()
delete m_hashAes1Rx4;
delete m_blake2b_initial_hash;
delete m_blake2b_initial_hash_double;
delete m_blake2b_initial_hash_big;
delete m_blake2b_hash_registers_32;
delete m_blake2b_hash_registers_64;
delete m_find_shares;
@@ -85,7 +87,7 @@ xmrig::OclRxBaseRunner::~OclRxBaseRunner()
}
void xmrig::OclRxBaseRunner::run(uint32_t nonce, uint32_t *hashOutput)
void xmrig::OclRxBaseRunner::run(uint32_t nonce, uint32_t nonce_offset, uint32_t *hashOutput)
{
static const uint32_t zero = 0;
@@ -96,8 +98,7 @@ void xmrig::OclRxBaseRunner::run(uint32_t nonce, uint32_t *hashOutput)
m_blake2b_initial_hash_double->setNonce(nonce);
}
else {
hashOutput[0xFF] = 0;
return;
m_blake2b_initial_hash_big->setNonce(nonce, nonce_offset);
}
m_find_shares->setNonce(nonce);
@@ -107,9 +108,12 @@ void xmrig::OclRxBaseRunner::run(uint32_t nonce, uint32_t *hashOutput)
if (m_jobSize <= 128) {
m_blake2b_initial_hash->enqueue(m_queue, m_intensity);
}
else {
else if (m_jobSize <= 256) {
m_blake2b_initial_hash_double->enqueue(m_queue, m_intensity);
}
else {
m_blake2b_initial_hash_big->enqueue(m_queue, m_intensity);
}
m_fillAes1Rx4_scratchpad->enqueue(m_queue, m_intensity);
@@ -150,12 +154,15 @@ void xmrig::OclRxBaseRunner::set(const Job &job, uint8_t *blob)
memset(blob + job.size(), 0, Job::kMaxBlobSize - job.size());
}
memset(blob + job.nonceOffset(), 0, job.nonceSize());
enqueueWriteBuffer(m_input, CL_TRUE, 0, Job::kMaxBlobSize, blob);
m_jobSize = job.size();
m_blake2b_initial_hash->setBlobSize(job.size());
m_blake2b_initial_hash_double->setBlobSize(job.size());
m_blake2b_initial_hash_big->setBlobSize(job.size());
m_find_shares->setTarget(job.target());
}
@@ -191,6 +198,9 @@ void xmrig::OclRxBaseRunner::build()
m_blake2b_initial_hash_double = new Blake2bInitialHashDoubleKernel(m_program);
m_blake2b_initial_hash_double->setArgs(m_hashes, m_input);
m_blake2b_initial_hash_big = new Blake2bInitialHashBigKernel(m_program);
m_blake2b_initial_hash_big->setArgs(m_hashes, m_input);
m_blake2b_hash_registers_32 = new Blake2bHashRegistersKernel(m_program, "blake2b_hash_registers_32");
m_blake2b_hash_registers_64 = new Blake2bHashRegistersKernel(m_program, "blake2b_hash_registers_64");

View File

@@ -36,6 +36,7 @@ namespace xmrig {
class Blake2bHashRegistersKernel;
class Blake2bInitialHashKernel;
class Blake2bInitialHashDoubleKernel;
class Blake2bInitialHashBigKernel;
class FillAesKernel;
class FindSharesKernel;
class HashAesKernel;
@@ -53,7 +54,7 @@ protected:
size_t bufferSize() const override;
void build() override;
void init() override;
void run(uint32_t nonce, uint32_t *hashOutput) override;
void run(uint32_t nonce, uint32_t nonce_offset, uint32_t *hashOutput) override;
void set(const Job &job, uint8_t *blob) override;
protected:
@@ -63,6 +64,7 @@ protected:
Blake2bHashRegistersKernel *m_blake2b_hash_registers_64 = nullptr;
Blake2bInitialHashKernel *m_blake2b_initial_hash = nullptr;
Blake2bInitialHashDoubleKernel *m_blake2b_initial_hash_double = nullptr;
Blake2bInitialHashBigKernel* m_blake2b_initial_hash_big = nullptr;
Buffer m_seed;
cl_mem m_dataset = nullptr;
cl_mem m_entropy = nullptr;

View File

@@ -1,6 +1,6 @@
/* XMRig
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2023 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2024 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2024 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
@@ -25,6 +25,8 @@
#include "base/crypto/keccak.h"
#include "base/io/Env.h"
#include "base/io/json/Json.h"
#include "base/io/log/Log.h"
#include "base/io/log/Tags.h"
#include "base/kernel/Base.h"
#include "base/tools/Chrono.h"
#include "base/tools/Cvt.h"
@@ -39,7 +41,6 @@
#include <thread>
#include <iostream>
namespace xmrig {
@@ -81,8 +82,7 @@ static rapidjson::Value getResources(rapidjson::Document &doc)
xmrig::Api::Api(Base *base) :
m_base(base),
m_timestamp(Chrono::currentMSecsSinceEpoch()),
m_httpd(nullptr)
m_timestamp(Chrono::currentMSecsSinceEpoch())
{
base->addListener(this);
@@ -95,8 +95,7 @@ xmrig::Api::~Api()
# ifdef XMRIG_FEATURE_HTTP
if (m_httpd) {
m_httpd->stop();
delete m_httpd;
m_httpd = nullptr; // Ensure the pointer is set to nullptr after deletion
m_httpd.reset();
}
# endif
}
@@ -116,11 +115,11 @@ void xmrig::Api::start()
# ifdef XMRIG_FEATURE_HTTP
if (!m_httpd) {
m_httpd = new Httpd(m_base);
m_httpd = std::make_shared<Httpd>(m_base);
if (!m_httpd->start()) {
std::cerr << "HTTP server failed to start." << std::endl;
delete m_httpd; // Properly handle failure to start
m_httpd = nullptr;
LOG_ERR("%s " RED_BOLD("HTTP API server failed to start."), Tags::network());
m_httpd.reset();
}
}
# endif

View File

@@ -1,6 +1,6 @@
/* XMRig
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2023 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2024 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2024 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
@@ -66,7 +66,7 @@ private:
Base *m_base;
char m_id[32]{};
const uint64_t m_timestamp;
Httpd *m_httpd = nullptr;
std::shared_ptr<Httpd> m_httpd;
std::vector<IApiListener *> m_listeners;
String m_workerId;
uint8_t m_ticks = 0;

View File

@@ -69,13 +69,13 @@ bool xmrig::Httpd::start()
bool tls = false;
# ifdef XMRIG_FEATURE_TLS
m_http = new HttpsServer(m_httpListener);
m_http = std::make_shared<HttpsServer>(m_httpListener);
tls = m_http->setTls(m_base->config()->tls());
# else
m_http = new HttpServer(m_httpListener);
m_http = std::make_shared<HttpServer>(m_httpListener);
# endif
m_server = new TcpServer(config.host(), config.port(), m_http);
m_server = std::make_shared<TcpServer>(config.host(), config.port(), m_http.get());
const int rc = m_server->bind();
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CSI "1;%dm%s:%d" " " RED_BOLD("%s"),
@@ -112,9 +112,6 @@ bool xmrig::Httpd::start()
void xmrig::Httpd::stop()
{
delete m_server;
delete m_http;
m_server = nullptr;
m_http = nullptr;
m_port = 0;

View File

@@ -55,13 +55,13 @@ private:
const Base *m_base;
std::shared_ptr<IHttpListener> m_httpListener;
TcpServer *m_server = nullptr;
std::shared_ptr<TcpServer> m_server;
uint16_t m_port = 0;
# ifdef XMRIG_FEATURE_TLS
HttpsServer *m_http = nullptr;
std::shared_ptr<HttpsServer> m_http;
# else
HttpServer *m_http = nullptr;
std::shared_ptr<HttpServer> m_http;
# endif
};

View File

@@ -81,7 +81,7 @@ const char *Algorithm::kRX_WOW = "rx/wow";
const char *Algorithm::kRX_ARQ = "rx/arq";
const char *Algorithm::kRX_GRAFT = "rx/graft";
const char *Algorithm::kRX_SFX = "rx/sfx";
const char *Algorithm::kRX_KEVA = "rx/keva";
const char *Algorithm::kRX_YADA = "rx/yada";
#endif
#ifdef XMRIG_ALGO_ARGON2
@@ -147,7 +147,7 @@ static const std::map<uint32_t, const char *> kAlgorithmNames = {
ALGO_NAME(RX_ARQ),
ALGO_NAME(RX_GRAFT),
ALGO_NAME(RX_SFX),
ALGO_NAME(RX_KEVA),
ALGO_NAME(RX_YADA),
# endif
# ifdef XMRIG_ALGO_ARGON2
@@ -261,8 +261,8 @@ static const std::map<const char *, Algorithm::Id, aliasCompare> kAlgorithmAlias
ALGO_ALIAS(RX_GRAFT, "randomgraft"),
ALGO_ALIAS_AUTO(RX_SFX), ALGO_ALIAS(RX_SFX, "randomx/sfx"),
ALGO_ALIAS(RX_SFX, "randomsfx"),
ALGO_ALIAS_AUTO(RX_KEVA), ALGO_ALIAS(RX_KEVA, "randomx/keva"),
ALGO_ALIAS(RX_KEVA, "randomkeva"),
ALGO_ALIAS_AUTO(RX_YADA), ALGO_ALIAS(RX_YADA, "randomx/yada"),
ALGO_ALIAS(RX_YADA, "randomyada"),
# endif
# ifdef XMRIG_ALGO_ARGON2
@@ -350,7 +350,7 @@ std::vector<xmrig::Algorithm> xmrig::Algorithm::all(const std::function<bool(con
CN_HEAVY_0, CN_HEAVY_TUBE, CN_HEAVY_XHV,
CN_PICO_0, CN_PICO_TLO,
CN_UPX2,
RX_0, RX_WOW, RX_ARQ, RX_GRAFT, RX_SFX, RX_KEVA,
RX_0, RX_WOW, RX_ARQ, RX_GRAFT, RX_SFX, RX_YADA,
AR2_CHUKWA, AR2_CHUKWA_V2, AR2_WRKZ,
KAWPOW_RVN,
GHOSTRIDER_RTM

View File

@@ -77,7 +77,7 @@ public:
RX_ARQ = 0x72121061, // "rx/arq" RandomARQ (Arqma).
RX_GRAFT = 0x72151267, // "rx/graft" RandomGRAFT (Graft).
RX_SFX = 0x72151273, // "rx/sfx" RandomSFX (Safex Cash).
RX_KEVA = 0x7214116b, // "rx/keva" RandomKEVA (Keva).
RX_YADA = 0x72151279, // "rx/yada" RandomYada (YadaCoin).
AR2_CHUKWA = 0x61130000, // "argon2/chukwa" Argon2id (Chukwa).
AR2_CHUKWA_V2 = 0x61140000, // "argon2/chukwav2" Argon2id (Chukwa v2).
AR2_WRKZ = 0x61120000, // "argon2/wrkz" Argon2id (WRKZ)
@@ -143,7 +143,7 @@ public:
static const char *kRX_ARQ;
static const char *kRX_GRAFT;
static const char *kRX_SFX;
static const char *kRX_KEVA;
static const char *kRX_YADA;
# endif
# ifdef XMRIG_ALGO_ARGON2

View File

@@ -50,11 +50,11 @@ static const CoinInfo coinInfo[] = {
{ Algorithm::CN_R, "SUMO", "Sumokoin", 240, 1000000000, BLUE_BG_BOLD( WHITE_BOLD_S " sumo ") },
{ Algorithm::RX_ARQ, "ARQ", "ArQmA", 120, 1000000000, BLUE_BG_BOLD( WHITE_BOLD_S " arqma ") },
{ Algorithm::RX_GRAFT, "GRFT", "Graft", 120, 10000000000, BLUE_BG_BOLD( WHITE_BOLD_S " graft ") },
{ Algorithm::RX_KEVA, "KVA", "Kevacoin", 0, 0, MAGENTA_BG_BOLD(WHITE_BOLD_S " keva ") },
{ Algorithm::KAWPOW_RVN, "RVN", "Ravencoin", 0, 0, BLUE_BG_BOLD( WHITE_BOLD_S " raven ") },
{ Algorithm::RX_WOW, "WOW", "Wownero", 300, 100000000000, MAGENTA_BG_BOLD(WHITE_BOLD_S " wownero ") },
{ Algorithm::RX_0, "ZEPH", "Zephyr", 120, 1000000000000, BLUE_BG_BOLD( WHITE_BOLD_S " zephyr ") },
{ Algorithm::RX_0, "Townforge","Townforge", 30, 100000000, MAGENTA_BG_BOLD(WHITE_BOLD_S " townforge ") },
{ Algorithm::RX_YADA, "YDA", "YadaCoin", 120, 100000000, BLUE_BG_BOLD( WHITE_BOLD_S " yada ") },
};

View File

@@ -36,11 +36,11 @@ public:
SUMO,
ARQMA,
GRAFT,
KEVA,
RAVEN,
WOWNERO,
ZEPHYR,
TOWNFORGE,
YADA,
MAX
};

View File

@@ -128,7 +128,7 @@ public:
} // namespace xmrig
xmrig::Async::Async(Callback callback) : d_ptr(new AsyncPrivate())
xmrig::Async::Async(Callback callback) : d_ptr(std::make_shared<AsyncPrivate>())
{
d_ptr->callback = std::move(callback);
d_ptr->async = new uv_async_t;
@@ -151,8 +151,6 @@ xmrig::Async::Async(IAsyncListener *listener) : d_ptr(new AsyncPrivate())
xmrig::Async::~Async()
{
Handle::close(d_ptr->async);
delete d_ptr;
}

View File

@@ -49,7 +49,7 @@ public:
void send();
private:
AsyncPrivate *d_ptr;
std::shared_ptr<AsyncPrivate> d_ptr;
};

View File

@@ -36,7 +36,7 @@ xmrig::Watcher::Watcher(const String &path, IWatcherListener *listener) :
m_listener(listener),
m_path(path)
{
m_timer = new Timer(this);
m_timer = std::make_shared<Timer>(this);
m_fsEvent = new uv_fs_event_t;
m_fsEvent->data = this;
@@ -48,8 +48,6 @@ xmrig::Watcher::Watcher(const String &path, IWatcherListener *listener) :
xmrig::Watcher::~Watcher()
{
delete m_timer;
Handle::close(m_fsEvent);
}

View File

@@ -60,7 +60,7 @@ private:
IWatcherListener *m_listener;
String m_path;
Timer *m_timer;
std::shared_ptr<Timer> m_timer;
uv_fs_event_t *m_fsEvent;
};

View File

@@ -211,11 +211,13 @@ rapidjson::Value xmrig::Json::normalize(double value, bool zero)
{
using namespace rapidjson;
if (!std::isnormal(value)) {
const double value_rounded = floor(value * 100.0) / 100.0;
if (!std::isnormal(value) || !std::isnormal(value_rounded)) {
return zero ? Value(0.0) : Value(kNullType);
}
return Value(floor(value * 100.0) / 100.0);
return Value(value_rounded);
}

View File

@@ -66,17 +66,10 @@ public:
LogPrivate() = default;
~LogPrivate() = default;
inline ~LogPrivate()
{
for (auto backend : m_backends) {
delete backend;
}
}
inline void add(ILogBackend *backend) { m_backends.push_back(backend); }
inline void add(std::shared_ptr<ILogBackend> backend) { m_backends.emplace_back(backend); }
void print(Log::Level level, const char *fmt, va_list args)
@@ -108,7 +101,7 @@ public:
}
if (!m_backends.empty()) {
for (auto backend : m_backends) {
for (auto& backend : m_backends) {
backend->print(ts, level, m_buf, offset, size, true);
backend->print(ts, level, txt.c_str(), offset ? (offset - 11) : 0, txt.size(), false);
}
@@ -188,13 +181,13 @@ private:
char m_buf[Log::kMaxBufferSize]{};
std::mutex m_mutex;
std::vector<ILogBackend*> m_backends;
std::vector<std::shared_ptr<ILogBackend>> m_backends;
};
bool Log::m_background = false;
bool Log::m_colors = true;
LogPrivate *Log::d = nullptr;
std::shared_ptr<LogPrivate> Log::d{};
uint32_t Log::m_verbose = 0;
@@ -202,7 +195,7 @@ uint32_t Log::m_verbose = 0;
void xmrig::Log::add(ILogBackend *backend)
void xmrig::Log::add(std::shared_ptr<ILogBackend> backend)
{
assert(d != nullptr);
@@ -214,14 +207,13 @@ void xmrig::Log::add(ILogBackend *backend)
void xmrig::Log::destroy()
{
delete d;
d = nullptr;
d.reset();
}
void xmrig::Log::init()
{
d = new LogPrivate();
d = std::make_shared<LogPrivate>();
}

View File

@@ -23,6 +23,7 @@
#include <cstddef>
#include <cstdint>
#include <memory>
namespace xmrig {
@@ -49,7 +50,7 @@ public:
constexpr static size_t kMaxBufferSize = 16384;
static void add(ILogBackend *backend);
static void add(std::shared_ptr<ILogBackend> backend);
static void destroy();
static void init();
static void print(const char *fmt, ...);
@@ -66,7 +67,7 @@ public:
private:
static bool m_background;
static bool m_colors;
static LogPrivate *d;
static std::shared_ptr<LogPrivate> d;
static uint32_t m_verbose;
};

View File

@@ -80,11 +80,10 @@ public:
inline ~BasePrivate()
{
# ifdef XMRIG_FEATURE_API
delete api;
api.reset();
# endif
delete config;
delete watcher;
watcher.reset();
NetBuffer::destroy();
}
@@ -98,27 +97,25 @@ public:
}
inline void replace(Config *newConfig)
inline void replace(std::shared_ptr<Config> newConfig)
{
Config *previousConfig = config;
auto previousConfig = config;
config = newConfig;
for (IBaseListener *listener : listeners) {
listener->onConfigChanged(config, previousConfig);
listener->onConfigChanged(config.get(), previousConfig.get());
}
delete previousConfig;
}
Api *api = nullptr;
Config *config = nullptr;
std::shared_ptr<Api> api;
std::shared_ptr<Config> config;
std::vector<IBaseListener *> listeners;
Watcher *watcher = nullptr;
std::shared_ptr<Watcher> watcher;
private:
inline static Config *load(Process *process)
inline static std::shared_ptr<Config> load(Process *process)
{
JsonChain chain;
ConfigTransform transform;
@@ -127,29 +124,29 @@ private:
ConfigTransform::load(chain, process, transform);
if (read(chain, config)) {
return config.release();
return config;
}
chain.addFile(Process::location(Process::DataLocation, "config.json"));
if (read(chain, config)) {
return config.release();
return config;
}
chain.addFile(Process::location(Process::HomeLocation, "." APP_ID ".json"));
if (read(chain, config)) {
return config.release();
return config;
}
chain.addFile(Process::location(Process::HomeLocation, ".config" XMRIG_DIR_SEPARATOR APP_ID ".json"));
if (read(chain, config)) {
return config.release();
return config;
}
# ifdef XMRIG_FEATURE_EMBEDDED_CONFIG
chain.addRaw(default_config);
if (read(chain, config)) {
return config.release();
return config;
}
# endif
@@ -162,7 +159,7 @@ private:
xmrig::Base::Base(Process *process)
: d_ptr(new BasePrivate(process))
: d_ptr(std::make_shared<BasePrivate>(process))
{
}
@@ -170,7 +167,6 @@ xmrig::Base::Base(Process *process)
xmrig::Base::~Base()
{
delete d_ptr;
}
@@ -183,7 +179,7 @@ bool xmrig::Base::isReady() const
int xmrig::Base::init()
{
# ifdef XMRIG_FEATURE_API
d_ptr->api = new Api(this);
d_ptr->api = std::make_shared<Api>(this);
d_ptr->api->addListener(this);
# endif
@@ -193,16 +189,16 @@ int xmrig::Base::init()
Log::setBackground(true);
}
else {
Log::add(new ConsoleLog(config()->title()));
Log::add(std::make_shared<ConsoleLog>(config()->title()));
}
if (config()->logFile()) {
Log::add(new FileLog(config()->logFile()));
Log::add(std::make_shared<FileLog>(config()->logFile()));
}
# ifdef HAVE_SYSLOG_H
if (config()->isSyslog()) {
Log::add(new SysLog());
Log::add(std::make_shared<SysLog>());
}
# endif
@@ -221,7 +217,7 @@ void xmrig::Base::start()
}
if (config()->isWatch()) {
d_ptr->watcher = new Watcher(config()->fileName(), this);
d_ptr->watcher = std::make_shared<Watcher>(config()->fileName(), this);
}
}
@@ -232,8 +228,7 @@ void xmrig::Base::stop()
api()->stop();
# endif
delete d_ptr->watcher;
d_ptr->watcher = nullptr;
d_ptr->watcher.reset();
}
@@ -241,7 +236,7 @@ xmrig::Api *xmrig::Base::api() const
{
assert(d_ptr->api != nullptr);
return d_ptr->api;
return d_ptr->api.get();
}
@@ -258,18 +253,14 @@ bool xmrig::Base::reload(const rapidjson::Value &json)
return false;
}
auto config = new Config();
auto config = std::make_shared<Config>();
if (!config->read(reader, d_ptr->config->fileName())) {
delete config;
return false;
}
const bool saved = config->save();
if (config->isWatch() && d_ptr->watcher && saved) {
delete config;
return true;
}
@@ -279,11 +270,11 @@ bool xmrig::Base::reload(const rapidjson::Value &json)
}
xmrig::Config *xmrig::Base::config() const
xmrig::Config* xmrig::Base::config() const
{
assert(d_ptr->config != nullptr);
assert(d_ptr->config);
return d_ptr->config;
return d_ptr->config.get();
}
@@ -300,12 +291,10 @@ void xmrig::Base::onFileChanged(const String &fileName)
JsonChain chain;
chain.addFile(fileName);
auto config = new Config();
auto config = std::make_shared<Config>();
if (!config->read(chain, chain.fileName())) {
LOG_ERR("%s " RED("reloading failed"), Tags::config());
delete config;
return;
}

View File

@@ -64,7 +64,7 @@ protected:
# endif
private:
BasePrivate *d_ptr;
std::shared_ptr<BasePrivate> d_ptr;
};

View File

@@ -29,13 +29,13 @@
namespace xmrig {
static Storage<DnsUvBackend> *storage = nullptr;
static std::shared_ptr<Storage<DnsUvBackend>> storage = nullptr;
Storage<DnsUvBackend> &DnsUvBackend::getStorage()
{
if (storage == nullptr) {
storage = new Storage<DnsUvBackend>();
if (!storage) {
storage = std::make_shared<Storage<DnsUvBackend>>();
}
return *storage;
@@ -67,8 +67,7 @@ xmrig::DnsUvBackend::~DnsUvBackend()
storage->release(m_key);
if (storage->isEmpty()) {
delete storage;
storage = nullptr;
storage.reset();
}
}

View File

@@ -363,7 +363,7 @@ bool xmrig::Client::parseJob(const rapidjson::Value &params, int *code)
Job job(has<EXT_NICEHASH>(), m_pool.algorithm(), m_rpcId);
if (!job.setId(params["job_id"].GetString())) {
if (!job.setId(Json::getString(params, "job_id"))) {
*code = 3;
return false;
}
@@ -400,7 +400,7 @@ bool xmrig::Client::parseJob(const rapidjson::Value &params, int *code)
}
}
if (!job.setTarget(params["target"].GetString())) {
if (!job.setTarget(Json::getString(params, "target"))) {
*code = 5;
return false;
}

View File

@@ -87,14 +87,13 @@ xmrig::DaemonClient::DaemonClient(int id, IClientListener *listener) :
BaseClient(id, listener)
{
m_httpListener = std::make_shared<HttpListener>(this);
m_timer = new Timer(this);
m_timer = std::make_shared<Timer>(this);
m_key = m_storage.add(this);
}
xmrig::DaemonClient::~DaemonClient()
{
delete m_timer;
delete m_ZMQSocket;
}
@@ -104,9 +103,6 @@ void xmrig::DaemonClient::deleteLater()
if (m_pool.zmq_port() >= 0) {
ZMQClose(true);
}
else {
delete this;
}
}

View File

@@ -107,7 +107,7 @@ private:
uint64_t m_jobSteadyMs = 0;
String m_tlsFingerprint;
String m_tlsVersion;
Timer *m_timer;
std::shared_ptr<Timer> m_timer;
uint64_t m_blocktemplateRequestHeight = 0;
WalletAddress m_walletAddress;

View File

@@ -7,8 +7,8 @@
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
* Copyright 2019 Howard Chu <https://github.com/hyc>
* Copyright 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2024 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2024 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
@@ -24,11 +24,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <cassert>
#include <cstring>
#include "base/net/stratum/Job.h"
#include "base/tools/Alignment.h"
#include "base/tools/Buffer.h"
@@ -112,35 +110,69 @@ bool xmrig::Job::setSeedHash(const char *hash)
bool xmrig::Job::setTarget(const char *target)
{
if (!target) {
static auto parse = [](const char *target, size_t size, const Algorithm &algorithm) -> uint64_t {
if (algorithm == Algorithm::RX_YADA) {
return strtoull(target, nullptr, 16);
}
const auto raw = Cvt::fromHex(target, size);
switch (raw.size()) {
case 4:
return 0xFFFFFFFFFFFFFFFFULL / (0xFFFFFFFFULL / uint64_t(*reinterpret_cast<const uint32_t *>(raw.data())));
case 8:
return *reinterpret_cast<const uint64_t *>(raw.data());
default:
break;
}
return 0;
};
const size_t size = target ? strlen(target) : 0;
if (size < 4 || (m_target = parse(target, size, algorithm())) == 0) {
return false;
}
const auto raw = Cvt::fromHex(target, strlen(target));
const size_t size = raw.size();
if (size == 4) {
m_target = 0xFFFFFFFFFFFFFFFFULL / (0xFFFFFFFFULL / uint64_t(*reinterpret_cast<const uint32_t *>(raw.data())));
}
else if (size == 8) {
m_target = *reinterpret_cast<const uint64_t *>(raw.data());
}
else {
return false;
}
# ifdef XMRIG_PROXY_PROJECT
assert(sizeof(m_rawTarget) > (size * 2));
memset(m_rawTarget, 0, sizeof(m_rawTarget));
memcpy(m_rawTarget, target, std::min(size * 2, sizeof(m_rawTarget)));
# endif
m_diff = toDiff(m_target);
# ifdef XMRIG_PROXY_PROJECT
if (size >= sizeof(m_rawTarget)) {
return false;
}
memset(m_rawTarget, 0, sizeof(m_rawTarget));
memcpy(m_rawTarget, target, size);
# endif
return true;
}
size_t xmrig::Job::nonceOffset() const
{
switch (algorithm().family()) {
case Algorithm::KAWPOW:
return 32;
case Algorithm::GHOSTRIDER:
return 76;
default:
break;
}
if (algorithm() == Algorithm::RX_YADA) {
return 147;
}
return 39;
}
void xmrig::Job::setDiff(uint64_t diff)
{
m_diff = diff;
@@ -171,14 +203,6 @@ void xmrig::Job::setSigKey(const char *sig_key)
}
int32_t xmrig::Job::nonceOffset() const
{
auto f = algorithm().family();
if (f == Algorithm::KAWPOW) return 32;
if (f == Algorithm::GHOSTRIDER) return 76;
return 39;
}
uint32_t xmrig::Job::getNumTransactions() const
{
if (!(m_algorithm.isCN() || m_algorithm.family() == Algorithm::RANDOM_X)) {

View File

@@ -7,8 +7,8 @@
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
* Copyright 2019 Howard Chu <https://github.com/hyc>
* Copyright 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2024 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2024 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
@@ -27,11 +27,9 @@
#ifndef XMRIG_JOB_H
#define XMRIG_JOB_H
#include <cstddef>
#include <cstdint>
#include "base/crypto/Algorithm.h"
#include "base/tools/Buffer.h"
#include "base/tools/String.h"
@@ -63,6 +61,7 @@ public:
bool setBlob(const char *blob);
bool setSeedHash(const char *hash);
bool setTarget(const char *target);
size_t nonceOffset() const;
void setDiff(uint64_t diff);
void setSigKey(const char *sig_key);
@@ -77,7 +76,6 @@ public:
inline const String &poolWallet() const { return m_poolWallet; }
inline const uint32_t *nonce() const { return reinterpret_cast<const uint32_t*>(m_blob + nonceOffset()); }
inline const uint8_t *blob() const { return m_blob; }
int32_t nonceOffset() const;
inline size_t nonceSize() const { return (algorithm().family() == Algorithm::KAWPOW) ? 8 : 4; }
inline size_t size() const { return m_size; }
inline uint32_t *nonce() { return reinterpret_cast<uint32_t*>(m_blob + nonceOffset()); }
@@ -111,7 +109,7 @@ public:
inline bool operator!=(const Job &other) const { return !isEqual(other); }
inline bool operator==(const Job &other) const { return isEqual(other); }
inline Job &operator=(const Job &other) { copy(other); return *this; }
inline Job &operator=(const Job &other) { if (this != &other) { copy(other); } return *this; }
inline Job &operator=(Job &&other) noexcept { move(std::move(other)); return *this; }
# ifdef XMRIG_FEATURE_BENCHMARK

View File

@@ -221,42 +221,42 @@ bool xmrig::Pool::isEqual(const Pool &other) const
}
xmrig::IClient *xmrig::Pool::createClient(int id, IClientListener *listener) const
std::shared_ptr<xmrig::IClient> xmrig::Pool::createClient(int id, IClientListener* listener) const
{
IClient *client = nullptr;
std::shared_ptr<xmrig::IClient> client;
if (m_mode == MODE_POOL) {
# if defined XMRIG_ALGO_KAWPOW || defined XMRIG_ALGO_GHOSTRIDER
const uint32_t f = m_algorithm.family();
if ((f == Algorithm::KAWPOW) || (f == Algorithm::GHOSTRIDER) || (m_coin == Coin::RAVEN)) {
client = new EthStratumClient(id, Platform::userAgent(), listener);
client = std::make_shared<EthStratumClient>(id, Platform::userAgent(), listener);
}
else
# endif
{
client = new Client(id, Platform::userAgent(), listener);
client = std::make_shared<Client>(id, Platform::userAgent(), listener);
}
}
# ifdef XMRIG_FEATURE_HTTP
else if (m_mode == MODE_DAEMON) {
client = new DaemonClient(id, listener);
client = std::make_shared<DaemonClient>(id, listener);
}
else if (m_mode == MODE_SELF_SELECT) {
client = new SelfSelectClient(id, Platform::userAgent(), listener, m_submitToOrigin);
client = std::make_shared<SelfSelectClient>(id, Platform::userAgent(), listener, m_submitToOrigin);
}
# endif
# if defined XMRIG_ALGO_KAWPOW || defined XMRIG_ALGO_GHOSTRIDER
else if (m_mode == MODE_AUTO_ETH) {
client = new AutoClient(id, Platform::userAgent(), listener);
client = std::make_shared<AutoClient>(id, Platform::userAgent(), listener);
}
# endif
# ifdef XMRIG_FEATURE_BENCHMARK
else if (m_mode == MODE_BENCHMARK) {
client = new BenchClient(m_benchmark, listener);
client = std::make_shared<BenchClient>(m_benchmark, listener);
}
# endif
assert(client != nullptr);
assert(client);
if (client) {
client->setPool(*this);

View File

@@ -127,7 +127,7 @@ public:
bool isEnabled() const;
bool isEqual(const Pool &other) const;
IClient *createClient(int id, IClientListener *listener) const;
std::shared_ptr<IClient> createClient(int id, IClientListener *listener) const;
rapidjson::Value toJSON(rapidjson::Document &doc) const;
std::string printableName() const;

View File

@@ -80,17 +80,17 @@ int xmrig::Pools::donateLevel() const
}
xmrig::IStrategy *xmrig::Pools::createStrategy(IStrategyListener *listener) const
std::shared_ptr<xmrig::IStrategy> xmrig::Pools::createStrategy(IStrategyListener *listener) const
{
if (active() == 1) {
for (const Pool &pool : m_data) {
if (pool.isEnabled()) {
return new SinglePoolStrategy(pool, retryPause(), retries(), listener);
return std::make_shared<SinglePoolStrategy>(pool, retryPause(), retries(), listener);
}
}
}
auto strategy = new FailoverStrategy(retryPause(), retries(), listener);
auto strategy = std::make_shared<FailoverStrategy>(retryPause(), retries(), listener);
for (const Pool &pool : m_data) {
if (pool.isEnabled()) {
strategy->add(pool);
@@ -154,7 +154,7 @@ void xmrig::Pools::load(const IJsonReader &reader)
Pool pool(value);
if (pool.isValid()) {
m_data.push_back(std::move(pool));
m_data.emplace_back(std::move(pool));
}
}

View File

@@ -73,7 +73,7 @@ public:
bool isEqual(const Pools &other) const;
int donateLevel() const;
IStrategy *createStrategy(IStrategyListener *listener) const;
std::shared_ptr<IStrategy> createStrategy(IStrategyListener *listener) const;
rapidjson::Value toJSON(rapidjson::Document &doc) const;
size_t active() const;
uint32_t benchSize() const;

View File

@@ -56,13 +56,12 @@ xmrig::SelfSelectClient::SelfSelectClient(int id, const char *agent, IClientList
m_listener(listener)
{
m_httpListener = std::make_shared<HttpListener>(this);
m_client = new Client(id, agent, this);
m_client = std::make_shared<Client>(id, agent, this);
}
xmrig::SelfSelectClient::~SelfSelectClient()
{
delete m_client;
}

View File

@@ -105,7 +105,7 @@ private:
bool m_active = false;
bool m_quiet = false;
const bool m_submitToOrigin;
IClient *m_client;
std::shared_ptr<IClient> m_client;
IClientListener *m_listener;
int m_retries = 5;
int64_t m_failures = 0;

View File

@@ -53,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 { delete this; }
inline void deleteLater() override {}
inline void setAlgo(const Algorithm &algo) override {}
inline void setEnabled(bool enabled) override {}
inline void setProxy(const ProxyUrl &proxy) override {}

View File

@@ -47,7 +47,7 @@ xmrig::FailoverStrategy::FailoverStrategy(int retryPause, int retries, IStrategy
xmrig::FailoverStrategy::~FailoverStrategy()
{
for (IClient *client : m_pools) {
for (auto& client : m_pools) {
client->deleteLater();
}
}
@@ -55,7 +55,7 @@ xmrig::FailoverStrategy::~FailoverStrategy()
void xmrig::FailoverStrategy::add(const Pool &pool)
{
IClient *client = pool.createClient(static_cast<int>(m_pools.size()), this);
std::shared_ptr<IClient> client = pool.createClient(static_cast<int>(m_pools.size()), this);
client->setRetries(m_retries);
client->setRetryPause(m_retryPause * 1000);
@@ -93,7 +93,7 @@ void xmrig::FailoverStrategy::resume()
void xmrig::FailoverStrategy::setAlgo(const Algorithm &algo)
{
for (IClient *client : m_pools) {
for (auto& client : m_pools) {
client->setAlgo(algo);
}
}
@@ -101,7 +101,7 @@ void xmrig::FailoverStrategy::setAlgo(const Algorithm &algo)
void xmrig::FailoverStrategy::setProxy(const ProxyUrl &proxy)
{
for (IClient *client : m_pools) {
for (auto& client : m_pools) {
client->setProxy(proxy);
}
}
@@ -109,7 +109,7 @@ void xmrig::FailoverStrategy::setProxy(const ProxyUrl &proxy)
void xmrig::FailoverStrategy::stop()
{
for (auto &pool : m_pools) {
for (auto& pool : m_pools) {
pool->disconnect();
}
@@ -122,7 +122,7 @@ void xmrig::FailoverStrategy::stop()
void xmrig::FailoverStrategy::tick(uint64_t now)
{
for (IClient *client : m_pools) {
for (auto& client : m_pools) {
client->tick(now);
}
}

View File

@@ -49,7 +49,7 @@ public:
protected:
inline bool isActive() const override { return m_active >= 0; }
inline IClient *client() const override { return isActive() ? active() : m_pools[m_index]; }
inline IClient* client() const override { return isActive() ? active() : m_pools[m_index].get(); }
int64_t submit(const JobResult &result) override;
void connect() override;
@@ -67,7 +67,7 @@ protected:
void onVerifyAlgorithm(const IClient *client, const Algorithm &algorithm, bool *ok) override;
private:
inline IClient *active() const { return m_pools[static_cast<size_t>(m_active)]; }
inline IClient* active() const { return m_pools[static_cast<size_t>(m_active)].get(); }
const bool m_quiet;
const int m_retries;
@@ -75,7 +75,7 @@ private:
int m_active = -1;
IStrategyListener *m_listener;
size_t m_index = 0;
std::vector<IClient*> m_pools;
std::vector<std::shared_ptr<IClient>> m_pools;
};

View File

@@ -66,7 +66,7 @@ void xmrig::SinglePoolStrategy::resume()
return;
}
m_listener->onJob(this, m_client, m_client->job(), rapidjson::Value(rapidjson::kNullType));
m_listener->onJob(this, m_client.get(), m_client->job(), rapidjson::Value(rapidjson::kNullType));
}

View File

@@ -49,7 +49,7 @@ public:
protected:
inline bool isActive() const override { return m_active; }
inline IClient *client() const override { return m_client; }
inline IClient* client() const override { return m_client.get(); }
int64_t submit(const JobResult &result) override;
void connect() override;
@@ -68,7 +68,7 @@ protected:
private:
bool m_active;
IClient *m_client;
std::shared_ptr<IClient> m_client;
IStrategyListener *m_listener;
};

View File

@@ -23,22 +23,23 @@
#include <cassert>
#include <memory>
#include <uv.h>
namespace xmrig {
static MemPool<XMRIG_NET_BUFFER_CHUNK_SIZE, XMRIG_NET_BUFFER_INIT_CHUNKS> *pool = nullptr;
static std::shared_ptr<MemPool<XMRIG_NET_BUFFER_CHUNK_SIZE, XMRIG_NET_BUFFER_INIT_CHUNKS>> pool;
inline MemPool<XMRIG_NET_BUFFER_CHUNK_SIZE, XMRIG_NET_BUFFER_INIT_CHUNKS> *getPool()
{
if (!pool) {
pool = new MemPool<XMRIG_NET_BUFFER_CHUNK_SIZE, XMRIG_NET_BUFFER_INIT_CHUNKS>();
pool = std::make_shared<MemPool<XMRIG_NET_BUFFER_CHUNK_SIZE, XMRIG_NET_BUFFER_INIT_CHUNKS>>();
}
return pool;
return pool.get();
}
@@ -59,8 +60,7 @@ void xmrig::NetBuffer::destroy()
assert(pool->freeSize() == pool->size());
delete pool;
pool = nullptr;
pool.reset();
}

View File

@@ -84,10 +84,10 @@ public:
inline ~MinerPrivate()
{
delete timer;
timer.reset();
for (IBackend *backend : backends) {
delete backend;
for (auto& backend : backends) {
backend.reset();
}
# ifdef XMRIG_ALGO_RANDOMX
@@ -98,7 +98,7 @@ public:
bool isEnabled(const Algorithm &algorithm) const
{
for (IBackend *backend : backends) {
for (auto& backend : backends) {
if (backend->isEnabled() && backend->isEnabled(algorithm)) {
return true;
}
@@ -124,7 +124,7 @@ public:
Nonce::reset(job.index());
}
for (IBackend *backend : backends) {
for (auto& backend : backends) {
backend->setJob(job);
}
@@ -175,7 +175,7 @@ public:
double t[3] = { 0.0 };
for (IBackend *backend : backends) {
for (auto& backend : backends) {
const Hashrate *hr = backend->hashrate();
if (!hr) {
continue;
@@ -221,7 +221,7 @@ public:
reply.SetArray();
for (IBackend *backend : backends) {
for (auto& backend : backends) {
reply.PushBack(backend->toJSON(doc), allocator);
}
}
@@ -364,9 +364,9 @@ public:
Controller *controller;
Job job;
mutable std::map<Algorithm::Id, double> maxHashrate;
std::vector<IBackend *> backends;
std::vector<std::shared_ptr<IBackend>> backends;
String userJobId;
Timer *timer = nullptr;
std::shared_ptr<Timer> timer;
uint64_t ticks = 0;
Taskbar m_taskbar;
@@ -378,7 +378,7 @@ public:
xmrig::Miner::Miner(Controller *controller)
: d_ptr(new MinerPrivate(controller))
: d_ptr(std::make_shared<MinerPrivate>(controller))
{
const int priority = controller->config()->cpu().priority();
if (priority >= 0) {
@@ -400,29 +400,23 @@ xmrig::Miner::Miner(Controller *controller)
controller->api()->addListener(this);
# endif
d_ptr->timer = new Timer(this);
d_ptr->timer = std::make_shared<Timer>(this);
d_ptr->backends.reserve(3);
d_ptr->backends.push_back(new CpuBackend(controller));
d_ptr->backends.emplace_back(std::make_shared<CpuBackend>(controller));
# ifdef XMRIG_FEATURE_OPENCL
d_ptr->backends.push_back(new OclBackend(controller));
d_ptr->backends.emplace_back(std::make_shared<OclBackend>(controller));
# endif
# ifdef XMRIG_FEATURE_CUDA
d_ptr->backends.push_back(new CudaBackend(controller));
d_ptr->backends.emplace_back(std::make_shared<CudaBackend>(controller));
# endif
d_ptr->rebuild();
}
xmrig::Miner::~Miner()
{
delete d_ptr;
}
bool xmrig::Miner::isEnabled() const
{
return d_ptr->enabled;
@@ -441,7 +435,7 @@ const xmrig::Algorithms &xmrig::Miner::algorithms() const
}
const std::vector<xmrig::IBackend *> &xmrig::Miner::backends() const
const std::vector<std::shared_ptr<xmrig::IBackend>>& xmrig::Miner::backends() const
{
return d_ptr->backends;
}
@@ -538,7 +532,7 @@ void xmrig::Miner::setEnabled(bool enabled)
void xmrig::Miner::setJob(const Job &job, bool donate)
{
for (IBackend *backend : d_ptr->backends) {
for (auto& backend : d_ptr->backends) {
backend->prepare(job);
}
@@ -576,6 +570,11 @@ void xmrig::Miner::setJob(const Job &job, bool donate)
# ifdef XMRIG_ALGO_RANDOMX
const bool ready = d_ptr->initRX();
// Always reset nonce on RandomX dataset change
if (!ready) {
d_ptr->reset = true;
}
# else
constexpr const bool ready = true;
# endif
@@ -601,7 +600,7 @@ void xmrig::Miner::stop()
{
Nonce::stop();
for (IBackend *backend : d_ptr->backends) {
for (auto& backend : d_ptr->backends) {
backend->stop();
}
}
@@ -617,7 +616,7 @@ void xmrig::Miner::onConfigChanged(Config *config, Config *previousConfig)
const Job job = this->job();
for (IBackend *backend : d_ptr->backends) {
for (auto& backend : d_ptr->backends) {
backend->setJob(job);
}
}
@@ -631,7 +630,7 @@ void xmrig::Miner::onTimer(const Timer *)
bool stopMiner = false;
for (IBackend *backend : d_ptr->backends) {
for (auto& backend : d_ptr->backends) {
if (!backend->tick(d_ptr->ticks)) {
stopMiner = true;
}
@@ -713,7 +712,7 @@ void xmrig::Miner::onRequest(IApiRequest &request)
}
}
for (IBackend *backend : d_ptr->backends) {
for (auto& backend : d_ptr->backends) {
backend->handleRequest(request);
}
}

View File

@@ -46,12 +46,12 @@ public:
XMRIG_DISABLE_COPY_MOVE_DEFAULT(Miner)
Miner(Controller *controller);
~Miner() override;
~Miner() override = default;
bool isEnabled() const;
bool isEnabled(const Algorithm &algorithm) const;
const Algorithms &algorithms() const;
const std::vector<IBackend *> &backends() const;
const std::vector<std::shared_ptr<IBackend>> &backends() const;
Job job() const;
void execCommand(char command);
void pause();
@@ -72,7 +72,7 @@ protected:
# endif
private:
MinerPrivate *d_ptr;
std::shared_ptr<MinerPrivate> d_ptr;
};

View File

@@ -65,14 +65,13 @@ struct TaskbarPrivate
};
Taskbar::Taskbar() : d_ptr(new TaskbarPrivate())
Taskbar::Taskbar() : d_ptr(std::make_shared<TaskbarPrivate>())
{
}
Taskbar::~Taskbar()
{
delete d_ptr;
}

View File

@@ -19,6 +19,7 @@
#ifndef XMRIG_TASKBAR_H
#define XMRIG_TASKBAR_H
#include <memory>
namespace xmrig {
@@ -39,7 +40,7 @@ private:
bool m_active = false;
bool m_enabled = true;
TaskbarPrivate* d_ptr = nullptr;
std::shared_ptr<TaskbarPrivate> d_ptr;
void updateTaskbarColor();
};

View File

@@ -115,14 +115,13 @@ public:
xmrig::Config::Config() :
d_ptr(new ConfigPrivate())
d_ptr(std::make_shared<ConfigPrivate>())
{
}
xmrig::Config::~Config()
{
delete d_ptr;
}

View File

@@ -101,7 +101,7 @@ public:
void getJSON(rapidjson::Document &doc) const override;
private:
ConfigPrivate *d_ptr;
std::shared_ptr<ConfigPrivate> d_ptr;
};

View File

@@ -49,18 +49,12 @@ xmrig::MemoryPool::MemoryPool(size_t size, bool hugePages, uint32_t node)
constexpr size_t alignment = 1 << 24;
m_memory = new VirtualMemory(size * pageSize + alignment, hugePages, false, false, node);
m_memory = std::make_shared<VirtualMemory>(size * pageSize + alignment, hugePages, false, false, node);
m_alignOffset = (alignment - (((size_t)m_memory->scratchpad()) % alignment)) % alignment;
}
xmrig::MemoryPool::~MemoryPool()
{
delete m_memory;
}
bool xmrig::MemoryPool::isHugePages(uint32_t) const
{
return m_memory && m_memory->isHugePages();

View File

@@ -44,7 +44,7 @@ public:
XMRIG_DISABLE_COPY_MOVE_DEFAULT(MemoryPool)
MemoryPool(size_t size, bool hugePages, uint32_t node = 0);
~MemoryPool() override;
~MemoryPool() override = default;
protected:
bool isHugePages(uint32_t node) const override;
@@ -55,7 +55,7 @@ private:
size_t m_refs = 0;
size_t m_offset = 0;
size_t m_alignOffset = 0;
VirtualMemory *m_memory = nullptr;
std::shared_ptr<VirtualMemory> m_memory;
};

View File

@@ -42,14 +42,6 @@ xmrig::NUMAMemoryPool::NUMAMemoryPool(size_t size, bool hugePages) :
}
xmrig::NUMAMemoryPool::~NUMAMemoryPool()
{
for (auto kv : m_map) {
delete kv.second;
}
}
bool xmrig::NUMAMemoryPool::isHugePages(uint32_t node) const
{
if (!m_size) {
@@ -81,7 +73,7 @@ void xmrig::NUMAMemoryPool::release(uint32_t node)
xmrig::IMemoryPool *xmrig::NUMAMemoryPool::get(uint32_t node) const
{
return m_map.count(node) ? m_map.at(node) : nullptr;
return m_map.count(node) ? m_map.at(node).get() : nullptr;
}
@@ -89,8 +81,9 @@ xmrig::IMemoryPool *xmrig::NUMAMemoryPool::getOrCreate(uint32_t node) const
{
auto pool = get(node);
if (!pool) {
pool = new MemoryPool(m_nodeSize, m_hugePages, node);
m_map.insert({ node, pool });
auto new_pool = std::make_shared<MemoryPool>(m_nodeSize, m_hugePages, node);
m_map.emplace(node, new_pool);
pool = new_pool.get();
}
return pool;

View File

@@ -47,7 +47,7 @@ public:
XMRIG_DISABLE_COPY_MOVE_DEFAULT(NUMAMemoryPool)
NUMAMemoryPool(size_t size, bool hugePages);
~NUMAMemoryPool() override;
~NUMAMemoryPool() override = default;
protected:
bool isHugePages(uint32_t node) const override;
@@ -61,7 +61,7 @@ private:
bool m_hugePages = true;
size_t m_nodeSize = 0;
size_t m_size = 0;
mutable std::map<uint32_t, IMemoryPool *> m_map;
mutable std::map<uint32_t, std::shared_ptr<IMemoryPool>> m_map;
};

View File

@@ -38,7 +38,7 @@ namespace xmrig {
size_t VirtualMemory::m_hugePageSize = VirtualMemory::kDefaultHugePageSize;
static IMemoryPool *pool = nullptr;
static std::shared_ptr<IMemoryPool> pool;
static std::mutex mutex;
@@ -113,7 +113,7 @@ uint32_t xmrig::VirtualMemory::bindToNUMANode(int64_t)
void xmrig::VirtualMemory::destroy()
{
delete pool;
pool.reset();
}
@@ -125,10 +125,10 @@ void xmrig::VirtualMemory::init(size_t poolSize, size_t hugePageSize)
# ifdef XMRIG_FEATURE_HWLOC
if (Cpu::info()->nodes() > 1) {
pool = new NUMAMemoryPool(align(poolSize, Cpu::info()->nodes()), hugePageSize > 0);
pool = std::make_shared<NUMAMemoryPool>(align(poolSize, Cpu::info()->nodes()), hugePageSize > 0);
} else
# endif
{
pool = new MemoryPool(poolSize, hugePageSize > 0);
pool = std::make_shared<MemoryPool>(poolSize, hugePageSize > 0);
}
}

View File

@@ -16,7 +16,7 @@ xmrig -a gr -o rtm.suprnova.cc:4273 --tls -u WALLET_ADDRESS -p x
You can use **rtm_ghostrider_example.cmd** as a template and put pool URL and your wallet address there. The general XMRig documentation is available [here](https://xmrig.com/docs/miner).
**Using `--threads` or `-t` option is NOT recommended because it turns off advanced built-in config.** If you want to tweak the nubmer of threads used for GhostRider, it's recommended to start using config.json instead of command line. The best suitable command line option for this is `--cpu-max-threads-hint=N` where N can be between 0 and 100.
**Using `--threads` or `-t` option is NOT recommended because it turns off advanced built-in config.** If you want to tweak the number of threads used for GhostRider, it's recommended to start using config.json instead of command line. The best suitable command line option for this is `--cpu-max-threads-hint=N` where N can be between 0 and 100.
## Performance

View File

@@ -312,7 +312,7 @@ void benchmark()
constexpr uint32_t N = 1U << 21;
VirtualMemory::init(0, N);
VirtualMemory* memory = new VirtualMemory(N * 8, true, false, false);
std::shared_ptr<VirtualMemory> memory = std::make_shared<VirtualMemory>(N * 8, true, false, false);
// 2 MB cache per core by default
size_t max_scratchpad_size = 1U << 21;
@@ -438,7 +438,6 @@ void benchmark()
delete helper;
CnCtx::release(ctx, 8);
delete memory;
});
t.join();

View File

@@ -38,17 +38,6 @@ std::mutex KPCache::s_cacheMutex;
KPCache KPCache::s_cache;
KPCache::KPCache()
{
}
KPCache::~KPCache()
{
delete m_memory;
}
bool KPCache::init(uint32_t epoch)
{
if (epoch >= sizeof(cache_sizes) / sizeof(cache_sizes[0])) {
@@ -63,8 +52,7 @@ bool KPCache::init(uint32_t epoch)
const size_t size = cache_sizes[epoch];
if (!m_memory || m_memory->size() < size) {
delete m_memory;
m_memory = new VirtualMemory(size, false, false, false);
m_memory = std::make_shared<VirtualMemory>(size, false, false, false);
}
const ethash_h256_t seedhash = ethash_get_seedhash(epoch);

View File

@@ -41,8 +41,8 @@ public:
XMRIG_DISABLE_COPY_MOVE(KPCache)
KPCache();
~KPCache();
KPCache() = default;
~KPCache() = default;
bool init(uint32_t epoch);
@@ -61,7 +61,7 @@ public:
static KPCache s_cache;
private:
VirtualMemory* m_memory = nullptr;
std::shared_ptr<VirtualMemory> m_memory;
size_t m_size = 0;
uint32_t m_epoch = 0xFFFFFFFFUL;
std::vector<uint32_t> m_DAGCache;

View File

@@ -94,7 +94,7 @@ static size_t CalcDatasetItemSize()
// Main loop prologue
((uint8_t*)randomx_calc_dataset_item_aarch64_mix - ((uint8_t*)randomx_calc_dataset_item_aarch64_prefetch)) + 4 +
// Inner main loop (instructions)
((RandomX_ConfigurationBase::SuperscalarLatency * 3) + 2) * 16 +
((RandomX_ConfigurationBase::SuperscalarMaxLatency * 3) + 2) * 16 +
// Main loop epilogue
((uint8_t*)randomx_calc_dataset_item_aarch64_store_result - (uint8_t*)randomx_calc_dataset_item_aarch64_mix) + 4
) +
@@ -1078,6 +1078,6 @@ void JitCompilerA64::h_NOP(Instruction& instr, uint32_t& codePos)
{
}
InstructionGeneratorA64 JitCompilerA64::engine[257] = {};
InstructionGeneratorA64 JitCompilerA64::engine[256] = {};
}

View File

@@ -74,7 +74,7 @@ namespace randomx {
void enableWriting() const;
void enableExecution() const;
static InstructionGeneratorA64 engine[257];
static InstructionGeneratorA64 engine[256];
private:
const bool hugePages;

View File

@@ -266,6 +266,10 @@ namespace randomx {
// AVX2 init is slower on Zen4
initDatasetAVX2 = false;
break;
case xmrig::ICpuInfo::ARCH_ZEN5:
// AVX2 init is 49% faster on Zen5
initDatasetAVX2 = true;
break;
}
}
}
@@ -1443,6 +1447,6 @@ namespace randomx {
emitByte(0x90, code, codePos);
}
alignas(64) InstructionGeneratorX86 JitCompilerX86::engine[257] = {};
alignas(64) InstructionGeneratorX86 JitCompilerX86::engine[256] = {};
}

View File

@@ -81,7 +81,7 @@ namespace randomx {
void enableWriting() const;
void enableExecution() const;
alignas(64) static InstructionGeneratorX86 engine[257];
alignas(64) static InstructionGeneratorX86 engine[256];
private:
int registerUsage[RegistersCount] = {};

View File

@@ -100,17 +100,18 @@ RandomX_ConfigurationSafex::RandomX_ConfigurationSafex()
ArgonSalt = "RandomSFX\x01";
}
RandomX_ConfigurationKeva::RandomX_ConfigurationKeva()
RandomX_ConfigurationYada::RandomX_ConfigurationYada()
{
ArgonSalt = "RandomKV\x01";
ScratchpadL2_Size = 131072;
ScratchpadL3_Size = 1048576;
ArgonSalt = "RandomXYadaCoin\x03";
SuperscalarLatency = 150;
ArgonIterations = 4;
}
RandomX_ConfigurationBase::RandomX_ConfigurationBase()
: ArgonIterations(3)
, ArgonLanes(1)
, ArgonSalt("RandomX\x03")
, SuperscalarLatency(170)
, ScratchpadL1_Size(16384)
, ScratchpadL2_Size(262144)
, ScratchpadL3_Size(2097152)
@@ -260,7 +261,7 @@ typedef void(randomx::JitCompilerX86::* InstructionGeneratorX86_2)(const randomx
#define JIT_HANDLE(x, prev) do { \
const InstructionGeneratorX86_2 p = &randomx::JitCompilerX86::h_##x; \
memcpy(randomx::JitCompilerX86::engine + k, &p, sizeof(p)); \
memcpy(randomx::JitCompilerX86::engine + k, &p, sizeof(randomx::JitCompilerX86::engine[k])); \
} while (0)
#elif (XMRIG_ARM == 8)
@@ -357,7 +358,7 @@ RandomX_ConfigurationWownero RandomX_WowneroConfig;
RandomX_ConfigurationArqma RandomX_ArqmaConfig;
RandomX_ConfigurationGraft RandomX_GraftConfig;
RandomX_ConfigurationSafex RandomX_SafexConfig;
RandomX_ConfigurationKeva RandomX_KevaConfig;
RandomX_ConfigurationYada RandomX_YadaConfig;
alignas(64) RandomX_ConfigurationBase RandomX_CurrentConfig;

View File

@@ -69,7 +69,7 @@ struct RandomX_ConfigurationBase
{
ArgonMemory = 262144,
CacheAccesses = 8,
SuperscalarLatency = 170,
SuperscalarMaxLatency = 170,
DatasetBaseSize = 2147483648,
DatasetExtraSize = 33554368,
JumpBits = 8,
@@ -82,6 +82,7 @@ struct RandomX_ConfigurationBase
uint32_t ArgonIterations;
uint32_t ArgonLanes;
const char* ArgonSalt;
uint32_t SuperscalarLatency;
uint32_t ScratchpadL1_Size;
uint32_t ScratchpadL2_Size;
@@ -146,14 +147,14 @@ struct RandomX_ConfigurationWownero : public RandomX_ConfigurationBase { RandomX
struct RandomX_ConfigurationArqma : public RandomX_ConfigurationBase { RandomX_ConfigurationArqma(); };
struct RandomX_ConfigurationGraft : public RandomX_ConfigurationBase { RandomX_ConfigurationGraft(); };
struct RandomX_ConfigurationSafex : public RandomX_ConfigurationBase { RandomX_ConfigurationSafex(); };
struct RandomX_ConfigurationKeva : public RandomX_ConfigurationBase { RandomX_ConfigurationKeva(); };
struct RandomX_ConfigurationYada : public RandomX_ConfigurationBase { RandomX_ConfigurationYada(); };
extern RandomX_ConfigurationMonero RandomX_MoneroConfig;
extern RandomX_ConfigurationWownero RandomX_WowneroConfig;
extern RandomX_ConfigurationArqma RandomX_ArqmaConfig;
extern RandomX_ConfigurationGraft RandomX_GraftConfig;
extern RandomX_ConfigurationSafex RandomX_SafexConfig;
extern RandomX_ConfigurationKeva RandomX_KevaConfig;
extern RandomX_ConfigurationYada RandomX_YadaConfig;
extern RandomX_ConfigurationBase RandomX_CurrentConfig;

Some files were not shown because too many files have changed in this diff Show More