Skip to content

GPU Metal: do not let Metal track hazards on the memory buffers - #16068

Merged
ktf merged 1 commit into
AliceO2Group:devfrom
ktf:pr16068
Nov 6, 2026
Merged

ktf merged 1 commit into
AliceO2Group:devfrom
ktf:pr16068

Conversation

@ktf

@ktf ktf commented Nov 6, 2026

Copy link
Copy Markdown
Member

All memory of the reconstruction lives in three MTLBuffers, so with
Metal's default hazard tracking every encoder that writes device
memory conflicts with every other one, and Metal ordered them even
across the streams' command queues: in a Metal System Trace the
per-sector kernels the chain spreads over 8 streams did not overlap at
all (kernel time summed to the GPU busy time). The backend orders the
work itself, as CUDA streams do: a fence between the encoders of a
stream, an event between its command buffers, and the chain's events
between streams. So create the buffers untracked; the kernels of
different streams now overlap by about 150 ms per event.

On an M1 Max, interleaved over 3 rounds of 10 runs (load average 4 to
7), the 30-collision Pb-Pb time frame takes 975 ms per event instead
of 1046, and a 10-collision Pb-Pb time frame dumped from the full
system test 754 ms instead of 850. The clusters are byte-identical to
the CPU's on the 30-collision time frame and on sim5pp.

All memory of the reconstruction lives in three MTLBuffers, so with
Metal's default hazard tracking every encoder that writes device
memory conflicts with every other one, and Metal ordered them even
across the streams' command queues: in a Metal System Trace the
per-sector kernels the chain spreads over 8 streams did not overlap at
all (kernel time summed to the GPU busy time). The backend orders the
work itself, as CUDA streams do: a fence between the encoders of a
stream, an event between its command buffers, and the chain's events
between streams. So create the buffers untracked; the kernels of
different streams now overlap by about 150 ms per event.

On an M1 Max, interleaved over 3 rounds of 10 runs (load average 4 to
7), the 30-collision Pb-Pb time frame takes 975 ms per event instead
of 1046, and a 10-collision Pb-Pb time frame dumped from the full
system test 754 ms instead of 850. The clusters are byte-identical to
the CPU's on the 30-collision time frame and on sim5pp.
@ktf
ktf requested a review from davidrohr as a code owner November 6, 2026 18:58
@ktf
ktf merged commit cabb816 into AliceO2Group:dev Nov 6, 2026
9 of 11 checks passed
@ktf

ktf commented Nov 6, 2026

Copy link
Copy Markdown
Member Author

Metal only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant