Extended information about OpenCL devices.

This commit is contained in:
XMRig 2019-08-23 20:19:55 +07:00
parent 92bc46f232
commit 55e12fb34b
5 changed files with 125 additions and 21 deletions

View file

@ -121,22 +121,27 @@ public:
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("#%zu ") WHITE_BOLD("%s") "/" WHITE_BOLD("%s"), "OPENCL", platform.index(), platform.name().data(), platform.version().data());
for (const OclDevice &device : devices) {
char *name = nullptr;
if (device.board() == device.name()) {
const size_t size = device.name().size() + 64;
name = new char[size]();
const String topo = device.hasTopology() ? device.topology().toString() : "n/a";
const size_t size = device.board().size() + device.name().size() + 64;
char *name = new char[size]();
snprintf(name, size, GREEN_BOLD("%s"), device.name().data());
if (device.board() == device.name()) {
snprintf(name, size, GREEN_BOLD(" %s"), device.name().data());
}
else {
const size_t size = device.board().size() + device.name().size() + 64;
name = new char[size]();
snprintf(name, size, GREEN_BOLD("%s") " (" CYAN_BOLD("%s") ")", device.board().data(), device.name().data());
snprintf(name, size, GREEN_BOLD(" %s") " (" CYAN_BOLD("%s") ")", device.board().data(), device.name().data());
}
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("#%zu ") "%s cu:" WHITE_BOLD("%u") " mem:" CYAN("%1.2f/%1.2f") " GB", "OPENCL GPU",
device.index(), name, device.computeUnits(), static_cast<double>(device.freeMem()) / oneGiB, static_cast<double>(device.globalMem()) / oneGiB);
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("#%zu") YELLOW(" %s") "%s " WHITE_BOLD("%uMHz") " cu:" WHITE_BOLD("%u") " mem:" CYAN("%1.2f/%1.2f") " GB", "OPENCL GPU",
device.index(),
topo.data(),
name,
device.clock(),
device.computeUnits(),
static_cast<double>(device.freeMem()) / oneGiB,
static_cast<double>(device.globalMem()) / oneGiB);
delete [] name;
}
}

View file

@ -34,6 +34,13 @@
#include "rapidjson/document.h"
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;
namespace xmrig {
@ -112,6 +119,23 @@ xmrig::OclDevice::OclDevice(uint32_t index, cl_device_id id, cl_platform_id plat
{
m_vendorId = getVendorId(m_vendor);
m_type = getType(m_name);
if (m_vendorId == OCL_VENDOR_AMD) {
topology_amd topology;
if (OclLib::getDeviceInfo(id, 0x4037 /* CL_DEVICE_TOPOLOGY_AMD */, sizeof(topology), &topology, nullptr) == CL_SUCCESS && topology.raw.type == 1) {
m_topology = true;
m_pciTopology = PciTopology(static_cast<uint32_t>(topology.pcie.bus), static_cast<uint32_t>(topology.pcie.device), static_cast<uint32_t>(topology.pcie.function));
}
}
else if (m_vendorId == OCL_VENDOR_NVIDIA) {
cl_uint bus = 0;
if (OclLib::getDeviceInfo(id, 0x4008 /* CL_DEVICE_PCI_BUS_ID_NV */, sizeof (bus), &bus, nullptr) == CL_SUCCESS) {
m_topology = true;
cl_uint slot = OclLib::getDeviceUint(id, 0x4009 /* CL_DEVICE_PCI_SLOT_ID_NV */);
m_pciTopology = PciTopology(bus, (slot >> 3) & 0xff, slot & 7);
}
}
}
@ -127,6 +151,12 @@ size_t xmrig::OclDevice::globalMem() const
}
uint32_t xmrig::OclDevice::clock() const
{
return OclLib::getDeviceUint(id(), CL_DEVICE_MAX_CLOCK_FREQUENCY);
}
void xmrig::OclDevice::generate(const Algorithm &algorithm, OclThreads &threads) const
{
uint32_t intensity = getIntensity(algorithm);

View file

@ -29,6 +29,7 @@
#include <vector>
#include "backend/common/misc/PciTopology.h"
#include "backend/opencl/wrappers/OclVendor.h"
#include "base/tools/String.h"
@ -63,16 +64,19 @@ public:
size_t freeMem() const;
size_t globalMem() const;
uint32_t clock() const;
void generate(const Algorithm &algorithm, OclThreads &threads) const;
inline bool isValid() const { return m_id != nullptr && m_platform != nullptr; }
inline cl_device_id id() const { return m_id; }
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 uint32_t computeUnits() const { return m_computeUnits; }
inline uint32_t index() const { return m_index; }
inline bool hasTopology() const { return m_topology; }
inline bool isValid() const { return m_id != nullptr && m_platform != nullptr; }
inline cl_device_id id() const { return m_id; }
inline const PciTopology &topology() const { return m_pciTopology; }
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 uint32_t computeUnits() const { return m_computeUnits; }
inline uint32_t index() const { return m_index; }
private:
uint32_t getIntensity(const Algorithm &algorithm) const;
@ -82,6 +86,7 @@ private:
uint32_t getStridedIndex(const Algorithm &algorithm) const;
uint32_t getWorksize(const Algorithm &algorithm) const;
bool m_topology = false;
cl_device_id m_id = nullptr;
cl_platform_id m_platform = nullptr;
const String m_board;
@ -90,6 +95,7 @@ private:
const uint32_t m_computeUnits = 1;
const uint32_t m_index = 0;
OclVendor m_vendorId = OCL_VENDOR_UNKNOWN;
PciTopology m_pciTopology;
Type m_type = Unknown;
};