diff --git a/CHANGELOG.md b/CHANGELOG.md index a8cdb4dd..f3c885a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# v6.15.2 +- [#2606](https://github.com/xmrig/xmrig/pull/2606) Fixed: AstroBWT auto-config ignored `max-threads-hint`. +- Fixed possible crash on Windows (regression in v6.15.1). + +# v6.15.1 +- [#2586](https://github.com/xmrig/xmrig/pull/2586) Fixed Windows 7 compatibility. +- [#2594](https://github.com/xmrig/xmrig/pull/2594) Added Windows taskbar icon colors. + # v6.15.0 - [#2548](https://github.com/xmrig/xmrig/pull/2548) Added automatic coin detection for daemon mining. - [#2563](https://github.com/xmrig/xmrig/pull/2563) Added new algorithm RandomX Graft (`rx/graft`). diff --git a/CMakeLists.txt b/CMakeLists.txt index bf872465..c06832c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,6 +58,7 @@ set(HEADERS src/core/config/usage.h src/core/Controller.h src/core/Miner.h + src/core/Taskbar.h src/net/interfaces/IJobResultListener.h src/net/JobResult.h src/net/JobResults.h @@ -106,6 +107,7 @@ set(SOURCES src/core/config/ConfigTransform.cpp src/core/Controller.cpp src/core/Miner.cpp + src/core/Taskbar.cpp src/net/JobResults.cpp src/net/Network.cpp src/net/strategies/DonateStrategy.cpp diff --git a/src/backend/cpu/CpuWorker.cpp b/src/backend/cpu/CpuWorker.cpp index d1f0f405..ad8e6377 100644 --- a/src/backend/cpu/CpuWorker.cpp +++ b/src/backend/cpu/CpuWorker.cpp @@ -285,9 +285,9 @@ void xmrig::CpuWorker::start() bool valid = true; uint8_t miner_signature_saved[64]; - uint8_t* miner_signature_ptr = m_job.blob() + m_job.nonceOffset() + m_job.nonceSize(); # ifdef XMRIG_ALGO_RANDOMX + uint8_t* miner_signature_ptr = m_job.blob() + m_job.nonceOffset() + m_job.nonceSize(); if (job.algorithm().family() == Algorithm::RANDOM_X) { if (first) { diff --git a/src/backend/cpu/platform/HwlocCpuInfo.cpp b/src/backend/cpu/platform/HwlocCpuInfo.cpp index 353d676f..44e1872d 100644 --- a/src/backend/cpu/platform/HwlocCpuInfo.cpp +++ b/src/backend/cpu/platform/HwlocCpuInfo.cpp @@ -216,12 +216,6 @@ bool xmrig::HwlocCpuInfo::membind(hwloc_const_bitmap_t nodeset) xmrig::CpuThreads xmrig::HwlocCpuInfo::threads(const Algorithm &algorithm, uint32_t limit) const { -# ifdef XMRIG_ALGO_ASTROBWT - if (algorithm == Algorithm::ASTROBWT_DERO) { - return allThreads(algorithm, limit); - } -# endif - # ifndef XMRIG_ARM if (L2() == 0 && L3() == 0) { return BasicCpuInfo::threads(algorithm, limit); @@ -307,9 +301,16 @@ void xmrig::HwlocCpuInfo::processTopLevelCache(hwloc_obj_t cache, const Algorith size_t L2 = 0; int L2_associativity = 0; size_t extra = 0; - const size_t scratchpad = algorithm.l3(); + size_t scratchpad = algorithm.l3(); uint32_t intensity = algorithm.maxIntensity() == 1 ? 0 : 1; +# ifdef XMRIG_ALGO_ASTROBWT + if (algorithm == Algorithm::ASTROBWT_DERO) { + // Use fake low value to force usage of all available cores for AstroBWT (taking 'limit' into account) + scratchpad = 16 * 1024; + } +# endif + if (cache->attr->cache.depth == 3) { for (size_t i = 0; i < cache->arity; ++i) { hwloc_obj_t l2 = cache->children[i]; diff --git a/src/base/io/Env.cpp b/src/base/io/Env.cpp index 2a0d4ad7..6fef9073 100644 --- a/src/base/io/Env.cpp +++ b/src/base/io/Env.cpp @@ -143,17 +143,10 @@ xmrig::String xmrig::Env::get(const String &name, const std::map xmrig::String xmrig::Env::hostname() { char buf[UV_MAXHOSTNAMESIZE]{}; - size_t size = sizeof(buf); -# if UV_VERSION_HEX >= 0x010c00 - if (uv_os_gethostname(buf, &size) == 0) { + if (gethostname(buf, sizeof(buf)) == 0) { return static_cast(buf); } -# else - if (gethostname(buf, size) == 0) { - return static_cast(buf); - } -# endif return {}; } diff --git a/src/base/kernel/Entry.cpp b/src/base/kernel/Entry.cpp index c257ad24..f12e833f 100644 --- a/src/base/kernel/Entry.cpp +++ b/src/base/kernel/Entry.cpp @@ -141,7 +141,7 @@ xmrig::Entry::Id xmrig::Entry::get(const Process &process) return Usage; } - if (args.hasArg("-V") || args.hasArg("--version")) { + if (args.hasArg("-V") || args.hasArg("--version") || args.hasArg("--versions")) { return Version; } diff --git a/src/core/Miner.cpp b/src/core/Miner.cpp index 2b6c1dbe..8ffdc63b 100644 --- a/src/core/Miner.cpp +++ b/src/core/Miner.cpp @@ -22,6 +22,7 @@ #include "core/Miner.h" +#include "core/Taskbar.h" #include "3rdparty/rapidjson/document.h" #include "backend/common/Hashrate.h" #include "backend/cpu/Cpu.h" @@ -348,6 +349,8 @@ public: String userJobId; Timer *timer = nullptr; uint64_t ticks = 0; + + Taskbar m_taskbar; }; @@ -475,6 +478,7 @@ void xmrig::Miner::execCommand(char command) void xmrig::Miner::pause() { d_ptr->active = false; + d_ptr->m_taskbar.setActive(false); Nonce::pause(true); Nonce::touch(); @@ -494,6 +498,7 @@ void xmrig::Miner::setEnabled(bool enabled) } d_ptr->enabled = enabled; + d_ptr->m_taskbar.setEnabled(enabled); if (enabled) { LOG_INFO("%s " GREEN_BOLD("resumed"), Tags::miner()); @@ -551,6 +556,7 @@ void xmrig::Miner::setJob(const Job &job, bool donate) mutex.unlock(); d_ptr->active = true; + d_ptr->m_taskbar.setActive(true); if (ready) { d_ptr->handleJobChange(); diff --git a/src/core/Taskbar.cpp b/src/core/Taskbar.cpp new file mode 100644 index 00000000..c0af8bfa --- /dev/null +++ b/src/core/Taskbar.cpp @@ -0,0 +1,126 @@ +/* XMRig + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "core/Taskbar.h" + +#ifdef _WIN32 + + +#include +#include + + +namespace xmrig { + + +struct TaskbarPrivate +{ + TaskbarPrivate() + { + HRESULT hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + if (hr < 0) { + return; + } + + hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&m_taskbar)); + if (hr < 0) { + return; + } + + hr = m_taskbar->HrInit(); + if (hr < 0) { + m_taskbar->Release(); + m_taskbar = nullptr; + return; + } + + m_consoleWnd = GetConsoleWindow(); + } + + ~TaskbarPrivate() + { + if (m_taskbar) { + m_taskbar->Release(); + } + CoUninitialize(); + } + + ITaskbarList3* m_taskbar = nullptr; + HWND m_consoleWnd = nullptr; +}; + + +Taskbar::Taskbar() : d_ptr(new TaskbarPrivate()) +{ +} + + +Taskbar::~Taskbar() +{ + delete d_ptr; +} + + +void Taskbar::setActive(bool active) +{ + m_active = active; + updateTaskbarColor(); +} + + +void Taskbar::setEnabled(bool enabled) +{ + m_enabled = enabled; + updateTaskbarColor(); +} + + +void Taskbar::updateTaskbarColor() +{ + if (d_ptr->m_taskbar) { + if (m_active) { + d_ptr->m_taskbar->SetProgressState(d_ptr->m_consoleWnd, m_enabled ? TBPF_NOPROGRESS : TBPF_PAUSED); + d_ptr->m_taskbar->SetProgressValue(d_ptr->m_consoleWnd, m_enabled ? 0 : 1, 1); + } + else { + d_ptr->m_taskbar->SetProgressState(d_ptr->m_consoleWnd, TBPF_ERROR); + d_ptr->m_taskbar->SetProgressValue(d_ptr->m_consoleWnd, 1, 1); + } + } +} + + +} // namespace xmrig + + +#else // _WIN32 + + +namespace xmrig { + + +Taskbar::Taskbar() {} +Taskbar::~Taskbar() {} +void Taskbar::setActive(bool) {} +void Taskbar::setEnabled(bool) {} + + +} // namespace xmrig + + +#endif // _WIN32 diff --git a/src/core/Taskbar.h b/src/core/Taskbar.h new file mode 100644 index 00000000..abb04fde --- /dev/null +++ b/src/core/Taskbar.h @@ -0,0 +1,51 @@ +/* XMRig + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef XMRIG_TASKBAR_H +#define XMRIG_TASKBAR_H + + +namespace xmrig { + + +struct TaskbarPrivate; + + +class Taskbar +{ +public: + Taskbar(); + ~Taskbar(); + + void setActive(bool active); + void setEnabled(bool enabled); + +private: + bool m_active = false; + bool m_enabled = true; + + TaskbarPrivate* d_ptr = nullptr; + + void updateTaskbarColor(); +}; + + +} // namespace xmrig + + +#endif /* XMRIG_TASKBAR_H */ diff --git a/src/core/config/ConfigTransform.cpp b/src/core/config/ConfigTransform.cpp index 9acd8d78..9b6ea168 100644 --- a/src/core/config/ConfigTransform.cpp +++ b/src/core/config/ConfigTransform.cpp @@ -17,6 +17,7 @@ */ #include "core/config/ConfigTransform.h" +#include "base/crypto/Algorithm.h" #include "base/kernel/interfaces/IConfig.h" #include "base/net/stratum/Pool.h" #include "base/net/stratum/Pools.h" @@ -106,7 +107,7 @@ void xmrig::ConfigTransform::finalize(rapidjson::Document &doc) profile.AddMember(StringRef(kAffinity), m_affinity, allocator); # ifdef XMRIG_ALGO_KAWPOW - doc[CpuConfig::kField].AddMember(StringRef(kKawPow), false, doc.GetAllocator()); + doc[CpuConfig::kField].AddMember(StringRef(Algorithm::kKAWPOW), false, doc.GetAllocator()); # endif doc[CpuConfig::kField].AddMember(StringRef(kAsterisk), profile, doc.GetAllocator()); } diff --git a/src/crypto/randomx/jit_compiler_x86.cpp b/src/crypto/randomx/jit_compiler_x86.cpp index 825a526e..3860f8fb 100644 --- a/src/crypto/randomx/jit_compiler_x86.cpp +++ b/src/crypto/randomx/jit_compiler_x86.cpp @@ -114,40 +114,42 @@ namespace randomx { #define codeLoopBegin ADDR(randomx_program_loop_begin) #define codeLoopLoad ADDR(randomx_program_loop_load) #define codeLoopLoadXOP ADDR(randomx_program_loop_load_xop) - #define codeProgamStart ADDR(randomx_program_start) + #define codeProgramStart ADDR(randomx_program_start) + #define codeReadDataset ADDR(randomx_program_read_dataset) #define codeReadDatasetLightSshInit ADDR(randomx_program_read_dataset_sshash_init) #define codeReadDatasetLightSshFin ADDR(randomx_program_read_dataset_sshash_fin) #define codeDatasetInit ADDR(randomx_dataset_init) - #define codeDatasetInitAVX2_prologue ADDR(randomx_dataset_init_avx2_prologue) - #define codeDatasetInitAVX2_loop_end ADDR(randomx_dataset_init_avx2_loop_end) - #define codeDatasetInitAVX2_loop_epilogue ADDR(randomx_dataset_init_avx2_epilogue) - #define codeDatasetInitAVX2_ssh_load ADDR(randomx_dataset_init_avx2_ssh_load) - #define codeDatasetInitAVX2_ssh_prefetch ADDR(randomx_dataset_init_avx2_ssh_prefetch) + #define codeDatasetInitAVX2Prologue ADDR(randomx_dataset_init_avx2_prologue) + #define codeDatasetInitAVX2LoopEnd ADDR(randomx_dataset_init_avx2_loop_end) + #define codeDatasetInitAVX2Epilogue ADDR(randomx_dataset_init_avx2_epilogue) + #define codeDatasetInitAVX2SshLoad ADDR(randomx_dataset_init_avx2_ssh_load) + #define codeDatasetInitAVX2SshPrefetch ADDR(randomx_dataset_init_avx2_ssh_prefetch) #define codeLoopStore ADDR(randomx_program_loop_store) #define codeLoopEnd ADDR(randomx_program_loop_end) #define codeEpilogue ADDR(randomx_program_epilogue) #define codeProgramEnd ADDR(randomx_program_end) - #define codeShhLoad ADDR(randomx_sshash_load) - #define codeShhPrefetch ADDR(randomx_sshash_prefetch) - #define codeShhEnd ADDR(randomx_sshash_end) - #define codeShhInit ADDR(randomx_sshash_init) + #define codeSshLoad ADDR(randomx_sshash_load) + #define codeSshPrefetch ADDR(randomx_sshash_prefetch) + #define codeSshEnd ADDR(randomx_sshash_end) + #define codeSshInit ADDR(randomx_sshash_init) #define prologueSize (codeLoopBegin - codePrologue) #define loopLoadSize (codeLoopLoadXOP - codeLoopLoad) - #define loopLoadXOPSize (codeProgamStart - codeLoopLoadXOP) + #define loopLoadXOPSize (codeProgramStart - codeLoopLoadXOP) + #define readDatasetSize (codeReadDatasetLightSshInit - codeReadDataset) #define readDatasetLightInitSize (codeReadDatasetLightSshFin - codeReadDatasetLightSshInit) #define readDatasetLightFinSize (codeLoopStore - codeReadDatasetLightSshFin) #define loopStoreSize (codeLoopEnd - codeLoopStore) - #define datasetInitSize (codeDatasetInitAVX2_prologue - codeDatasetInit) - #define datasetInitAVX2_prologue_size (codeDatasetInitAVX2_loop_end - codeDatasetInitAVX2_prologue) - #define datasetInitAVX2_loop_end_size (codeDatasetInitAVX2_loop_epilogue - codeDatasetInitAVX2_loop_end) - #define datasetInitAVX2_epilogue_size (codeDatasetInitAVX2_ssh_load - codeDatasetInitAVX2_loop_epilogue) - #define datasetInitAVX2_ssh_load_size (codeDatasetInitAVX2_ssh_prefetch - codeDatasetInitAVX2_ssh_load) - #define datasetInitAVX2_ssh_prefetch_size (codeEpilogue - codeDatasetInitAVX2_ssh_prefetch) - #define epilogueSize (codeShhLoad - codeEpilogue) - #define codeSshLoadSize (codeShhPrefetch - codeShhLoad) - #define codeSshPrefetchSize (codeShhEnd - codeShhPrefetch) - #define codeSshInitSize (codeProgramEnd - codeShhInit) + #define datasetInitSize (codeDatasetInitAVX2Prologue - codeDatasetInit) + #define datasetInitAVX2PrologueSize (codeDatasetInitAVX2LoopEnd - codeDatasetInitAVX2Prologue) + #define datasetInitAVX2LoopEndSize (codeDatasetInitAVX2Epilogue - codeDatasetInitAVX2LoopEnd) + #define datasetInitAVX2EpilogueSize (codeDatasetInitAVX2SshLoad - codeDatasetInitAVX2Epilogue) + #define datasetInitAVX2SshLoadSize (codeDatasetInitAVX2SshPrefetch - codeDatasetInitAVX2SshLoad) + #define datasetInitAVX2SshPrefetchSize (codeEpilogue - codeDatasetInitAVX2SshPrefetch) + #define epilogueSize (codeSshLoad - codeEpilogue) + #define codeSshLoadSize (codeSshPrefetch - codeSshLoad) + #define codeSshPrefetchSize (codeSshEnd - codeSshPrefetch) + #define codeSshInitSize (codeProgramEnd - codeSshInit) #define epilogueOffset ((CodeSize - epilogueSize) & ~63) @@ -352,7 +354,7 @@ namespace randomx { uint8_t* p = code; if (initDatasetAVX2) { codePos = 0; - emit(codeDatasetInitAVX2_prologue, datasetInitAVX2_prologue_size, code, codePos); + emit(codeDatasetInitAVX2Prologue, datasetInitAVX2PrologueSize, code, codePos); for (unsigned j = 0; j < RandomX_CurrentConfig.CacheAccesses; ++j) { SuperscalarProgram& prog = programs[j]; @@ -361,29 +363,29 @@ namespace randomx { generateSuperscalarCode(prog(i), p, pos); } codePos = pos; - emit(codeShhLoad, codeSshLoadSize, code, codePos); - emit(codeDatasetInitAVX2_ssh_load, datasetInitAVX2_ssh_load_size, code, codePos); + emit(codeSshLoad, codeSshLoadSize, code, codePos); + emit(codeDatasetInitAVX2SshLoad, datasetInitAVX2SshLoadSize, code, codePos); if (j < RandomX_CurrentConfig.CacheAccesses - 1) { *(uint32_t*)(code + codePos) = 0xd88b49 + (static_cast(prog.getAddressRegister()) << 16); codePos += 3; - emit(RandomX_CurrentConfig.codeShhPrefetchTweaked, codeSshPrefetchSize, code, codePos); + emit(RandomX_CurrentConfig.codeSshPrefetchTweaked, codeSshPrefetchSize, code, codePos); uint8_t* p = code + codePos; - emit(codeDatasetInitAVX2_ssh_prefetch, datasetInitAVX2_ssh_prefetch_size, code, codePos); + emit(codeDatasetInitAVX2SshPrefetch, datasetInitAVX2SshPrefetchSize, code, codePos); p[3] += prog.getAddressRegister() << 3; } } - emit(codeDatasetInitAVX2_loop_end, datasetInitAVX2_loop_end_size, code, codePos); + emit(codeDatasetInitAVX2LoopEnd, datasetInitAVX2LoopEndSize, code, codePos); // Number of bytes from the start of randomx_dataset_init_avx2_prologue to loop_begin label constexpr int32_t prologue_size = 320; *(int32_t*)(code + codePos - 4) = prologue_size - codePos; - emit(codeDatasetInitAVX2_loop_epilogue, datasetInitAVX2_epilogue_size, code, codePos); + emit(codeDatasetInitAVX2Epilogue, datasetInitAVX2EpilogueSize, code, codePos); return; } - memcpy(code + superScalarHashOffset, codeShhInit, codeSshInitSize); + memcpy(code + superScalarHashOffset, codeSshInit, codeSshInitSize); codePos = superScalarHashOffset + codeSshInitSize; for (unsigned j = 0; j < RandomX_CurrentConfig.CacheAccesses; ++j) { SuperscalarProgram& prog = programs[j]; @@ -392,11 +394,11 @@ namespace randomx { generateSuperscalarCode(prog(i), p, pos); } codePos = pos; - emit(codeShhLoad, codeSshLoadSize, code, codePos); + emit(codeSshLoad, codeSshLoadSize, code, codePos); if (j < RandomX_CurrentConfig.CacheAccesses - 1) { *(uint32_t*)(code + codePos) = 0xd88b49 + (static_cast(prog.getAddressRegister()) << 16); codePos += 3; - emit(RandomX_CurrentConfig.codeShhPrefetchTweaked, codeSshPrefetchSize, code, codePos); + emit(RandomX_CurrentConfig.codeSshPrefetchTweaked, codeSshPrefetchSize, code, codePos); } } emitByte(0xc3, code, codePos); @@ -422,7 +424,7 @@ namespace randomx { } # ifdef XMRIG_FIX_RYZEN - xmrig::RxFix::setMainLoopBounds(mainLoopBounds); + xmrig::RxFix::setMainLoopBounds(mainLoopBounds); # endif imul_rcp_storage = code + (ADDR(randomx_program_imul_rcp_store) - codePrologue) + 2; diff --git a/src/crypto/randomx/randomx.cpp b/src/crypto/randomx/randomx.cpp index 1cdd17ee..256f6e3c 100644 --- a/src/crypto/randomx/randomx.cpp +++ b/src/crypto/randomx/randomx.cpp @@ -198,7 +198,7 @@ RandomX_ConfigurationBase::RandomX_ConfigurationBase() { const uint8_t* a = addr(randomx_sshash_prefetch); const uint8_t* b = addr(randomx_sshash_end); - memcpy(codeShhPrefetchTweaked, a, b - a); + memcpy(codeSshPrefetchTweaked, a, b - a); } { const uint8_t* a = addr(randomx_program_read_dataset); diff --git a/src/version.h b/src/version.h index c51a3235..5006415a 100644 --- a/src/version.h +++ b/src/version.h @@ -22,7 +22,7 @@ #define APP_ID "xmrig" #define APP_NAME "XMRig" #define APP_DESC "XMRig miner" -#define APP_VERSION "6.15.0-mo1" +#define APP_VERSION "6.15.2-mo1" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2021 xmrig.com" @@ -30,7 +30,7 @@ #define APP_VER_MAJOR 6 #define APP_VER_MINOR 15 -#define APP_VER_PATCH 0 +#define APP_VER_PATCH 2 #ifdef _MSC_VER # if (_MSC_VER >= 1920)