@@ -25,7 +25,11 @@ var calcCmd = &cli.Command{
25
25
26
26
var calcBatchCpuCmd = & cli.Command {
27
27
Name : "batch-cpu" ,
28
- Usage : "See layout of batch sealer threads" ,
28
+ Usage : "Analyze and display the layout of batch sealer threads" ,
29
+ Description : `Analyze and display the layout of batch sealer threads on your CPU.
30
+
31
+ It provides detailed information about CPU utilization for batch sealing operations, including core allocation, thread
32
+ distribution for different batch sizes.` ,
29
33
Flags : []cli.Flag {
30
34
& cli.BoolFlag {Name : "dual-hashers" , Value : true },
31
35
},
@@ -61,157 +65,59 @@ var calcBatchCpuCmd = &cli.Command{
61
65
printForBatchSize := func (batchSize int ) {
62
66
fmt .Printf ("Batch Size: %s sectors\n " , color .CyanString ("%d" , batchSize ))
63
67
fmt .Println ()
64
- fmt .Printf ("Required Threads: %d\n " , batchSize / sectorsPerThread )
65
- requiredCCX := (batchSize + sectorsPerCCX - 1 ) / sectorsPerCCX
66
- fmt .Printf ("Required CCX: %d\n " , requiredCCX )
67
68
68
- requiredCores := requiredCCX + batchSize / sectorsPerThread / info .ThreadsPerCore
69
- fmt .Printf ("Required Cores: %d hasher (+4 minimum for non-hashers)\n " , requiredCores )
69
+ config , err := sealsupra .GenerateSupraSealConfig (* info , cctx .Bool ("dual-hashers" ), batchSize , nil )
70
+ if err != nil {
71
+ fmt .Printf ("Error generating config: %s\n " , err )
72
+ return
73
+ }
70
74
71
- enoughCores := requiredCores <= info .CoreCount
75
+ fmt .Printf ("Required Threads: %d\n " , config .RequiredThreads )
76
+ fmt .Printf ("Required CCX: %d\n " , config .RequiredCCX )
77
+ fmt .Printf ("Required Cores: %d hasher (+4 minimum for non-hashers)\n " , config .RequiredCores )
78
+
79
+ enoughCores := config .RequiredCores <= info .CoreCount
72
80
if enoughCores {
73
81
fmt .Printf ("Enough cores available for hashers %s\n " , color .GreenString ("✔" ))
74
82
} else {
75
83
fmt .Printf ("Not enough cores available for hashers %s\n " , color .RedString ("✘" ))
76
84
return
77
85
}
78
86
79
- coresLeftover := info .CoreCount - requiredCores
80
- fmt .Printf ("Non-hasher cores: %d\n " , coresLeftover )
81
-
82
- const minOverheadCores = 4
83
-
84
- type CoreNum = int // core number, 0-based
85
-
86
- var (
87
- // core assignments for non-hasher work
88
- // defaults are the absolutely worst case of just 4 cores available
89
-
90
- pc1writer CoreNum = 1
91
- pc1reader CoreNum = 2
92
- pc1orchestrator CoreNum = 3
93
-
94
- pc2reader CoreNum = 0
95
- pc2hasher CoreNum = 1
96
- pc2hasher_cpu CoreNum = 0
97
- pc2writer CoreNum = 0
98
-
99
- c1reader CoreNum = 0
100
-
101
- pc2writer_cores int = 1
102
- )
103
-
104
- if coresLeftover < minOverheadCores {
105
- fmt .Printf ("Not enough cores for coordination %s\n " , color .RedString ("✘" ))
106
- return
107
- } else {
108
- fmt .Printf ("Enough cores for coordination %s\n " , color .GreenString ("✔" ))
109
- }
110
-
111
- nextFreeCore := minOverheadCores
87
+ fmt .Printf ("Non-hasher cores: %d\n " , info .CoreCount - config .RequiredCores )
112
88
113
- // first move pc2 to individual cores
114
- if coresLeftover > nextFreeCore {
115
- pc2writer = nextFreeCore
116
- nextFreeCore ++
117
- } else {
89
+ if config .P2WrRdOverlap {
118
90
color .Yellow ("! P2 writer will share a core with P2 reader, performance may be impacted" )
119
91
}
120
-
121
- if coresLeftover > nextFreeCore {
122
- pc2hasher = nextFreeCore
123
- nextFreeCore ++
124
- } else {
92
+ if config .P2HsP1WrOverlap {
125
93
color .Yellow ("! P2 hasher will share a core with P1 writer, performance may be impacted" )
126
94
}
127
-
128
- if coresLeftover > nextFreeCore {
129
- pc2hasher_cpu = nextFreeCore
130
- nextFreeCore ++
131
- } else {
95
+ if config .P2HcP2RdOverlap {
132
96
color .Yellow ("! P2 hasher_cpu will share a core with P2 reader, performance may be impacted" )
133
97
}
134
98
135
- if coresLeftover > nextFreeCore {
136
- // might be fine to sit on core0, but let's not do that
137
- pc2reader = nextFreeCore
138
- c1reader = nextFreeCore
139
- nextFreeCore ++
140
- }
141
-
142
- // add p2 writer cores, up to 8 total
143
- if coresLeftover > nextFreeCore {
144
- // swap pc2reader with pc2writer
145
- pc2writer , pc2reader = pc2reader , pc2writer
146
-
147
- for i := 0 ; i < 7 ; i ++ {
148
- if coresLeftover > nextFreeCore {
149
- pc2writer_cores ++
150
- nextFreeCore ++
151
- }
152
- }
153
- }
154
-
155
99
fmt .Println ()
156
- fmt .Printf ("pc1 writer: %d\n " , pc1writer )
157
- fmt .Printf ("pc1 reader: %d\n " , pc1reader )
158
- fmt .Printf ("pc1 orchestrator: %d\n " , pc1orchestrator )
100
+ fmt .Printf ("pc1 writer: %d\n " , config . Topology . PC1Writer )
101
+ fmt .Printf ("pc1 reader: %d\n " , config . Topology . PC1Reader )
102
+ fmt .Printf ("pc1 orchestrator: %d\n " , config . Topology . PC1Orchestrator )
159
103
fmt .Println ()
160
- fmt .Printf ("pc2 reader: %d\n " , pc2reader )
161
- fmt .Printf ("pc2 hasher: %d\n " , pc2hasher )
162
- fmt .Printf ("pc2 hasher_cpu: %d\n " , pc2hasher_cpu )
163
- fmt .Printf ("pc2 writer: %d\n " , pc2writer )
164
- fmt .Printf ("pc2 writer_cores: %d\n " , pc2writer_cores )
104
+ fmt .Printf ("pc2 reader: %d\n " , config . Topology . PC2Reader )
105
+ fmt .Printf ("pc2 hasher: %d\n " , config . Topology . PC2Hasher )
106
+ fmt .Printf ("pc2 hasher_cpu: %d\n " , config . Topology . PC2HasherCPU )
107
+ fmt .Printf ("pc2 writer: %d\n " , config . Topology . PC2Writer )
108
+ fmt .Printf ("pc2 writer_cores: %d\n " , config . Topology . PC2WriterCores )
165
109
fmt .Println ()
166
- fmt .Printf ("c1 reader: %d\n " , c1reader )
110
+ fmt .Printf ("c1 reader: %d\n " , config . Topology . C1Reader )
167
111
fmt .Println ()
168
112
169
- unoccupiedCores := coresLeftover - nextFreeCore
170
- fmt .Printf ("Unoccupied Cores: %d\n \n " , unoccupiedCores )
171
-
172
- var ccxCores []CoreNum // first core in each CCX
173
- for i := 0 ; i < info .CoreCount ; i += info .CoresPerL3 {
174
- ccxCores = append (ccxCores , i )
175
- }
176
-
177
- type sectorCoreConfig struct {
178
- core CoreNum // coordinator core
179
- hashers CoreNum // number of hasher cores
180
- }
181
- var coreConfigs []sectorCoreConfig
182
-
183
- for i := requiredCores ; i > 0 ; {
184
- firstCCXCoreNum := ccxCores [len (ccxCores )- 1 ]
185
- toAssign := min (i , info .CoresPerL3 )
186
-
187
- // shift up the first core if possible so that cores on the right are used first
188
- coreNum := firstCCXCoreNum + info .CoresPerL3 - toAssign
189
-
190
- coreConfigs = append (coreConfigs , sectorCoreConfig {
191
- core : coreNum ,
192
- hashers : (toAssign - 1 ) * info .ThreadsPerCore ,
193
- })
194
-
195
- i -= toAssign
196
- if toAssign == info .CoresPerL3 {
197
- ccxCores = ccxCores [:len (ccxCores )- 1 ]
198
- if len (ccxCores ) == 0 {
199
- break
200
- }
201
- }
202
- }
203
-
204
- // reverse the order
205
- for i , j := 0 , len (coreConfigs )- 1 ; i < j ; i , j = i + 1 , j - 1 {
206
- coreConfigs [i ], coreConfigs [j ] = coreConfigs [j ], coreConfigs [i ]
207
- }
113
+ fmt .Printf ("Unoccupied Cores: %d\n \n " , config .UnoccupiedCores )
208
114
209
115
fmt .Println ("{" )
210
116
fmt .Printf (" sectors = %d;\n " , batchSize )
211
117
fmt .Println (" coordinators = (" )
212
- for i , config := range coreConfigs {
213
- fmt .Printf (" { core = %d;\n hashers = %d; }" , config . core , config . hashers )
214
- if i < len (coreConfigs )- 1 {
118
+ for i , coord := range config . Topology . SectorConfigs [ 0 ]. Coordinators {
119
+ fmt .Printf (" { core = %d;\n hashers = %d; }" , coord . Core , coord . Hashers )
120
+ if i < len (config . Topology . SectorConfigs [ 0 ]. Coordinators )- 1 {
215
121
fmt .Println ("," )
216
122
} else {
217
123
fmt .Println ()
@@ -235,6 +141,10 @@ var calcBatchCpuCmd = &cli.Command{
235
141
var calcSuprasealConfigCmd = & cli.Command {
236
142
Name : "supraseal-config" ,
237
143
Usage : "Generate a supra_seal configuration" ,
144
+ Description : `Generate a supra_seal configuration for a given batch size.
145
+
146
+ This command outputs a configuration expected by SupraSeal. Main purpose of this command is for debugging and testing.
147
+ The config can be used directly with SupraSeal binaries to test it without involving Curio.` ,
238
148
Flags : []cli.Flag {
239
149
& cli.BoolFlag {
240
150
Name : "dual-hashers" ,
0 commit comments