Debian Codegraph @

tensilelite/Tensile/Common/ValidParameters.py

raw symbols SCIP
1 ################################################################################
2 #
3 # Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved.
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining a copy
6 # of this software and associated documentation files (the "Software"), to deal
7 # in the Software without restriction, including without limitation the rights
8 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 # copies of the Software, and to permit persons to whom the Software is
10 # furnished to do so, subject to the following conditions:
11 #
12 # The above copyright notice and this permission notice shall be included in
13 # all copies or substantial portions of the Software.
14 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 # SOFTWARE.
22 #
23 ################################################################################
24
25 import math
26 from functools import lru_cache
27
28 from .Architectures import SUPPORTED_ISA
29
30 ################################################################################
31 # Enumerate Valid Solution Parameters
32 ################################################################################
33
34 validThreadTileSides = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] + list(
35 range(20, 256, 4)
36 )
37 validThreadTiles = []
38 for i in validThreadTileSides:
39 for j in validThreadTileSides:
40 validThreadTiles.append([i, j])
41
42 validActivationFormats = ("NCHW", "NHWC", "CNHW", "NCDHW", "NDHWC", "CNDHW")
43 validWeightFormats = ("KCYX", "KYXC", "CKYX", "CYXK", "KCZYX", "CKZYX", "CZYXK")
44 validMacroTileSides = [
45 1,
46 2,
47 4,
48 8,
49 16,
50 32,
51 64,
52 128,
53 256,
54 512,
55 1024,
56 6,
57 12,
58 24,
59 48,
60 96,
61 192,
62 384,
63 768,
64 ]
65 validMacroTiles = []
66 validISA = [(0, 0, 0)]
67 validISA.extend(SUPPORTED_ISA)
68 for i in validMacroTileSides:
69 for j in validMacroTileSides:
70 validMacroTiles.append([i, j])
71 validTT = 32
72
73 @lru_cache
74 def makeValidWorkGroups():
75 validWorkGroups = []
76 for numThreads in range(32, 1025, 32):
77 for nsg in [1, 2, 4, 8, 16, 32, 64, 96, 128, 256]:
78 for sg0 in range(1, numThreads // nsg + 1):
79 sg1 = numThreads // nsg // sg0
80 if sg0 * sg1 * nsg == numThreads:
81 workGroup = [sg0, sg1, nsg]
82 validWorkGroups.append(workGroup)
83 return validWorkGroups
84
85 def makeValidWMMA():
86 return [[16, 16, 16, 1]]
87
88 @lru_cache
89 def makeValidMFMA():
90 validMFMA = {}
91 validMFMA["H"] = [[32, 32, 16, 1], [32, 32, 4, 2], [32, 32, 8, 1], [16, 16, 32, 1], [16, 16, 4, 4], [16, 16, 16, 1], [4, 4, 4, 16]]
92 validMFMA["S"] = [[32, 32, 1, 2], [32, 32, 2, 1], [16, 16, 1, 4], [16, 16, 4, 1], [4, 4, 1, 16], [16, 16, 32, 1], [32, 32, 16, 1]]
93 validMFMA["B"] = [[32, 32, 16, 1], [32, 32, 2, 2], [32, 32, 4, 1], [16, 16, 32, 1], [16, 16, 2, 4], [16, 16, 8, 1], [4, 4, 2, 16]]
94 validMFMA["4xi8"] = [
95 [32, 32, 4, 2],
96 [32, 32, 8, 1],
97 [16, 16, 4, 4],
98 [16, 16, 16, 1],
99 [4, 4, 4, 16],
100 [32, 32, 16, 1],
101 [16, 16, 32, 1],
102 ]
103 validMFMA["D"] = [[16, 16, 4, 1], [4, 4, 4, 4]]
104 validMFMA["B1k"] = [[32, 32, 4, 2], [32, 32, 8, 1], [16, 16, 4, 4], [16, 16, 16, 1], [4, 4, 4, 16]]
105 validMFMA["C"] = validMFMA["S"]
106 validMFMA["Z"] = validMFMA["D"]
107 validMFMA["I8"] = [
108 [32, 32, 4, 2],
109 [32, 32, 8, 1],
110 [16, 16, 4, 4],
111 [16, 16, 16, 1],
112 [4, 4, 4, 16],
113 ] + [[32, 32, 16, 1], [16, 16, 32, 1],] + [[16, 16, 64, 1],[32, 32, 32, 1]]
114 validMFMA["X"] = [[32, 32, 4, 1], [16, 16, 8, 1], [16, 16, 16, 1], [16, 16, 32, 1], [32, 32, 16, 1]]
115 validMFMA["F8"] = [[32, 32, 16, 1], [16, 16, 32, 1], [32, 32, 64, 1], [16, 16, 128, 1]]
116 validMFMA["B8"] = validMFMA["F8"]
117 validMFMA["F8B8"] = validMFMA["F8"]
118 validMFMA["B8F8"] = validMFMA["F8"]
119 validMFMA["F8N"] = [[32, 32, 16, 1], [16, 16, 32, 1]]
120 validMFMA["B8N"] = validMFMA["F8N"]
121 validMFMA["F8B8N"] = validMFMA["F8N"]
122 validMFMA["B8F8N"] = validMFMA["F8N"]
123 validMFMA["_format9"] = []
124
125 for MFMA in [
126 validMFMA["H"],
127 validMFMA["S"],
128 validMFMA["B"],
129 validMFMA["D"],
130 validMFMA["X"],
131 validMFMA["F8N"],
132 makeValidWMMA(),
133 ]:
134 for MI in MFMA:
135 for bm in range(int(math.log(MI[3], 2)) + 1):
136 for tt0 in range(1, validTT + 1):
137 for tt1 in range(1, validTT + 1):
138 for wave_m in range(3):
139 for wave_n in range(3):
140 validMFMA["_format9"].append(
141 [MI[0], MI[1], MI[2], MI[3], 2**bm, tt0, tt1, 2**wave_m, 2**wave_n]
142 )
143 return validMFMA
144
145 @lru_cache
146 def makeValidSMFMA():
147 validSMFMA = {}
148 validSMFMA["H"] = [[32, 32, 16, 1], [16, 16, 32, 1], [16, 16, 64, 1], [32, 32, 32, 1]]
149 validSMFMA["B"] = [[32, 32, 16, 1], [16, 16, 32, 1], [16, 16, 64, 1], [32, 32, 32, 1]]
150 validSMFMA["4xi8"] = [[32, 32, 32, 1], [16, 16, 64, 1], [16, 16, 128, 1], [32, 32, 64, 1]]
151 validSMFMA["I8"] = validSMFMA["4xi8"]
152 validSMFMA["F8"] = [[32, 32, 32, 1], [16, 16, 64, 1], [16, 16, 128, 1], [32, 32, 64, 1]]
153 validSMFMA["B8"] = validSMFMA["F8"]
154 validSMFMA["F8B8"] = validSMFMA["F8"]
155 validSMFMA["B8F8"] = validSMFMA["F8"]
156 validSMFMA["F8N"] = validSMFMA["F8"]
157 validSMFMA["B8N"] = validSMFMA["F8"]
158 validSMFMA["F8B8N"] = validSMFMA["F8N"]
159 validSMFMA["B8F8N"] = validSMFMA["F8N"]
160 validSMFMA["_format9"] = []
161 for SMFMA in [validSMFMA["H"], validSMFMA["B"], validSMFMA["4xi8"], validSMFMA["F8N"]]:
162 for MI in SMFMA:
163 for bm in range(int(math.log(MI[3], 2)) + 1):
164 for tt0 in range(1, validTT + 1):
165 for tt1 in range(1, validTT + 1):
166 for wave_m in range(3):
167 for wave_n in range(3):
168 validSMFMA["_format9"].append(
169 [MI[0], MI[1], MI[2], MI[3], 2**bm, tt0, tt1, 2**wave_m, 2**wave_n]
170 )
171 return validSMFMA
172
173 @lru_cache
174 def makeValidMatrixInstructions():
175 mfma = makeValidMFMA()
176 smfma = makeValidSMFMA()
177 validMatrixInstructions = (
178 [[], [-1]]
179 + mfma["H"]
180 + mfma["S"]
181 + mfma["B"]
182 + mfma["D"]
183 + mfma["B1k"]
184 + mfma["X"]
185 + smfma["H"]
186 + smfma["B"]
187 + smfma["4xi8"]
188 )
189 return validMatrixInstructions + mfma["_format9"] + smfma["_format9"]
190
191
192 validParameters = { # we need to make sure this matches develop
193 # 0: Global read is along parallel direction in thread level,
194 # each load instruction stride whole threads.
195 # ----> perp
196 # | [w0, w0, w1,w1,w2,w2,w3,w3, w0, w0, w1,w1,w2,w2,w3,w3]
197 # | [ t0,t32] [ ] [ t0,t32] [ ]
198 # para | [ t1,t33] [ wave 1,2,3 ] [ t1,t33] [ wave 1,2,3 ]
199 # | [ .., ..] [ ] [ .., ..] [ ]
200 # | [t31,t63] [ ] [t31,t63] [ ]
201 # V [-load_1] [-load_2]
202 #
203 # 1: Each wave load a block of memory,
204 # each load instruction stride 64 threads.
205 # ----> perp
206 # [ w0, w0, w0, w0, w1,w1,w1,w1, w2,w2,w2,w2, w3,w3,w3,w3]
207 # | [ t0,t32][ t0,t32]
208 # para | [ t1,t33][ t1,t33]
209 # | [ .., ..][ .., ..]
210 # | [t31,t63][t31,t63]
211 # V [-load_1][-load_2]
212 #
213 #
214 # 2: Each load instruction spread threads evenly in the perp direction
215 # ----> perp
216 # | [w0, w1, w2, w3, w0, w1, w2, w3, w0, w1, w2, w3, w0, w1, w2, w3]
217 # | [t0 ] [t0 ] [t32] [t32]
218 # para | [t1 ] [t1 ] [t33] [t33]
219 # | [.. ] [.. ] [.. ] [.. ]
220 # | [t31] [t31] [t63] [t63]
221 # V [load_1] [load_2] [load_1] [load_2]
222 #
223 "WaveSeparateGlobalReadA": [0, 1, 2],
224 "WaveSeparateGlobalReadB": [0, 1, 2],
225 # Add an unrolled loop and NGLL loop with swapped GRA and GRB order.
226 # which may change the tlb thrashing behavior.
227 "UnrollLoopSwapGlobalReadOrder": [0, 1],
228 # PrefetchGlobalRead = 1:
229 # Requires 2X LDS space, and VGPRs for buffering data on way into LDS
230 # prefetch / double-buffer reads from global memory -> vgprs -> lds.
231 #
232 # PrefetchGlobalRead = 2:
233 # Do another prefetch while writing data from vgpr to lds.
234 # prefetch / double-buffer reads from global memory -> vgprs --> lds.
235 # |-> prefetch reads
236 "PrefetchGlobalRead": [0, 1, 2],
237 # number of iteration prefetch local reads from lds to VGPRs buffer = PLR
238 "PrefetchLocalRead": list(range(128 + 1)),
239 # MatrixInstruction Only
240 # If set ClusterLocalRead, each iteration dedicated vgprBuffer for localRead
241 # So we can schedule these localReads to the front of the loop
242 "ClusterLocalRead": [0, 1],
243 # We use double LDS buffer when PrefetchGlobalRead.
244 # While it reads data from LDS[0]/[1], it prefetch global data and writes to LDS[1]/[0]
245 # If we can make sure all data are read from LDS to register before writing data to LDS, we can use 1 LDS buffer to save LDS memory.
246 # this can help to generate Kernel that LDS usage originally exceed MaxLDS if using double LDS buffer,
247 # or help to increase Occupancy.
248 # 1 means: Force to use 1 LDS Buffer even with PrefetchGlobalRead
249 # -1 means: generator will use 1 LDS buffer only when LDS exceed MaxLDS
250 # Use case:
251 # SIA2: 1LDSBuffer is set to 1 natively
252 # SIA3: 1LDSBuffer works only when PGR=True
253 # TODO: optimize scheduling to support more cases.
254 "1LDSBuffer": [-1, 0, 1],
255 # Split the unroll summation into multiple sections and combine the sections
256 # GSU applies only to the unroll summation dimension
257 # Set to 0 to disable GSU, kernel code will be generated without GSU support
258 # Set to -1 to choose GSU automatically in runtime, determined by function calculateAutoGSU
259 "GlobalSplitU": list(range(-1, 1024 + 1)),
260 # choose how to do GlobalSplitU
261 # 1: use atomic operation to accumulate on one buffer
262 # 2: each GSU group write to each own buffer and accumulate by another kernel
263 # 3: each GSU group write to each own buffer and accumulate by same kernel
264 "GlobalSplitUAlgorithm": ["SingleBuffer", "MultipleBuffer", "MultipleBufferSingleKernel"],
265 # don't create a whole copy of the Unroll loop with loads removed - instead
266 # use buffer limits to suppress global loads and ignore unnecessary ds_reads
267 "SuppressNoLoadLoop": [False, True],
268 # For PrefetchGlobalRead=1, create a second copy of the unroll loop with
269 # the LDS pointer swaps expanded into inline constants for LDS read and write instructions
270 # This eliminates 4 vector XOR instructions used for pointer swap
271 "ExpandPointerSwap": [False, True],
272 # Schedule global reads and global read increments into LocalRead iterations
273 # Can reduce pressure on local read instruction dispatch queue
274 # 0=perform global reads at start of instruction loop
275 # 1=schedule into the local read instruction iterations
276 "ScheduleGlobalRead": [0, 1],
277 # Schedule local writes into LocalRead iterations.
278 # Can reduce pressure on local read instruction dispatch queue
279 "ScheduleLocalWrite": [0, 1],
280 # Scheduling algorithm to use for each iteration:
281 # 0 = minimal/no scheduling. Global Read and increments, followed by local reads,
282 # followed by local writes, followed by MACs
283 "ScheduleIterAlg": [0, 1, 2, 3],
284 # For MatrixInstruction and SIA3, number of GlobalReadInstruction between mfma
285 # the purpose of this parameter is to control density of global read instruction scheduling
286 # Scheduling global read back to back can have better memory efficiency
287 # However, when full of vmem FIFO, it will block other instruction to be issued
288 # Range from 0.01 to 32
289 # 0.1 means 1 GR per 10 mfma
290 # 5 means 5 GR per 1 mfma
291 "GlobalReadPerMfma": [i / 100 for i in range(1, 3200)],
292 #
293 # For MatrixInstruction and SIA3, number of LocalWriteInstruction between mfma
294 # the purpose of this parameter is to control density of local write instruction scheduling
295 # In PGR1, we want to schedule local write more denser, so we can have more
296 # latency to hide global read
297 # In PGR2, since LW is followed by GR, every LW has same whole loop latency
298 # to hide global read. We want to schedule LW less denser, can
299 # avoid full of vmem FIFO.
300 # Range from 0.01 to 32
301 # 0.1 means 1 LW per 10 mfma
302 # 5 means 5 LW per 1 mfma
303 # -1 will derived an optimized value internally
304 # -2 will derived an optimized value and override LWPM silently (debug only, not recommended)
305 "LocalWritePerMfma": [i / 100 for i in range(1, 3200)] + [-1],
306 # Interleave alpha scale calculation with beta loads and address calcs - rather
307 # than as a separate block of instructions
308 "InterleaveAlpha": [0, 1],
309 # Create a copy of NoLoadLoop which interleaves the stores with the final mac
310 # calculation and may perform other optimizations
311 # 0 = no interleave
312 # 1 = interleave one stores after required macs have completed execution
313 # 2 = interleave two stores after required macs have completed execution
314 "OptNoLoadLoop": [0, 1, 2],
315 "BufferLoad": [False, True],
316 "BufferStore": [False, True],
317 # Attempt to load directly from global memory into Vgpr.
318 # Assembly only
319 "DirectToVgprA": [False, True],
320 "DirectToVgprB": [False, True],
321 "DirectToVgprSparseMetadata": [False, True],
322 # Attempt to load directly from global memory into LDS.
323 # Assembly only
324 # Requires BufferLoad, assembler support for lds modifier on buffer
325 # loads (checked automatically), GlobalVectorWidth=1 (this is hw
326 # requirement) and A/B must not require any transpose.
327 # DirectToLds reduces load latency and eliminates the
328 # G2L registers used to stage data. Also replaces the
329 # local write offset with an SGPR.
330 # For an 8x8 TT with PrefetchGlobalRead=1 this can save 33 VGPRs.
331 # - Requirements for DirectToLds=1:
332 # GlobalReadVectorWidth = 1/2/4 (GRVW * bpe must be 4 for now)
333 # TransposeLDS = 1 for TLU=0 case
334 # DirectToLds support for x1 only for now
335 "DirectToLds": [False, True],
336 # Load options:
337 # (GRO = Global Read Offset)
338 # BufferLoad=0:
339 # = Use flat instructions with 64 bit GRO for each load
340 # + supports sizes up to 2^64
341 # - uses many VGPR for addressing
342 # - uses execmask+compares for edge detection
343 # - generates extra LDS traffic (could convert flat->global load)
344 # BufferLoad=1:
345 # = Use buffer load instructions with 32-bit offset
346 # + Less VGPRS (32b offset vs 64-bit) needed for addressing
347 # + Uses hardware buffer limit for edge detection
348 # - Limited range - the bot-right corner of macro-tile (plus padding=GRVW
349 # for shift-pointer, if ShiftPtr is required) must be within 2^32.
350 # ShiftPtrPad = MayShift ? GRWV*BPE : 0
351 # For TLU=1: Unroll*StrideA1 + ShiftPtrPad <= 2^32
352 # For TLU=0: MT*StrideA1 + ShiftPtrPad <= 2^32
353 # These conditions should be checked using Assert - TODO
354 # = UseSgprForGRO=1:
355 # + Attempt to use SGPR for Global Read Offsets.
356 # + Use one VGPR base GRO + many SGPR GRO rather than many VGPR GRO.
357 # + Each SGPR stores an offset from base GlobalReadOffset+0.
358 # - Requirements for UseSgprForGRO=1:
359 # - BufferLoad=1
360 # - Use appropriate Assert*ElementMultiple or GRVW=1 to eliminate need for ShifPtr
361 # (UseSgprForGRO does not support ShiftPtr since ShiftPtr needs to potentially shift GRO)
362 # = KernelWriterAssembly also supports 64-bit 2D buffer size (see use64bPbcLimit)
363 # - Requires 4 instructions to move scalar limit and a couple SGPR
364 # - Enabled by default. If the overhead matters we can add asserts/YAML parm to specialize
365 # = UseInstOffsetForGRO=1:
366 # + Attempt to use Instruction offset for Global Read Offsets.
367 # + This feature avoid updating m0 for subsequent GRO(s) for directToLds feature
368 # - Requirements for UseInstOffsetForGRO=1:
369 # - BufferLoad=1
370 # - DirectToLds=1
371 # converting m0 update from LocalWriteAddrSGpr using is usually win
372 # -1 attempt to use a heuristic to determine when the tile size will use too many SGPR and fall back to VGPR
373 "UseInstOffsetForGRO": [-1, 0, 1],
374 # Converting VGPR GRO into SGPR GRO is usually a win
375 # However, the mode may exhaust all available SGPR, in particular for large unroll
376 # -1 attempt to use a heuristic to determine when the tile size will use too many SGPR and fall back to VGPR
377 "UseSgprForGRO": [-1, 0, 1],
378 # Use a 64-bit shadow limit register to allow buffers larger than 2^32 bytes
379 "Use64bShadowLimit": [True, False],
380 # Assertion properties
381 # These provide information or assertions that the problem size meets certain requirements
382 # for sizes or alignments. The kernel generator can use this information to produce
383 # a kernel which uses those assertions to produce a faster kernel.
384 #
385 # If modifying or adding Assertions also change ProblemProperties class in TensileTypes.h
386 # Kernel generator will assume that the summation size is some multiple of the element size
387 # and uses this to optimize the kernel.
388 # This can result in more efficient kernels, but requires runtime checking to ensure the specified
389 # summation value meets the requirements.
390 # (Recommended AF1EM value is 8 for half, 4 for single, 2 for double)
391 #
392 # Optimizations enabled by AssertSummationElementMultiple>1:
393 # - If >=2 for half:
394 # - Tail loop loads can be vectorized 2X to use dword
395 # - Enables asm kernels on V20
396 # - Can use DirectToLds for both unroll and tail loops
397 # - Tail loop can be unrolled up to InnerUnroll amount if AssertSummationElementMultiple%InnerUnroll==0
398 #
399 # 1 indicates no assertion (since all sizes are multiples of 1)
400 "AssertSummationElementMultiple": [1, 2, 4, 8, 16, 32, 64, 128],
401 # Kernel generator will assume that the FreeIndex[0] size is some multiple of the element size
402 # and uses this to optimize the kernel.
403 # FreeIndex[0] is usually letter "I"
404 # (Recommended AF0EM value is 8 for half, 4 for single, 2 for double)
405 #
406 # Optimizations enabled by AssertFree0ElementMultiple>1:
407 # Load optimizations:
408 # - For TLU=1 matrix, if AF1WM>=GLVW then can enable UseSgprForGRO
409 # - Reduces registers used for address calculations
410 # - Removes address shift/unshift code
411 # - UseSgprForGRO will only be enabled if all matrices meet assertion requirements.
412 #
413 # Store Optimizations:
414 # - Can vectorize stores in edge tiles. Vector width can be up to AF0EM.
415 # (since C matrix is always coalesced in Free0 index direction and this assertion guarantees the index element multiple)
416 #
417 # 1 indicates no assertion (since all sizes are multiples of 1)
418 "AssertFree0ElementMultiple": [1, 2, 4, 8, 16],
419 # Kernel generator will assume that the FreeIndex[1] size is some multiple of the element size
420 # and uses this to optimize the kernel.
421 # FreeIndex[1] is usually letter "J"
422 # (Recommended AF1EM value is 8 for half, 4 for single, 2 for double)
423 # Optimizations enabled by AssertFree1ElementMultiple>1:
424 # - See above AssertFree0ElementMultiple "Load optimizations"
425 # 1 indicates no assertion (since all sizes are multiples of 1)
426 "AssertFree1ElementMultiple": [1, 2, 4, 8, 16],
427 # Assertions that require arithmetic intensity to be specified value.
428 # Arithmetic intensity measures the ratio of computation to memory bandwidth required for a problem.
429 # These predicates can be used to adjust solution selection compute-bound or memory-bound problems.
430 "AssertAIGreaterThanEqual": -1,
431 "AssertAILessThanEqual": -1,
432 # Stagger the start summation position of the tiles.
433 # Elements from the summation dimension are loaded at offsets rather than all starting at 0.
434 # StaggerU is the max 'clicks' of StaggerUStride bytes where each wg starts ; see StaggerUMapping
435 # for how the specific stagger for a given wg is determined.
436 #
437 # The tile assignment C are same as with StaggerOffset=0 ; the difference is the
438 # order that the summation elements are added.
439 # GRO will wrap back to the row start when the edge is reached.
440 #
441 # This can be effective for TLU=0 style matrices where the K dimension is a large power-of-2.
442 # In this case the start of each row of the tile is separated by an exact power-of-2
443 # which causes poor dram, cache, and tlb behavior. V20 has 16 channels each 256 bytes wide.
444 # StaggerU adjusts the start position in the summation (aka 'U') dimension
445 # to avoid these conflicts. Both A and B matrix start at the adjusted position.
446 # If >0 specifies the offset in multiples of the macro-tile "unroll" dim
447 # - Higher values will spread traffic to more channels but provide less L2 re-use.
448 # - StaggerU and WorkGroupMapping interact and should be tuned together -
449 # The WGM controls how tiles are assigned in C matrix, while StaggerU controls where those
450 # tiles start reading their summation dim parms.
451 # - StaggerU requires BufferLoad==1 and is silently ignored if BufferLoad==0
452 "StaggerU": [0, 2, 4, 8, 16, 32, 64],
453 # Stride in bytes for each staggeru 'click'.
454 # 256 is recommended since this is the width of memory channel (on gfx803,gfx900,gf906) - so
455 # each click will start in a new memory channel and spread traffic among the 16 available channels.
456 # For example StaggerUStride=256 and StaggerU=8 will use 8 unique starting points
457 # in summation dimension, each offset by 256-bytes - provided the tensor dims are large
458 # enough to support this.
459 # StaggerUStride will be internally increased so it is an integer multiple of DepthU*BpeAB.
460 # (the implementation requires this - the unroll iteration accesses data in steps of
461 # DepthU*BPE
462 "StaggerUStride": [-1, 16, 32, 64, 128, 256, 512, 1024, 2048],
463 # How the tile assignment (wg0, wg1, wg2) controls the initial StaggerU offset:
464 # 0: Use wg0
465 # 1: Use wg1
466 # 2: Use wg2
467 # 3: Use wgSerial, wgSerial = wg0 + wg1 * nwg0 + wg2 * (nwg0 * nwg1)
468 # 4: Debug mode, offset each tile max allowed StaggerU. This just moves hotspot
469 # to a different bank since all workgroups still start at same point.
470 "StaggerUMapping": [0, 1, 2, 3, 4],
471 # GSU Workgroup Coalesced Ordering
472 # False: {(wg0,wg1,wg2,wgn)|(wg0,wg1,wg2,wgn)|...|(wg0,wg1,wg2,wgn)}
473 # True: {(wg0,wg0,wg0)|(wg1,wg1,wg1)|(wg2,wg2,wg2)|...|(wgn,wgn,wgn)}
474 "GlobalSplitUCoalesced": [False, True],
475 # GSU Workgroup Mapping
476 # False: wg issued order = {(wg0,wg1,wg2,wgn),(wg0,wg1,wg2,wgn)|...|(wg0,wg1,wg2,wgn)}
477 # -> workgroups do the summation by tile -> slower GR but faster GW
478 # True: wg issused oder = {(wg0,wg0,wg0)|(wg1,wg1,wg1)|(wg2,wg2,wg2)|...|(wgn,wgn,wgn)}
479 # -> workgroups split up the summation -> faster GR but slower GW
480 "GlobalSplitUWorkGroupMappingRoundRobin": [False, True],
481 # 0=don't use magic div (source only)
482 # 1=magic div alg #1. Slightly faster but limited range (if magic number is 2^32)
483 # 2=magic div alg#2. Slightly slower but handles all unsigned ints up to 2^32
484 "MagicDivAlg": [0, 1, 2],
485 # For Block Mapping type:
486 # 0 : Use hardware-assigned wg number with no remapping.
487 # N : WG block width. "Wrap" to a new wg1 "row" assignment after N WGs assigned in that row.
488 # Tensor C always mapped with first free coord as fastest moving
489 # (Elements in this dimension are sequential in memory.
490 #
491 # For 2D nonbatched Matrix this means index order is I, then J
492 # For 2D batched Matrix this means index order is I, then J, then K.
493 #
494 # Then for 2D case:
495 # - If drawn in row-major format, I is the width and J is the height.
496 # - WGM determines dimensions of the box used to assign tiles from C
497 # - WGM is the height of the box (in the J dimension)
498 # - Given WGM, the box width (in I dim) is determined by number of CUs
499 # - The box always moves across matrixC in the fastest-moving "I" dim, then
500 # wraps to next J. TODO - might be useful to change this?
501 #
502 # Examples for 2D matrix:
503 # WGM=8: on CU64 machine this is a square box
504 # WGM=1: Short/Fat - this will cover maximum width in I dimension of C. This matches hardware assigned mapping.
505 # WGM=64: Tall/Skinny - this will cover maximum width in J dimension of C.
506 #
507 # Formula for wgSerial:
508 # wgSerial = wg0 + (wg1 % WorkGroupMapping) * nwg0
509 "WorkGroupMapping": list(
510 range(-1024, 1024 + 1)
511 ), # change a workgroup's id so that the all the workgroups on the gpu at a time are hitting L2 cache the best
512 "WorkGroupMappingXCC": [
513 1,
514 2,
515 4,
516 8,
517 16,
518 32,
519 ], # change a workgroup's id so that contiguous workgroup can map on same XCC
520 # -1 : WorkGroupMappingXCCGroup will be set to CU_count at runtime. Please ensure that (CU_count % WGMXCC == 0).
521 "WorkGroupMappingXCCGroup": list(
522 range(-1, 1024)
523 ), # change a workgroup's id so that contiguous workgroup can map on same XCC, remap workgroup in a group of WGMXCCG.
524 "MaxOccupancy": list(
525 range(1, 40 + 1)
526 ), # wg / CU; if cache thrashing is hurting performance, this allocates extra lds to artificially limit occupancy
527 "MaxLDS": [-1, 65536, 163840],
528 "WorkGroup": makeValidWorkGroups(), # ( wg0 x wg1 x LocalSplitU ) dimensions of the workgroup which will operate on a tile and share lds
529 # ThreadTile: ( tt0 x tt1 ) dimensions of the C tile that each thread works on,
530 # TT=4 and VW=4 means a thread will work on a tight 4x4 tile of C, where VW=1 means the tile will work on 16 spread out values
531 # Generally, the VW determines the consecutive a WI will work on, then it will skip ahead SG0*VW elements to get to the next row of VGPR inputs
532 "ThreadTile": validThreadTiles,
533 "MacroTile": validMacroTiles, # MT0 = wg0*tt0, MT1 = wg1*tt1
534 "WavefrontSize": [32, 64],
535 # MatrixInstruction: (M x N x K x B)
536 # XDLOPS tile definition, only valid for gfx908, gfx90a
537 # MxNxKxB specifies matrix instruction variants
538 # MxNxB determines the shape of the C tile each instruction worked on
539 # K determines the unroll depth
540 # If empty, do not use these instructions
541 #
542 # Alternative format: (M x N x K x B x MIBlockM x WaveTileM x WaveTileN x WaveM x WaveN)
543 # (Note: MxN means M-by-N in the following comments)
544 # MIBlockM determines how many blocks along M dimension for multi-block MI variants. Concrete examples:
545 # - MI 16x16x1x4 (4-block variant) with MIBlockM=4 -> (16x16)*(4x1)=64x16 tile per instruction executed
546 # - MI 32x32x1x2 (2-block variant) with MIBlockM=1 -> (32x32)*(1x2)=32x64 tile per instruction executed
547 # WaveTileM/N are dimensions of the C tile each wave works on, and is close to the concept of ThreadTile in classic VALU kernels
548 # - WT 4x1 -> each wave executes 4x1 matrix instructions on the C tile of total area (4*MITileM)x(1*MITileN)
549 # WaveM/N are dimensions of waves spawned for one workgroup where each wave consists of 64 threads
550 # - Wave2x2 -> a total of 4 waves in one workgroup of shape 2x2
551 # Putting it all together:
552 # - [32, 32, 1, 2, 1, 4, 1, 2, 2]
553 # ^^^^^^^^^^^^ ^ ^^^^ ^^^^
554 # MatrixInst BlkM WT Wave
555 # - means (32x64) per MI * (4x1) per wave * (2x2) per workgroup = (32*4*2)x(64*1*2) = 256x128 macro tile
556 # Tensile will ignore the parameters ThreadTile and WorkGroup when the alternative format is used
557 # NOTE: MatrixInstruction is no longer validated through this structure, but is instead validated via the
558 # ``TensileLogic`` program.
559 "MatrixInstruction": -1,
560 # StoreRemap: Optimize MatrixInstruction store patterns to enhance performance.
561 # MI output data between each threads are along N dims.
562 # But global memory is along M dim continuous.
563 # That mean global write between each threads are not continuous.
564 # Therefore, store performance for MI instruction is poor.
565 # How StoreRemap works in final store stage:
566 # 1. Put all thread output data into LDS.
567 # 2. All thread read data from LDS along M dims.
568 # (match global Memory continuous direction)
569 # 3. All thread write out data into global memory.
570 # 0: Disable StoreRemap (default)
571 # 1~8: Enable StoreRemap and set the global write vector width
572 # Suggest optimum value: fp32 = [2,4], fp16 or bf16 = [4,8] (dwordx2 and dowrdx4)
573 # -1: Use dwordx2 if support SRVW, or set SRVW to 0
574 "StoreRemapVectorWidth": [-1, 0, 1, 2, 4, 8],
575 # SourceSwap: Optimizes MatrixInstruction store pattern by swapping mfma input order.
576 "SourceSwap": [False, True],
577 # Following parameters are designed for store scheduling.
578 # (store stands for load from C (with beta) and store to C/D)
579 #
580 # we want to hide store behind unroll loop
581 # 1. if we can launch 2 WorkGroups per CU (occupancy >= 2, large M/N)
582 # 2. if there are remaining global memory bandwidth in unroll loop (compute bound kernel)
583 #
584 # we can hide store behind the other WG's loop by lowering priority of store
585 # priority of loop is the same as priority of store
586 # WG0: ???????????????\__
587 # |<-- loop --->|<-- store -->|end
588 #
589 # WG1: ___________________________/????????????\__
590 # |<--------- loop ------------------->|<-- store -->|end
591 #
592 # priority of loop is higher than priority of store
593 # WG0: ???????\____________________
594 # |<-- loop --->|<------ store ----->|end
595 #
596 # WG1: _____________/?????\__________________
597 # |<------- loop -------->|<----- store ---->|end
598 "StorePriorityOpt": [False, True],
599 #
600 # If we issue store in short period of time, kernel will become from compute bound to memory bound
601 # 0 means issue instructions as many as possible if VGPR available
602 "NumElementsPerBatchStore": list(range(-1, 256)),
603 #
604 # add sync after per batch store in order to store contiguous elements
605 # add sleep after per batch store in order to distribute store over whole loops
606 # NOTE: this parameter is highly depends on size_k
607 # 0 means no sync and sleep
608 "StoreSyncOpt": list(range(0, 256)),
609 #
610 # There are index or address calculation between global instructions.
611 # issue global instruction b2b has better performance
612 "GroupLoadStore": [False, True],
613 # In order to remove the copying from Acc vgpr to Arch vgpr, only use Arch vgprs for v_mfma_xxx.
614 # Only support for kernel whose totalVgpr counts less than 256 and gcn that has control bit ACC_CD.
615 "MIArchVgpr": [False, True],
616 # StreamK (SK) kernels divide work evenly among CUs by splitting along MT and K dimensions.
617 # Total work units are calculated as (#MTs x #LoopIters) and divided among workgroups.
618 # In most cases each workgroup will calculate a partial tile that are accumulated in a fixup step in the same kernel
619 # 0 : Standard data-parallel kernel
620 # 1 : Basic StreamK
621 # 2 : Two-Tile StreamK (each WG completes an even number of sk iterations, followed by an even number of dp tiles)
622 # 3 : Two-Tile StreamK with DP before SK tiles
623 # StreamK kernels can adjust the number of CUs being used.
624 # Using fewer sometimes increases overall throughput by allowing other kernels to run in parallel.
625 # StreamK grid is controlled by setting these enviornment variables:
626 # TENSILE_STREAMK_FIXED_GRID lets you override the default grid size with a specific number
627 # 0 = override disabled (default)
628 # TENSILE_STREAMK_FULL_TILES sets the number of full tiles to be included in stream-k work
629 # -1 = use prediction model for best performance (not yet implemented)
630 # 0 = only remainder tiles run in stream-k
631 # 1+ = remainder + 1 (or more) full grids of tiles run in stream-k (default=1)
632 # TENSILE_STREAMK_DYNAMIC_GRID selects dynamic grid mode, which automatically limits the number of CUs used:
633 # 0 = Off, always use all CUs.
634 # 1 = Only reduce CUs for small problems to number of output tiles when num_tiles < CU count.
635 # 2 = Also reduce CUs used for large sizes to improve data-parallel portion and reduce power.
636 # 3 = Analytically predict the best grid-size by weighing the cost of the fix-up step and the cost of processing MACs (default).
637 # Note: dynamic grid coefficients currently apply to gfx942 variants
638 # 4 = StreamK algorithm will behave as data parallel (Launch WGs = #CUs)
639 # 5 = StreamK Algorithm will use Origami's "select_best_grid_size" function
640 # TENSILE_STREAMK_DYNAMIC_WGM Enables Origami's analytical model-based WGM selection
641 # TENSILE_STREAMK_MAX_CUS allows the user to manually set maximum number of CUs used, which could free up some CUs for
642 # other operations to run in parallel with gemm.
643 # TENSILE_STREAMK_GRID_MULTIPLIER lets you set how many workgroups are created per CU being used.
644 # 1 = 1 WG per CU (default), for example. 2 will launch WGs = 2 x CU count.
645 # The priority of these environment variables is defined as follows:
646 # TENSILE_STREAMK_FIXED_GRID > TENSILE_STREAMK_DYNAMIC_GRID > TENSILE_STREAMK_MAX_CUS > TENSILE_STREAMK_GRID_MULTIPLIER
647 "StreamK": [0, 1, 2, 3],
648 # Determines if StreamK kernel uses atomics
649 # 0: uses workspace to store partial tiles, accumulate in deterministic fix-up step
650 # 1: uses atomics to accumulate partial tiles
651 "StreamKAtomic": [0, 1],
652 # Enables XCC-based remapping of workgroups, set the value to the number of XCCs
653 # for the device/configuration being used
654 # 0: uses default workgroup assignment
655 # 2+: remaps workgroups to be contiguous within an XCC for a given number of XCCs
656 "StreamKXCCMapping": [0] + list(range(2, 9)),
657 # Debug settings for stream-k kernels to disable parts of the kernel
658 # Bit 0: Don't generate fixup code
659 # Bit 1: Don't generate write to partials code
660 # Both parts can be disabled together
661 # 0 = Debug mode off, generate full kernel
662 # 1 = No fixup
663 # 2 = No partials
664 # 3 = Nofixup and no partials
665 "DebugStreamK": [0, 1, 2, 3],
666 # Controls desired width (#elements) for loads from global memory -> LDS.
667 # and eliminates the pointer unshift logic
668 # -1 : Set GlobalReadVectorWidth = VectorWidth
669 # NOTE: for input bpe=32, max GRVW is 4 (to fit dwordx4) (FP32), min GRVW is 1 (dword)
670 # bpe=16, max GRVW is 8 (to fit dwordx4) (FP16), min GRVW is 2 (dword)
671 # bpe=8, max GRVW is 16 (to fit dwordx4) (INT8), min GRVW is 4 (dword)
672 "GlobalReadVectorWidthA": [-2, -1, 1, 2, 3, 4, 6, 8, 16],
673 "GlobalReadVectorWidthB": [-2, -1, 1, 2, 3, 4, 6, 8, 16],
674 # Controls desired width (#elements) for loads from LDS -> VGPR.
675 # -1 : Set LocalReadVectorWidth = VectorWidth
676 # 1 cannot be used for half type.
677 # used in combination with TransposeLDS=True
678 # in TransposeLDS=1 case, use wider load to fetch elements in summation dimension from LDS
679 # helps optimizing instruction scheduling between MFMA and nonMFMA instructions
680 # NOTE: for input bpe=32, max LRVW is 4 (to fit ds_read_b128) (FP32)
681 # bpe=16, max LRVW is 8 (to fit ds_read_b128) (FP16)
682 # bpe=8, max LRVW is 16 (to fit ds_read_b128) (INT8)
683 "LocalReadVectorWidth": [-1, 1, 2, 4, 8, 16],
684 # threads should read/write/operate on this many contiguous elements from the C matrix.
685 # If VW=4 then thread0 will process 4 consec C elements, then thread1 next 4, etc.
686 # If the ThreadTile is > VectorWidth then thread0 will next operate on the 4 elements in C at (4*NumThreads)
687 # Typically the load vector width and store vector width are directly related to the VW.
688 # The global load width is closely related to the width of local stores so
689 # GlobalReadVectorWidth also controls local write width.
690 # Local read width also matches since VectorWidth consec elements must be read
691 # Typically matching 16 bytes is good choice since the stores will be optimally coalesced with 16 bytes/WI.
692 # Using a VW too large which results in >16bytes/thread isn't supported
693 # For MFMA non SourceSwap: this parameter didn't take effect
694 # -1 means set vw to largest localReadWidth according to MIWaveTile
695 "VectorWidthA": [-1, 1, 2, 3, 4, 6, 8],
696 "VectorWidthB": [-1, 1, 2, 3, 4, 6, 8],
697 # If 0, store 1 element per instruction.
698 # If 1, store vector-width elements per instruction.
699 # if -1, store vector-wide elements per instruction unless PBD would not generate a valid kernel
700 "VectorStore": [-1, 0, 1],
701 # Controls desired width (#elements) for stores from reg to global memory.
702 # When MatrixInstruciton == None, derived parameter gwvw takes precedence.
703 # -1 : Set StoreVectorWidth = VectorWidth
704 "StoreVectorWidth": [-1, 1, 2, 3, 4, 6, 8],
705 # when loading all the data from global into lds requires multiple load instructions, these parameters govern which
706 # loads will pull which rectangle of data from global into lds
707 # NLC=1 means one load along the coalesced dimension, which results in the most coalescing possible
708 # NLC=-1 looks for the largest number of reads along the coalesced dimension which results in the least ammount of coalescing;
709 # however in this case the stride between one load and another is a static value, therefore buffer loads only need one set of registers
710 # whereas the =1 case has a stride which is a multiple of a kernel argument and therefore needs one address per load in the perpendicular dimension
711 "NumLoadsCoalescedA": list(range(-1, 64 + 1)),
712 "NumLoadsCoalescedB": list(range(-1, 64 + 1)),
713 # DepthU, LocalSplitU (which is the 3rd number in WorkGroup), and LoopUnroll are closely related
714 # LoopUnroll=4 means there are 4 subiterations within the loop, 4 actual iterations written in the code.
715 # LocalSplit=2 means the workgroup is split up into 2 subgroups, and each subgroup is doing different parts of the summation.
716 # subgroup0 does k=0-3, 8-11... and subgroup1 does k=4-7, 12-15...
717 # So, each iteration through the summation loop, which has 4 actual subiterations, does 8 summation iterations, because each subgroup did 4;
718 # and when data is read from global memory the threads read 8 elements along the summation dimension.
719 # DepthU = LoopUnroll * LocalSplitU = 4*2 in this case
720 # it made more sense for the user to directly control LocalSplitU and DepthU, then derrive afterwards LoopUnroll=DepthU/LocalSplitU
721 # -1 : Only allow GLVW=1
722 # -2 : Only allow max(GLVWA,GLVWB) < VW ?
723 # -3 : Only allow min(GLVWA,GLVWB) < VW ?
724 "DepthU": [-1] + list(range(2, 1024 + 1, 1)),
725 # integer amount of padding to put into LDS, in 2016 this didn't seem to help performance, profilers were showing that channel conflicts weren't really hurting
726 # performance so this has been deprecated and probably doesn't work
727 # -1 means use same padding as the VectorWidth if TLU=0 else 0. (Padding only helps when transpose is required)
728 # With MatrixInstruciton: -1 means max(GRVW,MIInput) if TLU=0
729 "LdsPadA": [-1, 0, 1, 2, 3, 4, 8, 16, 32, 48, 64],
730 "LdsPadB": [-1, 0, 1, 2, 3, 4, 8, 16, 32, 48, 64],
731 "LdsPadMetadata": [-1, 0, 1, 2, 3, 4, 8],
732 # Padding boundary for LDS. defines block-size for pad insertion. for every 'LdsBlockSizePerPad' bytes, LDS padding (pad value from LdsPad parameter)
733 # is added (readOffset aware of the pad and adjusts offset value based on this parameter value).
734 # Only support LdsBlockSizePerPad >= unrollDepth * BPE
735 # 0 means disable LdsBlockSizePerPad
736 "LdsBlockSizePerPadA": [-1, 0, 64, 128, 256, 512, 1024, 2048],
737 "LdsBlockSizePerPadB": [-1, 0, 64, 128, 256, 512, 1024, 2048],
738 "LdsBlockSizePerPadMetadata": [-1, 0, 64, 128, 256, 512, 1024, 2048],
739 # Transpose LDS format. Local store in coalesced dimension , same as optimized global fetch dimension . applicable only in TLU=0 case for miSIMD(s)
740 # -1 : keep LDS layout same as global fetch dimension for both A and B
741 # set TLDS = 1 for NN,TN,TT
742 # set TLDS = 0 for NT
743 # 0 : coalesced dimension of lds is tile dimension
744 # 1 : keep LDS layout same as global fetch dimension for both A and B for NN,TN,TT, but NT would be rejected
745 # 2 : coalesced dimension of lds is unroll dimension for both A and B
746 "TransposeLDS": [-1, 1, 0, 2],
747 # add gls or slc after global memory read/writes to change caching, not caching the writes is promising and improved performance a tiny bit
748 # 0: none, 1: glc, 2: slc, 3: glc slc
749 # For gfx942, sets sc0/sc1/nt bits
750 # 0: none, 1: sc0, 2: sc1, 3: sc0 sc1, 4: nt, 5: nt sc0, 6: nt sc1, 7: nt sc0 sc1
751 "NonTemporalE": list(range(0, 8)),
752 "NonTemporalD": list(range(0, 8)),
753 "NonTemporalC": list(range(0, 8)),
754 "NonTemporalA": list(range(0, 8)),
755 "NonTemporalB": list(range(0, 8)),
756 "NonTemporalWS": list(range(0, 8)),
757 "NonTemporalMetadata": list(range(0, 8)),
758 "NonTemporal": list(range(-1, 8)),
759 # Group together unroll iterations inside the unroll loop.
760 # For example, InnerUnroll=2 will fetch LDS for two unroll iterations
761 "InnerUnroll": [1, 2, 4, 8, 16, 32, 64],
762 # Enable CP preload kernel arguments feature
763 # It can reduce time of loading kernel arguments by s_load.
764 # It needs new complier and vbios to support this feature.
765 "PreloadKernArgs": [False, True],
766 # Kernels should be written in assembly or source
767 # if assembly, ISA will determine architecture
768 # if source, Runtime will determine language
769 # later on, we'll relax this to inner kernel languages and outer kernel languages, such as inline asm embedded in ocl or in llvm
770 "KernelLanguage": ["Assembly"],
771 # We set validParams["ISA"] in multiple places
772 "ISA": validISA, # arch for assembly kernels
773 # Name of the custom kernel located at `CUSTOM_KERNEL_PATH`.
774 # a custom kernel is a user written assembly kernel with its associated configuration parameters included in a custom.config section
775 # inside the yaml block between the --- and ... markers. These parameters are only used for information purposes, not kernel generation.
776 # Ex:
777 # custom.config:
778 # ProblemType:
779 # OperationType: GEMM
780 # etc...
781 # ThreadTile: [8, 8]
782 # etc...
783 #
784 # Custom kernels can be included in a BenchmarkProblemSizeGroup by having their name (without file extension) listed under the "CustomKernels"
785 # category alongside InitialSolutionParameters, BenchmarkCommonParameters, etc...
786 "CustomKernelName": -1,
787 # Will allow a kernel to be accepted even when checks determine it's not viable.
788 # Intended for use with custom kernels which have confirmed to be correct
789 "NoReject": [False, True],
790 # Debug use only.
791 "ActivationFused": [True],
792 # True- function call
793 # False- inline
794 "ActivationFuncCall": [False, True],
795 # Alternative implementation for activation function
796 # Currently only supports GSU == 1
797 "ActivationAlt": [False, True],
798 # Do workgroup reduction. Currently for DBias
799 "WorkGroupReduction": [False],
800 # 4:2 Structured Sparse A Matrix, 0=Non Sparse, 1=Sparse Matrix A, 2=Sparse Matrix B
801 "Sparse": [0, 1, 2],
802 # in mix mode F8 need to convert to F16, do this before(0) ds or after(1) ds
803 "ConvertAfterDS": [False, True],
804 # Force disable shadow init to release more sgpr in preloop
805 "ForceDisableShadowInit": [False, True],
806 # Enable LDS Transpose Instruction
807 "LDSTrInst": [False, True],
808 # False: Use LocalSplitU. Number of WorkGroup[2] WorkItems (wave or thread) will compute the same output elements (matrix D) along different
809 # unroll indices. The local sum from those WorkItems are reduced through LDS.
810 # True: Use WaveSplitK. Number of WorkGroup[2] threads in the same wave compute the same output elements (matrix D) along different unroll indices.
811 # The local sum from those threads are reduced through suffling using VALU instructions. Currently only support dot2 kernel.
812 "WaveSplitK": [False, True],
813 # Control mbsk reduction prefetch order
814 # -1 : Select between 0/1 based on # store elements.
815 # 0 : Fetch from workgroup dim -> elements dim. (default)
816 # 1 : Fetch from elements dim -> workgroup dim. Has better prefetch pattern when # store elements is large.
817 "MbskPrefetchMethod": [-1, 0, 1],
818 "UseCustomMainLoopSchedule" : [0, 1]
819 }
820
821 newMIValidParameters = {
822 "EnableF32XdlMathOp": [False, True],
823 "UseF32XEmulation": [False, True],
824 'EnableMatrixInstruction': [False, True],
825 'ISA': -1,
826 'MFMA_BF16_1K': [False, True],
827 'MIBlock': -1,
828 'MIInputPerThread': -1,
829 'MIInputPerThreadA': -1,
830 'MIInputPerThreadB': -1,
831 'MIInputPerThreadMetadata': -1,
832 'MIWaveGroup': -1,
833 'MIWaveTile': -1,
834 'MatrixInstM': -1,
835 'MatrixInstN': -1,
836 'MatrixInstK': -1,
837 'MatrixInstB': -1,
838 'MatrixInstBM': -1,
839 'MatrixInstBN': -1,
840 'MatrixInstruction': -1,
841 'Sparse': -1,
842 'ThreadTile': -1,
843 'WavefrontSize': -1,
844 'WorkGroup': -1,
845 }
846
847
848 def checkParametersAreValid(param, validParams):
849 """Ensures paramaters in params exist and have valid values as specified by validParames"""
850 (name, values) = param
851 if name == "ProblemSizes":
852 return
853 elif name == "InternalSupportParams":
854 return
855
856 if name not in validParams:
857 raise Exception(
858 "Invalid parameter name: {}\nValid parameters are {}.".format(
859 name, sorted(validParameters.keys())
860 )
861 )
862
863 for value in values:
864 if validParams[name] != -1 and value not in validParams[name]:
865 msgBase = "Invalid parameter value: {} = {}\nValid values for {} are {}{}."
866 msgExt = (
867 " (only first 32 combos printed)\nRefer to Common.py for more info"
868 if len(validParams[name]) > 32
869 else ""
870 )
871 raise Exception(msgBase.format(name, value, name, validParams[name][:32], msgExt))