Skip to content

GPU: implement the work-group and warp collectives for Metal - #16110

Merged
ktf merged 1 commit into
AliceO2Group:devfrom
ktf:pr16110
Nov 12, 2026
Merged

ktf merged 1 commit into
AliceO2Group:devfrom
ktf:pr16110

Conversation

@ktf

@ktf ktf commented Nov 12, 2026

Copy link
Copy Markdown
Member

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.

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.
@ktf
ktf requested a review from davidrohr as a code owner November 12, 2026 08:00

@davidrohr davidrohr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, without testing it. Having this cross-platform is obviously important in general.

@ktf
ktf merged commit 9ac4611 into AliceO2Group:dev Nov 12, 2026
12 checks passed
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.

2 participants