Skip to content

GPUTracking: replace the merger's goto with helper lambdas - #15945

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

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

Conversation

@ktf

@ktf ktf commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

MSL supports neither goto nor labels. The label sat at the end of the loop body,
so each jump was a continue for the outer loop that could not be written as one
because it was issued from an inner loop.

Two lambdas take over the chain walks that did the jumping: one advances a track
along its segment chain and reports whether the target was met on the way, the
other reports whether the target sits on either neighbour chain. Each jump then
becomes a plain continue at the top level of the loop body. A null target lets
the first one also cover the four walks that never tested for one, leaving the
file three lines shorter than it is with the goto.

Checked against the goto version by transcribing both loop bodies into a harness
and comparing the skip decision and the resulting segment and neighbour links of
every track over 400000 random link graphs, 71% of which took a skip path and
100000 of which reached the merging stage: no differences.

@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.

Hm, I don't like that we need more instructions, but I do not think that there is a better solution. I do not believe this is performance critical, but I want to check at least that it does not change the performance. An alternative to make the code cleaner could be to use a lambda or a separate function.

@davidrohr

Copy link
Copy Markdown
Collaborator

I will try to run with this and O2/dev today and compare the performance on GPU, but I do not think there will be a difference. If we could have a version with a lambda or a function and return instead of goto, I'd prefer that for the syntax, and I assume also that would not change the performance.

MSL supports neither goto nor labels. The label sat at the end of the loop body,
so each jump was a continue for the outer loop that could not be written as one
because it was issued from an inner loop.

Two lambdas take over the chain walks that did the jumping: one advances a track
along its segment chain and reports whether the target was met on the way, the
other reports whether the target sits on either neighbour chain. Each jump then
becomes a plain continue at the top level of the loop body. A null target lets
the first one also cover the four walks that never tested for one, leaving the
file three lines shorter than it is with the goto.

Checked against the goto version by transcribing both loop bodies into a harness
and comparing the skip decision and the resulting segment and neighbour links of
every track over 400000 random link graphs, 71% of which took a skip path and
100000 of which reached the merging stage: no differences.
@ktf ktf changed the title GPUTracking: replace the merger's goto with a flag GPUTracking: replace the merger's goto with helper lambdas Oct 14, 2026
@ktf

ktf commented Oct 14, 2026

Copy link
Copy Markdown
Member Author

Version with the lambda now pushed in place of the old commit. It's even 3 lines shorter... ;-)

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.

2 participants