Compare commits

...

4 Commits
master ... dev

Author SHA1 Message Date
XMRig
cd2fd9d7a6
Simplified getting PCI topology for the OpenCL backend. 2024-11-08 13:03:35 +07:00
XMRig
064cd3ef20
Fixed and simplified OpenCL GPU type detection. 2024-11-08 07:09:35 +07:00
XMRig
e8bbd134f9
v6.22.3-dev 2024-11-03 15:06:54 +07:00
XMRig
cf86a1e05c
Merge branch 'master' into dev 2024-11-03 15:06:22 +07:00
8 changed files with 168 additions and 153 deletions

View File

@ -1,6 +1,6 @@
/* XMRig
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2024 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2024 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -19,10 +19,8 @@
#ifndef XMRIG_PCITOPOLOGY_H
#define XMRIG_PCITOPOLOGY_H
#include <cstdio>
#include "base/tools/String.h"
@ -33,7 +31,14 @@ class PciTopology
{
public:
PciTopology() = default;
PciTopology(uint32_t bus, uint32_t device, uint32_t function) : m_valid(true), m_bus(bus), m_device(device), m_function(function) {}
template<typename T>
inline PciTopology(T bus, T device, T function)
: m_valid(true),
m_bus(static_cast<uint8_t>(bus)),
m_device(static_cast<uint8_t>(device)),
m_function(static_cast<uint8_t>(function))
{}
inline bool isEqual(const PciTopology &other) const { return m_valid == other.m_valid && toUint32() == other.toUint32(); }
inline bool isValid() const { return m_valid; }
@ -70,4 +75,4 @@ private:
} // namespace xmrig
#endif /* XMRIG_PCITOPOLOGY_H */
#endif // XMRIG_PCITOPOLOGY_H

View File

