Repository navigation
feat(shader): decode s_setkill as s_endpgm - #821
ebosido444-ai wants to merge 2 commits into
Conversation
added3c to
3c4870a
Compare
|
Thanks for picking these up. I measured them on RDNA2 hardware (gfx1035, same SOPP encodings as gfx1013) when I did #436, and left them out on purpose. Some of the lowerings here don't match what the hardware does:
#771 implements the same four opcodes (CONTRIBUTING: one open PR per function), so one of the two will need to give way. I'd suggest keeping |
|
Measured beats read — all five points accepted, thanks for the gfx1035 data. Reworking to your suggested shape, pushed shortly: |
3c4870a to
b4da063
Compare
|
Thanks, this matches what I measured. Yes to the execution probe: it's ready, and you're welcome to take it. It reuses patchdiff --git a/core/libs/prx/libSceAgcDriver/tests/execution/ScalarProgramEnd.cpp b/core/libs/prx/libSceAgcDriver/tests/execution/ScalarProgramEnd.cpp
index a4362f4c..335a99a9 100644
--- a/core/libs/prx/libSceAgcDriver/tests/execution/ScalarProgramEnd.cpp
+++ b/core/libs/prx/libSceAgcDriver/tests/execution/ScalarProgramEnd.cpp
@@ -30,6 +30,11 @@ alignas(256) constexpr std::array<std::uint32_t, 30> Code{
0xe0701000, 0x80010603, 0xbf9b0000, 0xe0701004, 0x80010603, 0xbf810000,
};
+alignas(256) constexpr std::array<std::uint32_t, 20> SetkillCode{
+ 0x34020084, 0x34060086, 0xe0301000, 0x80000401, 0xbf8c3f70, 0x4a0a0881, 0x7e0c02ff, 0x00000bad, 0xbf060000, 0xbf840007,
+ 0xbf840003, 0xe0701000, 0x80010503, 0xbf8b0000, 0xe0701000, 0x80010603, 0xbf8b0001, 0xe0701004, 0x80010603, 0xbf810000,
+};
+
alignas(256) constexpr std::array<std::uint32_t, 2> RoundTowardZeroCode{0xbfa40003, 0xbf810000};
void Fill(std::uint32_t tid, std::uint32_t* words) { words[0] = tid * 0x01010101u + 7u; }
@@ -74,7 +79,7 @@ void ExpectRefused(AgcDriver::VulkanDevice& device) {
Require(refused, "scalar program end: s_round_mode 3 was translated");
}
-void Run(AgcDriver::VulkanDevice& device) {
+void Run(AgcDriver::VulkanDevice& device, std::span<const std::uint32_t> code) {
for (std::uint32_t tid = 0; tid < Threads; ++tid) Fill(tid, &Input[tid * Inputs]);
Output.fill(0xdeadbeefu);
std::vector<std::uint32_t> userData(8, 0u);
@@ -82,7 +87,6 @@ void Run(AgcDriver::VulkanDevice& device) {
const auto output = BufferDescriptor(Output.data(), static_cast<std::uint32_t>(Output.size() * 4u));
std::copy(input.begin(), input.end(), userData.begin());
std::copy(output.begin(), output.end(), userData.begin() + 4);
- const std::span<const std::uint32_t> code(Code);
const std::array<ShaderRecompiler::MemoryRegion, 1> memory{{{reinterpret_cast<std::uintptr_t>(code.data()), std::as_bytes(code)}}};
const auto result = ShaderRecompiler::Recompile(Request(device, code, userData, memory));
device.Dispatch(result, 1, 1, 1, {}, reinterpret_cast<std::uintptr_t>(code.data()));
@@ -104,7 +108,9 @@ int main() {
try {
const auto device = OpenVulkanTestDevice();
if (!device) return VulkanTestSkipped;
- Run(*device);
+ Run(*device, Code);
+ Check();
+ Run(*device, SetkillCode);
Check();
ExpectRefused(*device);
std::puts("scalar program end tests passed"); |
b4da063 to
744b61f
Compare
|
Took the probe exactly as you provided it (744b61f): ScalarProgramEnd.cpp gains the SetkillCode kernel and the Run(code) parameterisation, and per your note core/libs/tests/ScalarSetkill.cpp plus its CMake block are deleted — the execution path covers decoding and fails with unsupported SOPP opcode 11 without the decoder line. Your RADV/lavapipe/CI runs stand as the test evidence in the body; I could not improve on them. Thank you for the measurement work and the patch. |
…halt-kill # Conflicts: # docs/dev/TechnicalDebt.md
|
Thanks for reworking this to match the hardware measurement. The same change landed on |
What
s_setkill(SOPP 0x0b) makes shaders die at translation today (unsupported SOPP opcode). Measured on RDNA2 hardware (gfx1035, same SOPP encodings) by adriadam10:s_setkillwith ANY immediate ends the wave exactly likes_endpgm— a store before it is visible, nothing after it runs — so this decodes it asSEndpgm. Program slicing, CFG terminators and the SPIR-V path are shared withs_endpgmby construction, andS_SETKILLis credited intools/progress.pythrough the existingOPCODE_VARIANTSseam ofSEndpgm, thes_endpgm_savedpattern from #436. Shader progress: 1125 to 1126 out of 1166.s_sethalt,s_sendmsghaltands_code_endare deliberately not implemented and keep throwing as on main: the measurement shows halt freezes the wave until a debugger or trap handler resumes it (no Vulkan equivalent — discard or termination would pretend a plausible result wheremainis explicit),s_sendmsghalthalts after its message the same way, ands_code_endpadding never reaches translation (DecodeRdnaProgramstops ats_endpgm) while executing it hangs the wave. All three are recorded in the updateddocs/dev/TechnicalDebt.mdentry with the measurement and ISA references. No shared path changes — one decode row that is a no-op for every other opcode.Tested
Windows 11:
core/libs/tests/ScalarSetkill.cpp(registered asscalar_setkillbesidescalar_saveexec) checks decode identity withSEndpgmfor immediates 0, 1 and 0xFFFF and that translation takes theSEndpgmpath; scoped CMake/CTest suite (winlibs GCC 15.2.0 per BUILD.md):scalar_setkill,scalar_saveexec,scalar_bitcount64,guest_rtc— 4/4 passed. After the alias there is no distinct instruction left to execute, so this argues covered-by-existing instead of adding totests/execution/(#765 precedent).tools/progress.py: shaders 1125 -> 1126 out of 1166.Checklist
main; feat(shader): decode s_setkill as s_endpgm #771 implements the same four opcodes with rows the hardware measurement rules out and is CONFLICTING with main — disposition discussed with adriadam10 in the thread; one open PR per function will hold either wayNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository