Allow partially started threads.

This commit is contained in:
XMRig 2019-09-17 02:22:59 +07:00
parent e8acb8a2a9
commit e3fcb99d84
14 changed files with 94 additions and 37 deletions

View file

@ -72,12 +72,19 @@ static void printDisabled(const char *reason)
struct OclLaunchStatus
{
public:
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 bool started(bool ready)
{
ready ? m_started++ : m_errors++;
return (m_started + m_errors) == m_threads;
}
inline void start(size_t threads)
{
m_started = 0;
m_errors = 0;
m_threads = threads;
m_ts = Chrono::steadyMSecs();
OclWorker::ready = false;
@ -85,14 +92,23 @@ public:
inline void print() const
{
LOG_INFO("%s" GREEN_BOLD(" READY") " threads " CYAN_BOLD("%zu") BLACK_BOLD(" (%" PRIu64 " ms)"),
if (m_started == 0) {
LOG_ERR("%s " RED_BOLD("disabled") YELLOW(" (failed to start threads)"), tag);
return;
}
LOG_INFO("%s" GREEN_BOLD(" READY") " threads " "%s%zu/%zu" BLACK_BOLD(" (%" PRIu64 " ms)"),
tag,
m_errors == 0 ? CYAN_BOLD_S : YELLOW_BOLD_S,
m_started,
m_threads,
Chrono::steadyMSecs() - m_ts
);
}
private:
size_t m_errors = 0;
size_t m_started = 0;
size_t m_threads = 0;
uint64_t m_ts = 0;
@ -319,11 +335,11 @@ void xmrig::OclBackend::setJob(const Job &job)
}
void xmrig::OclBackend::start(IWorker *worker)
void xmrig::OclBackend::start(IWorker *worker, bool ready)
{
mutex.lock();
if (d_ptr->status.started()) {
if (d_ptr->status.started(ready)) {
d_ptr->status.print();
OclWorker::ready = true;
@ -331,7 +347,9 @@ void xmrig::OclBackend::start(IWorker *worker)
mutex.unlock();
worker->start();
if (ready) {
worker->start();
}
}