From be0e2cbdd95b041a4351f2ea384defbad13d4ab8 Mon Sep 17 00:00:00 2001 From: James Piechota Date: Tue, 26 Nov 2024 18:57:39 +0000 Subject: [PATCH] Expose more RandomX configuration values --- CMakeLists.txt | 25 +++++++++++++++++++++++++ src/configuration.h | 10 ++++++++++ 2 files changed, 35 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a50001..9fc377f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -217,6 +217,11 @@ set(RANDOMX_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/src" CACHE STRING "RandomX Incl option(USE_HIDDEN_VISIBILITY "Include -fvisibility=hidden flag" OFF) set(RANDOMX_ARGON_MEMORY "" CACHE STRING "Set the RANDOMX_ARGON_MEMORY value") set(RANDOMX_DATASET_BASE_SIZE "" CACHE STRING "Set the RANDOMX_DATASET_BASE_SIZE value") +set(RANDOMX_PROGRAM_SIZE "" CACHE STRING "Set the RANDOMX_PROGRAM_SIZE value") +set(RANDOMX_PROGRAM_ITERATIONS "" CACHE STRING "Set the RANDOMX_PROGRAM_ITERATIONS value") +set(RANDOMX_PROGRAM_COUNT "" CACHE STRING "Set the RANDOMX_PROGRAM_COUNT value") +set(RANDOMX_SCRATCHPAD_L3 "" CACHE STRING "Set the RANDOMX_SCRATCHPAD_L3 value") +set(RANDOMX_FREQ_ISTORE "" CACHE STRING "Set the RANDOMX_FREQ_ISTORE value") if(USE_HIDDEN_VISIBILITY) add_compile_options("-fvisibility=hidden") @@ -233,6 +238,26 @@ if(RANDOMX_DATASET_BASE_SIZE) target_compile_definitions(randomx PRIVATE RANDOMX_DATASET_BASE_SIZE=${RANDOMX_DATASET_BASE_SIZE}) endif() +if(RANDOMX_PROGRAM_SIZE) + target_compile_definitions(randomx PRIVATE RANDOMX_PROGRAM_SIZE=${RANDOMX_PROGRAM_SIZE}) +endif() + +if(RANDOMX_PROGRAM_ITERATIONS) + target_compile_definitions(randomx PRIVATE RANDOMX_PROGRAM_ITERATIONS=${RANDOMX_PROGRAM_ITERATIONS}) +endif() + +if(RANDOMX_PROGRAM_COUNT) + target_compile_definitions(randomx PRIVATE RANDOMX_PROGRAM_COUNT=${RANDOMX_PROGRAM_COUNT}) +endif() + +if(RANDOMX_SCRATCHPAD_L3) + target_compile_definitions(randomx PRIVATE RANDOMX_SCRATCHPAD_L3=${RANDOMX_SCRATCHPAD_L3}) +endif() + +if(RANDOMX_FREQ_ISTORE) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_ISTORE=${RANDOMX_FREQ_ISTORE}) +endif() + if(TARGET generate-asm) add_dependencies(randomx generate-asm) endif() diff --git a/src/configuration.h b/src/configuration.h index e795d05..2edcf44 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -57,16 +57,24 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define RANDOMX_DATASET_EXTRA_SIZE 31563008 // 493172 (just an arbitrary number) * 64, tweaked for Arweave //Number of instructions in a RandomX program. Must be divisible by 8. +#ifndef RANDOMX_PROGRAM_SIZE #define RANDOMX_PROGRAM_SIZE 256 +#endif //Number of iterations during VM execution. +#ifndef RANDOMX_PROGRAM_ITERATIONS #define RANDOMX_PROGRAM_ITERATIONS 2048 +#endif //Number of chained VM executions per hash. +#ifndef RANDOMX_PROGRAM_COUNT #define RANDOMX_PROGRAM_COUNT 8 +#endif //Scratchpad L3 size in bytes. Must be a power of 2. +#ifndef RANDOMX_SCRATCHPAD_L3 #define RANDOMX_SCRATCHPAD_L3 2097152 +#endif //Scratchpad L2 size in bytes. Must be a power of two and less than or equal to RANDOMX_SCRATCHPAD_L3. #define RANDOMX_SCRATCHPAD_L2 262144 @@ -120,7 +128,9 @@ Total sum of frequencies must be 256 #define RANDOMX_FREQ_CFROUND 1 //Store instruction +#ifndef RANDOMX_FREQ_ISTORE #define RANDOMX_FREQ_ISTORE 16 +#endif //No-op instruction #define RANDOMX_FREQ_NOP 0