Repository navigation
borealis: flush leading timestamps before opening a compute stream - #1235
Conversation
When start_stamps_ordered() is false (G17P and M5), a leading timestamp recorded before the command buffer's first stream is deferred in hk_sync_state::lead_ts so a first render stream can carry it on timestamp.vtx_end without inserting a cross-engine compute carrier ahead of the render. Attaching lead_ts to a first compute stream's timestamp.end instead caused two regressions from #1145: 1. Compute streams have no separate start-side end stamp, so latching a leading start timestamp on the compute stream's end moved the start timestamp past the dispatch and left current_cs.cs open with timestamp.end already populated. A trailing timestamp after the dispatch then hit stamp_covered() and copied the start stamp, collapsing measured GPU time to 0 us on compute workloads. 2. If an interleaved graphics+compute barrier recorded HK_SYNC_GFX_MEM into req[HK_SYNC_GFX][VDM].prior before the trailing timestamp (as in D3D12 compute.conv2d UAV <-> NON_PIXEL_SHADER_RESOURCE barriers), stamp_covered() returned false while current_cs.cs was still open with timestamp.end set. The fallback timestamp_only_stream() path reused the open compute stream and overwrote timestamp.end with the second query, leaving the first timestamp query permanently unavailable (UINT64_MAX) so a subsequent vkCmdCopyQueryPoolResults with VK_QUERY_RESULT_WAIT_BIT spun until the GPU watchdog hit ETIMEDOUT. Flush lead_ts into a preceding timestamp-only compute carrier in hk_cmd_buffer_get_cs_general() before creating any compute stream, keeping lead_ts on timestamp.vtx_end for first render streams. Also end any open timestamped compute stream before falling through to timestamp_only_stream() in hk_sync_write_timestamp() and assert that timestamp.end is never overwritten. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
|
|
J714s (MacBook Pro M5 Pro,
|
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict at c454b390fe62: ready
Audited hk_cmd_buffer.h, hk_sync.c, hk_sync.h, test-hk-sync-stamps.c, and all callers of hk_sync_stream_created() / hk_cs_create*() / hk_sync_write_timestamp():
hk_cmd_buffer_get_cs_general()flusheslead_tsinto a pureHK_SYNC_STAMPcarrier beforehk_cs_create()for compute streams (checkingvk_command_buffer_has_error()), preserving the#1145rendervtx_endpath. The only other computehk_sync_stream_created()site (hk_cmd_buffer.c:5266G18 indirect launch) is preceded bylibagx_g18_indirect_launch()viahk_cmd_buffer_get_cs_general(), soassert(cs->type == HK_CS_VDM)holds.hk_sync_flush_lead_timestamp()clearsst->lead_tsbeforetimestamp_only_stream()(no recursion), saves/restoresbrl_transition_activeandxfer_depth, updatesstamp_copy_after[HK_SYNC_CDM], asserts!cs->timestamp.end.handle, and ends the carrier compute stream.hk_sync_write_timestamp()closes any open timestamped compute stream viahk_sync_end_cs_if_timestamped()beforetimestamp_only_stream()and asserts!cs->timestamp.end.handle, preventing silent overwrite.- Verified at exact head
c454b390fe62on J700 (G17P B1), J615 (M3), and J714s (G17S B1) with0CTS failures,0faults, and#1145render perf preserved.
|
aurora-wip has failed
#1213 orders work after a compute barrier that follows earlier compute, so the dispatch after the GFX+COMPUTE barrier probably no longer shares the first dispatch's stream. The test asserts Please decide which is right: update the test's expected stream layout for #1213's rule, or fix the sync code if the trailing stamp now lands on the wrong stream. Until then every mesa PR's local gate baseline is 337/338 (only this check failing), and we compare against that. Commands: |
…x check Commit 088f203 (aurora-silicon#1213) changed cs_reusable() so a self-cut compute barrier keeps an open compute stream only when that stream already waits for its predecessor on the compute subqueue. Commit c454b39 (aurora-silicon#1235) then flushed leading timestamps into a preceding pure HK_SYNC_STAMP carrier before opening a compute stream. When an application compute stream follows a pure HK_SYNC_STAMP or HK_SYNC_QRESET stream (such as a leading timestamp carrier, timestamp copy stream, post-graphics query availability stream, or timestamp reset), an application barrier never names those query-memory streams, so the open compute stream does not wait on them. Treating them as unwaited predecessors in cs_reusable() caused hk_sync_check_cs() to split the compute stream on the first compute barrier, breaking test-hk-sync-stamps.c:1237 and gratuitously splitting compute chains. Scope cdm_waits_for_prefix() by the required producer kinds: - For application work in cs_reusable(), walk back to the latest earlier HK_SYNC_ALL compute stream, ignoring pure HK_SYNC_STAMP and HK_SYNC_QRESET streams while still splitting whenever an unwaited application compute stream sits behind them. - For hk_sync_get_cs_after() and non-application callers (query commands, events, and timestamp streams), keep checking HK_SYNC_STREAM_KINDS so dependencies on earlier stamp or reset streams are never dropped. Signed-off-by: DjDeveloperr <hey@djdev.me>
Fixes two regressions introduced by #1145 (
5ab97d0f2c60) on chips wherestart_stamps_ordered()is false (G17P and M5):What:
hk_sync_state::lead_tsinto a preceding timestamp-only compute carrier inhk_cmd_buffer_get_cs_general()before creating any compute stream, instead of attachinglead_tsto the compute stream'stimestamp.endinhk_sync_stream_created().lead_tsriding ontimestamp.vtx_endwhen the first stream is a render stream (HK_CS_VDM), preserving borealis: keep timestamp work off command-buffer boundaries and pack timed passes #1145's cross-engine hop elimination and render packing.brl_transition_activeandxfer_deptharoundhk_sync_flush_lead_timestamp()so a flushed carrier stays pureHK_SYNC_STAMP.timestamp_only_stream()inhk_sync_write_timestamp()and assert!cs->timestamp.end.handlebefore writingcs->timestamp.end.test-hk-sync-stamps.cwith regression coverage for both the0 uscompute timestamp collapse and the bracketed compute +GFX|COMPUTEbarrier overwrite/deadlock sequence (plustest-hk-host-flush.c,test-hk-query-reset.c, andtest-hk-tess-batch.cstubs).Root cause:
Q0) to a compute stream'stimestamp.endlatchedQ0after the compute work finished and leftcurrent_cs.csopen withtimestamp.endalready set. A trailing timestamp (Q1) then hitstamp_covered()and copiedQ0 -> Q1, collapsing GPU time to0 uson compute and compute-transfer workloads.compute.conv2dETIMEDOUTdeadlock: When an interleavedGFX|COMPUTEbarrier (such as D3D12UAV <-> NON_PIXEL_SHADER_RESOURCE) recordedHK_SYNC_GFX_MEMintoreq[HK_SYNC_GFX][VDM].priorbeforeQ1,stamp_covered()returnedfalsewhilecurrent_cs.cswas still open withtimestamp.end = Q0. The fallbacktimestamp_only_stream()path reused the open compute stream and overwrotetimestamp.endwithQ1, leavingQ0permanentlyUINT64_MAXsovkCmdCopyQueryPoolResults(..., VK_QUERY_RESULT_WAIT_BIT)spun until the G17 watchdog returnedETIMEDOUT.Tested:
./rig/fedora-mesaci.sh c454b390fe62): 218/0 PASS, 0 warnings in touched lines (hk_sync_stamps: 896 tests, 0 failures; mutation reverting the fix fails 56/896 assertions across all 8 chip/exact-prior variants).J700,G17P B1, stock7.3.0-41.fc44.aurora.aarch64, isolated overlayc454b390fe62,stock.diff0, 0 GPU faults, 0 AVCs, 0 recoveries):gpubench-d3d12 --verify compute.conv2d gaussian 1080p d=1: PASS (1282.05 us/submit,gpu_us 976.08 us, CRC2d55a14d), anatomy confirms[CB0 reset] -> [CB1 Q0 carrier bar=c1] -> [CB1 H+V dispatches + Q1] -> [CB1 copy_query_g17p bar=c3].gpubench-d3d12 --verifyfull sweep: 47/47 PASS,gpu_us==0: 2/47 (restored to pre-borealis: keep timestamp work off command-buffer boundaries and pack timed passes #11454b87e99be586baseline; was 8/38 + 1ETIMEDOUT).gpubench-d3d11 --verifyfull sweep: 45/45 PASS,gpu_us==0: 4/45 (restored to pre-borealis: keep timestamp work off command-buffer boundaries and pack timed passes #1145 baseline; was 15/45).gpubench-vk --verifyfull sweep: 37/37 PASS,gpu_us==0: 0/37.query-pool.txtmustpass (dEQP-VK.query_pool.statistics_query.*18770/18775 PASS + 5 Not supported; all remaining 501dEQP-VK.query_pool.*including timestamp/occlusion/copy/reset/concurrent 474/501 PASS + 27 Not supported -> 19244 PASS / 0 FAIL / 32 Not supported total) anddEQP-VK.api.command_buffers.*(131/131 PASS).Risk: two-way · M3, M4, Neo, M5
Not yet:
start_stamps_ordered()is true on M3/M4 solead_tsis inactive there; M5 shares the!start_stamps_ordered()path covered by the unit tests across G17S/G17C/G17G/G17P).