Skip to content

Commit

Permalink
Expose more RandomX configuration values
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesPiechota committed Nov 26, 2024
1 parent c18431e commit be0e2cb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
25 changes: 25 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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()
Expand Down
10 changes: 10 additions & 0 deletions src/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit be0e2cb

Please sign in to comment.