Simplify branch buffers.

This commit is contained in:
XMRig 2019-08-31 09:36:06 +07:00
parent 71329718e4
commit 96f3df3929
2 changed files with 34 additions and 22 deletions

View file

@ -47,10 +47,16 @@ xmrig::OclCnRunner::OclCnRunner(size_t index, const OclLaunchData &data) : OclBa
}
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);
if (ret != CL_SUCCESS) {
return;
}
for (size_t i = 0; i < BRANCH_MAX; ++i) {
m_branches[i] = OclLib::createBuffer(data.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) {
@ -85,10 +91,10 @@ xmrig::OclCnRunner::~OclCnRunner()
OclLib::releaseMemObject(m_scratchpads);
OclLib::releaseMemObject(m_states);
OclLib::releaseMemObject(m_blake256);
OclLib::releaseMemObject(m_groestl256);
OclLib::releaseMemObject(m_jh256);
OclLib::releaseMemObject(m_skein512);
for (size_t i = 0; i < BRANCH_MAX; ++i) {
OclLib::releaseMemObject(m_branches[i]);
}
}
@ -97,10 +103,10 @@ bool xmrig::OclCnRunner::isReadyToBuild() const
return OclBaseRunner::isReadyToBuild() &&
m_scratchpads != nullptr &&
m_states != nullptr &&
m_blake256 != nullptr &&
m_groestl256 != nullptr &&
m_jh256 != nullptr &&
m_skein512 != 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;
}

View file

@ -48,11 +48,17 @@ protected:
void build() override;
private:
cl_mem m_blake256 = nullptr;
cl_mem m_groestl256 = nullptr;
cl_mem m_jh256 = nullptr;
enum Branches : size_t {
BRANCH_BLAKE_256,
BRANCH_GROESTL_256,
BRANCH_JH_256,
BRANCH_SKEIN_512,
BRANCH_MAX
};
cl_mem m_branches[BRANCH_MAX] = { nullptr, nullptr, nullptr, nullptr };
cl_mem m_scratchpads = nullptr;
cl_mem m_skein512 = nullptr;
cl_mem m_states = nullptr;
Cn0Kernel *m_cn0 = nullptr;
};