configuration.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. //Dataset base size in bytes. Must be a power of 2.
  39. #define RANDOMX_DATASET_BASE_SIZE 2147483648
  40. //Dataset extra size. Must be divisible by 64.
  41. #define RANDOMX_DATASET_EXTRA_SIZE 33554368
  42. //Number of instructions in a RandomX program. Must be divisible by 8.
  43. #define RANDOMX_PROGRAM_SIZE 256
  44. //Number of iterations during VM execution.
  45. #define RANDOMX_PROGRAM_ITERATIONS 2048
  46. //Number of chained VM executions per hash.
  47. #define RANDOMX_PROGRAM_COUNT 8
  48. //Scratchpad L3 size in bytes. Must be a power of 2.
  49. #define RANDOMX_SCRATCHPAD_L3 2097152
  50. //Scratchpad L2 size in bytes. Must be a power of two and less than or equal to RANDOMX_SCRATCHPAD_L3.
  51. #define RANDOMX_SCRATCHPAD_L2 262144
  52. //Scratchpad L1 size in bytes. Must be a power of two (minimum 64) and less than or equal to RANDOMX_SCRATCHPAD_L2.
  53. #define RANDOMX_SCRATCHPAD_L1 16384
  54. //Jump condition mask size in bits.
  55. #define RANDOMX_JUMP_BITS 8
  56. //Jump condition mask offset in bits. The sum of RANDOMX_JUMP_BITS and RANDOMX_JUMP_OFFSET must not exceed 16.
  57. #define RANDOMX_JUMP_OFFSET 8
  58. /*
  59. Instruction frequencies (per 256 opcodes)
  60. Total sum of frequencies must be 256
  61. */
  62. //Integer instructions
  63. #define RANDOMX_FREQ_IADD_RS 25
  64. #define RANDOMX_FREQ_IADD_M 7
  65. #define RANDOMX_FREQ_ISUB_R 16
  66. #define RANDOMX_FREQ_ISUB_M 7
  67. #define RANDOMX_FREQ_IMUL_R 16
  68. #define RANDOMX_FREQ_IMUL_M 4
  69. #define RANDOMX_FREQ_IMULH_R 4
  70. #define RANDOMX_FREQ_IMULH_M 1
  71. #define RANDOMX_FREQ_ISMULH_R 4
  72. #define RANDOMX_FREQ_ISMULH_M 1
  73. #define RANDOMX_FREQ_IMUL_RCP 8
  74. #define RANDOMX_FREQ_INEG_R 2
  75. #define RANDOMX_FREQ_IXOR_R 15
  76. #define RANDOMX_FREQ_IXOR_M 5
  77. #define RANDOMX_FREQ_IROR_R 8
  78. #define RANDOMX_FREQ_IROL_R 2
  79. #define RANDOMX_FREQ_ISWAP_R 4
  80. //Floating point instructions
  81. #define RANDOMX_FREQ_FSWAP_R 4
  82. #define RANDOMX_FREQ_FADD_R 16
  83. #define RANDOMX_FREQ_FADD_M 5
  84. #define RANDOMX_FREQ_FSUB_R 16
  85. #define RANDOMX_FREQ_FSUB_M 5
  86. #define RANDOMX_FREQ_FSCAL_R 6
  87. #define RANDOMX_FREQ_FMUL_R 32
  88. #define RANDOMX_FREQ_FDIV_M 4
  89. #define RANDOMX_FREQ_FSQRT_R 6
  90. //Control instructions
  91. #define RANDOMX_FREQ_CBRANCH 16
  92. #define RANDOMX_FREQ_CFROUND 1
  93. //Store instruction
  94. #define RANDOMX_FREQ_ISTORE 16
  95. //No-op instruction
  96. #define RANDOMX_FREQ_NOP 0
  97. /* ------
  98. 256
  99. */