mirror of
https://github.com/xmrig/xmrig.git
synced 2024-11-18 18:11:05 +00:00
Added support for "cn/msr" also known as "cn-fast".
This commit is contained in:
parent
974cb4162a
commit
8908c2c027
10 changed files with 136 additions and 75 deletions
|
@ -57,6 +57,7 @@ static AlgoData const algorithms[] = {
|
||||||
{ "cryptonight/0", "cn/0", xmrig::CRYPTONIGHT, xmrig::VARIANT_0 },
|
{ "cryptonight/0", "cn/0", xmrig::CRYPTONIGHT, xmrig::VARIANT_0 },
|
||||||
{ "cryptonight/1", "cn/1", xmrig::CRYPTONIGHT, xmrig::VARIANT_1 },
|
{ "cryptonight/1", "cn/1", xmrig::CRYPTONIGHT, xmrig::VARIANT_1 },
|
||||||
{ "cryptonight/xtl", "cn/xtl", xmrig::CRYPTONIGHT, xmrig::VARIANT_XTL },
|
{ "cryptonight/xtl", "cn/xtl", xmrig::CRYPTONIGHT, xmrig::VARIANT_XTL },
|
||||||
|
{ "cryptonight/msr", "cn/msr", xmrig::CRYPTONIGHT, xmrig::VARIANT_MSR },
|
||||||
|
|
||||||
# ifndef XMRIG_NO_AEON
|
# ifndef XMRIG_NO_AEON
|
||||||
{ "cryptonight-lite", "cn-lite", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_AUTO },
|
{ "cryptonight-lite", "cn-lite", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_AUTO },
|
||||||
|
@ -68,6 +69,8 @@ static AlgoData const algorithms[] = {
|
||||||
|
|
||||||
# ifndef XMRIG_NO_SUMO
|
# ifndef XMRIG_NO_SUMO
|
||||||
{ "cryptonight-heavy", "cn-heavy", xmrig::CRYPTONIGHT_HEAVY, xmrig::VARIANT_0 },
|
{ "cryptonight-heavy", "cn-heavy", xmrig::CRYPTONIGHT_HEAVY, xmrig::VARIANT_0 },
|
||||||
|
{ "cryptonight-heavy/0", "cn-heavy/0", xmrig::CRYPTONIGHT_HEAVY, xmrig::VARIANT_0 },
|
||||||
|
{ "cryptonight-heavy/xhv", "cn-heavy/xhv", xmrig::CRYPTONIGHT_HEAVY, xmrig::VARIANT_XHV },
|
||||||
# endif
|
# endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -89,7 +92,9 @@ static const char *variants[] = {
|
||||||
"0",
|
"0",
|
||||||
"1",
|
"1",
|
||||||
"ipbc",
|
"ipbc",
|
||||||
"xtl"
|
"xtl",
|
||||||
|
"msr",
|
||||||
|
"xhv"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -145,11 +150,6 @@ void xmrig::Algorithm::parseAlgorithm(const char *algo)
|
||||||
|
|
||||||
void xmrig::Algorithm::parseVariant(const char *variant)
|
void xmrig::Algorithm::parseVariant(const char *variant)
|
||||||
{
|
{
|
||||||
if (m_algo == CRYPTONIGHT_HEAVY) {
|
|
||||||
m_variant = VARIANT_0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_variant = VARIANT_AUTO;
|
m_variant = VARIANT_AUTO;
|
||||||
|
|
||||||
for (size_t i = 0; i < ARRAY_SIZE(variants); i++) {
|
for (size_t i = 0; i < ARRAY_SIZE(variants); i++) {
|
||||||
|
@ -163,7 +163,7 @@ void xmrig::Algorithm::parseVariant(const char *variant)
|
||||||
|
|
||||||
void xmrig::Algorithm::parseVariant(int variant)
|
void xmrig::Algorithm::parseVariant(int variant)
|
||||||
{
|
{
|
||||||
if (variant >= VARIANT_AUTO && variant <= VARIANT_XTL) {
|
if (variant >= VARIANT_AUTO && variant < VARIANT_MAX) {
|
||||||
m_variant = static_cast<Variant>(variant);
|
m_variant = static_cast<Variant>(variant);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -175,10 +175,6 @@ void xmrig::Algorithm::parseVariant(int variant)
|
||||||
void xmrig::Algorithm::setAlgo(Algo algo)
|
void xmrig::Algorithm::setAlgo(Algo algo)
|
||||||
{
|
{
|
||||||
m_algo = algo;
|
m_algo = algo;
|
||||||
|
|
||||||
if (m_algo == CRYPTONIGHT_HEAVY) {
|
|
||||||
m_variant = VARIANT_0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -173,12 +173,12 @@ xmrig::Variant Job::variant() const
|
||||||
return xmrig::VARIANT_1;
|
return xmrig::VARIANT_1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_algorithm.variant() == xmrig::VARIANT_AUTO) {
|
if (m_algorithm.variant() == xmrig::VARIANT_MSR && m_blob[0] < 7) {
|
||||||
if (m_algorithm.algo() == xmrig::CRYPTONIGHT) {
|
return xmrig::VARIANT_1;
|
||||||
return xmrig::VARIANT_1;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return (m_blob[0] > 6 ? xmrig::VARIANT_1 : xmrig::VARIANT_0);
|
if (m_algorithm.variant() == xmrig::VARIANT_AUTO && m_algorithm.algo() != xmrig::CRYPTONIGHT_HEAVY) {
|
||||||
|
return xmrig::VARIANT_1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_algorithm.variant();
|
return m_algorithm.variant();
|
||||||
|
|
|
@ -321,12 +321,12 @@ void Pool::rebuild()
|
||||||
m_algorithms.push_back(m_algorithm);
|
m_algorithms.push_back(m_algorithm);
|
||||||
|
|
||||||
# ifndef XMRIG_PROXY_PROJECT
|
# ifndef XMRIG_PROXY_PROJECT
|
||||||
if (m_algorithm.algo() != xmrig::CRYPTONIGHT_HEAVY) {
|
addVariant(xmrig::VARIANT_1);
|
||||||
addVariant(xmrig::VARIANT_1);
|
addVariant(xmrig::VARIANT_0);
|
||||||
addVariant(xmrig::VARIANT_0);
|
addVariant(xmrig::VARIANT_XTL);
|
||||||
addVariant(xmrig::VARIANT_XTL);
|
addVariant(xmrig::VARIANT_IPBC);
|
||||||
addVariant(xmrig::VARIANT_IPBC);
|
addVariant(xmrig::VARIANT_MSR);
|
||||||
addVariant(xmrig::VARIANT_AUTO);
|
addVariant(xmrig::VARIANT_XHV);
|
||||||
}
|
addVariant(xmrig::VARIANT_AUTO);
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,8 +61,11 @@ enum Variant {
|
||||||
VARIANT_AUTO = -1, // Autodetect
|
VARIANT_AUTO = -1, // Autodetect
|
||||||
VARIANT_0 = 0, // Original CryptoNight or CryptoNight-Heavy
|
VARIANT_0 = 0, // Original CryptoNight or CryptoNight-Heavy
|
||||||
VARIANT_1 = 1, // CryptoNight variant 1 also known as Monero7 and CryptoNightV7
|
VARIANT_1 = 1, // CryptoNight variant 1 also known as Monero7 and CryptoNightV7
|
||||||
VARIANT_IPBC = 2, // CryptoNight Lite variant 1 with XOR (IPBC only)
|
VARIANT_IPBC = 2, // Modified CryptoNight Lite variant 1 with XOR (IPBC/TUBE only)
|
||||||
VARIANT_XTL = 3 // CryptoNight variant 1 (Stellite only)
|
VARIANT_XTL = 3, // Modified CryptoNight variant 1 (Stellite only)
|
||||||
|
VARIANT_MSR = 4, // Modified CryptoNight variant 1 (Masari only)
|
||||||
|
VARIANT_XHV = 5, // Modified CryptoNight-Heavy (Haven Protocol only)
|
||||||
|
VARIANT_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ namespace xmrig
|
||||||
constexpr const size_t CRYPTONIGHT_MEMORY = 2 * 1024 * 1024;
|
constexpr const size_t CRYPTONIGHT_MEMORY = 2 * 1024 * 1024;
|
||||||
constexpr const uint32_t CRYPTONIGHT_MASK = 0x1FFFF0;
|
constexpr const uint32_t CRYPTONIGHT_MASK = 0x1FFFF0;
|
||||||
constexpr const uint32_t CRYPTONIGHT_ITER = 0x80000;
|
constexpr const uint32_t CRYPTONIGHT_ITER = 0x80000;
|
||||||
|
constexpr const uint32_t CRYPTONIGHT_MSR_ITER = 0x40000;
|
||||||
|
|
||||||
constexpr const size_t CRYPTONIGHT_LITE_MEMORY = 1 * 1024 * 1024;
|
constexpr const size_t CRYPTONIGHT_LITE_MEMORY = 1 * 1024 * 1024;
|
||||||
constexpr const uint32_t CRYPTONIGHT_LITE_MASK = 0xFFFF0;
|
constexpr const uint32_t CRYPTONIGHT_LITE_MASK = 0xFFFF0;
|
||||||
|
@ -102,18 +103,24 @@ inline uint32_t cn_select_mask(Algo algorithm)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<Algo ALGO> inline constexpr uint32_t cn_select_iter() { return 0; }
|
template<Algo ALGO, Variant variant> inline constexpr uint32_t cn_select_iter() { return 0; }
|
||||||
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT>() { return CRYPTONIGHT_ITER; }
|
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT, VARIANT_0>() { return CRYPTONIGHT_ITER; }
|
||||||
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT_LITE>() { return CRYPTONIGHT_LITE_ITER; }
|
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT, VARIANT_1>() { return CRYPTONIGHT_ITER; }
|
||||||
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT_HEAVY>() { return CRYPTONIGHT_HEAVY_ITER; }
|
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT, VARIANT_XTL>() { return CRYPTONIGHT_ITER; }
|
||||||
|
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT, VARIANT_MSR>() { return CRYPTONIGHT_MSR_ITER; }
|
||||||
|
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT_LITE, VARIANT_0>() { return CRYPTONIGHT_LITE_ITER; }
|
||||||
|
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT_LITE, VARIANT_1>() { return CRYPTONIGHT_LITE_ITER; }
|
||||||
|
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT_LITE, VARIANT_IPBC>() { return CRYPTONIGHT_LITE_ITER; }
|
||||||
|
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT_HEAVY, VARIANT_0>() { return CRYPTONIGHT_HEAVY_ITER; }
|
||||||
|
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT_HEAVY, VARIANT_XHV>() { return CRYPTONIGHT_HEAVY_ITER; }
|
||||||
|
|
||||||
|
|
||||||
inline uint32_t cn_select_iter(Algo algorithm)
|
inline uint32_t cn_select_iter(Algo algorithm, Variant variant)
|
||||||
{
|
{
|
||||||
switch(algorithm)
|
switch(algorithm)
|
||||||
{
|
{
|
||||||
case CRYPTONIGHT:
|
case CRYPTONIGHT:
|
||||||
return CRYPTONIGHT_ITER;
|
return variant == VARIANT_MSR ? CRYPTONIGHT_MSR_ITER : CRYPTONIGHT_ITER;
|
||||||
|
|
||||||
case CRYPTONIGHT_LITE:
|
case CRYPTONIGHT_LITE:
|
||||||
return CRYPTONIGHT_LITE_ITER;
|
return CRYPTONIGHT_LITE_ITER;
|
||||||
|
|
|
@ -99,6 +99,21 @@ const static uint8_t test_output_xtl[160] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Masari (MSR)
|
||||||
|
const static uint8_t test_output_msr[160] = {
|
||||||
|
0x3C, 0x7A, 0x61, 0x08, 0x4C, 0x5E, 0xB8, 0x65, 0xB4, 0x98, 0xAB, 0x2F, 0x5A, 0x1A, 0xC5, 0x2C,
|
||||||
|
0x49, 0xC1, 0x77, 0xC2, 0xD0, 0x13, 0x34, 0x42, 0xD6, 0x5E, 0xD5, 0x14, 0x33, 0x5C, 0x82, 0xC5,
|
||||||
|
0x69, 0xDF, 0x38, 0x51, 0x1B, 0xB3, 0xEB, 0x7D, 0xE7, 0x6B, 0x08, 0x8E, 0xB6, 0x7E, 0xB7, 0x1C,
|
||||||
|
0x5F, 0x3C, 0x81, 0xC9, 0xF7, 0xCE, 0xAE, 0x28, 0xC0, 0xFE, 0xEB, 0xBA, 0x0B, 0x40, 0x38, 0x1D,
|
||||||
|
0x44, 0xD0, 0xD5, 0xD3, 0x98, 0x1F, 0xA3, 0x0E, 0xE9, 0x89, 0x1A, 0xD7, 0x88, 0xCC, 0x25, 0x76,
|
||||||
|
0x9C, 0xFF, 0x4D, 0x7F, 0x9C, 0xCF, 0x48, 0x07, 0x91, 0xF9, 0x82, 0xF5, 0x4C, 0xE9, 0xBD, 0x82,
|
||||||
|
0x36, 0x36, 0x64, 0x14, 0xED, 0xB8, 0x54, 0xEE, 0x22, 0xA1, 0x66, 0xA3, 0x87, 0x10, 0x76, 0x1F,
|
||||||
|
0x5A, 0xCD, 0x4C, 0x31, 0x4C, 0xBA, 0x41, 0xD2, 0xDB, 0x6C, 0x31, 0x2E, 0x7A, 0x64, 0x15, 0xFF,
|
||||||
|
0xA6, 0xD9, 0xB9, 0x7D, 0x1C, 0x3C, 0x98, 0xDD, 0x16, 0xE6, 0xD3, 0xAA, 0xEF, 0xB6, 0xB3, 0x53,
|
||||||
|
0x74, 0xD1, 0xAC, 0x5C, 0x04, 0x26, 0x7D, 0x71, 0xDE, 0xAB, 0x66, 0x28, 0x91, 0x3A, 0x6F, 0x4F
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifndef XMRIG_NO_AEON
|
#ifndef XMRIG_NO_AEON
|
||||||
const static uint8_t test_output_v0_lite[160] = {
|
const static uint8_t test_output_v0_lite[160] = {
|
||||||
0x36, 0x95, 0xB4, 0xB5, 0x3B, 0xB0, 0x03, 0x58, 0xB0, 0xAD, 0x38, 0xDC, 0x16, 0x0F, 0xEB, 0x9E,
|
0x36, 0x95, 0xB4, 0xB5, 0x3B, 0xB0, 0x03, 0x58, 0xB0, 0xAD, 0x38, 0xDC, 0x16, 0x0F, 0xEB, 0x9E,
|
||||||
|
|
|
@ -403,11 +403,11 @@ static inline void cryptonight_monero_tweak(uint64_t* mem_out, __m128i tmp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<xmrig::Algo ALGO, bool SOFT_AES, int VARIANT>
|
template<xmrig::Algo ALGO, bool SOFT_AES, xmrig::Variant VARIANT>
|
||||||
inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx)
|
inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx)
|
||||||
{
|
{
|
||||||
constexpr size_t MASK = xmrig::cn_select_mask<ALGO>();
|
constexpr size_t MASK = xmrig::cn_select_mask<ALGO>();
|
||||||
constexpr size_t ITERATIONS = xmrig::cn_select_iter<ALGO>();
|
constexpr size_t ITERATIONS = xmrig::cn_select_iter<ALGO, VARIANT>();
|
||||||
constexpr size_t MEM = xmrig::cn_select_memory<ALGO>();
|
constexpr size_t MEM = xmrig::cn_select_memory<ALGO>();
|
||||||
|
|
||||||
if (VARIANT > 0 && size < 43) {
|
if (VARIANT > 0 && size < 43) {
|
||||||
|
@ -493,11 +493,11 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<xmrig::Algo ALGO, bool SOFT_AES, int VARIANT>
|
template<xmrig::Algo ALGO, bool SOFT_AES, xmrig::Variant VARIANT>
|
||||||
inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx)
|
inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx)
|
||||||
{
|
{
|
||||||
constexpr size_t MASK = xmrig::cn_select_mask<ALGO>();
|
constexpr size_t MASK = xmrig::cn_select_mask<ALGO>();
|
||||||
constexpr size_t ITERATIONS = xmrig::cn_select_iter<ALGO>();
|
constexpr size_t ITERATIONS = xmrig::cn_select_iter<ALGO, VARIANT>();
|
||||||
constexpr size_t MEM = xmrig::cn_select_memory<ALGO>();
|
constexpr size_t MEM = xmrig::cn_select_memory<ALGO>();
|
||||||
|
|
||||||
if (VARIANT > 0 && size < 43) {
|
if (VARIANT > 0 && size < 43) {
|
||||||
|
@ -700,11 +700,11 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<xmrig::Algo ALGO, bool SOFT_AES, int VARIANT>
|
template<xmrig::Algo ALGO, bool SOFT_AES, xmrig::Variant VARIANT>
|
||||||
inline void cryptonight_triple_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx)
|
inline void cryptonight_triple_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx)
|
||||||
{
|
{
|
||||||
constexpr size_t MASK = xmrig::cn_select_mask<ALGO>();
|
constexpr size_t MASK = xmrig::cn_select_mask<ALGO>();
|
||||||
constexpr size_t ITERATIONS = xmrig::cn_select_iter<ALGO>();
|
constexpr size_t ITERATIONS = xmrig::cn_select_iter<ALGO, VARIANT>();
|
||||||
constexpr size_t MEM = xmrig::cn_select_memory<ALGO>();
|
constexpr size_t MEM = xmrig::cn_select_memory<ALGO>();
|
||||||
|
|
||||||
if (VARIANT > 0 && size < 43) {
|
if (VARIANT > 0 && size < 43) {
|
||||||
|
@ -790,11 +790,11 @@ inline void cryptonight_triple_hash(const uint8_t *__restrict__ input, size_t si
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<xmrig::Algo ALGO, bool SOFT_AES, int VARIANT>
|
template<xmrig::Algo ALGO, bool SOFT_AES, xmrig::Variant VARIANT>
|
||||||
inline void cryptonight_quad_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx)
|
inline void cryptonight_quad_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx)
|
||||||
{
|
{
|
||||||
constexpr size_t MASK = xmrig::cn_select_mask<ALGO>();
|
constexpr size_t MASK = xmrig::cn_select_mask<ALGO>();
|
||||||
constexpr size_t ITERATIONS = xmrig::cn_select_iter<ALGO>();
|
constexpr size_t ITERATIONS = xmrig::cn_select_iter<ALGO, VARIANT>();
|
||||||
constexpr size_t MEM = xmrig::cn_select_memory<ALGO>();
|
constexpr size_t MEM = xmrig::cn_select_memory<ALGO>();
|
||||||
|
|
||||||
if (VARIANT > 0 && size < 43) {
|
if (VARIANT > 0 && size < 43) {
|
||||||
|
@ -896,11 +896,11 @@ inline void cryptonight_quad_hash(const uint8_t *__restrict__ input, size_t size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<xmrig::Algo ALGO, bool SOFT_AES, int VARIANT>
|
template<xmrig::Algo ALGO, bool SOFT_AES, xmrig::Variant VARIANT>
|
||||||
inline void cryptonight_penta_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx)
|
inline void cryptonight_penta_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx)
|
||||||
{
|
{
|
||||||
constexpr size_t MASK = xmrig::cn_select_mask<ALGO>();
|
constexpr size_t MASK = xmrig::cn_select_mask<ALGO>();
|
||||||
constexpr size_t ITERATIONS = xmrig::cn_select_iter<ALGO>();
|
constexpr size_t ITERATIONS = xmrig::cn_select_iter<ALGO, VARIANT>();
|
||||||
constexpr size_t MEM = xmrig::cn_select_memory<ALGO>();
|
constexpr size_t MEM = xmrig::cn_select_memory<ALGO>();
|
||||||
|
|
||||||
if (VARIANT > 0 && size < 43) {
|
if (VARIANT > 0 && size < 43) {
|
||||||
|
|
|
@ -62,9 +62,15 @@ bool xmrig::CpuThread::isSoftAES(AlgoVariant av)
|
||||||
|
|
||||||
xmrig::CpuThread::cn_hash_fun xmrig::CpuThread::fn(Algo algorithm, AlgoVariant av, Variant variant)
|
xmrig::CpuThread::cn_hash_fun xmrig::CpuThread::fn(Algo algorithm, AlgoVariant av, Variant variant)
|
||||||
{
|
{
|
||||||
assert(variant == VARIANT_0 || variant == VARIANT_1 || variant == VARIANT_IPBC || variant == VARIANT_XTL);
|
assert(variant == VARIANT_0 ||
|
||||||
|
variant == VARIANT_1 ||
|
||||||
|
variant == VARIANT_IPBC ||
|
||||||
|
variant == VARIANT_XTL ||
|
||||||
|
variant == VARIANT_MSR ||
|
||||||
|
variant == VARIANT_XHV
|
||||||
|
);
|
||||||
|
|
||||||
static const cn_hash_fun func_table[90] = {
|
static const cn_hash_fun func_table[180] = {
|
||||||
cryptonight_single_hash<CRYPTONIGHT, false, VARIANT_0>,
|
cryptonight_single_hash<CRYPTONIGHT, false, VARIANT_0>,
|
||||||
cryptonight_double_hash<CRYPTONIGHT, false, VARIANT_0>,
|
cryptonight_double_hash<CRYPTONIGHT, false, VARIANT_0>,
|
||||||
cryptonight_single_hash<CRYPTONIGHT, true, VARIANT_0>,
|
cryptonight_single_hash<CRYPTONIGHT, true, VARIANT_0>,
|
||||||
|
@ -87,7 +93,7 @@ xmrig::CpuThread::cn_hash_fun xmrig::CpuThread::fn(Algo algorithm, AlgoVariant a
|
||||||
cryptonight_quad_hash<CRYPTONIGHT, true, VARIANT_1>,
|
cryptonight_quad_hash<CRYPTONIGHT, true, VARIANT_1>,
|
||||||
cryptonight_penta_hash<CRYPTONIGHT, true, VARIANT_1>,
|
cryptonight_penta_hash<CRYPTONIGHT, true, VARIANT_1>,
|
||||||
|
|
||||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_IPBC
|
||||||
|
|
||||||
cryptonight_single_hash<CRYPTONIGHT, false, VARIANT_XTL>,
|
cryptonight_single_hash<CRYPTONIGHT, false, VARIANT_XTL>,
|
||||||
cryptonight_double_hash<CRYPTONIGHT, false, VARIANT_XTL>,
|
cryptonight_double_hash<CRYPTONIGHT, false, VARIANT_XTL>,
|
||||||
|
@ -100,6 +106,19 @@ xmrig::CpuThread::cn_hash_fun xmrig::CpuThread::fn(Algo algorithm, AlgoVariant a
|
||||||
cryptonight_quad_hash<CRYPTONIGHT, true, VARIANT_XTL>,
|
cryptonight_quad_hash<CRYPTONIGHT, true, VARIANT_XTL>,
|
||||||
cryptonight_penta_hash<CRYPTONIGHT, true, VARIANT_XTL>,
|
cryptonight_penta_hash<CRYPTONIGHT, true, VARIANT_XTL>,
|
||||||
|
|
||||||
|
cryptonight_single_hash<CRYPTONIGHT, false, VARIANT_MSR>,
|
||||||
|
cryptonight_double_hash<CRYPTONIGHT, false, VARIANT_MSR>,
|
||||||
|
cryptonight_single_hash<CRYPTONIGHT, true, VARIANT_MSR>,
|
||||||
|
cryptonight_double_hash<CRYPTONIGHT, true, VARIANT_MSR>,
|
||||||
|
cryptonight_triple_hash<CRYPTONIGHT, false, VARIANT_MSR>,
|
||||||
|
cryptonight_quad_hash<CRYPTONIGHT, false, VARIANT_MSR>,
|
||||||
|
cryptonight_penta_hash<CRYPTONIGHT, false, VARIANT_MSR>,
|
||||||
|
cryptonight_triple_hash<CRYPTONIGHT, true, VARIANT_MSR>,
|
||||||
|
cryptonight_quad_hash<CRYPTONIGHT, true, VARIANT_MSR>,
|
||||||
|
cryptonight_penta_hash<CRYPTONIGHT, true, VARIANT_MSR>,
|
||||||
|
|
||||||
|
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_XHV
|
||||||
|
|
||||||
# ifndef XMRIG_NO_AEON
|
# ifndef XMRIG_NO_AEON
|
||||||
cryptonight_single_hash<CRYPTONIGHT_LITE, false, VARIANT_0>,
|
cryptonight_single_hash<CRYPTONIGHT_LITE, false, VARIANT_0>,
|
||||||
cryptonight_double_hash<CRYPTONIGHT_LITE, false, VARIANT_0>,
|
cryptonight_double_hash<CRYPTONIGHT_LITE, false, VARIANT_0>,
|
||||||
|
@ -134,12 +153,16 @@ xmrig::CpuThread::cn_hash_fun xmrig::CpuThread::fn(Algo algorithm, AlgoVariant a
|
||||||
cryptonight_quad_hash<CRYPTONIGHT_LITE, true, VARIANT_IPBC>,
|
cryptonight_quad_hash<CRYPTONIGHT_LITE, true, VARIANT_IPBC>,
|
||||||
cryptonight_penta_hash<CRYPTONIGHT_LITE, true, VARIANT_IPBC>,
|
cryptonight_penta_hash<CRYPTONIGHT_LITE, true, VARIANT_IPBC>,
|
||||||
|
|
||||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_XTL
|
||||||
|
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_MSR
|
||||||
|
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_XHV
|
||||||
# else
|
# else
|
||||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||||
|
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||||
|
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifndef XMRIG_NO_SUMO
|
# ifndef XMRIG_NO_SUMO
|
||||||
|
@ -153,18 +176,33 @@ xmrig::CpuThread::cn_hash_fun xmrig::CpuThread::fn(Algo algorithm, AlgoVariant a
|
||||||
cryptonight_triple_hash<CRYPTONIGHT_HEAVY, true, VARIANT_0>,
|
cryptonight_triple_hash<CRYPTONIGHT_HEAVY, true, VARIANT_0>,
|
||||||
cryptonight_quad_hash<CRYPTONIGHT_HEAVY, true, VARIANT_0>,
|
cryptonight_quad_hash<CRYPTONIGHT_HEAVY, true, VARIANT_0>,
|
||||||
cryptonight_penta_hash<CRYPTONIGHT_HEAVY, true, VARIANT_0>,
|
cryptonight_penta_hash<CRYPTONIGHT_HEAVY, true, VARIANT_0>,
|
||||||
|
|
||||||
|
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_1
|
||||||
|
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_IPBC
|
||||||
|
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_XTL
|
||||||
|
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_MSR
|
||||||
|
|
||||||
|
cryptonight_single_hash<CRYPTONIGHT_HEAVY, false, VARIANT_XHV>,
|
||||||
|
cryptonight_double_hash<CRYPTONIGHT_HEAVY, false, VARIANT_XHV>,
|
||||||
|
cryptonight_single_hash<CRYPTONIGHT_HEAVY, true, VARIANT_XHV>,
|
||||||
|
cryptonight_double_hash<CRYPTONIGHT_HEAVY, true, VARIANT_XHV>,
|
||||||
|
cryptonight_triple_hash<CRYPTONIGHT_HEAVY, false, VARIANT_XHV>,
|
||||||
|
cryptonight_quad_hash<CRYPTONIGHT_HEAVY, false, VARIANT_XHV>,
|
||||||
|
cryptonight_penta_hash<CRYPTONIGHT_HEAVY, false, VARIANT_XHV>,
|
||||||
|
cryptonight_triple_hash<CRYPTONIGHT_HEAVY, true, VARIANT_XHV>,
|
||||||
|
cryptonight_quad_hash<CRYPTONIGHT_HEAVY, true, VARIANT_XHV>,
|
||||||
|
cryptonight_penta_hash<CRYPTONIGHT_HEAVY, true, VARIANT_XHV>,
|
||||||
# else
|
# else
|
||||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||||
|
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||||
|
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||||
|
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||||
|
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||||
|
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||||
# endif
|
# endif
|
||||||
};
|
};
|
||||||
|
|
||||||
# ifndef XMRIG_NO_SUMO
|
const size_t index = VARIANT_MAX * 10 * algorithm + 10 * variant + av - 1;
|
||||||
if (algorithm == CRYPTONIGHT_HEAVY) {
|
|
||||||
variant = VARIANT_0;
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
const size_t index = 40 * algorithm + 10 * variant + av - 1;
|
|
||||||
|
|
||||||
# ifndef NDEBUG
|
# ifndef NDEBUG
|
||||||
cn_hash_fun func = func_table[index];
|
cn_hash_fun func = func_table[index];
|
||||||
|
|
|
@ -50,36 +50,23 @@ MultiWorker<N>::~MultiWorker()
|
||||||
template<size_t N>
|
template<size_t N>
|
||||||
bool MultiWorker<N>::selfTest()
|
bool MultiWorker<N>::selfTest()
|
||||||
{
|
{
|
||||||
if (m_thread->fn(xmrig::VARIANT_0) == nullptr) {
|
if (m_thread->algorithm() == xmrig::CRYPTONIGHT) {
|
||||||
return false;
|
return verify(xmrig::VARIANT_0, test_output_v0) &&
|
||||||
}
|
verify(xmrig::VARIANT_1, test_output_v1) &&
|
||||||
|
verify(xmrig::VARIANT_XTL, test_output_xtl) &&
|
||||||
m_thread->fn(xmrig::VARIANT_0)(test_input, 76, m_hash, m_ctx);
|
verify(xmrig::VARIANT_MSR, test_output_msr);
|
||||||
|
|
||||||
if (m_thread->algorithm() == xmrig::CRYPTONIGHT && memcmp(m_hash, test_output_v0, sizeof m_hash) == 0) {
|
|
||||||
m_thread->fn(xmrig::VARIANT_1)(test_input, 76, m_hash, m_ctx);
|
|
||||||
if (memcmp(m_hash, test_output_v1, sizeof m_hash) != 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_thread->fn(xmrig::VARIANT_XTL)(test_input, 76, m_hash, m_ctx);
|
|
||||||
return memcmp(m_hash, test_output_xtl, sizeof m_hash) == 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifndef XMRIG_NO_AEON
|
# ifndef XMRIG_NO_AEON
|
||||||
if (m_thread->algorithm() == xmrig::CRYPTONIGHT_LITE && memcmp(m_hash, test_output_v0_lite, sizeof m_hash) == 0) {
|
if (m_thread->algorithm() == xmrig::CRYPTONIGHT_LITE) {
|
||||||
m_thread->fn(xmrig::VARIANT_1)(test_input, 76, m_hash, m_ctx);
|
return verify(xmrig::VARIANT_0, test_output_v0_lite) &&
|
||||||
if (memcmp(m_hash, test_output_v1_lite, sizeof m_hash) != 0) {
|
verify(xmrig::VARIANT_1, test_output_v1_lite) &&
|
||||||
return false;
|
verify(xmrig::VARIANT_IPBC, test_output_ipbc_lite);
|
||||||
}
|
|
||||||
|
|
||||||
m_thread->fn(xmrig::VARIANT_IPBC)(test_input, 76, m_hash, m_ctx);
|
|
||||||
return memcmp(m_hash, test_output_ipbc_lite, sizeof m_hash) == 0;
|
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifndef XMRIG_NO_SUMO
|
# ifndef XMRIG_NO_SUMO
|
||||||
return m_thread->algorithm() == xmrig::CRYPTONIGHT_HEAVY && memcmp(m_hash, test_output_heavy, sizeof m_hash) == 0;
|
return m_thread->algorithm() == xmrig::CRYPTONIGHT_HEAVY && verify(xmrig::VARIANT_0, test_output_heavy);
|
||||||
# else
|
# else
|
||||||
return false;
|
return false;
|
||||||
# endif
|
# endif
|
||||||
|
@ -140,6 +127,20 @@ bool MultiWorker<N>::resume(const Job &job)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<size_t N>
|
||||||
|
bool MultiWorker<N>::verify(xmrig::Variant variant, const uint8_t *referenceValue)
|
||||||
|
{
|
||||||
|
|
||||||
|
xmrig::CpuThread::cn_hash_fun func = m_thread->fn(variant);
|
||||||
|
if (!func) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
func(test_input, 76, m_hash, m_ctx);
|
||||||
|
return memcmp(m_hash, referenceValue, sizeof m_hash) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<size_t N>
|
template<size_t N>
|
||||||
void MultiWorker<N>::consumeJob()
|
void MultiWorker<N>::consumeJob()
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,6 +48,7 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool resume(const Job &job);
|
bool resume(const Job &job);
|
||||||
|
bool verify(xmrig::Variant variant, const uint8_t *referenceValue);
|
||||||
void consumeJob();
|
void consumeJob();
|
||||||
void save(const Job &job);
|
void save(const Job &job);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue