1
0
mirror of https://github.com/xmrig/xmrig.git synced 2025-12-06 23:52:38 -05:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Artem Zuikov
9e804278f1 Merge ead82cdba9 into 16ecb8f085 2024-12-28 12:36:19 -06:00
XMRig
16ecb8f085 Allow use of the previous CUDA plugin version with a warning. 2024-12-23 23:14:06 +07:00
4ertus2
ead82cdba9 prevent manual mutex lock/unlock 2024-10-20 23:21:00 +03:00
9 changed files with 58 additions and 44 deletions

View File

@@ -180,11 +180,11 @@ public:
}
# endif
mutex.lock();
{
std::lock_guard<std::mutex> lock(mutex);
pages += status.hugePages();
mutex.unlock();
pages += status.hugePages();
}
rapidjson::Value hugepages;
@@ -380,14 +380,14 @@ void xmrig::CpuBackend::setJob(const Job &job)
void xmrig::CpuBackend::start(IWorker *worker, bool ready)
{
mutex.lock();
{
std::lock_guard<std::mutex> lock(mutex);
if (d_ptr->status.started(worker, ready)) {
d_ptr->status.print();
if (d_ptr->status.started(worker, ready)) {
d_ptr->status.print();
}
}
mutex.unlock();
if (ready) {
worker->start();
}

View File

@@ -465,16 +465,17 @@ void xmrig::CudaBackend::setJob(const Job &job)
void xmrig::CudaBackend::start(IWorker *worker, bool ready)
{
mutex.lock();
{
std::lock_guard<std::mutex> lock(mutex);
if (d_ptr->status.started(ready)) {
d_ptr->status.print();
if (d_ptr->status.started(ready)) {
d_ptr->status.print();
CudaWorker::ready = true;
}
CudaWorker::ready = true;
}
mutex.unlock();
if (ready) {
worker->start();
}

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-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 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 "backend/cuda/runners/CudaRxRunner.h"
#include "backend/cuda/CudaLaunchData.h"
#include "backend/cuda/wrappers/CudaLib.h"
@@ -59,7 +58,7 @@ bool xmrig::CudaRxRunner::set(const Job &job, uint8_t *blob)
m_seed = job.seed();
if (m_ready) {
auto dataset = Rx::dataset(job, 0);
const auto *dataset = Rx::dataset(job, 0);
callWrapper(CudaLib::rxUpdateDataset(m_ctx, dataset->raw(), dataset->size(false)));
}
}
@@ -69,7 +68,7 @@ bool xmrig::CudaRxRunner::set(const Job &job, uint8_t *blob)
return rc;
}
auto dataset = Rx::dataset(job, 0);
const auto *dataset = Rx::dataset(job, 0);
m_ready = callWrapper(CudaLib::rxPrepare(m_ctx, dataset->raw(), dataset->size(false), m_datasetHost, m_intensity));
return m_ready;

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-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 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

View File

@@ -19,10 +19,10 @@
#include <stdexcept>
#include <uv.h>
#include "backend/cuda/wrappers/CudaLib.h"
#include "base/io/Env.h"
#include "base/io/log/Log.h"
#include "base/io/log/Tags.h"
#include "base/kernel/Process.h"
#include "crypto/rx/RxAlgo.h"
@@ -205,13 +205,23 @@ bool xmrig::CudaLib::rxHash(nvid_ctx *ctx, uint32_t startNonce, uint64_t target,
bool xmrig::CudaLib::rxPrepare(nvid_ctx *ctx, const void *dataset, size_t datasetSize, bool dataset_host, uint32_t batchSize) noexcept
{
# ifdef XMRIG_ALGO_RANDOMX
if (!pRxUpdateDataset) {
LOG_WARN("%s" YELLOW_BOLD("CUDA plugin is outdated. Please update to the latest version"), Tags::randomx());
}
# endif
return pRxPrepare(ctx, dataset, datasetSize, dataset_host, batchSize);
}
bool xmrig::CudaLib::rxUpdateDataset(nvid_ctx* ctx, const void* dataset, size_t datasetSize) noexcept
bool xmrig::CudaLib::rxUpdateDataset(nvid_ctx *ctx, const void *dataset, size_t datasetSize) noexcept
{
return pRxUpdateDataset(ctx, dataset, datasetSize);
if (pRxUpdateDataset) {
return pRxUpdateDataset(ctx, dataset, datasetSize);
}
return true;
}
@@ -397,7 +407,6 @@ void xmrig::CudaLib::load()
DLSYM(Release);
DLSYM(RxHash);
DLSYM(RxPrepare);
DLSYM(RxUpdateDataset);
DLSYM(KawPowHash);
DLSYM(KawPowPrepare_v2);
DLSYM(KawPowStopHash);
@@ -411,5 +420,7 @@ void xmrig::CudaLib::load()
DLSYM(SetJob_v2);
}
uv_dlsym(&cudaLib, kRxUpdateDataset, reinterpret_cast<void**>(&pRxUpdateDataset));
pInit();
}

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
@@ -71,7 +71,7 @@ public:
static bool deviceInit(nvid_ctx *ctx) noexcept;
static bool rxHash(nvid_ctx *ctx, uint32_t startNonce, uint64_t target, uint32_t *rescount, uint32_t *resnonce) noexcept;
static bool rxPrepare(nvid_ctx *ctx, const void *dataset, size_t datasetSize, bool dataset_host, uint32_t batchSize) noexcept;
static bool rxUpdateDataset(nvid_ctx* ctx, const void* dataset, size_t datasetSize) noexcept;
static bool rxUpdateDataset(nvid_ctx *ctx, const void *dataset, size_t datasetSize) noexcept;
static bool kawPowHash(nvid_ctx *ctx, uint8_t* job_blob, uint64_t target, uint32_t *rescount, uint32_t *resnonce, uint32_t *skipped_hashes) noexcept;
static bool kawPowPrepare(nvid_ctx *ctx, const void* cache, size_t cache_size, const void* dag_precalc, size_t dag_size, uint32_t height, const uint64_t* dag_sizes) noexcept;
static bool kawPowStopHash(nvid_ctx *ctx) noexcept;

View File

@@ -447,16 +447,16 @@ void xmrig::OclBackend::setJob(const Job &job)
void xmrig::OclBackend::start(IWorker *worker, bool ready)
{
mutex.lock();
{
std::lock_guard<std::mutex> lock(mutex);
if (d_ptr->status.started(ready)) {
d_ptr->status.print();
if (d_ptr->status.started(ready)) {
d_ptr->status.print();
OclWorker::ready = true;
OclWorker::ready = true;
}
}
mutex.unlock();
if (ready) {
worker->start();
}

View File

@@ -569,7 +569,14 @@ void xmrig::Miner::setJob(const Job &job, bool donate)
d_ptr->algorithm = job.algorithm();
mutex.lock();
# ifdef XMRIG_ALGO_RANDOMX
bool ready = false;
# else
constexpr const bool ready = true;
# endif
{
std::lock_guard<std::mutex> lock(mutex);
const uint8_t index = donate ? 1 : 0;
@@ -588,14 +595,12 @@ void xmrig::Miner::setJob(const Job &job, bool donate)
}
# ifdef XMRIG_ALGO_RANDOMX
const bool ready = d_ptr->initRX();
ready = d_ptr->initRX();
// Always reset nonce on RandomX dataset change
if (!ready) {
d_ptr->reset = true;
}
# else
constexpr const bool ready = true;
# endif
# ifdef XMRIG_ALGO_GHOSTRIDER
@@ -604,7 +609,7 @@ void xmrig::Miner::setJob(const Job &job, bool donate)
}
# endif
mutex.unlock();
}
d_ptr->active = true;
d_ptr->m_taskbar.setActive(true);

View File

@@ -1,7 +1,7 @@
/* XMRig
* Copyright (c) 2018-2019 tevador <tevador@gmail.com>
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2020 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
@@ -17,9 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "crypto/rx/RxBasicStorage.h"
#include "backend/common/Tags.h"
#include "base/io/log/Log.h"
#include "base/io/log/Tags.h"
#include "base/tools/Chrono.h"