Support Dataset size larger than 4 GiB

Support arbitrary value of RANDOMX_DATASET_EXTRA_SIZE
This commit is contained in:
tevador 2019-05-29 17:27:49 +02:00
parent 378d5def38
commit bc2aae0f61
6 changed files with 6 additions and 6 deletions

View File

@ -88,7 +88,7 @@ void randomx_vm::initialize() {
config.readReg2 = 4 + (addressRegisters & 1);
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[1], randomx::getFloatMask(program.getEntropy(15)));
}

View File

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

View File

@ -273,7 +273,7 @@ namespace randomx {
}
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);
for (int i = 0; i < RegistersCount; ++i)
r[i] ^= datasetLine[i];

View File

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

View File

@ -50,7 +50,7 @@ namespace randomx {
void setDataset(randomx_dataset* dataset) override { }
void setCache(randomx_cache* cache) override;
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>;