mirror of
https://github.com/xmrig/xmrig.git
synced 2025-03-12 09:37:35 +00:00
Removed non thread safe access to config.
This commit is contained in:
parent
ee677ef5c9
commit
926871cbe1
13 changed files with 24 additions and 27 deletions
|
@ -5,8 +5,8 @@
|
|||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -35,7 +35,6 @@ namespace xmrig {
|
|||
|
||||
class VirtualMemory;
|
||||
class Job;
|
||||
class Config;
|
||||
|
||||
|
||||
class IWorker
|
||||
|
@ -49,7 +48,7 @@ public:
|
|||
virtual size_t intensity() const = 0;
|
||||
virtual uint64_t rawHashes() const = 0;
|
||||
virtual void getHashrateData(uint64_t&, uint64_t&) const = 0;
|
||||
virtual void start(Config*) = 0;
|
||||
virtual void start() = 0;
|
||||
virtual void jobEarlyNotification(const Job&) = 0;
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
|
|
|
@ -390,7 +390,7 @@ void xmrig::CpuBackend::start(IWorker *worker, bool ready)
|
|||
mutex.unlock();
|
||||
|
||||
if (ready) {
|
||||
worker->start(d_ptr->controller->config());
|
||||
worker->start();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -116,16 +116,17 @@ size_t xmrig::CpuConfig::memPoolSize() const
|
|||
std::vector<xmrig::CpuLaunchData> xmrig::CpuConfig::get(const Miner *miner, const Algorithm &algorithm, uint32_t benchSize) const
|
||||
{
|
||||
std::vector<CpuLaunchData> out;
|
||||
const CpuThreads &threads = m_threads.get(algorithm);
|
||||
const auto &threads = m_threads.get(algorithm);
|
||||
|
||||
if (threads.isEmpty()) {
|
||||
return out;
|
||||
}
|
||||
|
||||
out.reserve(threads.count());
|
||||
const size_t count = threads.count();
|
||||
out.reserve(count);
|
||||
|
||||
for (const CpuThread &thread : threads.data()) {
|
||||
out.emplace_back(miner, algorithm, *this, thread, benchSize);
|
||||
for (const auto &thread : threads.data()) {
|
||||
out.emplace_back(miner, algorithm, *this, thread, benchSize, count);
|
||||
}
|
||||
|
||||
return out;
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <algorithm>
|
||||
|
||||
|
||||
xmrig::CpuLaunchData::CpuLaunchData(const Miner *miner, const Algorithm &algorithm, const CpuConfig &config, const CpuThread &thread, uint32_t benchSize) :
|
||||
xmrig::CpuLaunchData::CpuLaunchData(const Miner *miner, const Algorithm &algorithm, const CpuConfig &config, const CpuThread &thread, uint32_t benchSize, size_t threads) :
|
||||
algorithm(algorithm),
|
||||
assembly(config.assembly()),
|
||||
astrobwtAVX2(config.astrobwtAVX2()),
|
||||
|
@ -43,6 +43,7 @@ xmrig::CpuLaunchData::CpuLaunchData(const Miner *miner, const Algorithm &algorit
|
|||
priority(config.priority()),
|
||||
affinity(thread.affinity()),
|
||||
miner(miner),
|
||||
threads(threads),
|
||||
benchSize(benchSize),
|
||||
intensity(std::min<uint32_t>(thread.intensity(), algorithm.maxIntensity()))
|
||||
{
|
||||
|
|
|
@ -44,7 +44,7 @@ class Miner;
|
|||
class CpuLaunchData
|
||||
{
|
||||
public:
|
||||
CpuLaunchData(const Miner *miner, const Algorithm &algorithm, const CpuConfig &config, const CpuThread &thread, uint32_t benchSize);
|
||||
CpuLaunchData(const Miner *miner, const Algorithm &algorithm, const CpuConfig &config, const CpuThread &thread, uint32_t benchSize, size_t threads);
|
||||
|
||||
bool isEqual(const CpuLaunchData &other) const;
|
||||
CnHash::AlgoVariant av() const;
|
||||
|
@ -66,6 +66,7 @@ public:
|
|||
const int priority;
|
||||
const int64_t affinity;
|
||||
const Miner *miner;
|
||||
const size_t threads;
|
||||
const uint32_t benchSize;
|
||||
const uint32_t intensity;
|
||||
};
|
||||
|
|
|
@ -86,6 +86,7 @@ xmrig::CpuWorker<N>::CpuWorker(size_t id, const CpuLaunchData &data) :
|
|||
m_av(data.av()),
|
||||
m_astrobwtMaxSize(data.astrobwtMaxSize * 1000),
|
||||
m_miner(data.miner),
|
||||
m_threads(data.threads),
|
||||
m_benchSize(data.benchSize),
|
||||
m_ctx()
|
||||
{
|
||||
|
@ -199,7 +200,7 @@ bool xmrig::CpuWorker<N>::selfTest()
|
|||
|
||||
|
||||
template<size_t N>
|
||||
void xmrig::CpuWorker<N>::start(xmrig::Config* config)
|
||||
void xmrig::CpuWorker<N>::start()
|
||||
{
|
||||
while (Nonce::sequence(Nonce::CPU) > 0) {
|
||||
if (Nonce::isPaused()) {
|
||||
|
@ -220,10 +221,6 @@ void xmrig::CpuWorker<N>::start(xmrig::Config* config)
|
|||
alignas(16) uint64_t tempHash[8] = {};
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
const size_t benchThreads = config->cpu().threads().get(m_job.currentJob().algorithm()).count();
|
||||
# endif
|
||||
|
||||
while (!Nonce::isOutdated(Nonce::CPU, m_job.sequence())) {
|
||||
const Job &job = m_job.currentJob();
|
||||
|
||||
|
@ -253,7 +250,7 @@ void xmrig::CpuWorker<N>::start(xmrig::Config* config)
|
|||
}
|
||||
|
||||
// Make each hash dependent on the previous one in single thread benchmark to prevent cheating with multiple threads
|
||||
if (benchThreads == 1) {
|
||||
if (m_threads == 1) {
|
||||
*(uint64_t*)(m_job.blob()) ^= m_benchData;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,6 @@ namespace xmrig {
|
|||
|
||||
|
||||
class RxVm;
|
||||
class Config;
|
||||
|
||||
|
||||
template<size_t N>
|
||||
|
@ -57,7 +56,7 @@ public:
|
|||
|
||||
protected:
|
||||
bool selfTest() override;
|
||||
void start(Config*) override;
|
||||
void start() override;
|
||||
|
||||
inline const VirtualMemory *memory() const override { return m_memory; }
|
||||
inline size_t intensity() const override { return N; }
|
||||
|
@ -83,6 +82,7 @@ private:
|
|||
const CnHash::AlgoVariant m_av;
|
||||
const int m_astrobwtMaxSize;
|
||||
const Miner *m_miner;
|
||||
const size_t m_threads;
|
||||
const uint32_t m_benchSize;
|
||||
cryptonight_ctx *m_ctx[N];
|
||||
VirtualMemory *m_memory = nullptr;
|
||||
|
|
|
@ -481,7 +481,7 @@ void xmrig::CudaBackend::start(IWorker *worker, bool ready)
|
|||
mutex.unlock();
|
||||
|
||||
if (ready) {
|
||||
worker->start(d_ptr->controller->config());
|
||||
worker->start();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ size_t xmrig::CudaWorker::intensity() const
|
|||
}
|
||||
|
||||
|
||||
void xmrig::CudaWorker::start(xmrig::Config*)
|
||||
void xmrig::CudaWorker::start()
|
||||
{
|
||||
while (Nonce::sequence(Nonce::CUDA) > 0) {
|
||||
if (!isReady()) {
|
||||
|
|
|
@ -39,7 +39,6 @@ namespace xmrig {
|
|||
|
||||
|
||||
class ICudaRunner;
|
||||
class Config;
|
||||
|
||||
|
||||
class CudaWorker : public Worker
|
||||
|
@ -59,7 +58,7 @@ public:
|
|||
protected:
|
||||
bool selfTest() override;
|
||||
size_t intensity() const override;
|
||||
void start(Config*) override;
|
||||
void start() override;
|
||||
|
||||
private:
|
||||
bool consumeJob();
|
||||
|
|
|
@ -463,7 +463,7 @@ void xmrig::OclBackend::start(IWorker *worker, bool ready)
|
|||
mutex.unlock();
|
||||
|
||||
if (ready) {
|
||||
worker->start(d_ptr->controller->config());
|
||||
worker->start();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ size_t xmrig::OclWorker::intensity() const
|
|||
}
|
||||
|
||||
|
||||
void xmrig::OclWorker::start(xmrig::Config*)
|
||||
void xmrig::OclWorker::start()
|
||||
{
|
||||
cl_uint results[0x100];
|
||||
|
||||
|
|
|
@ -40,7 +40,6 @@ namespace xmrig {
|
|||
|
||||
class IOclRunner;
|
||||
class Job;
|
||||
class Config;
|
||||
|
||||
|
||||
class OclWorker : public Worker
|
||||
|
@ -60,7 +59,7 @@ public:
|
|||
protected:
|
||||
bool selfTest() override;
|
||||
size_t intensity() const override;
|
||||
void start(Config*) override;
|
||||
void start() override;
|
||||
|
||||
private:
|
||||
bool consumeJob();
|
||||
|
|
Loading…
Reference in a new issue