Skip to content

Commit

Permalink
Improved Flex algo speed
Browse files Browse the repository at this point in the history
  • Loading branch information
MoneroOcean committed May 29, 2024
1 parent 0ec9860 commit 35ede29
Show file tree
Hide file tree
Showing 31 changed files with 33 additions and 4,787 deletions.
10 changes: 0 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,6 @@ set(SOURCES_CRYPTO
src/crypto/common/Nonce.cpp
src/crypto/common/VirtualMemory.cpp
src/crypto/flex/flex.cpp
src/crypto/flex/cryptonote/cryptonight_dark.c
src/crypto/flex/cryptonote/cryptonight_dark_lite.c
src/crypto/flex/cryptonote/cryptonight_fast.c
src/crypto/flex/cryptonote/cryptonight_lite.c
src/crypto/flex/cryptonote/cryptonight_turtle.c
src/crypto/flex/cryptonote/cryptonight_turtle_lite.c
src/crypto/flex/cryptonote/crypto/oaes_lib.c
src/crypto/flex/cryptonote/crypto/aesb.c
src/crypto/flex/cryptonote/crypto/hash.c
src/crypto/flex/cryptonote/crypto/c_keccak.c
)

if (WITH_MO_BENCHMARK)
Expand Down
21 changes: 18 additions & 3 deletions src/crypto/cn/CryptoNight_x86.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,14 @@ static inline void do_skein_hash(const uint8_t *input, size_t len, uint8_t *outp
xmr_skein(input, output);
}

static inline void do_flex_skein_hash(const uint8_t* input, size_t len, uint8_t* output) {
int r = skein_hash(512, input, 8 * len, (uint8_t*)output);
assert(SKEIN_SUCCESS == r);
}


void (* const extra_hashes[4])(const uint8_t *, size_t, uint8_t *) = {do_blake_hash, do_groestl_hash, do_jh_hash, do_skein_hash};
void (* const extra_hashes_flex[3])(const uint8_t *, size_t, uint8_t *) = {do_blake_hash, do_groestl_hash, do_flex_skein_hash};


#if (defined(__i386__) || defined(_M_IX86)) && !(defined(__clang__) && defined(__clang_major__) && (__clang_major__ >= 15))
Expand Down Expand Up @@ -853,7 +859,10 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si

cn_implode_scratchpad<ALGO, SOFT_AES, interleave>(ctx[0]);
keccakf(h0, 24);
extra_hashes[ctx[0]->state[0] & 3](ctx[0]->state, 200, output);
if (height == 101) // Flex algo ugly hack
extra_hashes_flex[ctx[0]->state[0] & 2](ctx[0]->state, 200, output);
else
extra_hashes[ctx[0]->state[0] & 3](ctx[0]->state, 200, output);
}


Expand Down Expand Up @@ -1125,7 +1134,10 @@ inline void cryptonight_single_hash_asm(const uint8_t *__restrict__ input, size_

cn_implode_scratchpad<ALGO, false, 0>(ctx[0]);
keccakf(reinterpret_cast<uint64_t*>(ctx[0]->state), 24);
extra_hashes[ctx[0]->state[0] & 3](ctx[0]->state, 200, output);
if (height == 101) // Flex algo ugly hack
extra_hashes_flex[ctx[0]->state[0] & 2](ctx[0]->state, 200, output);
else
extra_hashes[ctx[0]->state[0] & 3](ctx[0]->state, 200, output);
}


Expand Down Expand Up @@ -1253,7 +1265,10 @@ static NOINLINE void cryptonight_single_hash_gr_sse41(const uint8_t* __restrict_

cn_implode_scratchpad<ALGO, false, 0>(ctx[0]);
keccakf(reinterpret_cast<uint64_t*>(ctx[0]->state), 24);
extra_hashes[ctx[0]->state[0] & 3](ctx[0]->state, 200, output);
if (height == 101) // Flex algo ugly hack
extra_hashes_flex[ctx[0]->state[0] & 2](ctx[0]->state, 200, output);
else
extra_hashes[ctx[0]->state[0] & 3](ctx[0]->state, 200, output);
}


Expand Down
177 changes: 0 additions & 177 deletions src/crypto/flex/cryptonote/crypto/aesb.c

This file was deleted.

43 changes: 0 additions & 43 deletions src/crypto/flex/cryptonote/crypto/c_blake256.h

This file was deleted.

56 changes: 0 additions & 56 deletions src/crypto/flex/cryptonote/crypto/c_groestl.h

This file was deleted.

20 changes: 0 additions & 20 deletions src/crypto/flex/cryptonote/crypto/c_jh.h

This file was deleted.

Loading

0 comments on commit 35ede29

Please sign in to comment.