diff options
Diffstat (limited to 'tools/f64_diff.py')
| -rw-r--r-- | tools/f64_diff.py | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/tools/f64_diff.py b/tools/f64_diff.py index 340f3d106..4e42ca6f3 100644 --- a/tools/f64_diff.py +++ b/tools/f64_diff.py | |||
| @@ -57,7 +57,6 @@ KNOWN_DIVERGENCES = { | |||
| 57 | "f64-omod": "SHADER-721: f64 output modifiers; owned by @fiestorra.", | 57 | "f64-omod": "SHADER-721: f64 output modifiers; owned by @fiestorra.", |
| 58 | "double-neg-abs": "TEST-912 (#4172): spirv_mini_interp rounds binary64 OpFNegate/FAbs through binary32, changing values as well as NaN payloads.", | 58 | "double-neg-abs": "TEST-912 (#4172): spirv_mini_interp rounds binary64 OpFNegate/FAbs through binary32, changing values as well as NaN payloads.", |
| 59 | "fclamp-nan-zero": "FClamp NaN and signed-zero results are driver-dependent after f64 clamp/omod.", | 59 | "fclamp-nan-zero": "FClamp NaN and signed-zero results are driver-dependent after f64 clamp/omod.", |
| 60 | "div-fixup-nan-s0": "RDNA2 ISA maps NaN(S0) to signed infinity; current translator preserves the NaN payload.", | ||
| 61 | } | 60 | } |
| 62 | 61 | ||
| 63 | 62 | ||
| @@ -342,15 +341,8 @@ def ref_program(lines, include_known=False): | |||
| 342 | else: | 341 | else: |
| 343 | d = int(dst[2:-1].split(":")[0]); vgpr[d], vgpr[d + 1] = bits_to_words(out) | 342 | d = int(dst[2:-1].split(":")[0]); vgpr[d], vgpr[d + 1] = bits_to_words(out) |
| 344 | elif op == "v_div_fixup_f64": | 343 | elif op == "v_div_fixup_f64": |
| 345 | args = [read_source(t, vgpr, sgpr) for t in a[:3]] | 344 | # NaN(S0) gives signed infinity, measured on RDNA2 gfx1036 (TEST-983; the translator has it since #2477, 48a1a98b). |
| 346 | s0, s1, s2 = args | 345 | d = int(dst[2:-1].split(":")[0]); vgpr[d], vgpr[d + 1] = bits_to_words(fixup(*[read_source(t, vgpr, sgpr) for t in a[:3]])) |
| 347 | ediff = ((s2 >> 52) & 0x7FF) - ((s1 >> 52) & 0x7FF) | ||
| 348 | normal_division = (not is_nan(s1) and not is_inf(s1) and not is_zero(s1) | ||
| 349 | and not is_nan(s2) and not is_inf(s2) and not is_zero(s2) | ||
| 350 | and -1074 <= ediff < 1024) | ||
| 351 | if not include_known and is_nan(s0) and normal_division: | ||
| 352 | raise SkipCase(f"KNOWN_DIVERGENCE div-fixup-nan-s0: {KNOWN_DIVERGENCES['div-fixup-nan-s0']}") | ||
| 353 | d = int(dst[2:-1].split(":")[0]); vgpr[d], vgpr[d + 1] = bits_to_words(fixup(*args)) | ||
| 354 | elif op == "v_frexp_mant_f64": | 346 | elif op == "v_frexp_mant_f64": |
| 355 | d = int(dst[2:-1].split(":")[0]); vgpr[d], vgpr[d + 1] = bits_to_words(frexp(read_source(a[0], vgpr, sgpr))[0]) | 347 | d = int(dst[2:-1].split(":")[0]); vgpr[d], vgpr[d + 1] = bits_to_words(frexp(read_source(a[0], vgpr, sgpr))[0]) |
| 356 | elif op == "v_frexp_exp_i32_f64": | 348 | elif op == "v_frexp_exp_i32_f64": |
| @@ -545,11 +537,7 @@ def make_case(rng, op, allow_literal=True, known_case=None): | |||
| 545 | if known_case == "fclamp-nan-zero": left, right = "0x7ff80001", "1.0" | 537 | if known_case == "fclamp-nan-zero": left, right = "0x7ff80001", "1.0" |
| 546 | body_lines.append(f"{op} v[8:9], {left}, {right}{suffix}") | 538 | body_lines.append(f"{op} v[8:9], {left}, {right}{suffix}") |
| 547 | elif op == "v_div_fixup_f64": | 539 | elif op == "v_div_fixup_f64": |
| 548 | if known_case == "div-fixup-nan-s0": | 540 | body_lines.append(f"{op} v[8:9], {gen_source(rng, 0, allow_literal, bus)}, {gen_source(rng, 1, allow_literal, bus)}, {gen_source(rng, 2, allow_literal, bus)}") |
| 549 | setup_lines += ["v_mov_b32 v12, 0x00000000", "v_mov_b32 v13, 0x7ff80000"] | ||
| 550 | body_lines.append(f"{op} v[8:9], v[12:13], 1.0, 2.0") | ||
| 551 | else: | ||
| 552 | body_lines.append(f"{op} v[8:9], {gen_source(rng, 0, allow_literal, bus)}, {gen_source(rng, 1, allow_literal, bus)}, {gen_source(rng, 2, allow_literal, bus)}") | ||
| 553 | elif op == "v_div_fmas_f64": | 541 | elif op == "v_div_fmas_f64": |
| 554 | # VCC is initialized true so the f64 scaled FMA path is exercised deterministically. | 542 | # VCC is initialized true so the f64 scaled FMA path is exercised deterministically. |
| 555 | body_lines += ["v_cmp_eq_i32_e32 vcc_lo, 0, 0", f"{op} v[8:9], {gen_source(rng, 0, allow_literal, bus)}, {gen_source(rng, 1, allow_literal, bus)}, {gen_source(rng, 2, allow_literal, bus)}"] | 543 | body_lines += ["v_cmp_eq_i32_e32 vcc_lo, 0, 0", f"{op} v[8:9], {gen_source(rng, 0, allow_literal, bus)}, {gen_source(rng, 1, allow_literal, bus)}, {gen_source(rng, 2, allow_literal, bus)}"] |
| @@ -681,8 +669,7 @@ def run_batch(ops, programs, seed, max_ops=1, sweep=True, allow_literal=True, kn | |||
| 681 | sequence = [(op, True, None) for op in ops] if sweep else [] | 669 | sequence = [(op, True, None) for op in ops] if sweep else [] |
| 682 | sequence += [(rng.choice(ops), False, None) for _ in range(programs)] | 670 | sequence += [(rng.choice(ops), False, None) for _ in range(programs)] |
| 683 | if known: | 671 | if known: |
| 684 | sequence += [("v_div_fixup_f64" if label == "div-fixup-nan-s0" else "v_add_f64", True, label) | 672 | sequence += [("v_add_f64", True, label) for label in KNOWN_DIVERGENCES] |
| 685 | for label in KNOWN_DIVERGENCES] | ||
| 686 | cases = [] | 673 | cases = [] |
| 687 | for idx, (op, is_sweep, known_case) in enumerate(sequence): | 674 | for idx, (op, is_sweep, known_case) in enumerate(sequence): |
| 688 | setup_lines, body_lines, _, _ = make_case(rng, op, allow_literal, known_case) | 675 | setup_lines, body_lines, _, _ = make_case(rng, op, allow_literal, known_case) |