mirror of
https://github.com/xmrig/xmrig.git
synced 2024-12-23 12:09:22 +00:00
Readjust OclDevice logic and add OCL_VENDOR_APPLE
This commit is contained in:
parent
4bd94a79a4
commit
67e29c1af1
3 changed files with 75 additions and 11 deletions
|
@ -38,6 +38,21 @@ typedef union
|
||||||
struct { cl_uint type; cl_uint data[5]; } raw;
|
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;
|
struct { cl_uint type; cl_char unused[17]; cl_char bus; cl_char device; cl_char function; } pcie;
|
||||||
} topology_amd;
|
} topology_amd;
|
||||||
|
#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 {
|
namespace xmrig {
|
||||||
|
@ -74,6 +89,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)
|
static OclVendor getVendorId(const String &vendor)
|
||||||
{
|
{
|
||||||
if (vendor.contains("Advanced Micro Devices") || vendor.contains("AMD")) {
|
if (vendor.contains("Advanced Micro Devices") || vendor.contains("AMD")) {
|
||||||
|
@ -81,19 +118,36 @@ static OclVendor getVendorId(const String &vendor)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vendor.contains("NVIDIA")) {
|
if (vendor.contains("NVIDIA")) {
|
||||||
return OCL_VENDOR_NVIDIA;
|
return OCL_VENDOR_NVIDIA;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vendor.contains("Intel")) {
|
if (vendor.contains("Intel")) {
|
||||||
return OCL_VENDOR_INTEL;
|
return OCL_VENDOR_INTEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (vendor.contains("Apple")) {
|
||||||
|
return OCL_VENDOR_APPLE;
|
||||||
|
}
|
||||||
|
|
||||||
return OCL_VENDOR_UNKNOWN;
|
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("Pro 5300M")) {
|
||||||
|
return OclDevice::Navi_14;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name.contains("RX 580")) {
|
||||||
|
return OclDevice::Polaris;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (name == "gfx900" || name == "gfx901") {
|
if (name == "gfx900" || name == "gfx901") {
|
||||||
return OclDevice::Vega_10;
|
return OclDevice::Vega_10;
|
||||||
}
|
}
|
||||||
|
@ -140,28 +194,31 @@ static OclDevice::Type getType(const String &name)
|
||||||
xmrig::OclDevice::OclDevice(uint32_t index, cl_device_id id, cl_platform_id platform) :
|
xmrig::OclDevice::OclDevice(uint32_t index, cl_device_id id, cl_platform_id platform) :
|
||||||
m_id(id),
|
m_id(id),
|
||||||
m_platform(platform),
|
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_name(OclLib::getString(id, CL_DEVICE_NAME)),
|
||||||
m_vendor(OclLib::getString(id, CL_DEVICE_VENDOR)),
|
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_maxMemoryAlloc(OclLib::getUlong(id, CL_DEVICE_MAX_MEM_ALLOC_SIZE)),
|
||||||
m_globalMemory(OclLib::getUlong(id, CL_DEVICE_GLOBAL_MEM_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)
|
||||||
{
|
{
|
||||||
m_vendorId = getVendorId(m_vendor);
|
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;
|
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_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;
|
cl_uint bus = 0;
|
||||||
if (OclLib::getDeviceInfo(id, 0x4008 /* 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, nullptr) == CL_SUCCESS) {
|
||||||
cl_uint slot = OclLib::getUint(id, 0x4009 /* CL_DEVICE_PCI_SLOT_ID_NV */);
|
cl_uint slot = OclLib::getUint(id, CL_DEVICE_PCI_SLOT_ID_NV);
|
||||||
m_topology = PciTopology(bus, (slot >> 3) & 0xff, slot & 7);
|
m_topology = PciTopology(bus, (slot >> 3) & 0xff, slot & 7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,11 +64,14 @@ public:
|
||||||
|
|
||||||
inline bool isValid() const { return m_id != nullptr && m_platform != nullptr; }
|
inline bool isValid() const { return m_id != nullptr && m_platform != nullptr; }
|
||||||
inline cl_device_id id() const { return m_id; }
|
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 PciTopology &topology() const { return m_topology; }
|
||||||
inline const String &board() const { return m_board.isNull() ? m_name : m_board; }
|
inline const String &board() const { return m_board.isNull() ? m_name : m_board; }
|
||||||
inline const String &name() const { return m_name; }
|
inline const String &name() const { return m_name; }
|
||||||
inline const String &vendor() const { return m_vendor; }
|
inline const String &vendor() const { return m_vendor; }
|
||||||
inline OclVendor vendorId() const { return m_vendorId; }
|
inline OclVendor vendorId() const { return m_vendorId; }
|
||||||
|
inline const String &extensions() const { return m_extensions; }
|
||||||
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(maxMemAllocSize(), globalMemSize()); }
|
inline size_t freeMemSize() const { return std::min(maxMemAllocSize(), globalMemSize()); }
|
||||||
|
@ -83,13 +86,16 @@ public:
|
||||||
private:
|
private:
|
||||||
cl_device_id m_id = nullptr;
|
cl_device_id m_id = nullptr;
|
||||||
cl_platform_id m_platform = 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_name;
|
||||||
const String m_vendor;
|
const String m_vendor;
|
||||||
|
String m_extensions;
|
||||||
const size_t m_maxMemoryAlloc = 0;
|
const size_t m_maxMemoryAlloc = 0;
|
||||||
const size_t m_globalMemory = 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_platformVendorId = OCL_VENDOR_UNKNOWN;
|
||||||
OclVendor m_vendorId = OCL_VENDOR_UNKNOWN;
|
OclVendor m_vendorId = OCL_VENDOR_UNKNOWN;
|
||||||
PciTopology m_topology;
|
PciTopology m_topology;
|
||||||
Type m_type = Unknown;
|
Type m_type = Unknown;
|
||||||
|
|
|
@ -33,7 +33,8 @@ enum OclVendor : unsigned {
|
||||||
OCL_VENDOR_UNKNOWN,
|
OCL_VENDOR_UNKNOWN,
|
||||||
OCL_VENDOR_AMD,
|
OCL_VENDOR_AMD,
|
||||||
OCL_VENDOR_NVIDIA,
|
OCL_VENDOR_NVIDIA,
|
||||||
OCL_VENDOR_INTEL
|
OCL_VENDOR_INTEL,
|
||||||
|
OCL_VENDOR_APPLE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue