From 465806f55b1004b7824de5c118f3a2bd3caa557e Mon Sep 17 00:00:00 2001 From: James Piechota Date: Wed, 27 Nov 2024 01:34:04 +0000 Subject: [PATCH] Expose all the opcode frequency values --- CMakeLists.txt | 145 ++++++++++++++++++++++++++++++++++++ src/configuration.h | 83 +++++++++++++++++++++ src/instruction_weights.hpp | 1 + 3 files changed, 229 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fc377fa..fbea5fe7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -221,7 +221,36 @@ 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_IADD_RS "" CACHE STRING "Set the RANDOMX_FREQ_IADD_RS value") +set(RANDOMX_FREQ_IADD_M "" CACHE STRING "Set the RANDOMX_FREQ_IADD_M value") +set(RANDOMX_FREQ_ISUB_R "" CACHE STRING "Set the RANDOMX_FREQ_ISUB_R value") +set(RANDOMX_FREQ_ISUB_M "" CACHE STRING "Set the RANDOMX_FREQ_ISUB_M value") +set(RANDOMX_FREQ_IMUL_R "" CACHE STRING "Set the RANDOMX_FREQ_IMUL_R value") +set(RANDOMX_FREQ_IMUL_M "" CACHE STRING "Set the RANDOMX_FREQ_IMUL_M value") +set(RANDOMX_FREQ_IMULH_R "" CACHE STRING "Set the RANDOMX_FREQ_IMULH_R value") +set(RANDOMX_FREQ_IMULH_M "" CACHE STRING "Set the RANDOMX_FREQ_IMULH_M value") +set(RANDOMX_FREQ_ISMULH_R "" CACHE STRING "Set the RANDOMX_FREQ_ISMULH_R value") +set(RANDOMX_FREQ_ISMULH_M "" CACHE STRING "Set the RANDOMX_FREQ_ISMULH_M value") +set(RANDOMX_FREQ_IMUL_RCP "" CACHE STRING "Set the RANDOMX_FREQ_IMUL_RCP value") +set(RANDOMX_FREQ_INEG_R "" CACHE STRING "Set the RANDOMX_FREQ_INEG_R value") +set(RANDOMX_FREQ_IXOR_R "" CACHE STRING "Set the RANDOMX_FREQ_IXOR_R value") +set(RANDOMX_FREQ_IXOR_M "" CACHE STRING "Set the RANDOMX_FREQ_IXOR_M value") +set(RANDOMX_FREQ_IROR_R "" CACHE STRING "Set the RANDOMX_FREQ_IROR_R value") +set(RANDOMX_FREQ_IROL_R "" CACHE STRING "Set the RANDOMX_FREQ_IROL_R value") +set(RANDOMX_FREQ_ISWAP_R "" CACHE STRING "Set the RANDOMX_FREQ_ISWAP_R value") +set(RANDOMX_FREQ_FSWAP_R "" CACHE STRING "Set the RANDOMX_FREQ_FSWAP_R value") +set(RANDOMX_FREQ_FADD_R "" CACHE STRING "Set the RANDOMX_FREQ_FADD_R value") +set(RANDOMX_FREQ_FADD_M "" CACHE STRING "Set the RANDOMX_FREQ_FADD_M value") +set(RANDOMX_FREQ_FSUB_R "" CACHE STRING "Set the RANDOMX_FREQ_FSUB_R value") +set(RANDOMX_FREQ_FSUB_M "" CACHE STRING "Set the RANDOMX_FREQ_FSUB_M value") +set(RANDOMX_FREQ_FSCAL_R "" CACHE STRING "Set the RANDOMX_FREQ_FSCAL_R value") +set(RANDOMX_FREQ_FMUL_R "" CACHE STRING "Set the RANDOMX_FREQ_FMUL_R value") +set(RANDOMX_FREQ_FDIV_M "" CACHE STRING "Set the RANDOMX_FREQ_FDIV_M value") +set(RANDOMX_FREQ_FSQRT_R "" CACHE STRING "Set the RANDOMX_FREQ_FSQRT_R value") +set(RANDOMX_FREQ_CBRANCH "" CACHE STRING "Set the RANDOMX_FREQ_CBRANCH value") +set(RANDOMX_FREQ_CFROUND "" CACHE STRING "Set the RANDOMX_FREQ_CFROUND value") set(RANDOMX_FREQ_ISTORE "" CACHE STRING "Set the RANDOMX_FREQ_ISTORE value") +set(RANDOMX_FREQ_NOP "" CACHE STRING "Set the RANDOMX_FREQ_NOP value") if(USE_HIDDEN_VISIBILITY) add_compile_options("-fvisibility=hidden") @@ -254,10 +283,126 @@ if(RANDOMX_SCRATCHPAD_L3) target_compile_definitions(randomx PRIVATE RANDOMX_SCRATCHPAD_L3=${RANDOMX_SCRATCHPAD_L3}) endif() +if(RANDOMX_FREQ_IADD_RS) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_IADD_RS=${RANDOMX_FREQ_IADD_RS}) +endif() + +if(RANDOMX_FREQ_IADD_M) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_IADD_M=${RANDOMX_FREQ_IADD_M}) +endif() + +if(RANDOMX_FREQ_ISUB_R) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_ISUB_R=${RANDOMX_FREQ_ISUB_R}) +endif() + +if(RANDOMX_FREQ_ISUB_M) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_ISUB_M=${RANDOMX_FREQ_ISUB_M}) +endif() + +if(RANDOMX_FREQ_IMUL_R) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_IMUL_R=${RANDOMX_FREQ_IMUL_R}) +endif() + +if(RANDOMX_FREQ_IMUL_M) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_IMUL_M=${RANDOMX_FREQ_IMUL_M}) +endif() + +if(RANDOMX_FREQ_IMULH_R) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_IMULH_R=${RANDOMX_FREQ_IMULH_R}) +endif() + +if(RANDOMX_FREQ_IMULH_M) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_IMULH_M=${RANDOMX_FREQ_IMULH_M}) +endif() + +if(RANDOMX_FREQ_ISMULH_R) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_ISMULH_R=${RANDOMX_FREQ_ISMULH_R}) +endif() + +if(RANDOMX_FREQ_ISMULH_M) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_ISMULH_M=${RANDOMX_FREQ_ISMULH_M}) +endif() + +if(RANDOMX_FREQ_IMUL_RCP) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_IMUL_RCP=${RANDOMX_FREQ_IMUL_RCP}) +endif() + +if(RANDOMX_FREQ_INEG_R) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_INEG_R=${RANDOMX_FREQ_INEG_R}) +endif() + +if(RANDOMX_FREQ_IXOR_R) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_IXOR_R=${RANDOMX_FREQ_IXOR_R}) +endif() + +if(RANDOMX_FREQ_IXOR_M) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_IXOR_M=${RANDOMX_FREQ_IXOR_M}) +endif() + +if(RANDOMX_FREQ_IROR_R) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_IROR_R=${RANDOMX_FREQ_IROR_R}) +endif() + +if(RANDOMX_FREQ_IROL_R) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_IROL_R=${RANDOMX_FREQ_IROL_R}) +endif() + +if(RANDOMX_FREQ_ISWAP_R) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_ISWAP_R=${RANDOMX_FREQ_ISWAP_R}) +endif() + +if(RANDOMX_FREQ_FSWAP_R) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_FSWAP_R=${RANDOMX_FREQ_FSWAP_R}) +endif() + +if(RANDOMX_FREQ_FADD_R) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_FADD_R=${RANDOMX_FREQ_FADD_R}) +endif() + +if(RANDOMX_FREQ_FADD_M) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_FADD_M=${RANDOMX_FREQ_FADD_M}) +endif() + +if(RANDOMX_FREQ_FSUB_R) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_FSUB_R=${RANDOMX_FREQ_FSUB_R}) +endif() + +if(RANDOMX_FREQ_FSUB_M) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_FSUB_M=${RANDOMX_FREQ_FSUB_M}) +endif() + +if(RANDOMX_FREQ_FSCAL_R) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_FSCAL_R=${RANDOMX_FREQ_FSCAL_R}) +endif() + +if(RANDOMX_FREQ_FMUL_R) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_FMUL_R=${RANDOMX_FREQ_FMUL_R}) +endif() + +if(RANDOMX_FREQ_FDIV_M) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_FDIV_M=${RANDOMX_FREQ_FDIV_M}) +endif() + +if(RANDOMX_FREQ_FSQRT_R) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_FSQRT_R=${RANDOMX_FREQ_FSQRT_R}) +endif() + +if(RANDOMX_FREQ_CBRANCH) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_CBRANCH=${RANDOMX_FREQ_CBRANCH}) +endif() + +if(RANDOMX_FREQ_CFROUND) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_CFROUND=${RANDOMX_FREQ_CFROUND}) +endif() + if(RANDOMX_FREQ_ISTORE) target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_ISTORE=${RANDOMX_FREQ_ISTORE}) endif() +if(RANDOMX_FREQ_NOP) + target_compile_definitions(randomx PRIVATE RANDOMX_FREQ_NOP=${RANDOMX_FREQ_NOP}) +endif() + if(TARGET generate-asm) add_dependencies(randomx generate-asm) endif() diff --git a/src/configuration.h b/src/configuration.h index 2edcf44f..7e53ef0d 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -94,38 +94,119 @@ Total sum of frequencies must be 256 */ //Integer instructions +#ifndef RANDOMX_FREQ_IADD_RS #define RANDOMX_FREQ_IADD_RS 25 +#endif + +#ifndef RANDOMX_FREQ_IADD_M #define RANDOMX_FREQ_IADD_M 7 +#endif + +#ifndef RANDOMX_FREQ_ISUB_R #define RANDOMX_FREQ_ISUB_R 16 +#endif + +#ifndef RANDOMX_FREQ_ISUB_M #define RANDOMX_FREQ_ISUB_M 7 +#endif + +#ifndef RANDOMX_FREQ_IMUL_R #define RANDOMX_FREQ_IMUL_R 16 +#endif + +#ifndef RANDOMX_FREQ_IMUL_M #define RANDOMX_FREQ_IMUL_M 4 +#endif + +#ifndef RANDOMX_FREQ_IMULH_R #define RANDOMX_FREQ_IMULH_R 4 +#endif + +#ifndef RANDOMX_FREQ_IMULH_M #define RANDOMX_FREQ_IMULH_M 1 +#endif + +#ifndef RANDOMX_FREQ_ISMULH_R #define RANDOMX_FREQ_ISMULH_R 4 +#endif + +#ifndef RANDOMX_FREQ_ISMULH_M #define RANDOMX_FREQ_ISMULH_M 1 +#endif + +#ifndef RANDOMX_FREQ_IMUL_RCP #define RANDOMX_FREQ_IMUL_RCP 8 +#endif + +#ifndef RANDOMX_FREQ_INEG_R #define RANDOMX_FREQ_INEG_R 2 +#endif + +#ifndef RANDOMX_FREQ_IXOR_R #define RANDOMX_FREQ_IXOR_R 15 +#endif + +#ifndef RANDOMX_FREQ_IXOR_M #define RANDOMX_FREQ_IXOR_M 5 +#endif + +#ifndef RANDOMX_FREQ_IROR_R #define RANDOMX_FREQ_IROR_R 10 +#endif + +#ifndef RANDOMX_FREQ_IROL_R #define RANDOMX_FREQ_IROL_R 0 +#endif + +#ifndef RANDOMX_FREQ_ISWAP_R #define RANDOMX_FREQ_ISWAP_R 4 +#endif //Floating point instructions +#ifndef RANDOMX_FREQ_FSWAP_R #define RANDOMX_FREQ_FSWAP_R 8 +#endif + +#ifndef RANDOMX_FREQ_FADD_R #define RANDOMX_FREQ_FADD_R 20 +#endif + +#ifndef RANDOMX_FREQ_FADD_M #define RANDOMX_FREQ_FADD_M 5 +#endif + +#ifndef RANDOMX_FREQ_FSUB_R #define RANDOMX_FREQ_FSUB_R 20 +#endif + +#ifndef RANDOMX_FREQ_FSUB_M #define RANDOMX_FREQ_FSUB_M 5 +#endif + +#ifndef RANDOMX_FREQ_FSCAL_R #define RANDOMX_FREQ_FSCAL_R 6 +#endif + +#ifndef RANDOMX_FREQ_FMUL_R #define RANDOMX_FREQ_FMUL_R 20 +#endif + +#ifndef RANDOMX_FREQ_FDIV_M #define RANDOMX_FREQ_FDIV_M 4 +#endif + +#ifndef RANDOMX_FREQ_FSQRT_R #define RANDOMX_FREQ_FSQRT_R 6 +#endif //Control instructions +#ifndef RANDOMX_FREQ_CBRANCH #define RANDOMX_FREQ_CBRANCH 16 +#endif + +#ifndef RANDOMX_FREQ_CFROUND #define RANDOMX_FREQ_CFROUND 1 +#endif //Store instruction #ifndef RANDOMX_FREQ_ISTORE @@ -133,7 +214,9 @@ Total sum of frequencies must be 256 #endif //No-op instruction +#ifndef RANDOMX_FREQ_NOP #define RANDOMX_FREQ_NOP 0 +#endif /* ------ 256 */ \ No newline at end of file diff --git a/src/instruction_weights.hpp b/src/instruction_weights.hpp index f6c88734..2c208a7e 100644 --- a/src/instruction_weights.hpp +++ b/src/instruction_weights.hpp @@ -63,6 +63,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define REP32(x) REP31(x) x, #define REP33(x) REP32(x) x, #define REP40(x) REP32(x) REP8(x) +#define REP48(x) REP40(x) REP8(x) #define REP64(x) REP32(x) REP32(x) #define REP128(x) REP32(x) REP32(x) REP32(x) REP32(x) #define REP232(x) REP128(x) REP40(x) REP40(x) REP24(x)