From 1dcdca149808f442138e0a8befaedc31750dfb73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Franch?= Date: Sat, 10 Oct 2026 00:16:57 +0200 Subject: [PATCH] test(agc): pin v_div_fmas_f64 with VCC set on subnormal operands and results Expected values measured on RDNA2 (gfx1035) with the HW oracle at IEEE=0 and IEEE=1, f64 denormals kept. Co-Authored-By: Claude --- .../tests/execution/F64FmaSubnormals.cpp | 53 +++++++++++++++---- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/core/libs/prx/libSceAgcDriver/tests/execution/F64FmaSubnormals.cpp b/core/libs/prx/libSceAgcDriver/tests/execution/F64FmaSubnormals.cpp index 7e0dc61ce..c6b2934fa 100644 --- a/core/libs/prx/libSceAgcDriver/tests/execution/F64FmaSubnormals.cpp +++ b/core/libs/prx/libSceAgcDriver/tests/execution/F64FmaSubnormals.cpp @@ -26,6 +26,11 @@ alignas(256) constexpr std::array Code{ 0x04220d04, 0xe0741000, 0x80010c03, 0xbf810000, }; +alignas(256) constexpr std::array FmasCode{ + 0x34020085, 0x34060083, 0xe0381000, 0x80000401, 0xe0381010, 0x80000801, 0xbf8c3f70, 0xbeea03c1, + 0xd570000c, 0x04220d04, 0xe0741000, 0x80010c03, 0xbf810000, +}; + constexpr std::uint64_t Rows[Threads][4] = { {0xaf909f1570e40fb2ull, 0x10697a78dd1df49bull, 0x8000000000000000ull, 0x800d3be6095b3463ull}, {0x1e50511fd30f5d67ull, 0x24c92a1b12df5283ull, 0x8329a9b24976c10bull, 0x0006cc7690f01937ull}, @@ -61,6 +66,29 @@ constexpr std::uint64_t Rows[Threads][4] = { {0xa000000000000001ull, 0x1fffffffffffffffull, 0x0010000000000000ull, 0x8000000000000000ull}, }; +constexpr std::uint64_t FmasRows[][4] = { + {0xcee37832c306ee31ull, 0x80017e95cd7d98dfull, 0x8c168438ac98afa4ull, 0x06cd18c0555dceefull}, + {0x800e8b91a326e01dull, 0xd020fb9f53a2df2cull, 0x8cb514f5ff6d74b0ull, 0x083ee09fedab559aull}, + {0xfc21916e447cf802ull, 0x8004eec859174483ull, 0x3be2fe907aa80074ull, 0x3426da145be5eaacull}, + {0x6456b4d74e778407ull, 0x0000000000000112ull, 0x20280ac49e7f906cull, 0x19b84d8e7e014d9full}, + {0x3b87a9e17b60d8beull, 0x0c5959dcff86b48aull, 0x026239792b5377a2ull, 0x0004afcb04199627ull}, + {0xaf25fa06e8714b4bull, 0x18d2b6bb683e8122ull, 0x02a53f820f7c716bull, 0x800cda229eb9a09dull}, + {0xb99c5fe31c736fbbull, 0x8e5264264dcfc027ull, 0x8022aa8efefbe52cull, 0x0008275eae4b3d41ull}, + {0xc6fdfbc0001ad5dfull, 0x00ffcab17e745bd1ull, 0x82e0e3a0b85211a8ull, 0x800ee4e6bd8a79e5ull}, + {0xc1d1a6cfa76ad3b9ull, 0x862ba38c1492703full, 0x017130645c1851d5ull, 0x000f3ef62c247005ull}, + {0xada41786a4b824bcull, 0x1a554baa4a83fe63ull, 0x0134fb8e603406d4ull, 0x800d5ef26b6f7a29ull}, + {0xb81b70578b6c14b9ull, 0x8fcdd6775e710cc1ull, 0x829c666c28b85110ull, 0x0006656d3ea3b537ull}, + {0x2c256baa0ef1c91bull, 0x9baa7695febd5f53ull, 0x82d3dfc5a191618bull, 0x800236db72e217c3ull}, + {0x355013dab21e2539ull, 0x1296e6732f928ca7ull, 0x82f4e48c5e9c126cull, 0x0005c0b776cad66bull}, + {0xc458817a2d2ea918ull, 0x03a473fd45d66f08ull, 0x03240e0c4f7cfcc4ull, 0x800fa9bfa078e4f1ull}, + {0x33291df738c3f676ull, 0x146a0194f3933c51ull, 0x0120115306c4e7b2ull, 0x000028d32d6f3f07ull}, + {0xb1d797d703ad9014ull, 0x9613cb63b23f1b8bull, 0x0244b2cb24e6fb3aull, 0x00074c0e33ad5c9dull}, + {0x4656b4266997b7f2ull, 0x819765c0b9bfcad0ull, 0x03c9a52d2b9f1094ull, 0x80084cd678e92eefull}, + {0x4513191709caec8cull, 0x02d3b5ddc4ac6b05ull, 0x826384dfaf4b9e81ull, 0x0005e1b7f963c7dbull}, + {0xba6ec9ec81f6efb7ull, 0x8d785fa355446f4eull, 0x0279c121fe09c0aaull, 0x0005dcdd7f8c7cd3ull}, + {0xbe667b0282fcc03cull, 0x897ce8a400290c2cull, 0x0378775e473d7a50ull, 0x000513c44ed72187ull}, +}; + std::array BufferDescriptor(const void* data, std::uint32_t bytes) { const auto address = reinterpret_cast(data); return {static_cast(address), static_cast((address >> 32u) & 0xffffu), bytes, 0x01016facu}; @@ -72,11 +100,13 @@ std::string Hex(std::uint64_t value) { return text; } -void Run(AgcDriver::VulkanDevice& device) { - for (std::uint32_t tid = 0; tid < Threads; ++tid) { +template +void Run(AgcDriver::VulkanDevice& device, const std::array& program, const std::uint64_t (&rows)[Count][4]) { + Input.fill(0u); + for (std::uint32_t tid = 0; tid < Count; ++tid) { for (std::uint32_t operand = 0; operand < 3; ++operand) { - Input[tid * Inputs + operand * 2] = static_cast(Rows[tid][operand]); - Input[tid * Inputs + operand * 2 + 1] = static_cast(Rows[tid][operand] >> 32u); + Input[tid * Inputs + operand * 2] = static_cast(rows[tid][operand]); + Input[tid * Inputs + operand * 2 + 1] = static_cast(rows[tid][operand] >> 32u); } } Output.fill(0xdeadbeefu); @@ -85,7 +115,7 @@ void Run(AgcDriver::VulkanDevice& device) { const auto output = BufferDescriptor(Output.data(), static_cast(Output.size() * 4u)); std::copy(input.begin(), input.end(), userData.begin()); std::copy(output.begin(), output.end(), userData.begin() + 4); - const std::span code(Code); + const std::span code(program); const std::array memory{{{reinterpret_cast(code.data()), std::as_bytes(code)}}}; const ShaderRecompiler::ShaderComputeStageInfo compute{{Threads, 1, 1}, 0u, {false, false, false}, false, 1}; ShaderRecompiler::RecompileRequest request{ @@ -100,10 +130,11 @@ void Run(AgcDriver::VulkanDevice& device) { device.WaitIdle(); } -void Check() { - for (std::uint32_t tid = 0; tid < Threads; ++tid) { +template +void Check(const char* name, const std::uint64_t (&rows)[Count][4]) { + for (std::uint32_t tid = 0; tid < Count; ++tid) { const std::uint64_t actual = Output[tid * Results] | (static_cast(Output[tid * Results + 1]) << 32u); - Require(actual == Rows[tid][3], "v_fma_f64: lane " + std::to_string(tid) + " fma(" + Hex(Rows[tid][0]) + ", " + Hex(Rows[tid][1]) + ", " + Hex(Rows[tid][2]) + ") is " + Hex(actual) + ", expected " + Hex(Rows[tid][3])); + Require(actual == rows[tid][3], std::string(name) + ": lane " + std::to_string(tid) + " (" + Hex(rows[tid][0]) + ", " + Hex(rows[tid][1]) + ", " + Hex(rows[tid][2]) + ") is " + Hex(actual) + ", expected " + Hex(rows[tid][3])); } } @@ -113,8 +144,10 @@ int main() { try { const auto device = OpenVulkanTestDevice(); if (!device) return VulkanTestSkipped; - Run(*device); - Check(); + Run(*device, Code, Rows); + Check("v_fma_f64", Rows); + Run(*device, FmasCode, FmasRows); + Check("v_div_fmas_f64 with VCC set", FmasRows); std::puts("v_fma_f64 subnormal tests passed"); return 0; } catch (const std::exception& error) {