Repository navigation
GPU: implement the work-group and warp collectives for Metal - #16110
Merged
Merged
Conversation
Metal fell through to the CPU branch of GPUCommonAlgorithm.h, where a scan, a reduction or a broadcast returns the thread's own value: right for one thread per block, wrong for the 32- to 1024-thread groups Metal runs. The TPC ZS decoding and the stream compaction of the cluster finder got wrong offsets and counts, and found no clusters at all. Implement them with MSL's SIMD-group functions, and the work-group ones by scanning within each SIMD group and then across the group totals, which go through smem as with cub. MSL has the thread index only as a kernel parameter, so like smem it is taken from the caller's scope, and the CfUtils block helpers get it through GPUCA_THREAD_INFO_DECL, which is empty for the other backends. blockPredicateScan loses the default of its last parameter for that. Sums are returned promoted, since the callers pass !!pred and a bool would truncate them. The CUDA, HIP, OpenCL and CPU code is unchanged.
davidrohr
approved these changes
Nov 12, 2026
davidrohr
left a comment
Collaborator
There was a problem hiding this comment.
Looks good, without testing it. Having this cross-platform is obviously important in general.
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.
Metal fell through to the CPU branch of GPUCommonAlgorithm.h, where a
scan, a reduction or a broadcast returns the thread's own value: right for
one thread per block, wrong for the 32- to 1024-thread groups Metal runs.
The TPC ZS decoding and the stream compaction of the cluster finder got
wrong offsets and counts, and found no clusters at all.
Implement them with MSL's SIMD-group functions, and the work-group ones by
scanning within each SIMD group and then across the group totals, which go
through smem as with cub. MSL has the thread index only as a kernel
parameter, so like smem it is taken from the caller's scope, and the
CfUtils block helpers get it through GPUCA_THREAD_INFO_DECL, which is
empty for the other backends. blockPredicateScan loses the default of its
last parameter for that. Sums are returned promoted, since the callers
pass !!pred and a bool would truncate them.
The CUDA, HIP, OpenCL and CPU code is unchanged.