KawPow WIP
This commit is contained in:
parent
07025dc41b
commit
22b937cc1c
88 changed files with 11004 additions and 8383 deletions
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include "backend/cuda/wrappers/CudaLib.h"
|
||||
#include "base/io/Env.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "crypto/rx/RxAlgo.h"
|
||||
|
||||
|
||||
|
@ -64,9 +65,10 @@ 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 = "KawPowPrepare";
|
||||
static const char *kSetJob = "setJob";
|
||||
static const char *kSetJob_v2 = "setJob_v2";
|
||||
static const char *kSymbolNotFound = "symbol not found";
|
||||
static const char *kVersion = "version";
|
||||
|
||||
|
||||
|
@ -88,6 +90,8 @@ 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 *);
|
||||
using KawPowPrepare_t = bool (*)(nvid_ctx *, const void *, size_t, size_t, uint32_t, const uint64_t*);
|
||||
using setJob_t = bool (*)(nvid_ctx *, const void *, size_t, int32_t);
|
||||
using setJob_v2_t = bool (*)(nvid_ctx *, const void *, size_t, const char *);
|
||||
using version_t = uint32_t (*)(Version);
|
||||
|
@ -111,12 +115,14 @@ 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_t pKawPowPrepare = nullptr;
|
||||
static setJob_t pSetJob = nullptr;
|
||||
static setJob_v2_t pSetJob_v2 = nullptr;
|
||||
static version_t pVersion = nullptr;
|
||||
|
||||
|
||||
#define DLSYM(x) if (uv_dlsym(&cudaLib, k##x, reinterpret_cast<void**>(&p##x)) == -1) { throw std::runtime_error(kSymbolNotFound); }
|
||||
#define DLSYM(x) if (uv_dlsym(&cudaLib, k##x, reinterpret_cast<void**>(&p##x)) == -1) { throw std::runtime_error("symbol not found (" #x ")"); }
|
||||
|
||||
|
||||
bool CudaLib::m_initialized = false;
|
||||
|
@ -199,6 +205,18 @@ bool xmrig::CudaLib::rxPrepare(nvid_ctx *ctx, const void *dataset, size_t datase
|
|||
}
|
||||
|
||||
|
||||
bool xmrig::CudaLib::KawPowHash(nvid_ctx *ctx, uint8_t* job_blob, uint64_t target, uint32_t *rescount, uint32_t *resnonce) noexcept
|
||||
{
|
||||
return pKawPowHash(ctx, job_blob, target, rescount, resnonce);
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::CudaLib::KawPowPrepare(nvid_ctx *ctx, const void* cache, size_t cache_size, size_t dag_size, uint32_t height, const uint64_t* dag_sizes) noexcept
|
||||
{
|
||||
return pKawPowPrepare(ctx, cache, cache_size, dag_size, height, dag_sizes);
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::CudaLib::setJob(nvid_ctx *ctx, const void *data, size_t size, const Algorithm &algorithm) noexcept
|
||||
{
|
||||
const Algorithm algo = RxAlgo::id(algorithm);
|
||||
|
@ -323,7 +341,7 @@ bool xmrig::CudaLib::load()
|
|||
return false;
|
||||
}
|
||||
|
||||
if (pVersion(ApiVersion) != 3u) {
|
||||
if (pVersion(ApiVersion) != 6u) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -347,6 +365,8 @@ bool xmrig::CudaLib::load()
|
|||
DLSYM(RxPrepare);
|
||||
DLSYM(AstroBWTHash);
|
||||
DLSYM(AstroBWTPrepare);
|
||||
DLSYM(KawPowHash);
|
||||
DLSYM(KawPowPrepare);
|
||||
DLSYM(Version);
|
||||
|
||||
if (!pDeviceInfo_v2) {
|
||||
|
@ -357,6 +377,7 @@ bool xmrig::CudaLib::load()
|
|||
DLSYM(SetJob);
|
||||
}
|
||||
} catch (std::exception &ex) {
|
||||
LOG_ERR("Error loading CUDA library: %s", ex.what());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue