Fixes OclDevice::globalMemSize() that sometimes returns 0

This commit is contained in:
Anton Kamenov 2019-10-14 13:34:17 +03:00
parent 5b4026694d
commit ed08895d4a
2 changed files with 9 additions and 21 deletions

View file

@ -132,6 +132,8 @@ xmrig::OclDevice::OclDevice(uint32_t index, cl_device_id id, cl_platform_id plat
m_board(OclLib::getString(id, 0x4038 /* CL_DEVICE_BOARD_NAME_AMD */)), m_board(OclLib::getString(id, 0x4038 /* CL_DEVICE_BOARD_NAME_AMD */)),
m_name(OclLib::getString(id, CL_DEVICE_NAME)), m_name(OclLib::getString(id, CL_DEVICE_NAME)),
m_vendor(OclLib::getString(id, CL_DEVICE_VENDOR)), m_vendor(OclLib::getString(id, CL_DEVICE_VENDOR)),
m_maxMemoryAlloc(OclLib::getUlong(id, CL_DEVICE_MAX_MEM_ALLOC_SIZE)),
m_globalMemory(OclLib::getUlong(id, CL_DEVICE_GLOBAL_MEM_SIZE)),
m_computeUnits(OclLib::getUint(id, CL_DEVICE_MAX_COMPUTE_UNITS, 1)), m_computeUnits(OclLib::getUint(id, CL_DEVICE_MAX_COMPUTE_UNITS, 1)),
m_index(index) m_index(index)
{ {
@ -155,24 +157,6 @@ xmrig::OclDevice::OclDevice(uint32_t index, cl_device_id id, cl_platform_id plat
} }
size_t xmrig::OclDevice::freeMemSize() const
{
return std::min(maxMemAllocSize(), globalMemSize());
}
size_t xmrig::OclDevice::globalMemSize() const
{
return OclLib::getUlong(id(), CL_DEVICE_GLOBAL_MEM_SIZE);
}
size_t xmrig::OclDevice::maxMemAllocSize() const
{
return OclLib::getUlong(id(), CL_DEVICE_MAX_MEM_ALLOC_SIZE);
}
xmrig::String xmrig::OclDevice::printableName() const xmrig::String xmrig::OclDevice::printableName() const
{ {
const size_t size = m_board.size() + m_name.size() + 64; const size_t size = m_board.size() + m_name.size() + 64;

View file

@ -33,6 +33,7 @@
#include "backend/opencl/wrappers/OclVendor.h" #include "backend/opencl/wrappers/OclVendor.h"
#include "base/tools/String.h" #include "base/tools/String.h"
#include <algorithm>
using cl_device_id = struct _cl_device_id *; using cl_device_id = struct _cl_device_id *;
using cl_platform_id = struct _cl_platform_id *; using cl_platform_id = struct _cl_platform_id *;
@ -62,9 +63,6 @@ public:
OclDevice() = delete; OclDevice() = delete;
OclDevice(uint32_t index, cl_device_id id, cl_platform_id platform); OclDevice(uint32_t index, cl_device_id id, cl_platform_id platform);
size_t freeMemSize() const;
size_t globalMemSize() const;
size_t maxMemAllocSize() const;
String printableName() const; String printableName() const;
uint32_t clock() const; uint32_t clock() const;
void generate(const Algorithm &algorithm, OclThreads &threads) const; void generate(const Algorithm &algorithm, OclThreads &threads) const;
@ -78,6 +76,9 @@ public:
inline OclVendor vendorId() const { return m_vendorId; } inline OclVendor vendorId() const { return m_vendorId; }
inline Type type() const { return m_type; } inline Type type() const { return m_type; }
inline uint32_t computeUnits() const { return m_computeUnits; } inline uint32_t computeUnits() const { return m_computeUnits; }
inline size_t freeMemSize() const { return std::min(m_maxMemoryAlloc, m_globalMemory); }
inline size_t globalMemSize() const { return m_globalMemory; }
inline size_t maxMemAllocSize() const { return m_maxMemoryAlloc; }
inline uint32_t index() const { return m_index; } inline uint32_t index() const { return m_index; }
# ifdef XMRIG_FEATURE_API # ifdef XMRIG_FEATURE_API
@ -90,6 +91,9 @@ private:
const String m_board; const String m_board;
const String m_name; const String m_name;
const String m_vendor; const String m_vendor;
const size_t m_freeMemory = 0;
const size_t m_maxMemoryAlloc = 0;
const size_t m_globalMemory = 0;
const uint32_t m_computeUnits = 1; const uint32_t m_computeUnits = 1;
const uint32_t m_index = 0; const uint32_t m_index = 0;
OclVendor m_vendorId = OCL_VENDOR_UNKNOWN; OclVendor m_vendorId = OCL_VENDOR_UNKNOWN;