From 9be3b69109cb335a607e24a7c4ebc5d5c36d91a1 Mon Sep 17 00:00:00 2001 From: cohcho Date: Fri, 25 Sep 2020 14:36:06 +0000 Subject: [PATCH] soft_aes: fix previous optimization the best order of hash/fill/prefetch depends on hw/soft AES only hw AES is faster after previous optimization --- src/crypto/randomx/aes_hash.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/crypto/randomx/aes_hash.cpp b/src/crypto/randomx/aes_hash.cpp index a15f75ad..274a9d4c 100644 --- a/src/crypto/randomx/aes_hash.cpp +++ b/src/crypto/randomx/aes_hash.cpp @@ -260,14 +260,26 @@ void hashAndFillAes1Rx4(void *scratchpad, size_t scratchpadSize, void *hash, voi rx_store_vec_i128((rx_vec_i128*)scratchpadPtr + k * 4 + 2, fill_state2); \ rx_store_vec_i128((rx_vec_i128*)scratchpadPtr + k * 4 + 3, fill_state3); - HASH_STATE(0); - HASH_STATE(1); + switch(softAes) { + case 0: + HASH_STATE(0); + HASH_STATE(1); - FILL_STATE(0); - FILL_STATE(1); + FILL_STATE(0); + FILL_STATE(1); - rx_prefetch_t0(prefetchPtr); - rx_prefetch_t0(prefetchPtr + 64); + rx_prefetch_t0(prefetchPtr); + rx_prefetch_t0(prefetchPtr + 64); + break; + default: + HASH_STATE(0); + FILL_STATE(0); + rx_prefetch_t0(prefetchPtr); + + HASH_STATE(1); + FILL_STATE(1); + rx_prefetch_t0(prefetchPtr + 64); + } scratchpadPtr += 128; prefetchPtr += 128;