OpenCL RandomX WIP
This commit is contained in:
parent
ff89ec660c
commit
4c90f9960e
72 changed files with 1717 additions and 505 deletions
|
@ -30,6 +30,7 @@
|
|||
#include "backend/opencl/wrappers/OclLib.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/net/stratum/Job.h"
|
||||
#include "backend/opencl/wrappers/OclError.h"
|
||||
|
||||
|
||||
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_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();
|
||||
|
||||
# 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
|
||||
{
|
||||
return data().thread.index();
|
||||
|
@ -93,9 +73,35 @@ uint32_t xmrig::OclBaseRunner::deviceIndex() const
|
|||
|
||||
void xmrig::OclBaseRunner::build()
|
||||
{
|
||||
if (!isReadyToBuild()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_program = OclCache::build(this);
|
||||
|
||||
if (m_program == nullptr) {
|
||||
throw std::runtime_error(OclError::toString(CL_INVALID_PROGRAM));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
{
|
||||
public:
|
||||
OclBaseRunner() = delete;
|
||||
OclBaseRunner(const OclBaseRunner &other) = delete;
|
||||
OclBaseRunner(OclBaseRunner &&other) = delete;
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(OclBaseRunner)
|
||||
|
||||
OclBaseRunner(size_t id, const OclLaunchData &data);
|
||||
|
||||
~OclBaseRunner() override;
|
||||
|
||||
OclBaseRunner &operator=(const OclBaseRunner &other) = delete;
|
||||
OclBaseRunner &operator=(OclBaseRunner &&other) = delete;
|
||||
|
||||
protected:
|
||||
inline cl_context ctx() const override { return m_ctx; }
|
||||
inline const Algorithm &algorithm() const override { return m_algorithm; }
|
||||
|
@ -62,12 +57,14 @@ protected:
|
|||
inline const OclLaunchData &data() const override { return m_data; }
|
||||
inline size_t threadId() const override { return m_threadId; }
|
||||
|
||||
bool isReadyToBuild() const override;
|
||||
bool selfTest() const override;
|
||||
uint32_t deviceIndex() const override;
|
||||
void build() override;
|
||||
void init() override;
|
||||
|
||||
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;
|
||||
cl_command_queue m_queue = nullptr;
|
||||
cl_context m_ctx;
|
||||
|
|
|
@ -39,30 +39,6 @@
|
|||
|
||||
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();
|
||||
if (data.device.vendorId() == OCL_VENDOR_NVIDIA) {
|
||||
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)
|
||||
{
|
||||
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);
|
||||
|
||||
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) {
|
||||
return false;
|
||||
}
|
||||
enqueueWriteBuffer(m_branches[i], CL_FALSE, sizeof(cl_uint) * g_intensity, sizeof(cl_uint), &zero);
|
||||
}
|
||||
|
||||
if (OclLib::enqueueWriteBuffer(m_queue, m_output, CL_FALSE, sizeof(cl_uint) * 0xFF, sizeof(cl_uint), &zero, 0, nullptr, nullptr) != CL_SUCCESS) {
|
||||
return false;
|
||||
enqueueWriteBuffer(m_output, CL_FALSE, sizeof(cl_uint) * 0xFF, sizeof(cl_uint), &zero);
|
||||
|
||||
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)) {
|
||||
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;
|
||||
}
|
||||
enqueueReadBuffer(m_output, CL_TRUE, 0, sizeof(cl_uint) * 0x100, hashOutput);
|
||||
|
||||
uint32_t &results = hashOutput[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)
|
||||
{
|
||||
if (job.size() > (Job::kMaxBlobSize - 4)) {
|
||||
return false;
|
||||
throw std::length_error("job size too big");
|
||||
}
|
||||
|
||||
blob[job.size()] = 0x01;
|
||||
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) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const uint32_t intensity = data().thread.intensity();
|
||||
|
||||
if (!m_cn0->setArgs(m_input, m_scratchpads, m_states, intensity)) {
|
||||
return false;
|
||||
}
|
||||
enqueueWriteBuffer(m_input, CL_TRUE, 0, Job::kMaxBlobSize, blob);
|
||||
|
||||
if (m_algorithm == Algorithm::CN_R && m_height != job.height()) {
|
||||
delete m_cn1;
|
||||
|
@ -207,20 +133,11 @@ bool xmrig::OclCnRunner::set(const Job &job, uint8_t *blob)
|
|||
m_height = job.height();
|
||||
m_cnr = OclCnR::get(*this, 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)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
for (auto kernel : m_branchKernels) {
|
||||
kernel->setTarget(job.target());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -231,18 +148,38 @@ void xmrig::OclCnRunner::build()
|
|||
{
|
||||
OclBaseRunner::build();
|
||||
|
||||
if (!m_program) {
|
||||
return;
|
||||
}
|
||||
const uint32_t intensity = data().thread.intensity();
|
||||
|
||||
m_cn0 = new Cn0Kernel(m_program);
|
||||
m_cn0->setArgs(m_input, m_scratchpads, m_states, intensity);
|
||||
|
||||
m_cn2 = new Cn2Kernel(m_program);
|
||||
m_cn2->setArgs(m_scratchpads, m_states, m_branches, intensity);
|
||||
|
||||
if (m_algorithm != Algorithm::CN_R) {
|
||||
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) {
|
||||
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
|
||||
{
|
||||
public:
|
||||
OclCnRunner() = delete;
|
||||
OclCnRunner(const OclCnRunner &other) = delete;
|
||||
OclCnRunner(OclCnRunner &&other) = delete;
|
||||
OclCnRunner(size_t index, const OclLaunchData &data);
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(OclCnRunner)
|
||||
|
||||
OclCnRunner(size_t index, const OclLaunchData &data);
|
||||
~OclCnRunner() override;
|
||||
|
||||
OclCnRunner &operator=(const OclCnRunner &other) = delete;
|
||||
OclCnRunner &operator=(OclCnRunner &&other) = delete;
|
||||
|
||||
protected:
|
||||
bool isReadyToBuild() const override;
|
||||
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 init() override;
|
||||
|
||||
private:
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_OCLRXRUNNER_H
|
||||
#define XMRIG_OCLRXRUNNER_H
|
||||
#ifndef XMRIG_OCLRXJITRUNNER_H
|
||||
#define XMRIG_OCLRXJITRUNNER_H
|
||||
|
||||
|
||||
#include "backend/opencl/runners/OclBaseRunner.h"
|
||||
#include "backend/opencl/runners/OclRxBaseRunner.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class OclRxRunner : public OclBaseRunner
|
||||
class OclRxJitRunner : public OclRxBaseRunner
|
||||
{
|
||||
public:
|
||||
OclRxRunner(size_t index, const OclLaunchData &data);
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(OclRxJitRunner)
|
||||
|
||||
OclRxJitRunner(size_t index, const OclLaunchData &data);
|
||||
~OclRxJitRunner() override;
|
||||
|
||||
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;
|
||||
|
||||
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)
|
||||
{
|
||||
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 += " -DMASK=" + std::to_string(CnAlgo<>::mask(m_algorithm)) + "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)
|
||||
{
|
||||
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);
|
||||
|
||||
if (OclLib::enqueueWriteBuffer(m_queue, m_output, CL_FALSE, sizeof(cl_uint) * 0xFF, sizeof(cl_uint), &zero, 0, nullptr, nullptr) != CL_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
enqueueWriteBuffer(m_output, CL_FALSE, sizeof(cl_uint) * 0xFF, sizeof(cl_uint), &zero);
|
||||
|
||||
if (!m_cn0->enqueue(m_queue, nonce, g_thd)) {
|
||||
return false;
|
||||
}
|
||||
m_cn0->enqueue(m_queue, nonce, g_thd);
|
||||
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)) {
|
||||
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;
|
||||
}
|
||||
enqueueReadBuffer(m_output, CL_TRUE, 0, sizeof(cl_uint) * 0x100, hashOutput);
|
||||
|
||||
uint32_t &results = hashOutput[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)
|
||||
{
|
||||
if (job.size() > (Job::kMaxBlobSize - 4)) {
|
||||
|
@ -144,27 +98,9 @@ bool xmrig::OclRyoRunner::set(const Job &job, uint8_t *blob)
|
|||
blob[job.size()] = 0x01;
|
||||
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) {
|
||||
return false;
|
||||
}
|
||||
enqueueWriteBuffer(m_input, CL_TRUE, 0, Job::kMaxBlobSize, blob);
|
||||
|
||||
const uint32_t intensity = data().thread.intensity();
|
||||
|
||||
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;
|
||||
}
|
||||
m_cn2->setTarget(job.target());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -174,12 +110,28 @@ void xmrig::OclRyoRunner::build()
|
|||
{
|
||||
OclBaseRunner::build();
|
||||
|
||||
if (!m_program) {
|
||||
return;
|
||||
}
|
||||
const uint32_t intensity = data().thread.intensity();
|
||||
|
||||
m_cn00 = new Cn00RyoKernel(m_program);
|
||||
m_cn0 = new Cn0Kernel(m_program);
|
||||
m_cn1 = new Cn1RyoKernel(m_program);
|
||||
m_cn2 = new Cn2RyoKernel(m_program);
|
||||
m_cn00->setArgs(m_scratchpads, m_states);
|
||||
|
||||
m_cn0 = new Cn0Kernel(m_program);
|
||||
m_cn0->setArgs(m_input, m_scratchpads, m_states, intensity);
|
||||
|
||||
m_cn1 = new Cn1RyoKernel(m_program);
|
||||
m_cn1->setArgs(m_scratchpads, m_states, intensity);
|
||||
|
||||
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
|
||||
{
|
||||
public:
|
||||
OclRyoRunner() = delete;
|
||||
OclRyoRunner(const OclRyoRunner &other) = delete;
|
||||
OclRyoRunner(OclRyoRunner &&other) = delete;
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(OclRyoRunner)
|
||||
|
||||
OclRyoRunner(size_t index, const OclLaunchData &data);
|
||||
|
||||
~OclRyoRunner() override;
|
||||
|
||||
OclRyoRunner &operator=(const OclRyoRunner &other) = delete;
|
||||
OclRyoRunner &operator=(OclRyoRunner &&other) = delete;
|
||||
|
||||
protected:
|
||||
bool isReadyToBuild() const override;
|
||||
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 init() override;
|
||||
|
||||
private:
|
||||
cl_mem m_scratchpads = nullptr;
|
||||
|
|
|
@ -22,61 +22,20 @@
|
|||
* 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;
|
||||
uint32_t gcn_version = 12;
|
||||
cl_int ret;
|
||||
|
||||
switch (data.thread.worksize()) {
|
||||
case 2:
|
||||
case 4:
|
||||
case 8:
|
||||
case 16:
|
||||
worksize = data.thread.worksize();
|
||||
break;
|
||||
|
||||
default:
|
||||
worksize = 8;
|
||||
if (host) {
|
||||
// TODO use host memory for dataset
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
else {
|
||||
m_dataset = OclLib::createBuffer(ctx, CL_MEM_READ_ONLY, RxDataset::maxSize(), nullptr, &ret);
|
||||
}
|
||||
}
|
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 */
|
Loading…
Add table
Add a link
Reference in a new issue