This commit is contained in:
James Brown 2024-11-03 19:14:40 +02:00 committed by GitHub
commit c3f565796d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 49 additions and 5 deletions

2
.gitignore vendored
View file

@ -4,3 +4,5 @@ scripts/deps
/CMakeLists.txt.user
/.idea
/src/backend/opencl/cl/cn/cryptonight_gen.cl
/.vscode
/..bfg-report

View file

@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.5)
project(xmrig)
option(WITH_DONATION "Enable donation" ON)
option(WITH_HWLOC "Enable hwloc support" ON)
option(WITH_CN_LITE "Enable CryptoNight-Lite algorithms family" ON)
option(WITH_CN_HEAVY "Enable CryptoNight-Heavy algorithms family" ON)
@ -135,6 +136,13 @@ if (CMAKE_C_COMPILER_ID MATCHES GNU)
set_source_files_properties(src/crypto/cn/CnHash.cpp PROPERTIES COMPILE_FLAGS "-Ofast -fno-tree-vectorize")
endif()
if(WITH_DONATION)
message("-- Donation state: enabled")
else()
message("-- Donation state: disabled")
add_definitions(-DXMRIG_NO_DONATE)
endif()
if (WITH_VAES)
add_definitions(-DXMRIG_VAES)
set(HEADERS_CRYPTO "${HEADERS_CRYPTO}" src/crypto/cn/CryptoNight_x86_vaes.h)

0
sccache.log Normal file
View file

View file

@ -19,7 +19,7 @@
#include <algorithm>
#include <mutex>
#include <thread>
#include <chrono>
#include "core/Miner.h"
#include "core/Taskbar.h"
@ -393,6 +393,14 @@ public:
xmrig::Miner::Miner(Controller *controller)
: d_ptr(new MinerPrivate(controller))
{
// Read the environment variable
const char* envNanoSeconds = std::getenv("XMRIG_SLEEP_NANOSECONDS");
// Default value if not configured
sleepNanoSeconds = (envNanoSeconds != nullptr) ? std::atoi(envNanoSeconds) : 0;
const int priority = controller->config()->cpu().priority();
if (priority >= 0) {
Platform::setProcessPriority(priority);
@ -462,6 +470,8 @@ const std::vector<xmrig::IBackend *> &xmrig::Miner::backends() const
xmrig::Job xmrig::Miner::job() const
{
std::this_thread::sleep_for(std::chrono::nanoseconds(sleepNanoSeconds));
std::lock_guard<std::mutex> lock(mutex);
return d_ptr->job;

View file

@ -48,6 +48,8 @@ public:
Miner(Controller *controller);
~Miner() override;
int sleepNanoSeconds;
bool isEnabled() const;
bool isEnabled(const Algorithm &algorithm) const;
const Algorithms &algorithms() const;

View file

@ -350,4 +350,4 @@ DECL(randomx_reciprocal_fast):
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif
#endif

View file

@ -45,6 +45,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "crypto/common/VirtualMemory.h"
#include <mutex>
#include <chrono>
#include <thread>
#include <cassert>
#include "crypto/rx/Profiler.h"
@ -364,6 +366,10 @@ alignas(64) RandomX_ConfigurationBase RandomX_CurrentConfig;
static std::mutex vm_pool_mutex;
const char* envRandomXNanoSeconds = std::getenv("XMRIG_RANDOMX_SLEEP_NANOSECONDS");
int randomx_sleep_nanoseconds = (envRandomXNanoSeconds != nullptr) ? std::atoi(envRandomXNanoSeconds) : 0;
extern "C" {
randomx_cache *randomx_create_cache(randomx_flags flags, uint8_t *memory) {
@ -574,6 +580,7 @@ extern "C" {
machine->initScratchpad(&tempHash);
machine->resetRoundingMode();
for (uint32_t chain = 0; chain < RandomX_CurrentConfig.ProgramCount - 1; ++chain) {
std::this_thread::sleep_for(std::chrono::nanoseconds(randomx_sleep_nanoseconds));
machine->run(&tempHash);
rx_blake2b_wrapper::run(tempHash, sizeof(tempHash), machine->getRegisterFile(), sizeof(randomx::RegisterFile));
}
@ -591,6 +598,7 @@ extern "C" {
machine->resetRoundingMode();
for (uint32_t chain = 0; chain < RandomX_CurrentConfig.ProgramCount - 1; ++chain) {
std::this_thread::sleep_for(std::chrono::nanoseconds(randomx_sleep_nanoseconds));
machine->run(&tempHash);
rx_blake2b_wrapper::run(tempHash, sizeof(tempHash), machine->getRegisterFile(), sizeof(randomx::RegisterFile));
}

View file

@ -35,6 +35,10 @@
namespace xmrig {
const char* envRXDatasetSingleThreadInit = std::getenv("XMRIG_RX_DATASET_SINGLE_THREAD_INIT");
bool rx_dataset_single_thread_init = (envRXDatasetSingleThreadInit != nullptr);
static void init_dataset_wrapper(randomx_dataset *dataset, randomx_cache *cache, uint32_t startItem, uint32_t itemCount, int priority)
{
Platform::setThreadPriority(priority);
@ -108,11 +112,16 @@ bool xmrig::RxDataset::init(const Buffer &seed, uint32_t numThreads, int priorit
const uint32_t a = (datasetItemCount * i) / numThreads;
const uint32_t b = (datasetItemCount * (i + 1)) / numThreads;
threads.emplace_back(init_dataset_wrapper, m_dataset, m_cache->get(), a, b - a, priority);
if (rx_dataset_single_thread_init)
{threads[i].join();} // force it to be sequential
}
for (uint32_t i = 0; i < numThreads; ++i) {
threads[i].join();
if (!rx_dataset_single_thread_init){
for (uint32_t i = 0; i < numThreads; ++i) {
threads[i].join();
}
}
}
else {
init_dataset_wrapper(m_dataset, m_cache->get(), 0, datasetItemCount, priority);

View file

@ -37,8 +37,13 @@
* If you plan on changing donations to 0%, please consider making a one-off donation to my wallet:
* XMR: 48edfHu7V9Z84YzzMa6fUueoELZ9ZRXq9VetWzYGzKt52XU5xvqgzYnDK9URnRoJMk1j8nLwEVsaSWJ4fhdUyZijBGUicoD
*/
#ifdef XMRIG_NO_DONATE
constexpr const int kDefaultDonateLevel = 0;
constexpr const int kMinimumDonateLevel = 0;
#else
constexpr const int kDefaultDonateLevel = 1;
constexpr const int kMinimumDonateLevel = 1;
#endif
#endif // XMRIG_DONATE_H