configuration.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. Copyright (c) 2018-2019, tevador <tevador@gmail.com>
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are met:
  6. * Redistributions of source code must retain the above copyright
  7. notice, this list of conditions and the following disclaimer.
  8. * Redistributions in binary form must reproduce the above copyright
  9. notice, this list of conditions and the following disclaimer in the
  10. documentation and/or other materials provided with the distribution.
  11. * Neither the name of the copyright holder nor the
  12. names of its contributors may be used to endorse or promote products
  13. derived from this software without specific prior written permission.
  14. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  15. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  18. FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  19. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  20. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  21. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  22. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  23. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #pragma once
  26. //Cache size in KiB. Must be a power of 2.
  27. #define RANDOMX_ARGON_MEMORY 262144
  28. //Number of Argon2d iterations for Cache initialization
  29. #define RANDOMX_ARGON_ITERATIONS 3
  30. //Number of parallel lanes for Cache initialization
  31. #define RANDOMX_ARGON_LANES 1
  32. //Argon2d salt
  33. #define RANDOMX_ARGON_SALT "RandomX\x03"
  34. //Number of random Cache accesses per Dataset item. Minimum is 2.
  35. #define RANDOMX_CACHE_ACCESSES 8
  36. //Target latency for SuperscalarHash (in cycles of the reference CPU).
  37. #define RANDOMX_SUPERSCALAR_LATENCY 170
  38. //The maximum size of a SuperscalarHash program (number of instructions).
  39. #define RANDOMX_SUPERSCALAR_MAX_SIZE 512
  40. //Dataset base size in bytes. Must be a power of 2.
  41. #define RANDOMX_DATASET_BASE_SIZE 2147483648
  42. //Dataset extra size. Must be divisible by 64.
  43. #define RANDOMX_DATASET_EXTRA_SIZE 33554368
  44. //Number of instructions in a RandomX program
  45. #define RANDOMX_PROGRAM_SIZE 256
  46. //Number of iterations during VM execution
  47. #define RANDOMX_PROGRAM_ITERATIONS 2048
  48. //Number of chained VM executions per hash
  49. #define RANDOMX_PROGRAM_COUNT 8
  50. //Scratchpad L3 size in bytes. Must be a power of 2.
  51. #define RANDOMX_SCRATCHPAD_L3 2097152
  52. //Scratchpad L2 size in bytes. Must be a power of two and less than or equal to RANDOMX_SCRATCHPAD_L3.
  53. #define RANDOMX_SCRATCHPAD_L2 262144
  54. //Scratchpad L1 size in bytes. Must be a power of two and less than or equal to RANDOMX_SCRATCHPAD_L2.
  55. #define RANDOMX_SCRATCHPAD_L1 16384
  56. //Jump condition mask size in bits.
  57. #define RANDOMX_JUMP_BITS 8
  58. //Jump condition mask offset in bits.
  59. #define RANDOMX_JUMP_OFFSET 8
  60. /*
  61. Instruction frequencies (per 256 opcodes)
  62. Total sum of frequencies must be 256
  63. */
  64. #define RANDOMX_FREQ_IADD_RS 25
  65. #define RANDOMX_FREQ_IADD_M 7
  66. #define RANDOMX_FREQ_ISUB_R 16
  67. #define RANDOMX_FREQ_ISUB_M 7
  68. #define RANDOMX_FREQ_IMUL_R 16
  69. #define RANDOMX_FREQ_IMUL_M 4
  70. #define RANDOMX_FREQ_IMULH_R 4
  71. #define RANDOMX_FREQ_IMULH_M 1
  72. #define RANDOMX_FREQ_ISMULH_R 4
  73. #define RANDOMX_FREQ_ISMULH_M 1
  74. #define RANDOMX_FREQ_IMUL_RCP 8
  75. #define RANDOMX_FREQ_INEG_R 2
  76. #define RANDOMX_FREQ_IXOR_R 15
  77. #define RANDOMX_FREQ_IXOR_M 5
  78. #define RANDOMX_FREQ_IROR_R 10
  79. #define RANDOMX_FREQ_IROL_R 0
  80. #define RANDOMX_FREQ_ISWAP_R 4
  81. #define RANDOMX_FREQ_FSWAP_R 8
  82. #define RANDOMX_FREQ_FADD_R 20
  83. #define RANDOMX_FREQ_FADD_M 5
  84. #define RANDOMX_FREQ_FSUB_R 20
  85. #define RANDOMX_FREQ_FSUB_M 5
  86. #define RANDOMX_FREQ_FSCAL_R 6
  87. #define RANDOMX_FREQ_FMUL_R 20
  88. #define RANDOMX_FREQ_FDIV_M 4
  89. #define RANDOMX_FREQ_FSQRT_R 6
  90. #define RANDOMX_FREQ_CBRANCH 16
  91. #define RANDOMX_FREQ_CFROUND 1
  92. #define RANDOMX_FREQ_ISTORE 16
  93. #define RANDOMX_FREQ_NOP 0
  94. /* ------
  95. 256
  96. */