Added ADL support for Windows.
This commit is contained in:
parent
264e3928c2
commit
56f23db878
14 changed files with 6395 additions and 83 deletions
|
@ -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-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 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
|
||||
|
@ -27,11 +27,11 @@
|
|||
#include <string>
|
||||
|
||||
|
||||
#include "backend/opencl/OclBackend.h"
|
||||
#include "backend/common/Hashrate.h"
|
||||
#include "backend/common/interfaces/IWorker.h"
|
||||
#include "backend/common/Tags.h"
|
||||
#include "backend/common/Workers.h"
|
||||
#include "backend/opencl/OclBackend.h"
|
||||
#include "backend/opencl/OclConfig.h"
|
||||
#include "backend/opencl/OclLaunchData.h"
|
||||
#include "backend/opencl/OclWorker.h"
|
||||
|
@ -52,6 +52,13 @@
|
|||
#endif
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_ADL
|
||||
#include "backend/opencl/wrappers/AdlLib.h"
|
||||
|
||||
namespace xmrig { static const char *kAdlLabel = "ADL"; }
|
||||
#endif
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
|
@ -59,14 +66,15 @@ extern template class Threads<OclThreads>;
|
|||
|
||||
|
||||
constexpr const size_t oneMiB = 1024U * 1024U;
|
||||
static const char *kLabel = "OPENCL";
|
||||
static const char *tag = MAGENTA_BG_BOLD(WHITE_BOLD_S " ocl ");
|
||||
static const String kType = "opencl";
|
||||
static std::mutex mutex;
|
||||
|
||||
|
||||
static void printDisabled(const char *reason)
|
||||
static void printDisabled(const char *label, const char *reason)
|
||||
{
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") RED_BOLD("disabled") "%s", "OPENCL", reason);
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") RED_BOLD("disabled") "%s", label, reason);
|
||||
}
|
||||
|
||||
|
||||
|
@ -129,11 +137,11 @@ public:
|
|||
void init(const OclConfig &cl)
|
||||
{
|
||||
if (!cl.isEnabled()) {
|
||||
return printDisabled("");
|
||||
return printDisabled(kLabel, "");
|
||||
}
|
||||
|
||||
if (!OclLib::init(cl.loader())) {
|
||||
return printDisabled(RED_S " (failed to load OpenCL runtime)");
|
||||
return printDisabled(kLabel, RED_S " (failed to load OpenCL runtime)");
|
||||
}
|
||||
|
||||
if (platform.isValid()) {
|
||||
|
@ -142,14 +150,30 @@ public:
|
|||
|
||||
platform = cl.platform();
|
||||
if (!platform.isValid()) {
|
||||
return printDisabled(RED_S " (selected OpenCL platform NOT found)");
|
||||
return printDisabled(kLabel, RED_S " (selected OpenCL platform NOT found)");
|
||||
}
|
||||
|
||||
devices = platform.devices();
|
||||
if (devices.empty()) {
|
||||
return printDisabled(RED_S " (no devices)");
|
||||
return printDisabled(kLabel, RED_S " (no devices)");
|
||||
}
|
||||
|
||||
# ifdef XMRIG_FEATURE_ADL
|
||||
if (cl.isAdlEnabled()) {
|
||||
if (AdlLib::init()) {
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") "press " MAGENTA_BG(WHITE_BOLD_S "e") " for health report",
|
||||
kAdlLabel
|
||||
);
|
||||
}
|
||||
else {
|
||||
printDisabled(kAdlLabel, RED_S " (failed to load ADL)");
|
||||
}
|
||||
}
|
||||
else {
|
||||
printDisabled(kAdlLabel, "");
|
||||
}
|
||||
# endif
|
||||
|
||||
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) {
|
||||
|
@ -204,6 +228,32 @@ public:
|
|||
}
|
||||
|
||||
|
||||
# ifdef XMRIG_FEATURE_ADL
|
||||
void printHealth()
|
||||
{
|
||||
if (!AdlLib::isReady()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto &device : devices) {
|
||||
const auto health = AdlLib::health(device);
|
||||
|
||||
LOG_INFO("%s" CYAN_BOLD(" #%u") YELLOW(" %s") MAGENTA_BOLD("%4uW") CSI "1;%um %2uC" CYAN_BOLD(" %4u") CYAN("RPM") WHITE_BOLD(" %u/%u") "MHz",
|
||||
tag,
|
||||
device.index(),
|
||||
device.topology().toString().data(),
|
||||
health.power,
|
||||
health.temperature < 60 ? 32 : (health.temperature > 85 ? 31 : 33),
|
||||
health.temperature,
|
||||
health.rpm,
|
||||
health.clock,
|
||||
health.memClock
|
||||
);
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
|
||||
Algorithm algo;
|
||||
Controller *controller;
|
||||
OclContext context;
|
||||
|
@ -237,6 +287,10 @@ xmrig::OclBackend::~OclBackend()
|
|||
delete d_ptr;
|
||||
|
||||
OclLib::close();
|
||||
|
||||
# ifdef XMRIG_FEATURE_ADL
|
||||
AdlLib::close();
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -270,6 +324,16 @@ const xmrig::String &xmrig::OclBackend::type() const
|
|||
}
|
||||
|
||||
|
||||
void xmrig::OclBackend::execCommand(char command)
|
||||
{
|
||||
# ifdef XMRIG_FEATURE_ADL
|
||||
if (command == 'e' || command == 'E') {
|
||||
d_ptr->printHealth();
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
void xmrig::OclBackend::prepare(const Job &)
|
||||
{
|
||||
}
|
||||
|
@ -385,6 +449,15 @@ void xmrig::OclBackend::stop()
|
|||
void xmrig::OclBackend::tick(uint64_t ticks)
|
||||
{
|
||||
d_ptr->workers.tick(ticks);
|
||||
|
||||
# ifdef XMRIG_FEATURE_ADL
|
||||
if (isEnabled()) {
|
||||
auto seconds = d_ptr->controller->config()->healthPrintTime();
|
||||
if (seconds && ticks && (ticks % (seconds * 2)) == 0) {
|
||||
d_ptr->printHealth();
|
||||
}
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue