Skip to content

GPU Metal: make the double pipeline work, with the slave's offsets into the shared buffers - #16235

Merged
ktf merged 1 commit into
AliceO2Group:devfrom
ktf:pr16235
Nov 30, 2026
Merged

ktf merged 1 commit into
AliceO2Group:devfrom
ktf:pr16235

Conversation

@ktf

@ktf ktf commented Nov 29, 2026

Copy link
Copy Markdown
Member

With --PROCdoublePipeline 1, the slave instance shares the master's
mem_host / mem_gpu buffers, but its mHostMemoryBase / mDeviceMemoryBase
are the end of the master's permanent memory. The backend computed the
buffer offsets of GPUMemCpy, WriteToConstantMemory (metalResolve) and
GPUMemClean16 from the instance's bases, so every slave copy and every
clean landed that much too low, on the master's memory: the slave's
scratch was never cleared (its clusters accumulated over the time
frames, 19009 -> 33527 in sim5pp), and its cleans zeroed the master's
permanent memory. On pbpb30, plain dev crashed in MergeBorderTracks<3>,
and with only the copies fixed every slave time frame was wrong
(3.8 M of 4416506 clusters, 0 tracks) and the run hung in DrainStream.
--benchmark sync-gpu-wall, which forces the double pipeline, could not
run on Metal.

The offsets are now taken from the buffers, as the CPU-visible
addresses already were, and the slave takes the master's core count as
in CUDA (it ran its kernels with the grids for one core). The slave
keeps sharing the constant buffer, the queues and the events' backend
state with the master, as in CUDA: the pipeline worker runs one chain
at a time.

pbpb30 and sim5pp, --runs 10 in the double pipeline with
debugDumpFinal: all 5 time frames of each instance have the cluster set
of the single pipeline (identical sorted dump) and match its tracks as
closely as single-pipeline runs match each other (pbpb30 99.53 to
99.66% against 99.53 to 99.58%, sim5pp 100%); rc 0, no errors, no hang.
The single pipeline is unchanged (same check, CPU library identical).
On an M1 Max, sync-gpu-wall on pbpb30 gives 1095.9 +- 15.0 ms per TF
against 1091.3 +- 15.7 for the single pipeline (5 interleaved rounds):
the double pipeline works but gains nothing on this small time frame.

…to the shared buffers

With --PROCdoublePipeline 1, the slave instance shares the master's
mem_host / mem_gpu buffers, but its mHostMemoryBase / mDeviceMemoryBase
are the end of the master's permanent memory. The backend computed the
buffer offsets of GPUMemCpy, WriteToConstantMemory (metalResolve) and
GPUMemClean16 from the instance's bases, so every slave copy and every
clean landed that much too low, on the master's memory: the slave's
scratch was never cleared (its clusters accumulated over the time
frames, 19009 -> 33527 in sim5pp), and its cleans zeroed the master's
permanent memory. On pbpb30, plain dev crashed in MergeBorderTracks<3>,
and with only the copies fixed every slave time frame was wrong
(3.8 M of 4416506 clusters, 0 tracks) and the run hung in DrainStream.
--benchmark sync-gpu-wall, which forces the double pipeline, could not
run on Metal.

The offsets are now taken from the buffers, as the CPU-visible
addresses already were, and the slave takes the master's core count as
in CUDA (it ran its kernels with the grids for one core). The slave
keeps sharing the constant buffer, the queues and the events' backend
state with the master, as in CUDA: the pipeline worker runs one chain
at a time.

pbpb30 and sim5pp, --runs 10 in the double pipeline with
debugDumpFinal: all 5 time frames of each instance have the cluster set
of the single pipeline (identical sorted dump) and match its tracks as
closely as single-pipeline runs match each other (pbpb30 99.53 to
99.66% against 99.53 to 99.58%, sim5pp 100%); rc 0, no errors, no hang.
The single pipeline is unchanged (same check, CPU library identical).
On an M1 Max, sync-gpu-wall on pbpb30 gives 1095.9 +- 15.0 ms per TF
against 1091.3 +- 15.7 for the single pipeline (5 interleaved rounds):
the double pipeline works but gains nothing on this small time frame.
@ktf
ktf requested a review from davidrohr as a code owner November 29, 2026 14:05
@ktf

ktf commented Nov 29, 2026

Copy link
Copy Markdown
Member Author

@davidrohr the little friend claims the same issue is there in the OpenCL backend.

@ktf

ktf commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

See #16236.

@ktf
ktf merged commit a564b98 into AliceO2Group:dev Nov 30, 2026
11 checks passed
@ktf

ktf commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

Metal only. Merging.

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