From 69cbfd682a231134d6643f5f5cc31786f2eae9db Mon Sep 17 00:00:00 2001 From: SChernykh Date: Tue, 7 Apr 2020 18:46:22 +0200 Subject: [PATCH] Use node number instead of affinity --- src/backend/cpu/CpuWorker.cpp | 2 +- src/crypto/randomx/randomx.cpp | 7 +++---- src/crypto/randomx/randomx.h | 2 +- src/crypto/rx/RxVm.cpp | 4 ++-- src/crypto/rx/RxVm.h | 2 +- src/net/JobResults.cpp | 2 +- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/backend/cpu/CpuWorker.cpp b/src/backend/cpu/CpuWorker.cpp index 7d2aa671f..756c34eac 100644 --- a/src/backend/cpu/CpuWorker.cpp +++ b/src/backend/cpu/CpuWorker.cpp @@ -118,7 +118,7 @@ void xmrig::CpuWorker::allocateRandomX_VM() } if (!m_vm) { - m_vm = new RxVm(dataset, m_memory->scratchpad(), !m_hwAES, m_assembly, m_affinity); + m_vm = new RxVm(dataset, m_memory->scratchpad(), !m_hwAES, m_assembly, m_node); } } #endif diff --git a/src/crypto/randomx/randomx.cpp b/src/crypto/randomx/randomx.cpp index df9a3c99e..ae960df03 100644 --- a/src/crypto/randomx/randomx.cpp +++ b/src/crypto/randomx/randomx.cpp @@ -399,25 +399,24 @@ extern "C" { delete dataset; } - randomx_vm* randomx_create_vm(randomx_flags flags, randomx_cache* cache, randomx_dataset* dataset, uint8_t* scratchpad, int64_t affinity) { + randomx_vm* randomx_create_vm(randomx_flags flags, randomx_cache* cache, randomx_dataset* dataset, uint8_t* scratchpad, uint32_t node) { assert(cache != nullptr || (flags & RANDOMX_FLAG_FULL_MEM)); assert(cache == nullptr || cache->isInitialized()); assert(dataset != nullptr || !(flags & RANDOMX_FLAG_FULL_MEM)); randomx_vm* vm = nullptr; - std::lock_guard lock(vm_pool_mutex); - static uint8_t* vm_pool[64] = {}; static size_t vm_pool_offset[64] = {}; constexpr size_t VM_POOL_SIZE = 2 * 1024 * 1024; - uint32_t node = xmrig::VirtualMemory::bindToNUMANode(affinity); if (node > 64) { node = 0; } + std::lock_guard lock(vm_pool_mutex); + if (!vm_pool[node]) { vm_pool[node] = (uint8_t*) xmrig::VirtualMemory::allocateLargePagesMemory(VM_POOL_SIZE); if (!vm_pool[node]) { diff --git a/src/crypto/randomx/randomx.h b/src/crypto/randomx/randomx.h index aebe8dfd4..3ca65c8fd 100644 --- a/src/crypto/randomx/randomx.h +++ b/src/crypto/randomx/randomx.h @@ -308,7 +308,7 @@ RANDOMX_EXPORT void randomx_release_dataset(randomx_dataset *dataset); * (3) cache parameter is NULL and RANDOMX_FLAG_FULL_MEM is not set * (4) dataset parameter is NULL and RANDOMX_FLAG_FULL_MEM is set */ -RANDOMX_EXPORT randomx_vm *randomx_create_vm(randomx_flags flags, randomx_cache *cache, randomx_dataset *dataset, uint8_t *scratchpad, int64_t affinity); +RANDOMX_EXPORT randomx_vm *randomx_create_vm(randomx_flags flags, randomx_cache *cache, randomx_dataset *dataset, uint8_t *scratchpad, uint32_t node); /** * Reinitializes a virtual machine with a new Cache. This function should be called anytime diff --git a/src/crypto/rx/RxVm.cpp b/src/crypto/rx/RxVm.cpp index 5382af316..8a354616f 100644 --- a/src/crypto/rx/RxVm.cpp +++ b/src/crypto/rx/RxVm.cpp @@ -31,7 +31,7 @@ #include "crypto/rx/RxVm.h" -xmrig::RxVm::RxVm(RxDataset *dataset, uint8_t *scratchpad, bool softAes, xmrig::Assembly assembly, int64_t affinity) +xmrig::RxVm::RxVm(RxDataset *dataset, uint8_t *scratchpad, bool softAes, xmrig::Assembly assembly, uint32_t node) { if (!softAes) { m_flags |= RANDOMX_FLAG_HARD_AES; @@ -53,7 +53,7 @@ xmrig::RxVm::RxVm(RxDataset *dataset, uint8_t *scratchpad, bool softAes, xmrig:: m_flags |= RANDOMX_FLAG_AMD; } - m_vm = randomx_create_vm(static_cast(m_flags), dataset->cache() ? dataset->cache()->get() : nullptr, dataset->get(), scratchpad, affinity); + m_vm = randomx_create_vm(static_cast(m_flags), dataset->cache() ? dataset->cache()->get() : nullptr, dataset->get(), scratchpad, node); } diff --git a/src/crypto/rx/RxVm.h b/src/crypto/rx/RxVm.h index 93603529e..519a5f2ef 100644 --- a/src/crypto/rx/RxVm.h +++ b/src/crypto/rx/RxVm.h @@ -50,7 +50,7 @@ class RxVm public: XMRIG_DISABLE_COPY_MOVE_DEFAULT(RxVm); - RxVm(RxDataset *dataset, uint8_t *scratchpad, bool softAes, xmrig::Assembly assembly, int64_t affinity); + RxVm(RxDataset *dataset, uint8_t *scratchpad, bool softAes, xmrig::Assembly assembly, uint32_t node); ~RxVm(); inline randomx_vm *get() const { return m_vm; } diff --git a/src/net/JobResults.cpp b/src/net/JobResults.cpp index 306367171..6103d40c1 100644 --- a/src/net/JobResults.cpp +++ b/src/net/JobResults.cpp @@ -116,7 +116,7 @@ static void getResults(JobBundle &bundle, std::vector &results, uint3 return; } - auto vm = new RxVm(dataset, memory->scratchpad(), !hwAES, Assembly::NONE, -1); + auto vm = new RxVm(dataset, memory->scratchpad(), !hwAES, Assembly::NONE, 0); for (uint32_t nonce : bundle.nonces) { *bundle.job.nonce() = nonce;