Preparation for #1.4.0 (#30)
- Fixed CPU affinity on Windows for NUMA and CPUs with lot of cores - Implemented per thread configurable Multihash mode (double, triple, quadruple, quintuple) - Rebased from XMRig 2.4.4
This commit is contained in:
parent
5f8ea98764
commit
acf27e9341
41 changed files with 2575 additions and 1104 deletions
|
@ -22,7 +22,7 @@
|
|||
*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <cstdlib>
|
||||
#include <sys/mman.h>
|
||||
|
||||
|
||||
|
@ -36,26 +36,20 @@
|
|||
#include "crypto/CryptoNight.h"
|
||||
#include "log/Log.h"
|
||||
#include "Mem.h"
|
||||
#include "Options.h"
|
||||
|
||||
|
||||
bool Mem::allocate(const Options* options)
|
||||
{
|
||||
m_algo = options->algo();
|
||||
m_threads = options->threads();
|
||||
m_doubleHash = options->doubleHash();
|
||||
m_doubleHashThreadMask = options->doubleHashThreadMask();
|
||||
m_hashFactor = options->hashFactor();
|
||||
m_multiHashThreadMask = Mem::ThreadBitSet(options->multiHashThreadMask());
|
||||
m_memorySize = 0;
|
||||
|
||||
size_t scratchPadSize = m_algo == Options::ALGO_CRYPTONIGHT ? MEMORY : MEMORY_LITE;
|
||||
for (int i=0; i < m_threads; i++) {
|
||||
m_memorySize += sizeof(cryptonight_ctx);
|
||||
|
||||
if (isDoubleHash(i)) {
|
||||
m_memorySize += scratchPadSize*2;
|
||||
} else {
|
||||
m_memorySize += scratchPadSize;
|
||||
}
|
||||
m_memorySize += scratchPadSize * getThreadHashFactor(i);
|
||||
}
|
||||
|
||||
if (!options->hugePages()) {
|
||||
|
@ -70,7 +64,7 @@ bool Mem::allocate(const Options* options)
|
|||
# elif defined(__FreeBSD__)
|
||||
m_memory = static_cast<uint8_t*>(mmap(0, m_memorySize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_ALIGNED_SUPER | MAP_PREFAULT_READ, -1, 0));
|
||||
# else
|
||||
m_memory = static_cast<uint8_t*>(mmap(0, m_memorySize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB | MAP_POPULATE, 0, 0));
|
||||
m_memory = static_cast<uint8_t*>(mmap(nullptr, m_memorySize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB | MAP_POPULATE, 0, 0));
|
||||
# endif
|
||||
if (m_memory == MAP_FAILED) {
|
||||
m_memory = static_cast<uint8_t*>(_mm_malloc(m_memorySize, 16));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue