mirror of
https://github.com/xmrig/xmrig.git
synced 2025-02-04 04:06:44 +00:00
Make CpuLaunchStatus more high level.
This commit is contained in:
parent
4f1d4695cd
commit
4a5e185973
2 changed files with 67 additions and 52 deletions
|
@ -61,29 +61,63 @@ extern template class Threads<CpuThreads>;
|
||||||
|
|
||||||
static const char *tag = CYAN_BG_BOLD(" cpu ");
|
static const char *tag = CYAN_BG_BOLD(" cpu ");
|
||||||
static const String kType = "cpu";
|
static const String kType = "cpu";
|
||||||
|
static std::mutex mutex;
|
||||||
|
|
||||||
|
|
||||||
struct CpuLaunchStatus
|
struct CpuLaunchStatus
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
inline void reset()
|
inline size_t hugePages() const { return m_hugePages; }
|
||||||
|
inline size_t memory() const { return m_ways * m_memory; }
|
||||||
|
inline size_t pages() const { return m_pages; }
|
||||||
|
inline size_t threads() const { return m_threads; }
|
||||||
|
inline size_t ways() const { return m_ways; }
|
||||||
|
|
||||||
|
inline void start(const std::vector<CpuLaunchData> &threads, size_t memory)
|
||||||
{
|
{
|
||||||
hugePages = 0;
|
m_hugePages = 0;
|
||||||
memory = 0;
|
m_memory = memory;
|
||||||
pages = 0;
|
m_pages = 0;
|
||||||
started = 0;
|
m_started = 0;
|
||||||
threads = 0;
|
m_threads = threads.size();
|
||||||
ways = 0;
|
m_ways = 0;
|
||||||
ts = Chrono::steadyMSecs();
|
m_ts = Chrono::steadyMSecs();
|
||||||
|
|
||||||
|
for (const CpuLaunchData &data : threads) {
|
||||||
|
m_ways += data.intensity;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t hugePages = 0;
|
inline bool started(const std::pair<size_t, size_t> &hugePages)
|
||||||
size_t memory = 0;
|
{
|
||||||
size_t pages = 0;
|
m_started++;
|
||||||
size_t started = 0;
|
m_hugePages += hugePages.first;
|
||||||
size_t threads = 0;
|
m_pages += hugePages.second;
|
||||||
size_t ways = 0;
|
|
||||||
uint64_t ts = 0;
|
return m_started == m_threads;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void print() const
|
||||||
|
{
|
||||||
|
LOG_INFO("%s" GREEN_BOLD(" READY") " threads " CYAN_BOLD("%zu(%zu)") " huge pages %s%zu/%zu %1.0f%%\x1B[0m memory " CYAN_BOLD("%zu KB") BLACK_BOLD(" (%" PRIu64 " ms)"),
|
||||||
|
tag,
|
||||||
|
m_threads, m_ways,
|
||||||
|
(m_hugePages == m_pages ? GREEN_BOLD_S : (m_hugePages == 0 ? RED_BOLD_S : YELLOW_BOLD_S)),
|
||||||
|
m_hugePages, m_pages,
|
||||||
|
m_hugePages == 0 ? 0.0 : static_cast<double>(m_hugePages) / m_pages * 100.0,
|
||||||
|
m_ways * m_memory / 1024,
|
||||||
|
Chrono::steadyMSecs() - m_ts
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
size_t m_hugePages = 0;
|
||||||
|
size_t m_memory = 0;
|
||||||
|
size_t m_pages = 0;
|
||||||
|
size_t m_started = 0;
|
||||||
|
size_t m_threads = 0;
|
||||||
|
size_t m_ways = 0;
|
||||||
|
uint64_t m_ts = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,14 +141,7 @@ public:
|
||||||
|
|
||||||
workers.stop();
|
workers.stop();
|
||||||
|
|
||||||
status.reset();
|
status.start(threads, algo.l3());
|
||||||
status.memory = algo.l3();
|
|
||||||
status.threads = threads.size();
|
|
||||||
|
|
||||||
for (const CpuLaunchData &data : threads) {
|
|
||||||
status.ways += static_cast<size_t>(data.intensity);
|
|
||||||
}
|
|
||||||
|
|
||||||
workers.start(threads);
|
workers.start(threads);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +150,7 @@ public:
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mutex);
|
std::lock_guard<std::mutex> lock(mutex);
|
||||||
|
|
||||||
return status.ways;
|
return status.ways();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -139,8 +166,8 @@ public:
|
||||||
|
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
|
|
||||||
pages.first += status.hugePages;
|
pages.first += status.hugePages();
|
||||||
pages.second += status.pages;
|
pages.second += status.pages();
|
||||||
|
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
|
|
||||||
|
@ -162,7 +189,6 @@ public:
|
||||||
Algorithm algo;
|
Algorithm algo;
|
||||||
Controller *controller;
|
Controller *controller;
|
||||||
CpuLaunchStatus status;
|
CpuLaunchStatus status;
|
||||||
std::mutex mutex;
|
|
||||||
std::vector<CpuLaunchData> threads;
|
std::vector<CpuLaunchData> threads;
|
||||||
String profileName;
|
String profileName;
|
||||||
Workers<CpuLaunchData> workers;
|
Workers<CpuLaunchData> workers;
|
||||||
|
@ -291,28 +317,13 @@ void xmrig::CpuBackend::setJob(const Job &job)
|
||||||
|
|
||||||
void xmrig::CpuBackend::start(IWorker *worker)
|
void xmrig::CpuBackend::start(IWorker *worker)
|
||||||
{
|
{
|
||||||
d_ptr->mutex.lock();
|
mutex.lock();
|
||||||
|
|
||||||
const auto pages = worker->memory()->hugePages();
|
if (d_ptr->status.started(worker->memory()->hugePages())) {
|
||||||
|
d_ptr->status.print();
|
||||||
d_ptr->status.started++;
|
|
||||||
d_ptr->status.hugePages += pages.first;
|
|
||||||
d_ptr->status.pages += pages.second;
|
|
||||||
|
|
||||||
if (d_ptr->status.started == d_ptr->status.threads) {
|
|
||||||
const double percent = d_ptr->status.hugePages == 0 ? 0.0 : static_cast<double>(d_ptr->status.hugePages) / d_ptr->status.pages * 100.0;
|
|
||||||
const size_t memory = d_ptr->status.ways * d_ptr->status.memory / 1024;
|
|
||||||
|
|
||||||
LOG_INFO("%s" GREEN_BOLD(" READY") " threads " CYAN_BOLD("%zu(%zu)") " huge pages %s%zu/%zu %1.0f%%\x1B[0m memory " CYAN_BOLD("%zu KB") BLACK_BOLD(" (%" PRIu64 " ms)"),
|
|
||||||
tag,
|
|
||||||
d_ptr->status.threads, d_ptr->status.ways,
|
|
||||||
(d_ptr->status.hugePages == d_ptr->status.pages ? GREEN_BOLD_S : (d_ptr->status.hugePages == 0 ? RED_BOLD_S : YELLOW_BOLD_S)),
|
|
||||||
d_ptr->status.hugePages, d_ptr->status.pages, percent, memory,
|
|
||||||
Chrono::steadyMSecs() - d_ptr->status.ts
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
d_ptr->mutex.unlock();
|
mutex.unlock();
|
||||||
|
|
||||||
worker->start();
|
worker->start();
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,9 +71,17 @@ 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 uint64_t ts() const { return Chrono::steadyMSecs() - m_ts; }
|
|
||||||
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(); }
|
||||||
|
|
||||||
|
inline void print() const
|
||||||
|
{
|
||||||
|
LOG_INFO("%s" GREEN_BOLD(" READY") " threads " CYAN_BOLD("%zu") BLACK_BOLD(" (%" PRIu64 " ms)"),
|
||||||
|
tag,
|
||||||
|
m_threads,
|
||||||
|
Chrono::steadyMSecs() - m_ts
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_t m_started = 0;
|
size_t m_started = 0;
|
||||||
size_t m_threads = 0;
|
size_t m_threads = 0;
|
||||||
|
@ -279,11 +287,7 @@ void xmrig::OclBackend::start(IWorker *worker)
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
|
|
||||||
if (d_ptr->status.started()) {
|
if (d_ptr->status.started()) {
|
||||||
LOG_INFO("%s" GREEN_BOLD(" READY") " threads " CYAN_BOLD("%zu") BLACK_BOLD(" (%" PRIu64 " ms)"),
|
d_ptr->status.print();
|
||||||
tag,
|
|
||||||
d_ptr->status.threads(),
|
|
||||||
d_ptr->status.ts()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
|
|
Loading…
Reference in a new issue