OpenCL RandomX WIP
This commit is contained in:
parent
ff89ec660c
commit
4c90f9960e
72 changed files with 1717 additions and 505 deletions
|
@ -64,8 +64,8 @@ function rx()
|
||||||
'randomx_jit.cl'
|
'randomx_jit.cl'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
rx = rx.replace(/ #include "fillAes1Rx4.cl"/g, fs.readFileSync('fillAes1Rx4.cl', 'utf8'));
|
rx = rx.replace(/(\t| )*#include "fillAes1Rx4.cl"/g, fs.readFileSync('fillAes1Rx4.cl', 'utf8'));
|
||||||
rx = rx.replace(/ #include "blake2b_double_block.cl"/g, fs.readFileSync('blake2b_double_block.cl', 'utf8'));
|
rx = rx.replace(/(\t| )*#include "blake2b_double_block.cl"/g, fs.readFileSync('blake2b_double_block.cl', 'utf8'));
|
||||||
|
|
||||||
//fs.writeFileSync('randomx_gen.cl', rx);
|
//fs.writeFileSync('randomx_gen.cl', rx);
|
||||||
fs.writeFileSync('randomx_cl.h', text2h(rx, 'xmrig', 'randomx_cl'));
|
fs.writeFileSync('randomx_cl.h', text2h(rx, 'xmrig', 'randomx_cl'));
|
||||||
|
|
44
src/backend/common/Tags.h
Normal file
44
src/backend/common/Tags.h
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XMRIG_TAGS_H
|
||||||
|
#define XMRIG_TAGS_H
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
const char *cpu_tag();
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef XMRIG_FEATURE_OPENCL
|
||||||
|
const char *ocl_tag();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace xmrig
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* XMRIG_TAGS_H */
|
|
@ -151,12 +151,13 @@ xmrig::IWorker *xmrig::Workers<T>::create(Thread<T> *)
|
||||||
template<class T>
|
template<class T>
|
||||||
void xmrig::Workers<T>::onReady(void *arg)
|
void xmrig::Workers<T>::onReady(void *arg)
|
||||||
{
|
{
|
||||||
Thread<T> *handle = static_cast<Thread<T>* >(arg);
|
auto handle = static_cast<Thread<T>* >(arg);
|
||||||
|
|
||||||
IWorker *worker = create(handle);
|
IWorker *worker = create(handle);
|
||||||
if (!worker || !worker->selfTest()) {
|
if (!worker || !worker->selfTest()) {
|
||||||
LOG_ERR("thread %zu error: \"hash self-test failed\".", worker->id());
|
LOG_ERR("thread %zu error: \"hash self-test failed\".", worker->id());
|
||||||
|
|
||||||
|
delete worker;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
set(HEADERS_BACKEND_COMMON
|
set(HEADERS_BACKEND_COMMON
|
||||||
src/backend/common/Hashrate.h
|
src/backend/common/Hashrate.h
|
||||||
|
src/backend/common/Tags.h
|
||||||
src/backend/common/interfaces/IBackend.h
|
src/backend/common/interfaces/IBackend.h
|
||||||
src/backend/common/interfaces/IRxListener.h
|
src/backend/common/interfaces/IRxListener.h
|
||||||
src/backend/common/interfaces/IThread.h
|
src/backend/common/interfaces/IThread.h
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include "backend/common/Hashrate.h"
|
#include "backend/common/Hashrate.h"
|
||||||
#include "backend/common/interfaces/IWorker.h"
|
#include "backend/common/interfaces/IWorker.h"
|
||||||
|
#include "backend/common/Tags.h"
|
||||||
#include "backend/common/Workers.h"
|
#include "backend/common/Workers.h"
|
||||||
#include "backend/cpu/Cpu.h"
|
#include "backend/cpu/Cpu.h"
|
||||||
#include "backend/cpu/CpuBackend.h"
|
#include "backend/cpu/CpuBackend.h"
|
||||||
|
@ -196,6 +197,12 @@ public:
|
||||||
} // namespace xmrig
|
} // namespace xmrig
|
||||||
|
|
||||||
|
|
||||||
|
const char *xmrig::cpu_tag()
|
||||||
|
{
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
xmrig::CpuBackend::CpuBackend(Controller *controller) :
|
xmrig::CpuBackend::CpuBackend(Controller *controller) :
|
||||||
d_ptr(new CpuBackendPrivate(controller))
|
d_ptr(new CpuBackendPrivate(controller))
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include "backend/common/Hashrate.h"
|
#include "backend/common/Hashrate.h"
|
||||||
#include "backend/common/interfaces/IWorker.h"
|
#include "backend/common/interfaces/IWorker.h"
|
||||||
|
#include "backend/common/Tags.h"
|
||||||
#include "backend/common/Workers.h"
|
#include "backend/common/Workers.h"
|
||||||
#include "backend/opencl/OclBackend.h"
|
#include "backend/opencl/OclBackend.h"
|
||||||
#include "backend/opencl/OclConfig.h"
|
#include "backend/opencl/OclConfig.h"
|
||||||
|
@ -192,6 +193,12 @@ public:
|
||||||
} // namespace xmrig
|
} // namespace xmrig
|
||||||
|
|
||||||
|
|
||||||
|
const char *xmrig::ocl_tag()
|
||||||
|
{
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
xmrig::OclBackend::OclBackend(Controller *controller) :
|
xmrig::OclBackend::OclBackend(Controller *controller) :
|
||||||
d_ptr(new OclBackendPrivate(controller))
|
d_ptr(new OclBackendPrivate(controller))
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include "3rdparty/base32/base32.h"
|
#include "3rdparty/base32/base32.h"
|
||||||
|
#include "backend/common/Tags.h"
|
||||||
#include "backend/opencl/interfaces/IOclRunner.h"
|
#include "backend/opencl/interfaces/IOclRunner.h"
|
||||||
#include "backend/opencl/OclCache.h"
|
#include "backend/opencl/OclCache.h"
|
||||||
#include "backend/opencl/OclLaunchData.h"
|
#include "backend/opencl/OclLaunchData.h"
|
||||||
|
@ -42,13 +43,12 @@
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
static const char *tag = MAGENTA_BG_BOLD(WHITE_BOLD_S " ocl ");
|
|
||||||
static std::mutex mutex;
|
static std::mutex mutex;
|
||||||
|
|
||||||
|
|
||||||
static cl_program createFromSource(const IOclRunner *runner)
|
static cl_program createFromSource(const IOclRunner *runner)
|
||||||
{
|
{
|
||||||
LOG_INFO("%s GPU " WHITE_BOLD("#%zu") " " YELLOW_BOLD("compiling..."), tag, runner->data().device.index());
|
LOG_INFO("%s GPU " WHITE_BOLD("#%zu") " " YELLOW_BOLD("compiling..."), ocl_tag(), runner->data().device.index());
|
||||||
|
|
||||||
cl_int ret;
|
cl_int ret;
|
||||||
cl_device_id device = runner->data().device.id();
|
cl_device_id device = runner->data().device.id();
|
||||||
|
@ -68,7 +68,7 @@ static cl_program createFromSource(const IOclRunner *runner)
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO("%s GPU " WHITE_BOLD("#%zu") " " GREEN_BOLD("compilation completed") BLACK_BOLD(" (%" PRIu64 " ms)"),
|
LOG_INFO("%s GPU " WHITE_BOLD("#%zu") " " GREEN_BOLD("compilation completed") BLACK_BOLD(" (%" PRIu64 " ms)"),
|
||||||
tag, runner->data().device.index(), Chrono::steadyMSecs() - ts);
|
ocl_tag(), runner->data().device.index(), Chrono::steadyMSecs() - ts);
|
||||||
|
|
||||||
return program;
|
return program;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
typedef struct _cl_program *cl_program;
|
using cl_program = struct _cl_program *;
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
|
|
@ -166,6 +166,10 @@ std::vector<xmrig::OclLaunchData> xmrig::OclConfig::get(const Miner *miner, cons
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
|
auto dataset = algorithm.family() == Algorithm::RANDOM_X ? std::make_shared<OclRxDataset>() : nullptr;
|
||||||
|
# endif
|
||||||
|
|
||||||
if (thread.threads().size() > 1) {
|
if (thread.threads().size() > 1) {
|
||||||
auto interleave = std::make_shared<OclInterleave>(thread.threads().size());
|
auto interleave = std::make_shared<OclInterleave>(thread.threads().size());
|
||||||
|
|
||||||
|
@ -173,11 +177,21 @@ std::vector<xmrig::OclLaunchData> xmrig::OclConfig::get(const Miner *miner, cons
|
||||||
OclLaunchData data(miner, algorithm, *this, platform, thread, devices[thread.index()], affinity);
|
OclLaunchData data(miner, algorithm, *this, platform, thread, devices[thread.index()], affinity);
|
||||||
data.interleave = interleave;
|
data.interleave = interleave;
|
||||||
|
|
||||||
out.emplace_back(data);
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
|
data.dataset = dataset;
|
||||||
|
# endif
|
||||||
|
|
||||||
|
out.emplace_back(std::move(data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
out.emplace_back(miner, algorithm, *this, platform, thread, devices[thread.index()], thread.threads()[0]);
|
OclLaunchData data(miner, algorithm, *this, platform, thread, devices[thread.index()], thread.threads().front());
|
||||||
|
|
||||||
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
|
data.dataset = dataset;
|
||||||
|
# endif
|
||||||
|
|
||||||
|
out.emplace_back(std::move(data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,11 @@
|
||||||
#include "crypto/common/Nonce.h"
|
#include "crypto/common/Nonce.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef XMRIG_ALGO_RANDOMX
|
||||||
|
# include "backend/opencl/runners/tools/OclRxDataset.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
using cl_context = struct _cl_context *;
|
using cl_context = struct _cl_context *;
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,6 +71,10 @@ public:
|
||||||
const OclPlatform platform;
|
const OclPlatform platform;
|
||||||
const OclThread thread;
|
const OclThread thread;
|
||||||
OclInterleavePtr interleave;
|
OclInterleavePtr interleave;
|
||||||
|
|
||||||
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
|
OclRxDatasetPtr dataset;
|
||||||
|
# endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ xmrig::OclThread::OclThread(const rapidjson::Value &value)
|
||||||
# ifdef XMRIG_ALGO_RANDOMX
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
m_bfactor = Json::getUint(value, kBFactor, 6);
|
m_bfactor = Json::getUint(value, kBFactor, 6);
|
||||||
m_gcnAsm = Json::getUint(value, kGCNAsm, m_gcnAsm);
|
m_gcnAsm = Json::getUint(value, kGCNAsm, m_gcnAsm);
|
||||||
m_datasetHost = Json::getInt(value, kDatasetHost, m_datasetHost);
|
m_datasetHost = Json::getBool(value, kDatasetHost, m_datasetHost);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
const rapidjson::Value &si = Json::getArray(value, kStridedIndex);
|
const rapidjson::Value &si = Json::getArray(value, kStridedIndex);
|
||||||
|
@ -134,11 +134,11 @@ rapidjson::Value xmrig::OclThread::toJSON(rapidjson::Document &doc) const
|
||||||
out.AddMember(StringRef(kUnroll), unrollFactor(), allocator);
|
out.AddMember(StringRef(kUnroll), unrollFactor(), allocator);
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_RANDOMX
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
if (m_datasetHost != -1) {
|
// if (m_datasetHost != -1) {
|
||||||
out.AddMember(StringRef(kBFactor), bfactor(), allocator);
|
// out.AddMember(StringRef(kBFactor), bfactor(), allocator);
|
||||||
out.AddMember(StringRef(kGCNAsm), gcnAsm(), allocator);
|
// out.AddMember(StringRef(kGCNAsm), gcnAsm(), allocator);
|
||||||
out.AddMember(StringRef(kDatasetHost), datasetHost(), allocator);
|
// out.AddMember(StringRef(kDatasetHost), isDatasetHost(), allocator);
|
||||||
}
|
// }
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
|
|
|
@ -68,11 +68,11 @@ public:
|
||||||
|
|
||||||
OclThread(const rapidjson::Value &value);
|
OclThread(const rapidjson::Value &value);
|
||||||
|
|
||||||
|
inline bool isAsm() const { return m_gcnAsm; }
|
||||||
|
inline bool isDatasetHost() const { return m_datasetHost; }
|
||||||
inline bool isValid() const { return m_intensity > 0; }
|
inline bool isValid() const { return m_intensity > 0; }
|
||||||
inline const std::vector<int64_t> &threads() const { return m_threads; }
|
inline const std::vector<int64_t> &threads() const { return m_threads; }
|
||||||
inline uint32_t bfactor() const { return m_bfactor; }
|
inline uint32_t bfactor() const { return m_bfactor; }
|
||||||
inline uint32_t datasetHost() const { return m_datasetHost < 0 ? 0 : static_cast<uint32_t>(m_datasetHost); }
|
|
||||||
inline uint32_t gcnAsm() const { return m_gcnAsm; }
|
|
||||||
inline uint32_t index() const { return m_index; }
|
inline uint32_t index() const { return m_index; }
|
||||||
inline uint32_t intensity() const { return m_intensity; }
|
inline uint32_t intensity() const { return m_intensity; }
|
||||||
inline uint32_t memChunk() const { return m_memChunk; }
|
inline uint32_t memChunk() const { return m_memChunk; }
|
||||||
|
@ -95,11 +95,11 @@ private:
|
||||||
|
|
||||||
inline void setIntensity(uint32_t intensity) { m_intensity = intensity / m_worksize * m_worksize; }
|
inline void setIntensity(uint32_t intensity) { m_intensity = intensity / m_worksize * m_worksize; }
|
||||||
|
|
||||||
int m_datasetHost = -1;
|
bool m_datasetHost = false;
|
||||||
|
bool m_gcnAsm = false;
|
||||||
std::bitset<FIELD_MAX> m_fields = 1;
|
std::bitset<FIELD_MAX> m_fields = 1;
|
||||||
std::vector<int64_t> m_threads;
|
std::vector<int64_t> m_threads;
|
||||||
uint32_t m_bfactor = 6;
|
uint32_t m_bfactor = 6;
|
||||||
uint32_t m_gcnAsm = 1;
|
|
||||||
uint32_t m_index = 0;
|
uint32_t m_index = 0;
|
||||||
uint32_t m_intensity = 0;
|
uint32_t m_intensity = 0;
|
||||||
uint32_t m_memChunk = 2;
|
uint32_t m_memChunk = 2;
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include "backend/opencl/OclWorker.h"
|
#include "backend/opencl/OclWorker.h"
|
||||||
|
|
||||||
|
#include "backend/common/Tags.h"
|
||||||
#include "backend/opencl/runners/OclCnRunner.h"
|
#include "backend/opencl/runners/OclCnRunner.h"
|
||||||
#include "base/io/log/Log.h"
|
#include "base/io/log/Log.h"
|
||||||
#include "base/tools/Chrono.h"
|
#include "base/tools/Chrono.h"
|
||||||
|
@ -35,7 +36,8 @@
|
||||||
|
|
||||||
|
|
||||||
#ifdef XMRIG_ALGO_RANDOMX
|
#ifdef XMRIG_ALGO_RANDOMX
|
||||||
# include "backend/opencl/runners/OclRxRunner.h"
|
# include "backend/opencl/runners/OclRxJitRunner.h"
|
||||||
|
# include "backend/opencl/runners/OclRxVmRunner.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef XMRIG_ALGO_CN_GPU
|
#ifdef XMRIG_ALGO_CN_GPU
|
||||||
|
@ -58,6 +60,12 @@ static inline bool isReady() { return !Nonce::isPaused()
|
||||||
static inline uint32_t roundSize(uint32_t intensity) { return kReserveCount / intensity + 1; }
|
static inline uint32_t roundSize(uint32_t intensity) { return kReserveCount / intensity + 1; }
|
||||||
|
|
||||||
|
|
||||||
|
static inline void printError(size_t id, const char *error)
|
||||||
|
{
|
||||||
|
LOG_ERR("%s" RED_S " thread " RED_BOLD("#%zu") RED_S " failed with error " RED_BOLD("%s"), ocl_tag(), id, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace xmrig
|
} // namespace xmrig
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,7 +80,12 @@ xmrig::OclWorker::OclWorker(size_t id, const OclLaunchData &data) :
|
||||||
switch (m_algorithm.family()) {
|
switch (m_algorithm.family()) {
|
||||||
case Algorithm::RANDOM_X:
|
case Algorithm::RANDOM_X:
|
||||||
# ifdef XMRIG_ALGO_RANDOMX
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
m_runner = new OclRxRunner(id, data);
|
if (data.thread.isAsm() && data.device.vendorId() == OCL_VENDOR_AMD) {
|
||||||
|
m_runner = new OclRxJitRunner(id, data);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_runner = new OclRxVmRunner(id, data);
|
||||||
|
}
|
||||||
# endif
|
# endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -95,9 +108,20 @@ xmrig::OclWorker::OclWorker(size_t id, const OclLaunchData &data) :
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_runner) {
|
if (!m_runner) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
m_runner->init();
|
||||||
m_runner->build();
|
m_runner->build();
|
||||||
}
|
}
|
||||||
|
catch (std::exception &ex) {
|
||||||
|
printError(id, ex.what());
|
||||||
|
|
||||||
|
delete m_runner;
|
||||||
|
m_runner = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -109,7 +133,7 @@ xmrig::OclWorker::~OclWorker()
|
||||||
|
|
||||||
bool xmrig::OclWorker::selfTest()
|
bool xmrig::OclWorker::selfTest()
|
||||||
{
|
{
|
||||||
return m_runner && m_runner->selfTest();
|
return m_runner != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -136,7 +160,9 @@ void xmrig::OclWorker::start()
|
||||||
m_interleave->resumeDelay(m_id);
|
m_interleave->resumeDelay(m_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
consumeJob();
|
if (!consumeJob()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!Nonce::isOutdated(Nonce::OPENCL, m_job.sequence())) {
|
while (!Nonce::isOutdated(Nonce::OPENCL, m_job.sequence())) {
|
||||||
|
@ -146,7 +172,12 @@ void xmrig::OclWorker::start()
|
||||||
|
|
||||||
const uint64_t t = Chrono::steadyMSecs();
|
const uint64_t t = Chrono::steadyMSecs();
|
||||||
|
|
||||||
if (!m_runner->run(*m_job.nonce(), results)) {
|
try {
|
||||||
|
m_runner->run(*m_job.nonce(), results);
|
||||||
|
}
|
||||||
|
catch (std::exception &ex) {
|
||||||
|
printError(id(), ex.what());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,20 +191,32 @@ void xmrig::OclWorker::start()
|
||||||
std::this_thread::yield();
|
std::this_thread::yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
consumeJob();
|
if (!consumeJob()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::OclWorker::consumeJob()
|
bool xmrig::OclWorker::consumeJob()
|
||||||
{
|
{
|
||||||
if (Nonce::sequence(Nonce::OPENCL) == 0) {
|
if (Nonce::sequence(Nonce::OPENCL) == 0) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_job.add(m_miner->job(), Nonce::sequence(Nonce::OPENCL), roundSize(m_intensity) * m_intensity);
|
m_job.add(m_miner->job(), Nonce::sequence(Nonce::OPENCL), roundSize(m_intensity) * m_intensity);
|
||||||
|
|
||||||
|
try {
|
||||||
m_runner->set(m_job.currentJob(), m_job.blob());
|
m_runner->set(m_job.currentJob(), m_job.blob());
|
||||||
}
|
}
|
||||||
|
catch (std::exception &ex) {
|
||||||
|
printError(id(), ex.what());
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::OclWorker::storeStats(uint64_t t)
|
void xmrig::OclWorker::storeStats(uint64_t t)
|
||||||
|
|
|
@ -59,7 +59,7 @@ protected:
|
||||||
void start() override;
|
void start() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void consumeJob();
|
bool consumeJob();
|
||||||
void storeStats(uint64_t ts);
|
void storeStats(uint64_t ts);
|
||||||
|
|
||||||
const Algorithm m_algorithm;
|
const Algorithm m_algorithm;
|
||||||
|
|
|
@ -26,10 +26,13 @@
|
||||||
#define XMRIG_IOCLRUNNER_H
|
#define XMRIG_IOCLRUNNER_H
|
||||||
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include "base/tools/Object.h"
|
||||||
|
|
||||||
|
|
||||||
typedef struct _cl_context *cl_context;
|
#include <cstdint>
|
||||||
|
|
||||||
|
|
||||||
|
using cl_context = struct _cl_context *;
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
@ -43,10 +46,12 @@ class OclLaunchData;
|
||||||
class IOclRunner
|
class IOclRunner
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
XMRIG_DISABLE_COPY_MOVE(IOclRunner)
|
||||||
|
|
||||||
|
IOclRunner() = default;
|
||||||
virtual ~IOclRunner() = default;
|
virtual ~IOclRunner() = default;
|
||||||
|
|
||||||
virtual bool run(uint32_t nonce, uint32_t *hashOutput) = 0;
|
virtual bool run(uint32_t nonce, uint32_t *hashOutput) = 0;
|
||||||
virtual bool selfTest() const = 0;
|
|
||||||
virtual bool set(const Job &job, uint8_t *blob) = 0;
|
virtual bool set(const Job &job, uint8_t *blob) = 0;
|
||||||
virtual cl_context ctx() const = 0;
|
virtual cl_context ctx() const = 0;
|
||||||
virtual const Algorithm &algorithm() const = 0;
|
virtual const Algorithm &algorithm() const = 0;
|
||||||
|
@ -57,9 +62,7 @@ public:
|
||||||
virtual size_t threadId() const = 0;
|
virtual size_t threadId() const = 0;
|
||||||
virtual uint32_t deviceIndex() const = 0;
|
virtual uint32_t deviceIndex() const = 0;
|
||||||
virtual void build() = 0;
|
virtual void build() = 0;
|
||||||
|
virtual void init() = 0;
|
||||||
protected:
|
|
||||||
virtual bool isReadyToBuild() const = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,17 +27,18 @@
|
||||||
#include "backend/opencl/wrappers/OclLib.h"
|
#include "backend/opencl/wrappers/OclLib.h"
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::Cn00RyoKernel::enqueue(cl_command_queue queue, size_t threads)
|
void xmrig::Cn00RyoKernel::enqueue(cl_command_queue queue, size_t threads)
|
||||||
{
|
{
|
||||||
const size_t gthreads = threads * 64;
|
const size_t gthreads = threads * 64;
|
||||||
const size_t lthreads = 64;
|
const size_t lthreads = 64;
|
||||||
|
|
||||||
return enqueueNDRange(queue, 1, nullptr, >hreads, <hreads);
|
enqueueNDRange(queue, 1, nullptr, >hreads, <hreads);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// __kernel void cn00(__global int *Scratchpad, __global ulong *states)
|
// __kernel void cn00(__global int *Scratchpad, __global ulong *states)
|
||||||
bool xmrig::Cn00RyoKernel::setArgs(cl_mem scratchpads, cl_mem states)
|
void xmrig::Cn00RyoKernel::setArgs(cl_mem scratchpads, cl_mem states)
|
||||||
{
|
{
|
||||||
return setArg(0, sizeof(cl_mem), &scratchpads) && setArg(1, sizeof(cl_mem), &states);
|
setArg(0, sizeof(cl_mem), &scratchpads);
|
||||||
|
setArg(1, sizeof(cl_mem), &states);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,8 @@ class Cn00RyoKernel : public OclKernel
|
||||||
public:
|
public:
|
||||||
inline Cn00RyoKernel(cl_program program) : OclKernel(program, "cn00") {}
|
inline Cn00RyoKernel(cl_program program) : OclKernel(program, "cn00") {}
|
||||||
|
|
||||||
bool enqueue(cl_command_queue queue, size_t threads);
|
void enqueue(cl_command_queue queue, size_t threads);
|
||||||
bool setArgs(cl_mem scratchpads, cl_mem states);
|
void setArgs(cl_mem scratchpads, cl_mem states);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,21 +27,21 @@
|
||||||
#include "backend/opencl/wrappers/OclLib.h"
|
#include "backend/opencl/wrappers/OclLib.h"
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::Cn0Kernel::enqueue(cl_command_queue queue, uint32_t nonce, size_t threads)
|
void xmrig::Cn0Kernel::enqueue(cl_command_queue queue, uint32_t nonce, size_t threads)
|
||||||
{
|
{
|
||||||
const size_t offset[2] = { nonce, 1 };
|
const size_t offset[2] = { nonce, 1 };
|
||||||
const size_t gthreads[2] = { threads, 8 };
|
const size_t gthreads[2] = { threads, 8 };
|
||||||
static const size_t lthreads[2] = { 8, 8 };
|
static const size_t lthreads[2] = { 8, 8 };
|
||||||
|
|
||||||
return enqueueNDRange(queue, 2, offset, gthreads, lthreads);
|
enqueueNDRange(queue, 2, offset, gthreads, lthreads);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// __kernel void cn0(__global ulong *input, __global uint4 *Scratchpad, __global ulong *states, uint Threads)
|
// __kernel void cn0(__global ulong *input, __global uint4 *Scratchpad, __global ulong *states, uint Threads)
|
||||||
bool xmrig::Cn0Kernel::setArgs(cl_mem input, cl_mem scratchpads, cl_mem states, uint32_t threads)
|
void xmrig::Cn0Kernel::setArgs(cl_mem input, cl_mem scratchpads, cl_mem states, uint32_t threads)
|
||||||
{
|
{
|
||||||
return setArg(0, sizeof(cl_mem), &input) &&
|
setArg(0, sizeof(cl_mem), &input);
|
||||||
setArg(1, sizeof(cl_mem), &scratchpads) &&
|
setArg(1, sizeof(cl_mem), &scratchpads);
|
||||||
setArg(2, sizeof(cl_mem), &states) &&
|
setArg(2, sizeof(cl_mem), &states);
|
||||||
setArg(3, sizeof(uint32_t), &threads);
|
setArg(3, sizeof(uint32_t), &threads);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,8 @@ class Cn0Kernel : public OclKernel
|
||||||
public:
|
public:
|
||||||
inline Cn0Kernel(cl_program program) : OclKernel(program, "cn0") {}
|
inline Cn0Kernel(cl_program program) : OclKernel(program, "cn0") {}
|
||||||
|
|
||||||
bool enqueue(cl_command_queue queue, uint32_t nonce, size_t threads);
|
void enqueue(cl_command_queue queue, uint32_t nonce, size_t threads);
|
||||||
bool setArgs(cl_mem input, cl_mem scratchpads, cl_mem states, uint32_t threads);
|
void setArgs(cl_mem input, cl_mem scratchpads, cl_mem states, uint32_t threads);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,21 +43,21 @@ xmrig::Cn1Kernel::Cn1Kernel(cl_program program, uint64_t height)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::Cn1Kernel::enqueue(cl_command_queue queue, uint32_t nonce, size_t threads, size_t worksize)
|
void xmrig::Cn1Kernel::enqueue(cl_command_queue queue, uint32_t nonce, size_t threads, size_t worksize)
|
||||||
{
|
{
|
||||||
const size_t offset = nonce;
|
const size_t offset = nonce;
|
||||||
const size_t gthreads = threads;
|
const size_t gthreads = threads;
|
||||||
const size_t lthreads = worksize;
|
const size_t lthreads = worksize;
|
||||||
|
|
||||||
return enqueueNDRange(queue, 1, &offset, >hreads, <hreads);
|
enqueueNDRange(queue, 1, &offset, >hreads, <hreads);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// __kernel void cn1(__global ulong *input, __global uint4 *Scratchpad, __global ulong *states, uint Threads)
|
// __kernel void cn1(__global ulong *input, __global uint4 *Scratchpad, __global ulong *states, uint Threads)
|
||||||
bool xmrig::Cn1Kernel::setArgs(cl_mem input, cl_mem scratchpads, cl_mem states, uint32_t threads)
|
void xmrig::Cn1Kernel::setArgs(cl_mem input, cl_mem scratchpads, cl_mem states, uint32_t threads)
|
||||||
{
|
{
|
||||||
return setArg(0, sizeof(cl_mem), &input) &&
|
setArg(0, sizeof(cl_mem), &input);
|
||||||
setArg(1, sizeof(cl_mem), &scratchpads) &&
|
setArg(1, sizeof(cl_mem), &scratchpads);
|
||||||
setArg(2, sizeof(cl_mem), &states) &&
|
setArg(2, sizeof(cl_mem), &states);
|
||||||
setArg(3, sizeof(uint32_t), &threads);
|
setArg(3, sizeof(uint32_t), &threads);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,8 +38,8 @@ public:
|
||||||
Cn1Kernel(cl_program program);
|
Cn1Kernel(cl_program program);
|
||||||
Cn1Kernel(cl_program program, uint64_t height);
|
Cn1Kernel(cl_program program, uint64_t height);
|
||||||
|
|
||||||
bool enqueue(cl_command_queue queue, uint32_t nonce, size_t threads, size_t worksize);
|
void enqueue(cl_command_queue queue, uint32_t nonce, size_t threads, size_t worksize);
|
||||||
bool setArgs(cl_mem input, cl_mem scratchpads, cl_mem states, uint32_t threads);
|
void setArgs(cl_mem input, cl_mem scratchpads, cl_mem states, uint32_t threads);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,19 +30,19 @@
|
||||||
#include "backend/opencl/wrappers/OclLib.h"
|
#include "backend/opencl/wrappers/OclLib.h"
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::Cn1RyoKernel::enqueue(cl_command_queue queue, size_t threads, size_t worksize)
|
void xmrig::Cn1RyoKernel::enqueue(cl_command_queue queue, size_t threads, size_t worksize)
|
||||||
{
|
{
|
||||||
const size_t gthreads = threads * 16;
|
const size_t gthreads = threads * 16;
|
||||||
const size_t lthreads = worksize * 16;
|
const size_t lthreads = worksize * 16;
|
||||||
|
|
||||||
return enqueueNDRange(queue, 1, nullptr, >hreads, <hreads);
|
enqueueNDRange(queue, 1, nullptr, >hreads, <hreads);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// __kernel void cn1(__global int *lpad_in, __global int *spad, uint numThreads)
|
// __kernel void cn1(__global int *lpad_in, __global int *spad, uint numThreads)
|
||||||
bool xmrig::Cn1RyoKernel::setArgs(cl_mem scratchpads, cl_mem states, uint32_t threads)
|
void xmrig::Cn1RyoKernel::setArgs(cl_mem scratchpads, cl_mem states, uint32_t threads)
|
||||||
{
|
{
|
||||||
return setArg(0, sizeof(cl_mem), &scratchpads) &&
|
setArg(0, sizeof(cl_mem), &scratchpads);
|
||||||
setArg(1, sizeof(cl_mem), &states) &&
|
setArg(1, sizeof(cl_mem), &states);
|
||||||
setArg(2, sizeof(uint32_t), &threads);
|
setArg(2, sizeof(uint32_t), &threads);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,8 @@ class Cn1RyoKernel : public OclKernel
|
||||||
public:
|
public:
|
||||||
inline Cn1RyoKernel(cl_program program) : OclKernel(program, "cn1") {}
|
inline Cn1RyoKernel(cl_program program) : OclKernel(program, "cn1") {}
|
||||||
|
|
||||||
bool enqueue(cl_command_queue queue, size_t threads, size_t worksize);
|
void enqueue(cl_command_queue queue, size_t threads, size_t worksize);
|
||||||
bool setArgs(cl_mem scratchpads, cl_mem states, uint32_t threads);
|
void setArgs(cl_mem scratchpads, cl_mem states, uint32_t threads);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,28 +27,24 @@
|
||||||
#include "backend/opencl/wrappers/OclLib.h"
|
#include "backend/opencl/wrappers/OclLib.h"
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::Cn2Kernel::enqueue(cl_command_queue queue, uint32_t nonce, size_t threads)
|
void xmrig::Cn2Kernel::enqueue(cl_command_queue queue, uint32_t nonce, size_t threads)
|
||||||
{
|
{
|
||||||
const size_t offset[2] = { nonce, 1 };
|
const size_t offset[2] = { nonce, 1 };
|
||||||
const size_t gthreads[2] = { threads, 8 };
|
const size_t gthreads[2] = { threads, 8 };
|
||||||
static const size_t lthreads[2] = { 8, 8 };
|
static const size_t lthreads[2] = { 8, 8 };
|
||||||
|
|
||||||
return enqueueNDRange(queue, 2, offset, gthreads, lthreads);
|
enqueueNDRange(queue, 2, offset, gthreads, lthreads);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// __kernel void cn2(__global uint4 *Scratchpad, __global ulong *states, __global uint *Branch0, __global uint *Branch1, __global uint *Branch2, __global uint *Branch3, uint Threads)
|
// __kernel void cn2(__global uint4 *Scratchpad, __global ulong *states, __global uint *Branch0, __global uint *Branch1, __global uint *Branch2, __global uint *Branch3, uint Threads)
|
||||||
bool xmrig::Cn2Kernel::setArgs(cl_mem scratchpads, cl_mem states, const std::vector<cl_mem> &branches, uint32_t threads)
|
void xmrig::Cn2Kernel::setArgs(cl_mem scratchpads, cl_mem states, const std::vector<cl_mem> &branches, uint32_t threads)
|
||||||
{
|
{
|
||||||
if (!setArg(0, sizeof(cl_mem), &scratchpads) || !setArg(1, sizeof(cl_mem), &states) || !setArg(6, sizeof(uint32_t), &threads)) {
|
setArg(0, sizeof(cl_mem), &scratchpads);
|
||||||
return false;
|
setArg(1, sizeof(cl_mem), &states);
|
||||||
}
|
setArg(6, sizeof(uint32_t), &threads);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < branches.size(); ++i) {
|
for (uint32_t i = 0; i < branches.size(); ++i) {
|
||||||
if (!setArg(i + 2, sizeof(cl_mem), &branches[i])) {
|
setArg(i + 2, sizeof(cl_mem), &branches[i]);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
|
@ -37,8 +37,8 @@ class Cn2Kernel : public OclKernel
|
||||||
public:
|
public:
|
||||||
inline Cn2Kernel(cl_program program) : OclKernel(program, "cn2") {}
|
inline Cn2Kernel(cl_program program) : OclKernel(program, "cn2") {}
|
||||||
|
|
||||||
bool enqueue(cl_command_queue queue, uint32_t nonce, size_t threads);
|
void enqueue(cl_command_queue queue, uint32_t nonce, size_t threads);
|
||||||
bool setArgs(cl_mem scratchpads, cl_mem states, const std::vector<cl_mem> &branches, uint32_t threads);
|
void setArgs(cl_mem scratchpads, cl_mem states, const std::vector<cl_mem> &branches, uint32_t threads);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,22 +27,27 @@
|
||||||
#include "backend/opencl/wrappers/OclLib.h"
|
#include "backend/opencl/wrappers/OclLib.h"
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::Cn2RyoKernel::enqueue(cl_command_queue queue, uint32_t nonce, size_t threads)
|
void xmrig::Cn2RyoKernel::enqueue(cl_command_queue queue, uint32_t nonce, size_t threads)
|
||||||
{
|
{
|
||||||
const size_t offset[2] = { nonce, 1 };
|
const size_t offset[2] = { nonce, 1 };
|
||||||
const size_t gthreads[2] = { threads, 8 };
|
const size_t gthreads[2] = { threads, 8 };
|
||||||
static const size_t lthreads[2] = { 8, 8 };
|
static const size_t lthreads[2] = { 8, 8 };
|
||||||
|
|
||||||
return enqueueNDRange(queue, 2, offset, gthreads, lthreads);
|
enqueueNDRange(queue, 2, offset, gthreads, lthreads);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// __kernel void cn2(__global uint4 *Scratchpad, __global ulong *states, __global uint *output, ulong Target, uint Threads)
|
// __kernel void cn2(__global uint4 *Scratchpad, __global ulong *states, __global uint *output, ulong Target, uint Threads)
|
||||||
bool xmrig::Cn2RyoKernel::setArgs(cl_mem scratchpads, cl_mem states, cl_mem output, uint64_t target, uint32_t threads)
|
void xmrig::Cn2RyoKernel::setArgs(cl_mem scratchpads, cl_mem states, cl_mem output, uint32_t threads)
|
||||||
{
|
{
|
||||||
return setArg(0, sizeof(cl_mem), &scratchpads) &&
|
setArg(0, sizeof(cl_mem), &scratchpads);
|
||||||
setArg(1, sizeof(cl_mem), &states) &&
|
setArg(1, sizeof(cl_mem), &states);
|
||||||
setArg(2, sizeof(cl_mem), &output) &&
|
setArg(2, sizeof(cl_mem), &output);
|
||||||
setArg(3, sizeof(cl_ulong), &target) &&
|
|
||||||
setArg(4, sizeof(uint32_t), &threads);
|
setArg(4, sizeof(uint32_t), &threads);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::Cn2RyoKernel::setTarget(uint64_t target)
|
||||||
|
{
|
||||||
|
setArg(3, sizeof(cl_ulong), &target);
|
||||||
|
}
|
||||||
|
|
|
@ -37,8 +37,9 @@ class Cn2RyoKernel : public OclKernel
|
||||||
public:
|
public:
|
||||||
inline Cn2RyoKernel(cl_program program) : OclKernel(program, "cn2") {}
|
inline Cn2RyoKernel(cl_program program) : OclKernel(program, "cn2") {}
|
||||||
|
|
||||||
bool enqueue(cl_command_queue queue, uint32_t nonce, size_t threads);
|
void enqueue(cl_command_queue queue, uint32_t nonce, size_t threads);
|
||||||
bool setArgs(cl_mem scratchpads, cl_mem states, cl_mem output, uint64_t target, uint32_t threads);
|
void setArgs(cl_mem scratchpads, cl_mem states, cl_mem output, uint32_t threads);
|
||||||
|
void setTarget(uint64_t target);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,22 +41,27 @@ xmrig::CnBranchKernel::CnBranchKernel(size_t index, cl_program program) : OclKer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::CnBranchKernel::enqueue(cl_command_queue queue, uint32_t nonce, size_t threads, size_t worksize)
|
void xmrig::CnBranchKernel::enqueue(cl_command_queue queue, uint32_t nonce, size_t threads, size_t worksize)
|
||||||
{
|
{
|
||||||
const size_t offset = nonce;
|
const size_t offset = nonce;
|
||||||
const size_t gthreads = threads;
|
const size_t gthreads = threads;
|
||||||
const size_t lthreads = worksize;
|
const size_t lthreads = worksize;
|
||||||
|
|
||||||
return enqueueNDRange(queue, 1, &offset, >hreads, <hreads);
|
enqueueNDRange(queue, 1, &offset, >hreads, <hreads);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// __kernel void Skein(__global ulong *states, __global uint *BranchBuf, __global uint *output, ulong Target, uint Threads)
|
// __kernel void Skein(__global ulong *states, __global uint *BranchBuf, __global uint *output, ulong Target, uint Threads)
|
||||||
bool xmrig::CnBranchKernel::setArgs(cl_mem states, cl_mem branch, cl_mem output, uint64_t target, uint32_t threads)
|
void xmrig::CnBranchKernel::setArgs(cl_mem states, cl_mem branch, cl_mem output, uint32_t threads)
|
||||||
{
|
{
|
||||||
return setArg(0, sizeof(cl_mem), &states) &&
|
setArg(0, sizeof(cl_mem), &states);
|
||||||
setArg(1, sizeof(cl_mem), &branch) &&
|
setArg(1, sizeof(cl_mem), &branch);
|
||||||
setArg(2, sizeof(cl_mem), &output) &&
|
setArg(2, sizeof(cl_mem), &output);
|
||||||
setArg(3, sizeof(cl_ulong), &target) &&
|
|
||||||
setArg(4, sizeof(cl_uint), &threads);
|
setArg(4, sizeof(cl_uint), &threads);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::CnBranchKernel::setTarget(uint64_t target)
|
||||||
|
{
|
||||||
|
setArg(3, sizeof(cl_ulong), &target);
|
||||||
|
}
|
||||||
|
|
|
@ -36,8 +36,9 @@ class CnBranchKernel : public OclKernel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CnBranchKernel(size_t index, cl_program program);
|
CnBranchKernel(size_t index, cl_program program);
|
||||||
bool enqueue(cl_command_queue queue, uint32_t nonce, size_t threads, size_t worksize);
|
void enqueue(cl_command_queue queue, uint32_t nonce, size_t threads, size_t worksize);
|
||||||
bool setArgs(cl_mem states, cl_mem branch, cl_mem output, uint64_t target, uint32_t threads);
|
void setArgs(cl_mem states, cl_mem branch, cl_mem output, uint32_t threads);
|
||||||
|
void setTarget(uint64_t target);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
37
src/backend/opencl/kernels/rx/Blake2bHashRegistersKernel.cpp
Normal file
37
src/backend/opencl/kernels/rx/Blake2bHashRegistersKernel.cpp
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "backend/opencl/kernels/rx/Blake2bHashRegistersKernel.h"
|
||||||
|
#include "backend/opencl/wrappers/OclLib.h"
|
||||||
|
|
||||||
|
|
||||||
|
// __kernel void blake2b_hash_registers_32(__global void *out, __global const void* in, uint inStrideBytes)
|
||||||
|
// __kernel void blake2b_hash_registers_64(__global void *out, __global const void* in, uint inStrideBytes)
|
||||||
|
void xmrig::Blake2bHashRegistersKernel::setArgs(cl_mem out, cl_mem in, uint32_t inStrideBytes)
|
||||||
|
{
|
||||||
|
setArg(0, sizeof(cl_mem), &out);
|
||||||
|
setArg(1, sizeof(cl_mem), &in);
|
||||||
|
setArg(2, sizeof(uint32_t), &inStrideBytes);
|
||||||
|
}
|
47
src/backend/opencl/kernels/rx/Blake2bHashRegistersKernel.h
Normal file
47
src/backend/opencl/kernels/rx/Blake2bHashRegistersKernel.h
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XMRIG_BLAKE2BHASHREGISTERSKERNEL_H
|
||||||
|
#define XMRIG_BLAKE2BHASHREGISTERSKERNEL_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "backend/opencl/wrappers/OclKernel.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
class Blake2bHashRegistersKernel : public OclKernel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
inline Blake2bHashRegistersKernel(cl_program program, const char *name) : OclKernel(program, name) {}
|
||||||
|
|
||||||
|
void setArgs(cl_mem out, cl_mem in, uint32_t inStrideBytes);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace xmrig
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* XMRIG_BLAKE2BHASHREGISTERSKERNEL_H */
|
35
src/backend/opencl/kernels/rx/Blake2bInitialHashKernel.cpp
Normal file
35
src/backend/opencl/kernels/rx/Blake2bInitialHashKernel.cpp
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "backend/opencl/kernels/rx/Blake2bInitialHashKernel.h"
|
||||||
|
#include "backend/opencl/wrappers/OclLib.h"
|
||||||
|
|
||||||
|
|
||||||
|
// __kernel void blake2b_initial_hash(__global void *out, __global const void* blockTemplate, uint blockTemplateSize, uint start_nonce)
|
||||||
|
void xmrig::Blake2bInitialHashKernel::setArgs(cl_mem out, cl_mem blockTemplate)
|
||||||
|
{
|
||||||
|
setArg(0, sizeof(cl_mem), &out);
|
||||||
|
setArg(1, sizeof(cl_mem), &blockTemplate);
|
||||||
|
}
|
47
src/backend/opencl/kernels/rx/Blake2bInitialHashKernel.h
Normal file
47
src/backend/opencl/kernels/rx/Blake2bInitialHashKernel.h
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XMRIG_BLAKE2BINITIALHASHKERNEL_H
|
||||||
|
#define XMRIG_BLAKE2BINITIALHASHKERNEL_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "backend/opencl/wrappers/OclKernel.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
class Blake2bInitialHashKernel : public OclKernel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
inline Blake2bInitialHashKernel(cl_program program) : OclKernel(program, "blake2b_initial_hash") {}
|
||||||
|
|
||||||
|
void setArgs(cl_mem out, cl_mem blockTemplate);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace xmrig
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* XMRIG_BLAKE2BINITIALHASHKERNEL_H */
|
38
src/backend/opencl/kernels/rx/ExecuteVmKernel.cpp
Normal file
38
src/backend/opencl/kernels/rx/ExecuteVmKernel.cpp
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "backend/opencl/kernels/rx/ExecuteVmKernel.h"
|
||||||
|
#include "backend/opencl/wrappers/OclLib.h"
|
||||||
|
|
||||||
|
|
||||||
|
// __kernel void execute_vm(__global void* vm_states, __global void* rounding, __global void* scratchpads, __global const void* dataset_ptr, uint32_t batch_size, uint32_t num_iterations, uint32_t first, uint32_t last)
|
||||||
|
void xmrig::ExecuteVmKernel::setArgs(cl_mem vm_states, cl_mem rounding, cl_mem scratchpads, cl_mem dataset_ptr, uint32_t batch_size)
|
||||||
|
{
|
||||||
|
setArg(0, sizeof(cl_mem), &vm_states);
|
||||||
|
setArg(1, sizeof(cl_mem), &rounding);
|
||||||
|
setArg(2, sizeof(cl_mem), &scratchpads);
|
||||||
|
setArg(3, sizeof(cl_mem), &dataset_ptr);
|
||||||
|
setArg(4, sizeof(uint32_t), &batch_size);
|
||||||
|
}
|
47
src/backend/opencl/kernels/rx/ExecuteVmKernel.h
Normal file
47
src/backend/opencl/kernels/rx/ExecuteVmKernel.h
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XMRIG_EXECUTEVMKERNEL_H
|
||||||
|
#define XMRIG_EXECUTEVMKERNEL_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "backend/opencl/wrappers/OclKernel.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
class ExecuteVmKernel : public OclKernel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
inline ExecuteVmKernel(cl_program program) : OclKernel(program, "execute_vm") {}
|
||||||
|
|
||||||
|
void setArgs(cl_mem vm_states, cl_mem rounding, cl_mem scratchpads, cl_mem dataset_ptr, uint32_t batch_size);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace xmrig
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* XMRIG_EXECUTEVMKERNEL_H */
|
38
src/backend/opencl/kernels/rx/FillAesKernel.cpp
Normal file
38
src/backend/opencl/kernels/rx/FillAesKernel.cpp
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "backend/opencl/kernels/rx/FillAesKernel.h"
|
||||||
|
#include "backend/opencl/wrappers/OclLib.h"
|
||||||
|
|
||||||
|
|
||||||
|
// __kernel void fillAes1Rx4_scratchpad(__global void* state, __global void* out, uint batch_size, uint rx_version)
|
||||||
|
// __kernel void fillAes4Rx4_entropy(__global void* state, __global void* out, uint batch_size, uint rx_version)
|
||||||
|
void xmrig::FillAesKernel::setArgs(cl_mem state, cl_mem out, uint32_t batch_size, uint32_t rx_version)
|
||||||
|
{
|
||||||
|
setArg(0, sizeof(cl_mem), &state);
|
||||||
|
setArg(1, sizeof(cl_mem), &out);
|
||||||
|
setArg(2, sizeof(uint32_t), &batch_size);
|
||||||
|
setArg(3, sizeof(uint32_t), &rx_version);
|
||||||
|
}
|
47
src/backend/opencl/kernels/rx/FillAesKernel.h
Normal file
47
src/backend/opencl/kernels/rx/FillAesKernel.h
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XMRIG_FILLAESKERNEL_H
|
||||||
|
#define XMRIG_FILLAESKERNEL_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "backend/opencl/wrappers/OclKernel.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
class FillAesKernel : public OclKernel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
inline FillAesKernel(cl_program program, const char *name) : OclKernel(program, name) {}
|
||||||
|
|
||||||
|
void setArgs(cl_mem state, cl_mem out, uint32_t batch_size, uint32_t rx_version);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace xmrig
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* XMRIG_FILLAESKERNEL_H */
|
35
src/backend/opencl/kernels/rx/FindSharesKernel.cpp
Normal file
35
src/backend/opencl/kernels/rx/FindSharesKernel.cpp
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "backend/opencl/kernels/rx/FindSharesKernel.h"
|
||||||
|
#include "backend/opencl/wrappers/OclLib.h"
|
||||||
|
|
||||||
|
|
||||||
|
// __kernel void find_shares(__global const uint64_t* hashes, uint64_t target, uint32_t start_nonce, __global uint32_t* shares)
|
||||||
|
void xmrig::FindSharesKernel::setArgs(cl_mem hashes, cl_mem shares)
|
||||||
|
{
|
||||||
|
setArg(0, sizeof(cl_mem), &hashes);
|
||||||
|
setArg(3, sizeof(cl_mem), &shares);
|
||||||
|
}
|
47
src/backend/opencl/kernels/rx/FindSharesKernel.h
Normal file
47
src/backend/opencl/kernels/rx/FindSharesKernel.h
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XMRIG_FINDSHARESKERNEL_H
|
||||||
|
#define XMRIG_FINDSHARESKERNEL_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "backend/opencl/wrappers/OclKernel.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
class FindSharesKernel : public OclKernel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
inline FindSharesKernel(cl_program program) : OclKernel(program, "find_shares") {}
|
||||||
|
|
||||||
|
void setArgs(cl_mem hashes, cl_mem shares);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace xmrig
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* XMRIG_FINDSHARESKERNEL_H */
|
40
src/backend/opencl/kernels/rx/HashAesKernel.cpp
Normal file
40
src/backend/opencl/kernels/rx/HashAesKernel.cpp
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "backend/opencl/kernels/rx/HashAesKernel.h"
|
||||||
|
#include "backend/opencl/wrappers/OclLib.h"
|
||||||
|
|
||||||
|
|
||||||
|
// __kernel void hashAes1Rx4(__global const void* input, __global void* hash, uint hashOffsetBytes, uint hashStrideBytes, uint batch_size)
|
||||||
|
void xmrig::HashAesKernel::setArgs(cl_mem input, cl_mem hash, uint32_t hashStrideBytes, uint32_t batch_size)
|
||||||
|
{
|
||||||
|
const uint32_t hashOffsetBytes = 192;
|
||||||
|
|
||||||
|
setArg(0, sizeof(cl_mem), &input);
|
||||||
|
setArg(1, sizeof(cl_mem), &hash);
|
||||||
|
setArg(2, sizeof(uint32_t), &hashOffsetBytes);
|
||||||
|
setArg(3, sizeof(uint32_t), &hashStrideBytes);
|
||||||
|
setArg(4, sizeof(uint32_t), &batch_size);
|
||||||
|
}
|
47
src/backend/opencl/kernels/rx/HashAesKernel.h
Normal file
47
src/backend/opencl/kernels/rx/HashAesKernel.h
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XMRIG_HASHAESKERNEL_H
|
||||||
|
#define XMRIG_HASHAESKERNEL_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "backend/opencl/wrappers/OclKernel.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
class HashAesKernel : public OclKernel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
inline HashAesKernel(cl_program program) : OclKernel(program, "hashAes1Rx4") {}
|
||||||
|
|
||||||
|
void setArgs(cl_mem input, cl_mem hash, uint32_t hashStrideBytes, uint32_t batch_size);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace xmrig
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* XMRIG_HASHAESKERNEL_H */
|
36
src/backend/opencl/kernels/rx/InitVmKernel.cpp
Normal file
36
src/backend/opencl/kernels/rx/InitVmKernel.cpp
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "backend/opencl/kernels/rx/InitVmKernel.h"
|
||||||
|
#include "backend/opencl/wrappers/OclLib.h"
|
||||||
|
|
||||||
|
|
||||||
|
// __kernel void init_vm(__global const void* entropy_data, __global void* vm_states, __global uint32_t* rounding, uint32_t iteration)
|
||||||
|
void xmrig::InitVmKernel::setArgs(cl_mem entropy_data, cl_mem vm_states, cl_mem rounding)
|
||||||
|
{
|
||||||
|
setArg(0, sizeof(cl_mem), &entropy_data);
|
||||||
|
setArg(1, sizeof(cl_mem), &vm_states);
|
||||||
|
setArg(2, sizeof(cl_mem), &rounding);
|
||||||
|
}
|
47
src/backend/opencl/kernels/rx/InitVmKernel.h
Normal file
47
src/backend/opencl/kernels/rx/InitVmKernel.h
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XMRIG_INITVMKERNEL_H
|
||||||
|
#define XMRIG_INITVMKERNEL_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "backend/opencl/wrappers/OclKernel.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
class InitVmKernel : public OclKernel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
inline InitVmKernel(cl_program program) : OclKernel(program, "init_vm") {}
|
||||||
|
|
||||||
|
void setArgs(cl_mem entropy_data, cl_mem vm_states, cl_mem rounding);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace xmrig
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* XMRIG_INITVMKERNEL_H */
|
|
@ -65,8 +65,33 @@ if (WITH_OPENCL)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (WITH_RANDOMX)
|
if (WITH_RANDOMX)
|
||||||
list(APPEND HEADERS_BACKEND_OPENCL src/backend/opencl/runners/OclRxRunner.h)
|
list(APPEND HEADERS_BACKEND_OPENCL
|
||||||
list(APPEND SOURCES_BACKEND_OPENCL src/backend/opencl/runners/OclRxRunner.cpp)
|
src/backend/opencl/kernels/rx/Blake2bHashRegistersKernel.h
|
||||||
|
src/backend/opencl/kernels/rx/Blake2bInitialHashKernel.h
|
||||||
|
src/backend/opencl/kernels/rx/ExecuteVmKernel.h
|
||||||
|
src/backend/opencl/kernels/rx/FillAesKernel.h
|
||||||
|
src/backend/opencl/kernels/rx/FindSharesKernel.h
|
||||||
|
src/backend/opencl/kernels/rx/HashAesKernel.cpp
|
||||||
|
src/backend/opencl/kernels/rx/InitVmKernel.h
|
||||||
|
src/backend/opencl/runners/OclRxBaseRunner.h
|
||||||
|
src/backend/opencl/runners/OclRxJitRunner.h
|
||||||
|
src/backend/opencl/runners/OclRxVmRunner.h
|
||||||
|
src/backend/opencl/runners/tools/OclRxDataset.h
|
||||||
|
)
|
||||||
|
|
||||||
|
list(APPEND SOURCES_BACKEND_OPENCL
|
||||||
|
src/backend/opencl/kernels/rx/Blake2bHashRegistersKernel.cpp
|
||||||
|
src/backend/opencl/kernels/rx/Blake2bInitialHashKernel.cpp
|
||||||
|
src/backend/opencl/kernels/rx/ExecuteVmKernel.cpp
|
||||||
|
src/backend/opencl/kernels/rx/FillAesKernel.cpp
|
||||||
|
src/backend/opencl/kernels/rx/FindSharesKernel.cpp
|
||||||
|
src/backend/opencl/kernels/rx/HashAesKernel.cpp
|
||||||
|
src/backend/opencl/kernels/rx/InitVmKernel.cpp
|
||||||
|
src/backend/opencl/runners/OclRxBaseRunner.cpp
|
||||||
|
src/backend/opencl/runners/OclRxJitRunner.cpp
|
||||||
|
src/backend/opencl/runners/OclRxVmRunner.cpp
|
||||||
|
src/backend/opencl/runners/tools/OclRxDataset.cpp
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (WITH_CN_GPU AND CMAKE_SIZEOF_VOID_P EQUAL 8)
|
if (WITH_CN_GPU AND CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "backend/opencl/wrappers/OclLib.h"
|
#include "backend/opencl/wrappers/OclLib.h"
|
||||||
#include "base/io/log/Log.h"
|
#include "base/io/log/Log.h"
|
||||||
#include "base/net/stratum/Job.h"
|
#include "base/net/stratum/Job.h"
|
||||||
|
#include "backend/opencl/wrappers/OclError.h"
|
||||||
|
|
||||||
|
|
||||||
xmrig::OclBaseRunner::OclBaseRunner(size_t id, const OclLaunchData &data) :
|
xmrig::OclBaseRunner::OclBaseRunner(size_t id, const OclLaunchData &data) :
|
||||||
|
@ -39,15 +40,6 @@ xmrig::OclBaseRunner::OclBaseRunner(size_t id, const OclLaunchData &data) :
|
||||||
m_data(data),
|
m_data(data),
|
||||||
m_threadId(id)
|
m_threadId(id)
|
||||||
{
|
{
|
||||||
cl_int ret;
|
|
||||||
m_queue = OclLib::createCommandQueue(m_ctx, data.device.id(), &ret);
|
|
||||||
if (ret != CL_SUCCESS) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_input = OclLib::createBuffer(m_ctx, CL_MEM_READ_ONLY, Job::kMaxBlobSize, nullptr, &ret);
|
|
||||||
m_output = OclLib::createBuffer(m_ctx, CL_MEM_READ_WRITE, sizeof(cl_uint) * 0x100, nullptr, &ret);
|
|
||||||
|
|
||||||
m_deviceKey = data.device.name();
|
m_deviceKey = data.device.name();
|
||||||
|
|
||||||
# ifdef XMRIG_STRICT_OPENCL_CACHE
|
# ifdef XMRIG_STRICT_OPENCL_CACHE
|
||||||
|
@ -73,18 +65,6 @@ xmrig::OclBaseRunner::~OclBaseRunner()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::OclBaseRunner::isReadyToBuild() const
|
|
||||||
{
|
|
||||||
return m_queue != nullptr && m_input != nullptr && m_output != nullptr && !m_options.empty() && m_source != nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::OclBaseRunner::selfTest() const
|
|
||||||
{
|
|
||||||
return isReadyToBuild() && m_program != nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint32_t xmrig::OclBaseRunner::deviceIndex() const
|
uint32_t xmrig::OclBaseRunner::deviceIndex() const
|
||||||
{
|
{
|
||||||
return data().thread.index();
|
return data().thread.index();
|
||||||
|
@ -93,9 +73,35 @@ uint32_t xmrig::OclBaseRunner::deviceIndex() const
|
||||||
|
|
||||||
void xmrig::OclBaseRunner::build()
|
void xmrig::OclBaseRunner::build()
|
||||||
{
|
{
|
||||||
if (!isReadyToBuild()) {
|
m_program = OclCache::build(this);
|
||||||
return;
|
|
||||||
|
if (m_program == nullptr) {
|
||||||
|
throw std::runtime_error(OclError::toString(CL_INVALID_PROGRAM));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_program = OclCache::build(this);
|
|
||||||
|
void xmrig::OclBaseRunner::init()
|
||||||
|
{
|
||||||
|
m_queue = OclLib::createCommandQueue(m_ctx, data().device.id());
|
||||||
|
m_input = OclLib::createBuffer(m_ctx, CL_MEM_READ_ONLY, Job::kMaxBlobSize);
|
||||||
|
m_output = OclLib::createBuffer(m_ctx, CL_MEM_READ_WRITE, sizeof(cl_uint) * 0x100);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::OclBaseRunner::enqueueReadBuffer(cl_mem buffer, cl_bool blocking_read, size_t offset, size_t size, void *ptr)
|
||||||
|
{
|
||||||
|
const cl_int ret = OclLib::enqueueReadBuffer(m_queue, buffer, blocking_read, offset, size, ptr, 0, nullptr, nullptr);
|
||||||
|
if (ret != CL_SUCCESS) {
|
||||||
|
throw std::runtime_error(OclError::toString(ret));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::OclBaseRunner::enqueueWriteBuffer(cl_mem buffer, cl_bool blocking_write, size_t offset, size_t size, const void *ptr)
|
||||||
|
{
|
||||||
|
const cl_int ret = OclLib::enqueueWriteBuffer(m_queue, buffer, blocking_write, offset, size, ptr, 0, nullptr, nullptr);
|
||||||
|
if (ret != CL_SUCCESS) {
|
||||||
|
throw std::runtime_error(OclError::toString(ret));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,16 +43,11 @@ class OclLaunchData;
|
||||||
class OclBaseRunner : public IOclRunner
|
class OclBaseRunner : public IOclRunner
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OclBaseRunner() = delete;
|
XMRIG_DISABLE_COPY_MOVE_DEFAULT(OclBaseRunner)
|
||||||
OclBaseRunner(const OclBaseRunner &other) = delete;
|
|
||||||
OclBaseRunner(OclBaseRunner &&other) = delete;
|
|
||||||
OclBaseRunner(size_t id, const OclLaunchData &data);
|
OclBaseRunner(size_t id, const OclLaunchData &data);
|
||||||
|
|
||||||
~OclBaseRunner() override;
|
~OclBaseRunner() override;
|
||||||
|
|
||||||
OclBaseRunner &operator=(const OclBaseRunner &other) = delete;
|
|
||||||
OclBaseRunner &operator=(OclBaseRunner &&other) = delete;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
inline cl_context ctx() const override { return m_ctx; }
|
inline cl_context ctx() const override { return m_ctx; }
|
||||||
inline const Algorithm &algorithm() const override { return m_algorithm; }
|
inline const Algorithm &algorithm() const override { return m_algorithm; }
|
||||||
|
@ -62,12 +57,14 @@ protected:
|
||||||
inline const OclLaunchData &data() const override { return m_data; }
|
inline const OclLaunchData &data() const override { return m_data; }
|
||||||
inline size_t threadId() const override { return m_threadId; }
|
inline size_t threadId() const override { return m_threadId; }
|
||||||
|
|
||||||
bool isReadyToBuild() const override;
|
|
||||||
bool selfTest() const override;
|
|
||||||
uint32_t deviceIndex() const override;
|
uint32_t deviceIndex() const override;
|
||||||
void build() override;
|
void build() override;
|
||||||
|
void init() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void enqueueReadBuffer(cl_mem buffer, cl_bool blocking_read, size_t offset, size_t size, void *ptr);
|
||||||
|
void enqueueWriteBuffer(cl_mem buffer, cl_bool blocking_write, size_t offset, size_t size, const void *ptr);
|
||||||
|
|
||||||
Algorithm m_algorithm;
|
Algorithm m_algorithm;
|
||||||
cl_command_queue m_queue = nullptr;
|
cl_command_queue m_queue = nullptr;
|
||||||
cl_context m_ctx;
|
cl_context m_ctx;
|
||||||
|
|
|
@ -39,30 +39,6 @@
|
||||||
|
|
||||||
xmrig::OclCnRunner::OclCnRunner(size_t index, const OclLaunchData &data) : OclBaseRunner(index, data)
|
xmrig::OclCnRunner::OclCnRunner(size_t index, const OclLaunchData &data) : OclBaseRunner(index, data)
|
||||||
{
|
{
|
||||||
if (m_queue == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const size_t g_thd = data.thread.intensity();
|
|
||||||
|
|
||||||
cl_int ret;
|
|
||||||
m_scratchpads = OclLib::createBuffer(m_ctx, CL_MEM_READ_WRITE, data.algorithm.l3() * g_thd, nullptr, &ret);
|
|
||||||
if (ret != CL_SUCCESS) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_states = OclLib::createBuffer(m_ctx, CL_MEM_READ_WRITE, 200 * g_thd, nullptr, &ret);
|
|
||||||
if (ret != CL_SUCCESS) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = 0; i < BRANCH_MAX; ++i) {
|
|
||||||
m_branches[i] = OclLib::createBuffer(m_ctx, CL_MEM_READ_WRITE, sizeof(cl_uint) * (g_thd + 2), nullptr, &ret);
|
|
||||||
if (ret != CL_SUCCESS) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t stridedIndex = data.thread.stridedIndex();
|
uint32_t stridedIndex = data.thread.stridedIndex();
|
||||||
if (data.device.vendorId() == OCL_VENDOR_NVIDIA) {
|
if (data.device.vendorId() == OCL_VENDOR_NVIDIA) {
|
||||||
stridedIndex = 0;
|
stridedIndex = 0;
|
||||||
|
@ -105,18 +81,6 @@ xmrig::OclCnRunner::~OclCnRunner()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::OclCnRunner::isReadyToBuild() const
|
|
||||||
{
|
|
||||||
return OclBaseRunner::isReadyToBuild() &&
|
|
||||||
m_scratchpads != nullptr &&
|
|
||||||
m_states != nullptr &&
|
|
||||||
m_branches[BRANCH_BLAKE_256] != nullptr &&
|
|
||||||
m_branches[BRANCH_GROESTL_256] != nullptr &&
|
|
||||||
m_branches[BRANCH_JH_256] != nullptr &&
|
|
||||||
m_branches[BRANCH_SKEIN_512] != nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::OclCnRunner::run(uint32_t nonce, uint32_t *hashOutput)
|
bool xmrig::OclCnRunner::run(uint32_t nonce, uint32_t *hashOutput)
|
||||||
{
|
{
|
||||||
static const cl_uint zero = 0;
|
static const cl_uint zero = 0;
|
||||||
|
@ -128,36 +92,20 @@ bool xmrig::OclCnRunner::run(uint32_t nonce, uint32_t *hashOutput)
|
||||||
assert(g_thd % w_size == 0);
|
assert(g_thd % w_size == 0);
|
||||||
|
|
||||||
for (size_t i = 0; i < BRANCH_MAX; ++i) {
|
for (size_t i = 0; i < BRANCH_MAX; ++i) {
|
||||||
if (OclLib::enqueueWriteBuffer(m_queue, m_branches[i], CL_FALSE, sizeof(cl_uint) * g_intensity, sizeof(cl_uint), &zero, 0, nullptr, nullptr) != CL_SUCCESS) {
|
enqueueWriteBuffer(m_branches[i], CL_FALSE, sizeof(cl_uint) * g_intensity, sizeof(cl_uint), &zero);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OclLib::enqueueWriteBuffer(m_queue, m_output, CL_FALSE, sizeof(cl_uint) * 0xFF, sizeof(cl_uint), &zero, 0, nullptr, nullptr) != CL_SUCCESS) {
|
enqueueWriteBuffer(m_output, CL_FALSE, sizeof(cl_uint) * 0xFF, sizeof(cl_uint), &zero);
|
||||||
return false;
|
|
||||||
|
m_cn0->enqueue(m_queue, nonce, g_thd);
|
||||||
|
m_cn1->enqueue(m_queue, nonce, g_thd, w_size);
|
||||||
|
m_cn2->enqueue(m_queue, nonce, g_thd);
|
||||||
|
|
||||||
|
for (auto kernel : m_branchKernels) {
|
||||||
|
kernel->enqueue(m_queue, nonce, g_thd, w_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_cn0->enqueue(m_queue, nonce, g_thd)) {
|
enqueueReadBuffer(m_output, CL_TRUE, 0, sizeof(cl_uint) * 0x100, hashOutput);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_cn1->enqueue(m_queue, nonce, g_thd, w_size)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_cn2->enqueue(m_queue, nonce, g_thd)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = 0; i < BRANCH_MAX; ++i) {
|
|
||||||
if (!m_branchKernels[i]->enqueue(m_queue, nonce, g_thd, w_size)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (OclLib::enqueueReadBuffer(m_queue, m_output, CL_TRUE, 0, sizeof(cl_uint) * 0x100, hashOutput, 0, nullptr, nullptr) != CL_SUCCESS) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t &results = hashOutput[0xFF];
|
uint32_t &results = hashOutput[0xFF];
|
||||||
if (results > 0xFF) {
|
if (results > 0xFF) {
|
||||||
|
@ -168,38 +116,16 @@ bool xmrig::OclCnRunner::run(uint32_t nonce, uint32_t *hashOutput)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::OclCnRunner::selfTest() const
|
|
||||||
{
|
|
||||||
if (OclBaseRunner::selfTest() && m_cn0->isValid() && m_cn2->isValid()) {
|
|
||||||
if (m_algorithm != Algorithm::CN_R) {
|
|
||||||
return m_cn1->isValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::OclCnRunner::set(const Job &job, uint8_t *blob)
|
bool xmrig::OclCnRunner::set(const Job &job, uint8_t *blob)
|
||||||
{
|
{
|
||||||
if (job.size() > (Job::kMaxBlobSize - 4)) {
|
if (job.size() > (Job::kMaxBlobSize - 4)) {
|
||||||
return false;
|
throw std::length_error("job size too big");
|
||||||
}
|
}
|
||||||
|
|
||||||
blob[job.size()] = 0x01;
|
blob[job.size()] = 0x01;
|
||||||
memset(blob + job.size() + 1, 0, Job::kMaxBlobSize - job.size() - 1);
|
memset(blob + job.size() + 1, 0, Job::kMaxBlobSize - job.size() - 1);
|
||||||
|
|
||||||
if (OclLib::enqueueWriteBuffer(m_queue, m_input, CL_TRUE, 0, Job::kMaxBlobSize, blob, 0, nullptr, nullptr) != CL_SUCCESS) {
|
enqueueWriteBuffer(m_input, CL_TRUE, 0, Job::kMaxBlobSize, blob);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const uint32_t intensity = data().thread.intensity();
|
|
||||||
|
|
||||||
if (!m_cn0->setArgs(m_input, m_scratchpads, m_states, intensity)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_algorithm == Algorithm::CN_R && m_height != job.height()) {
|
if (m_algorithm == Algorithm::CN_R && m_height != job.height()) {
|
||||||
delete m_cn1;
|
delete m_cn1;
|
||||||
|
@ -207,20 +133,11 @@ bool xmrig::OclCnRunner::set(const Job &job, uint8_t *blob)
|
||||||
m_height = job.height();
|
m_height = job.height();
|
||||||
m_cnr = OclCnR::get(*this, m_height);
|
m_cnr = OclCnR::get(*this, m_height);
|
||||||
m_cn1 = new Cn1Kernel(m_cnr, m_height);
|
m_cn1 = new Cn1Kernel(m_cnr, m_height);
|
||||||
|
m_cn1->setArgs(m_input, m_scratchpads, m_states, data().thread.intensity());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_cn1->setArgs(m_input, m_scratchpads, m_states, intensity)) {
|
for (auto kernel : m_branchKernels) {
|
||||||
return false;
|
kernel->setTarget(job.target());
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_cn2->setArgs(m_scratchpads, m_states, m_branches, intensity)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = 0; i < BRANCH_MAX; ++i) {
|
|
||||||
if (!m_branchKernels[i]->setArgs(m_states, m_branches[i], m_output, job.target(), intensity)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -231,18 +148,38 @@ void xmrig::OclCnRunner::build()
|
||||||
{
|
{
|
||||||
OclBaseRunner::build();
|
OclBaseRunner::build();
|
||||||
|
|
||||||
if (!m_program) {
|
const uint32_t intensity = data().thread.intensity();
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_cn0 = new Cn0Kernel(m_program);
|
m_cn0 = new Cn0Kernel(m_program);
|
||||||
|
m_cn0->setArgs(m_input, m_scratchpads, m_states, intensity);
|
||||||
|
|
||||||
m_cn2 = new Cn2Kernel(m_program);
|
m_cn2 = new Cn2Kernel(m_program);
|
||||||
|
m_cn2->setArgs(m_scratchpads, m_states, m_branches, intensity);
|
||||||
|
|
||||||
if (m_algorithm != Algorithm::CN_R) {
|
if (m_algorithm != Algorithm::CN_R) {
|
||||||
m_cn1 = new Cn1Kernel(m_program);
|
m_cn1 = new Cn1Kernel(m_program);
|
||||||
|
m_cn1->setArgs(m_input, m_scratchpads, m_states, intensity);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < BRANCH_MAX; ++i) {
|
for (size_t i = 0; i < BRANCH_MAX; ++i) {
|
||||||
m_branchKernels[i] = new CnBranchKernel(i, m_program);
|
auto kernel = new CnBranchKernel(i, m_program);
|
||||||
|
kernel->setArgs(m_states, m_branches[i], m_output, intensity);
|
||||||
|
|
||||||
|
m_branchKernels[i] = kernel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::OclCnRunner::init()
|
||||||
|
{
|
||||||
|
OclBaseRunner::init();
|
||||||
|
|
||||||
|
const size_t g_thd = data().thread.intensity();
|
||||||
|
|
||||||
|
m_scratchpads = OclLib::createBuffer(m_ctx, CL_MEM_READ_WRITE, m_algorithm.l3() * g_thd);
|
||||||
|
m_states = OclLib::createBuffer(m_ctx, CL_MEM_READ_WRITE, 200 * g_thd);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < BRANCH_MAX; ++i) {
|
||||||
|
m_branches[i] = OclLib::createBuffer(m_ctx, CL_MEM_READ_WRITE, sizeof(cl_uint) * (g_thd + 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,22 +41,16 @@ class CnBranchKernel;
|
||||||
class OclCnRunner : public OclBaseRunner
|
class OclCnRunner : public OclBaseRunner
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OclCnRunner() = delete;
|
XMRIG_DISABLE_COPY_MOVE_DEFAULT(OclCnRunner)
|
||||||
OclCnRunner(const OclCnRunner &other) = delete;
|
|
||||||
OclCnRunner(OclCnRunner &&other) = delete;
|
|
||||||
OclCnRunner(size_t index, const OclLaunchData &data);
|
|
||||||
|
|
||||||
|
OclCnRunner(size_t index, const OclLaunchData &data);
|
||||||
~OclCnRunner() override;
|
~OclCnRunner() override;
|
||||||
|
|
||||||
OclCnRunner &operator=(const OclCnRunner &other) = delete;
|
|
||||||
OclCnRunner &operator=(OclCnRunner &&other) = delete;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool isReadyToBuild() const override;
|
|
||||||
bool run(uint32_t nonce, uint32_t *hashOutput) override;
|
bool run(uint32_t nonce, uint32_t *hashOutput) override;
|
||||||
bool selfTest() const override;
|
|
||||||
bool set(const Job &job, uint8_t *blob) override;
|
bool set(const Job &job, uint8_t *blob) override;
|
||||||
void build() override;
|
void build() override;
|
||||||
|
void init() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum Branches : size_t {
|
enum Branches : size_t {
|
||||||
|
|
129
src/backend/opencl/runners/OclRxBaseRunner.cpp
Normal file
129
src/backend/opencl/runners/OclRxBaseRunner.cpp
Normal file
|
@ -0,0 +1,129 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "backend/opencl/runners/OclRxBaseRunner.h"
|
||||||
|
|
||||||
|
#include "backend/opencl/kernels/rx/Blake2bHashRegistersKernel.h"
|
||||||
|
#include "backend/opencl/kernels/rx/Blake2bInitialHashKernel.h"
|
||||||
|
#include "backend/opencl/kernels/rx/FillAesKernel.h"
|
||||||
|
#include "backend/opencl/kernels/rx/FindSharesKernel.h"
|
||||||
|
#include "backend/opencl/kernels/rx/HashAesKernel.h"
|
||||||
|
#include "backend/opencl/OclLaunchData.h"
|
||||||
|
#include "backend/opencl/wrappers/OclLib.h"
|
||||||
|
#include "crypto/rx/RxAlgo.h"
|
||||||
|
|
||||||
|
|
||||||
|
xmrig::OclRxBaseRunner::OclRxBaseRunner(size_t index, const OclLaunchData &data) : OclBaseRunner(index, data)
|
||||||
|
{
|
||||||
|
uint32_t worksize = 0;
|
||||||
|
uint32_t gcn_version = 12;
|
||||||
|
|
||||||
|
switch (data.thread.worksize()) {
|
||||||
|
case 2:
|
||||||
|
case 4:
|
||||||
|
case 8:
|
||||||
|
case 16:
|
||||||
|
worksize = data.thread.worksize();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
worksize = 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.device.type() == OclDevice::Vega_10 || data.device.type() == OclDevice::Vega_20) {
|
||||||
|
gcn_version = 14;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_options += " -DALGO=" + std::to_string(m_algorithm.id());
|
||||||
|
m_options += " -DWORKERS_PER_HASH=" + std::to_string(worksize);
|
||||||
|
m_options += " -DGCN_VERSION=" + std::to_string(gcn_version);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
xmrig::OclRxBaseRunner::~OclRxBaseRunner()
|
||||||
|
{
|
||||||
|
delete m_fillAes1Rx4_scratchpad;
|
||||||
|
delete m_fillAes4Rx4_entropy;
|
||||||
|
delete m_hashAes1Rx4;
|
||||||
|
delete m_blake2b_initial_hash;
|
||||||
|
delete m_blake2b_hash_registers_32;
|
||||||
|
delete m_blake2b_hash_registers_64;
|
||||||
|
delete m_find_shares;
|
||||||
|
|
||||||
|
OclLib::release(m_entropy);
|
||||||
|
OclLib::release(m_hashes);
|
||||||
|
OclLib::release(m_rounding);
|
||||||
|
OclLib::release(m_scratchpads);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool xmrig::OclRxBaseRunner::run(uint32_t nonce, uint32_t *hashOutput)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool xmrig::OclRxBaseRunner::set(const Job &job, uint8_t *blob)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::OclRxBaseRunner::build()
|
||||||
|
{
|
||||||
|
OclBaseRunner::build();
|
||||||
|
|
||||||
|
const uint32_t batch_size = data().thread.intensity();
|
||||||
|
const uint32_t rx_version = RxAlgo::version(m_algorithm);
|
||||||
|
|
||||||
|
m_fillAes1Rx4_scratchpad = new FillAesKernel(m_program, "fillAes1Rx4_scratchpad");
|
||||||
|
m_fillAes1Rx4_scratchpad->setArgs(m_hashes, m_scratchpads, batch_size, rx_version);
|
||||||
|
|
||||||
|
m_fillAes4Rx4_entropy = new FillAesKernel(m_program, "fillAes4Rx4_entropy");
|
||||||
|
m_fillAes1Rx4_scratchpad->setArgs(m_hashes, m_entropy, batch_size, rx_version);
|
||||||
|
|
||||||
|
m_hashAes1Rx4 = new HashAesKernel(m_program);
|
||||||
|
|
||||||
|
m_blake2b_initial_hash = new Blake2bInitialHashKernel(m_program);
|
||||||
|
m_blake2b_initial_hash->setArgs(m_hashes, m_input);
|
||||||
|
|
||||||
|
m_blake2b_hash_registers_32 = new Blake2bHashRegistersKernel(m_program, "blake2b_hash_registers_32");
|
||||||
|
m_blake2b_hash_registers_64 = new Blake2bHashRegistersKernel(m_program, "blake2b_hash_registers_64");
|
||||||
|
|
||||||
|
m_find_shares = new FindSharesKernel(m_program);
|
||||||
|
m_find_shares->setArgs(m_hashes, m_output);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::OclRxBaseRunner::init()
|
||||||
|
{
|
||||||
|
OclBaseRunner::init();
|
||||||
|
|
||||||
|
const size_t g_thd = data().thread.intensity();
|
||||||
|
|
||||||
|
m_scratchpads = OclLib::createBuffer(m_ctx, CL_MEM_READ_WRITE, (m_algorithm.l3() + 64) * g_thd);
|
||||||
|
m_hashes = OclLib::createBuffer(m_ctx, CL_MEM_READ_WRITE, 64 * g_thd);
|
||||||
|
m_entropy = OclLib::createBuffer(m_ctx, CL_MEM_READ_WRITE, (128 + 2560) * g_thd);
|
||||||
|
m_rounding = OclLib::createBuffer(m_ctx, CL_MEM_READ_WRITE, sizeof(uint32_t) * g_thd);
|
||||||
|
}
|
74
src/backend/opencl/runners/OclRxBaseRunner.h
Normal file
74
src/backend/opencl/runners/OclRxBaseRunner.h
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XMRIG_OCLRXBASERUNNER_H
|
||||||
|
#define XMRIG_OCLRXBASERUNNER_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "backend/opencl/runners/OclBaseRunner.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
class Blake2bHashRegistersKernel;
|
||||||
|
class Blake2bInitialHashKernel;
|
||||||
|
class FillAesKernel;
|
||||||
|
class FindSharesKernel;
|
||||||
|
class HashAesKernel;
|
||||||
|
|
||||||
|
|
||||||
|
class OclRxBaseRunner : public OclBaseRunner
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
XMRIG_DISABLE_COPY_MOVE_DEFAULT(OclRxBaseRunner)
|
||||||
|
|
||||||
|
OclRxBaseRunner(size_t index, const OclLaunchData &data);
|
||||||
|
~OclRxBaseRunner() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool run(uint32_t nonce, uint32_t *hashOutput) override;
|
||||||
|
bool set(const Job &job, uint8_t *blob) override;
|
||||||
|
void build() override;
|
||||||
|
void init() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Blake2bHashRegistersKernel *m_blake2b_hash_registers_32 = nullptr;
|
||||||
|
Blake2bHashRegistersKernel *m_blake2b_hash_registers_64 = nullptr;
|
||||||
|
Blake2bInitialHashKernel *m_blake2b_initial_hash = nullptr;
|
||||||
|
cl_mem m_entropy = nullptr;
|
||||||
|
cl_mem m_hashes = nullptr;
|
||||||
|
cl_mem m_rounding = nullptr;
|
||||||
|
cl_mem m_scratchpads = nullptr;
|
||||||
|
FillAesKernel *m_fillAes1Rx4_scratchpad = nullptr;
|
||||||
|
FillAesKernel *m_fillAes4Rx4_entropy = nullptr;
|
||||||
|
FindSharesKernel *m_find_shares = nullptr;
|
||||||
|
HashAesKernel *m_hashAes1Rx4 = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} /* namespace xmrig */
|
||||||
|
|
||||||
|
|
||||||
|
#endif // XMRIG_OCLRXBASERUNNER_H
|
76
src/backend/opencl/runners/OclRxJitRunner.cpp
Normal file
76
src/backend/opencl/runners/OclRxJitRunner.cpp
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "backend/opencl/runners/OclRxJitRunner.h"
|
||||||
|
|
||||||
|
#include "backend/opencl/wrappers/OclLib.h"
|
||||||
|
#include "backend/opencl/OclLaunchData.h"
|
||||||
|
#include "backend/opencl/kernels/rx/HashAesKernel.h"
|
||||||
|
#include "backend/opencl/kernels/rx/Blake2bHashRegistersKernel.h"
|
||||||
|
|
||||||
|
|
||||||
|
xmrig::OclRxJitRunner::OclRxJitRunner(size_t index, const OclLaunchData &data) : OclRxBaseRunner(index, data)
|
||||||
|
{
|
||||||
|
if (m_rounding == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const size_t g_thd = data.thread.intensity();
|
||||||
|
cl_int ret;
|
||||||
|
|
||||||
|
m_registers = OclLib::createBuffer(m_ctx, CL_MEM_READ_WRITE, 256 * g_thd, nullptr, &ret);
|
||||||
|
if (ret != CL_SUCCESS) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_intermediate_programs = OclLib::createBuffer(m_ctx, CL_MEM_READ_WRITE, 5120 * g_thd, nullptr, &ret);
|
||||||
|
if (ret != CL_SUCCESS) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_programs = OclLib::createBuffer(m_ctx, CL_MEM_READ_WRITE, 10048 * g_thd, nullptr, &ret);
|
||||||
|
if (ret != CL_SUCCESS) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
xmrig::OclRxJitRunner::~OclRxJitRunner()
|
||||||
|
{
|
||||||
|
OclLib::release(m_intermediate_programs);
|
||||||
|
OclLib::release(m_programs);
|
||||||
|
OclLib::release(m_registers);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::OclRxJitRunner::build()
|
||||||
|
{
|
||||||
|
OclRxBaseRunner::build();
|
||||||
|
|
||||||
|
const uint32_t batch_size = data().thread.intensity();
|
||||||
|
|
||||||
|
m_hashAes1Rx4->setArgs(m_scratchpads, m_registers, 256, batch_size);
|
||||||
|
m_blake2b_hash_registers_32->setArgs(m_hashes, m_registers, 256);
|
||||||
|
m_blake2b_hash_registers_64->setArgs(m_hashes, m_registers, 256);
|
||||||
|
}
|
|
@ -22,26 +22,31 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef XMRIG_OCLRXRUNNER_H
|
#ifndef XMRIG_OCLRXJITRUNNER_H
|
||||||
#define XMRIG_OCLRXRUNNER_H
|
#define XMRIG_OCLRXJITRUNNER_H
|
||||||
|
|
||||||
|
|
||||||
#include "backend/opencl/runners/OclBaseRunner.h"
|
#include "backend/opencl/runners/OclRxBaseRunner.h"
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
class OclRxRunner : public OclBaseRunner
|
class OclRxJitRunner : public OclRxBaseRunner
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OclRxRunner(size_t index, const OclLaunchData &data);
|
XMRIG_DISABLE_COPY_MOVE_DEFAULT(OclRxJitRunner)
|
||||||
|
|
||||||
|
OclRxJitRunner(size_t index, const OclLaunchData &data);
|
||||||
|
~OclRxJitRunner() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool run(uint32_t nonce, uint32_t *hashOutput) override;
|
|
||||||
bool selfTest() const override;
|
|
||||||
bool set(const Job &job, uint8_t *blob) override;
|
|
||||||
void build() override;
|
void build() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
cl_mem m_intermediate_programs = nullptr;
|
||||||
|
cl_mem m_programs = nullptr;
|
||||||
|
cl_mem m_registers = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
77
src/backend/opencl/runners/OclRxVmRunner.cpp
Normal file
77
src/backend/opencl/runners/OclRxVmRunner.cpp
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "backend/opencl/runners/OclRxVmRunner.h"
|
||||||
|
|
||||||
|
#include "backend/opencl/kernels/rx/Blake2bHashRegistersKernel.h"
|
||||||
|
#include "backend/opencl/kernels/rx/ExecuteVmKernel.h"
|
||||||
|
#include "backend/opencl/kernels/rx/HashAesKernel.h"
|
||||||
|
#include "backend/opencl/kernels/rx/InitVmKernel.h"
|
||||||
|
#include "backend/opencl/OclLaunchData.h"
|
||||||
|
#include "backend/opencl/wrappers/OclLib.h"
|
||||||
|
#include "crypto/rx/RxAlgo.h"
|
||||||
|
|
||||||
|
|
||||||
|
xmrig::OclRxVmRunner::OclRxVmRunner(size_t index, const OclLaunchData &data) : OclRxBaseRunner(index, data)
|
||||||
|
{
|
||||||
|
if (m_rounding == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const size_t g_thd = data.thread.intensity();
|
||||||
|
cl_int ret;
|
||||||
|
|
||||||
|
m_vm_states = OclLib::createBuffer(m_ctx, CL_MEM_READ_WRITE, 2560 * g_thd, nullptr, &ret);
|
||||||
|
if (ret != CL_SUCCESS) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
xmrig::OclRxVmRunner::~OclRxVmRunner()
|
||||||
|
{
|
||||||
|
delete m_init_vm;
|
||||||
|
delete m_execute_vm;
|
||||||
|
|
||||||
|
OclLib::release(m_vm_states);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::OclRxVmRunner::build()
|
||||||
|
{
|
||||||
|
OclRxBaseRunner::build();
|
||||||
|
|
||||||
|
const uint32_t batch_size = data().thread.intensity();
|
||||||
|
const uint32_t hashStrideBytes = RxAlgo::programSize(m_algorithm) * 8;
|
||||||
|
|
||||||
|
m_hashAes1Rx4->setArgs(m_scratchpads, m_vm_states, hashStrideBytes, batch_size);
|
||||||
|
m_blake2b_hash_registers_32->setArgs(m_hashes, m_vm_states, hashStrideBytes);
|
||||||
|
m_blake2b_hash_registers_64->setArgs(m_hashes, m_vm_states, hashStrideBytes);
|
||||||
|
|
||||||
|
m_init_vm = new InitVmKernel(m_program);
|
||||||
|
m_init_vm->setArgs(m_entropy, m_vm_states, m_rounding);
|
||||||
|
|
||||||
|
m_execute_vm = new ExecuteVmKernel(m_program);
|
||||||
|
m_execute_vm->setArgs(m_vm_states, m_rounding, m_scratchpads, data().dataset->get(), batch_size);
|
||||||
|
}
|
60
src/backend/opencl/runners/OclRxVmRunner.h
Normal file
60
src/backend/opencl/runners/OclRxVmRunner.h
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XMRIG_OCLRXVMRUNNER_H
|
||||||
|
#define XMRIG_OCLRXVMRUNNER_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "backend/opencl/runners/OclRxBaseRunner.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
class ExecuteVmKernel;
|
||||||
|
class InitVmKernel;
|
||||||
|
|
||||||
|
|
||||||
|
class OclRxVmRunner : public OclRxBaseRunner
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
XMRIG_DISABLE_COPY_MOVE_DEFAULT(OclRxVmRunner)
|
||||||
|
|
||||||
|
OclRxVmRunner(size_t index, const OclLaunchData &data);
|
||||||
|
~OclRxVmRunner() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void build() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
cl_mem m_vm_states = nullptr;
|
||||||
|
ExecuteVmKernel *m_execute_vm = nullptr;
|
||||||
|
InitVmKernel *m_init_vm = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} /* namespace xmrig */
|
||||||
|
|
||||||
|
|
||||||
|
#endif // XMRIG_OCLRXVMRUNNER_H
|
|
@ -39,23 +39,6 @@
|
||||||
|
|
||||||
xmrig::OclRyoRunner::OclRyoRunner(size_t index, const OclLaunchData &data) : OclBaseRunner(index, data)
|
xmrig::OclRyoRunner::OclRyoRunner(size_t index, const OclLaunchData &data) : OclBaseRunner(index, data)
|
||||||
{
|
{
|
||||||
if (m_queue == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const size_t g_thd = data.thread.intensity();
|
|
||||||
|
|
||||||
cl_int ret;
|
|
||||||
m_scratchpads = OclLib::createBuffer(m_ctx, CL_MEM_READ_WRITE, data.algorithm.l3() * g_thd, nullptr, &ret);
|
|
||||||
if (ret != CL_SUCCESS) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_states = OclLib::createBuffer(m_ctx, CL_MEM_READ_WRITE, 200 * g_thd, nullptr, &ret);
|
|
||||||
if (ret != CL_SUCCESS) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_options += " -DITERATIONS=" + std::to_string(CnAlgo<>::iterations(m_algorithm)) + "U";
|
m_options += " -DITERATIONS=" + std::to_string(CnAlgo<>::iterations(m_algorithm)) + "U";
|
||||||
m_options += " -DMASK=" + std::to_string(CnAlgo<>::mask(m_algorithm)) + "U";
|
m_options += " -DMASK=" + std::to_string(CnAlgo<>::mask(m_algorithm)) + "U";
|
||||||
m_options += " -DWORKSIZE=" + std::to_string(data.thread.worksize()) + "U";
|
m_options += " -DWORKSIZE=" + std::to_string(data.thread.worksize()) + "U";
|
||||||
|
@ -78,14 +61,6 @@ xmrig::OclRyoRunner::~OclRyoRunner()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::OclRyoRunner::isReadyToBuild() const
|
|
||||||
{
|
|
||||||
return OclBaseRunner::isReadyToBuild() &&
|
|
||||||
m_scratchpads != nullptr &&
|
|
||||||
m_states != nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::OclRyoRunner::run(uint32_t nonce, uint32_t *hashOutput)
|
bool xmrig::OclRyoRunner::run(uint32_t nonce, uint32_t *hashOutput)
|
||||||
{
|
{
|
||||||
static const cl_uint zero = 0;
|
static const cl_uint zero = 0;
|
||||||
|
@ -96,29 +71,14 @@ bool xmrig::OclRyoRunner::run(uint32_t nonce, uint32_t *hashOutput)
|
||||||
|
|
||||||
assert(g_thd % w_size == 0);
|
assert(g_thd % w_size == 0);
|
||||||
|
|
||||||
if (OclLib::enqueueWriteBuffer(m_queue, m_output, CL_FALSE, sizeof(cl_uint) * 0xFF, sizeof(cl_uint), &zero, 0, nullptr, nullptr) != CL_SUCCESS) {
|
enqueueWriteBuffer(m_output, CL_FALSE, sizeof(cl_uint) * 0xFF, sizeof(cl_uint), &zero);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_cn0->enqueue(m_queue, nonce, g_thd)) {
|
m_cn0->enqueue(m_queue, nonce, g_thd);
|
||||||
return false;
|
m_cn00->enqueue(m_queue, g_thd);
|
||||||
}
|
m_cn1->enqueue(m_queue, g_thd, w_size);
|
||||||
|
m_cn2->enqueue(m_queue, nonce, g_thd);
|
||||||
|
|
||||||
if (!m_cn00->enqueue(m_queue, g_thd)) {
|
enqueueReadBuffer(m_output, CL_TRUE, 0, sizeof(cl_uint) * 0x100, hashOutput);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_cn1->enqueue(m_queue, g_thd, w_size)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_cn2->enqueue(m_queue, nonce, g_thd)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (OclLib::enqueueReadBuffer(m_queue, m_output, CL_TRUE, 0, sizeof(cl_uint) * 0x100, hashOutput, 0, nullptr, nullptr) != CL_SUCCESS) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t &results = hashOutput[0xFF];
|
uint32_t &results = hashOutput[0xFF];
|
||||||
if (results > 0xFF) {
|
if (results > 0xFF) {
|
||||||
|
@ -129,12 +89,6 @@ bool xmrig::OclRyoRunner::run(uint32_t nonce, uint32_t *hashOutput)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::OclRyoRunner::selfTest() const
|
|
||||||
{
|
|
||||||
return OclBaseRunner::selfTest() && m_cn0->isValid() && m_cn00->isValid() && m_cn1->isValid() && m_cn2->isValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::OclRyoRunner::set(const Job &job, uint8_t *blob)
|
bool xmrig::OclRyoRunner::set(const Job &job, uint8_t *blob)
|
||||||
{
|
{
|
||||||
if (job.size() > (Job::kMaxBlobSize - 4)) {
|
if (job.size() > (Job::kMaxBlobSize - 4)) {
|
||||||
|
@ -144,27 +98,9 @@ bool xmrig::OclRyoRunner::set(const Job &job, uint8_t *blob)
|
||||||
blob[job.size()] = 0x01;
|
blob[job.size()] = 0x01;
|
||||||
memset(blob + job.size() + 1, 0, Job::kMaxBlobSize - job.size() - 1);
|
memset(blob + job.size() + 1, 0, Job::kMaxBlobSize - job.size() - 1);
|
||||||
|
|
||||||
if (OclLib::enqueueWriteBuffer(m_queue, m_input, CL_TRUE, 0, Job::kMaxBlobSize, blob, 0, nullptr, nullptr) != CL_SUCCESS) {
|
enqueueWriteBuffer(m_input, CL_TRUE, 0, Job::kMaxBlobSize, blob);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const uint32_t intensity = data().thread.intensity();
|
m_cn2->setTarget(job.target());
|
||||||
|
|
||||||
if (!m_cn00->setArgs(m_scratchpads, m_states)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_cn0->setArgs(m_input, m_scratchpads, m_states, intensity)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_cn1->setArgs(m_scratchpads, m_states, intensity)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_cn2->setArgs(m_scratchpads, m_states, m_output, job.target(), intensity)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -174,12 +110,28 @@ void xmrig::OclRyoRunner::build()
|
||||||
{
|
{
|
||||||
OclBaseRunner::build();
|
OclBaseRunner::build();
|
||||||
|
|
||||||
if (!m_program) {
|
const uint32_t intensity = data().thread.intensity();
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_cn00 = new Cn00RyoKernel(m_program);
|
m_cn00 = new Cn00RyoKernel(m_program);
|
||||||
|
m_cn00->setArgs(m_scratchpads, m_states);
|
||||||
|
|
||||||
m_cn0 = new Cn0Kernel(m_program);
|
m_cn0 = new Cn0Kernel(m_program);
|
||||||
|
m_cn0->setArgs(m_input, m_scratchpads, m_states, intensity);
|
||||||
|
|
||||||
m_cn1 = new Cn1RyoKernel(m_program);
|
m_cn1 = new Cn1RyoKernel(m_program);
|
||||||
|
m_cn1->setArgs(m_scratchpads, m_states, intensity);
|
||||||
|
|
||||||
m_cn2 = new Cn2RyoKernel(m_program);
|
m_cn2 = new Cn2RyoKernel(m_program);
|
||||||
|
m_cn2->setArgs(m_scratchpads, m_states, m_output, intensity);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::OclRyoRunner::init()
|
||||||
|
{
|
||||||
|
OclBaseRunner::init();
|
||||||
|
|
||||||
|
const size_t g_thd = data().thread.intensity();
|
||||||
|
|
||||||
|
m_scratchpads = OclLib::createBuffer(m_ctx, CL_MEM_READ_WRITE, data().algorithm.l3() * g_thd);
|
||||||
|
m_states = OclLib::createBuffer(m_ctx, CL_MEM_READ_WRITE, 200 * g_thd);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,22 +41,17 @@ class Cn2RyoKernel;
|
||||||
class OclRyoRunner : public OclBaseRunner
|
class OclRyoRunner : public OclBaseRunner
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OclRyoRunner() = delete;
|
XMRIG_DISABLE_COPY_MOVE_DEFAULT(OclRyoRunner)
|
||||||
OclRyoRunner(const OclRyoRunner &other) = delete;
|
|
||||||
OclRyoRunner(OclRyoRunner &&other) = delete;
|
|
||||||
OclRyoRunner(size_t index, const OclLaunchData &data);
|
OclRyoRunner(size_t index, const OclLaunchData &data);
|
||||||
|
|
||||||
~OclRyoRunner() override;
|
~OclRyoRunner() override;
|
||||||
|
|
||||||
OclRyoRunner &operator=(const OclRyoRunner &other) = delete;
|
|
||||||
OclRyoRunner &operator=(OclRyoRunner &&other) = delete;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool isReadyToBuild() const override;
|
|
||||||
bool run(uint32_t nonce, uint32_t *hashOutput) override;
|
bool run(uint32_t nonce, uint32_t *hashOutput) override;
|
||||||
bool selfTest() const override;
|
|
||||||
bool set(const Job &job, uint8_t *blob) override;
|
bool set(const Job &job, uint8_t *blob) override;
|
||||||
void build() override;
|
void build() override;
|
||||||
|
void init() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
cl_mem m_scratchpads = nullptr;
|
cl_mem m_scratchpads = nullptr;
|
||||||
|
|
|
@ -22,61 +22,20 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "backend/opencl/runners/OclRxRunner.h"
|
|
||||||
|
|
||||||
#include "backend/opencl/OclLaunchData.h"
|
#include "backend/opencl/wrappers/OclLib.h"
|
||||||
|
#include "backend/opencl/runners/tools/OclRxDataset.h"
|
||||||
|
#include "crypto/rx/RxDataset.h"
|
||||||
|
|
||||||
|
|
||||||
xmrig::OclRxRunner::OclRxRunner(size_t index, const OclLaunchData &data) : OclBaseRunner(index, data)
|
void xmrig::OclRxDataset::createBuffer(cl_context ctx, const Algorithm &algorithm, bool host)
|
||||||
{
|
{
|
||||||
uint32_t worksize = 0;
|
cl_int ret;
|
||||||
uint32_t gcn_version = 12;
|
|
||||||
|
|
||||||
switch (data.thread.worksize()) {
|
if (host) {
|
||||||
case 2:
|
// TODO use host memory for dataset
|
||||||
case 4:
|
|
||||||
case 8:
|
|
||||||
case 16:
|
|
||||||
worksize = data.thread.worksize();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
worksize = 8;
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
if (data.device.type() == OclDevice::Vega_10 || data.device.type() == OclDevice::Vega_20) {
|
m_dataset = OclLib::createBuffer(ctx, CL_MEM_READ_ONLY, RxDataset::maxSize(), nullptr, &ret);
|
||||||
gcn_version = 14;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_options += " -DALGO=" + std::to_string(m_algorithm.id());
|
|
||||||
m_options += " -DWORKERS_PER_HASH=" + std::to_string(worksize);
|
|
||||||
m_options += " -DGCN_VERSION=" + std::to_string(gcn_version);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::OclRxRunner::run(uint32_t nonce, uint32_t *hashOutput)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::OclRxRunner::selfTest() const
|
|
||||||
{
|
|
||||||
return false; // TODO OclRxRunner
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::OclRxRunner::set(const Job &job, uint8_t *blob)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void xmrig::OclRxRunner::build()
|
|
||||||
{
|
|
||||||
OclBaseRunner::build();
|
|
||||||
|
|
||||||
if (!m_program) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
62
src/backend/opencl/runners/tools/OclRxDataset.h
Normal file
62
src/backend/opencl/runners/tools/OclRxDataset.h
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XMRIG_OCLRXDATASET_H
|
||||||
|
#define XMRIG_OCLRXDATASET_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
|
using cl_context = struct _cl_context *;
|
||||||
|
using cl_mem = struct _cl_mem *;
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
class Algorithm;
|
||||||
|
|
||||||
|
|
||||||
|
class OclRxDataset
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
OclRxDataset() = default;
|
||||||
|
|
||||||
|
inline cl_mem get() const { return m_dataset; }
|
||||||
|
|
||||||
|
void createBuffer(cl_context ctx, const Algorithm &algorithm, bool host);
|
||||||
|
|
||||||
|
private:
|
||||||
|
cl_mem m_dataset = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
using OclRxDatasetPtr = std::shared_ptr<OclRxDataset>;
|
||||||
|
|
||||||
|
|
||||||
|
} /* namespace xmrig */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* XMRIG_OCLINTERLEAVE_H */
|
|
@ -23,8 +23,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "backend/opencl/wrappers/OclLib.h"
|
|
||||||
#include "backend/opencl/wrappers/OclContext.h"
|
#include "backend/opencl/wrappers/OclContext.h"
|
||||||
|
#include "backend/opencl/wrappers/OclLib.h"
|
||||||
|
|
||||||
|
|
||||||
xmrig::OclContext::OclContext(const OclDevice &device)
|
xmrig::OclContext::OclContext(const OclDevice &device)
|
||||||
|
@ -59,6 +59,12 @@ bool xmrig::OclContext::init(const std::vector<OclDevice> &devices, std::vector<
|
||||||
|
|
||||||
for (OclLaunchData &data : threads) {
|
for (OclLaunchData &data : threads) {
|
||||||
data.ctx = m_ctx;
|
data.ctx = m_ctx;
|
||||||
|
|
||||||
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
|
if (data.algorithm.family() == Algorithm::RANDOM_X) {
|
||||||
|
data.dataset->createBuffer(m_ctx, data.algorithm, data.thread.isDatasetHost());
|
||||||
|
}
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -28,9 +28,10 @@
|
||||||
|
|
||||||
#include "backend/opencl/OclLaunchData.h"
|
#include "backend/opencl/OclLaunchData.h"
|
||||||
#include "backend/opencl/wrappers/OclDevice.h"
|
#include "backend/opencl/wrappers/OclDevice.h"
|
||||||
|
#include "base/tools/Object.h"
|
||||||
|
|
||||||
|
|
||||||
typedef struct _cl_context *cl_context;
|
using cl_context = struct _cl_context *;
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
@ -39,6 +40,8 @@ namespace xmrig {
|
||||||
class OclContext
|
class OclContext
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
XMRIG_DISABLE_COPY_MOVE(OclContext)
|
||||||
|
|
||||||
OclContext() = default;
|
OclContext() = default;
|
||||||
OclContext(const OclDevice &device);
|
OclContext(const OclDevice &device);
|
||||||
~OclContext();
|
~OclContext();
|
||||||
|
|
|
@ -23,17 +23,20 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "backend/common/Tags.h"
|
||||||
#include "backend/opencl/wrappers/OclError.h"
|
#include "backend/opencl/wrappers/OclError.h"
|
||||||
#include "backend/opencl/wrappers/OclKernel.h"
|
#include "backend/opencl/wrappers/OclKernel.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"
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
|
||||||
xmrig::OclKernel::OclKernel(cl_program program, const char *name) :
|
xmrig::OclKernel::OclKernel(cl_program program, const char *name) :
|
||||||
m_name(name)
|
m_name(name)
|
||||||
{
|
{
|
||||||
cl_int ret = 0;
|
m_kernel = OclLib::createKernel(program, name);
|
||||||
m_kernel = OclLib::createKernel(program, name, &ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,34 +46,26 @@ xmrig::OclKernel::~OclKernel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::OclKernel::enqueueNDRange(cl_command_queue queue, uint32_t work_dim, const size_t *global_work_offset, const size_t *global_work_size, const size_t *local_work_size)
|
void xmrig::OclKernel::enqueueNDRange(cl_command_queue queue, uint32_t work_dim, const size_t *global_work_offset, const size_t *global_work_size, const size_t *local_work_size)
|
||||||
{
|
{
|
||||||
if (!isValid()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const cl_int ret = OclLib::enqueueNDRangeKernel(queue, m_kernel, work_dim, global_work_offset, global_work_size, local_work_size, 0, nullptr, nullptr);
|
const cl_int ret = OclLib::enqueueNDRangeKernel(queue, m_kernel, work_dim, global_work_offset, global_work_size, local_work_size, 0, nullptr, nullptr);
|
||||||
if (ret != CL_SUCCESS) {
|
if (ret != CL_SUCCESS) {
|
||||||
LOG_ERR(MAGENTA_BG_BOLD(WHITE_BOLD_S " ocl ") RED(" error ") RED_BOLD("%s") RED(" when calling ") RED_BOLD("clEnqueueNDRangeKernel") RED(" for kernel ") RED_BOLD("%s"),
|
LOG_ERR("%s" RED(" error ") RED_BOLD("%s") RED(" when calling ") RED_BOLD("clEnqueueNDRangeKernel") RED(" for kernel ") RED_BOLD("%s"),
|
||||||
OclError::toString(ret), name().data());
|
ocl_tag(), OclError::toString(ret), name().data());
|
||||||
}
|
|
||||||
|
|
||||||
return ret == CL_SUCCESS;
|
throw std::runtime_error(OclError::toString(ret));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::OclKernel::setArg(uint32_t index, size_t size, const void *value)
|
void xmrig::OclKernel::setArg(uint32_t index, size_t size, const void *value)
|
||||||
{
|
{
|
||||||
if (!isValid()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const cl_int ret = OclLib::setKernelArg(m_kernel, index, size, value);
|
const cl_int ret = OclLib::setKernelArg(m_kernel, index, size, value);
|
||||||
if (ret != CL_SUCCESS) {
|
if (ret != CL_SUCCESS) {
|
||||||
LOG_ERR(MAGENTA_BG_BOLD(WHITE_BOLD_S " ocl ") RED(" error ") RED_BOLD("%s") RED(" when calling ") RED_BOLD("clSetKernelArg") RED(" for kernel ") RED_BOLD("%s")
|
LOG_ERR("%s" RED(" error ") RED_BOLD("%s") RED(" when calling ") RED_BOLD("clSetKernelArg") RED(" for kernel ") RED_BOLD("%s")
|
||||||
RED(" argument ") RED_BOLD("%u") RED(" size ") RED_BOLD("%zu"),
|
RED(" argument ") RED_BOLD("%u") RED(" size ") RED_BOLD("%zu"),
|
||||||
OclError::toString(ret), name().data(), index, size);
|
ocl_tag(), OclError::toString(ret), name().data(), index, size);
|
||||||
}
|
|
||||||
|
|
||||||
return ret == CL_SUCCESS;
|
throw std::runtime_error(OclError::toString(ret));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#define XMRIG_OCLKERNEL_H
|
#define XMRIG_OCLKERNEL_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "base/tools/Object.h"
|
||||||
#include "base/tools/String.h"
|
#include "base/tools/String.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,6 +42,8 @@ namespace xmrig {
|
||||||
class OclKernel
|
class OclKernel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
XMRIG_DISABLE_COPY_MOVE_DEFAULT(OclKernel)
|
||||||
|
|
||||||
OclKernel(cl_program program, const char *name);
|
OclKernel(cl_program program, const char *name);
|
||||||
virtual ~OclKernel();
|
virtual ~OclKernel();
|
||||||
|
|
||||||
|
@ -48,8 +51,8 @@ public:
|
||||||
inline cl_kernel kernel() const { return m_kernel; }
|
inline cl_kernel kernel() const { return m_kernel; }
|
||||||
inline const String &name() const { return m_name; }
|
inline const String &name() const { return m_name; }
|
||||||
|
|
||||||
bool enqueueNDRange(cl_command_queue queue, uint32_t work_dim, const size_t *global_work_offset, const size_t *global_work_size, const size_t *local_work_size);
|
void enqueueNDRange(cl_command_queue queue, uint32_t work_dim, const size_t *global_work_offset, const size_t *global_work_size, const size_t *local_work_size);
|
||||||
bool setArg(uint32_t index, size_t size, const void *value);
|
void setArg(uint32_t index, size_t size, const void *value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
cl_kernel m_kernel = nullptr;
|
cl_kernel m_kernel = nullptr;
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <uv.h>
|
#include <uv.h>
|
||||||
|
|
||||||
|
|
||||||
|
#include "backend/common/Tags.h"
|
||||||
#include "backend/opencl/wrappers/OclError.h"
|
#include "backend/opencl/wrappers/OclError.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"
|
||||||
|
@ -63,6 +64,7 @@ static const char *kReleaseMemObject = "clReleaseMemObject";
|
||||||
static const char *kReleaseProgram = "clReleaseProgram";
|
static const char *kReleaseProgram = "clReleaseProgram";
|
||||||
static const char *kSetKernelArg = "clSetKernelArg";
|
static const char *kSetKernelArg = "clSetKernelArg";
|
||||||
|
|
||||||
|
|
||||||
#if defined(CL_VERSION_2_0)
|
#if defined(CL_VERSION_2_0)
|
||||||
typedef cl_command_queue (CL_API_CALL *createCommandQueueWithProperties_t)(cl_context, cl_device_id, const cl_queue_properties *, cl_int *);
|
typedef cl_command_queue (CL_API_CALL *createCommandQueueWithProperties_t)(cl_context, cl_device_id, const cl_queue_properties *, cl_int *);
|
||||||
#endif
|
#endif
|
||||||
|
@ -208,7 +210,7 @@ const char *xmrig::OclLib::defaultLoader()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cl_command_queue xmrig::OclLib::createCommandQueue(cl_context context, cl_device_id device, cl_int *errcode_ret)
|
cl_command_queue xmrig::OclLib::createCommandQueue(cl_context context, cl_device_id device, cl_int *errcode_ret) noexcept
|
||||||
{
|
{
|
||||||
cl_command_queue result;
|
cl_command_queue result;
|
||||||
|
|
||||||
|
@ -235,6 +237,18 @@ cl_command_queue xmrig::OclLib::createCommandQueue(cl_context context, cl_device
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
cl_command_queue xmrig::OclLib::createCommandQueue(cl_context context, cl_device_id device)
|
||||||
|
{
|
||||||
|
cl_int ret;
|
||||||
|
cl_command_queue queue = createCommandQueue(context, device, &ret);
|
||||||
|
if (ret != CL_SUCCESS) {
|
||||||
|
throw std::runtime_error(OclError::toString(ret));
|
||||||
|
}
|
||||||
|
|
||||||
|
return queue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
cl_context xmrig::OclLib::createContext(const cl_context_properties *properties, cl_uint num_devices, const cl_device_id *devices, void (CL_CALLBACK *pfn_notify)(const char *, const void *, size_t, void *), void *user_data, cl_int *errcode_ret)
|
cl_context xmrig::OclLib::createContext(const cl_context_properties *properties, cl_uint num_devices, const cl_device_id *devices, void (CL_CALLBACK *pfn_notify)(const char *, const void *, size_t, void *), void *user_data, cl_int *errcode_ret)
|
||||||
{
|
{
|
||||||
assert(pCreateContext != nullptr);
|
assert(pCreateContext != nullptr);
|
||||||
|
@ -257,7 +271,7 @@ cl_context xmrig::OclLib::createContext(const std::vector<cl_device_id> &ids)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cl_int xmrig::OclLib::buildProgram(cl_program program, cl_uint num_devices, const cl_device_id *device_list, const char *options, void (CL_CALLBACK *pfn_notify)(cl_program program, void *user_data), void *user_data)
|
cl_int xmrig::OclLib::buildProgram(cl_program program, cl_uint num_devices, const cl_device_id *device_list, const char *options, void (CL_CALLBACK *pfn_notify)(cl_program program, void *user_data), void *user_data) noexcept
|
||||||
{
|
{
|
||||||
assert(pBuildProgram != nullptr);
|
assert(pBuildProgram != nullptr);
|
||||||
|
|
||||||
|
@ -270,7 +284,7 @@ cl_int xmrig::OclLib::buildProgram(cl_program program, cl_uint num_devices, cons
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cl_int xmrig::OclLib::enqueueNDRangeKernel(cl_command_queue command_queue, cl_kernel kernel, cl_uint work_dim, const size_t *global_work_offset, const size_t *global_work_size, const size_t *local_work_size, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event)
|
cl_int xmrig::OclLib::enqueueNDRangeKernel(cl_command_queue command_queue, cl_kernel kernel, cl_uint work_dim, const size_t *global_work_offset, const size_t *global_work_size, const size_t *local_work_size, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event) noexcept
|
||||||
{
|
{
|
||||||
assert(pEnqueueNDRangeKernel != nullptr);
|
assert(pEnqueueNDRangeKernel != nullptr);
|
||||||
|
|
||||||
|
@ -278,7 +292,7 @@ cl_int xmrig::OclLib::enqueueNDRangeKernel(cl_command_queue command_queue, cl_ke
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cl_int xmrig::OclLib::enqueueReadBuffer(cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, size_t offset, size_t size, void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event)
|
cl_int xmrig::OclLib::enqueueReadBuffer(cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, size_t offset, size_t size, void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event) noexcept
|
||||||
{
|
{
|
||||||
assert(pEnqueueReadBuffer != nullptr);
|
assert(pEnqueueReadBuffer != nullptr);
|
||||||
|
|
||||||
|
@ -291,7 +305,7 @@ cl_int xmrig::OclLib::enqueueReadBuffer(cl_command_queue command_queue, cl_mem b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cl_int xmrig::OclLib::enqueueWriteBuffer(cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write, size_t offset, size_t size, const void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event)
|
cl_int xmrig::OclLib::enqueueWriteBuffer(cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write, size_t offset, size_t size, const void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event) noexcept
|
||||||
{
|
{
|
||||||
assert(pEnqueueWriteBuffer != nullptr);
|
assert(pEnqueueWriteBuffer != nullptr);
|
||||||
|
|
||||||
|
@ -304,7 +318,7 @@ cl_int xmrig::OclLib::enqueueWriteBuffer(cl_command_queue command_queue, cl_mem
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cl_int xmrig::OclLib::finish(cl_command_queue command_queue)
|
cl_int xmrig::OclLib::finish(cl_command_queue command_queue) noexcept
|
||||||
{
|
{
|
||||||
assert(pFinish != nullptr);
|
assert(pFinish != nullptr);
|
||||||
|
|
||||||
|
@ -312,7 +326,7 @@ cl_int xmrig::OclLib::finish(cl_command_queue command_queue)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cl_int xmrig::OclLib::getDeviceIDs(cl_platform_id platform, cl_device_type device_type, cl_uint num_entries, cl_device_id *devices, cl_uint *num_devices)
|
cl_int xmrig::OclLib::getDeviceIDs(cl_platform_id platform, cl_device_type device_type, cl_uint num_entries, cl_device_id *devices, cl_uint *num_devices) noexcept
|
||||||
{
|
{
|
||||||
assert(pGetDeviceIDs != nullptr);
|
assert(pGetDeviceIDs != nullptr);
|
||||||
|
|
||||||
|
@ -320,7 +334,7 @@ cl_int xmrig::OclLib::getDeviceIDs(cl_platform_id platform, cl_device_type devic
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cl_int xmrig::OclLib::getDeviceInfo(cl_device_id device, cl_device_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
|
cl_int xmrig::OclLib::getDeviceInfo(cl_device_id device, cl_device_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret) noexcept
|
||||||
{
|
{
|
||||||
assert(pGetDeviceInfo != nullptr);
|
assert(pGetDeviceInfo != nullptr);
|
||||||
|
|
||||||
|
@ -341,7 +355,7 @@ cl_int xmrig::OclLib::getPlatformIDs(cl_uint num_entries, cl_platform_id *platfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cl_int xmrig::OclLib::getPlatformInfo(cl_platform_id platform, cl_platform_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
|
cl_int xmrig::OclLib::getPlatformInfo(cl_platform_id platform, cl_platform_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret) noexcept
|
||||||
{
|
{
|
||||||
assert(pGetPlatformInfo != nullptr);
|
assert(pGetPlatformInfo != nullptr);
|
||||||
|
|
||||||
|
@ -349,7 +363,7 @@ cl_int xmrig::OclLib::getPlatformInfo(cl_platform_id platform, cl_platform_info
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cl_int xmrig::OclLib::getProgramBuildInfo(cl_program program, cl_device_id device, cl_program_build_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
|
cl_int xmrig::OclLib::getProgramBuildInfo(cl_program program, cl_device_id device, cl_program_build_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret) noexcept
|
||||||
{
|
{
|
||||||
assert(pGetProgramBuildInfo != nullptr);
|
assert(pGetProgramBuildInfo != nullptr);
|
||||||
|
|
||||||
|
@ -375,11 +389,15 @@ cl_int xmrig::OclLib::getProgramInfo(cl_program program, cl_program_info param_n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cl_int xmrig::OclLib::release(cl_command_queue command_queue)
|
cl_int xmrig::OclLib::release(cl_command_queue command_queue) noexcept
|
||||||
{
|
{
|
||||||
assert(pReleaseCommandQueue != nullptr);
|
assert(pReleaseCommandQueue != nullptr);
|
||||||
assert(pGetCommandQueueInfo != nullptr);
|
assert(pGetCommandQueueInfo != nullptr);
|
||||||
|
|
||||||
|
if (command_queue == nullptr) {
|
||||||
|
return CL_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
finish(command_queue);
|
finish(command_queue);
|
||||||
|
|
||||||
cl_int ret = pReleaseCommandQueue(command_queue);
|
cl_int ret = pReleaseCommandQueue(command_queue);
|
||||||
|
@ -391,7 +409,7 @@ cl_int xmrig::OclLib::release(cl_command_queue command_queue)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cl_int xmrig::OclLib::release(cl_context context)
|
cl_int xmrig::OclLib::release(cl_context context) noexcept
|
||||||
{
|
{
|
||||||
assert(pReleaseContext != nullptr);
|
assert(pReleaseContext != nullptr);
|
||||||
|
|
||||||
|
@ -404,7 +422,7 @@ cl_int xmrig::OclLib::release(cl_context context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cl_int xmrig::OclLib::release(cl_kernel kernel)
|
cl_int xmrig::OclLib::release(cl_kernel kernel) noexcept
|
||||||
{
|
{
|
||||||
assert(pReleaseKernel != nullptr);
|
assert(pReleaseKernel != nullptr);
|
||||||
|
|
||||||
|
@ -421,7 +439,7 @@ cl_int xmrig::OclLib::release(cl_kernel kernel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cl_int xmrig::OclLib::release(cl_mem mem_obj)
|
cl_int xmrig::OclLib::release(cl_mem mem_obj) noexcept
|
||||||
{
|
{
|
||||||
assert(pReleaseMemObject != nullptr);
|
assert(pReleaseMemObject != nullptr);
|
||||||
|
|
||||||
|
@ -438,7 +456,7 @@ cl_int xmrig::OclLib::release(cl_mem mem_obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cl_int xmrig::OclLib::release(cl_program program)
|
cl_int xmrig::OclLib::release(cl_program program) noexcept
|
||||||
{
|
{
|
||||||
assert(pReleaseProgram != nullptr);
|
assert(pReleaseProgram != nullptr);
|
||||||
|
|
||||||
|
@ -455,7 +473,7 @@ cl_int xmrig::OclLib::release(cl_program program)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cl_int xmrig::OclLib::setKernelArg(cl_kernel kernel, cl_uint arg_index, size_t arg_size, const void *arg_value)
|
cl_int xmrig::OclLib::setKernelArg(cl_kernel kernel, cl_uint arg_index, size_t arg_size, const void *arg_value) noexcept
|
||||||
{
|
{
|
||||||
assert(pSetKernelArg != nullptr);
|
assert(pSetKernelArg != nullptr);
|
||||||
|
|
||||||
|
@ -463,14 +481,14 @@ cl_int xmrig::OclLib::setKernelArg(cl_kernel kernel, cl_uint arg_index, size_t a
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cl_kernel xmrig::OclLib::createKernel(cl_program program, const char *kernel_name, cl_int *errcode_ret)
|
cl_kernel xmrig::OclLib::createKernel(cl_program program, const char *kernel_name, cl_int *errcode_ret) noexcept
|
||||||
{
|
{
|
||||||
assert(pCreateKernel != nullptr);
|
assert(pCreateKernel != nullptr);
|
||||||
|
|
||||||
auto result = pCreateKernel(program, kernel_name, errcode_ret);
|
auto result = pCreateKernel(program, kernel_name, errcode_ret);
|
||||||
if (*errcode_ret != CL_SUCCESS) {
|
if (*errcode_ret != CL_SUCCESS) {
|
||||||
LOG_ERR(MAGENTA_BG_BOLD(WHITE_BOLD_S " ocl ") RED(" error ") RED_BOLD("%s") RED(" when calling ") RED_BOLD("clCreateKernel") RED(" for kernel ") RED_BOLD("%s"),
|
LOG_ERR("%s" RED(" error ") RED_BOLD("%s") RED(" when calling ") RED_BOLD("clCreateKernel") RED(" for kernel ") RED_BOLD("%s"),
|
||||||
OclError::toString(*errcode_ret), kernel_name);
|
ocl_tag(), OclError::toString(*errcode_ret), kernel_name);
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -479,14 +497,38 @@ cl_kernel xmrig::OclLib::createKernel(cl_program program, const char *kernel_nam
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cl_mem xmrig::OclLib::createBuffer(cl_context context, cl_mem_flags flags, size_t size, void *host_ptr, cl_int *errcode_ret)
|
cl_kernel xmrig::OclLib::createKernel(cl_program program, const char *kernel_name)
|
||||||
|
{
|
||||||
|
cl_int ret;
|
||||||
|
cl_kernel kernel = createKernel(program, kernel_name, &ret);
|
||||||
|
if (ret != CL_SUCCESS) {
|
||||||
|
throw std::runtime_error(OclError::toString(ret));
|
||||||
|
}
|
||||||
|
|
||||||
|
return kernel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
cl_mem xmrig::OclLib::createBuffer(cl_context context, cl_mem_flags flags, size_t size, void *host_ptr)
|
||||||
|
{
|
||||||
|
cl_int ret;
|
||||||
|
cl_mem mem = createBuffer(context, flags, size, host_ptr, &ret);
|
||||||
|
if (ret != CL_SUCCESS) {
|
||||||
|
throw std::runtime_error(OclError::toString(ret));
|
||||||
|
}
|
||||||
|
|
||||||
|
return mem;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
cl_mem xmrig::OclLib::createBuffer(cl_context context, cl_mem_flags flags, size_t size, void *host_ptr, cl_int *errcode_ret) noexcept
|
||||||
{
|
{
|
||||||
assert(pCreateBuffer != nullptr);
|
assert(pCreateBuffer != nullptr);
|
||||||
|
|
||||||
auto result = pCreateBuffer(context, flags, size, host_ptr, errcode_ret);
|
auto result = pCreateBuffer(context, flags, size, host_ptr, errcode_ret);
|
||||||
if (*errcode_ret != CL_SUCCESS) {
|
if (*errcode_ret != CL_SUCCESS) {
|
||||||
LOG_ERR(MAGENTA_BG_BOLD(WHITE_BOLD_S " ocl ") RED(" error ") RED_BOLD("%s") RED(" when calling ") RED_BOLD("%s") RED(" with buffer size ") RED_BOLD("%zu"),
|
LOG_ERR("%s" RED(" error ") RED_BOLD("%s") RED(" when calling ") RED_BOLD("%s") RED(" with buffer size ") RED_BOLD("%zu"),
|
||||||
OclError::toString(*errcode_ret), kCreateBuffer, size);
|
ocl_tag(), OclError::toString(*errcode_ret), kCreateBuffer, size);
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -495,7 +537,7 @@ cl_mem xmrig::OclLib::createBuffer(cl_context context, cl_mem_flags flags, size_
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cl_program xmrig::OclLib::createProgramWithBinary(cl_context context, cl_uint num_devices, const cl_device_id *device_list, const size_t *lengths, const unsigned char **binaries, cl_int *binary_status, cl_int *errcode_ret)
|
cl_program xmrig::OclLib::createProgramWithBinary(cl_context context, cl_uint num_devices, const cl_device_id *device_list, const size_t *lengths, const unsigned char **binaries, cl_int *binary_status, cl_int *errcode_ret) noexcept
|
||||||
{
|
{
|
||||||
assert(pCreateProgramWithBinary != nullptr);
|
assert(pCreateProgramWithBinary != nullptr);
|
||||||
|
|
||||||
|
@ -510,7 +552,7 @@ cl_program xmrig::OclLib::createProgramWithBinary(cl_context context, cl_uint nu
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cl_program xmrig::OclLib::createProgramWithSource(cl_context context, cl_uint count, const char **strings, const size_t *lengths, cl_int *errcode_ret)
|
cl_program xmrig::OclLib::createProgramWithSource(cl_context context, cl_uint count, const char **strings, const size_t *lengths, cl_int *errcode_ret) noexcept
|
||||||
{
|
{
|
||||||
assert(pCreateProgramWithSource != nullptr);
|
assert(pCreateProgramWithSource != nullptr);
|
||||||
|
|
||||||
|
@ -525,7 +567,7 @@ cl_program xmrig::OclLib::createProgramWithSource(cl_context context, cl_uint co
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cl_uint xmrig::OclLib::getDeviceUint(cl_device_id id, cl_device_info param, cl_uint defaultValue)
|
cl_uint xmrig::OclLib::getDeviceUint(cl_device_id id, cl_device_info param, cl_uint defaultValue) noexcept
|
||||||
{
|
{
|
||||||
OclLib::getDeviceInfo(id, param, sizeof(cl_uint), &defaultValue);
|
OclLib::getDeviceInfo(id, param, sizeof(cl_uint), &defaultValue);
|
||||||
|
|
||||||
|
@ -533,7 +575,7 @@ cl_uint xmrig::OclLib::getDeviceUint(cl_device_id id, cl_device_info param, cl_u
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cl_uint xmrig::OclLib::getNumPlatforms()
|
cl_uint xmrig::OclLib::getNumPlatforms() noexcept
|
||||||
{
|
{
|
||||||
cl_uint count = 0;
|
cl_uint count = 0;
|
||||||
cl_int ret;
|
cl_int ret;
|
||||||
|
@ -550,7 +592,7 @@ cl_uint xmrig::OclLib::getNumPlatforms()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cl_uint xmrig::OclLib::getReferenceCount(cl_program program)
|
cl_uint xmrig::OclLib::getReferenceCount(cl_program program) noexcept
|
||||||
{
|
{
|
||||||
cl_uint out = 0;
|
cl_uint out = 0;
|
||||||
OclLib::getProgramInfo(program, CL_PROGRAM_REFERENCE_COUNT, sizeof(cl_uint), &out);
|
OclLib::getProgramInfo(program, CL_PROGRAM_REFERENCE_COUNT, sizeof(cl_uint), &out);
|
||||||
|
@ -559,7 +601,7 @@ cl_uint xmrig::OclLib::getReferenceCount(cl_program program)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cl_ulong xmrig::OclLib::getDeviceUlong(cl_device_id id, cl_device_info param, cl_ulong defaultValue)
|
cl_ulong xmrig::OclLib::getDeviceUlong(cl_device_id id, cl_device_info param, cl_ulong defaultValue) noexcept
|
||||||
{
|
{
|
||||||
OclLib::getDeviceInfo(id, param, sizeof(cl_ulong), &defaultValue);
|
OclLib::getDeviceInfo(id, param, sizeof(cl_ulong), &defaultValue);
|
||||||
|
|
||||||
|
@ -567,7 +609,7 @@ cl_ulong xmrig::OclLib::getDeviceUlong(cl_device_id id, cl_device_info param, cl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<cl_platform_id> xmrig::OclLib::getPlatformIDs()
|
std::vector<cl_platform_id> xmrig::OclLib::getPlatformIDs() noexcept
|
||||||
{
|
{
|
||||||
const uint32_t count = getNumPlatforms();
|
const uint32_t count = getNumPlatforms();
|
||||||
std::vector<cl_platform_id> platforms(count);
|
std::vector<cl_platform_id> platforms(count);
|
||||||
|
@ -580,7 +622,7 @@ std::vector<cl_platform_id> xmrig::OclLib::getPlatformIDs()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
xmrig::String xmrig::OclLib::getDeviceString(cl_device_id id, cl_device_info param)
|
xmrig::String xmrig::OclLib::getDeviceString(cl_device_id id, cl_device_info param) noexcept
|
||||||
{
|
{
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
if (getDeviceInfo(id, param, 0, nullptr, &size) != CL_SUCCESS) {
|
if (getDeviceInfo(id, param, 0, nullptr, &size) != CL_SUCCESS) {
|
||||||
|
@ -594,7 +636,7 @@ xmrig::String xmrig::OclLib::getDeviceString(cl_device_id id, cl_device_info par
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
xmrig::String xmrig::OclLib::getPlatformInfo(cl_platform_id platform, cl_platform_info param_name)
|
xmrig::String xmrig::OclLib::getPlatformInfo(cl_platform_id platform, cl_platform_info param_name) noexcept
|
||||||
{
|
{
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
if (getPlatformInfo(platform, param_name, 0, nullptr, &size) != CL_SUCCESS) {
|
if (getPlatformInfo(platform, param_name, 0, nullptr, &size) != CL_SUCCESS) {
|
||||||
|
@ -608,7 +650,7 @@ xmrig::String xmrig::OclLib::getPlatformInfo(cl_platform_id platform, cl_platfor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
xmrig::String xmrig::OclLib::getProgramBuildLog(cl_program program, cl_device_id device)
|
xmrig::String xmrig::OclLib::getProgramBuildLog(cl_program program, cl_device_id device) noexcept
|
||||||
{
|
{
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
if (getProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, 0, nullptr, &size) != CL_SUCCESS) {
|
if (getProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, 0, nullptr, &size) != CL_SUCCESS) {
|
||||||
|
|
|
@ -46,38 +46,41 @@ public:
|
||||||
static inline bool isInitialized() { return m_initialized; }
|
static inline bool isInitialized() { return m_initialized; }
|
||||||
static inline const String &loader() { return m_loader; }
|
static inline const String &loader() { return m_loader; }
|
||||||
|
|
||||||
static cl_command_queue createCommandQueue(cl_context context, cl_device_id device, cl_int *errcode_ret);
|
static cl_command_queue createCommandQueue(cl_context context, cl_device_id device, cl_int *errcode_ret) noexcept;
|
||||||
|
static cl_command_queue createCommandQueue(cl_context context, cl_device_id device);
|
||||||
static cl_context createContext(const cl_context_properties *properties, cl_uint num_devices, const cl_device_id *devices, void (CL_CALLBACK *pfn_notify)(const char *, const void *, size_t, void *), void *user_data, cl_int *errcode_ret);
|
static cl_context createContext(const cl_context_properties *properties, cl_uint num_devices, const cl_device_id *devices, void (CL_CALLBACK *pfn_notify)(const char *, const void *, size_t, void *), void *user_data, cl_int *errcode_ret);
|
||||||
static cl_context createContext(const std::vector<cl_device_id> &ids);
|
static cl_context createContext(const std::vector<cl_device_id> &ids);
|
||||||
static cl_int buildProgram(cl_program program, cl_uint num_devices, const cl_device_id *device_list, const char *options = nullptr, void (CL_CALLBACK *pfn_notify)(cl_program program, void *user_data) = nullptr, void *user_data = nullptr);
|
static cl_int buildProgram(cl_program program, cl_uint num_devices, const cl_device_id *device_list, const char *options = nullptr, void (CL_CALLBACK *pfn_notify)(cl_program program, void *user_data) = nullptr, void *user_data = nullptr) noexcept;
|
||||||
static cl_int enqueueNDRangeKernel(cl_command_queue command_queue, cl_kernel kernel, cl_uint work_dim, const size_t *global_work_offset, const size_t *global_work_size, const size_t *local_work_size, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event);
|
static cl_int enqueueNDRangeKernel(cl_command_queue command_queue, cl_kernel kernel, cl_uint work_dim, const size_t *global_work_offset, const size_t *global_work_size, const size_t *local_work_size, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event) noexcept;
|
||||||
static cl_int enqueueReadBuffer(cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, size_t offset, size_t size, void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event);
|
static cl_int enqueueReadBuffer(cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, size_t offset, size_t size, void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event) noexcept;
|
||||||
static cl_int enqueueWriteBuffer(cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write, size_t offset, size_t size, const void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event);
|
static cl_int enqueueWriteBuffer(cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write, size_t offset, size_t size, const void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event) noexcept;
|
||||||
static cl_int finish(cl_command_queue command_queue);
|
static cl_int finish(cl_command_queue command_queue) noexcept;
|
||||||
static cl_int getDeviceIDs(cl_platform_id platform, cl_device_type device_type, cl_uint num_entries, cl_device_id *devices, cl_uint *num_devices);
|
static cl_int getDeviceIDs(cl_platform_id platform, cl_device_type device_type, cl_uint num_entries, cl_device_id *devices, cl_uint *num_devices) noexcept;
|
||||||
static cl_int getDeviceInfo(cl_device_id device, cl_device_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret = nullptr);
|
static cl_int getDeviceInfo(cl_device_id device, cl_device_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret = nullptr) noexcept;
|
||||||
static cl_int getPlatformIDs(cl_uint num_entries, cl_platform_id *platforms, cl_uint *num_platforms);
|
static cl_int getPlatformIDs(cl_uint num_entries, cl_platform_id *platforms, cl_uint *num_platforms);
|
||||||
static cl_int getPlatformInfo(cl_platform_id platform, cl_platform_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret);
|
static cl_int getPlatformInfo(cl_platform_id platform, cl_platform_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret) noexcept;
|
||||||
static cl_int getProgramBuildInfo(cl_program program, cl_device_id device, cl_program_build_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret);
|
static cl_int getProgramBuildInfo(cl_program program, cl_device_id device, cl_program_build_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret) noexcept;
|
||||||
static cl_int getProgramInfo(cl_program program, cl_program_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret = nullptr);
|
static cl_int getProgramInfo(cl_program program, cl_program_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret = nullptr);
|
||||||
static cl_int release(cl_command_queue command_queue);
|
static cl_int release(cl_command_queue command_queue) noexcept;
|
||||||
static cl_int release(cl_context context);
|
static cl_int release(cl_context context) noexcept;
|
||||||
static cl_int release(cl_kernel kernel);
|
static cl_int release(cl_kernel kernel) noexcept;
|
||||||
static cl_int release(cl_mem mem_obj);
|
static cl_int release(cl_mem mem_obj) noexcept;
|
||||||
static cl_int release(cl_program program);
|
static cl_int release(cl_program program) noexcept;
|
||||||
static cl_int setKernelArg(cl_kernel kernel, cl_uint arg_index, size_t arg_size, const void *arg_value);
|
static cl_int setKernelArg(cl_kernel kernel, cl_uint arg_index, size_t arg_size, const void *arg_value) noexcept;
|
||||||
static cl_kernel createKernel(cl_program program, const char *kernel_name, cl_int *errcode_ret);
|
static cl_kernel createKernel(cl_program program, const char *kernel_name, cl_int *errcode_ret) noexcept;
|
||||||
static cl_mem createBuffer(cl_context context, cl_mem_flags flags, size_t size, void *host_ptr, cl_int *errcode_ret);
|
static cl_kernel createKernel(cl_program program, const char *kernel_name);
|
||||||
static cl_program createProgramWithBinary(cl_context context, cl_uint num_devices, const cl_device_id *device_list, const size_t *lengths, const unsigned char **binaries, cl_int *binary_status, cl_int *errcode_ret);
|
static cl_mem createBuffer(cl_context context, cl_mem_flags flags, size_t size, void *host_ptr = nullptr);
|
||||||
static cl_program createProgramWithSource(cl_context context, cl_uint count, const char **strings, const size_t *lengths, cl_int *errcode_ret);
|
static cl_mem createBuffer(cl_context context, cl_mem_flags flags, size_t size, void *host_ptr, cl_int *errcode_ret) noexcept;
|
||||||
static cl_uint getDeviceUint(cl_device_id id, cl_device_info param, cl_uint defaultValue = 0);
|
static cl_program createProgramWithBinary(cl_context context, cl_uint num_devices, const cl_device_id *device_list, const size_t *lengths, const unsigned char **binaries, cl_int *binary_status, cl_int *errcode_ret) noexcept;
|
||||||
static cl_uint getNumPlatforms();
|
static cl_program createProgramWithSource(cl_context context, cl_uint count, const char **strings, const size_t *lengths, cl_int *errcode_ret) noexcept;
|
||||||
static cl_uint getReferenceCount(cl_program program);
|
static cl_uint getDeviceUint(cl_device_id id, cl_device_info param, cl_uint defaultValue = 0) noexcept;
|
||||||
static cl_ulong getDeviceUlong(cl_device_id id, cl_device_info param, cl_ulong defaultValue = 0);
|
static cl_uint getNumPlatforms() noexcept;
|
||||||
static std::vector<cl_platform_id> getPlatformIDs();
|
static cl_uint getReferenceCount(cl_program program) noexcept;
|
||||||
static String getDeviceString(cl_device_id id, cl_device_info param);
|
static cl_ulong getDeviceUlong(cl_device_id id, cl_device_info param, cl_ulong defaultValue = 0) noexcept;
|
||||||
static String getPlatformInfo(cl_platform_id platform, cl_platform_info param_name);
|
static std::vector<cl_platform_id> getPlatformIDs() noexcept;
|
||||||
static String getProgramBuildLog(cl_program program, cl_device_id device);
|
static String getDeviceString(cl_device_id id, cl_device_info param) noexcept;
|
||||||
|
static String getPlatformInfo(cl_platform_id platform, cl_platform_info param_name) noexcept;
|
||||||
|
static String getProgramBuildLog(cl_program program, cl_device_id device) noexcept;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool load();
|
static bool load();
|
||||||
|
|
52
src/base/tools/Object.h
Normal file
52
src/base/tools/Object.h
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XMRIG_OBJECT_H
|
||||||
|
#define XMRIG_OBJECT_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
#define XMRIG_DISABLE_COPY_MOVE(X) \
|
||||||
|
X(const X &other) = delete; \
|
||||||
|
X(X &&other) = delete; \
|
||||||
|
X &operator=(const X &other) = delete; \
|
||||||
|
X &operator=(X &&other) = delete;
|
||||||
|
|
||||||
|
|
||||||
|
#define XMRIG_DISABLE_COPY_MOVE_DEFAULT(X) \
|
||||||
|
X() = delete; \
|
||||||
|
X(const X &other) = delete; \
|
||||||
|
X(X &&other) = delete; \
|
||||||
|
X &operator=(const X &other) = delete; \
|
||||||
|
X &operator=(X &&other) = delete;
|
||||||
|
|
||||||
|
|
||||||
|
} /* namespace xmrig */
|
||||||
|
|
||||||
|
#endif /* XMRIG_OBJECT_H */
|
|
@ -25,17 +25,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <map>
|
#include "crypto/rx/Rx.h"
|
||||||
#include <mutex>
|
|
||||||
#include <thread>
|
|
||||||
#include <uv.h>
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef XMRIG_FEATURE_HWLOC
|
|
||||||
# include <hwloc.h>
|
|
||||||
# include "backend/cpu/platform/HwlocCpuInfo.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#include "backend/common/interfaces/IRxListener.h"
|
#include "backend/common/interfaces/IRxListener.h"
|
||||||
#include "backend/cpu/Cpu.h"
|
#include "backend/cpu/Cpu.h"
|
||||||
|
@ -45,12 +35,24 @@
|
||||||
#include "base/tools/Buffer.h"
|
#include "base/tools/Buffer.h"
|
||||||
#include "base/tools/Chrono.h"
|
#include "base/tools/Chrono.h"
|
||||||
#include "base/tools/Handle.h"
|
#include "base/tools/Handle.h"
|
||||||
#include "crypto/rx/Rx.h"
|
#include "base/tools/Object.h"
|
||||||
#include "crypto/rx/RxAlgo.h"
|
#include "crypto/rx/RxAlgo.h"
|
||||||
#include "crypto/rx/RxCache.h"
|
#include "crypto/rx/RxCache.h"
|
||||||
#include "crypto/rx/RxDataset.h"
|
#include "crypto/rx/RxDataset.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef XMRIG_FEATURE_HWLOC
|
||||||
|
# include <hwloc.h>
|
||||||
|
# include "backend/cpu/platform/HwlocCpuInfo.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <mutex>
|
||||||
|
#include <thread>
|
||||||
|
#include <uv.h>
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,8 +94,9 @@ inline static void bindToNUMANode(uint32_t) {}
|
||||||
class RxPrivate
|
class RxPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
inline RxPrivate() :
|
XMRIG_DISABLE_COPY_MOVE(RxPrivate)
|
||||||
m_seed()
|
|
||||||
|
inline RxPrivate()
|
||||||
{
|
{
|
||||||
m_async = new uv_async_t;
|
m_async = new uv_async_t;
|
||||||
m_async->data = this;
|
m_async->data = this;
|
||||||
|
@ -144,12 +147,12 @@ public:
|
||||||
LOG_INFO("%s" CYAN_BOLD("#%u") MAGENTA_BOLD(" allocate") CYAN_BOLD(" %zu MB") BLACK_BOLD(" (%zu+%zu) for RandomX dataset & cache"),
|
LOG_INFO("%s" CYAN_BOLD("#%u") MAGENTA_BOLD(" allocate") CYAN_BOLD(" %zu MB") BLACK_BOLD(" (%zu+%zu) for RandomX dataset & cache"),
|
||||||
tag,
|
tag,
|
||||||
nodeId,
|
nodeId,
|
||||||
(RxDataset::size() + RxCache::size()) / 1024 / 1024,
|
(RxDataset::maxSize() + RxCache::maxSize()) / 1024 / 1024,
|
||||||
RxDataset::size() / 1024 / 1024,
|
RxDataset::maxSize() / 1024 / 1024,
|
||||||
RxCache::size() / 1024 / 1024
|
RxCache::maxSize() / 1024 / 1024
|
||||||
);
|
);
|
||||||
|
|
||||||
RxDataset *dataset = new RxDataset(d_ptr->m_hugePages);
|
auto dataset = new RxDataset(d_ptr->m_hugePages);
|
||||||
d_ptr->datasets[nodeId] = dataset;
|
d_ptr->datasets[nodeId] = dataset;
|
||||||
|
|
||||||
if (dataset->get() != nullptr) {
|
if (dataset->get() != nullptr) {
|
||||||
|
@ -244,7 +247,7 @@ private:
|
||||||
bool m_numa = true;
|
bool m_numa = true;
|
||||||
IRxListener *m_listener = nullptr;
|
IRxListener *m_listener = nullptr;
|
||||||
size_t m_ready = 0;
|
size_t m_ready = 0;
|
||||||
uint8_t m_seed[32];
|
uint8_t m_seed[32]{ 0 };
|
||||||
uv_async_t *m_async;
|
uv_async_t *m_async;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#define XMRIG_RX_H
|
#define XMRIG_RX_H
|
||||||
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <cstdint>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -47,3 +47,29 @@ xmrig::Algorithm::Id xmrig::RxAlgo::apply(Algorithm::Id algorithm)
|
||||||
|
|
||||||
return algorithm;
|
return algorithm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t xmrig::RxAlgo::version(Algorithm::Id algorithm)
|
||||||
|
{
|
||||||
|
return algorithm == Algorithm::RX_WOW ? 103 : 104;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t xmrig::RxAlgo::programSize(Algorithm::Id algorithm)
|
||||||
|
{
|
||||||
|
switch (algorithm) {
|
||||||
|
case Algorithm::RX_0:
|
||||||
|
return RandomX_MoneroConfig.ProgramSize;
|
||||||
|
|
||||||
|
case Algorithm::RX_WOW:
|
||||||
|
return RandomX_WowneroConfig.ProgramSize;
|
||||||
|
|
||||||
|
case Algorithm::RX_LOKI:
|
||||||
|
return RandomX_LokiConfig.ProgramSize;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -28,8 +28,8 @@
|
||||||
#define XMRIG_RX_ALGO_H
|
#define XMRIG_RX_ALGO_H
|
||||||
|
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <cstddef>
|
||||||
#include <stdint.h>
|
#include <cstdint>
|
||||||
|
|
||||||
|
|
||||||
#include "crypto/common/Algorithm.h"
|
#include "crypto/common/Algorithm.h"
|
||||||
|
@ -43,6 +43,8 @@ class RxAlgo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Algorithm::Id apply(Algorithm::Id algorithm);
|
static Algorithm::Id apply(Algorithm::Id algorithm);
|
||||||
|
static uint32_t programSize(Algorithm::Id algorithm);
|
||||||
|
static uint32_t version(Algorithm::Id algorithm);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#define XMRIG_RX_CACHE_H
|
#define XMRIG_RX_CACHE_H
|
||||||
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <cstdint>
|
||||||
|
|
||||||
|
|
||||||
#include "crypto/randomx/configuration.h"
|
#include "crypto/randomx/configuration.h"
|
||||||
|
@ -55,7 +55,7 @@ public:
|
||||||
|
|
||||||
bool init(const uint8_t *seed);
|
bool init(const uint8_t *seed);
|
||||||
|
|
||||||
static inline constexpr size_t size() { return RANDOMX_CACHE_MAX_SIZE; }
|
static inline constexpr size_t maxSize() { return RANDOMX_CACHE_MAX_SIZE; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isReady(const uint8_t *seed) const;
|
bool isReady(const uint8_t *seed) const;
|
||||||
|
|
|
@ -99,16 +99,16 @@ bool xmrig::RxDataset::init(const uint8_t *seed, uint32_t numThreads)
|
||||||
std::pair<size_t, size_t> xmrig::RxDataset::hugePages() const
|
std::pair<size_t, size_t> xmrig::RxDataset::hugePages() const
|
||||||
{
|
{
|
||||||
constexpr size_t twoMiB = 2u * 1024u * 1024u;
|
constexpr size_t twoMiB = 2u * 1024u * 1024u;
|
||||||
constexpr const size_t total = (VirtualMemory::align(size(), twoMiB) + VirtualMemory::align(RxCache::size(), twoMiB)) / twoMiB;
|
constexpr const size_t total = (VirtualMemory::align(maxSize(), twoMiB) + VirtualMemory::align(RxCache::maxSize(), twoMiB)) / twoMiB;
|
||||||
|
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
if (isHugePages()) {
|
if (isHugePages()) {
|
||||||
count += VirtualMemory::align(size(), twoMiB) / twoMiB;
|
count += VirtualMemory::align(maxSize(), twoMiB) / twoMiB;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_cache->isHugePages()) {
|
if (m_cache->isHugePages()) {
|
||||||
count += VirtualMemory::align(RxCache::size(), twoMiB) / twoMiB;
|
count += VirtualMemory::align(RxCache::maxSize(), twoMiB) / twoMiB;
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::pair<size_t, size_t>(count, total);
|
return { count, total };
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include "crypto/common/Algorithm.h"
|
#include "crypto/common/Algorithm.h"
|
||||||
#include "crypto/randomx/configuration.h"
|
#include "crypto/randomx/configuration.h"
|
||||||
|
#include "base/tools/Object.h"
|
||||||
|
|
||||||
|
|
||||||
struct randomx_dataset;
|
struct randomx_dataset;
|
||||||
|
@ -45,6 +46,8 @@ class RxCache;
|
||||||
class RxDataset
|
class RxDataset
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
XMRIG_DISABLE_COPY_MOVE_DEFAULT(RxDataset)
|
||||||
|
|
||||||
RxDataset(bool hugePages = true);
|
RxDataset(bool hugePages = true);
|
||||||
~RxDataset();
|
~RxDataset();
|
||||||
|
|
||||||
|
@ -55,7 +58,7 @@ public:
|
||||||
bool init(const uint8_t *seed, uint32_t numThreads);
|
bool init(const uint8_t *seed, uint32_t numThreads);
|
||||||
std::pair<size_t, size_t> hugePages() const;
|
std::pair<size_t, size_t> hugePages() const;
|
||||||
|
|
||||||
static inline constexpr size_t size() { return RANDOMX_DATASET_MAX_SIZE; }
|
static inline constexpr size_t maxSize() { return RANDOMX_DATASET_MAX_SIZE; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Algorithm m_algorithm;
|
Algorithm m_algorithm;
|
||||||
|
|
Loading…
Reference in a new issue