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