Skip to content

Commit 063261e

Browse files
committed
cleaning
Signed-off-by: Aurore De Spirlet <aurore.despirlet@amd.com>
1 parent 2381ce9 commit 063261e

3 files changed

Lines changed: 11 additions & 54 deletions

File tree

examples/python/7.1_schedule.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,9 @@ def test_dbuf_8wave_pingpong_mxfp_gemm_Bshuffle_lds(
216216
)
217217
options.specialize = True
218218
options.use_buffer_ops = True
219-
options.minimize_shared_allocs = True
219+
options.minimize_shared_allocs = False
220220
options.linearize_shared_access = True
221+
options.wave_runtime = True
221222

222223
if dynamic:
223224
options.dynamic_symbols = [tkl.sym.M, tkl.sym.N, tkl.sym.K]

wave_lang/kernel/wave/compile.py

Lines changed: 6 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,6 @@ def build_graph_passes(
520520
partial(partition_ops_with_gpr_offsets, trace, launchable.constraints),
521521
partial(partition_strided_operators, trace, launchable.constraints),
522522
partial(remove_chained_extractslice, trace),
523-
# Run an early coalescing pass so scheduling (including manual schedules)
524-
# can reason about merged read widths/counts instead of only pre-merge reads.
525523
partial(
526524
merge_contiguous_reads,
527525
trace,
@@ -1295,7 +1293,9 @@ def _generate_asm_code(mb, options):
12951293
mlir_path = mlir_file.name
12961294

12971295
try:
1298-
base_passes = [
1296+
cmd = [
1297+
waveasm_translate,
1298+
f"--target={options.target}",
12991299
"--mlir-cse",
13001300
"--waveasm-scoped-cse",
13011301
"--waveasm-peephole",
@@ -1306,63 +1306,17 @@ def _generate_asm_code(mb, options):
13061306
"--waveasm-memory-offset-opt",
13071307
"--canonicalize",
13081308
"--waveasm-scoped-cse",
1309-
]
1310-
# (2,2) wave shapes generate extract_strided_slice -> V_BFE_U32
1311-
# for scale extraction, creating load->VALU data hazards that
1312-
# require ticketed waitcnt. (1,4) shapes use scalesIdxA on the
1313-
# MFMA directly and don't hit this path.
1314-
# (1,4): wg=(64,4,1) == waves_in_m=1, waves_in_n=4 == off
1315-
# (2,2): wg=(128,2,1) == waves_in_m=2, waves_in_n=2 == on
1316-
# (4,1): wg=(256,1,1) == waves_in_m=4, waves_in_n=1 == off
1317-
threads_per_wave = 64
1318-
waves_in_m = wg[0] // threads_per_wave
1319-
waves_in_n = wg[1]
1320-
# TODO: improve Ticketing logic (better latency-covering heuristics,
1321-
# smarter coalescing) so ticketed waitcnt can be always-on without
1322-
# a performance hit, removing this wave-shape conditional.
1323-
use_ticketed_waitcnt = waves_in_m >= 2 and waves_in_n >= 2
1324-
waitcnt_flag = (
1325-
"--waveasm-insert-waitcnt"
1326-
if use_ticketed_waitcnt
1327-
else "--waveasm-insert-waitcnt=ticketed-waitcnt=false"
1328-
)
1329-
tail_passes = [
1309+
"--waveasm-loop-address-promotion",
13301310
"--waveasm-linear-scan=max-vgprs=512 max-agprs=512",
1331-
waitcnt_flag,
1311+
"--waveasm-insert-waitcnt=ticketed-waitcnt=false",
13321312
f"--waveasm-hazard-mitigation=target={options.target}",
13331313
"--emit-assembly",
13341314
f"--workgroup-size-x={wg[0]}",
13351315
f"--workgroup-size-y={wg[1]}",
13361316
f"--workgroup-size-z={wg[2]}",
13371317
mlir_path,
13381318
]
1339-
1340-
def _run_translate(extra_passes):
1341-
full_cmd = (
1342-
[waveasm_translate, f"--target={options.target}"]
1343-
+ base_passes
1344-
+ extra_passes
1345-
+ tail_passes
1346-
)
1347-
return subprocess.run(full_cmd, capture_output=True, text=True, timeout=60)
1348-
1349-
import re
1350-
1351-
HW_VGPR_LIMIT = 256
1352-
1353-
# loop-address-promotion converts per-iteration LDS address
1354-
# arithmetic (V_ADD_U32) into precomputed rotating VGPR iter-args,
1355-
# removing VALU ops from the critical path. The trade-off is extra
1356-
# live VGPRs for the promoted addresses. For large block sizes
1357-
# (e.g. 256x160x256, 256x192x256) this can push the VGPR count
1358-
# past the gfx9 hardware limit of 256. We try with the pass
1359-
# first and fall back without it when the limit is exceeded.
1360-
result = _run_translate(["--waveasm-loop-address-promotion"])
1361-
if result.returncode == 0:
1362-
m = re.search(r"\.vgpr_count:\s*(\d+)", result.stdout)
1363-
if m and int(m.group(1)) > HW_VGPR_LIMIT:
1364-
result = _run_translate([])
1365-
1319+
result = subprocess.run(cmd, capture_output=True, text=True, timeout=60)
13661320
if result.returncode != 0:
13671321
raise RuntimeError(f"waveasm-translate failed:\n{result.stderr}")
13681322
asm_text = result.stdout

wave_lang/kernel/wave/schedules/gemm_mxfp4_double_buffer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1591,7 +1591,9 @@ def mxfp4_dbuf_schedule():
15911591
return mxfp4_dbuf_schedule
15921592

15931593

1594-
def get_mxfp4_asymmetric_schedule(is_bscale_shuffled: bool = False):
1594+
def get_mxfp4_asymmetric_schedule(
1595+
eliminate_epilogue: bool = False, is_bscale_shuffled: bool = False
1596+
):
15951597
"""Return an asymmetric-prefetch MXFP4 schedule for wave_compile().
15961598
15971599
Asymmetric data paths:

0 commit comments

Comments
 (0)