Skip to content

Commit 5578ec6

Browse files
authored
fix(hipblaslt): skip gfx1250 subtile codegen tests on other archs (#8893)
ISSUE ID : AIHPBLAS-3658 ## Motivation Address test failures on gfx950 ``` FAILED Tensile/Tests/unit/test_subtile_gfx1250_codegen.py::TestGfx1250SubtileCodegen::test_gr_ptr_updates_tdm[A] - AssertionError: assert 's_add_u64' in '/* TDM addr update: A += 128 */\ns_add_u32 s[sgprAddressA], s[sgprAddressA], 128\n\ns_addc_u32 s[sgprAddressA+1], s[sgprAddressA+1], 128\ns_mov_b64 s[sgprtdmAGroup0+2:sgprtdmAGroup0+2+1], s[sgprAddressA:sgprAddressA+1] // sync ... FAILED Tensile/Tests/unit/test_subtile_gfx1250_codegen.py::TestGfx1250SubtileCodegen::test_gr_ptr_updates_tdm[B] - AssertionError: assert 's_add_u64' in '/* TDM addr update: B += 128 */\ns_add_u32 s[sgprAddressB], s[sgprAddressB], 128\n\ns_addc_u32 s[sgprAddressB+1], s[sgprAddressB+1], 128\ns_mov_b64 s[sgprtdmBGroup0+2:sgprtdmBGroup0+2+1], s[sgprAddressB:sgprAddressB+1] // sync ... ``` ## Technical Details Rocisa emits two u32 instructions on gfx950 and a single u64 on gfx1250. Use pytestmark skipif + a module-scoped fixture to pin rocisa to gfx1250, matching the pattern in test_emitMfmaInstruction.py. On machines with an older amdclang++ that does not know gfx1250, the entire module is skipped instead of failing with wrong encodings. ## Test Expect CI to pass.
1 parent cf070e7 commit 5578ec6

1 file changed

Lines changed: 22 additions & 16 deletions

File tree

projects/hipblaslt/tensilelite/Tensile/Tests/unit/test_subtile_gfx1250_codegen.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
import os
1313
import sys
14-
import shutil
1514

1615
import pytest
1716
from types import SimpleNamespace
@@ -21,19 +20,33 @@
2120
TENSILE_ROOT = os.path.abspath(os.path.join(SCRIPT_DIR, "..", "..", ".."))
2221
sys.path.insert(0, TENSILE_ROOT)
2322

23+
from gpu_test_helpers import init_rocisa
24+
2425

2526
GFX1250_ISA = (12, 5, 0)
2627
WAVESIZE_32 = 32
2728

2829

29-
def _init_rocisa_gfx1250():
30-
from rocisa import rocIsa
31-
from Tensile.Common.Architectures import gfxToIsa
32-
ri = rocIsa.getInstance()
33-
isa = gfxToIsa("gfx1250")
34-
asmpath = shutil.which('amdclang++') or '/usr/bin/amdclang++'
35-
ri.init(isa, asmpath)
36-
ri.setKernel(isa, WAVESIZE_32)
30+
def _gfx1250_asm_supported():
31+
"""Return True if the host assembler supports gfx1250 instructions."""
32+
try:
33+
init_rocisa(target="gfx1250", wavesize=WAVESIZE_32)
34+
from rocisa import rocIsa
35+
caps = rocIsa.getInstance().getAsmCaps()
36+
return bool(caps.get("s_add_u64", 0))
37+
except Exception:
38+
return False
39+
40+
41+
pytestmark = pytest.mark.skipif(
42+
not _gfx1250_asm_supported(),
43+
reason="assembler does not support gfx1250 instructions",
44+
)
45+
46+
47+
@pytest.fixture(scope="module", autouse=True)
48+
def _rocisa_once():
49+
init_rocisa(target="gfx1250", wavesize=WAVESIZE_32)
3750

3851

3952
def _mock_dtype(num_bytes=2):
@@ -143,7 +156,6 @@ class TestGfx1250SubtileCodegen:
143156
ids=[f"{a}x{b}_wg{w[0]}x{w[1]}" for a, b, w in CONFIGS_1x1 + CONFIGS_MULTI_WAVE])
144157
def test_tdm_skips_gr_offset_alloc(self, mt_a, mt_b, wg):
145158
"""TDM-enabled kernel: GR offset registers should not be allocated."""
146-
_init_rocisa_gfx1250()
147159
kernel = _create_gfx1250_kernel(mt_a, mt_b, mi_wave_group=wg)
148160
writer, tiA, tiB = _create_writer_gfx1250(kernel)
149161
tiA.allocOffsetRegisters(writer, kernel)
@@ -155,7 +167,6 @@ def test_tdm_skips_gr_offset_alloc(self, mt_a, mt_b, wg):
155167
ids=[f"{a}x{b}_wg{w[0]}x{w[1]}" for a, b, w in CONFIGS_MULTI_WAVE])
156168
def test_lr_tile_assignment_multi_wave(self, mt_a, mt_b, wg):
157169
"""LR tile assignment with multi-wave TDM produces valid assembly."""
158-
_init_rocisa_gfx1250()
159170
from Tensile.Components.Subtile.SubtileLREmit import lraTileAssignment
160171
kernel = _create_gfx1250_kernel(mt_a, mt_b, mi_wave_group=wg)
161172
writer, tiA, tiB = _create_writer_gfx1250(kernel)
@@ -173,7 +184,6 @@ def test_lr_tile_assignment_multi_wave(self, mt_a, mt_b, wg):
173184
ids=[f"{a}x{b}" for a, b, _ in CONFIGS_1x1])
174185
def test_ds_read_dual_load(self, mt_a, mt_b, wg):
175186
"""Wave32 8-VGPR tiles emit two DSLoadB128 (lo + hi K-halves)."""
176-
_init_rocisa_gfx1250()
177187
from Tensile.Components.Subtile.SubtileLREmit import emitSingleDsRead
178188
kernel = _create_gfx1250_kernel(mt_a, mt_b)
179189
writer, tiA, tiB = _create_writer_gfx1250(kernel)
@@ -201,7 +211,6 @@ def test_select_d_geometry_wave32(self):
201211

