Skip to content
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11153,6 +11153,11 @@ if(EXISTS "${INTAKE_PYTHON}")
"$<TARGET_FILE:offscreen_check>" ${adapter})
set_tests_properties(pixel_aot_cmpx_e64_${adapter} PROPERTIES TIMEOUT 60 SKIP_RETURN_CODE 77
ENVIRONMENT "FORM_COVERAGE_RECORD=${CMAKE_BINARY_DIR}/form_coverage/pixel_aot_cmpx_e64_${adapter}.txt")
add_test(NAME pixel_aot_cmpx_sdwa_${adapter} COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_SOURCE_DIR}/tests/pixel_aot_check.py" draw-cmpx-sdwa "${DXC_EXECUTABLE}"
"$<TARGET_FILE:offscreen_check>" ${adapter})
set_tests_properties(pixel_aot_cmpx_sdwa_${adapter} PROPERTIES TIMEOUT 60 SKIP_RETURN_CODE 77
ENVIRONMENT "FORM_COVERAGE_RECORD=${CMAKE_BINARY_DIR}/form_coverage/pixel_aot_cmpx_sdwa_${adapter}.txt")
add_test(NAME pixel_aot_region_body_${adapter} COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_SOURCE_DIR}/tests/pixel_aot_check.py" draw-region-body "${DXC_EXECUTABLE}"
"$<TARGET_FILE:offscreen_check>" ${adapter})
Expand Down Expand Up @@ -11344,6 +11349,10 @@ if(EXISTS "${INTAKE_PYTHON}")
"${CMAKE_SOURCE_DIR}/tests/pixel_aot_check.py" draw-f16-round "${DXC_EXECUTABLE}"
"$<TARGET_FILE:offscreen_check>" ${adapter})
set_tests_properties(pixel_aot_f16_round_${adapter} PROPERTIES TIMEOUT 60 SKIP_RETURN_CODE 77)
add_test(NAME pixel_aot_f16_rcp_sqrt_${adapter} COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_SOURCE_DIR}/tests/pixel_aot_check.py" draw-f16-rcp-sqrt "${DXC_EXECUTABLE}"
"$<TARGET_FILE:offscreen_check>" ${adapter})
set_tests_properties(pixel_aot_f16_rcp_sqrt_${adapter} PROPERTIES TIMEOUT 60 SKIP_RETURN_CODE 77)
add_test(NAME pixel_aot_f16_fmac_ldexp_${adapter} COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_SOURCE_DIR}/tests/pixel_aot_check.py" draw-f16-fmac-ldexp "${DXC_EXECUTABLE}"
"$<TARGET_FILE:offscreen_check>" ${adapter})
Expand Down Expand Up @@ -11630,6 +11639,8 @@ if(EXISTS "${INTAKE_PYTHON}")
ENVIRONMENT "FORM_COVERAGE_RECORD=${CMAKE_BINARY_DIR}/form_coverage/pixel_aot_f16_arith_${adapter}.txt")
set_tests_properties(pixel_aot_f16_round_${adapter} PROPERTIES
ENVIRONMENT "FORM_COVERAGE_RECORD=${CMAKE_BINARY_DIR}/form_coverage/pixel_aot_f16_round_${adapter}.txt")
set_tests_properties(pixel_aot_f16_rcp_sqrt_${adapter} PROPERTIES
ENVIRONMENT "FORM_COVERAGE_RECORD=${CMAKE_BINARY_DIR}/form_coverage/pixel_aot_f16_rcp_sqrt_${adapter}.txt")
set_tests_properties(pixel_aot_f16_fmac_ldexp_${adapter} PROPERTIES
ENVIRONMENT "FORM_COVERAGE_RECORD=${CMAKE_BINARY_DIR}/form_coverage/pixel_aot_f16_fmac_ldexp_${adapter}.txt")
set_tests_properties(pixel_aot_f16_cvt_int16_${adapter} PROPERTIES
Expand Down
12 changes: 9 additions & 3 deletions docs/experiments.md

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions docs/experiments/direct-sdwa-profiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ SDWA validation is per operand, mirroring
`place_subword` destination placement; no modifier or subword selection is
silently ignored.

Still refused in SDWA: `v_sin_f16`/`v_cos_f16` (no direct lowering),
`v_fmac_f32`/`v_fmac_f16` and the rest of `VOP2_SDWA_UNSUPPORTED_OPS`,
The SDWA forms of `v_sin_f16`/`v_cos_f16` are covered by the separate
`native_sin_cos_f16` suite. Still refused in SDWA: `v_fmac_f32`/`v_fmac_f16`
and the rest of `VOP2_SDWA_UNSUPPORTED_OPS`,
64-bit `_f64`/`_b64` forms, and VOP3-only ops (`v_fma_f16`, `v_min3_f16`,
`v_med3_f16`, `v_cvt_pknorm_*`).

Expand All @@ -56,7 +57,7 @@ a second and third program (12, 28 and 6 slots, each under the 32-slot
hardware layout) with an independent Python/ISA reference model, plus 15
refusal controls: disallowed VOP2 SDWA ops, float/int modifier violations,
omod/clamp on integer destinations, invalid 16-bit destination selection and
unused mode, a byte source pick, literal 255, and `v_sin_f16`. The new
unused mode, a byte source pick, and literal 255. The new
profiles also pin the `v_frexp_*_f32` SDWA source pick (a WORD_1 pick reads
only the high half, so the picked value is a subnormal) and destination
placement (a WORD destination keeps only the result's low half, with the
Expand Down
74 changes: 72 additions & 2 deletions tests/form_coverage_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,12 @@ def check_shader_records():
assert compare_forms <= covered, (name, sorted(compare_forms - covered))
assert not {form for _, form in covered} & (compare_neighbours | {f"{n}_e64" for n in compare_neighbours})
assert cmpx_forms <= reference and cmpx_forms <= covered, (name, sorted(cmpx_forms - covered))
assert {form for _, form in covered if form.startswith("v_cmpx_")} == {form for _, form in cmpx_forms}, name
# The non-SDWA v_cmpx family is the 190 forms above; the 62 exec-writing SDWA forms are a separate
# family, checked by check_cmpx_sdwa_coverage and counted here from the same control run.
assert {form for _, form in covered
if form.startswith("v_cmpx_") and not form.endswith("_sdwa")} == {form for _, form in cmpx_forms}, name
assert {form for _, form in covered if form.startswith("v_cmpx_") and form.endswith("_sdwa")} == \
{entry["form"] for entry in pixel.CMPX_SDWA_FORMS}, name
# The scalar ALU fixture counts its SOP1, SOP2, SOPK and SOPC forms; the neighbours the controls
# reject (s_addc_u32, s_cmp_lt_u64) stay out; s_getreg_b32 joined the accepted forms with the mode-register fixture.
scalar = {"s_movk_i32", "s_cmovk_i32", "s_not_b32", "s_add_u32", "s_sub_u32", "s_add_i32", "s_sub_i32",
Expand Down Expand Up @@ -651,7 +656,8 @@ def check_f16_arith_forms():

def check_f16_round_forms():
"""The eight plain binary16 VOP1 rounding forms (e32 and e64 spellings of floor, ceil, trunc and rndne) count as
covered once the translator accepts their fixtures; fract, rcp, sqrt and the DPP and SDWA spellings stay uncovered."""
covered once the translator accepts their fixtures; fract and the DPP and SDWA spellings stay uncovered here, and
rcp and sqrt have their own fixture."""
import pixel_aot_check as pixel
saved = set(pixel.ACCEPTED)
pixel.ACCEPTED.clear()
Expand Down Expand Up @@ -680,6 +686,41 @@ def check_f16_round_forms():
pixel.ACCEPTED.update(saved)


def check_f16_rcp_sqrt_forms():
"""The four plain binary16 VOP1 reciprocal and square root forms (e32 and e64 spellings of rcp and sqrt) count as
covered once the translator accepts their fixtures; their DPP, SDWA and rsq neighbours stay uncovered."""
import pixel_aot_check as pixel
saved = set(pixel.ACCEPTED)
pixel.ACCEPTED.clear()
try:
for key in pixel.F16_RCP_SQRT_PROGRAMS:
pixel.translate_f16(pixel.f16_rcp_sqrt_program(*key))
ops = ("rcp", "sqrt")
forms = {("VOP1", f"v_{op}_f16") for op in ops} | {("VOP3", f"v_{op}_f16_e64") for op in ops}
assert len(forms) == 4
neighbours = {
("VOP1", "v_rsq_f16"), ("VOP3", "v_rsq_f16_e64"),
("DPP16", "v_rcp_f16_dpp"), ("DPP16", "v_sqrt_f16_dpp"),
("DPP8", "v_rcp_f16_dpp"), ("DPP8", "v_sqrt_f16_dpp"),
("SDWA", "v_rcp_f16_sdwa"), ("SDWA", "v_sqrt_f16_sdwa"),
}
# The two operations add one VOP1 and one VOP3 row to each reference table.
for name in ("gfx1013.tsv", "rdna2.tsv"):
reference = fc.load_reference(name)
assert forms <= reference, (name, sorted(forms - reference))
assert neighbours <= reference, (name, sorted(neighbours - reference))
covered = fc.gfx_forms(pixel.ACCEPTED, reference)
assert forms <= covered, (name, sorted(forms - covered))
assert not neighbours & covered, (name, sorted(neighbours & covered))
pixel.ACCEPTED.clear()
for body in pixel.F16_EXACT_EXTRA_PROGRAMS.values():
pixel.translate_f16(pixel.uncompressed_export(body))
assert not forms & fc.gfx_forms(pixel.ACCEPTED, fc.load_reference("gfx1013.tsv"))
finally:
pixel.ACCEPTED.clear()
pixel.ACCEPTED.update(saved)


def check_f16_fmac_ldexp_forms():
"""The two plain e32 binary16 forms v_fmac_f16 and v_ldexp_f16 count as covered once the translator accepts their
fixtures; their e64, DPP and SDWA spellings and the arithmetic they resemble stay uncovered."""
Expand Down Expand Up @@ -1422,6 +1463,33 @@ def check_sdwa_cmp_coverage():
assert ("SDWA", "v_cmp_lt_f16_sdwa") not in fc.gfx_forms(stripped, reference), name


def check_cmpx_sdwa_coverage():
"""The 62 exec-writing VOPC SDWA comparisons are the complete SDWA v_cmpx family of both references,
counted from this fixture's accepted words. The non-SDWA exec writers and the v_cmp SDWA forms stay out."""
import pixel_aot_check as pixel
wanted = {("SDWA", entry["form"]) for entry in pixel.CMPX_SDWA_FORMS}
assert len(wanted) == 62
saved = set(pixel.ACCEPTED)
pixel.ACCEPTED.clear()
try:
pixel.translate(pixel.uncompressed_export(pixel.cmpx_sdwa_body()))
accepted = set(pixel.ACCEPTED)
finally:
pixel.ACCEPTED.clear()
pixel.ACCEPTED.update(saved)
assert not {form for form in accepted if form.startswith("v_cmp_")}
assert not {form for form in accepted if form.startswith("v_cmpx_") and not form.endswith("_sdwa")}
for name in ("gfx1013.tsv", "rdna2.tsv"):
reference = fc.load_reference(name)
family = {entry for entry in reference if entry[0] == "SDWA" and entry[1].startswith("v_cmpx_")}
assert family == wanted, (name, sorted(family ^ wanted))
covered = fc.gfx_forms(accepted, reference)
assert wanted <= covered, (name, sorted(wanted - covered))
# Control: removing one accepted SDWA word removes exactly that form from the count.
stripped = accepted - {"v_cmpx_lt_f16_sdwa"}
assert ("SDWA", "v_cmpx_lt_f16_sdwa") not in fc.gfx_forms(stripped, reference), name


def check_dpp_f16_arith_round_forms():
"""The 16 quad-local DPP16/DPP8 binary16 arithmetic and rounding forms count as covered once
the translator accepts their fixtures; unlowered f16 DPP/SDWA neighbours stay uncovered."""
Expand Down Expand Up @@ -1709,6 +1777,7 @@ def check_f16_cvt_norm_forms():
check_int16_ternary_forms()
check_f16_arith_forms()
check_f16_round_forms()
check_f16_rcp_sqrt_forms()
check_f16_fmac_ldexp_forms()
check_f16_cvt_int16_forms()
check_f16_to_int16_forms()
Expand All @@ -1722,6 +1791,7 @@ def check_f16_cvt_norm_forms():
check_swap_coverage()
check_pk_fmac_coverage()
check_sdwa_cmp_coverage()
check_cmpx_sdwa_coverage()
check_sopk_wait_forms()
check_s_version_form()
check_parsing()
Expand Down
3 changes: 2 additions & 1 deletion tests/native_cvt_f16_i16_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ def refusal_programs():
programs = []
for op, (vop1_op, vop3_op, _, to_f16) in OPS.items():
programs.append(([vop1(vop1_op, 3, 250), 0xFF00B101, 0xBF810000], 'unsupported DPP arithmetic'))
programs.append(([vop1(vop1_op, 3, 249), 0x06060601, 0xBF810000], 'unimplemented direct SDWA operand profile'))
programs.append(([vop1(vop1_op, 3, 249), 0x06060601, 0xBF810000],
'unsupported SDWA destination modifier'))
programs.append((vop3_unary(vop3_op, 3, 257, omod=1) + [0xBF810000], f'unsupported {op} clamp or omod'))
programs.append((vop3_unary(vop3_op, 3, 257, op_sel=1) + [0xBF810000], f'unsupported {op} high-half op_sel'))
programs.append((vop3_unary(vop3_op, 3, 257, op_sel=8) + [0xBF810000], f'unsupported {op} high-half op_sel'))
Expand Down
3 changes: 2 additions & 1 deletion tests/native_sdwa_profiles_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,8 @@ def refusal_cases():
(sdwa_instruction(profile("v_floor_f16", 0x5B, True, 0, src0=DWORD | 0x80, dst=WORD_0), reg0=255),
"literal is unavailable in SDWA"),
(sdwa_instruction(profile("v_fmac_f32", 0x2B, False, 0, 0)), SDWA_REFUSAL),
(sdwa_instruction(profile("v_sin_f16", 0x60, True, 0)), SDWA_REFUSAL),
# v_sin_f16/v_cos_f16 are admitted by the SDWA path since #3300; the
# separate native_sin_cos_f16 suite pins their positive forms.
)


Expand Down
Loading
Loading