mirror of
https://github.com/xmrig/xmrig.git
synced 2024-11-18 18:11:05 +00:00
Initial stub for setting job in OpenCL backend.
This commit is contained in:
parent
fcfb738ded
commit
aa294ff066
10 changed files with 67 additions and 23 deletions
|
@ -297,6 +297,10 @@ void xmrig::CpuWorker<N>::allocateCnCtx()
|
||||||
template<size_t N>
|
template<size_t N>
|
||||||
void xmrig::CpuWorker<N>::consumeJob()
|
void xmrig::CpuWorker<N>::consumeJob()
|
||||||
{
|
{
|
||||||
|
if (Nonce::sequence(Nonce::CPU) == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_job.add(m_miner->job(), Nonce::sequence(Nonce::CPU), kReserveCount);
|
m_job.add(m_miner->job(), Nonce::sequence(Nonce::CPU), kReserveCount);
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_RANDOMX
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
|
|
|
@ -130,5 +130,10 @@ void xmrig::OclWorker::start()
|
||||||
|
|
||||||
void xmrig::OclWorker::consumeJob()
|
void xmrig::OclWorker::consumeJob()
|
||||||
{
|
{
|
||||||
m_job.add(m_miner->job(), Nonce::sequence(Nonce::OPENCL), kReserveCount);
|
if (Nonce::sequence(Nonce::OPENCL) == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_job.add(m_miner->job(), Nonce::sequence(Nonce::OPENCL), kReserveCount);
|
||||||
|
m_runner->set(m_job.currentJob(), m_job.blob());
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ public:
|
||||||
virtual ~IOclRunner() = default;
|
virtual ~IOclRunner() = default;
|
||||||
|
|
||||||
virtual bool selfTest() const = 0;
|
virtual bool selfTest() const = 0;
|
||||||
|
virtual bool set(const Job &job, uint8_t *blob) = 0;
|
||||||
virtual const char *buildOptions() const = 0;
|
virtual const char *buildOptions() const = 0;
|
||||||
virtual const char *deviceKey() const = 0;
|
virtual const char *deviceKey() const = 0;
|
||||||
virtual const char *source() const = 0;
|
virtual const char *source() const = 0;
|
||||||
|
@ -49,7 +50,9 @@ public:
|
||||||
virtual size_t threadId() const = 0;
|
virtual size_t threadId() const = 0;
|
||||||
virtual void build() = 0;
|
virtual void build() = 0;
|
||||||
virtual void run(uint32_t *hashOutput) = 0;
|
virtual void run(uint32_t *hashOutput) = 0;
|
||||||
virtual void set(const Job &job) = 0;
|
|
||||||
|
protected:
|
||||||
|
virtual bool isReadyToBuild() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -73,15 +73,21 @@ xmrig::OclBaseRunner::~OclBaseRunner()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::OclBaseRunner::selfTest() const
|
bool xmrig::OclBaseRunner::isReadyToBuild() const
|
||||||
{
|
{
|
||||||
return m_queue != nullptr && m_input != nullptr && m_output != nullptr && !m_options.empty() && m_source != nullptr;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::OclBaseRunner::build()
|
void xmrig::OclBaseRunner::build()
|
||||||
{
|
{
|
||||||
if (!selfTest()) {
|
if (!isReadyToBuild()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,9 +99,3 @@ void xmrig::OclBaseRunner::run(uint32_t *hashOutput)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::OclBaseRunner::set(const Job &job)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -53,10 +53,10 @@ 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;
|
bool selfTest() const override;
|
||||||
void build() override;
|
void build() override;
|
||||||
void run(uint32_t *hashOutput) override;
|
void run(uint32_t *hashOutput) override;
|
||||||
void set(const Job &job) override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Algorithm m_algorithm;
|
Algorithm m_algorithm;
|
||||||
|
|
|
@ -23,9 +23,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "backend/opencl/OclLaunchData.h"
|
||||||
#include "backend/opencl/runners/OclCnRunner.h"
|
#include "backend/opencl/runners/OclCnRunner.h"
|
||||||
#include "backend/opencl/wrappers/OclLib.h"
|
#include "backend/opencl/wrappers/OclLib.h"
|
||||||
#include "backend/opencl/OclLaunchData.h"
|
#include "base/io/log/Log.h"
|
||||||
|
#include "base/net/stratum/Job.h"
|
||||||
#include "crypto/cn/CnAlgo.h"
|
#include "crypto/cn/CnAlgo.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,9 +89,9 @@ xmrig::OclCnRunner::~OclCnRunner()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::OclCnRunner::selfTest() const
|
bool xmrig::OclCnRunner::isReadyToBuild() const
|
||||||
{
|
{
|
||||||
return OclBaseRunner::selfTest() &&
|
return OclBaseRunner::isReadyToBuild() &&
|
||||||
m_scratchpads != nullptr &&
|
m_scratchpads != nullptr &&
|
||||||
m_states != nullptr &&
|
m_states != nullptr &&
|
||||||
m_blake256 != nullptr &&
|
m_blake256 != nullptr &&
|
||||||
|
@ -97,3 +99,20 @@ bool xmrig::OclCnRunner::selfTest() const
|
||||||
m_jh256 != nullptr &&
|
m_jh256 != nullptr &&
|
||||||
m_skein512 != nullptr;
|
m_skein512 != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool xmrig::OclCnRunner::set(const Job &job, uint8_t *blob)
|
||||||
|
{
|
||||||
|
if (job.size() > (Job::kMaxBlobSize - 4)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -39,7 +39,8 @@ public:
|
||||||
~OclCnRunner() override;
|
~OclCnRunner() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool selfTest() const override;
|
bool isReadyToBuild() const override;
|
||||||
|
bool set(const Job &job, uint8_t *blob) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
cl_mem m_blake256 = nullptr;
|
cl_mem m_blake256 = nullptr;
|
||||||
|
|
|
@ -34,3 +34,9 @@ bool xmrig::OclRxRunner::selfTest() const
|
||||||
{
|
{
|
||||||
return false; // TODO
|
return false; // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool xmrig::OclRxRunner::set(const Job &job, uint8_t *blob)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool selfTest() const override;
|
bool selfTest() const override;
|
||||||
|
bool set(const Job &job, uint8_t *blob) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -295,7 +295,12 @@ cl_int xmrig::OclLib::enqueueWriteBuffer(cl_command_queue command_queue, cl_mem
|
||||||
{
|
{
|
||||||
assert(pEnqueueWriteBuffer != nullptr);
|
assert(pEnqueueWriteBuffer != nullptr);
|
||||||
|
|
||||||
return pEnqueueWriteBuffer(command_queue, buffer, blocking_write, offset, size, ptr, num_events_in_wait_list, event_wait_list, event);
|
const cl_int ret = pEnqueueWriteBuffer(command_queue, buffer, blocking_write, offset, size, ptr, num_events_in_wait_list, event_wait_list, event);
|
||||||
|
if (ret != CL_SUCCESS) {
|
||||||
|
LOG_ERR(kErrorTemplate, OclError::toString(ret), kEnqueueWriteBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue