From ed08895d4a5243b3fe588b297c16080c8d851c5d Mon Sep 17 00:00:00 2001 From: Anton Kamenov Date: Mon, 14 Oct 2019 13:34:17 +0300 Subject: [PATCH] Fixes OclDevice::globalMemSize() that sometimes returns 0 --- src/backend/opencl/wrappers/OclDevice.cpp | 20 ++------------------ src/backend/opencl/wrappers/OclDevice.h | 10 +++++++--- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/opencl/wrappers/OclDevice.cpp b/src/backend/opencl/wrappers/OclDevice.cpp index 67f8166b5..14e815608 100644 --- a/src/backend/opencl/wrappers/OclDevice.cpp +++ b/src/backend/opencl/wrappers/OclDevice.cpp @@ -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_name(OclLib::getString(id, CL_DEVICE_NAME)), 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_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 { const size_t size = m_board.size() + m_name.size() + 64; diff --git a/src/backend/opencl/wrappers/OclDevice.h b/src/backend/opencl/wrappers/OclDevice.h index 3be58ed22..faf03b667 100644 --- a/src/backend/opencl/wrappers/OclDevice.h +++ b/src/backend/opencl/wrappers/OclDevice.h @@ -33,6 +33,7 @@ #include "backend/opencl/wrappers/OclVendor.h" #include "base/tools/String.h" +#include using cl_device_id = struct _cl_device_id *; using cl_platform_id = struct _cl_platform_id *; @@ -62,9 +63,6 @@ public: OclDevice() = delete; 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; uint32_t clock() const; void generate(const Algorithm &algorithm, OclThreads &threads) const; @@ -78,6 +76,9 @@ public: inline OclVendor vendorId() const { return m_vendorId; } inline Type type() const { return m_type; } 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; } # ifdef XMRIG_FEATURE_API @@ -90,6 +91,9 @@ private: const String m_board; const String m_name; 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_index = 0; OclVendor m_vendorId = OCL_VENDOR_UNKNOWN;