Fixed excessive memory allocation.

This commit is contained in:
XMRig 2019-09-30 08:28:25 +07:00
parent 3560b6a3c2
commit 6bc217e985
3 changed files with 38 additions and 7 deletions

View file

@ -23,10 +23,11 @@
*/
#include "backend/opencl/runners/OclBaseRunner.h"
#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/runners/tools/OclSharedState.h"
#include "backend/opencl/wrappers/OclError.h"
#include "backend/opencl/wrappers/OclLib.h"
#include "base/io/log/Log.h"
@ -34,6 +35,9 @@
#include "crypto/common/VirtualMemory.h"
constexpr size_t oneGiB = 1024 * 1024 * 1024;
xmrig::OclBaseRunner::OclBaseRunner(size_t id, const OclLaunchData &data) :
m_algorithm(data.algorithm),
m_ctx(data.ctx),
@ -93,16 +97,17 @@ void xmrig::OclBaseRunner::build()
void xmrig::OclBaseRunner::init()
{
m_queue = OclLib::createCommandQueue(m_ctx, data().device.id());
m_queue = OclLib::createCommandQueue(m_ctx, data().device.id());
constexpr size_t oneGiB = 1024 * 1024 * 1024;
size_t size = bufferSize();
size_t size = align(bufferSize());
if (size < oneGiB && data().device.vendorId() == OCL_VENDOR_AMD && data().device.freeMemSize() >= oneGiB) {
size = oneGiB;
m_buffer = OclSharedState::get(data().device.index()).createBuffer(m_ctx, size, m_offset);
}
else {
m_buffer = OclLib::createBuffer(m_ctx, CL_MEM_READ_WRITE, size);
}
m_buffer = OclLib::createBuffer(m_ctx, CL_MEM_READ_WRITE, size);
m_input = createSubBuffer(CL_MEM_READ_ONLY | CL_MEM_HOST_WRITE_ONLY, Job::kMaxBlobSize);
m_output = createSubBuffer(CL_MEM_READ_WRITE, sizeof(cl_uint) * 0x100);
}