Integrated thread based double hash mode
This commit is contained in:
parent
196beded79
commit
daa4d912b3
17 changed files with 161 additions and 134 deletions
63
src/Mem.cpp
63
src/Mem.cpp
|
@ -30,58 +30,29 @@
|
|||
#include "Options.h"
|
||||
|
||||
|
||||
bool Mem::m_doubleHash = false;
|
||||
int Mem::m_algo = 0;
|
||||
int Mem::m_flags = 0;
|
||||
int Mem::m_threads = 0;
|
||||
size_t Mem::m_offset = 0;
|
||||
uint8_t *Mem::m_memory = nullptr;
|
||||
|
||||
bool Mem::m_doubleHash = false;
|
||||
int Mem::m_algo = 0;
|
||||
int Mem::m_flags = 0;
|
||||
int Mem::m_threads = 0;
|
||||
size_t Mem::m_memorySize = 0;
|
||||
uint8_t *Mem::m_memory = nullptr;
|
||||
int64_t Mem::m_doubleHashThreadMask = -1L;
|
||||
|
||||
cryptonight_ctx *Mem::create(int threadId)
|
||||
{
|
||||
# ifndef XMRIG_NO_AEON
|
||||
if (m_algo == Options::ALGO_CRYPTONIGHT_LITE) {
|
||||
return createLite(threadId);
|
||||
size_t scratchPadSize = m_algo == Options::ALGO_CRYPTONIGHT ? MEMORY : MEMORY_LITE;
|
||||
|
||||
size_t offset = 0;
|
||||
for (int i=0; i < threadId; i++) {
|
||||
offset += sizeof(cryptonight_ctx);
|
||||
offset += isDoubleHash(i) ? scratchPadSize*2 : scratchPadSize;
|
||||
}
|
||||
# endif
|
||||
|
||||
cryptonight_ctx *ctx = reinterpret_cast<cryptonight_ctx *>(&m_memory[MEMORY - sizeof(cryptonight_ctx) * (threadId + 1)]);
|
||||
auto* ctx = reinterpret_cast<cryptonight_ctx *>(&m_memory[offset]);
|
||||
|
||||
const int ratio = m_doubleHash ? 2 : 1;
|
||||
ctx->memory = &m_memory[MEMORY * (threadId * ratio + 1)];
|
||||
size_t memOffset = offset+sizeof(cryptonight_ctx);
|
||||
|
||||
ctx->memory = &m_memory[memOffset];
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *Mem::calloc(size_t num, size_t size)
|
||||
{
|
||||
void *mem = &m_memory[m_offset];
|
||||
m_offset += (num * size);
|
||||
|
||||
memset(mem, 0, num * size);
|
||||
|
||||
return mem;
|
||||
}
|
||||
|
||||
|
||||
#ifndef XMRIG_NO_AEON
|
||||
cryptonight_ctx *Mem::createLite(int threadId) {
|
||||
cryptonight_ctx *ctx;
|
||||
|
||||
if (!m_doubleHash) {
|
||||
const size_t offset = MEMORY * (threadId + 1);
|
||||
|
||||
ctx = reinterpret_cast<cryptonight_ctx *>(&m_memory[offset + MEMORY_LITE]);
|
||||
ctx->memory = &m_memory[offset];
|
||||
return ctx;
|
||||
}
|
||||
|
||||
ctx = reinterpret_cast<cryptonight_ctx *>(&m_memory[MEMORY - sizeof(cryptonight_ctx) * (threadId + 1)]);
|
||||
ctx->memory = &m_memory[MEMORY * (threadId + 1)];
|
||||
|
||||
return ctx;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue