Restored OclCache.
This commit is contained in:
parent
47b8cb6044
commit
ec1839d580
27 changed files with 290 additions and 72 deletions
|
@ -23,29 +23,49 @@
|
|||
*/
|
||||
|
||||
|
||||
#include "backend/opencl/cl/OclSource.h"
|
||||
#include "backend/opencl/OclCache.h"
|
||||
#include "backend/opencl/OclLaunchData.h"
|
||||
#include "backend/opencl/runners/OclBaseRunner.h"
|
||||
#include "backend/opencl/wrappers/OclLib.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/net/stratum/Job.h"
|
||||
|
||||
|
||||
xmrig::OclBaseRunner::OclBaseRunner(size_t, const OclLaunchData &data) :
|
||||
xmrig::OclBaseRunner::OclBaseRunner(size_t id, const OclLaunchData &data) :
|
||||
m_algorithm(data.algorithm),
|
||||
m_ctx(data.ctx)
|
||||
m_source(OclSource::get(data.algorithm)),
|
||||
m_data(data),
|
||||
m_threadId(id)
|
||||
{
|
||||
cl_int ret;
|
||||
m_queue = OclLib::createCommandQueue(m_ctx, data.device.id(), &ret);
|
||||
m_queue = OclLib::createCommandQueue(data.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_input = OclLib::createBuffer(data.ctx, CL_MEM_READ_ONLY, Job::kMaxBlobSize, nullptr, &ret);
|
||||
m_output = OclLib::createBuffer(data.ctx, CL_MEM_READ_WRITE, sizeof(cl_uint) * 0x100, nullptr, &ret);
|
||||
|
||||
m_deviceKey = data.device.name();
|
||||
|
||||
# ifdef XMRIG_STRICT_OPENCL_CACHE
|
||||
m_deviceKey += ":";
|
||||
m_deviceKey += data.platform.version();
|
||||
|
||||
m_deviceKey += ":";
|
||||
m_deviceKey += OclLib::getDeviceString(data.device.id(), CL_DRIVER_VERSION);
|
||||
# endif
|
||||
|
||||
# if defined(__x86_64__) || defined(_M_AMD64) || defined (__arm64__) || defined (__aarch64__)
|
||||
m_deviceKey += ":64";
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
xmrig::OclBaseRunner::~OclBaseRunner()
|
||||
{
|
||||
OclLib::releaseProgram(m_program);
|
||||
OclLib::releaseMemObject(m_input);
|
||||
OclLib::releaseMemObject(m_output);
|
||||
|
||||
|
@ -55,14 +75,17 @@ xmrig::OclBaseRunner::~OclBaseRunner()
|
|||
|
||||
bool xmrig::OclBaseRunner::selfTest() const
|
||||
{
|
||||
return m_queue != nullptr && m_input != nullptr && m_output != nullptr && !m_options.empty();
|
||||
return m_queue != nullptr && m_input != nullptr && m_output != nullptr && !m_options.empty() && m_source != nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *xmrig::OclBaseRunner::buildOptions() const
|
||||
void xmrig::OclBaseRunner::build()
|
||||
{
|
||||
return m_options.c_str();
|
||||
if (!selfTest()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_program = OclCache::build(this);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -43,21 +43,31 @@ class OclLaunchData;
|
|||
class OclBaseRunner : public IOclRunner
|
||||
{
|
||||
public:
|
||||
OclBaseRunner(size_t index, const OclLaunchData &data);
|
||||
OclBaseRunner(size_t id, const OclLaunchData &data);
|
||||
~OclBaseRunner() override;
|
||||
|
||||
protected:
|
||||
inline const char *buildOptions() const override { return m_options.c_str(); }
|
||||
inline const char *deviceKey() const override { return m_deviceKey.c_str(); }
|
||||
inline const char *source() const override { return m_source; }
|
||||
inline const OclLaunchData &data() const override { return m_data; }
|
||||
inline size_t threadId() const override { return m_threadId; }
|
||||
|
||||
bool selfTest() const override;
|
||||
const char *buildOptions() const override;
|
||||
void build() override;
|
||||
void run(uint32_t *hashOutput) override;
|
||||
void set(const Job &job) override;
|
||||
|
||||
protected:
|
||||
Algorithm m_algorithm;
|
||||
cl_command_queue m_queue = nullptr;
|
||||
cl_context m_ctx;
|
||||
cl_mem m_input = nullptr;
|
||||
cl_mem m_output = nullptr;
|
||||
cl_program m_program = nullptr;
|
||||
const char *m_source;
|
||||
const OclLaunchData &m_data;
|
||||
const size_t m_threadId;
|
||||
std::string m_deviceKey;
|
||||
std::string m_options;
|
||||
};
|
||||
|
||||
|
|
|
@ -38,16 +38,16 @@ xmrig::OclCnRunner::OclCnRunner(size_t index, const OclLaunchData &data) : OclBa
|
|||
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);
|
||||
m_scratchpads = OclLib::createBuffer(data.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);
|
||||
m_blake256 = OclLib::createBuffer(m_ctx, CL_MEM_READ_WRITE, sizeof(cl_uint) * (g_thd + 2), nullptr, &ret);
|
||||
m_groestl256 = OclLib::createBuffer(m_ctx, CL_MEM_READ_WRITE, sizeof(cl_uint) * (g_thd + 2), nullptr, &ret);
|
||||
m_jh256 = OclLib::createBuffer(m_ctx, CL_MEM_READ_WRITE, sizeof(cl_uint) * (g_thd + 2), nullptr, &ret);
|
||||
m_skein512 = OclLib::createBuffer(m_ctx, CL_MEM_READ_WRITE, sizeof(cl_uint) * (g_thd + 2), nullptr, &ret);
|
||||
m_states = OclLib::createBuffer(data.ctx, CL_MEM_READ_WRITE, 200 * g_thd, nullptr, &ret);
|
||||
m_blake256 = OclLib::createBuffer(data.ctx, CL_MEM_READ_WRITE, sizeof(cl_uint) * (g_thd + 2), nullptr, &ret);
|
||||
m_groestl256 = OclLib::createBuffer(data.ctx, CL_MEM_READ_WRITE, sizeof(cl_uint) * (g_thd + 2), nullptr, &ret);
|
||||
m_jh256 = OclLib::createBuffer(data.ctx, CL_MEM_READ_WRITE, sizeof(cl_uint) * (g_thd + 2), nullptr, &ret);
|
||||
m_skein512 = OclLib::createBuffer(data.ctx, CL_MEM_READ_WRITE, sizeof(cl_uint) * (g_thd + 2), nullptr, &ret);
|
||||
|
||||
uint32_t stridedIndex = data.thread.stridedIndex();
|
||||
if (data.device.vendorId() == OCL_VENDOR_NVIDIA) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue