Repository navigation
perf(shader): let APS5_FAST_F32 compile f32 arithmetic with host float rules - #10720
Conversation
|
This pull request is labeled |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed exact head 7d6cc57fdf7fb9b6ad5e683807329d4a8a24d50a. The opt-in switch is applied consistently to NaN-result selection, denormal handling, and shader-cache versioning; the PR reports paired focused Vulkan tests and performance traces. Local diff-check and conventions pass; I could not run the GPU tests in this environment. One integration blocker remains: open #4287 changes the body of nanResultF32, where this PR adds its early return. The description says whichever lands second should preserve the line, but the checklist says Depends on: none and does not record an agreed order. CONTRIBUTING requires coordinating overlapping changes and recording the dependency/order. Please confirm the plan with the other author and update the checklist.
|
Linux/RADV, first AMD run — main
No On the default-vs-opt-in question: at least for this test, host rules are correct on RADV across GCN5/RDNA2/RDNA3. I can't speak to the perf tradeoff without AI-assisted: yes. |
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
MarcZX10
left a comment
There was a problem hiding this comment.
The implementation is opt-in, changes the shader cache key, and the author reports paired focused Vulkan runs with validation enabled and no VUIDs, so the change itself is well scoped. I would keep the default decision with maintainers as the PR does. One evidence caveat for the performance data: both trace captures say trace_dropped: true, with hundreds of thousands of lost events on the queue worker and draw committer. GPU-busy-per-present is still reported by the trace tool, but please clarify whether that aggregate remains complete when event buffers fill, and attach/compare tools/trace_digest.py summaries as the repository performance rule requires. The current PR text has detailed summaries but no visible trace-digest output in the body; I cannot validate the 26% GPU-busy claim from the pasted excerpts alone. I am leaving this as a non-blocking comment pending that clarification.
|
I downloaded the attached trace archive and ran Please include the digest outputs in the PR report and clarify whether |
MarcZX10
left a comment
There was a problem hiding this comment.
Re-reviewed exact head 7d6cc57fdf7fb9b6ad5e683807329d4a8a24d50a. The checklist now records Depends on: #4287, matching the stated merge order. The attached archive and body include the trace_digest.py summaries for both arms, with dropped-event counts and the higher p90/p99 for the fast arm disclosed. I checked the current trace implementation: gpu_busy_ms_per_present is derived from the Vulkan present counters, which accumulate completed GPU timestamp batch durations; it does not use the bounded per-thread event buffers that dropped queue-worker and draw-committer slices in these traces. The JSON also does not report the GPU range snapshot as dropped. That supports the reported aggregate GPU-busy metric while limiting the dropped traces’ completeness for CPU slice attribution. The PR reports paired main/change validation runs and no VUIDs on the RTX 2080 Ti; I did not rerun the Vulkan tests locally. Product jobs are skipped by hosted PR policy. The opt-in remains off by default as described. No remaining review blocker found.
|
@Meh7an Thanks for asking. Exact stays the default: titles should get RDNA's results unless someone opts out, and a quarter of the GPU time on one page doesn't change that for me. Host rules are fine as the opt-in through |
…nversions boykopovar#10720 skips the emulated f32 denormal flush with an early return near the end of f32DenormalFlushFor. On boykopovar#10720's base, v_min_f32, v_max_f32, v_min3_f32, v_max3_f32, v_med3_f32 and the f32 conversions (v_cvt_i32_f32, v_cvt_u32_f32, v_cvt_rpi_i32_f32, v_cvt_flr_i32_f32, v_frexp_exp_i32_f32, v_cvt_f64_f32, v_cvt_pknorm_i16_f32, v_cvt_pknorm_u16_f32, v_cvt_pk_u8_f32, v_cvt_pkrtz_f16_f32 and v_cvt_f16_f32) reached that return. Since boykopovar#6009 (min and max in f32 denormal modes 1 and 2) and boykopovar#10595 (conversions in the same modes) they return from the switch first, so with APS5_FAST_F32 set they still flushed. Under APS5_FAST_F32 they now return no flush where they returned one, as on boykopovar#10720's base. The f32 compares, which share the conversions' return since boykopovar#10595, get their own return again and keep their flush, as they did on boykopovar#10720's base; so do the legacy mad and mac forms and the add, sub and mul forms in denormal modes 1 and 2. With the switch off the translation is unchanged.
|
A macOS data point for the opt-in, with a title where the exact rules dominate the frame: SudokuZen (PPSA50001) runs its main menu 2.6× faster with Setup: Apple M4, macOS 27.0.1, MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0), x86-64 Release under Rosetta 2. The tree is {"commit":"642de4f3cf0a","dirty":false,"env":{"APS5_TRACE_SECONDS":"20:10"},"gpu":"Apple M4","driver":"MoltenVK 1.4.2","os":"Darwin 27.0.0","title_id":"PPSA50001","resolution":"3840x2160","presents":166,"frame_ms":{"p50":59.764,"p90":62.323,"p99":67.39,"max":67.85},"gpu_busy_ms_per_present":58.065,"trace_dropped":false}
{"commit":"642de4f3cf0a","dirty":false,"env":{"APS5_FAST_F32":"1","APS5_TRACE_SECONDS":"20:10"},"gpu":"Apple M4","driver":"MoltenVK 1.4.2","os":"Darwin 27.0.0","title_id":"PPSA50001","resolution":"3840x2160","presents":433,"frame_ms":{"p50":22.946,"p90":24.499,"p99":26.495,"max":43.458},"gpu_busy_ms_per_present":21.001,"trace_dropped":false}Frame p50 59.8 → 22.9 ms (16.7 → 43.7 FPS), GPU busy per present 58.1 → 21.0 ms. Neither trace dropped events. The two Where the time goes. The menu's animated backdrop is one pixel shader (code at Tests on the same build with A note for anyone profiling this on MoltenVK: AI-assisted: yes |
✅ NVIDIA GPU test: passedPR head
Failing on main too (4, not counted against this PR)Validated but not compared (1, not in the main baseline's validation pass)Validation IDs already present on main (4 IDs in 426 tests)Skipped (50)ReproduceAutomated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
What
APS5_FAST_F32(set to anything but0) compiles f32 arithmetic with the host GPU's float rules instead of emulating RDNA's.nanResultF32returns the instruction's host result. Onmainit picks RDNA's NaN: the first NaN source, quieted in IEEE mode; else0xffc00000when the result is NaN.f32DenormalFlushForasks for no software flush. Onmainit emulates RDNA's denormal flush in software wherever the device's own flush (ProbeFloat32FlushToZero) does not cover the instruction.SourceVersiondiffers).Results differ from RDNA's only when a result is a NaN (its sign and payload bits) or a denormal (the host's rules decide whether it is flushed). The switch is off by default, so nothing changes unless it is set.
A question for the maintainers. On the page measured below, the exact rules cost about a quarter of the GPU time. Would you take host rules as the default, with an exact opt-in, the way
v_rcp_f32uses the driver's division unlessAPS5_EXACT_RCPis set? I kept it opt-in here so that is your call. If you'd rather have it as the default, I'll flip it in this PR and rename the switch.Test.
agc_driver_f32_arithmetic_nan_fast(new) runs the f32 NaN program ofagc_driver_f32_arithmetic_nanwithAPS5_FAST_F32=1. Every non-NaN result must match RDNA as before; a result that RDNA gives as a NaN only has to be a NaN. Without that allowance it fails at lane 0'sv_add_f32, which returns0x7fffffff(NVIDIA's NaN) where RDNA returns0x7f812345. The default test is unchanged.Related. Both of these stay exact; this switch is for users who accept host NaN payloads and denormals:
tools/pr_overlap.pylists one conflict: #4287 rewrites the body ofnanResultF32, where this PR adds an early return as the first line. The proposed order is #4287 first (comment). Once it merges, this PR rebases onto it and keeps that line as the function's first statement. It found no other overlap. Of the PRs it could not compare, #5925, #6858 and #6924 only callShaderDiskCache::SourceVersion(), which returns each mode's own version.Tested
Windows 11 Pro 10.0.26300, NVIDIA GeForce RTX 2080 Ti, driver 617.14, i9-9900K, on
main29f539a.Sonic Origins Plus (PPSA05324), Sonic 2 page of the main menu,
main's defaults otherwise. One build, two arms: the default (exact) andAPS5_FAST_F32=1. Each arm got one warm-up boot (each mode has its own shader cache version), then one traced round (APS5_TRACE_SECONDS=200:15). The build is 991731d42276, which differs from this PR's head only in the test and its registration.Driver.Packet(ms/frame)APS5_FAST_F32=1ctest(2159 tests) onmainplus this PR: everything passes exceptagc_driver_depth_plane_partial_store("repeated lookups of the first layer of an unchanged array proved no refresh"), which fails the same way on plainmain29f539a on this machine.ctest --test-dir build -R "f32|f16|nan|denormal|rcp|float|fma" -VwithANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation: 88/88 onmain, 89/89 on this PR (the extra one isagc_driver_f32_arithmetic_nan_fast). Neither log haswas not found but was requested by env var VK_INSTANCE_LAYERS, and neither has aVUID-line.The two summaries and their digests (both traces are attached):
fast-f32-s2-traces.zip
default (exact)
seconds 200:15 from present 3536: 179 presents, frame p50 82.9 / p90 91.5 / p99 99.3 / max 100.9 ms, GPU busy 68.7 ms per present
NVIDIA GeForce RTX 2080 Ti, NVIDIA 617.14, Windows 10.0.26300, 3840x2160, commit 991731d42276, dropped: yes
{"commit":"991731d42276","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"200:15"},"gpu":"NVIDIA GeForce RTX 2080 Ti","driver":"NVIDIA 617.14","os":"Windows 10.0.26300","cpu":"Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz","cpu_threads":16,"memory_mib":32684,"title_id":"PPSA05324","title":"Sonic Origins","content_version":"02.002.000","resolution":"3840x2160","window":{"spec":"seconds 200:15","first_present":3536,"ms":15057.73},"presents":179,"frame_ms":{"p50":82.867,"p90":91.489,"p99":99.282,"max":100.922},"gpu_busy_ms_per_present":68.708,"worker_busy_pct":{"queue worker 0x0":97.332},"top_phases_ms_per_frame":{"Driver.Packet":81.817,"Driver.Packet.draw":63.141,"Graphics.Draw":62.47,"Driver.Draw":62.079,"Graphics.Draw.draw_and_resource_release":51.314,"Driver.Draw.shader_compile_and_link":41.913,"Shader.DrawStage":31.065,"Driver.Present":27.175},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.65,"events_lost":424742,"totals_full":false},"draw committer":{"events_full_after_s":12.969,"events_lost":42124,"totals_full":false}},"trace":"aps5-trace-991731d42276-35344.json.gz"}Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): batch 68.6, Graphics.Draw 30.9, Driver.Present 27.2, VideoOut.Flip 27.2, VideoOut.Flip.present 27.0, Driver.Present.render_fence_wait 26.6, Vulkan.Retire 26.6, Vulkan.Retire.wait 26.6, Graphics.Draw.draw_and_resource_release 25.1, Driver.Packet 16.3
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
APS5_FAST_F32=1
seconds 200:15 from present 3652: 177 presents, frame p50 82.5 / p90 94.9 / p99 110.9 / max 115.6 ms, GPU busy 50.5 ms per present
NVIDIA GeForce RTX 2080 Ti, NVIDIA 617.14, Windows 10.0.26300, 3840x2160, commit 991731d42276, dropped: yes
{"commit":"991731d42276","dirty":false,"env":{"APS5_FAST_F32":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"200:15"},"gpu":"NVIDIA GeForce RTX 2080 Ti","driver":"NVIDIA 617.14","os":"Windows 10.0.26300","cpu":"Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz","cpu_threads":16,"memory_mib":32684,"title_id":"PPSA05324","title":"Sonic Origins","content_version":"02.002.000","resolution":"3840x2160","window":{"spec":"seconds 200:15","first_present":3652,"ms":15012.498},"presents":177,"frame_ms":{"p50":82.519,"p90":94.855,"p99":110.893,"max":115.578},"gpu_busy_ms_per_present":50.452,"worker_busy_pct":{"queue worker 0x0":97.16},"top_phases_ms_per_frame":{"Driver.Packet":82.34,"Driver.Packet.draw":63.581,"Driver.Draw":62.584,"Graphics.Draw":62.527,"Graphics.Draw.draw_and_resource_release":51.211,"Driver.Draw.shader_compile_and_link":42.519,"Shader.DrawStage":31.644,"Shader.DrawStage.materialize":19.099},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.696,"events_lost":427832,"totals_full":false},"draw committer":{"events_full_after_s":13.125,"events_lost":37963,"totals_full":false}},"trace":"aps5-trace-991731d42276-33916.json.gz"}Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): batch 50.4, Graphics.Draw 32.1, Graphics.Draw.draw_and_resource_release 26.4, Driver.Present 17.7, VideoOut.Flip 17.7, VideoOut.Flip.present 17.6, Driver.Present.render_fence_wait 17.2, Vulkan.Retire 17.2, Vulkan.Retire.wait 17.2, Driver.Packet 17.0
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)