Implemented option "dataset_host".

This commit is contained in:
XMRig 2019-09-12 13:49:27 +07:00
parent 7f0891a0f0
commit ad7141fe21
5 changed files with 31 additions and 9 deletions

View file

@ -305,7 +305,7 @@ void xmrig::OclBackend::setJob(const Job &job)
return stop();
}
if (!d_ptr->context.init(d_ptr->devices, threads)) {
if (!d_ptr->context.init(d_ptr->devices, threads, job)) {
LOG_WARN("%s " RED_BOLD("disabled") YELLOW(" (OpenCL context unavailable)"), tag);
return stop();

View file

@ -23,19 +23,32 @@
*/
#include "backend/opencl/wrappers/OclLib.h"
#include "backend/opencl/runners/tools/OclRxDataset.h"
#include "backend/opencl/wrappers/OclLib.h"
#include "crypto/rx/Rx.h"
#include "crypto/rx/RxDataset.h"
void xmrig::OclRxDataset::createBuffer(cl_context ctx, const Algorithm &algorithm, bool host)
void xmrig::OclRxDataset::createBuffer(cl_context ctx, const Job &job, bool host)
{
if (m_dataset) {
return;
}
cl_int ret;
if (host) {
// TODO use host memory for dataset
auto dataset = Rx::dataset(job, 0);
m_dataset = OclLib::createBuffer(ctx, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, RxDataset::maxSize(), dataset->raw(), &ret);
}
else {
m_dataset = OclLib::createBuffer(ctx, CL_MEM_READ_ONLY, RxDataset::maxSize(), nullptr, &ret);
}
}
xmrig::OclRxDataset::~OclRxDataset()
{
OclLib::release(m_dataset);
}

View file

@ -26,6 +26,9 @@
#define XMRIG_OCLRXDATASET_H
#include "base/tools/Object.h"
#include <memory>
@ -36,17 +39,20 @@ using cl_mem = struct _cl_mem *;
namespace xmrig {
class Algorithm;
class Job;
class OclRxDataset
{
public:
XMRIG_DISABLE_COPY_MOVE(OclRxDataset)
OclRxDataset() = default;
~OclRxDataset();
inline cl_mem get() const { return m_dataset; }
void createBuffer(cl_context ctx, const Algorithm &algorithm, bool host);
void createBuffer(cl_context ctx,const Job &job, bool host);
private:
cl_mem m_dataset = nullptr;

View file

@ -42,7 +42,7 @@ xmrig::OclContext::~OclContext()
}
bool xmrig::OclContext::init(const std::vector<OclDevice> &devices, std::vector<OclLaunchData> &threads)
bool xmrig::OclContext::init(const std::vector<OclDevice> &devices, std::vector<OclLaunchData> &threads, const Job &job)
{
if (!m_ctx) {
std::vector<cl_device_id> ids(devices.size());
@ -62,7 +62,7 @@ bool xmrig::OclContext::init(const std::vector<OclDevice> &devices, std::vector<
# ifdef XMRIG_ALGO_RANDOMX
if (data.algorithm.family() == Algorithm::RANDOM_X) {
data.dataset->createBuffer(m_ctx, data.algorithm, data.thread.isDatasetHost());
data.dataset->createBuffer(m_ctx, job, data.thread.isDatasetHost());
}
# endif
}

View file

@ -37,6 +37,9 @@ using cl_context = struct _cl_context *;
namespace xmrig {
class Job;
class OclContext
{
public:
@ -46,7 +49,7 @@ public:
OclContext(const OclDevice &device);
~OclContext();
bool init(const std::vector<OclDevice> &devices, std::vector<OclLaunchData> &threads);
bool init(const std::vector<OclDevice> &devices, std::vector<OclLaunchData> &threads, const Job &job);
inline bool isValid() const { return m_ctx != nullptr; }
inline cl_context ctx() const { return m_ctx; }