From 311d3e1c18a9bdfbb5943445d92dca6386332925 Mon Sep 17 00:00:00 2001 From: XMRig Date: Sat, 15 Feb 2020 04:32:32 +0700 Subject: [PATCH] Fixed wrong OpenCL platform on macOS. --- CHANGELOG.md | 1 + src/backend/opencl/OclConfig.cpp | 28 ++++++++++++++++++++++------ src/backend/opencl/OclConfig.h | 8 ++++++-- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 299c3f61e..2c893de86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - [#1551](https://github.com/xmrig/xmrig/pull/1551) Added RandomX JIT for AMD Navi GPUs. - Added health information for AMD GPUs (clocks/power/fan/temperature) via ADL (Windows) and sysfs (Linux). - Fixed possible nicehash nonce overflow in some conditions. +- Fixed wrong OpenCL platform on macOS, option `platform` now ignored on this OS. # v5.5.3 - [#1529](https://github.com/xmrig/xmrig/pull/1529) Fixed crash on Bulldozer CPUs. diff --git a/src/backend/opencl/OclConfig.cpp b/src/backend/opencl/OclConfig.cpp index 3ed5d5434..a90bcc903 100644 --- a/src/backend/opencl/OclConfig.cpp +++ b/src/backend/opencl/OclConfig.cpp @@ -35,14 +35,17 @@ namespace xmrig { -static const char *kAMD = "AMD"; static const char *kCache = "cache"; static const char *kDevicesHint = "devices-hint"; static const char *kEnabled = "enabled"; -static const char *kINTEL = "INTEL"; static const char *kLoader = "loader"; + +#ifndef XMRIG_OS_APPLE +static const char *kAMD = "AMD"; +static const char *kINTEL = "INTEL"; static const char *kNVIDIA = "NVIDIA"; static const char *kPlatform = "platform"; +#endif #ifdef XMRIG_FEATURE_ADL static const char *kAdl = "adl"; @@ -55,10 +58,11 @@ extern template class Threads; } -xmrig::OclConfig::OclConfig() : - m_platformVendor(kAMD) -{ -} +#ifndef XMRIG_OS_APPLE +xmrig::OclConfig::OclConfig() : m_platformVendor(kAMD) {} +#else +xmrig::OclConfig::OclConfig() = default; +#endif xmrig::OclPlatform xmrig::OclConfig::platform() const @@ -68,6 +72,7 @@ xmrig::OclPlatform xmrig::OclConfig::platform() const return {}; } +# ifndef XMRIG_OS_APPLE if (!m_platformVendor.isEmpty()) { String search; String vendor = m_platformVendor; @@ -97,6 +102,9 @@ xmrig::OclPlatform xmrig::OclConfig::platform() const } return {}; +# else + return platforms[0]; +# endif } @@ -110,7 +118,10 @@ rapidjson::Value xmrig::OclConfig::toJSON(rapidjson::Document &doc) const obj.AddMember(StringRef(kEnabled), m_enabled, allocator); obj.AddMember(StringRef(kCache), m_cache, allocator); obj.AddMember(StringRef(kLoader), m_loader.toJSON(), allocator); + +# ifndef XMRIG_OS_APPLE obj.AddMember(StringRef(kPlatform), m_platformVendor.isEmpty() ? Value(m_platformIndex) : m_platformVendor.toJSON(), allocator); +# endif # ifdef XMRIG_FEATURE_ADL obj.AddMember(StringRef(kAdl), m_adl, allocator); @@ -160,7 +171,10 @@ void xmrig::OclConfig::read(const rapidjson::Value &value) m_cache = Json::getBool(value, kCache, m_cache); m_loader = Json::getString(value, kLoader); +# ifndef XMRIG_OS_APPLE setPlatform(Json::getValue(value, kPlatform)); +# endif + setDevicesHint(Json::getString(value, kDevicesHint)); # ifdef XMRIG_FEATURE_ADL @@ -226,6 +240,7 @@ void xmrig::OclConfig::setDevicesHint(const char *devicesHint) } +#ifndef XMRIG_OS_APPLE void xmrig::OclConfig::setPlatform(const rapidjson::Value &platform) { if (platform.IsString()) { @@ -236,3 +251,4 @@ void xmrig::OclConfig::setPlatform(const rapidjson::Value &platform) m_platformIndex = platform.GetUint(); } } +#endif diff --git a/src/backend/opencl/OclConfig.h b/src/backend/opencl/OclConfig.h index 813b1c69e..0aeca97ad 100644 --- a/src/backend/opencl/OclConfig.h +++ b/src/backend/opencl/OclConfig.h @@ -58,16 +58,20 @@ public: private: void generate(); void setDevicesHint(const char *devicesHint); - void setPlatform(const rapidjson::Value &platform); bool m_cache = true; bool m_enabled = false; bool m_shouldSave = false; std::vector m_devicesHint; String m_loader; - String m_platformVendor; Threads m_threads; + +# ifndef XMRIG_OS_APPLE + void setPlatform(const rapidjson::Value &platform); + + String m_platformVendor; uint32_t m_platformIndex = 0; +# endif # ifdef XMRIG_FEATURE_ADL bool m_adl = true;