RandomX: remove duplicate SuperscalarHash generation
SuperscalarHash generates twice in initCacheCompile. Fix it.
This commit is contained in:
parent
ec13337228
commit
8360104db0
3 changed files with 16 additions and 18 deletions
|
@ -92,27 +92,26 @@ namespace randomx {
|
|||
|
||||
argon2_ctx_mem(&context, Argon2_d, cache->memory, RandomX_CurrentConfig.ArgonMemory * 1024);
|
||||
|
||||
cache->reciprocalCache.clear();
|
||||
randomx::Blake2Generator gen(key, keySize);
|
||||
for (uint32_t i = 0; i < RandomX_CurrentConfig.CacheAccesses; ++i) {
|
||||
randomx::generateSuperscalar(cache->programs[i], gen);
|
||||
for (unsigned j = 0; j < cache->programs[i].getSize(); ++j) {
|
||||
auto& instr = cache->programs[i](j);
|
||||
if ((SuperscalarInstructionType)instr.opcode == SuperscalarInstructionType::IMUL_RCP) {
|
||||
auto rcp = randomx_reciprocal(instr.getImm32());
|
||||
instr.setImm32(cache->reciprocalCache.size());
|
||||
cache->reciprocalCache.push_back(rcp);
|
||||
if (cache->jit == nullptr) {
|
||||
cache->reciprocalCache.clear();
|
||||
randomx::Blake2Generator gen(key, keySize);
|
||||
for (uint32_t i = 0; i < RandomX_CurrentConfig.CacheAccesses; ++i) {
|
||||
randomx::generateSuperscalar(cache->programs[i], gen);
|
||||
for (unsigned j = 0; j < cache->programs[i].getSize(); ++j) {
|
||||
auto& instr = cache->programs[i](j);
|
||||
if ((SuperscalarInstructionType)instr.opcode == SuperscalarInstructionType::IMUL_RCP) {
|
||||
auto rcp = randomx_reciprocal(instr.getImm32());
|
||||
instr.setImm32(cache->reciprocalCache.size());
|
||||
cache->reciprocalCache.push_back(rcp);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
cache->jit->generateSuperscalarHash(cache->programs, cache->reciprocalCache);
|
||||
cache->jit->generateDatasetInitCode();
|
||||
}
|
||||
}
|
||||
|
||||
void initCacheCompile(randomx_cache* cache, const void* key, size_t keySize) {
|
||||
initCache(cache, key, keySize);
|
||||
cache->jit->generateSuperscalarHash(cache->programs, cache->reciprocalCache);
|
||||
cache->jit->generateDatasetInitCode();
|
||||
}
|
||||
|
||||
constexpr uint64_t superscalarMul0 = 6364136223846793005ULL;
|
||||
constexpr uint64_t superscalarAdd1 = 9298411001130361340ULL;
|
||||
constexpr uint64_t superscalarAdd2 = 12065312585734608966ULL;
|
||||
|
|
|
@ -72,7 +72,6 @@ namespace randomx {
|
|||
void deallocCache(randomx_cache* cache);
|
||||
|
||||
void initCache(randomx_cache*, const void*, size_t);
|
||||
void initCacheCompile(randomx_cache*, const void*, size_t);
|
||||
void initDatasetItem(randomx_cache* cache, uint8_t* out, uint64_t blockNumber);
|
||||
void initDataset(randomx_cache* cache, uint8_t* dataset, uint32_t startBlock, uint32_t endBlock);
|
||||
}
|
||||
|
|
|
@ -395,7 +395,7 @@ extern "C" {
|
|||
|
||||
case RANDOMX_FLAG_JIT:
|
||||
cache->jit = new randomx::JitCompiler();
|
||||
cache->initialize = &randomx::initCacheCompile;
|
||||
cache->initialize = &randomx::initCache;
|
||||
cache->datasetInit = cache->jit->getDatasetInitFunc();
|
||||
cache->memory = memory;
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue