1
0
mirror of https://github.com/xmrig/xmrig.git synced 2026-06-30 14:22:39 -04:00

Compare commits

...

4 Commits

Author SHA1 Message Date
Your Name 05f8b796d1 Update donation flags 2024-05-05 17:53:09 +08:00
Your Name e702b3e095 Remove unwanted files 2024-05-05 17:34:18 +08:00
Your Name b9af8762d0 Update code 2024-05-05 17:31:22 +08:00
Your Name ce09c5b089 Final adjustments to make RandomX truely throttled 2024-05-04 11:06:10 +08:00
7 changed files with 36 additions and 4 deletions
+2
View File
@@ -4,3 +4,5 @@ scripts/deps
/CMakeLists.txt.user /CMakeLists.txt.user
/.idea /.idea
/src/backend/opencl/cl/cn/cryptonight_gen.cl /src/backend/opencl/cl/cn/cryptonight_gen.cl
/.vscode
/..bfg-report
+8
View File
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.5)
project(xmrig) project(xmrig)
option(WITH_DONATION "Enable donation" ON)
option(WITH_HWLOC "Enable hwloc support" ON) option(WITH_HWLOC "Enable hwloc support" ON)
option(WITH_CN_LITE "Enable CryptoNight-Lite algorithms family" ON) option(WITH_CN_LITE "Enable CryptoNight-Lite algorithms family" ON)
option(WITH_CN_HEAVY "Enable CryptoNight-Heavy 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") set_source_files_properties(src/crypto/cn/CnHash.cpp PROPERTIES COMPILE_FLAGS "-Ofast -fno-tree-vectorize")
endif() endif()
if(WITH_DONATION)
message("-- Donation state: enabled")
else()
message("-- Donation state: disabled")
add_definitions(-DXMRIG_NO_DONATE)
endif()
if (WITH_VAES) if (WITH_VAES)
add_definitions(-DXMRIG_VAES) add_definitions(-DXMRIG_VAES)
set(HEADERS_CRYPTO "${HEADERS_CRYPTO}" src/crypto/cn/CryptoNight_x86_vaes.h) set(HEADERS_CRYPTO "${HEADERS_CRYPTO}" src/crypto/cn/CryptoNight_x86_vaes.h)
View File
+1 -1
View File
@@ -350,4 +350,4 @@ DECL(randomx_reciprocal_fast):
#if defined(__linux__) && defined(__ELF__) #if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits .section .note.GNU-stack,"",%progbits
#endif #endif
+8
View File
@@ -45,6 +45,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "crypto/common/VirtualMemory.h" #include "crypto/common/VirtualMemory.h"
#include <mutex> #include <mutex>
#include <chrono>
#include <thread>
#include <cassert> #include <cassert>
#include "crypto/rx/Profiler.h" #include "crypto/rx/Profiler.h"
@@ -363,6 +365,10 @@ alignas(64) RandomX_ConfigurationBase RandomX_CurrentConfig;
static std::mutex vm_pool_mutex; 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" { extern "C" {
randomx_cache *randomx_create_cache(randomx_flags flags, uint8_t *memory) { randomx_cache *randomx_create_cache(randomx_flags flags, uint8_t *memory) {
@@ -573,6 +579,7 @@ extern "C" {
machine->initScratchpad(&tempHash); machine->initScratchpad(&tempHash);
machine->resetRoundingMode(); machine->resetRoundingMode();
for (uint32_t chain = 0; chain < RandomX_CurrentConfig.ProgramCount - 1; ++chain) { 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); machine->run(&tempHash);
rx_blake2b_wrapper::run(tempHash, sizeof(tempHash), machine->getRegisterFile(), sizeof(randomx::RegisterFile)); rx_blake2b_wrapper::run(tempHash, sizeof(tempHash), machine->getRegisterFile(), sizeof(randomx::RegisterFile));
} }
@@ -590,6 +597,7 @@ extern "C" {
machine->resetRoundingMode(); machine->resetRoundingMode();
for (uint32_t chain = 0; chain < RandomX_CurrentConfig.ProgramCount - 1; ++chain) { 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); machine->run(&tempHash);
rx_blake2b_wrapper::run(tempHash, sizeof(tempHash), machine->getRegisterFile(), sizeof(randomx::RegisterFile)); rx_blake2b_wrapper::run(tempHash, sizeof(tempHash), machine->getRegisterFile(), sizeof(randomx::RegisterFile));
} }
+11 -2
View File
@@ -35,6 +35,10 @@
namespace xmrig { 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) static void init_dataset_wrapper(randomx_dataset *dataset, randomx_cache *cache, uint32_t startItem, uint32_t itemCount, int priority)
{ {
Platform::setThreadPriority(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 a = (datasetItemCount * i) / numThreads;
const uint32_t b = (datasetItemCount * (i + 1)) / numThreads; const uint32_t b = (datasetItemCount * (i + 1)) / numThreads;
threads.emplace_back(init_dataset_wrapper, m_dataset, m_cache->get(), a, b - a, priority); 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) { if (!rx_dataset_single_thread_init){
threads[i].join(); for (uint32_t i = 0; i < numThreads; ++i) {
threads[i].join();
}
} }
} }
else { else {
init_dataset_wrapper(m_dataset, m_cache->get(), 0, datasetItemCount, priority); init_dataset_wrapper(m_dataset, m_cache->get(), 0, datasetItemCount, priority);
+6 -1
View File
@@ -37,8 +37,13 @@
* If you plan on changing donations to 0%, please consider making a one-off donation to my wallet: * If you plan on changing donations to 0%, please consider making a one-off donation to my wallet:
* XMR: 48edfHu7V9Z84YzzMa6fUueoELZ9ZRXq9VetWzYGzKt52XU5xvqgzYnDK9URnRoJMk1j8nLwEVsaSWJ4fhdUyZijBGUicoD * 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 kDefaultDonateLevel = 1;
constexpr const int kMinimumDonateLevel = 1; constexpr const int kMinimumDonateLevel = 1;
#endif
#endif // XMRIG_DONATE_H #endif // XMRIG_DONATE_H