Implemented CUDA config generation.
This commit is contained in:
parent
77d5b73724
commit
d4a3024996
16 changed files with 208 additions and 42 deletions
|
@ -34,12 +34,11 @@
|
|||
#include <algorithm>
|
||||
|
||||
|
||||
|
||||
xmrig::CudaDevice::CudaDevice(uint32_t index) :
|
||||
xmrig::CudaDevice::CudaDevice(uint32_t index, int32_t bfactor, int32_t bsleep) :
|
||||
m_index(index)
|
||||
{
|
||||
auto ctx = CudaLib::alloc(index, 0, 0, 0, 0, Algorithm::INVALID);
|
||||
if (CudaLib::deviceInfo(ctx) != 0) {
|
||||
auto ctx = CudaLib::alloc(index, bfactor, bsleep);
|
||||
if (CudaLib::deviceInfo(ctx, 0, 0, Algorithm::INVALID) != 0) {
|
||||
CudaLib::release(ctx);
|
||||
|
||||
return;
|
||||
|
@ -105,6 +104,11 @@ uint32_t xmrig::CudaDevice::smx() const
|
|||
|
||||
void xmrig::CudaDevice::generate(const Algorithm &algorithm, CudaThreads &threads) const
|
||||
{
|
||||
if (CudaLib::deviceInfo(m_ctx, -1, -1, algorithm) != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
threads.add(CudaThread(m_index, m_ctx));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
CudaDevice() = delete;
|
||||
CudaDevice(const CudaDevice &other) = delete;
|
||||
CudaDevice(CudaDevice &&other) noexcept;
|
||||
CudaDevice(uint32_t index);
|
||||
CudaDevice(uint32_t index, int32_t bfactor, int32_t bsleep);
|
||||
~CudaDevice();
|
||||
|
||||
size_t freeMemSize() const;
|
||||
|
|
|
@ -58,9 +58,9 @@ static const char *kSymbolNotFound = "symbol not found";
|
|||
static const char *kVersion = "version";
|
||||
|
||||
|
||||
using alloc_t = nvid_ctx * (*)(size_t, int32_t, int32_t, int32_t, int32_t, int32_t);
|
||||
using alloc_t = nvid_ctx * (*)(uint32_t, int32_t, int32_t);
|
||||
using deviceCount_t = uint32_t (*)();
|
||||
using deviceInfo_t = int32_t (*)(nvid_ctx *);
|
||||
using deviceInfo_t = int32_t (*)(nvid_ctx *, int32_t, int32_t, int32_t);
|
||||
using deviceInt_t = int32_t (*)(nvid_ctx *, CudaLib::DeviceProperty);
|
||||
using deviceName_t = const char * (*)(nvid_ctx *);
|
||||
using deviceUint_t = uint32_t (*)(nvid_ctx *, CudaLib::DeviceProperty);
|
||||
|
@ -129,9 +129,9 @@ const char *xmrig::CudaLib::pluginVersion() noexcept
|
|||
}
|
||||
|
||||
|
||||
int xmrig::CudaLib::deviceInfo(nvid_ctx *ctx) noexcept
|
||||
int xmrig::CudaLib::deviceInfo(nvid_ctx *ctx, int32_t blocks, int32_t threads, const Algorithm &algorithm) noexcept
|
||||
{
|
||||
return pDeviceInfo(ctx);
|
||||
return pDeviceInfo(ctx, blocks, threads, algorithm);
|
||||
}
|
||||
|
||||
|
||||
|
@ -141,13 +141,13 @@ int32_t xmrig::CudaLib::deviceInt(nvid_ctx *ctx, DeviceProperty property) noexce
|
|||
}
|
||||
|
||||
|
||||
nvid_ctx *xmrig::CudaLib::alloc(size_t id, int blocks, int threads, int bfactor, int bsleep, const Algorithm &algorithm) noexcept
|
||||
nvid_ctx *xmrig::CudaLib::alloc(uint32_t id, int32_t bfactor, int32_t bsleep) noexcept
|
||||
{
|
||||
return pAlloc(id, blocks, threads, bfactor, bsleep, algorithm);
|
||||
return pAlloc(id, bfactor, bsleep);
|
||||
}
|
||||
|
||||
|
||||
std::vector<xmrig::CudaDevice> xmrig::CudaLib::devices() noexcept
|
||||
std::vector<xmrig::CudaDevice> xmrig::CudaLib::devices(int32_t bfactor, int32_t bsleep) noexcept
|
||||
{
|
||||
const uint32_t count = deviceCount();
|
||||
if (!count) {
|
||||
|
@ -158,7 +158,7 @@ std::vector<xmrig::CudaDevice> xmrig::CudaLib::devices() noexcept
|
|||
out.reserve(count);
|
||||
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
CudaDevice device(i);
|
||||
CudaDevice device(i, bfactor, bsleep);
|
||||
if (device.isValid()) {
|
||||
out.emplace_back(std::move(device));
|
||||
}
|
||||
|
|
|
@ -72,10 +72,10 @@ public:
|
|||
|
||||
static const char *deviceName(nvid_ctx *ctx) noexcept;
|
||||
static const char *pluginVersion() noexcept;
|
||||
static int deviceInfo(nvid_ctx *ctx) noexcept;
|
||||
static int deviceInfo(nvid_ctx *ctx, int32_t blocks, int32_t threads, const Algorithm &algorithm) noexcept;
|
||||
static int32_t deviceInt(nvid_ctx *ctx, DeviceProperty property) noexcept;
|
||||
static nvid_ctx *alloc(size_t id, int blocks, int threads, int bfactor, int bsleep, const Algorithm &algorithm) noexcept;
|
||||
static std::vector<CudaDevice> devices() noexcept;
|
||||
static nvid_ctx *alloc(uint32_t id, int32_t bfactor, int32_t bsleep) noexcept;
|
||||
static std::vector<CudaDevice> devices(int32_t bfactor, int32_t bsleep) noexcept;
|
||||
static uint32_t deviceCount() noexcept;
|
||||
static uint32_t deviceUint(nvid_ctx *ctx, DeviceProperty property) noexcept;
|
||||
static uint32_t driverVersion() noexcept;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue