Skip to content

GPU: scan the pad baseline in time segments where the backend asks for it - #16186

Open
ktf wants to merge 1 commit into
AliceO2Group:devfrom
ktf:pr16186
Open

ktf wants to merge 1 commit into
AliceO2Group:devfrom
ktf:pr16186

Conversation

@ktf

@ktf ktf commented Nov 24, 2026

Copy link
Copy Markdown
Member

The new scan is in the shared TPC cluster finder code and is selected
per backend, at compile time, by the new parameter
CF_CHECK_PAD_BASELINE_SEGMENTED, which is 1 only for Metal. CUDA, HIP
and OpenCL keep the existing scan, since its speed there could not be
measured here.

GPUTPCCFCheckPadBaseline runs one block of 576 threads per row, and
without the HIP tail filter only the up to 138 threads that own a pad
do work, each walking all time bins of its pad. Without the filter the
baseline needs, per pad, only the number of time bins with charge,
the longest run of them and the largest charge, and these combine
over consecutive segments of time. So with the new parameter all four
threads per pad scan a quarter of the time bins each, straight from
the charge map, and the quarters are joined at the end. The block
size, its static_assert, the grid and the noisy-pad flags are
unchanged; with the HIP tail filter on, the existing scan runs.

On an M1 Max the kernel takes 1.6 ms per call instead of 3.7 (median
in a Metal System Trace), and the 30-collision Pb-Pb time frame 1088
ms per event instead of 1182 (3 interleaved rounds of 10 runs, load
average 4 to 6). The clusters are byte-identical to the CPU's, also
with noisy-pad thresholds tightened until 6 to 24% of the clusters
are dropped, and the CPU backend's own output is unchanged.

@ktf
ktf requested a review from davidrohr as a code owner November 24, 2026 12:24
@ktf

ktf commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

@davidrohr standalone optimisation, including your comments. @fweig I guess you want to check this one.

@fweig

fweig commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Do we really need a third implementation of this kernel? It's hard enough to maintain as it already is. :/

@alibuild

Copy link
Copy Markdown
Collaborator

Error while checking build/O2/fullCI_slc9 for b3ef699 at 2026-11-24 14:03:

## sw/BUILD/O2-RTC-test-latest/log
/tmp/o2cagpu_rtc_135_2069895659_2.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_109.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_66.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_25.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_89.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_32.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_67.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_49.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_47.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_88.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_40.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_5.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_54.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_15.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_20.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_57.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_98.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_93.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_30.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_34.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_79.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_35.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_52.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_10.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_99.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_45.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_104.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_8.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_19.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_70.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_9.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_44.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_84.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_21.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_43.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_72.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_7.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_100.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_13.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_36.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_63.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_28.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_73.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_0.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_101.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_62.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_50.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
/tmp/o2cagpu_rtc_135_2069895659_56.cu(31017): error: identifier "GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED" is undefined
[0 more errors; see full log]

Full log here.

@ktf

ktf commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

On Metal the separate scan halves the kernel time (208 → 92 ms on my sample); folding it into the existing kernel only gets 9%. Could you try CF_CHECK_PAD_BASELINE_SEGMENTED=1 on CUDA/HIP before I drop the optimisation?

@davidrohr

Copy link
Copy Markdown
Collaborator

The CI fails. I believe since you have not added the parameter to kernels.cmake.

I'll have a look at CUDA and AMD performance once CI passes, and once I find some time.

If there is a significant improvement, we should merge this. Let's see how it works on the other GPUs.
But since @fweig is working heavily on this kernel for the highly ionizing particles, I would not make his work more complicated for the time being.

…r it

The new scan is in the shared TPC cluster finder code and is selected
per backend, at compile time, by the new parameter
CF_CHECK_PAD_BASELINE_SEGMENTED, which is 1 only for Metal. CUDA, HIP
and OpenCL keep the existing scan, since its speed there could not be
measured here.

GPUTPCCFCheckPadBaseline runs one block of 576 threads per row, and
without the HIP tail filter only the up to 138 threads that own a pad
do work, each walking all time bins of its pad. Without the filter the
baseline needs, per pad, only the number of time bins with charge,
the longest run of them and the largest charge, and these combine
over consecutive segments of time. So with the new parameter all four
threads per pad scan a quarter of the time bins each, straight from
the charge map, and the quarters are joined at the end. The block
size, its static_assert, the grid and the noisy-pad flags are
unchanged; with the HIP tail filter on, the existing scan runs.

On an M1 Max the kernel takes 1.6 ms per call instead of 3.7 (median
in a Metal System Trace), and the 30-collision Pb-Pb time frame 1088
ms per event instead of 1182 (3 interleaved rounds of 10 runs, load
average 4 to 6). The clusters are byte-identical to the CPU's, also
with noisy-pad thresholds tightened until 6 to 24% of the clusters
are dropped, and the CPU backend's own output is unchanged.
@ktf

ktf commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

Updated with the kernels.cmake.

This branch has not been deployed

No deployments
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.

4 participants