@ -1,6 +1,6 @@
/* XMRig
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2024 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2024 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -227,7 +227,7 @@ public:
# endif
Log::print("|" CYAN_BOLD("%3zu") " |" CYAN_BOLD("%4u") " |" YELLOW(" %7s") " |" CYAN_BOLD("%10d") " |" CYAN_BOLD("%8d") " |"
CYAN_BOLD("%7d") " |" CYAN_BOLD("%3d") " |" CYAN_BOLD("%4d") " |" CYAN("%7zu") " | " GREEN("%s"),
CYAN_BOLD("%7d") " |" CYAN_BOLD("%3d") " |" CYAN_BOLD("%4d") " |" CYAN("%7zu") " | " GREEN_BOLD("%s"),
i,
data.thread.index(),
data.device.topology().toString().data(),

View File

@ -5,8 +5,8 @@
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2024 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2024 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -22,7 +22,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "backend/cuda/wrappers/CudaDevice.h"
#include "3rdparty/rapidjson/document.h"
#include "backend/cuda/CudaThreads.h"
@ -41,7 +40,7 @@
xmrig::CudaDevice::CudaDevice(uint32_t index, int32_t bfactor, int32_t bsleep) :
m_index(index)
{
auto ctx = CudaLib::alloc(index, bfactor, bsleep);
auto *ctx = CudaLib::alloc(index, bfactor, bsleep);
if (!CudaLib::deviceInfo(ctx, 0, 0, Algorithm::INVALID)) {
CudaLib::release(ctx);
@ -50,7 +49,7 @@ xmrig::CudaDevice::CudaDevice(uint32_t index, int32_t bfactor, int32_t bsleep) :
m_ctx = ctx;
m_name = CudaLib::deviceName(ctx);
m_topology = PciTopology(CudaLib::deviceUint(ctx, CudaLib::DevicePciBusID), CudaLib::deviceUint(ctx, CudaLib::DevicePciDeviceID), 0);
m_topology = { CudaLib::deviceUint(ctx, CudaLib::DevicePciBusID), CudaLib::deviceUint(ctx, CudaLib::DevicePciDeviceID), 0U };
}

View File

@ -5,13 +5,7 @@ if (BUILD_STATIC AND XMRIG_OS_UNIX AND WITH_OPENCL)
endif()
if (WITH_OPENCL)
add_definitions(/DXMRIG_FEATURE_OPENCL)
add_definitions(/DCL_USE_DEPRECATED_OPENCL_1_2_APIS)
if (XMRIG_OS_APPLE)
add_definitions(/DCL_TARGET_OPENCL_VERSION=120)
elseif (WITH_OPENCL_VERSION)
add_definitions(/DCL_TARGET_OPENCL_VERSION=${WITH_OPENCL_VERSION})
endif()
add_definitions(/DXMRIG_FEATURE_OPENCL /DCL_USE_DEPRECATED_OPENCL_1_2_APIS)
set(HEADERS_BACKEND_OPENCL
src/backend/opencl/cl/OclSource.h
@ -71,6 +65,13 @@ if (WITH_OPENCL)
src/backend/opencl/wrappers/OclPlatform.cpp
)
if (XMRIG_OS_APPLE)
add_definitions(/DCL_TARGET_OPENCL_VERSION=120)
list(APPEND SOURCES_BACKEND_OPENCL src/backend/opencl/wrappers/OclDevice_mac.cpp)
elseif (WITH_OPENCL_VERSION)
add_definitions(/DCL_TARGET_OPENCL_VERSION=${WITH_OPENCL_VERSION})
endif()
if (WIN32)
list(APPEND SOURCES_BACKEND_OPENCL src/backend/opencl/OclCache_win.cpp)
else()

View File

@ -1,6 +1,7 @@
/* XMRig
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2021 Spudz76 <https://github.com/Spudz76>
* Copyright (c) 2018-2024 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2024 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -17,6 +18,7 @@
*/
#include "backend/opencl/wrappers/OclDevice.h"
#include "3rdparty/fmt/core.h"
#include "3rdparty/rapidjson/document.h"
#include "backend/opencl/OclGenerator.h"
#include "backend/opencl/OclThreads.h"
@ -30,19 +32,21 @@
#include <algorithm>
// NOLINTNEXTLINE(modernize-use-using)
typedef union
{
struct { cl_uint type; cl_uint data[5]; } raw;
struct { cl_uint type; cl_char unused[17]; cl_char bus; cl_char device; cl_char function; } pcie;
} topology_amd;
#include <map>
namespace xmrig {
struct topology_amd {
cl_uint type;
cl_char unused[17];
cl_char bus;
cl_char device;
cl_char function;
};
#ifdef XMRIG_ALGO_RANDOMX
extern bool ocl_generic_rx_generator(const OclDevice &device, const Algorithm &algorithm, OclThreads &threads);
#endif
@ -81,9 +85,11 @@ static OclVendor getPlatformVendorId(const String &vendor, const String &extensi
return OCL_VENDOR_INTEL;
}
# ifdef XMRIG_OS_APPLE
if (extensions.contains("cl_APPLE_") || vendor.contains("Apple")) {
return OCL_VENDOR_APPLE;
}
# endif
return OCL_VENDOR_UNKNOWN;
}
@ -103,117 +109,16 @@ static OclVendor getVendorId(const String &vendor)
return OCL_VENDOR_INTEL;
}
# ifdef XMRIG_OS_APPLE
if (vendor.contains("Apple")) {
return OCL_VENDOR_APPLE;
}
# endif
return OCL_VENDOR_UNKNOWN;
}
static OclDevice::Type getType(const String &name, const OclVendor platformVendorId)
{
if (platformVendorId == OCL_VENDOR_APPLE) {
// Apple Platform: uses product names, not gfx# or codenames
if (name.contains("AMD Radeon")) {
if (name.contains(" 450 ") ||
name.contains(" 455 ") ||
name.contains(" 460 ")) {
return OclDevice::Baffin;
}
if (name.contains(" 555 ") || name.contains(" 555X ") ||
name.contains(" 560 ") || name.contains(" 560X ") ||
name.contains(" 570 ") || name.contains(" 570X ") ||
name.contains(" 575 ") || name.contains(" 575X ")) {
return OclDevice::Polaris;
}
if (name.contains(" 580 ") || name.contains(" 580X ")) {
return OclDevice::Ellesmere;
}
if (name.contains(" Vega ")) {
if (name.contains(" 48 ") ||
name.contains(" 56 ") ||
name.contains(" 64 ") ||
name.contains(" 64X ")) {
return OclDevice::Vega_10;
}
if (name.contains(" 16 ") ||
name.contains(" 20 ") ||
name.contains(" II ")) {
return OclDevice::Vega_20;
}
}
if (name.contains(" 5700 ") || name.contains(" W5700X ")) {
return OclDevice::Navi_10;
}
if (name.contains(" 5600 ") || name.contains(" 5600M ")) {
return OclDevice::Navi_12;
}
if (name.contains(" 5300 ") || name.contains(" 5300M ") ||
name.contains(" 5500 ") || name.contains(" 5500M ")) {
return OclDevice::Navi_14;
}
if (name.contains(" W6800 ") || name.contains(" W6900X ")) {
return OclDevice::Navi_21;
}
}
}
if (name == "gfx900" || name == "gfx901") {
return OclDevice::Vega_10;
}
if (name == "gfx902" || name == "gfx903") {
return OclDevice::Raven;
}
if (name == "gfx906" || name == "gfx907") {
return OclDevice::Vega_20;
}
if (name == "gfx1010") {
return OclDevice::Navi_10;
}
if (name == "gfx1011") {
return OclDevice::Navi_12;
}
if (name == "gfx1012") {
return OclDevice::Navi_14;
}
if (name == "gfx1030") {
return OclDevice::Navi_21;
}
if (name == "gfx804") {
return OclDevice::Lexa;
}
if (name == "Baffin") {
return OclDevice::Baffin;
}
if (name.contains("Ellesmere")) {
return OclDevice::Ellesmere;
}
if (name == "gfx803" || name.contains("polaris")) {
return OclDevice::Polaris;
}
return OclDevice::Unknown;
}
} // namespace xmrig
@ -231,21 +136,21 @@ xmrig::OclDevice::OclDevice(uint32_t index, cl_device_id id, cl_platform_id plat
{
m_vendorId = getVendorId(m_vendor);
m_platformVendorId = getPlatformVendorId(m_platformVendor, m_extensions);
m_type = getType(m_name, m_platformVendorId);
m_type = getType(m_name);
if (m_extensions.contains("cl_amd_device_attribute_query")) {
topology_amd topology;
if (OclLib::getDeviceInfo(id, CL_DEVICE_TOPOLOGY_AMD, sizeof(topology), &topology, nullptr) == CL_SUCCESS && topology.raw.type == CL_DEVICE_TOPOLOGY_TYPE_PCIE_AMD) {
m_topology = PciTopology(static_cast<uint32_t>(topology.pcie.bus), static_cast<uint32_t>(topology.pcie.device), static_cast<uint32_t>(topology.pcie.function));
topology_amd topology{};
if (OclLib::getDeviceInfo(id, CL_DEVICE_TOPOLOGY_AMD, sizeof(topology), &topology) == CL_SUCCESS && topology.type == CL_DEVICE_TOPOLOGY_TYPE_PCIE_AMD) {
m_topology = { topology.bus, topology.device, topology.function };
}
m_board = OclLib::getString(id, CL_DEVICE_BOARD_NAME_AMD);
}
else if (m_extensions.contains("cl_nv_device_attribute_query")) {
cl_uint bus = 0;
if (OclLib::getDeviceInfo(id, CL_DEVICE_PCI_BUS_ID_NV, sizeof (bus), &bus, nullptr) == CL_SUCCESS) {
if (OclLib::getDeviceInfo(id, CL_DEVICE_PCI_BUS_ID_NV, sizeof(bus), &bus) == CL_SUCCESS) {
cl_uint slot = OclLib::getUint(id, CL_DEVICE_PCI_SLOT_ID_NV);
m_topology = PciTopology(bus, (slot >> 3) & 0xff, slot & 7);
m_topology = { bus, (slot >> 3) & 0xff, slot & 7 };
}
}
}
@ -253,17 +158,11 @@ xmrig::OclDevice::OclDevice(uint32_t index, cl_device_id id, cl_platform_id plat
xmrig::String xmrig::OclDevice::printableName() const
{
const size_t size = m_board.size() + m_name.size() + 64;
char *buf = new char[size]();
if (m_board.isNull()) {
snprintf(buf, size, GREEN_BOLD("%s"), m_name.data());
}
else {
snprintf(buf, size, GREEN_BOLD("%s") " (" CYAN_BOLD("%s") ")", m_board.data(), m_name.data());
return fmt::format(GREEN_BOLD("{}"), m_name).c_str();
}
return buf;
return fmt::format(GREEN_BOLD("{}") " (" CYAN_BOLD("{}") ")", m_board, m_name).c_str();
}
@ -311,3 +210,35 @@ void xmrig::OclDevice::toJSON(rapidjson::Value &out, rapidjson::Document &doc) c
# endif
}
#endif
#ifndef XMRIG_OS_APPLE
xmrig::OclDevice::Type xmrig::OclDevice::getType(const String &name)
{
static std::map<const char *, OclDevice::Type> types = {
{ "gfx900", Vega_10 },
{ "gfx901", Vega_10 },
{ "gfx902", Raven },
{ "gfx903", Raven },
{ "gfx906", Vega_20 },
{ "gfx907", Vega_20 },
{ "gfx1010", Navi_10 },
{ "gfx1011", Navi_12 },
{ "gfx1012", Navi_14 },
{ "gfx1030", Navi_21 },
{ "gfx804", Lexa },
{ "Baffin", Baffin },
{ "Ellesmere", Ellesmere },
{ "gfx803", Polaris },
{ "polaris", Polaris },
};
for (auto &kv : types) {
if (name.contains(kv.first)) {
return kv.second;
}
}
return OclDevice::Unknown;
}
#endif

View File

@ -1,6 +1,6 @@
/* XMRig
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2024 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2024 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -86,6 +86,8 @@ public:
# endif
private:
static OclDevice::Type getType(const String &name);
cl_device_id m_id = nullptr;
cl_platform_id m_platform = nullptr;
const String m_platformVendor;

View File

@ -0,0 +1,77 @@
/* XMRig
* Copyright (c) 2021 Spudz76 <https://github.com/Spudz76>
* Copyright (c) 2018-2024 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2024 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "backend/opencl/wrappers/OclDevice.h"
xmrig::OclDevice::Type xmrig::OclDevice::getType(const String &name)
{
// Apple Platform: uses product names, not gfx# or codenames
if (name.contains("AMD Radeon")) {
if (name.contains(" 450 ") ||
name.contains(" 455 ") ||
name.contains(" 460 ")) {
return Baffin;
}
if (name.contains(" 555 ") || name.contains(" 555X ") ||
name.contains(" 560 ") || name.contains(" 560X ") ||
name.contains(" 570 ") || name.contains(" 570X ") ||
name.contains(" 575 ") || name.contains(" 575X ")) {
return Polaris;
}
if (name.contains(" 580 ") || name.contains(" 580X ")) {
return Ellesmere;
}
if (name.contains(" Vega ")) {
if (name.contains(" 48 ") ||
name.contains(" 56 ") ||
name.contains(" 64 ") ||
name.contains(" 64X ")) {
return Vega_10;
}
if (name.contains(" 16 ") ||
name.contains(" 20 ") ||
name.contains(" II ")) {
return Vega_20;
}
}
if (name.contains(" 5700 ") || name.contains(" W5700X ")) {
return Navi_10;
}
if (name.contains(" 5600 ") || name.contains(" 5600M ")) {
return Navi_12;
}
if (name.contains(" 5300 ") || name.contains(" 5300M ") ||
name.contains(" 5500 ") || name.contains(" 5500M ")) {
return Navi_14;
}
if (name.contains(" W6800 ") || name.contains(" W6900X ")) {
return Navi_21;
}
}
return OclDevice::Unknown;
}

View File

@ -22,7 +22,7 @@
#define APP_ID "xmrig"
#define APP_NAME "XMRig"
#define APP_DESC "XMRig miner"
#define APP_VERSION "6.22.2"
#define APP_VERSION "6.22.3-dev"
#define APP_DOMAIN "xmrig.com"
#define APP_SITE "www.xmrig.com"
#define APP_COPYRIGHT "Copyright (C) 2016-2024 xmrig.com"
@ -30,7 +30,7 @@
#define APP_VER_MAJOR 6
#define APP_VER_MINOR 22
#define APP_VER_PATCH 2
#define APP_VER_PATCH 3
#ifdef _MSC_VER
# if (_MSC_VER >= 1930)