Repository navigation
GPU Metal: make the double pipeline work, with the slave's offsets into the shared buffers - #16235
Merged
Merged
Conversation
…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.
Member
Author
|
@davidrohr the little friend claims the same issue is there in the OpenCL backend. |
Member
Author
|
See #16236. |
Member
Author
|
Metal only. Merging. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.