Added support for new CUDA plugin API.

This commit is contained in:
XMRig 2021-08-29 14:22:19 +07:00
parent 838996a0fc
commit 123c7ab140
No known key found for this signature in database
GPG key ID: 446A53638BE94409
3 changed files with 34 additions and 18 deletions

View file

@ -54,6 +54,7 @@ static const char *kAstroBWTHash = "astroBWTHash";
static const char *kAstroBWTPrepare = "astroBWTPrepare";
static const char *kCnHash = "cnHash";
static const char *kDeviceCount = "deviceCount";
static const char *kDeviceInfo = "deviceInfo";
static const char *kDeviceInfo_v2 = "deviceInfo_v2";
static const char *kDeviceInit = "deviceInit";
static const char *kDeviceInt = "deviceInt";
@ -61,14 +62,15 @@ static const char *kDeviceName = "deviceName";
static const char *kDeviceUint = "deviceUint";
static const char *kDeviceUlong = "deviceUlong";
static const char *kInit = "init";
static const char *kKawPowHash = "kawPowHash";
static const char *kKawPowPrepare_v2 = "kawPowPrepare_v2";
static const char *kKawPowStopHash = "kawPowStopHash";
static const char *kLastError = "lastError";
static const char *kPluginVersion = "pluginVersion";
static const char *kRelease = "release";
static const char *kRxHash = "rxHash";
static const char *kRxPrepare = "rxPrepare";
static const char *kKawPowHash = "kawPowHash";
static const char *kKawPowPrepare_v2 = "kawPowPrepare_v2";
static const char *kKawPowStopHash = "kawPowStopHash";
static const char *kSetJob = "setJob";
static const char *kSetJob_v2 = "setJob_v2";
static const char *kVersion = "version";
@ -78,6 +80,7 @@ using astroBWTHash_t = bool (*)(nvid_ctx *, u
using astroBWTPrepare_t = bool (*)(nvid_ctx *, uint32_t);
using cnHash_t = bool (*)(nvid_ctx *, uint32_t, uint64_t, uint64_t, uint32_t *, uint32_t *);
using deviceCount_t = uint32_t (*)();
using deviceInfo_t = bool (*)(nvid_ctx *, int32_t, int32_t, uint32_t, int32_t);
using deviceInfo_v2_t = bool (*)(nvid_ctx *, int32_t, int32_t, const char *, int32_t);
using deviceInit_t = bool (*)(nvid_ctx *);
using deviceInt_t = int32_t (*)(nvid_ctx *, CudaLib::DeviceProperty);
@ -85,14 +88,15 @@ using deviceName_t = const char * (*)(nvid_
using deviceUint_t = uint32_t (*)(nvid_ctx *, CudaLib::DeviceProperty);
using deviceUlong_t = uint64_t (*)(nvid_ctx *, CudaLib::DeviceProperty);
using init_t = void (*)();
using kawPowHash_t = bool (*)(nvid_ctx *, uint8_t*, uint64_t, uint32_t *, uint32_t *, uint32_t *);
using kawPowPrepare_v2_t = bool (*)(nvid_ctx *, const void *, size_t, const void *, size_t, uint32_t, const uint64_t*);
using kawPowStopHash_t = bool (*)(nvid_ctx *);
using lastError_t = const char * (*)(nvid_ctx *);
using pluginVersion_t = const char * (*)();
using release_t = void (*)(nvid_ctx *);
using rxHash_t = bool (*)(nvid_ctx *, uint32_t, uint64_t, uint32_t *, uint32_t *);
using rxPrepare_t = bool (*)(nvid_ctx *, const void *, size_t, bool, uint32_t);
using kawPowHash_t = bool (*)(nvid_ctx *, uint8_t*, uint64_t, uint32_t *, uint32_t *, uint32_t *);
using kawPowPrepare_v2_t = bool (*)(nvid_ctx *, const void *, size_t, const void *, size_t, uint32_t, const uint64_t*);
using kawPowStopHash_t = bool (*)(nvid_ctx *);
using setJob_t = bool (*)(nvid_ctx *, const void *, size_t, uint32_t);
using setJob_v2_t = bool (*)(nvid_ctx *, const void *, size_t, const char *);
using version_t = uint32_t (*)(Version);
@ -102,6 +106,7 @@ static astroBWTHash_t pAstroBWTHash = nullptr;
static astroBWTPrepare_t pAstroBWTPrepare = nullptr;
static cnHash_t pCnHash = nullptr;
static deviceCount_t pDeviceCount = nullptr;
static deviceInfo_t pDeviceInfo = nullptr;
static deviceInfo_v2_t pDeviceInfo_v2 = nullptr;
static deviceInit_t pDeviceInit = nullptr;
static deviceInt_t pDeviceInt = nullptr;
@ -109,14 +114,15 @@ static deviceName_t pDeviceName = nullptr;
static deviceUint_t pDeviceUint = nullptr;
static deviceUlong_t pDeviceUlong = nullptr;
static init_t pInit = nullptr;
static kawPowHash_t pKawPowHash = nullptr;
static kawPowPrepare_v2_t pKawPowPrepare_v2 = nullptr;
static kawPowStopHash_t pKawPowStopHash = nullptr;
static lastError_t pLastError = nullptr;
static pluginVersion_t pPluginVersion = nullptr;
static release_t pRelease = nullptr;
static rxHash_t pRxHash = nullptr;
static rxPrepare_t pRxPrepare = nullptr;
static kawPowHash_t pKawPowHash = nullptr;
static kawPowPrepare_v2_t pKawPowPrepare_v2 = nullptr;
static kawPowStopHash_t pKawPowStopHash = nullptr;
static setJob_t pSetJob = nullptr;
static setJob_v2_t pSetJob_v2 = nullptr;
static version_t pVersion = nullptr;
@ -192,6 +198,10 @@ bool xmrig::CudaLib::deviceInfo(nvid_ctx *ctx, int32_t blocks, int32_t threads,
{
const Algorithm algo = RxAlgo::id(algorithm);
if (pDeviceInfo) {
return pDeviceInfo(ctx, blocks, threads, algo, dataset_host);
}
return pDeviceInfo_v2(ctx, blocks, threads, algo.isValid() ? algo.name() : nullptr, dataset_host);
}
@ -235,6 +245,9 @@ bool xmrig::CudaLib::kawPowStopHash(nvid_ctx *ctx) noexcept
bool xmrig::CudaLib::setJob(nvid_ctx *ctx, const void *data, size_t size, const Algorithm &algorithm) noexcept
{
const Algorithm algo = RxAlgo::id(algorithm);
if (pSetJob) {
return pSetJob(ctx, data, size, algo);
}
return pSetJob_v2(ctx, data, size, algo.name());
}
@ -378,7 +391,8 @@ void xmrig::CudaLib::load()
{
DLSYM(Version);
if (pVersion(ApiVersion) != 3U) {
const uint32_t api = pVersion(ApiVersion);
if (api < 3U || api > 4U) {
throw std::runtime_error("API version mismatch");
}
@ -401,8 +415,15 @@ void xmrig::CudaLib::load()
DLSYM(KawPowHash);
DLSYM(KawPowPrepare_v2);
DLSYM(KawPowStopHash);
DLSYM(DeviceInfo_v2);
DLSYM(SetJob_v2);
if (api == 4U) {
DLSYM(DeviceInfo);
DLSYM(SetJob);
}
else if (api == 3U) {
DLSYM(DeviceInfo_v2);
DLSYM(SetJob_v2);
}
pInit();
}