diff --git a/CMakeLists.txt b/CMakeLists.txt index 5da721cd70..eb2868afb9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10404,6 +10404,11 @@ if(EXISTS "${INTAKE_PYTHON}") "${CMAKE_SOURCE_DIR}/tests/mesh_entry_aot_cli_check.py") add_test(NAME mesh_bitcmp_clause_cpu COMMAND "${INTAKE_PYTHON}" -B "${CMAKE_SOURCE_DIR}/tests/mesh_bitcmp_clause_check.py") + # Source-built wide SMEM loads: x16 descriptor slots and x8/x16 constant reads. + add_test(NAME compute_store_aot_smem_wide_loads COMMAND "${INTAKE_PYTHON}" -B + "${CMAKE_SOURCE_DIR}/tests/compute_store_check.py" smem-wide-loads) + set_tests_properties(compute_store_aot_smem_wide_loads PROPERTIES TIMEOUT 30 + ENVIRONMENT "FORM_COVERAGE_RECORD=${CMAKE_BINARY_DIR}/form_coverage/compute_store_aot_smem_wide_loads.txt") foreach(adapter IN ITEMS hardware warp) add_test(NAME mesh_dynamic_aot_draw_${adapter} COMMAND "${INTAKE_PYTHON}" -B "${CMAKE_SOURCE_DIR}/tests/mesh_dynamic_aot_draw_check.py" "${DXC_EXECUTABLE}" diff --git a/docs/experiments/direct-sdwa-profiles.md b/docs/experiments/direct-sdwa-profiles.md index 0190cfb3f9..09d6097443 100644 --- a/docs/experiments/direct-sdwa-profiles.md +++ b/docs/experiments/direct-sdwa-profiles.md @@ -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_*`). @@ -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 diff --git a/tests/compute_store_check.py b/tests/compute_store_check.py index 79faca44d3..c43cb4cc99 100644 --- a/tests/compute_store_check.py +++ b/tests/compute_store_check.py @@ -1105,6 +1105,119 @@ def read(name, *changes, **binding): assert "inputData.Load(tid.x * 16u + 0u)" in source +# Wide SMEM loads: x16 fetches four consecutive 16-byte descriptor slots, while an x8 or x16 +# constant read fills eight or all sixteen words of the bound constant record. +SMEM_WIDE_BINDING = dict(table_reg=7, descriptor_offset=0x30, constant_descriptor=0x40, + image_descriptor=0x50, image_format="R32G32B32A32_UINT") +SMEM_WIDE_PREFIX = ["s_mov_b32 s12, s7", "s_mov_b32 s13, 0"] +SMEM_WIDE_SLOAD16 = SMEM_WIDE_PREFIX + [ + "s_load_dwordx16 s[16:31], s[12:13], 0x30", + "s_waitcnt lgkmcnt(0)", + "v_mov_b32_e32 v0, 0x600d", + "v_mov_b32_e32 v1, 0x1234", + "buffer_store_dwordx2 v[0:1], off, s[16:19], 0", + "s_endpgm", +] +SMEM_WIDE_CONSTANT_PREFIX = SMEM_WIDE_PREFIX + [ + "s_load_dwordx4 s[16:19], s[12:13], 0x30", + "s_load_dwordx4 s[20:23], s[12:13], 0x40", + "s_waitcnt lgkmcnt(0)", +] +SMEM_WIDE_SBUFFER8 = SMEM_WIDE_CONSTANT_PREFIX + [ + "s_buffer_load_dwordx8 s[24:31], s[20:23], 0x20", + "s_waitcnt lgkmcnt(0)", + "v_mov_b32_e32 v0, s24", + "v_mov_b32_e32 v1, s31", + "buffer_store_dwordx2 v[0:1], off, s[16:19], 0", + "s_endpgm", +] +SMEM_WIDE_SBUFFER16 = SMEM_WIDE_CONSTANT_PREFIX + [ + "s_buffer_load_dwordx16 s[32:47], s[20:23], null", + "s_waitcnt lgkmcnt(0)", + "v_mov_b32_e32 v0, s32", + "v_mov_b32_e32 v1, s47", + "buffer_store_dwordx2 v[0:1], off, s[16:19], 0", + "s_endpgm", +] + + +def smem_wide_load_controls(): + """x16 descriptor loads and x8/x16 constant reads: accepted words, boundaries and refusals.""" + def lower(lines, **binding): + return aot.lower(lines, 1, **(SMEM_WIDE_BINDING | binding)).splitlines() + + def reject(message, lines, **binding): + rejects(message, aot.lower, lines, 1, **(SMEM_WIDE_BINDING | binding)) + + # The four slots map in order to u0, b0 and both halves of the t0 image descriptor; the u0 + # words drive the store and the words picked from b0 prove the x8/x16 offsets. + assert " outputData.Store2(0u, uint2(0x0000600du, 0x00001234u));" in lower(SMEM_WIDE_SLOAD16) + assert " outputData.Store2(0u, uint2(params[2].x, params[3].w));" in lower(SMEM_WIDE_SBUFFER8) + assert " outputData.Store2(0u, uint2(params[0].x, params[3].w));" in lower(SMEM_WIDE_SBUFFER16) + + # The last destination word stays at or below s105: s88 ends the x16 table load at s103, + # s96:103 is the highest x8 constant read and s80:95 the highest x16 one. + lower(variant(SMEM_WIDE_SLOAD16, + ("s_load_dwordx16 s[16:31], s[12:13], 0x30", + "s_load_dwordx4 s[16:19], s[12:13], 0x30\n" + "s_load_dwordx16 s[88:103], s[12:13], 0x30"))) + lower(variant(SMEM_WIDE_SBUFFER8, ("s[24:31]", "s[96:103]"), + ("v_mov_b32_e32 v0, s24", "v_mov_b32_e32 v0, s96"), + ("v_mov_b32_e32 v1, s31", "v_mov_b32_e32 v1, s103"))) + lower(variant(SMEM_WIDE_SBUFFER16, ("s[32:47]", "s[80:95]"), + ("v_mov_b32_e32 v0, s32", "v_mov_b32_e32 v0, s80"), + ("v_mov_b32_e32 v1, s47", "v_mov_b32_e32 v1, s95"))) + + unresolved = "Unresolved compute descriptor load" + constant = "Unresolved or out-of-range compute constant read" + # Destination alignment, the 0..105 register bound, a base pair or a fourth table slot that + # is missing, and a destination that overlaps an outstanding load are each refused. + reject(unresolved, variant(SMEM_WIDE_SLOAD16, ("s[16:31]", "s[17:32]"))) + reject(unresolved, variant(SMEM_WIDE_SLOAD16, ("s[16:31]", "s[92:107]"))) + reject(unresolved, variant(SMEM_WIDE_SLOAD16, ("s[12:13], 0x30", "s[12:14], 0x30"))) + reject(unresolved, variant(SMEM_WIDE_SLOAD16, ("s[12:13], 0x30", "s[11:12], 0x30"))) + reject(unresolved, SMEM_WIDE_SLOAD16, image_descriptor=None, image_format=None) + reject(unresolved, variant( + SMEM_WIDE_SLOAD16, ("s_load_dwordx16 s[16:31], s[12:13], 0x30", + "s_load_dwordx4 s[16:19], s[12:13], 0x30\n" + "s_load_dwordx16 s[16:31], s[12:13], 0x30"))) + # An x8 read must start on an eight-word boundary and an x16 read on a sixteen-word one; the + # 16-word constant record bounds the offset, and the base must be the ready four-word b0 view. + reject(constant, variant(SMEM_WIDE_SBUFFER8, ("s[24:31]", "s[25:32]"))) + reject(constant, variant(SMEM_WIDE_SBUFFER8, ("s[24:31]", "s[104:111]"))) + reject(constant, variant(SMEM_WIDE_SBUFFER8, ("0x20", "0x24"))) + reject(constant, variant(SMEM_WIDE_SBUFFER8, ("s[20:23], 0x20", "s[20:22], 0x20"))) + reject(constant, variant(SMEM_WIDE_SBUFFER8, ("s[20:23], 0x20", "s[21:24], 0x20"))) + reject(constant, variant(SMEM_WIDE_SBUFFER8, ("s[20:23], 0x20", "s[16:19], 0x20"))) + reject(constant, variant( + SMEM_WIDE_SBUFFER8, ("s_buffer_load_dwordx8 s[24:31], s[20:23], 0x20", + "s_load_dwordx4 s[24:27], s[12:13], 0x30\n" + "s_buffer_load_dwordx8 s[24:31], s[20:23], 0x20"))) + reject(constant, variant(SMEM_WIDE_SBUFFER16, ("s[32:47]", "s[33:48]"))) + reject(constant, variant(SMEM_WIDE_SBUFFER16, ("s[32:47]", "s[96:111]"))) + reject(constant, variant(SMEM_WIDE_SBUFFER16, (", null", ", 0x4"))) + reject(constant, variant(SMEM_WIDE_SBUFFER16, ("s[20:23], null", "s[20:22], null"))) + reject(constant, variant(SMEM_WIDE_SBUFFER16, ("s[20:23], null", "s[16:19], null"))) + reject(constant, variant( + SMEM_WIDE_SBUFFER16, ("s_buffer_load_dwordx16 s[32:47], s[20:23], null", + "s_buffer_load_dwordx4 s[32:35], s[20:23], null\n" + "s_buffer_load_dwordx16 s[32:47], s[20:23], null"))) + # The x16 load needs four distinct table slots. + reject("Invalid or overlapping constant descriptor binding", SMEM_WIDE_SBUFFER8, + constant_descriptor=0x38) + + +def smem_wide_loads(directory): + """Check and record the wide SMEM forms.""" + smem_wide_load_controls() + if record := os.environ.get("FORM_COVERAGE_RECORD"): + path = Path(record) + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text("s_load_dwordx16\ns_buffer_load_dwordx8\ns_buffer_load_dwordx16\n", + encoding="utf-8") + return 0 + + def alu_controls(): """Read-compute-write: exact output, then one rejection per instruction or operand outside the subset.""" def alu(*changes, **binding): @@ -9993,6 +10106,7 @@ def descriptor_store_draw(directory, compiler, renderer, backend): with tempfile.TemporaryDirectory() as tmp: # The store cases and the guard/read cases run as separate CTest entries so each stays within its timeout. modes = {"binary": binary, "draw": draw, + "smem-wide-loads": smem_wide_loads, "draw-scratch-base-write": draw_scratch_base_write, "draw-mubuf-subword": mubuf_subword_draw, "draw-mubuf-reduction": mubuf_reduction_draw, diff --git a/tests/native_cvt_f16_i16_check.py b/tests/native_cvt_f16_i16_check.py index e92cc74afb..dc61801ef5 100644 --- a/tests/native_cvt_f16_i16_check.py +++ b/tests/native_cvt_f16_i16_check.py @@ -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')) diff --git a/tests/native_sdwa_profiles_check.py b/tests/native_sdwa_profiles_check.py index 2e114e4aa2..9437c26be1 100644 --- a/tests/native_sdwa_profiles_check.py +++ b/tests/native_sdwa_profiles_check.py @@ -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. ) diff --git a/tests/startup_resource_retire_title.cpp b/tests/startup_resource_retire_title.cpp index 23c4f51952..e172024908 100644 --- a/tests/startup_resource_retire_title.cpp +++ b/tests/startup_resource_retire_title.cpp @@ -880,6 +880,9 @@ bool case6_written_generation_preserved(Context& c, void* title_mem) std::puts("FAIL: releasing the newer wrapper erased metadata used by the older wrapper's live SRV"); return false; } + // The release above signalled a release-time fence on every registered queue, and the drains never wait for the + // GPU: let both queues pass before settle(), as the other stages do (#3507). + if (!c.sync(c.direct) || !c.sync(c.gated)) return false; Tnew.freed = true; if (!c.settle("newer wrapper retired with older SRV live", "newer wrapper kept or older SRV retired")) return false; if (!x2w_d3d12_written_probe(title_mem, &generation, &bc7_width, nullptr) || generation != 2 || bc7_width != side) { diff --git a/tools/compute_store_aot.py b/tools/compute_store_aot.py index 703a8e81ec..0c6e00fc63 100644 --- a/tools/compute_store_aot.py +++ b/tools/compute_store_aot.py @@ -1598,8 +1598,8 @@ def lower(instructions, group, *, table_reg, descriptor_offset=None, group_reg=N or shift != dims[axis].bit_length() - 1): raise ValueError("Unverified group base") scalar[dst] = ("group_base", axis) - elif m := re.fullmatch(r"s_load_dwordx([48]) s\[(\d+):(\d+)\], s\[(\d+):(\d+)\], (null|0x[0-9a-f]+)", line): - # x8 loads two descriptors bound at consecutive 16-byte slots of the table. + elif m := re.fullmatch(r"s_load_dwordx(4|8|16) s\[(\d+):(\d+)\], s\[(\d+):(\d+)\], (null|0x[0-9a-f]+)", line): + # Each 16-byte descriptor slot supplies four words; x8 loads two consecutive slots and x16 four. count = int(m[1]) dest, last, base, high = map(int, m.groups()[1:5]) offset = 0 if m[6] == "null" else int(m[6], 16) @@ -1613,7 +1613,7 @@ def lower(instructions, group, *, table_reg, descriptor_offset=None, group_reg=N for word, reg in enumerate(regs): scalar[reg] = (descriptor_bindings[slots[word // 4]], word % 4) pending.update(regs) - elif m := re.fullmatch(r"(?:s_buffer_load_dwordx([24]) s\[(\d+):(\d+)\]|s_buffer_load_dword s(\d+)), " + elif m := re.fullmatch(r"(?:s_buffer_load_dwordx(2|4|8|16) s\[(\d+):(\d+)\]|s_buffer_load_dword s(\d+)), " r"s\[(\d+):(\d+)\], (null|0x[0-9a-f]+)", line): count = int(m[1] or 1) dest, last = (int(m[4]), int(m[4])) if m[4] else (int(m[2]), int(m[3])) diff --git a/tools/startup/gfx2hlsl.py b/tools/startup/gfx2hlsl.py index 0c8bdee786..dbf459541a 100644 --- a/tools/startup/gfx2hlsl.py +++ b/tools/startup/gfx2hlsl.py @@ -14081,6 +14081,20 @@ def stage_ok(s): fail_name = base_name + '.fail' fail_entry = files.get(fail_name) recheck = lost and (manifest_entry is not None) + + # A watch pass sees a request written after it started even when an + # earlier pass already recorded its failure. Keep that failure + # unchanged: retrying it every second would rewrite .fail and + # make its mtime look like new work. + if watch_since_ns is not None and fail_entry is not None and not recheck: + try: + fail_stat = fail_entry.stat() + if (fail_stat.st_mtime_ns > watch_since_ns and + fail_stat.st_mtime >= max(entry.stat().st_mtime, described or 0)): + continue + except OSError: + pass + if skip_failed and not recheck and fail_entry is not None: try: fail_mtime = fail_entry.stat().st_mtime diff --git a/tools/startup/triage_run.py b/tools/startup/triage_run.py index 4ee978ed53..e22aa9fb29 100644 --- a/tools/startup/triage_run.py +++ b/tools/startup/triage_run.py @@ -178,6 +178,7 @@ 'an output UAV covers only part of a copied placement', 'an output UAV has no supported byte interval', 'an output UAV interval crosses the end of its buffer', + 'an output UAV interval exceeds the D3D12 buffer view element limit', 'an output UAV interval is empty', 'an output UAV interval is not 16-byte aligned in its buffer', 'an output UAV interval is not whole dwords',