"""Value regressions for RDNA2's binary64 round-to-integral instructions.""" import contextlib import math import shutil import struct import subprocess import tempfile import unittest from pathlib import Path from unittest.mock import patch import support import spirv_mini_interp def words(value): return struct.unpack("> 32:#x}", instruction, "exp mrt0 v4, v5, v4, v5 done vm", "s_endpgm", ]))[:2] return low | high << 32 @contextlib.contextmanager def driver_that_quiets_and_flushes(): """The interpreter's double-precision Trunc, Ceil, RoundEven and Floor, replaced by what Vulkan allows a driver and what two of them were measured to do (cs_w32_round_f64): a NaN operand comes back with its quiet bit set, sign and payload kept (NVIDIA 620.70, llvmpipe), and a subnormal operand is read as a zero of its sign (llvmpipe; the module declares no DenormPreserve for 64 bits). Every other operand is rounded as before. Yields the list of operands the four functions were called with.""" calls = [] def driver(function): def rounded(x): calls.append(x) if x != x: bits = struct.unpack("