Print OpenCL platform and devices in summary.
This commit is contained in:
parent
ebdf650450
commit
92bc46f232
3 changed files with 55 additions and 20 deletions
|
@ -55,6 +55,13 @@ extern template class Threads<OclThreads>;
|
||||||
|
|
||||||
static const char *tag = MAGENTA_BG_BOLD(WHITE_BOLD_S " ocl ");
|
static const char *tag = MAGENTA_BG_BOLD(WHITE_BOLD_S " ocl ");
|
||||||
static const String kType = "opencl";
|
static const String kType = "opencl";
|
||||||
|
constexpr const size_t oneGiB = 1024u * 1024u * 1024u;
|
||||||
|
|
||||||
|
|
||||||
|
static void printDisabled(const char *reason)
|
||||||
|
{
|
||||||
|
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") RED_BOLD("disabled") "%s", "OPENCL", reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
struct LaunchStatus
|
struct LaunchStatus
|
||||||
|
@ -87,30 +94,50 @@ public:
|
||||||
inline OclBackendPrivate(Controller *controller) :
|
inline OclBackendPrivate(Controller *controller) :
|
||||||
controller(controller)
|
controller(controller)
|
||||||
{
|
{
|
||||||
|
init(controller->config()->cl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool init(const OclConfig &cl)
|
void init(const OclConfig &cl)
|
||||||
{
|
{
|
||||||
|
if (!cl.isEnabled()) {
|
||||||
|
return printDisabled("");
|
||||||
|
}
|
||||||
|
|
||||||
if (!OclLib::init(cl.loader())) {
|
if (!OclLib::init(cl.loader())) {
|
||||||
LOG_ERR("%s" RED_S " failed to load OpenCL runtime (%s): " RED_BOLD_S "\"%s\"", tag, OclLib::loader().data(), OclLib::lastError());
|
return printDisabled(RED_S " (failed to load OpenCL runtime)");
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!platform.isValid()) {
|
|
||||||
platform = cl.platform();
|
platform = cl.platform();
|
||||||
|
|
||||||
if (!platform.isValid()) {
|
if (!platform.isValid()) {
|
||||||
LOG_ERR("%s" RED_S " selected OpenCL platform NOT found.", tag);
|
return printDisabled(RED_S " (selected OpenCL platform NOT found)");
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO("%s use platform " WHITE_BOLD("%s") "/" WHITE_BOLD("%s"), tag, platform.name().data(), platform.version().data());
|
devices = platform.devices();
|
||||||
|
if (devices.empty()) {
|
||||||
|
return printDisabled(RED_S " (no devices)");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
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]();
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -150,6 +177,7 @@ public:
|
||||||
LaunchStatus status;
|
LaunchStatus status;
|
||||||
OclPlatform platform;
|
OclPlatform platform;
|
||||||
std::mutex mutex;
|
std::mutex mutex;
|
||||||
|
std::vector<OclDevice> devices;
|
||||||
std::vector<OclLaunchData> threads;
|
std::vector<OclLaunchData> threads;
|
||||||
String profileName;
|
String profileName;
|
||||||
Workers<OclLaunchData> workers;
|
Workers<OclLaunchData> workers;
|
||||||
|
@ -176,7 +204,7 @@ xmrig::OclBackend::~OclBackend()
|
||||||
|
|
||||||
bool xmrig::OclBackend::isEnabled() const
|
bool xmrig::OclBackend::isEnabled() const
|
||||||
{
|
{
|
||||||
return d_ptr->controller->config()->cl().isEnabled();
|
return d_ptr->controller->config()->cl().isEnabled() && OclLib::isInitialized() && d_ptr->platform.isValid() && !d_ptr->devices.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -241,9 +269,6 @@ void xmrig::OclBackend::setJob(const Job &job)
|
||||||
}
|
}
|
||||||
|
|
||||||
const OclConfig &cl = d_ptr->controller->config()->cl();
|
const OclConfig &cl = d_ptr->controller->config()->cl();
|
||||||
if (!d_ptr->init(cl)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<OclLaunchData> threads = cl.get(d_ptr->controller->miner(), job.algorithm());
|
std::vector<OclLaunchData> threads = cl.get(d_ptr->controller->miner(), job.algorithm());
|
||||||
// if (d_ptr->threads.size() == threads.size() && std::equal(d_ptr->threads.begin(), d_ptr->threads.end(), threads.begin())) {
|
// if (d_ptr->threads.size() == threads.size() && std::equal(d_ptr->threads.begin(), d_ptr->threads.end(), threads.begin())) {
|
||||||
|
@ -283,6 +308,10 @@ void xmrig::OclBackend::start(IWorker *worker)
|
||||||
|
|
||||||
void xmrig::OclBackend::stop()
|
void xmrig::OclBackend::stop()
|
||||||
{
|
{
|
||||||
|
if (d_ptr->threads.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const uint64_t ts = Chrono::steadyMSecs();
|
const uint64_t ts = Chrono::steadyMSecs();
|
||||||
|
|
||||||
d_ptr->workers.stop();
|
d_ptr->workers.stop();
|
||||||
|
|
|
@ -165,7 +165,7 @@ void xmrig::OclConfig::read(const rapidjson::Value &value)
|
||||||
|
|
||||||
setPlatform(Json::getValue(value, kPlatform));
|
setPlatform(Json::getValue(value, kPlatform));
|
||||||
|
|
||||||
if (!m_threads.read(value)) {
|
if (isEnabled() && !m_threads.read(value)) {
|
||||||
generate();
|
generate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,9 +180,14 @@ void xmrig::OclConfig::read(const rapidjson::Value &value)
|
||||||
|
|
||||||
void xmrig::OclConfig::generate()
|
void xmrig::OclConfig::generate()
|
||||||
{
|
{
|
||||||
OclLib::init(loader());
|
if (!OclLib::init(loader())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const auto devices = platform().devices();
|
const auto devices = platform().devices();
|
||||||
|
if (devices.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_shouldSave = true;
|
m_shouldSave = true;
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ public:
|
||||||
static const char *lastError();
|
static const char *lastError();
|
||||||
static void close();
|
static void close();
|
||||||
|
|
||||||
|
static inline bool isInitialized() { return m_initialized; }
|
||||||
static inline const String &loader() { return m_loader; }
|
static inline const String &loader() { return m_loader; }
|
||||||
|
|
||||||
static cl_command_queue createCommandQueue(cl_context context, cl_device_id device, cl_int *errcode_ret);
|
static cl_command_queue createCommandQueue(cl_context context, cl_device_id device, cl_int *errcode_ret);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue