Added VAES support for Cryptonight variants
This commit is contained in:
parent
c40f1f9f66
commit
a4d5d0a75a
14 changed files with 749 additions and 40 deletions
|
@ -161,14 +161,14 @@ bool xmrig::CpuWorker<N>::selfTest()
|
|||
}
|
||||
# endif
|
||||
|
||||
allocateCnCtx();
|
||||
|
||||
# ifdef XMRIG_ALGO_GHOSTRIDER
|
||||
if (m_algorithm.family() == Algorithm::GHOSTRIDER) {
|
||||
return N == 8;
|
||||
return (N == 8) && verify(Algorithm::GHOSTRIDER_RTM, test_output_gr);
|
||||
}
|
||||
# endif
|
||||
|
||||
allocateCnCtx();
|
||||
|
||||
if (m_algorithm.family() == Algorithm::CN) {
|
||||
const bool rc = verify(Algorithm::CN_0, test_output_v0) &&
|
||||
verify(Algorithm::CN_1, test_output_v1) &&
|
||||
|
@ -397,6 +397,37 @@ bool xmrig::CpuWorker<N>::nextRound()
|
|||
template<size_t N>
|
||||
bool xmrig::CpuWorker<N>::verify(const Algorithm &algorithm, const uint8_t *referenceValue)
|
||||
{
|
||||
# ifdef XMRIG_ALGO_GHOSTRIDER
|
||||
if (algorithm == Algorithm::GHOSTRIDER_RTM) {
|
||||
uint8_t blob[N * 80] = {};
|
||||
for (size_t i = 0; i < N; ++i) {
|
||||
blob[i * 80 + 0] = static_cast<uint8_t>(i);
|
||||
blob[i * 80 + 4] = 0x10;
|
||||
blob[i * 80 + 5] = 0x02;
|
||||
}
|
||||
|
||||
uint8_t hash1[N * 32] = {};
|
||||
ghostrider::hash_octa(blob, 80, hash1, m_ctx, 0, false);
|
||||
|
||||
for (size_t i = 0; i < N; ++i) {
|
||||
blob[i * 80 + 0] = static_cast<uint8_t>(i);
|
||||
blob[i * 80 + 4] = 0x43;
|
||||
blob[i * 80 + 5] = 0x05;
|
||||
}
|
||||
|
||||
uint8_t hash2[N * 32] = {};
|
||||
ghostrider::hash_octa(blob, 80, hash2, m_ctx, 0, false);
|
||||
|
||||
for (size_t i = 0; i < N * 32; ++i) {
|
||||
if ((hash1[i] ^ hash2[i]) != referenceValue[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
# endif
|
||||
|
||||
cn_hash_fun func = fn(algorithm);
|
||||
if (!func) {
|
||||
return false;
|
||||
|
|
|
@ -61,6 +61,7 @@ public:
|
|||
|
||||
enum Flag : uint32_t {
|
||||
FLAG_AES,
|
||||
FLAG_VAES,
|
||||
FLAG_AVX,
|
||||
FLAG_AVX2,
|
||||
FLAG_AVX512F,
|
||||
|
@ -90,6 +91,7 @@ public:
|
|||
virtual Assembly::Id assembly() const = 0;
|
||||
virtual bool has(Flag feature) const = 0;
|
||||
virtual bool hasAES() const = 0;
|
||||
virtual bool hasVAES() const = 0;
|
||||
virtual bool hasAVX() const = 0;
|
||||
virtual bool hasAVX2() const = 0;
|
||||
virtual bool hasBMI2() const = 0;
|
||||
|
|
|
@ -52,8 +52,8 @@
|
|||
namespace xmrig {
|
||||
|
||||
|
||||
constexpr size_t kCpuFlagsSize = 14;
|
||||
static const std::array<const char *, kCpuFlagsSize> flagNames = { "aes", "avx", "avx2", "avx512f", "bmi2", "osxsave", "pdpe1gb", "sse2", "ssse3", "sse4.1", "xop", "popcnt", "cat_l3", "vm" };
|
||||
constexpr size_t kCpuFlagsSize = 15;
|
||||
static const std::array<const char *, kCpuFlagsSize> flagNames = { "aes", "vaes", "avx", "avx2", "avx512f", "bmi2", "osxsave", "pdpe1gb", "sse2", "ssse3", "sse4.1", "xop", "popcnt", "cat_l3", "vm" };
|
||||
static_assert(kCpuFlagsSize == ICpuInfo::FLAG_MAX, "kCpuFlagsSize and FLAG_MAX mismatch");
|
||||
|
||||
|
||||
|
@ -140,6 +140,7 @@ static inline bool has_osxsave() { return has_feature(PROCESSOR_INFO,
|
|||
static inline bool has_aes_ni() { return has_feature(PROCESSOR_INFO, ECX_Reg, 1 << 25); }
|
||||
static inline bool has_avx() { return has_feature(PROCESSOR_INFO, ECX_Reg, 1 << 28) && has_osxsave() && has_xcr_avx(); }
|
||||
static inline bool has_avx2() { return has_feature(EXTENDED_FEATURES, EBX_Reg, 1 << 5) && has_osxsave() && has_xcr_avx(); }
|
||||
static inline bool has_vaes() { return has_feature(EXTENDED_FEATURES, ECX_Reg, 1 << 9); }
|
||||
static inline bool has_avx512f() { return has_feature(EXTENDED_FEATURES, EBX_Reg, 1 << 16) && has_osxsave() && has_xcr_avx512(); }
|
||||
static inline bool has_bmi2() { return has_feature(EXTENDED_FEATURES, EBX_Reg, 1 << 8); }
|
||||
static inline bool has_pdpe1gb() { return has_feature(PROCESSOR_EXT_INFO, EDX_Reg, 1 << 26); }
|
||||
|
@ -178,6 +179,7 @@ xmrig::BasicCpuInfo::BasicCpuInfo() :
|
|||
m_flags.set(FLAG_AES, has_aes_ni());
|
||||
m_flags.set(FLAG_AVX, has_avx());
|
||||
m_flags.set(FLAG_AVX2, has_avx2());
|
||||
m_flags.set(FLAG_VAES, has_vaes());
|
||||
m_flags.set(FLAG_AVX512F, has_avx512f());
|
||||
m_flags.set(FLAG_BMI2, has_bmi2());
|
||||
m_flags.set(FLAG_OSXSAVE, has_osxsave());
|
||||
|
|
|
@ -44,6 +44,7 @@ protected:
|
|||
inline Assembly::Id assembly() const override { return m_assembly; }
|
||||
inline bool has(Flag flag) const override { return m_flags.test(flag); }
|
||||
inline bool hasAES() const override { return has(FLAG_AES); }
|
||||
inline bool hasVAES() const override { return has(FLAG_VAES); }
|
||||
inline bool hasAVX() const override { return has(FLAG_AVX); }
|
||||
inline bool hasAVX2() const override { return has(FLAG_AVX2); }
|
||||
inline bool hasBMI2() const override { return has(FLAG_BMI2); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue