From 2a5873c970ef49661b6cf998297d690850e4fe00 Mon Sep 17 00:00:00 2001 From: Luiz Neves Date: Sun, 22 Nov 2026 21:50:11 -0300 Subject: [PATCH 1/2] GPU test cs_w32_lds_add_f32: ds_add_f32 and ds_add_rtn_f32 #3120 merged ds_add_f32 with CPU-only checks. Lane 0 of a wave32 group checks the returned old value, a plain sum, ties to even both ways, -0 + +0, overflow to +inf, the non-returning form and offset:. No denormal or NaN input (not measured). Registered in check.py, run_gpu_tests.py and regen_fixtures.py; tests/semantic/test_lds_add_f32_fixture.py runs it on the CPU against a once-rounded double sum and checks both runners expect the same words. --- runtime/test/shaders/check.py | 4 +- runtime/test/shaders/cs_w32_lds_add_f32.asm | 89 +++++++++++++++++++ scripts/run_gpu_tests.py | 6 +- .../fixtures/disasm/cs_w32_lds_add_f32.s | 75 ++++++++++++++++ tests/semantic/regen_fixtures.py | 2 +- tests/semantic/test_lds_add_f32_fixture.py | 89 +++++++++++++++++++ 6 files changed, 261 insertions(+), 4 deletions(-) create mode 100644 runtime/test/shaders/cs_w32_lds_add_f32.asm create mode 100644 tests/semantic/fixtures/disasm/cs_w32_lds_add_f32.s create mode 100644 tests/semantic/test_lds_add_f32_fixture.py diff --git a/runtime/test/shaders/check.py b/runtime/test/shaders/check.py index 330af9f4f3..a64134e0b7 100644 --- a/runtime/test/shaders/check.py +++ b/runtime/test/shaders/check.py @@ -85,7 +85,7 @@ def not_found_message(build, missing): "cs_w32_lds_subdword", "cs_w32_lds_wide", "cs_w32_partial_scmp", "cs_exec_const", "cs_w32_mask_imm", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops", "cs_w32_sincos", "cs_lds_b64_cmpst", "cs_w32_andn2_exec", - "cs_mask_vgpr_exec") + "cs_mask_vgpr_exec", "cs_w32_lds_add_f32") # Wave32 lane-mask dumps: their EXEC/VCC masks and lane selects cover 32 lanes, so a device whose widest subgroup is # narrower (Mesa llvmpipe: 8) can't produce their words. They are skipped there, as ps_bitmask_perm is. They run with # 32 lanes requested (WAVE32_LANE_ENV), as run_gpu_tests.py does: a device with a range like 8..32 (Intel ANV) may @@ -115,6 +115,8 @@ def not_found_message(build, missing): # 64-bit scalar data ops and v_mad_u64_u32 (derivations in cs_w32_salu64.asm) # more ops with CPU-only checks until now (derivations in cs_w32_misc_ext.asm) # ops merged on 2026-11-22 with CPU-only checks (derivations in cs_w32_new_ops.asm) + # ds_add_f32 / ds_add_rtn_f32: binary32 add, ties to even (cs_w32_lds_add_f32.asm) + ("cs_w32_lds_add_f32", [0x3FC00000, 0x40700000, 0x4B800000, 0x4B800002, 0, 0x7F800000, 0x3E800000, 0x40200000]), ("cs_w32_new_ops", [0x55, 0x8001, 0xC0000000, 0x80014000, 0x4000FFFF, 0x77, 0x99, 0x1234]), ("cs_w32_misc_ext", [0x0FFF0FFF, 0xE2C4A688, 0x0007FFFF, 0x7FFF8000, 0xFFFE0002, 0xFFFF0005, 0x509, 0xCAFEF00D]), ("cs_w32_salu64", [0x1E6A2C48, 0x1234, 0xFFFFFFFF, 0x100, 47, 48, 0xFFFF8000, 0xFFFFFFFE]), diff --git a/runtime/test/shaders/cs_w32_lds_add_f32.asm b/runtime/test/shaders/cs_w32_lds_add_f32.asm new file mode 100644 index 0000000000..7f4c894156 --- /dev/null +++ b/runtime/test/shaders/cs_w32_lds_add_f32.asm @@ -0,0 +1,89 @@ +; ds_add_f32 / ds_add_rtn_f32 (#3120, merged with CPU-only checks): M = M + DATA as binary32, round to nearest even; +; the _rtn_ form returns the old M. Lane 0 of a wave32 group stores eight dwords: +; out[0] = ds_add_rtn_f32 old value (LDS 1.5, DATA 2.25) = 0x3FC00000 +; out[1] = the LDS word after it: 3.75 = 0x40700000 +; out[2] = 2^24 + 1.0: a tie, to the even 2^24 = 0x4B800000 +; out[3] = (2^24 + 2) + 1.0: a tie, to the even 2^24 + 4 = 0x4B800002 +; out[4] = -0 + +0 = +0 = 0x00000000 +; out[5] = 3e38 + 3e38 overflows to +inf = 0x7F800000 +; out[6] = ds_add_f32 (no return): 1.0 + -0.75 = 0x3E800000 +; out[7] = the word at 0xC4 after ds_add_rtn_f32 at base 0xC0 offset:4 (2.0 + 0.5) = 0x40200000 +; No denormal or NaN input: how the LDS adder treats those is not measured (docs/design.md). EXEC is cut to lane 0 +; before the first LDS op (one address per op, #1850). +; group: 32,1,1 +; Run: vk_compute_test cs_w32_lds_add_f32.spv 1 dump -> out[0..7] = 1069547520 1081081856 1266679808 1266679810 0 2139095040 1048576000 1075838976 +; mattr: +wavefrontsize32,-wavefrontsize64 +v_cmpx_eq_u32_e32 0, v0 +v_mov_b32_e32 v10, 0x40 +v_mov_b32_e32 v11, 0x3fc00000 +ds_write_b32 v10, v11 +s_waitcnt lgkmcnt(0) +v_mov_b32_e32 v12, 0x40100000 +ds_add_rtn_f32 v14, v10, v12 +s_waitcnt lgkmcnt(0) +ds_read_b32 v15, v10 +v_mov_b32_e32 v10, 0x50 +v_mov_b32_e32 v11, 0x4b800000 +ds_write_b32 v10, v11 +v_mov_b32_e32 v13, 1.0 +s_waitcnt lgkmcnt(0) +ds_add_f32 v10, v13 +s_waitcnt lgkmcnt(0) +ds_read_b32 v16, v10 +v_mov_b32_e32 v10, 0x60 +v_mov_b32_e32 v11, 0x4b800001 +ds_write_b32 v10, v11 +s_waitcnt lgkmcnt(0) +ds_add_f32 v10, v13 +s_waitcnt lgkmcnt(0) +ds_read_b32 v17, v10 +v_mov_b32_e32 v10, 0x70 +v_mov_b32_e32 v11, 0x80000000 +ds_write_b32 v10, v11 +v_mov_b32_e32 v12, 0 +s_waitcnt lgkmcnt(0) +ds_add_f32 v10, v12 +s_waitcnt lgkmcnt(0) +ds_read_b32 v18, v10 +v_mov_b32_e32 v10, 0x80 +v_mov_b32_e32 v11, 0x7f61b1e6 +ds_write_b32 v10, v11 +s_waitcnt lgkmcnt(0) +ds_add_f32 v10, v11 +s_waitcnt lgkmcnt(0) +ds_read_b32 v19, v10 +v_mov_b32_e32 v10, 0x90 +ds_write_b32 v10, v13 +v_mov_b32_e32 v12, 0xbf400000 +s_waitcnt lgkmcnt(0) +ds_add_f32 v10, v12 +s_waitcnt lgkmcnt(0) +ds_read_b32 v21, v10 +v_mov_b32_e32 v10, 0xc4 +v_mov_b32_e32 v11, 2.0 +ds_write_b32 v10, v11 +v_mov_b32_e32 v10, 0xc0 +v_mov_b32_e32 v12, 0.5 +s_waitcnt lgkmcnt(0) +ds_add_rtn_f32 v22, v10, v12 offset:4 +s_waitcnt lgkmcnt(0) +v_mov_b32_e32 v10, 0xc4 +ds_read_b32 v22, v10 +s_waitcnt lgkmcnt(0) +v_mov_b32_e32 v20, 0 +buffer_store_dword v14, v20, s[0:3], 0 offen +v_mov_b32_e32 v20, 4 +buffer_store_dword v15, v20, s[0:3], 0 offen +v_mov_b32_e32 v20, 8 +buffer_store_dword v16, v20, s[0:3], 0 offen +v_mov_b32_e32 v20, 12 +buffer_store_dword v17, v20, s[0:3], 0 offen +v_mov_b32_e32 v20, 16 +buffer_store_dword v18, v20, s[0:3], 0 offen +v_mov_b32_e32 v20, 20 +buffer_store_dword v19, v20, s[0:3], 0 offen +v_mov_b32_e32 v20, 24 +buffer_store_dword v21, v20, s[0:3], 0 offen +v_mov_b32_e32 v20, 28 +buffer_store_dword v22, v20, s[0:3], 0 offen +s_endpgm diff --git a/scripts/run_gpu_tests.py b/scripts/run_gpu_tests.py index 94de20f26f..909ba11c62 100644 --- a/scripts/run_gpu_tests.py +++ b/scripts/run_gpu_tests.py @@ -944,7 +944,7 @@ def run_suite(a, work: str) -> int: # Whole-wave mask test, as in check.py: needs a 64-wide subgroup, skipped where the device has none. # With LEONIDA_W64_EMULATE=1 it was translated with --wave64-emulate and runs on any subgroup size. results.append((name,) + wavemask_check(vk_compute, spv, cs_env, w64_emulated())) - elif name in ("cs_store", "cs_signed_zero_nan", "cs_smem_soffset_imm", "cs_w32_lane_wrap", "cs_movrelsd_2", "cs_w32_permute", "cs_w32_sincos", "cs_exec_const", "cs_w32_mask_imm", "cs_w64_mask_imm", "cs_w32_lds_u8_d16", "cs_w32_lds_subdword", "cs_w32_lds_wide", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops", "cs_wave64_ballot", "cs_wm_half_ops", "cs_wm_half_cmp", "cs_wm_bfm64", "cs_wm_scc_rfl", "cs_wqm_w64", "cs_wqm_w32", "cs_wqm_w64_half", + elif name in ("cs_store", "cs_signed_zero_nan", "cs_smem_soffset_imm", "cs_w32_lane_wrap", "cs_movrelsd_2", "cs_w32_permute", "cs_w32_sincos", "cs_w32_lds_add_f32", "cs_exec_const", "cs_w32_mask_imm", "cs_w64_mask_imm", "cs_w32_lds_u8_d16", "cs_w32_lds_subdword", "cs_w32_lds_wide", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops", "cs_wave64_ballot", "cs_wm_half_ops", "cs_wm_half_cmp", "cs_wm_bfm64", "cs_wm_scc_rfl", "cs_wqm_w64", "cs_wqm_w32", "cs_wqm_w64_half", "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", "cs_dpp_ops", "cs_dpp_bank", "cs_dpp_fi", "cs_dpp_bound", "cs_dpp_w64", "cs_w64_mask_detect", @@ -971,6 +971,8 @@ def run_suite(a, work: str) -> int: # 64-bit scalar data ops and v_mad_u64_u32 (cs_w32_salu64.asm) # more ops with CPU-only checks until now (cs_w32_misc_ext.asm) # ops merged on 2026-11-22 with CPU-only checks (cs_w32_new_ops.asm) + # ds_add_f32 / ds_add_rtn_f32: binary32 add, ties to even (cs_w32_lds_add_f32.asm) + "cs_w32_lds_add_f32": [0x3FC00000, 0x40700000, 0x4B800000, 0x4B800002, 0, 0x7F800000, 0x3E800000, 0x40200000], "cs_w32_new_ops": [0x55, 0x8001, 0xC0000000, 0x80014000, 0x4000FFFF, 0x77, 0x99, 0x1234], "cs_w32_misc_ext": [0x0FFF0FFF, 0xE2C4A688, 0x0007FFFF, 0x7FFF8000, 0xFFFE0002, 0xFFFF0005, 0x509, 0xCAFEF00D], "cs_w32_salu64": [0x1E6A2C48, 0x1234, 0xFFFFFFFF, 0x100, 47, 48, 0xFFFF8000, 0xFFFFFFFE], @@ -1058,7 +1060,7 @@ def run_suite(a, work: str) -> int: "cs_w32_permute", "cs_barrier_divergent", "cs_barrier_early_end", "cs_barrier_loop", "cs_w32_lds_u8_d16", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops", "cs_w32_lds_subdword", "cs_w32_lds_wide", - "cs_bpermute32", "cs_w32_partial_scmp", "cs_w32_sincos", + "cs_bpermute32", "cs_w32_partial_scmp", "cs_w32_sincos", "cs_w32_lds_add_f32", "cs_lds_b64_cmpst", "cs_exec_const", "cs_w32_mask_imm", "cs_mask_vgpr_exec", "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", "cs_dpp_ops", "cs_dpp_bound", "cs_dpp_bank", "cs_dpp_fi", "cs_w32_andn2_exec") and not emulated and not partial diff --git a/tests/semantic/fixtures/disasm/cs_w32_lds_add_f32.s b/tests/semantic/fixtures/disasm/cs_w32_lds_add_f32.s new file mode 100644 index 0000000000..7bb17afbf9 --- /dev/null +++ b/tests/semantic/fixtures/disasm/cs_w32_lds_add_f32.s @@ -0,0 +1,75 @@ +; cs_w32_lds_add_f32 test fixture generated by tests/semantic/regen_fixtures.py from runtime/test/shaders/cs_w32_lds_add_f32.asm + v_cmpx_eq_u32_e32 0, v0 + v_mov_b32_e32 v10, 0x40 + v_mov_b32_e32 v11, 0x3fc00000 + ds_write_b32 v10, v11 + s_waitcnt lgkmcnt(0) + v_mov_b32_e32 v12, 0x40100000 + ds_add_rtn_f32 v14, v10, v12 + s_waitcnt lgkmcnt(0) + ds_read_b32 v15, v10 + v_mov_b32_e32 v10, 0x50 + v_mov_b32_e32 v11, 0x4b800000 + ds_write_b32 v10, v11 + v_mov_b32_e32 v13, 1.0 + s_waitcnt lgkmcnt(0) + ds_add_f32 v10, v13 + s_waitcnt lgkmcnt(0) + ds_read_b32 v16, v10 + v_mov_b32_e32 v10, 0x60 + v_mov_b32_e32 v11, 0x4b800001 + ds_write_b32 v10, v11 + s_waitcnt lgkmcnt(0) + ds_add_f32 v10, v13 + s_waitcnt lgkmcnt(0) + ds_read_b32 v17, v10 + v_mov_b32_e32 v10, 0x70 + v_mov_b32_e32 v11, 0x80000000 + ds_write_b32 v10, v11 + v_mov_b32_e32 v12, 0 + s_waitcnt lgkmcnt(0) + ds_add_f32 v10, v12 + s_waitcnt lgkmcnt(0) + ds_read_b32 v18, v10 + v_mov_b32_e32 v10, 0x80 + v_mov_b32_e32 v11, 0x7f61b1e6 + ds_write_b32 v10, v11 + s_waitcnt lgkmcnt(0) + ds_add_f32 v10, v11 + s_waitcnt lgkmcnt(0) + ds_read_b32 v19, v10 + v_mov_b32_e32 v10, 0x90 + ds_write_b32 v10, v13 + v_mov_b32_e32 v12, 0xbf400000 + s_waitcnt lgkmcnt(0) + ds_add_f32 v10, v12 + s_waitcnt lgkmcnt(0) + ds_read_b32 v21, v10 + v_mov_b32_e32 v10, 0xc4 + v_mov_b32_e32 v11, 2.0 + ds_write_b32 v10, v11 + v_mov_b32_e32 v10, 0xc0 + v_mov_b32_e32 v12, 0.5 + s_waitcnt lgkmcnt(0) + ds_add_rtn_f32 v22, v10, v12 offset:4 + s_waitcnt lgkmcnt(0) + v_mov_b32_e32 v10, 0xc4 + ds_read_b32 v22, v10 + s_waitcnt lgkmcnt(0) + v_mov_b32_e32 v20, 0 + buffer_store_dword v14, v20, s[0:3], 0 offen + v_mov_b32_e32 v20, 4 + buffer_store_dword v15, v20, s[0:3], 0 offen + v_mov_b32_e32 v20, 8 + buffer_store_dword v16, v20, s[0:3], 0 offen + v_mov_b32_e32 v20, 12 + buffer_store_dword v17, v20, s[0:3], 0 offen + v_mov_b32_e32 v20, 16 + buffer_store_dword v18, v20, s[0:3], 0 offen + v_mov_b32_e32 v20, 20 + buffer_store_dword v19, v20, s[0:3], 0 offen + v_mov_b32_e32 v20, 24 + buffer_store_dword v21, v20, s[0:3], 0 offen + v_mov_b32_e32 v20, 28 + buffer_store_dword v22, v20, s[0:3], 0 offen + s_endpgm diff --git a/tests/semantic/regen_fixtures.py b/tests/semantic/regen_fixtures.py index d633f563cd..b58a8650de 100644 --- a/tests/semantic/regen_fixtures.py +++ b/tests/semantic/regen_fixtures.py @@ -21,7 +21,7 @@ "ps_sdwa_dword_hi", # 16-bit SDWA results with dst_sel:DWORD zero the high half "ps_sdwa", "ps_ops", "ps_ops2", "ps_ops3", "ps_ops4", "ps_ops5", "ps_ops6", "ps_ops7", "ps_ops8", "ps_legacy_mul", "ps_vcc_x2", "ps_vcmpx_forms", "ps_flat", "cs_bounds", "cs_fmt_1010102", "cs_fmt_sint32", "cs_fmt_int_narrow", "cs_fmt_d16_xyz", "cs_w64x_readlane", - "cs_w64x_writelane", "cs_w64x_bpermute", "cs_w32_permute", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops", "cs_w64x_permute", "cs_w64x_ballot", "cs_w64x_readfirstlane", + "cs_w64x_writelane", "cs_w64x_bpermute", "cs_w32_permute", "cs_w32_lds_add_f32", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops", "cs_w64x_permute", "cs_w64x_ballot", "cs_w64x_readfirstlane", "cs_w64x_load_ballot_load", "cs_w64x_partial", "cs_wave64_ballot", "cs_wm_bfm64", "cs_wm_half_cmp", "cs_wavemask", "cs_cvt_f32_sat", "ps_scc_minmax", "ps_fma_literal", "ps_f16_vop2", "ps_outmods_f16", "ps_f32_mods", "ps_f64_mods", "ps_sff_imm", "cs_w32_lds_u8_d16", "cs_w32_lane_wrap", "ps_bary", diff --git a/tests/semantic/test_lds_add_f32_fixture.py b/tests/semantic/test_lds_add_f32_fixture.py new file mode 100644 index 0000000000..cc967e26ed --- /dev/null +++ b/tests/semantic/test_lds_add_f32_fixture.py @@ -0,0 +1,89 @@ +"""cs_w32_lds_add_f32: the GPU test of ds_add_f32 / ds_add_rtn_f32 (#3120), run here on the CPU too. + +Standard library only; no GPU, no LLVM, no game files. + +runtime/test/shaders/cs_w32_lds_add_f32.asm (derivations in its header) stores eight words from lane 0. This runs its +fixture as one wave32 group through spirv_mini_interp with the buffer vk_compute_test gives it (every byte 0xEE, a V# +with num_records 0xFFFFFFFF), checks the words against a reference that adds in double precision (exact for two +binary32 values) and rounds once to binary32, that check.py and scripts/run_gpu_tests.py expect the same words, and +that EXEC is cut to lane 0 before the first LDS op. +""" +import os +import re +import struct +import unittest + +import support +import spirv_mini_interp as si + +HERE = os.path.dirname(os.path.abspath(__file__)) +ROOT = os.path.dirname(os.path.dirname(HERE)) + +FSSM = bytearray(0x148) +struct.pack_into("<4I", FSSM, 0x138, 0x8088, 32, 1, 1) # 4 user SGPRs, wg id in s4, 512 bytes of LDS, 32x1x1 +FSSM = bytes(FSSM) +VSHARP = [0, 0, 0xFFFFFFFF, 0x31016FAC] # vk_compute_test's V#: base 0, num_records max, raw +FILL = 0xEEEEEEEE + + +def f32(b): + return struct.unpack(" 0 else 0xFF800000 + + +EXPECTED = [ + 0x3FC00000, # ds_add_rtn_f32: the old value, 1.5 + add(0x3FC00000, 0x40100000), # 1.5 + 2.25 + add(0x4B800000, 0x3F800000), # 2^24 + 1: tie, down to even + add(0x4B800001, 0x3F800000), # (2^24 + 2) + 1: tie, up to even + add(0x80000000, 0x00000000), # -0 + +0 + add(0x7F61B1E6, 0x7F61B1E6), # 3e38 + 3e38: overflow + add(0x3F800000, 0xBF400000), # ds_add_f32: 1.0 + -0.75 + add(0x40000000, 0x3F000000), # offset:4: 2.0 + 0.5 +] + + +class LdsAddF32Fixture(unittest.TestCase): + def test_reference(self): + self.assertEqual(EXPECTED, [0x3FC00000, 0x40700000, 0x4B800000, 0x4B800002, 0, 0x7F800000, 0x3E800000, + 0x40200000]) + + def test_translated_shader(self): + spv = support.translate_fixture("cs_w32_lds_add_f32", fssm=FSSM) + mem = {4 * k: FILL for k in range(64)} + si.run_workgroup(spv, 32, 32, inputs_for=lambda i: {"%wg_id": (0, 0, 0), "%local_id": (i, 0, 0), + "%sg_lane": i}, + push_constants=VSHARP + [0] * 28, memory=mem) + for k, want in enumerate(EXPECTED): + with self.subTest(word=k): + self.assertEqual(mem[4 * k], want) + + def test_gpu_runners_expect_the_same_words(self): + for rel in (("runtime", "test", "shaders", "check.py"), ("scripts", "run_gpu_tests.py")): + with open(os.path.join(ROOT, *rel), encoding="utf-8") as f: + text = f.read() + m = re.search(r'"cs_w32_lds_add_f32"\)?[,:]\s*\[([^\]]*)\]', text) + with self.subTest(file="/".join(rel)): + self.assertIsNotNone(m) + self.assertEqual([int(v, 0) for v in m.group(1).split(",")], EXPECTED) + + def test_lds_ops_run_in_lane_0_only(self): + with open(os.path.join(ROOT, "runtime", "test", "shaders", "cs_w32_lds_add_f32.asm"), encoding="utf-8") as f: + lines = [ln.strip() for ln in f if ln.strip() and not ln.startswith(";")] + self.assertEqual(lines[0], "v_cmpx_eq_u32_e32 0, v0") + + +if __name__ == "__main__": + unittest.main() From 654c07e678a55f6c1610a995ad7dc560e7413ad5 Mon Sep 17 00:00:00 2001 From: Luiz Neves Date: Sun, 22 Nov 2026 22:33:06 -0300 Subject: [PATCH 2/2] test_lds_add_f32_fixture: runs under python -I; the double sum is exact for these inputs only @justr4mzi: python -I on the file failed with ModuleNotFoundError: support, as the folder was not on sys.path (now inserted, as test_cs_shared_memory_limit does). @tupacfan04: a double sum of two binary32 values is not exact in general; the docstring says it is for this file's inputs. --- tests/semantic/test_lds_add_f32_fixture.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/semantic/test_lds_add_f32_fixture.py b/tests/semantic/test_lds_add_f32_fixture.py index cc967e26ed..3fb4f61f62 100644 --- a/tests/semantic/test_lds_add_f32_fixture.py +++ b/tests/semantic/test_lds_add_f32_fixture.py @@ -4,19 +4,24 @@ runtime/test/shaders/cs_w32_lds_add_f32.asm (derivations in its header) stores eight words from lane 0. This runs its fixture as one wave32 group through spirv_mini_interp with the buffer vk_compute_test gives it (every byte 0xEE, a V# -with num_records 0xFFFFFFFF), checks the words against a reference that adds in double precision (exact for two -binary32 values) and rounds once to binary32, that check.py and scripts/run_gpu_tests.py expect the same words, and -that EXEC is cut to lane 0 before the first LDS op. +with num_records 0xFFFFFFFF), checks the words against a reference that adds in double precision and rounds once +to binary32 (exact for these inputs, whose exponents are close: in general a double sum of two binary32 values can +round, and rounding it again to binary32 could then differ from one rounding), that check.py and +scripts/run_gpu_tests.py expect the same words, and that EXEC is cut to lane 0 before the first LDS op. """ import os import re import struct +import sys import unittest -import support -import spirv_mini_interp as si - HERE = os.path.dirname(os.path.abspath(__file__)) +if HERE not in sys.path: + sys.path.insert(0, HERE) # python -I leaves the script's folder off sys.path + +import support # noqa: E402 (support puts tools/ on sys.path, honouring LEONIDA_TOOLS_DIR) +import spirv_mini_interp as si # noqa: E402 + ROOT = os.path.dirname(os.path.dirname(HERE)) FSSM = bytearray(0x148) @@ -35,7 +40,7 @@ def bits(x): def add(m, d): - """binary32 m + d, rounded once to nearest even; past FLT_MAX it is +-inf.""" + """binary32 m + d, rounded to nearest even (the double sum is exact for this file's inputs); past FLT_MAX +-inf.""" total = f32(m) + f32(d) try: return bits(total)