From 3b46f5eb6478e08b0c968f6ef12411f235029446 Mon Sep 17 00:00:00 2001 From: XMRig Date: Mon, 8 May 2017 23:28:39 +0300 Subject: [PATCH] Remove BMI2 av. --- CMakeLists.txt | 7 +- algo/cryptonight/bmi2/CMakeLists.txt | 2 - algo/cryptonight/cryptonight.c | 22 ++---- algo/cryptonight/cryptonight_av3_aesni_bmi2.c | 77 ------------------- ...v4_softaes.c => cryptonight_av3_softaes.c} | 2 +- ...ble.c => cryptonight_av4_softaes_double.c} | 2 +- options.c | 2 +- options.h | 5 +- 8 files changed, 14 insertions(+), 105 deletions(-) delete mode 100644 algo/cryptonight/bmi2/CMakeLists.txt delete mode 100644 algo/cryptonight/cryptonight_av3_aesni_bmi2.c rename algo/cryptonight/{cryptonight_av4_softaes.c => cryptonight_av3_softaes.c} (97%) rename algo/cryptonight/{cryptonight_av5_softaes_double.c => cryptonight_av4_softaes_double.c} (98%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 492a67faa..02f82f908 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,8 +42,8 @@ set(SOURCES algo/cryptonight/cryptonight.c algo/cryptonight/cryptonight_av1_aesni.c algo/cryptonight/cryptonight_av2_aesni_double.c - algo/cryptonight/cryptonight_av4_softaes.c - algo/cryptonight/cryptonight_av5_softaes_double.c + algo/cryptonight/cryptonight_av3_softaes.c + algo/cryptonight/cryptonight_av4_softaes_double.c util.c options.c stratum.c @@ -115,9 +115,8 @@ else() endif() if (CMAKE_SIZEOF_VOID_P EQUAL 8) - add_subdirectory(algo/cryptonight/bmi2) add_executable(xmrig ${HEADERS} ${HEADERS_CRYPTO} ${SOURCES} ${SOURCES_CRYPTO} ${HEADERS_UTILS} ${SOURCES_UTILS} ${HEADERS_COMPAT} ${SOURCES_COMPAT} ${SOURCES_OS} ${SOURCES_CPUID}) - target_link_libraries(xmrig jansson curl cryptonight_av3_aesni_bmi2 ${CPUID_LIB} ${EXTRA_LIBS}) + target_link_libraries(xmrig jansson curl ${CPUID_LIB} ${EXTRA_LIBS}) else() add_executable(xmrig32 ${HEADERS} ${HEADERS_CRYPTO} ${SOURCES} ${SOURCES_CRYPTO} ${HEADERS_UTILS} ${SOURCES_UTILS} ${HEADERS_COMPAT} ${SOURCES_COMPAT} ${SOURCES_OS} ${SOURCES_CPUID}) target_link_libraries(xmrig32 jansson curl ${CPUID_LIB} ${EXTRA_LIBS}) diff --git a/algo/cryptonight/bmi2/CMakeLists.txt b/algo/cryptonight/bmi2/CMakeLists.txt deleted file mode 100644 index c9a3fd856..000000000 --- a/algo/cryptonight/bmi2/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mbmi2") -add_library(cryptonight_av3_aesni_bmi2 STATIC ../cryptonight_av3_aesni_bmi2.c) diff --git a/algo/cryptonight/cryptonight.c b/algo/cryptonight/cryptonight.c index 827feb7cd..4b598033f 100644 --- a/algo/cryptonight/cryptonight.c +++ b/algo/cryptonight/cryptonight.c @@ -62,12 +62,8 @@ const static char test_output[64] = { void cryptonight_av1_aesni(const void* input, size_t size, void* output, struct cryptonight_ctx* ctx); void cryptonight_av2_aesni_double(const void* input, size_t size, void* output, struct cryptonight_ctx* ctx); -void cryptonight_av4_softaes(const void* input, size_t size, void* output, struct cryptonight_ctx* ctx); -void cryptonight_av5_softaes_double(const void* input, size_t size, void* output, struct cryptonight_ctx* ctx); - -#if defined(__x86_64__) - void cryptonight_av3_aesni_bmi2(const void* input, size_t size, void* output, struct cryptonight_ctx* ctx); -#endif +void cryptonight_av3_softaes(const void* input, size_t size, void* output, struct cryptonight_ctx* ctx); +void cryptonight_av4_softaes_double(const void* input, size_t size, void* output, struct cryptonight_ctx* ctx); void (*cryptonight_hash_ctx)(const void* input, size_t size, void* output, struct cryptonight_ctx* ctx) = NULL; @@ -99,19 +95,13 @@ bool cryptonight_init(int variant) cryptonight_hash_ctx = cryptonight_av2_aesni_double; break; -# if defined(__x86_64__) - case XMR_AV3_AESNI_BMI2: - cryptonight_hash_ctx = cryptonight_av3_aesni_bmi2; - break; -# endif - - case XMR_AV4_SOFT_AES: - cryptonight_hash_ctx = cryptonight_av4_softaes; + case XMR_AV3_SOFT_AES: + cryptonight_hash_ctx = cryptonight_av3_softaes; break; - case XMR_AV5_SOFT_AES_DOUBLE: + case XMR_AV4_SOFT_AES_DOUBLE: opt_double_hash = true; - cryptonight_hash_ctx = cryptonight_av5_softaes_double; + cryptonight_hash_ctx = cryptonight_av4_softaes_double; break; default: diff --git a/algo/cryptonight/cryptonight_av3_aesni_bmi2.c b/algo/cryptonight/cryptonight_av3_aesni_bmi2.c deleted file mode 100644 index 18582fce5..000000000 --- a/algo/cryptonight/cryptonight_av3_aesni_bmi2.c +++ /dev/null @@ -1,77 +0,0 @@ -/* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017 fireice-uk - * Copyright 2016-2017 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 - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include - -#include "cryptonight.h" -#include "cryptonight_aesni.h" -#include "crypto/c_keccak.h" - - -void cryptonight_av3_aesni_bmi2(const void *restrict input, size_t size, void *restrict output, struct cryptonight_ctx *restrict ctx) -{ - keccak((const uint8_t *) input, size, ctx->state0, 200); - - cn_explode_scratchpad((__m128i*) ctx->state0, (__m128i*) ctx->memory); - - const uint8_t* l0 = ctx->memory; - uint64_t* h0 = (uint64_t*) ctx->state0; - - uint64_t al0 = h0[0] ^ h0[4]; - uint64_t ah0 = h0[1] ^ h0[5]; - __m128i bx0 = _mm_set_epi64x(h0[3] ^ h0[7], h0[2] ^ h0[6]); - - uint64_t idx0 = h0[0] ^ h0[4]; - - for (size_t i = 0; __builtin_expect(i < 0x80000, 1); i++) { - __m128i cx; - cx = _mm_load_si128((__m128i *)&l0[idx0 & 0x1FFFF0]); - cx = _mm_aesenc_si128(cx, _mm_set_epi64x(ah0, al0)); - - _mm_store_si128((__m128i *)&l0[idx0 & 0x1FFFF0], _mm_xor_si128(bx0, cx)); - idx0 = _mm_cvtsi128_si64(cx); - bx0 = cx; - - uint64_t hi, lo, cl, ch; - cl = ((uint64_t*)&l0[idx0 & 0x1FFFF0])[0]; - ch = ((uint64_t*)&l0[idx0 & 0x1FFFF0])[1]; - lo = _mulx_u64(idx0, cl, &hi); - - al0 += hi; - ah0 += lo; - - ((uint64_t*)&l0[idx0 & 0x1FFFF0])[0] = al0; - ((uint64_t*)&l0[idx0 & 0x1FFFF0])[1] = ah0; - - ah0 ^= ch; - al0 ^= cl; - idx0 = al0; - } - - cn_implode_scratchpad((__m128i*) ctx->memory, (__m128i*) ctx->state0); - - keccakf(h0, 24); - extra_hashes[ctx->state0[0] & 3](ctx->state0, 200, output); -} diff --git a/algo/cryptonight/cryptonight_av4_softaes.c b/algo/cryptonight/cryptonight_av3_softaes.c similarity index 97% rename from algo/cryptonight/cryptonight_av4_softaes.c rename to algo/cryptonight/cryptonight_av3_softaes.c index cd0fc6f23..22be894d8 100644 --- a/algo/cryptonight/cryptonight_av4_softaes.c +++ b/algo/cryptonight/cryptonight_av3_softaes.c @@ -30,7 +30,7 @@ #include "crypto/c_keccak.h" -void cryptonight_av4_softaes(const void *restrict input, size_t size, void *restrict output, struct cryptonight_ctx *restrict ctx) +void cryptonight_av3_softaes(const void *restrict input, size_t size, void *restrict output, struct cryptonight_ctx *restrict ctx) { keccak((const uint8_t *) input, size, ctx->state0, 200); diff --git a/algo/cryptonight/cryptonight_av5_softaes_double.c b/algo/cryptonight/cryptonight_av4_softaes_double.c similarity index 98% rename from algo/cryptonight/cryptonight_av5_softaes_double.c rename to algo/cryptonight/cryptonight_av4_softaes_double.c index 113e228cb..afd4bebe1 100644 --- a/algo/cryptonight/cryptonight_av5_softaes_double.c +++ b/algo/cryptonight/cryptonight_av4_softaes_double.c @@ -30,7 +30,7 @@ #include "crypto/c_keccak.h" -void cryptonight_av5_softaes_double(const void *restrict input, size_t size, void *restrict output, struct cryptonight_ctx *restrict ctx) +void cryptonight_av4_softaes_double(const void *restrict input, size_t size, void *restrict output, struct cryptonight_ctx *restrict ctx) { keccak((const uint8_t *) input, size, ctx->state0, 200); keccak((const uint8_t *) input + size, size, ctx->state1, 200); diff --git a/options.c b/options.c index 302005ed4..9be20a391 100644 --- a/options.c +++ b/options.c @@ -117,7 +117,7 @@ static int get_algo_variant(int variant) { return XMR_AV1_AESNI; } - return XMR_AV4_SOFT_AES; + return XMR_AV3_SOFT_AES; } diff --git a/options.h b/options.h index 9f4a43a9d..eb466fbaa 100644 --- a/options.h +++ b/options.h @@ -36,9 +36,8 @@ enum xmr_algo_variant { XMR_AV0_AUTO, XMR_AV1_AESNI, XMR_AV2_AESNI_DOUBLE, - XMR_AV3_AESNI_BMI2, - XMR_AV4_SOFT_AES, - XMR_AV5_SOFT_AES_DOUBLE, + XMR_AV3_SOFT_AES, + XMR_AV4_SOFT_AES_DOUBLE, XMR_AV_MAX };