Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions tests/native_descriptor_scc_check.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Observe the SCC of a buffer stride extraction and both MAX operand orders."""
"""Observe the SCC of a buffer stride extraction and scalar min/max."""

from pathlib import Path
import struct
Expand All @@ -13,6 +13,15 @@
from startup_gfx2hlsl_compute_check import KEY, SENTINEL, TGID_X, TGID_Y, TGID_Z, USER7, WORDS


MINMAX_CASES = (
# Unequal operands are root constant s5 (3) and inline -1 (selector 193).
("s_min_u32", 0x07, 5, 193),
("s_min_i32", 0x06, 193, 5),
("s_max_u32", 0x09, 193, 5),
("s_max_i32", 0x08, 5, 193),
)


def program(*, runtime=False):
offset = 0 if runtime else 32
table, constant = (6, 4) if runtime else (4, 5)
Expand All @@ -28,9 +37,18 @@ def program(*, runtime=False):
# Flatten the 3x2x2 Dispatch so each group owns four output words.
words += [scalar(0x26, 8, 8, 131), scalar(0x26, 9, 9, 134),
scalar(0, 6, 7, 8), scalar(0, 6, 6, 9)]
words += [scalar(0x1e, 7, 6, 132), vmove(8, 7), sop1(3, 126, 129)]
group_shift = 132 if runtime else 134 # 16 or 64 bytes per group
words += [scalar(0x1e, 7, 6, group_shift), vmove(8, 7), sop1(3, 126, 129)]
for i, reg in enumerate((26, 28, 30, constant)):
words += [vmove(10, reg), 0xe0701000 | (4 * i), 0x80080a08]
if not runtime:
words.append(scalar(0x10, 31, 129, 128)) # s_or_b32: seed SCC=1
# MIN sets SCC for S0 < S1 and MAX for S0 > S1. Equal operands clear SCC.
for i, (_, op, lhs, rhs) in enumerate(MINMAX_CASES):
for j, (a, b) in enumerate(((constant, constant), (lhs, rhs))):
offset = 16 + 8 * i + 4 * j
words += [scalar(op, 31, a, b), scalar(0x0a, 31, 129, 128), # s_cselect_b32 s31, 1, 0
vmove(10, 31), 0xe0701000 | offset, 0x80080a08]
return words + [0xbf810000]


Expand Down Expand Up @@ -90,11 +108,19 @@ def root_bytes(srv_count):
stride = value & 0x3fff
expected = [0x69696969] * 2064
for group in range(2):
start = 8 + group * 4
start = 8 + group * 16
expected[start:start + 4] = [int(stride != 0), int(stride > 1), int(1 > stride), 3]
expected[start + 4:start + 12] = [0, 1] * len(MINMAX_CASES)
actual = list(struct.unpack("<2064I", readback.read_bytes()))
for group in range(2):
start = 8 + group * 16 + 4
for i, (name, _, _, _) in enumerate(MINMAX_CASES):
equal, unequal = actual[start + 2 * i:start + 2 * i + 2]
assert (equal, unequal) == (0, 1), (
f"{name} group {group}: SCC for equal operands={equal}, unequal operands={unequal}; expected 0, 1"
)
assert actual == expected, next((i, a, b) for i, (a, b) in enumerate(zip(actual, expected)) if a != b)
print(f"stride word {value}: two groups match {expected[8:12]} and all guards")
print(f"stride word {value}: two groups match {expected[8:12]}, min/max SCC pairs and all guards")
result = subprocess.run([replay, sdk, marker, work / "cache", "0", readback, mode],
capture_output=True, text=True)
assert result.returncode == 1 and "compute descriptor stride metadata missing" in result.stderr, result.stderr
Expand Down
Loading