Merge pull request #48 from tevador/pr-ds4

Support Dataset size larger than 4 GiB
This commit is contained in:
tevador 2019-06-01 11:12:27 +02:00 committed by GitHub
commit 25337d3241
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 6 additions and 6 deletions

View File

@ -88,7 +88,7 @@ void randomx_vm::initialize() {
config.readReg2 = 4 + (addressRegisters & 1); config.readReg2 = 4 + (addressRegisters & 1);
addressRegisters >>= 1; addressRegisters >>= 1;
config.readReg3 = 6 + (addressRegisters & 1); config.readReg3 = 6 + (addressRegisters & 1);
datasetOffset = (program.getEntropy(13) & randomx::DatasetExtraItems) * randomx::CacheLineSize; datasetOffset = (program.getEntropy(13) % (randomx::DatasetExtraItems + 1)) * randomx::CacheLineSize;
store64(&config.eMask[0], randomx::getFloatMask(program.getEntropy(14))); store64(&config.eMask[0], randomx::getFloatMask(program.getEntropy(14)));
store64(&config.eMask[1], randomx::getFloatMask(program.getEntropy(15))); store64(&config.eMask[1], randomx::getFloatMask(program.getEntropy(15)));
} }

View File

@ -60,7 +60,7 @@ protected:
randomx_cache* cachePtr = nullptr; randomx_cache* cachePtr = nullptr;
randomx_dataset* datasetPtr; randomx_dataset* datasetPtr;
}; };
uint32_t datasetOffset; uint64_t datasetOffset;
}; };
namespace randomx { namespace randomx {

View File

@ -273,7 +273,7 @@ namespace randomx {
} }
template<class Allocator, bool softAes> template<class Allocator, bool softAes>
void InterpretedVm<Allocator, softAes>::datasetRead(uint32_t address, int_reg_t(&r)[RegistersCount]) { void InterpretedVm<Allocator, softAes>::datasetRead(uint64_t address, int_reg_t(&r)[RegistersCount]) {
uint64_t* datasetLine = (uint64_t*)(mem.memory + address); uint64_t* datasetLine = (uint64_t*)(mem.memory + address);
for (int i = 0; i < RegistersCount; ++i) for (int i = 0; i < RegistersCount; ++i)
r[i] ^= datasetLine[i]; r[i] ^= datasetLine[i];

View File

@ -80,7 +80,7 @@ namespace randomx {
void run(void* seed) override; void run(void* seed) override;
void setDataset(randomx_dataset* dataset) override; void setDataset(randomx_dataset* dataset) override;
protected: protected:
virtual void datasetRead(uint32_t blockNumber, int_reg_t(&r)[RegistersCount]); virtual void datasetRead(uint64_t blockNumber, int_reg_t(&r)[RegistersCount]);
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

@ -38,7 +38,7 @@ namespace randomx {
} }
template<class Allocator, bool softAes> template<class Allocator, bool softAes>
void InterpretedLightVm<Allocator, softAes>::datasetRead(uint32_t address, int_reg_t(&r)[8]) { void InterpretedLightVm<Allocator, softAes>::datasetRead(uint64_t address, int_reg_t(&r)[8]) {
uint32_t itemNumber = address / CacheLineSize; uint32_t itemNumber = address / CacheLineSize;
int_reg_t rl[8]; int_reg_t rl[8];

View File

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