mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 23:18:37 +00:00
check.py: run cs_w64x_partial at subgroup 32 under wave64 emulation (TEST-20)
partial_wave_test always set VKC_SUBGROUP_SIZE=64. With LEONIDA_W64_EMULATE=1 the shader is translated for any subgroup width, and on AMD, where 64 is available, the emulated path was never run at 32 (#166, RX 6700 XT entry). Under emulation it now asks for 32; without emulation it still asks for 64.
This commit is contained in:
@ -83,12 +83,13 @@ class Skip(str):
|
||||
|
||||
def partial_wave_test(tools, spirv, name, expected_words):
|
||||
"""A group smaller than a wave: run with subgroup size 64 requested (no full subgroups); None if the device
|
||||
has no 64-wide subgroup (unless LEONIDA_W64_EMULATE=1)."""
|
||||
has no 64-wide subgroup. With LEONIDA_W64_EMULATE=1 it asks for 32 instead, the width the emulation is for, so
|
||||
a device that defaults to 64 (AMD) runs the emulated path at 32 too (#166)."""
|
||||
shader = os.path.join(spirv, name + ".spv")
|
||||
if not os.path.isfile(shader):
|
||||
return f"missing {name}.spv"
|
||||
old = os.environ.get("VKC_SUBGROUP_SIZE")
|
||||
os.environ["VKC_SUBGROUP_SIZE"] = "64"
|
||||
os.environ["VKC_SUBGROUP_SIZE"] = "32" if W64_EMULATED else "64"
|
||||
try:
|
||||
code, out = run(os.path.join(tools, "vk_compute_test" + EXE), shader, "1", "dump")
|
||||
finally:
|
||||
|
||||
50
tests/test_partial_wave_subgroup.py
Normal file
50
tests/test_partial_wave_subgroup.py
Normal file
@ -0,0 +1,50 @@
|
||||
"""TEST-20: check.py's partial-wave test asks vk_compute_test for subgroup size 64 natively and for 32 under
|
||||
LEONIDA_W64_EMULATE=1, so a device that defaults to 64 (AMD) also runs the emulated path at 32."""
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "runtime" / "test" / "shaders"))
|
||||
import check
|
||||
|
||||
NAME, WANT = check.W64X_PARTIAL[0]
|
||||
|
||||
|
||||
class PartialWaveSubgroupSize(unittest.TestCase):
|
||||
def run_partial(self, emulated, max_subgroup=64):
|
||||
asked = []
|
||||
|
||||
def harness(_tool, _shader, *_args):
|
||||
asked.append(os.environ.get("VKC_SUBGROUP_SIZE"))
|
||||
return 0, f"device: gpu (subgroup 32..{max_subgroup})\nout[0..7] = " + " ".join(map(str, WANT)) + "\n"
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
(Path(tmp) / f"{NAME}.spv").touch()
|
||||
with (patch.object(check, "run", side_effect=harness), patch.object(check, "W64_EMULATED", emulated),
|
||||
patch.dict(os.environ, {"VKC_SUBGROUP_SIZE": "16"})):
|
||||
result = check.partial_wave_test(tmp, tmp, NAME, WANT)
|
||||
restored = os.environ.get("VKC_SUBGROUP_SIZE")
|
||||
return result, asked, restored
|
||||
|
||||
def test_native_asks_for_64(self):
|
||||
result, asked, restored = self.run_partial(emulated=False)
|
||||
self.assertEqual((result, asked, restored), ("", ["64"], "16"))
|
||||
|
||||
def test_emulated_asks_for_32(self):
|
||||
result, asked, restored = self.run_partial(emulated=True)
|
||||
self.assertEqual((result, asked, restored), ("", ["32"], "16"))
|
||||
|
||||
def test_emulated_runs_on_a_32_wide_device(self):
|
||||
result, asked, _ = self.run_partial(emulated=True, max_subgroup=32)
|
||||
self.assertEqual((result, asked), ("", ["32"]))
|
||||
|
||||
def test_native_skips_without_64_wide_subgroups(self):
|
||||
result, _, _ = self.run_partial(emulated=False, max_subgroup=32)
|
||||
self.assertIsNone(result)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user