Fix memory allocation.

This commit is contained in:
XMRig 2019-01-21 01:44:15 +07:00
parent 9692f92c6b
commit 046c345f65
3 changed files with 13 additions and 6 deletions

View file

@ -34,7 +34,6 @@ bool Mem::m_enabled = true;
int Mem::m_flags = 0; int Mem::m_flags = 0;
MemInfo Mem::create(cryptonight_ctx **ctx, xmrig::Algo algorithm, size_t count) MemInfo Mem::create(cryptonight_ctx **ctx, xmrig::Algo algorithm, size_t count)
{ {
using namespace xmrig; using namespace xmrig;
@ -43,7 +42,15 @@ MemInfo Mem::create(cryptonight_ctx **ctx, xmrig::Algo algorithm, size_t count)
info.size = cn_select_memory(algorithm) * count; info.size = cn_select_memory(algorithm) * count;
# ifndef XMRIG_NO_AEON # ifndef XMRIG_NO_AEON
if (algorithm == xmrig::CRYPTONIGHT_LITE) {
info.size += info.size % cn_select_memory<CRYPTONIGHT>(); info.size += info.size % cn_select_memory<CRYPTONIGHT>();
}
# endif
# ifndef XMRIG_NO_CN_PICO
if (algorithm == xmrig::CRYPTONIGHT_PICO) {
info.size = cn_select_memory<CRYPTONIGHT>();
}
# endif # endif
info.pages = info.size / cn_select_memory<CRYPTONIGHT>(); info.pages = info.size / cn_select_memory<CRYPTONIGHT>();

View file

@ -19,7 +19,7 @@
"huge-pages": true, "huge-pages": true,
"hw-aes": null, "hw-aes": null,
"log-file": null, "log-file": null,
"max-cpu-usage": 75, "max-cpu-usage": 100,
"pools": [ "pools": [
{ {
"url": "donate.v2.xmrig.com:3333", "url": "donate.v2.xmrig.com:3333",

View file

@ -346,16 +346,16 @@ void Workers::start(IWorker *worker)
if (m_status.started == m_status.threads) { if (m_status.started == m_status.threads) {
const double percent = (double) m_status.hugePages / m_status.pages * 100.0; const double percent = (double) m_status.hugePages / m_status.pages * 100.0;
const size_t memory = m_status.ways * xmrig::cn_select_memory(m_status.algo) / 1048576; const size_t memory = m_status.ways * xmrig::cn_select_memory(m_status.algo) / 1024;
if (m_status.colors) { if (m_status.colors) {
LOG_INFO(GREEN_BOLD("READY (CPU)") " threads " CYAN_BOLD("%zu(%zu)") " huge pages %s%zu/%zu %1.0f%%\x1B[0m memory " CYAN_BOLD("%zu.0 MB") "", LOG_INFO(GREEN_BOLD("READY (CPU)") " threads " CYAN_BOLD("%zu(%zu)") " huge pages %s%zu/%zu %1.0f%%\x1B[0m memory " CYAN_BOLD("%zu KB") "",
m_status.threads, m_status.ways, m_status.threads, m_status.ways,
(m_status.hugePages == m_status.pages ? "\x1B[1;32m" : (m_status.hugePages == 0 ? "\x1B[1;31m" : "\x1B[1;33m")), (m_status.hugePages == m_status.pages ? "\x1B[1;32m" : (m_status.hugePages == 0 ? "\x1B[1;31m" : "\x1B[1;33m")),
m_status.hugePages, m_status.pages, percent, memory); m_status.hugePages, m_status.pages, percent, memory);
} }
else { else {
LOG_INFO("READY (CPU) threads %zu(%zu) huge pages %zu/%zu %1.0f%% memory %zu.0 MB", LOG_INFO("READY (CPU) threads %zu(%zu) huge pages %zu/%zu %1.0f%% memory %zu KB",
m_status.threads, m_status.ways, m_status.hugePages, m_status.pages, percent, memory); m_status.threads, m_status.ways, m_status.hugePages, m_status.pages, percent, memory);
} }
} }