mirror of
https://github.com/xmrig/xmrig.git
synced 2024-11-05 16:07:42 +00:00
Improved OpenCL startup time.
This commit is contained in:
parent
62f086f607
commit
d9adf14551
3 changed files with 18 additions and 4 deletions
|
@ -32,6 +32,7 @@
|
||||||
#include "backend/opencl/OclBackend.h"
|
#include "backend/opencl/OclBackend.h"
|
||||||
#include "backend/opencl/OclConfig.h"
|
#include "backend/opencl/OclConfig.h"
|
||||||
#include "backend/opencl/OclLaunchData.h"
|
#include "backend/opencl/OclLaunchData.h"
|
||||||
|
#include "backend/opencl/OclWorker.h"
|
||||||
#include "backend/opencl/wrappers/OclContext.h"
|
#include "backend/opencl/wrappers/OclContext.h"
|
||||||
#include "backend/opencl/wrappers/OclLib.h"
|
#include "backend/opencl/wrappers/OclLib.h"
|
||||||
#include "base/io/log/Log.h"
|
#include "base/io/log/Log.h"
|
||||||
|
@ -71,7 +72,14 @@ struct OclLaunchStatus
|
||||||
public:
|
public:
|
||||||
inline bool started() { m_started++; return m_started == m_threads; }
|
inline bool started() { m_started++; return m_started == m_threads; }
|
||||||
inline size_t threads() const { return m_threads; }
|
inline size_t threads() const { return m_threads; }
|
||||||
inline void start(size_t threads) { m_started = 0; m_threads = threads; m_ts = Chrono::steadyMSecs(); }
|
|
||||||
|
inline void start(size_t threads)
|
||||||
|
{
|
||||||
|
m_started = 0;
|
||||||
|
m_threads = threads;
|
||||||
|
m_ts = Chrono::steadyMSecs();
|
||||||
|
OclWorker::ready = false;
|
||||||
|
}
|
||||||
|
|
||||||
inline void print() const
|
inline void print() const
|
||||||
{
|
{
|
||||||
|
@ -309,6 +317,8 @@ void xmrig::OclBackend::start(IWorker *worker)
|
||||||
|
|
||||||
if (d_ptr->status.started()) {
|
if (d_ptr->status.started()) {
|
||||||
d_ptr->status.print();
|
d_ptr->status.print();
|
||||||
|
|
||||||
|
OclWorker::ready = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
|
|
|
@ -47,8 +47,10 @@ namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
static constexpr uint32_t kReserveCount = 32768;
|
static constexpr uint32_t kReserveCount = 32768;
|
||||||
|
std::atomic<bool> OclWorker::ready;
|
||||||
|
|
||||||
|
|
||||||
|
static inline bool isReady() { return !Nonce::isPaused() && OclWorker::ready; }
|
||||||
static inline uint32_t roundSize(uint32_t intensity) { return kReserveCount / intensity + 1; }
|
static inline uint32_t roundSize(uint32_t intensity) { return kReserveCount / intensity + 1; }
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,7 +106,7 @@ void xmrig::OclWorker::start()
|
||||||
cl_uint results[0x100];
|
cl_uint results[0x100];
|
||||||
|
|
||||||
while (Nonce::sequence(Nonce::OPENCL) > 0) {
|
while (Nonce::sequence(Nonce::OPENCL) > 0) {
|
||||||
if (Nonce::isPaused()) {
|
if (!isReady()) {
|
||||||
if (m_interleave) {
|
if (m_interleave) {
|
||||||
m_interleave->setResumeCounter(0);
|
m_interleave->setResumeCounter(0);
|
||||||
}
|
}
|
||||||
|
@ -112,7 +114,7 @@ void xmrig::OclWorker::start()
|
||||||
do {
|
do {
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
}
|
}
|
||||||
while (Nonce::isPaused() && Nonce::sequence(Nonce::OPENCL) > 0);
|
while (!isReady() && Nonce::sequence(Nonce::OPENCL) > 0);
|
||||||
|
|
||||||
if (Nonce::sequence(Nonce::OPENCL) == 0) {
|
if (Nonce::sequence(Nonce::OPENCL) == 0) {
|
||||||
break;
|
break;
|
||||||
|
@ -164,7 +166,7 @@ void xmrig::OclWorker::consumeJob()
|
||||||
|
|
||||||
void xmrig::OclWorker::storeStats(uint64_t t)
|
void xmrig::OclWorker::storeStats(uint64_t t)
|
||||||
{
|
{
|
||||||
if (Nonce::isPaused()) {
|
if (!isReady()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,8 @@ public:
|
||||||
OclWorker &operator=(const OclWorker &other) = delete;
|
OclWorker &operator=(const OclWorker &other) = delete;
|
||||||
OclWorker &operator=(OclWorker &&other) = delete;
|
OclWorker &operator=(OclWorker &&other) = delete;
|
||||||
|
|
||||||
|
static std::atomic<bool> ready;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool selfTest() override;
|
bool selfTest() override;
|
||||||
void start() override;
|
void start() override;
|
||||||
|
|
Loading…
Reference in a new issue