From 0e362f38bc88da6209c6cfb13ed704548b29b7d1 Mon Sep 17 00:00:00 2001 From: XMRig Date: Thu, 5 Sep 2019 13:00:40 +0700 Subject: [PATCH] Print detailed information about OpenCL threads. --- src/backend/opencl/OclBackend.cpp | 34 ++++++++++++++++++++++++------- src/backend/opencl/OclBackend.h | 7 +++++++ src/backend/opencl/OclCache.cpp | 4 ++-- src/crypto/cn/CnAlgo.h | 2 ++ 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/src/backend/opencl/OclBackend.cpp b/src/backend/opencl/OclBackend.cpp index d53c0db92..5e46940d7 100644 --- a/src/backend/opencl/OclBackend.cpp +++ b/src/backend/opencl/OclBackend.cpp @@ -54,7 +54,7 @@ namespace xmrig { extern template class Threads; -constexpr const size_t oneGiB = 1024u * 1024u * 1024u; +constexpr const size_t oneMiB = 1024u * 1024u; static const char *tag = MAGENTA_BG_BOLD(WHITE_BOLD_S " ocl "); static const String kType = "opencl"; static std::mutex mutex; @@ -122,14 +122,14 @@ public: Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("#%zu ") WHITE_BOLD("%s") "/" WHITE_BOLD("%s"), "OPENCL", platform.index(), platform.name().data(), platform.version().data()); for (const OclDevice &device : devices) { - Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("#%zu") YELLOW(" %s") " %s " WHITE_BOLD("%uMHz") " cu:" WHITE_BOLD("%u") " mem:" CYAN("%1.2f/%1.2f") " GB", "OPENCL GPU", + Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("#%zu") YELLOW(" %s") " %s " WHITE_BOLD("%uMHz") " cu:" WHITE_BOLD("%u") " mem:" CYAN("%zu/%zu") " MB", "OPENCL GPU", device.index(), device.hasTopology() ? device.topology().toString().data() : "n/a", device.printableName().data(), device.clock(), device.computeUnits(), - static_cast(device.freeMem()) / oneGiB, - static_cast(device.globalMem()) / oneGiB); + device.freeMem() / oneMiB, + device.globalMem() / oneMiB); } } @@ -143,6 +143,27 @@ public: algo.l3() / 1024 ); + Log::print(WHITE_BOLD("| # | GPU | BUS ID | I | W | SI | MC | U | MEM | NAME")); + + size_t i = 0; + for (const auto &data : threads) { + Log::print("|" CYAN_BOLD("%3zu") " |" CYAN_BOLD("%4u") " |" YELLOW(" %7s") " |" CYAN_BOLD("%5u") " |" CYAN_BOLD("%3u") " |" + CYAN_BOLD("%3u") " |" CYAN_BOLD("%3s") " |" CYAN_BOLD("%3u") " |" CYAN("%5zu") " | %s", + i, + data.thread.index(), + data.device.hasTopology() ? data.device.topology().toString().data() : "n/a", + data.thread.intensity(), + data.thread.worksize(), + data.thread.stridedIndex(), + data.thread.stridedIndex() == 2 ? std::to_string(data.thread.memChunk()).c_str() : "-", + data.thread.unrollFactor(), + data.thread.intensity() * algo.l3() / oneMiB, + data.device.printableName().data() + ); + + i++; + } + status.start(threads.size()); workers.start(threads); } @@ -339,9 +360,8 @@ rapidjson::Value xmrig::OclBackend::toJSON(rapidjson::Document &doc) const size_t i = 0; for (const OclLaunchData &data : d_ptr->threads) { - Value thread(kObjectType); - thread.AddMember("intensity", data.thread.intensity(), allocator); - thread.AddMember("affinity", data.affinity, allocator); + Value thread = data.thread.toJSON(doc); + thread.AddMember("affinity", data.affinity, allocator); Value hashrate(kArrayType); hashrate.PushBack(Hashrate::normalize(hr->calc(i, Hashrate::ShortInterval)), allocator); diff --git a/src/backend/opencl/OclBackend.h b/src/backend/opencl/OclBackend.h index bb44b109d..e6ba092ee 100644 --- a/src/backend/opencl/OclBackend.h +++ b/src/backend/opencl/OclBackend.h @@ -43,9 +43,16 @@ class Miner; class OclBackend : public IBackend { public: + OclBackend() = delete; + OclBackend(const OclBackend &other) = delete; OclBackend(Controller *controller); + OclBackend(OclBackend &&other) = delete; + ~OclBackend() override; + OclBackend &operator=(const OclBackend &other) = delete; + OclBackend &operator=(OclBackend &&other) = delete; + protected: bool isEnabled() const override; bool isEnabled(const Algorithm &algorithm) const override; diff --git a/src/backend/opencl/OclCache.cpp b/src/backend/opencl/OclCache.cpp index d01eea062..876ce74ab 100644 --- a/src/backend/opencl/OclCache.cpp +++ b/src/backend/opencl/OclCache.cpp @@ -67,8 +67,8 @@ static cl_program createFromSource(const IOclRunner *runner) return nullptr; } - LOG_INFO("%s GPU " WHITE_BOLD("#%zu") " " GREEN_BOLD("compilation completed") BLACK_BOLD( " (%.3fs)"), - tag, runner->data().device.index(), (Chrono::steadyMSecs() - ts) / 1000.0); + LOG_INFO("%s GPU " WHITE_BOLD("#%zu") " " GREEN_BOLD("compilation completed") BLACK_BOLD(" (%" PRIu64 " ms)"), + tag, runner->data().device.index(), Chrono::steadyMSecs() - ts); return program; } diff --git a/src/crypto/cn/CnAlgo.h b/src/crypto/cn/CnAlgo.h index 8660e2315..296c52b73 100644 --- a/src/crypto/cn/CnAlgo.h +++ b/src/crypto/cn/CnAlgo.h @@ -42,6 +42,8 @@ template class CnAlgo { public: + constexpr CnAlgo() {}; + constexpr inline Algorithm::Id base() const { static_assert(ALGO > Algorithm::INVALID && ALGO < Algorithm::RX_0, "invalid CRYPTONIGHT algorithm"); return Algorithm::CN_2; } constexpr inline bool isHeavy() const { return memory() == CN_MEMORY * 2; } constexpr inline bool isR() const { return ALGO == Algorithm::CN_R; }