RandomX: returned old soft AES impl and auto-select between the two
This commit is contained in:
parent
852fe14604
commit
8d1168385a
16 changed files with 194 additions and 101 deletions
|
@ -35,6 +35,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "crypto/randomx/blake2/blake2.h"
|
||||
#include "crypto/randomx/intrin_portable.h"
|
||||
#include "crypto/randomx/allocator.hpp"
|
||||
#include "crypto/randomx/soft_aes.h"
|
||||
#include "base/tools/Profiler.h"
|
||||
|
||||
randomx_vm::~randomx_vm() {
|
||||
|
@ -96,11 +97,11 @@ void randomx_vm::initialize() {
|
|||
|
||||
namespace randomx {
|
||||
|
||||
template<bool softAes>
|
||||
template<int softAes>
|
||||
VmBase<softAes>::~VmBase() {
|
||||
}
|
||||
|
||||
template<bool softAes>
|
||||
template<int softAes>
|
||||
void VmBase<softAes>::setScratchpad(uint8_t *scratchpad) {
|
||||
if (datasetPtr == nullptr) {
|
||||
throw std::invalid_argument("Cache/Dataset not set");
|
||||
|
@ -109,24 +110,35 @@ namespace randomx {
|
|||
this->scratchpad = scratchpad;
|
||||
}
|
||||
|
||||
template<bool softAes>
|
||||
template<int softAes>
|
||||
void VmBase<softAes>::getFinalResult(void* out) {
|
||||
hashAes1Rx4<softAes>(scratchpad, ScratchpadSize, ®.a);
|
||||
rx_blake2b_wrapper::run(out, RANDOMX_HASH_SIZE, ®, sizeof(RegisterFile));
|
||||
}
|
||||
|
||||
template<bool softAes>
|
||||
template<int softAes>
|
||||
void VmBase<softAes>::hashAndFill(void* out, uint64_t (&fill_state)[8]) {
|
||||
hashAndFillAes1Rx4<softAes>(scratchpad, ScratchpadSize, ®.a, fill_state);
|
||||
if (!softAes) {
|
||||
hashAndFillAes1Rx4<0>(scratchpad, ScratchpadSize, ®.a, fill_state);
|
||||
}
|
||||
else {
|
||||
if (GetSoftAESImpl() == 1) {
|
||||
hashAndFillAes1Rx4<1>(scratchpad, ScratchpadSize, ®.a, fill_state);
|
||||
}
|
||||
else {
|
||||
hashAndFillAes1Rx4<2>(scratchpad, ScratchpadSize, ®.a, fill_state);
|
||||
}
|
||||
}
|
||||
|
||||
rx_blake2b_wrapper::run(out, RANDOMX_HASH_SIZE, ®, sizeof(RegisterFile));
|
||||
}
|
||||
|
||||
template<bool softAes>
|
||||
template<int softAes>
|
||||
void VmBase<softAes>::initScratchpad(void* seed) {
|
||||
fillAes1Rx4<softAes>(seed, ScratchpadSize, scratchpad);
|
||||
}
|
||||
|
||||
template<bool softAes>
|
||||
template<int softAes>
|
||||
void VmBase<softAes>::generateProgram(void* seed) {
|
||||
PROFILE_SCOPE(RandomX_generate_program);
|
||||
fillAes4Rx4<softAes>(seed, 128 + RandomX_CurrentConfig.ProgramSize * 8, &program);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue