mirror of
https://github.com/xmrig/xmrig.git
synced 2024-11-18 10:01:06 +00:00
Implemented option "dataset_host".
This commit is contained in:
parent
7f0891a0f0
commit
ad7141fe21
5 changed files with 31 additions and 9 deletions
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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; }
|
||||
|
|
Loading…
Reference in a new issue