mirror of
https://github.com/xmrig/xmrig.git
synced 2025-12-26 06:00:00 -05:00
Merge remote-tracking branch 'remotes/origin/sync-base' into evo
This commit is contained in:
@@ -47,10 +47,6 @@ namespace xmrig {
|
||||
extern bool ocl_generic_rx_generator(const OclDevice &device, const Algorithm &algorithm, OclThreads &threads);
|
||||
#endif
|
||||
|
||||
#ifdef XMRIG_ALGO_ASTROBWT
|
||||
extern bool ocl_generic_astrobwt_generator(const OclDevice& device, const Algorithm& algorithm, OclThreads& threads);
|
||||
#endif
|
||||
|
||||
#ifdef XMRIG_ALGO_KAWPOW
|
||||
extern bool ocl_generic_kawpow_generator(const OclDevice& device, const Algorithm& algorithm, OclThreads& threads);
|
||||
#endif
|
||||
@@ -63,9 +59,6 @@ static ocl_gen_config_fun generators[] = {
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
ocl_generic_rx_generator,
|
||||
# endif
|
||||
# ifdef XMRIG_ALGO_ASTROBWT
|
||||
ocl_generic_astrobwt_generator,
|
||||
# endif
|
||||
# ifdef XMRIG_ALGO_KAWPOW
|
||||
ocl_generic_kawpow_generator,
|
||||
# endif
|
||||
@@ -74,6 +67,28 @@ static ocl_gen_config_fun generators[] = {
|
||||
};
|
||||
|
||||
|
||||
static OclVendor getPlatformVendorId(const String &vendor, const String &extensions)
|
||||
{
|
||||
if (extensions.contains("cl_amd_") || vendor.contains("Advanced Micro Devices") || vendor.contains("AMD")) {
|
||||
return OCL_VENDOR_AMD;
|
||||
}
|
||||
|
||||
if (extensions.contains("cl_nv_") || vendor.contains("NVIDIA")) {
|
||||
return OCL_VENDOR_NVIDIA;
|
||||
}
|
||||
|
||||
if (extensions.contains("cl_intel_") || vendor.contains("Intel")) {
|
||||
return OCL_VENDOR_INTEL;
|
||||
}
|
||||
|
||||
if (extensions.contains("cl_APPLE_") || vendor.contains("Apple")) {
|
||||
return OCL_VENDOR_APPLE;
|
||||
}
|
||||
|
||||
return OCL_VENDOR_UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
static OclVendor getVendorId(const String &vendor)
|
||||
{
|
||||
if (vendor.contains("Advanced Micro Devices") || vendor.contains("AMD")) {
|
||||
@@ -81,19 +96,76 @@ static OclVendor getVendorId(const String &vendor)
|
||||
}
|
||||
|
||||
if (vendor.contains("NVIDIA")) {
|
||||
return OCL_VENDOR_NVIDIA;
|
||||
return OCL_VENDOR_NVIDIA;
|
||||
}
|
||||
|
||||
if (vendor.contains("Intel")) {
|
||||
return OCL_VENDOR_INTEL;
|
||||
}
|
||||
|
||||
if (vendor.contains("Apple")) {
|
||||
return OCL_VENDOR_APPLE;
|
||||
}
|
||||
|
||||
return OCL_VENDOR_UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
static OclDevice::Type getType(const String &name)
|
||||
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;
|
||||
}
|
||||
@@ -118,6 +190,10 @@ static OclDevice::Type getType(const String &name)
|
||||
return OclDevice::Navi_14;
|
||||
}
|
||||
|
||||
if (name == "gfx1030") {
|
||||
return OclDevice::Navi_21;
|
||||
}
|
||||
|
||||
if (name == "gfx804") {
|
||||
return OclDevice::Lexa;
|
||||
}
|
||||
@@ -126,7 +202,11 @@ static OclDevice::Type getType(const String &name)
|
||||
return OclDevice::Baffin;
|
||||
}
|
||||
|
||||
if (name == "gfx803" || name.contains("polaris") || name == "Ellesmere") {
|
||||
if (name.contains("Ellesmere")) {
|
||||
return OclDevice::Ellesmere;
|
||||
}
|
||||
|
||||
if (name == "gfx803" || name.contains("polaris")) {
|
||||
return OclDevice::Polaris;
|
||||
}
|
||||
|
||||
@@ -140,28 +220,31 @@ static OclDevice::Type getType(const String &name)
|
||||
xmrig::OclDevice::OclDevice(uint32_t index, cl_device_id id, cl_platform_id platform) :
|
||||
m_id(id),
|
||||
m_platform(platform),
|
||||
m_board(OclLib::getString(id, 0x4038 /* CL_DEVICE_BOARD_NAME_AMD */)),
|
||||
m_platformVendor(OclLib::getString(platform, CL_PLATFORM_VENDOR)),
|
||||
m_name(OclLib::getString(id, CL_DEVICE_NAME)),
|
||||
m_vendor(OclLib::getString(id, CL_DEVICE_VENDOR)),
|
||||
m_extensions(OclLib::getString(id, CL_DEVICE_EXTENSIONS)),
|
||||
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)
|
||||
{
|
||||
m_vendorId = getVendorId(m_vendor);
|
||||
m_type = getType(m_name);
|
||||
m_platformVendorId = getPlatformVendorId(m_platformVendor, m_extensions);
|
||||
m_type = getType(m_name, m_platformVendorId);
|
||||
|
||||
if (m_vendorId == OCL_VENDOR_AMD) {
|
||||
if (m_extensions.contains("cl_amd_device_attribute_query")) {
|
||||
topology_amd topology;
|
||||
|
||||
if (OclLib::getDeviceInfo(id, 0x4037 /* CL_DEVICE_TOPOLOGY_AMD */, sizeof(topology), &topology, nullptr) == CL_SUCCESS && topology.raw.type == 1) {
|
||||
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));
|
||||
}
|
||||
m_board = OclLib::getString(id, CL_DEVICE_BOARD_NAME_AMD);
|
||||
}
|
||||
else if (m_vendorId == OCL_VENDOR_NVIDIA) {
|
||||
else if (m_extensions.contains("cl_nv_device_attribute_query")) {
|
||||
cl_uint bus = 0;
|
||||
if (OclLib::getDeviceInfo(id, 0x4008 /* CL_DEVICE_PCI_BUS_ID_NV */, sizeof (bus), &bus, nullptr) == CL_SUCCESS) {
|
||||
cl_uint slot = OclLib::getUint(id, 0x4009 /* CL_DEVICE_PCI_SLOT_ID_NV */);
|
||||
if (OclLib::getDeviceInfo(id, CL_DEVICE_PCI_BUS_ID_NV, sizeof (bus), &bus, nullptr) == CL_SUCCESS) {
|
||||
cl_uint slot = OclLib::getUint(id, CL_DEVICE_PCI_SLOT_ID_NV);
|
||||
m_topology = PciTopology(bus, (slot >> 3) & 0xff, slot & 7);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ public:
|
||||
enum Type {
|
||||
Unknown,
|
||||
Baffin,
|
||||
Ellesmere,
|
||||
Polaris,
|
||||
Lexa,
|
||||
Vega_10,
|
||||
@@ -52,7 +53,8 @@ public:
|
||||
Raven,
|
||||
Navi_10,
|
||||
Navi_12,
|
||||
Navi_14
|
||||
Navi_14,
|
||||
Navi_21
|
||||
};
|
||||
|
||||
OclDevice() = delete;
|
||||
@@ -64,11 +66,14 @@ public:
|
||||
|
||||
inline bool isValid() const { return m_id != nullptr && m_platform != nullptr; }
|
||||
inline cl_device_id id() const { return m_id; }
|
||||
inline const String &platformVendor() const { return m_platformVendor; }
|
||||
inline OclVendor platformVendorId() const { return m_vendorId; }
|
||||
inline const PciTopology &topology() const { return m_topology; }
|
||||
inline const String &board() const { return m_board.isNull() ? m_name : m_board; }
|
||||
inline const String &name() const { return m_name; }
|
||||
inline const String &vendor() const { return m_vendor; }
|
||||
inline OclVendor vendorId() const { return m_vendorId; }
|
||||
inline const String &extensions() const { return m_extensions; }
|
||||
inline Type type() const { return m_type; }
|
||||
inline uint32_t computeUnits() const { return m_computeUnits; }
|
||||
inline size_t freeMemSize() const { return std::min(maxMemAllocSize(), globalMemSize()); }
|
||||
@@ -83,13 +88,16 @@ public:
|
||||
private:
|
||||
cl_device_id m_id = nullptr;
|
||||
cl_platform_id m_platform = nullptr;
|
||||
const String m_board;
|
||||
const String m_platformVendor;
|
||||
String m_board;
|
||||
const String m_name;
|
||||
const String m_vendor;
|
||||
String m_extensions;
|
||||
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_platformVendorId = OCL_VENDOR_UNKNOWN;
|
||||
OclVendor m_vendorId = OCL_VENDOR_UNKNOWN;
|
||||
PciTopology m_topology;
|
||||
Type m_type = Unknown;
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
|
||||
#if defined(OCL_DEBUG_REFERENCE_COUNT)
|
||||
# define LOG_REFS(x, ...) xmrig::Log::print(xmrig::Log::WARNING, x, ##__VA_ARGS__)
|
||||
#else
|
||||
# define LOG_REFS(x, ...)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -405,7 +403,7 @@ cl_int xmrig::OclLib::getDeviceInfo(cl_device_id device, cl_device_info param_na
|
||||
assert(pGetDeviceInfo != nullptr);
|
||||
|
||||
const cl_int ret = pGetDeviceInfo(device, param_name, param_value_size, param_value, param_value_size_ret);
|
||||
if (ret != CL_SUCCESS && param_name != 0x4038) {
|
||||
if (ret != CL_SUCCESS && param_name != CL_DEVICE_BOARD_NAME_AMD) {
|
||||
LOG_ERR("Error %s when calling %s, param 0x%04x", OclError::toString(ret), kGetDeviceInfo, param_name);
|
||||
}
|
||||
|
||||
@@ -476,7 +474,9 @@ cl_int xmrig::OclLib::release(cl_command_queue command_queue) noexcept
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
||||
# if defined(OCL_DEBUG_REFERENCE_COUNT)
|
||||
LOG_REFS("%p %u ~queue", command_queue, getUint(command_queue, CL_QUEUE_REFERENCE_COUNT));
|
||||
# endif
|
||||
|
||||
finish(command_queue);
|
||||
|
||||
@@ -493,7 +493,9 @@ cl_int xmrig::OclLib::release(cl_context context) noexcept
|
||||
{
|
||||
assert(pReleaseContext != nullptr);
|
||||
|
||||
# if defined(OCL_DEBUG_REFERENCE_COUNT)
|
||||
LOG_REFS("%p %u ~context", context, getUint(context, CL_CONTEXT_REFERENCE_COUNT));
|
||||
# endif
|
||||
|
||||
const cl_int ret = pReleaseContext(context);
|
||||
if (ret != CL_SUCCESS) {
|
||||
@@ -508,7 +510,9 @@ cl_int xmrig::OclLib::release(cl_device_id id) noexcept
|
||||
{
|
||||
assert(pReleaseDevice != nullptr);
|
||||
|
||||
# if defined(OCL_DEBUG_REFERENCE_COUNT)
|
||||
LOG_REFS("%p %u ~device", id, getUint(id, CL_DEVICE_REFERENCE_COUNT));
|
||||
# endif
|
||||
|
||||
const cl_int ret = pReleaseDevice(id);
|
||||
if (ret != CL_SUCCESS) {
|
||||
@@ -527,7 +531,9 @@ cl_int xmrig::OclLib::release(cl_kernel kernel) noexcept
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
||||
# if defined(OCL_DEBUG_REFERENCE_COUNT)
|
||||
LOG_REFS("%p %u ~kernel %s", kernel, getUint(kernel, CL_KERNEL_REFERENCE_COUNT), getString(kernel, CL_KERNEL_FUNCTION_NAME).data());
|
||||
# endif
|
||||
|
||||
const cl_int ret = pReleaseKernel(kernel);
|
||||
if (ret != CL_SUCCESS) {
|
||||
@@ -546,7 +552,9 @@ cl_int xmrig::OclLib::release(cl_mem mem_obj) noexcept
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
||||
# if defined(OCL_DEBUG_REFERENCE_COUNT)
|
||||
LOG_REFS("%p %u ~mem %zub", mem_obj, getUint(mem_obj, CL_MEM_REFERENCE_COUNT), getUlong(mem_obj, CL_MEM_SIZE));
|
||||
# endif
|
||||
|
||||
const cl_int ret = pReleaseMemObject(mem_obj);
|
||||
if (ret != CL_SUCCESS) {
|
||||
@@ -565,7 +573,9 @@ cl_int xmrig::OclLib::release(cl_program program) noexcept
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
||||
# if defined(OCL_DEBUG_REFERENCE_COUNT)
|
||||
LOG_REFS("%p %u ~program %s", program, getUint(program, CL_PROGRAM_REFERENCE_COUNT), getString(program, CL_PROGRAM_KERNEL_NAMES).data());
|
||||
# endif
|
||||
|
||||
const cl_int ret = pReleaseProgram(program);
|
||||
if (ret != CL_SUCCESS) {
|
||||
|
||||
@@ -26,6 +26,22 @@
|
||||
#include "3rdparty/cl.h"
|
||||
#include "base/tools/String.h"
|
||||
|
||||
#ifndef CL_DEVICE_TOPOLOGY_AMD
|
||||
#define CL_DEVICE_TOPOLOGY_AMD 0x4037
|
||||
#endif
|
||||
#ifndef CL_DEVICE_BOARD_NAME_AMD
|
||||
#define CL_DEVICE_BOARD_NAME_AMD 0x4038
|
||||
#endif
|
||||
#ifndef CL_DEVICE_TOPOLOGY_TYPE_PCIE_AMD
|
||||
#define CL_DEVICE_TOPOLOGY_TYPE_PCIE_AMD 1
|
||||
#endif
|
||||
#ifndef CL_DEVICE_PCI_BUS_ID_NV
|
||||
#define CL_DEVICE_PCI_BUS_ID_NV 0x4008
|
||||
#endif
|
||||
#ifndef CL_DEVICE_PCI_SLOT_ID_NV
|
||||
#define CL_DEVICE_PCI_SLOT_ID_NV 0x4009
|
||||
#endif
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
@@ -33,7 +33,8 @@ enum OclVendor : unsigned {
|
||||
OCL_VENDOR_UNKNOWN,
|
||||
OCL_VENDOR_AMD,
|
||||
OCL_VENDOR_NVIDIA,
|
||||
OCL_VENDOR_INTEL
|
||||
OCL_VENDOR_INTEL,
|
||||
OCL_VENDOR_APPLE
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user