Repository navigation
D3D12.X: XCL_GPU_PROFILE logs the console programs that take GPU time - #1766
wondercrash wants to merge 1 commit into
Conversation
|
Full-suite run, since this PR has no test report yet. Tested exact head Tested
Not tested
AI use
|
PR #1766 compatibility verification on Intel Arc A770Tested Clean detached head
Full workspace suite
Not tested Per-program timing rows and long-run profiling, retail-title smoke or a main-branch baseline, sample-data paths, the D3D12 debug layer (DLL absent), and other adapters. AI use T3 Code / Codex ( |
A retail title's intro cutscene ran at 0.3-0.5 fps with the GPU at 98-100 %, and nothing in XCL measured GPU time per draw or dispatch: the logs could not say which console programs the GPU time went to. With XCL_GPU_PROFILE=1 each translated draw, dispatch and ExecuteIndirect (and an ExecuteIndirect with a PC pipeline) gets a timestamp query on its PC list before and after it, resolved right behind it into a readback ring of 2^17 pairs. Nothing on the CPU waits: a reporter thread takes the written pairs every 100 ms, and every 2 s logs the 15 console programs with the most GPU time (every 20 s also since the start): hash, kind, calls, total and longest ms, group counts of the longest call, and for compute the thread group size, wave64 / split form, code and DXIL size. Ticks are converted with a title queue's GetTimestampFrequency. Off by default; with it off each op pays one LazyLock read. Overlapping queues are each charged in full, so the sum can exceed wall time; bundles get no stamps; a recording run again without a Reset is counted once. The resolve waits on the GPU for the op to finish, so with the profile on a queue runs its ops one after the other. The unit tests cover the pair states and the ranking. Assisted-by: omp (Claude Opus 5.5)
c433edb to
5a3fc0c
Compare
Diagnostics only, off by default. Nothing in XCL measures GPU time per draw or dispatch, so a run where the GPU is busy but the title crawls cannot say which console programs the time goes to. With
XCL_GPU_PROFILE=1every draw, dispatch and ExecuteIndirect of console code gets a GPU timestamp pair, and every 2 s the log names the 15 console programs that took the most GPU time.This is how we found why a retail title's intro cutscene ran at 0.3-0.5 fps with the GPU at 98-100 %: full-screen compute passes of 150-580 ms each (e.g.
CS 79d178afa02abd49 Dispatch; 8x8x1 threads, wave32, ...: 1 call(s), longest 161.6 ms (320x180x1 groups)), which led to the cause (a separate change).Related, and different: #1065 (
XCL_GPU_TIMING) timesExecuteCommandListson the CPU; #1323 (XCL_GPU_CULPRIT) marks dispatches to name the ones a stalled queue has not finished; #1592 names the pipeline at a DRED fault; #996 is about timestamps on hosts without GPU timestamps. None measures GPU time per program.What is in it
crates/xcl/src/hle/d3d12x/gpu_profile.rs(new):begin/endrecordEndQuery(TIMESTAMP)before and after the op and aResolveQueryDataof the pair into a readback ring (2^17 pairs; one query heap and one readback buffer, made at the first timed op); a reporter thread takes the written pairs every 100 ms and logs every 2 s (every 20 s also the totals since the start): hash, kind, calls, total and longest ms, the group counts of the longest call, and for compute the thread group size, wave64 / split form, code and DXIL size. Ticks are converted with a title queue'sGetTimestampFrequency(note_queue). Tests:a_pair_counts_once_both_stamps_are_written_and_in_order,programs_are_ranked_by_their_total_and_keep_their_longest_call.bind.rs,console_list.rs: the timed call sites (Dispatch, console-list Dispatch, both ExecuteIndirect paths, DrawInstanced, DrawIndexedInstanced). The ExecuteIndirect span includes D3D12.X: an ExecuteIndirect reads the arguments written before it #1791'sfresh_indirect_arguments.real.rs: with the profile on, a translated pipeline's console shader hashes are kept (PSO_SHADERS, as for the frame trace) and a compute program's shape is noted; title queues are noted at submit (list_x.rskickoff_xtoo).gpu/recomp/pso.rs:compute_shape(thread group size, wave64, code size of a console CS).LazyLockread.Limits (in the module doc): queues that overlap on the GPU are each charged in full, so the sum can exceed wall time; bundles get no stamps; a recording run again without a Reset is counted once; the resolve waits on the GPU for the op to finish, so with the profile on a queue runs its ops one after the other (the numbers are per op, not the frame time).
Tested
cargo build --workspace && cargo test --workspace -- --test-threads=4:5a3fc0conmain6020a33,--no-fail-fast): 1151 passed, 5 failed, 46 ignored (no new build warnings);main6020a33: 1150 passed, 4 failed, 46 ignored.gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3(CreateComputePipelineState:0x8007000E, seeds 70, 545, 1019, 1507), the same when run alone onmain. The fifth on this PR,offline_compute_pipeline_is_reused_by_a_second_process, failed once in the full run and passed when run alone on this PR and onmain.V_MUL_F16,V_PK_MUL_F16,V_CVT_F16_F32),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).XCL_GPU_PROFILE=1, on our integration branch (main+ other PRs) with the same code:GPU timestamps at 1000000000 Hz; from 60 s the 2 s blocks read 1.9-2.1 s of GPU time per 2 s (e.g.last 2.0 s: 1920.5 ms of GPU time in 2905 op(s) of console code (3253 in flight, 0 lost, 0 out of order)), with the programs above at the top. In a later run with those programs changed, the same blocks showed79d178going from ~156 ms to a few ms.Regression run
.\scripts\smoke.ps1 -Game <retail title> -Seconds 60, no input (both runs stay on the start screen), profile off as in any run without the variable,mainfirst, same machine:Not tested
main+ this PR alone; on this PR's head the profile was only checked by the suite. The regression pair runs with the profile off.AI use
mainand ran the suite; omp with Claude Sonnet 5.5 rebased it onto6020a33; omp with Claude Opus 5.5 reran the suite and the regression pair. The title runs are ours, on the hardware above.