202212
def test_zero_tiles_wmma(self):
203213
"""gfx1250 tile zeroing uses v_wmma_f32_16x16x4_f32 with acc2_imm=0."""
204-
_init_rocisa_gfx1250()
205214
from Tensile.Components.Subtile.Kernel import initVgprTilesToZero
206215
kernel = _create_gfx1250_kernel(32, 32)
207216
writer, tiA, tiB = _create_writer_gfx1250(kernel)
@@ -218,7 +227,6 @@ def test_zero_tiles_wmma(self):
218227
@pytest.mark.parametrize("tc", ['A', 'B'])
219228
def test_gr_lds_buffer_swap_tdm(self, tc):
220229
"""TDM LDS buffer swap emits XOR on tracking SGPR."""
221-
_init_rocisa_gfx1250()
222230
from Tensile.Components.Subtile.SubtileGREmit import globalReadLDSBufferSwap
223231
kernel = _create_gfx1250_kernel(64, 64, mi_wave_group=[2, 2])
224232
writer, tiA, tiB = _create_writer_gfx1250(kernel)
@@ -233,7 +241,6 @@ def test_gr_lds_buffer_swap_tdm(self, tc):
233241
@pytest.mark.parametrize("tc", ['A', 'B'])
234242
def test_gr_ptr_updates_tdm(self, tc):
235243
"""TDM pointer update increments Address and syncs descriptor."""
236-
_init_rocisa_gfx1250()
237244
from Tensile.Components.Subtile.SubtileGREmit import globalReadPtrUpdates
238245
kernel = _create_gfx1250_kernel(64, 64, mi_wave_group=[2, 2])
239246
writer, tiA, tiB = _create_writer_gfx1250(kernel)
@@ -250,7 +257,6 @@ def test_gr_ptr_updates_tdm(self, tc):
250257
@pytest.mark.parametrize("tc", ['A', 'B'])
251258
def test_buffer_load_tdm(self, tc):
252259
"""TDM emitSingleBufferLoad emits tensor_load_to_lds."""
253-
_init_rocisa_gfx1250()
254260
from Tensile.Components.Subtile.SubtileGREmit import emitSingleBufferLoad
255261
kernel = _create_gfx1250_kernel(64, 64)
256262
writer, tiA, tiB = _create_writer_gfx1250(kernel)

0 commit comments

Comments
 (0)