Add Dataset prefetch in interpreted VM (#52)

- to formally match the specification
- a small increase in interpreted mining speed (~4%)
This commit is contained in:
tevador 2019-06-10 16:00:04 +02:00 committed by GitHub
parent eb6f6bb041
commit 52aa36249e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 0 deletions

View File

@ -246,6 +246,7 @@ namespace randomx {
mem.mx ^= r[config.readReg2] ^ r[config.readReg3]; mem.mx ^= r[config.readReg2] ^ r[config.readReg3];
mem.mx &= CacheLineAlignMask; mem.mx &= CacheLineAlignMask;
datasetPrefetch(datasetOffset + mem.mx);
datasetRead(datasetOffset + mem.ma, r); datasetRead(datasetOffset + mem.ma, r);
std::swap(mem.mx, mem.ma); std::swap(mem.mx, mem.ma);
@ -279,6 +280,11 @@ namespace randomx {
r[i] ^= datasetLine[i]; r[i] ^= datasetLine[i];
} }
template<class Allocator, bool softAes>
void InterpretedVm<Allocator, softAes>::datasetPrefetch(uint64_t address) {
rx_prefetch_nta(mem.memory + address);
}
#include "instruction_weights.hpp" #include "instruction_weights.hpp"
template<class Allocator, bool softAes> template<class Allocator, bool softAes>

View File

@ -81,6 +81,7 @@ namespace randomx {
void setDataset(randomx_dataset* dataset) override; void setDataset(randomx_dataset* dataset) override;
protected: protected:
virtual void datasetRead(uint64_t blockNumber, int_reg_t(&r)[RegistersCount]); virtual void datasetRead(uint64_t blockNumber, int_reg_t(&r)[RegistersCount]);
virtual void datasetPrefetch(uint64_t blockNumber);
private: private:
void execute(); void execute();
void precompileProgram(int_reg_t(&r)[RegistersCount], rx_vec_f128(&f)[RegisterCountFlt], rx_vec_f128(&e)[RegisterCountFlt], rx_vec_f128(&a)[RegisterCountFlt]); void precompileProgram(int_reg_t(&r)[RegistersCount], rx_vec_f128(&f)[RegisterCountFlt], rx_vec_f128(&e)[RegisterCountFlt], rx_vec_f128(&a)[RegisterCountFlt]);

View File

@ -51,6 +51,7 @@ namespace randomx {
void setCache(randomx_cache* cache) override; void setCache(randomx_cache* cache) override;
protected: protected:
void datasetRead(uint64_t address, int_reg_t(&r)[8]) override; void datasetRead(uint64_t address, int_reg_t(&r)[8]) override;
void datasetPrefetch(uint64_t address) override { }
}; };
using InterpretedLightVmDefault = InterpretedLightVm<AlignedAllocator<CacheLineSize>, true>; using InterpretedLightVmDefault = InterpretedLightVm<AlignedAllocator<CacheLineSize>, true>;