From d9dc6a396f415df815e5046d3692910ef74e1722 Mon Sep 17 00:00:00 2001 From: XMRig Date: Mon, 23 Sep 2019 05:33:48 +0700 Subject: [PATCH] Add support for initialize OpenCL in runtime. --- src/backend/opencl/OclBackend.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/backend/opencl/OclBackend.cpp b/src/backend/opencl/OclBackend.cpp index 4820ce086..9b226811f 100644 --- a/src/backend/opencl/OclBackend.cpp +++ b/src/backend/opencl/OclBackend.cpp @@ -135,6 +135,10 @@ public: return printDisabled(RED_S " (failed to load OpenCL runtime)"); } + if (platform.isValid()) { + return; + } + platform = cl.platform(); if (!platform.isValid()) { return printDisabled(RED_S " (selected OpenCL platform NOT found)"); @@ -302,12 +306,15 @@ void xmrig::OclBackend::printHashrate(bool details) void xmrig::OclBackend::setJob(const Job &job) { + const OclConfig &cl = d_ptr->controller->config()->cl(); + if (cl.isEnabled()) { + d_ptr->init(cl); + } + if (!isEnabled()) { return stop(); } - const OclConfig &cl = d_ptr->controller->config()->cl(); - std::vector threads = cl.get(d_ptr->controller->miner(), job.algorithm(), d_ptr->platform, d_ptr->devices, tag); if (!d_ptr->threads.empty() && d_ptr->threads.size() == threads.size() && std::equal(d_ptr->threads.begin(), d_ptr->threads.end(), threads.begin())) { return;