From ca43d155d888dfad98b1b49f39e24bad89f2bec2 Mon Sep 17 00:00:00 2001 From: XMRig Date: Sun, 20 Jan 2019 15:13:01 +0700 Subject: [PATCH 1/7] v2.9.5-dev --- src/version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/version.h b/src/version.h index 070d283f..bfdfa448 100644 --- a/src/version.h +++ b/src/version.h @@ -28,7 +28,7 @@ #define APP_ID "xmrig" #define APP_NAME "XMRig" #define APP_DESC "XMRig CPU miner" -#define APP_VERSION "2.9.4" +#define APP_VERSION "2.9.5-dev" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2019 xmrig.com" @@ -36,7 +36,7 @@ #define APP_VER_MAJOR 2 #define APP_VER_MINOR 9 -#define APP_VER_PATCH 4 +#define APP_VER_PATCH 5 #ifdef _MSC_VER # if (_MSC_VER >= 1910) From 36b01f136f49cd6ed23aabb3c05fdd86ae78e416 Mon Sep 17 00:00:00 2001 From: XMRig Date: Sun, 20 Jan 2019 19:52:44 +0700 Subject: [PATCH 2/7] #904 Initial support for "cn-pico/trtl". --- CMakeLists.txt | 5 ++ src/common/crypto/Algorithm.cpp | 13 +++- src/common/xmrig.h | 11 ++-- src/crypto/CryptoNight_constants.h | 25 +++++++- src/crypto/CryptoNight_test.h | 18 ++++++ src/crypto/CryptoNight_x86.h | 2 + src/workers/CpuThread.cpp | 96 ++++++++++++++++++++++-------- src/workers/MultiWorker.cpp | 6 ++ 8 files changed, 141 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index da818232..99a19bfd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,7 @@ project(xmrig) option(WITH_LIBCPUID "Use Libcpuid" ON) option(WITH_AEON "CryptoNight-Lite support" ON) option(WITH_SUMO "CryptoNight-Heavy support" ON) +option(WITH_CN_PICO "CryptoNight-Pico support" ON) option(WITH_HTTPD "HTTP REST API" ON) option(WITH_DEBUG_LOG "Enable debug log output" OFF) option(WITH_TLS "Enable OpenSSL support" ON) @@ -218,6 +219,10 @@ if (NOT WITH_IPBC) add_definitions(/DXMRIG_NO_IPBC) endif() +if (NOT WITH_CN_PICO) + add_definitions(/DXMRIG_NO_CN_PICO) +endif() + if (WITH_HTTPD) find_package(MHD) diff --git a/src/common/crypto/Algorithm.cpp b/src/common/crypto/Algorithm.cpp index 2f259372..d61f85b1 100644 --- a/src/common/crypto/Algorithm.cpp +++ b/src/common/crypto/Algorithm.cpp @@ -6,7 +6,7 @@ * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , * Copyright 2018 Lee Clagett - * Copyright 2018 SChernykh + * Copyright 2018-2019 SChernykh * Copyright 2016-2019 XMRig , * * This program is free software: you can redistribute it and/or modify @@ -78,6 +78,14 @@ static AlgoData const algorithms[] = { { "cryptonight-heavy/xhv", "cn-heavy/xhv", xmrig::CRYPTONIGHT_HEAVY, xmrig::VARIANT_XHV }, { "cryptonight-heavy/tube", "cn-heavy/tube", xmrig::CRYPTONIGHT_HEAVY, xmrig::VARIANT_TUBE }, # endif + +# ifndef XMRIG_NO_CN_PICO + { "cryptonight-pico/trtl", "cn-pico/trtl", xmrig::CRYPTONIGHT_PICO, xmrig::VARIANT_TRTL }, + { "cryptonight-pico", "cn-pico", xmrig::CRYPTONIGHT_PICO, xmrig::VARIANT_TRTL }, + { "cryptonight-turtle", "cn-trtl", xmrig::CRYPTONIGHT_PICO, xmrig::VARIANT_TRTL }, + { "cryptonight-ultralite", "cn-ultralite", xmrig::CRYPTONIGHT_PICO, xmrig::VARIANT_TRTL }, + { "cryptonight_turtle", "cn_turtle", xmrig::CRYPTONIGHT_PICO, xmrig::VARIANT_TRTL }, +# endif }; @@ -111,7 +119,8 @@ static const char *variants[] = { "xao", "rto", "2", - "half" + "half", + "trtl" }; diff --git a/src/common/xmrig.h b/src/common/xmrig.h index 883d866d..b2051331 100644 --- a/src/common/xmrig.h +++ b/src/common/xmrig.h @@ -5,7 +5,7 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018 SChernykh + * Copyright 2018-2019 SChernykh * Copyright 2016-2019 XMRig , * * This program is free software: you can redistribute it and/or modify @@ -32,9 +32,11 @@ namespace xmrig enum Algo { INVALID_ALGO = -1, - CRYPTONIGHT, /* CryptoNight (Monero) */ - CRYPTONIGHT_LITE, /* CryptoNight-Lite (AEON) */ - CRYPTONIGHT_HEAVY /* CryptoNight-Heavy (RYO) */ + CRYPTONIGHT, /* CryptoNight (2 MB) */ + CRYPTONIGHT_LITE, /* CryptoNight (1 MB) */ + CRYPTONIGHT_HEAVY, /* CryptoNight (4 MB) */ + CRYPTONIGHT_PICO, /* CryptoNight (256 KB) */ + CRYPTONIGHT_MAX }; @@ -70,6 +72,7 @@ enum Variant { VARIANT_RTO = 7, // Modified CryptoNight variant 1 (Arto only) VARIANT_2 = 8, // CryptoNight variant 2 VARIANT_HALF = 9, // CryptoNight variant 2 with half iterations (Masari/Stellite) + VARIANT_TRTL = 10, // CryptoNight Turtle (TRTL) VARIANT_MAX }; diff --git a/src/crypto/CryptoNight_constants.h b/src/crypto/CryptoNight_constants.h index f0032305..654e3740 100644 --- a/src/crypto/CryptoNight_constants.h +++ b/src/crypto/CryptoNight_constants.h @@ -6,6 +6,7 @@ * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , * Copyright 2018 Lee Clagett + * Copyright 2018-2019 SChernykh * Copyright 2016-2019 XMRig , * * This program is free software: you can redistribute it and/or modify @@ -22,8 +23,8 @@ * along with this program. If not, see . */ -#ifndef __CRYPTONIGHT_CONSTANTS_H__ -#define __CRYPTONIGHT_CONSTANTS_H__ +#ifndef XMRIG_CRYPTONIGHT_CONSTANTS_H +#define XMRIG_CRYPTONIGHT_CONSTANTS_H #include @@ -49,11 +50,17 @@ constexpr const size_t CRYPTONIGHT_HEAVY_MEMORY = 4 * 1024 * 1024; constexpr const uint32_t CRYPTONIGHT_HEAVY_MASK = 0x3FFFF0; constexpr const uint32_t CRYPTONIGHT_HEAVY_ITER = 0x40000; +constexpr const size_t CRYPTONIGHT_PICO_MEMORY = 256 * 1024; +constexpr const uint32_t CRYPTONIGHT_PICO_MASK = 0x1FFF0; +constexpr const uint32_t CRYPTONIGHT_PICO_ITER = 0x40000; +constexpr const uint32_t CRYPTONIGHT_TRTL_ITER = 0x10000; + template inline constexpr size_t cn_select_memory() { return 0; } template<> inline constexpr size_t cn_select_memory() { return CRYPTONIGHT_MEMORY; } template<> inline constexpr size_t cn_select_memory() { return CRYPTONIGHT_LITE_MEMORY; } template<> inline constexpr size_t cn_select_memory() { return CRYPTONIGHT_HEAVY_MEMORY; } +template<> inline constexpr size_t cn_select_memory() { return CRYPTONIGHT_PICO_MEMORY; } inline size_t cn_select_memory(Algo algorithm) @@ -69,6 +76,9 @@ inline size_t cn_select_memory(Algo algorithm) case CRYPTONIGHT_HEAVY: return CRYPTONIGHT_HEAVY_MEMORY; + case CRYPTONIGHT_PICO: + return CRYPTONIGHT_PICO_MEMORY; + default: break; } @@ -81,6 +91,7 @@ template inline constexpr uint32_t cn_select_mask() { retur template<> inline constexpr uint32_t cn_select_mask() { return CRYPTONIGHT_MASK; } template<> inline constexpr uint32_t cn_select_mask() { return CRYPTONIGHT_LITE_MASK; } template<> inline constexpr uint32_t cn_select_mask() { return CRYPTONIGHT_HEAVY_MASK; } +template<> inline constexpr uint32_t cn_select_mask() { return CRYPTONIGHT_PICO_MASK; } inline uint32_t cn_select_mask(Algo algorithm) @@ -96,6 +107,9 @@ inline uint32_t cn_select_mask(Algo algorithm) case CRYPTONIGHT_HEAVY: return CRYPTONIGHT_HEAVY_MASK; + case CRYPTONIGHT_PICO: + return CRYPTONIGHT_PICO_MASK; + default: break; } @@ -118,6 +132,7 @@ template<> inline constexpr uint32_t cn_select_iter template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_HEAVY_ITER; } template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_HEAVY_ITER; } template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_HEAVY_ITER; } +template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_TRTL_ITER; } inline uint32_t cn_select_iter(Algo algorithm, Variant variant) @@ -130,6 +145,9 @@ inline uint32_t cn_select_iter(Algo algorithm, Variant variant) case VARIANT_RTO: return CRYPTONIGHT_XAO_ITER; + case VARIANT_TRTL: + return CRYPTONIGHT_TRTL_ITER; + default: break; } @@ -164,9 +182,10 @@ template<> inline constexpr Variant cn_base_variant() { return VA template<> inline constexpr Variant cn_base_variant() { return VARIANT_1; } template<> inline constexpr Variant cn_base_variant() { return VARIANT_2; } template<> inline constexpr Variant cn_base_variant() { return VARIANT_2; } +template<> inline constexpr Variant cn_base_variant() { return VARIANT_2; } } /* namespace xmrig */ -#endif /* __CRYPTONIGHT_CONSTANTS_H__ */ +#endif /* XMRIG_CRYPTONIGHT_CONSTANTS_H */ diff --git a/src/crypto/CryptoNight_test.h b/src/crypto/CryptoNight_test.h index 63550ed8..ed2c9e0a 100644 --- a/src/crypto/CryptoNight_test.h +++ b/src/crypto/CryptoNight_test.h @@ -6,6 +6,7 @@ * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , * Copyright 2018 Lee Clagett + * Copyright 2018-2019 SChernykh * Copyright 2016-2019 XMRig , * * This program is free software: you can redistribute it and/or modify @@ -254,4 +255,21 @@ const static uint8_t test_output_tube_heavy[160] = { #endif +#ifndef XMRIG_NO_CN_PICO +// "cn-pico/trtl" +const static uint8_t test_output_pico_trtl[160] = { + 0x08, 0xF4, 0x21, 0xD7, 0x83, 0x31, 0x17, 0x30, 0x0E, 0xDA, 0x66, 0xE9, 0x8F, 0x4A, 0x25, 0x69, + 0x09, 0x3D, 0xF3, 0x00, 0x50, 0x01, 0x73, 0x94, 0x4E, 0xFC, 0x40, 0x1E, 0x9A, 0x4A, 0x17, 0xAF, + 0xB2, 0x17, 0x2E, 0xC9, 0x46, 0x6E, 0x1A, 0xEE, 0x70, 0xEC, 0x85, 0x72, 0xA1, 0x4C, 0x23, 0x3E, + 0xE3, 0x54, 0x58, 0x2B, 0xCB, 0x93, 0xF8, 0x69, 0xD4, 0x29, 0x74, 0x4D, 0xE5, 0x72, 0x6A, 0x26, + 0x4E, 0xFD, 0x28, 0xFC, 0xD3, 0x74, 0x8A, 0x83, 0xF3, 0xCA, 0x92, 0x84, 0xE7, 0x4E, 0x10, 0xC2, + 0x05, 0x62, 0xC7, 0xBE, 0x99, 0x73, 0xED, 0x90, 0xB5, 0x6F, 0xDA, 0x64, 0x71, 0x2D, 0x99, 0x39, + 0x29, 0xDB, 0x22, 0x2B, 0x97, 0xB6, 0x37, 0x0E, 0x9A, 0x03, 0x65, 0xCC, 0xF7, 0xD0, 0x9A, 0xB7, + 0x68, 0xCE, 0x07, 0x3E, 0x15, 0x40, 0x3C, 0xCE, 0x8C, 0x63, 0x16, 0x72, 0xB5, 0x74, 0x84, 0xF4, + 0xA1, 0xE7, 0x53, 0x85, 0xFB, 0x72, 0xDD, 0x75, 0x90, 0x39, 0xB2, 0x3D, 0xC3, 0x08, 0x2C, 0xD5, + 0x01, 0x08, 0x27, 0x75, 0x86, 0xB9, 0xBB, 0x9B, 0xDF, 0xEA, 0x49, 0xDE, 0x46, 0xCB, 0x83, 0x45 +}; +#endif + + #endif /* XMRIG_CRYPTONIGHT_TEST_H */ diff --git a/src/crypto/CryptoNight_x86.h b/src/crypto/CryptoNight_x86.h index d3ff25bc..1ba624be 100644 --- a/src/crypto/CryptoNight_x86.h +++ b/src/crypto/CryptoNight_x86.h @@ -458,6 +458,8 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si constexpr size_t MEM = xmrig::cn_select_memory(); constexpr xmrig::Variant BASE = xmrig::cn_base_variant(); + static_assert(MASK > 0 && ITERATIONS > 0 && MEM > 0, "unsupported algorithm/variant"); + if (BASE == xmrig::VARIANT_1 && size < 43) { memset(output, 0, 32); return; diff --git a/src/workers/CpuThread.cpp b/src/workers/CpuThread.cpp index db02bda7..552e809a 100644 --- a/src/workers/CpuThread.cpp +++ b/src/workers/CpuThread.cpp @@ -135,12 +135,12 @@ xmrig::CpuThread::cn_hash_fun xmrig::CpuThread::fn(Algo algorithm, AlgoVariant a assert(variant >= VARIANT_0 && variant < VARIANT_MAX); # ifndef XMRIG_NO_ASM - constexpr const size_t count = VARIANT_MAX * 10 * 3 + 8; + constexpr const size_t count = VARIANT_MAX * 10 * CRYPTONIGHT_MAX + 8; # else - constexpr const size_t count = VARIANT_MAX * 10 * 3; + constexpr const size_t count = VARIANT_MAX * 10 * CRYPTONIGHT_MAX; # endif - static const cn_hash_fun func_table[count] = { + static const cn_hash_fun func_table[] = { cryptonight_single_hash, cryptonight_double_hash, cryptonight_single_hash, @@ -233,6 +233,8 @@ xmrig::CpuThread::cn_hash_fun xmrig::CpuThread::fn(Algo algorithm, AlgoVariant a cryptonight_quad_hash, cryptonight_penta_hash, + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_TRTL + # ifndef XMRIG_NO_AEON cryptonight_single_hash, cryptonight_double_hash, @@ -263,18 +265,20 @@ xmrig::CpuThread::cn_hash_fun xmrig::CpuThread::fn(Algo algorithm, AlgoVariant a nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_XAO nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_RTO nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_2 - nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_XTL2 + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_HALF + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_TRTL # 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, + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // 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_TUBE + 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 + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_XAO + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_RTO + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_2 + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_HALF + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_TRTL # endif # ifndef XMRIG_NO_SUMO @@ -319,18 +323,55 @@ xmrig::CpuThread::cn_hash_fun xmrig::CpuThread::fn(Algo algorithm, AlgoVariant a nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_XAO nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_RTO nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_2 - nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_XTL2 + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_HALF + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_TRTL # 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, + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // 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_TUBE + 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 + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_XAO + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_RTO + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_2 + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_HALF + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_TRTL +# endif +# ifndef XMRIG_NO_CN_PICO + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // 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_TUBE + 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 + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_XAO + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_RTO + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_2 + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_HALF + + cryptonight_single_hash, + cryptonight_double_hash, + cryptonight_single_hash, + cryptonight_double_hash, + cryptonight_triple_hash, + cryptonight_quad_hash, + cryptonight_penta_hash, + cryptonight_triple_hash, + cryptonight_quad_hash, + cryptonight_penta_hash, +# else + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // 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_TUBE + 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 + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_XAO + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_RTO + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_2 + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_HALF + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_TRTL # endif # ifndef XMRIG_NO_ASM cryptonight_single_hash_asm, @@ -345,6 +386,9 @@ xmrig::CpuThread::cn_hash_fun xmrig::CpuThread::fn(Algo algorithm, AlgoVariant a # endif }; + + static_assert(count == sizeof(func_table) / sizeof(func_table[0]), "func_table size mismatch"); + # ifndef NDEBUG const size_t index = fnIndex(algorithm, av, variant, assembly); cn_hash_fun func = func_table[index]; @@ -531,7 +575,7 @@ size_t xmrig::CpuThread::fnIndex(Algo algorithm, AlgoVariant av, Variant variant return index; } - constexpr const size_t offset = VARIANT_MAX * 10 * 3; + constexpr const size_t offset = VARIANT_MAX * 10 * CRYPTONIGHT_MAX; size_t extra_offset = 0; if (algorithm == CRYPTONIGHT && (variant == VARIANT_2 || variant == VARIANT_HALF)) { diff --git a/src/workers/MultiWorker.cpp b/src/workers/MultiWorker.cpp index f0188322..eff33062 100644 --- a/src/workers/MultiWorker.cpp +++ b/src/workers/MultiWorker.cpp @@ -79,6 +79,12 @@ bool MultiWorker::selfTest() } # endif +# ifndef XMRIG_NO_CN_PICO + if (m_thread->algorithm() == CRYPTONIGHT_PICO) { + return verify(VARIANT_TRTL, test_output_pico_trtl); + } +# endif + return false; } From bc26d2ede6f6376f2bae1013e95fb7340f0c586b Mon Sep 17 00:00:00 2001 From: XMRig Date: Mon, 21 Jan 2019 00:32:24 +0700 Subject: [PATCH 3/7] #904 Add ASM implementation. --- src/crypto/CryptoNight_x86.h | 25 +++++++++++++++++++--- src/workers/CpuThread.cpp | 41 +++++++++++++++++++++++++++++++----- 2 files changed, 58 insertions(+), 8 deletions(-) diff --git a/src/crypto/CryptoNight_x86.h b/src/crypto/CryptoNight_x86.h index 1ba624be..a8c2c309 100644 --- a/src/crypto/CryptoNight_x86.h +++ b/src/crypto/CryptoNight_x86.h @@ -572,11 +572,16 @@ extern "C" void cnv2_mainloop_ryzen_asm(cryptonight_ctx *ctx); extern "C" void cnv2_mainloop_bulldozer_asm(cryptonight_ctx *ctx); extern "C" void cnv2_double_mainloop_sandybridge_asm(cryptonight_ctx *ctx0, cryptonight_ctx *ctx1); -extern xmrig::CpuThread::cn_mainloop_fun cn_half_mainloop_ivybridge_asm; -extern xmrig::CpuThread::cn_mainloop_fun cn_half_mainloop_ryzen_asm; -extern xmrig::CpuThread::cn_mainloop_fun cn_half_mainloop_bulldozer_asm; +extern xmrig::CpuThread::cn_mainloop_fun cn_half_mainloop_ivybridge_asm; +extern xmrig::CpuThread::cn_mainloop_fun cn_half_mainloop_ryzen_asm; +extern xmrig::CpuThread::cn_mainloop_fun cn_half_mainloop_bulldozer_asm; extern xmrig::CpuThread::cn_mainloop_double_fun cn_half_double_mainloop_sandybridge_asm; +extern xmrig::CpuThread::cn_mainloop_fun cn_trtl_mainloop_ivybridge_asm; +extern xmrig::CpuThread::cn_mainloop_fun cn_trtl_mainloop_ryzen_asm; +extern xmrig::CpuThread::cn_mainloop_fun cn_trtl_mainloop_bulldozer_asm; +extern xmrig::CpuThread::cn_mainloop_double_fun cn_trtl_double_mainloop_sandybridge_asm; + template inline void cryptonight_single_hash_asm(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx) @@ -608,6 +613,17 @@ inline void cryptonight_single_hash_asm(const uint8_t *__restrict__ input, size_ cn_half_mainloop_bulldozer_asm(ctx[0]); } } + else if (VARIANT == xmrig::VARIANT_TRTL) { + if (ASM == xmrig::ASM_INTEL) { + cn_trtl_mainloop_ivybridge_asm(ctx[0]); + } + else if (ASM == xmrig::ASM_RYZEN) { + cn_trtl_mainloop_ryzen_asm(ctx[0]); + } + else { + cn_trtl_mainloop_bulldozer_asm(ctx[0]); + } + } cn_implode_scratchpad(reinterpret_cast<__m128i*>(ctx[0]->memory), reinterpret_cast<__m128i*>(ctx[0]->state)); xmrig::keccakf(reinterpret_cast(ctx[0]->state), 24); @@ -632,6 +648,9 @@ inline void cryptonight_double_hash_asm(const uint8_t *__restrict__ input, size_ else if (VARIANT == xmrig::VARIANT_HALF) { cn_half_double_mainloop_sandybridge_asm(ctx[0], ctx[1]); } + else if (VARIANT == xmrig::VARIANT_TRTL) { + cn_trtl_double_mainloop_sandybridge_asm(ctx[0], ctx[1]); + } cn_implode_scratchpad(reinterpret_cast<__m128i*>(ctx[0]->memory), reinterpret_cast<__m128i*>(ctx[0]->state)); cn_implode_scratchpad(reinterpret_cast<__m128i*>(ctx[1]->memory), reinterpret_cast<__m128i*>(ctx[1]->state)); diff --git a/src/workers/CpuThread.cpp b/src/workers/CpuThread.cpp index 552e809a..af55b0da 100644 --- a/src/workers/CpuThread.cpp +++ b/src/workers/CpuThread.cpp @@ -97,11 +97,16 @@ extern "C" void cnv2_mainloop_bulldozer_asm(cryptonight_ctx *ctx); extern "C" void cnv2_double_mainloop_sandybridge_asm(cryptonight_ctx *ctx0, cryptonight_ctx *ctx1); -xmrig::CpuThread::cn_mainloop_fun cn_half_mainloop_ivybridge_asm = nullptr; -xmrig::CpuThread::cn_mainloop_fun cn_half_mainloop_ryzen_asm = nullptr; -xmrig::CpuThread::cn_mainloop_fun cn_half_mainloop_bulldozer_asm = nullptr; +xmrig::CpuThread::cn_mainloop_fun cn_half_mainloop_ivybridge_asm = nullptr; +xmrig::CpuThread::cn_mainloop_fun cn_half_mainloop_ryzen_asm = nullptr; +xmrig::CpuThread::cn_mainloop_fun cn_half_mainloop_bulldozer_asm = nullptr; xmrig::CpuThread::cn_mainloop_double_fun cn_half_double_mainloop_sandybridge_asm = nullptr; +xmrig::CpuThread::cn_mainloop_fun cn_trtl_mainloop_ivybridge_asm = nullptr; +xmrig::CpuThread::cn_mainloop_fun cn_trtl_mainloop_ryzen_asm = nullptr; +xmrig::CpuThread::cn_mainloop_fun cn_trtl_mainloop_bulldozer_asm = nullptr; +xmrig::CpuThread::cn_mainloop_double_fun cn_trtl_double_mainloop_sandybridge_asm = nullptr; + void xmrig::CpuThread::patchAsmVariants() { @@ -113,11 +118,21 @@ void xmrig::CpuThread::patchAsmVariants() cn_half_mainloop_bulldozer_asm = reinterpret_cast (base + 0x2000); cn_half_double_mainloop_sandybridge_asm = reinterpret_cast (base + 0x3000); + cn_trtl_mainloop_ivybridge_asm = reinterpret_cast (base + 0x4000); + cn_trtl_mainloop_ryzen_asm = reinterpret_cast (base + 0x5000); + cn_trtl_mainloop_bulldozer_asm = reinterpret_cast (base + 0x6000); + cn_trtl_double_mainloop_sandybridge_asm = reinterpret_cast (base + 0x7000); + patchCode(cn_half_mainloop_ivybridge_asm, cnv2_mainloop_ivybridge_asm, xmrig::CRYPTONIGHT_HALF_ITER, xmrig::CRYPTONIGHT_MASK); patchCode(cn_half_mainloop_ryzen_asm, cnv2_mainloop_ryzen_asm, xmrig::CRYPTONIGHT_HALF_ITER, xmrig::CRYPTONIGHT_MASK); patchCode(cn_half_mainloop_bulldozer_asm, cnv2_mainloop_bulldozer_asm, xmrig::CRYPTONIGHT_HALF_ITER, xmrig::CRYPTONIGHT_MASK); patchCode(cn_half_double_mainloop_sandybridge_asm, cnv2_double_mainloop_sandybridge_asm, xmrig::CRYPTONIGHT_HALF_ITER, xmrig::CRYPTONIGHT_MASK); + patchCode(cn_trtl_mainloop_ivybridge_asm, cnv2_mainloop_ivybridge_asm, xmrig::CRYPTONIGHT_TRTL_ITER, xmrig::CRYPTONIGHT_PICO_MASK); + patchCode(cn_trtl_mainloop_ryzen_asm, cnv2_mainloop_ryzen_asm, xmrig::CRYPTONIGHT_TRTL_ITER, xmrig::CRYPTONIGHT_PICO_MASK); + patchCode(cn_trtl_mainloop_bulldozer_asm, cnv2_mainloop_bulldozer_asm, xmrig::CRYPTONIGHT_TRTL_ITER, xmrig::CRYPTONIGHT_PICO_MASK); + patchCode(cn_trtl_double_mainloop_sandybridge_asm, cnv2_double_mainloop_sandybridge_asm, xmrig::CRYPTONIGHT_TRTL_ITER, xmrig::CRYPTONIGHT_PICO_MASK); + Mem::protectExecutableMemory(base, allocation_size); Mem::flushInstructionCache(base, allocation_size); } @@ -135,7 +150,7 @@ xmrig::CpuThread::cn_hash_fun xmrig::CpuThread::fn(Algo algorithm, AlgoVariant a assert(variant >= VARIANT_0 && variant < VARIANT_MAX); # ifndef XMRIG_NO_ASM - constexpr const size_t count = VARIANT_MAX * 10 * CRYPTONIGHT_MAX + 8; + constexpr const size_t count = VARIANT_MAX * 10 * CRYPTONIGHT_MAX + 12; # else constexpr const size_t count = VARIANT_MAX * 10 * CRYPTONIGHT_MAX; # endif @@ -382,7 +397,12 @@ xmrig::CpuThread::cn_hash_fun xmrig::CpuThread::fn(Algo algorithm, AlgoVariant a cryptonight_single_hash_asm, cryptonight_single_hash_asm, cryptonight_single_hash_asm, - cryptonight_double_hash_asm + cryptonight_double_hash_asm, + + cryptonight_single_hash_asm, + cryptonight_single_hash_asm, + cryptonight_single_hash_asm, + cryptonight_double_hash_asm # endif }; @@ -587,6 +607,17 @@ size_t xmrig::CpuThread::fnIndex(Algo algorithm, AlgoVariant av, Variant variant return offset + extra_offset + assembly - 2; } + if (av == AV_DOUBLE) { + return offset + 3 + extra_offset; + } + } + else if (algorithm == CRYPTONIGHT_PICO && variant == VARIANT_TRTL) { + extra_offset = 8; + + if (av == AV_SINGLE) { + return offset + extra_offset + assembly - 2; + } + if (av == AV_DOUBLE) { return offset + 3 + extra_offset; } From 9692f92c6b971cf90af7d59308646afd7b9027c2 Mon Sep 17 00:00:00 2001 From: XMRig Date: Mon, 21 Jan 2019 00:37:36 +0700 Subject: [PATCH 4/7] New default value for max-cpu-usage option is 100 (instead of 75) also this option now deprecated. --- src/core/Config.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/Config.cpp b/src/core/Config.cpp index c8891c77..e91a9f2b 100644 --- a/src/core/Config.cpp +++ b/src/core/Config.cpp @@ -5,7 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2016-2018 XMRig , + * Copyright 2018-2019 SChernykh + * Copyright 2016-2019 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -48,7 +49,7 @@ xmrig::Config::Config() : xmrig::CommonConfig(), m_hugePages(true), m_safe(false), m_shouldSave(false), - m_maxCpuUsage(75), + m_maxCpuUsage(100), m_priority(-1) { } From 046c345f65ab69a45fb304d222dbe15692289e94 Mon Sep 17 00:00:00 2001 From: XMRig Date: Mon, 21 Jan 2019 01:44:15 +0700 Subject: [PATCH 5/7] Fix memory allocation. --- src/Mem.cpp | 11 +++++++++-- src/config.json | 2 +- src/workers/Workers.cpp | 6 +++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Mem.cpp b/src/Mem.cpp index 1e7e1e3c..85a3a832 100644 --- a/src/Mem.cpp +++ b/src/Mem.cpp @@ -34,7 +34,6 @@ bool Mem::m_enabled = true; int Mem::m_flags = 0; - MemInfo Mem::create(cryptonight_ctx **ctx, xmrig::Algo algorithm, size_t count) { using namespace xmrig; @@ -43,7 +42,15 @@ MemInfo Mem::create(cryptonight_ctx **ctx, xmrig::Algo algorithm, size_t count) info.size = cn_select_memory(algorithm) * count; # ifndef XMRIG_NO_AEON - info.size += info.size % cn_select_memory(); + if (algorithm == xmrig::CRYPTONIGHT_LITE) { + info.size += info.size % cn_select_memory(); + } +# endif + +# ifndef XMRIG_NO_CN_PICO + if (algorithm == xmrig::CRYPTONIGHT_PICO) { + info.size = cn_select_memory(); + } # endif info.pages = info.size / cn_select_memory(); diff --git a/src/config.json b/src/config.json index ae85b1f7..f6646c11 100644 --- a/src/config.json +++ b/src/config.json @@ -19,7 +19,7 @@ "huge-pages": true, "hw-aes": null, "log-file": null, - "max-cpu-usage": 75, + "max-cpu-usage": 100, "pools": [ { "url": "donate.v2.xmrig.com:3333", diff --git a/src/workers/Workers.cpp b/src/workers/Workers.cpp index d6201ebf..735ed586 100644 --- a/src/workers/Workers.cpp +++ b/src/workers/Workers.cpp @@ -346,16 +346,16 @@ void Workers::start(IWorker *worker) if (m_status.started == m_status.threads) { const double percent = (double) m_status.hugePages / m_status.pages * 100.0; - const size_t memory = m_status.ways * xmrig::cn_select_memory(m_status.algo) / 1048576; + const size_t memory = m_status.ways * xmrig::cn_select_memory(m_status.algo) / 1024; if (m_status.colors) { - LOG_INFO(GREEN_BOLD("READY (CPU)") " threads " CYAN_BOLD("%zu(%zu)") " huge pages %s%zu/%zu %1.0f%%\x1B[0m memory " CYAN_BOLD("%zu.0 MB") "", + LOG_INFO(GREEN_BOLD("READY (CPU)") " threads " CYAN_BOLD("%zu(%zu)") " huge pages %s%zu/%zu %1.0f%%\x1B[0m memory " CYAN_BOLD("%zu KB") "", m_status.threads, m_status.ways, (m_status.hugePages == m_status.pages ? "\x1B[1;32m" : (m_status.hugePages == 0 ? "\x1B[1;31m" : "\x1B[1;33m")), m_status.hugePages, m_status.pages, percent, memory); } else { - LOG_INFO("READY (CPU) threads %zu(%zu) huge pages %zu/%zu %1.0f%% memory %zu.0 MB", + LOG_INFO("READY (CPU) threads %zu(%zu) huge pages %zu/%zu %1.0f%% memory %zu KB", m_status.threads, m_status.ways, m_status.hugePages, m_status.pages, percent, memory); } } From f478fa843d5dcaf797b19e826149ebc618b5bd61 Mon Sep 17 00:00:00 2001 From: XMRig Date: Mon, 21 Jan 2019 17:27:45 +0700 Subject: [PATCH 6/7] Better fix for memory allocation, thanks @SChernykh. --- src/Mem.cpp | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/Mem.cpp b/src/Mem.cpp index 85a3a832..76114745 100644 --- a/src/Mem.cpp +++ b/src/Mem.cpp @@ -41,19 +41,9 @@ MemInfo Mem::create(cryptonight_ctx **ctx, xmrig::Algo algorithm, size_t count) MemInfo info; info.size = cn_select_memory(algorithm) * count; -# ifndef XMRIG_NO_AEON - if (algorithm == xmrig::CRYPTONIGHT_LITE) { - info.size += info.size % cn_select_memory(); - } -# endif - -# ifndef XMRIG_NO_CN_PICO - if (algorithm == xmrig::CRYPTONIGHT_PICO) { - info.size = cn_select_memory(); - } -# endif - - info.pages = info.size / cn_select_memory(); + constexpr const size_t align_size = 2 * 1024 * 1024; + info.size = ((info.size + align_size - 1) / align_size) * align_size; + info.pages = info.size / align_size; allocate(info, m_enabled); From b1816005fdb6c587e40e2546ec4dff0fadc19b16 Mon Sep 17 00:00:00 2001 From: XMRig Date: Mon, 21 Jan 2019 19:16:49 +0700 Subject: [PATCH 7/7] Sync changes with proxy. --- src/common/crypto/Algorithm.cpp | 4 ++++ src/common/net/Job.h | 2 +- src/common/net/Pool.cpp | 6 +++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/common/crypto/Algorithm.cpp b/src/common/crypto/Algorithm.cpp index d61f85b1..6d408cd2 100644 --- a/src/common/crypto/Algorithm.cpp +++ b/src/common/crypto/Algorithm.cpp @@ -234,6 +234,10 @@ void xmrig::Algorithm::parseVariant(int variant) void xmrig::Algorithm::setAlgo(Algo algo) { m_algo = algo; + + if (m_algo == CRYPTONIGHT_PICO && m_variant == VARIANT_AUTO) { + m_variant = xmrig::VARIANT_TRTL; + } } diff --git a/src/common/net/Job.h b/src/common/net/Job.h index 6922b0ce..398e99ae 100644 --- a/src/common/net/Job.h +++ b/src/common/net/Job.h @@ -105,7 +105,7 @@ private: xmrig::Id m_id; # ifdef XMRIG_PROXY_PROJECT - char m_rawBlob[176]; + char m_rawBlob[kMaxBlobSize * 2 + 8]; char m_rawTarget[24]; # endif }; diff --git a/src/common/net/Pool.cpp b/src/common/net/Pool.cpp index a44f8a41..7e8fa1dc 100644 --- a/src/common/net/Pool.cpp +++ b/src/common/net/Pool.cpp @@ -5,7 +5,7 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018 SChernykh + * Copyright 2018-2019 SChernykh * Copyright 2016-2019 XMRig , * * This program is free software: you can redistribute it and/or modify @@ -106,8 +106,8 @@ bool Pool::isCompatible(const xmrig::Algorithm &algorithm) const } # ifdef XMRIG_PROXY_PROJECT - if (m_algorithm.algo() == xmrig::CRYPTONIGHT && algorithm.algo() == xmrig::CRYPTONIGHT && m_algorithm.variant() == xmrig::VARIANT_XTL) { - return true; + if (m_algorithm.algo() == xmrig::CRYPTONIGHT && algorithm.algo() == xmrig::CRYPTONIGHT) { + return m_algorithm.variant() == xmrig::VARIANT_XTL || m_algorithm.variant() == xmrig::VARIANT_MSR; } # endif