From 082b29f364e262f4f39b817826dce1abd88e870a Mon Sep 17 00:00:00 2001 From: alfredmox <> Date: Wed, 25 Jul 2018 14:22:25 +0200 Subject: [PATCH] First attempt at MoX support --- src/common/crypto/Algorithm.cpp | 5 ++++- src/common/xmrig.h | 1 + src/crypto/CryptoNight_arm.h | 6 +++--- src/crypto/CryptoNight_constants.h | 2 ++ src/crypto/CryptoNight_x86.h | 8 ++++---- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/common/crypto/Algorithm.cpp b/src/common/crypto/Algorithm.cpp index 31035fb1..94c38bf2 100644 --- a/src/common/crypto/Algorithm.cpp +++ b/src/common/crypto/Algorithm.cpp @@ -66,6 +66,7 @@ static AlgoData const algorithms[] = { { "cryptonight-light", "cn-light", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_AUTO }, { "cryptonight-lite/0", "cn-lite/0", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_0 }, { "cryptonight-lite/1", "cn-lite/1", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_1 }, + { "cryptonight/mox", "cn/mox", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_MOX }, # endif # ifndef XMRIG_NO_SUMO @@ -91,6 +92,7 @@ static AlgoData const xmrStakAlgorithms[] = { { "cryptonight_masari", nullptr, xmrig::CRYPTONIGHT, xmrig::VARIANT_MSR }, { "cryptonight-bittube2", nullptr, xmrig::CRYPTONIGHT_HEAVY, xmrig::VARIANT_TUBE }, // bittube-miner { "cryptonight_alloy", nullptr, xmrig::CRYPTONIGHT, xmrig::VARIANT_XAO }, // xmr-stak-alloy + { "cryptonight_mox", nullptr, xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_MOX }, }; #endif @@ -103,7 +105,8 @@ static const char *variants[] = { "msr", "xhv", "xao", - "rto" + "rto", + "mox" }; diff --git a/src/common/xmrig.h b/src/common/xmrig.h index 0ff945b9..d3804482 100644 --- a/src/common/xmrig.h +++ b/src/common/xmrig.h @@ -67,6 +67,7 @@ enum Variant { VARIANT_XHV = 5, // Modified CryptoNight-Heavy (Haven Protocol only) VARIANT_XAO = 6, // Modified CryptoNight variant 1 (Alloy only) VARIANT_RTO = 7, // Modified CryptoNight variant 1 (Arto only) + VARIANT_MOX = 8, VARIANT_MAX }; diff --git a/src/crypto/CryptoNight_arm.h b/src/crypto/CryptoNight_arm.h index efb5759e..03a28498 100644 --- a/src/crypto/CryptoNight_arm.h +++ b/src/crypto/CryptoNight_arm.h @@ -465,7 +465,7 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si } if (IS_MONERO) { - cryptonight_monero_tweak((uint64_t*)&l0[idx0 & MASK], _mm_xor_si128(bx0, cx)); + cryptonight_monero_tweak((uint64_t*)&l0[idx0 & MASK], _mm_xor_si128(bx0, cx)); } else { _mm_store_si128((__m128i *)&l0[idx0 & MASK], _mm_xor_si128(bx0, cx)); } @@ -582,8 +582,8 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si } if (IS_MONERO) { - cryptonight_monero_tweak((uint64_t*)&l0[idx0 & MASK], _mm_xor_si128(bx0, cx0)); - cryptonight_monero_tweak((uint64_t*)&l1[idx1 & MASK], _mm_xor_si128(bx1, cx1)); + cryptonight_monero_tweak((uint64_t*)&l0[idx0 & MASK], _mm_xor_si128(bx0, cx0)); + cryptonight_monero_tweak((uint64_t*)&l1[idx1 & MASK], _mm_xor_si128(bx1, cx1)); } else { _mm_store_si128((__m128i *) &l0[idx0 & MASK], _mm_xor_si128(bx0, cx0)); _mm_store_si128((__m128i *) &l1[idx1 & MASK], _mm_xor_si128(bx1, cx1)); diff --git a/src/crypto/CryptoNight_constants.h b/src/crypto/CryptoNight_constants.h index 08a755d4..4c89e678 100644 --- a/src/crypto/CryptoNight_constants.h +++ b/src/crypto/CryptoNight_constants.h @@ -111,6 +111,7 @@ template<> inline constexpr uint32_t cn_select_iter() template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_MSR_ITER; } template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_XAO_ITER; } template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_ITER; } +template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_LITE_ITER; } template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_LITE_ITER; } template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_LITE_ITER; } template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_HEAVY_ITER; } @@ -159,6 +160,7 @@ template<> inline constexpr bool cn_is_monero() { return true; } template<> inline constexpr bool cn_is_monero() { return false; } template<> inline constexpr bool cn_is_monero() { return false; } template<> inline constexpr bool cn_is_monero() { return true; } +template<> inline constexpr bool cn_is_monero() { return true; } inline bool cn_is_monero(Variant variant) diff --git a/src/crypto/CryptoNight_x86.h b/src/crypto/CryptoNight_x86.h index 199c190b..878d37fe 100644 --- a/src/crypto/CryptoNight_x86.h +++ b/src/crypto/CryptoNight_x86.h @@ -470,7 +470,7 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si } if (IS_MONERO) { - cryptonight_monero_tweak((uint64_t*)&l0[idx0 & MASK], _mm_xor_si128(bx0, cx)); + cryptonight_monero_tweak((uint64_t*)&l0[idx0 & MASK], _mm_xor_si128(bx0, cx)); } else { _mm_store_si128((__m128i *)&l0[idx0 & MASK], _mm_xor_si128(bx0, cx)); } @@ -585,8 +585,8 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si } if (IS_MONERO) { - cryptonight_monero_tweak((uint64_t*)&l0[idx0 & MASK], _mm_xor_si128(bx0, cx0)); - cryptonight_monero_tweak((uint64_t*)&l1[idx1 & MASK], _mm_xor_si128(bx1, cx1)); + cryptonight_monero_tweak((uint64_t*)&l0[idx0 & MASK], _mm_xor_si128(bx0, cx0)); + cryptonight_monero_tweak((uint64_t*)&l1[idx1 & MASK], _mm_xor_si128(bx1, cx1)); } else { _mm_store_si128((__m128i *) &l0[idx0 & MASK], _mm_xor_si128(bx0, cx0)); _mm_store_si128((__m128i *) &l1[idx1 & MASK], _mm_xor_si128(bx1, cx1)); @@ -707,7 +707,7 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si b = _mm_xor_si128(b, c); \ \ if (IS_MONERO) { \ - cryptonight_monero_tweak(reinterpret_cast(ptr), b); \ + cryptonight_monero_tweak(reinterpret_cast(ptr), b); \ } else { \ _mm_store_si128(ptr, b); \ }