mirror of
https://github.com/xmrig/xmrig.git
synced 2026-02-01 09:43:03 -05:00
Added OclContext class.
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#include "backend/opencl/OclBackend.h"
|
||||
#include "backend/opencl/OclConfig.h"
|
||||
#include "backend/opencl/OclLaunchData.h"
|
||||
#include "backend/opencl/wrappers/OclContext.h"
|
||||
#include "backend/opencl/wrappers/OclLib.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/net/stratum/Job.h"
|
||||
@@ -119,27 +120,14 @@ 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) {
|
||||
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]();
|
||||
|
||||
if (device.board() == device.name()) {
|
||||
snprintf(name, size, GREEN_BOLD(" %s"), device.name().data());
|
||||
}
|
||||
else {
|
||||
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") 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.hasTopology() ? device.topology().toString().data() : "n/a",
|
||||
device.printableName().data(),
|
||||
device.clock(),
|
||||
device.computeUnits(),
|
||||
static_cast<double>(device.freeMem()) / oneGiB,
|
||||
static_cast<double>(device.globalMem()) / oneGiB);
|
||||
|
||||
delete [] name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,6 +154,7 @@ public:
|
||||
Algorithm algo;
|
||||
Controller *controller;
|
||||
LaunchStatus status;
|
||||
OclContext context;
|
||||
OclPlatform platform;
|
||||
std::mutex mutex;
|
||||
std::vector<OclDevice> devices;
|
||||
@@ -275,6 +264,12 @@ void xmrig::OclBackend::setJob(const Job &job)
|
||||
return stop();
|
||||
}
|
||||
|
||||
if (!d_ptr->context.init(d_ptr->devices, threads)) {
|
||||
LOG_WARN("%s " RED_BOLD("disabled") YELLOW(" (OpenCL context unavailable)"), tag);
|
||||
|
||||
return stop();
|
||||
}
|
||||
|
||||
d_ptr->threads = std::move(threads);
|
||||
d_ptr->start();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user