Fix autoconfig and memory allocation for heavy algo.

This commit is contained in:
XMRig 2018-04-03 16:08:15 +07:00
parent 5c6ec587ac
commit 7d5a97137d
7 changed files with 42 additions and 14 deletions

View file

@ -27,8 +27,8 @@
#include "crypto/CryptoNight.h"
#include "crypto/CryptoNight_constants.h"
#include "Mem.h"
#include "xmrig.h"
bool Mem::m_doubleHash = false;
@ -48,10 +48,13 @@ cryptonight_ctx *Mem::create(int threadId)
}
# endif
cryptonight_ctx *ctx = reinterpret_cast<cryptonight_ctx *>(&m_memory[MONERO_MEMORY - sizeof(cryptonight_ctx) * (threadId + 1)]);
const size_t size = m_algo == xmrig::CRYPTONIGHT_HEAVY ? xmrig::cn_select_memory<xmrig::CRYPTONIGHT_HEAVY>()
: xmrig::cn_select_memory<xmrig::CRYPTONIGHT>();
cryptonight_ctx *ctx = reinterpret_cast<cryptonight_ctx *>(&m_memory[size - sizeof(cryptonight_ctx) * (threadId + 1)]);
const int ratio = m_doubleHash ? 2 : 1;
ctx->memory = &m_memory[MONERO_MEMORY * (threadId * ratio + 1)];
ctx->memory = &m_memory[size * (threadId * ratio + 1)];
return ctx;
}