Skip to content

[pocl] Backport upstream PR #2239 - #15001

Merged
vchuravy merged 1 commit into
JuliaPackaging:masterfrom
vchuravy:vc/pocl-wg-alloca-replicas
Oct 4, 2026
Merged

vchuravy merged 1 commit into
JuliaPackaging:masterfrom
vchuravy:vc/pocl-wg-alloca-replicas

Conversation

@vchuravy

@vchuravy vchuravy commented Oct 4, 2026

Copy link
Copy Markdown
Member

Backports pocl/pocl#2239 (merged upstream, in main) as patch 0014 of the pocl, pocl_next and pocl_standalone series.

The patch makes WorkitemLoops share compiler-expanded local memory (__pocl_work_group_alloca) between the replicas of a parallel region.

Bug: in PoCL 7.2.x, a branch with an early exit before a sub-group collective makes WorkitemLoops peel the first work-item into a replica. Bounds checks emit such early exits, for example in Julia's OpenCL.jl and KernelAbstractions.jl. Each replica then got its own scratch memory for the collective, so sub_group_reduce_add and friends returned garbage with the loops/loopvec work-group methods. JuliaGPU/OpenCL.jl#526 and JuliaGPU/KernelAbstractions.jl#831 need this to use the native cl_khr_subgroups collectives.

Recipe changes:

  • The patch only touches lib/llvmopencl/WorkitemLoops.cc; the upstream test is left out, like the other test files of the series.
  • pocl_standalone reaches the patches through its symlink to pocl_next/bundled, so this also bumps its build trigger.

Testing: I applied the series 0001–0014 to v7.2 (888c9774b) and built it locally against LLVM 23. Then I ran PoCL's regression tests plus a new test for this case, which exercises reduce, scan, broadcast and any after a branch with an early return:

  • The new test passes for loops, loopvec and cbs.
  • On release_7_2 without the fix, it fails for loops and loopvec.
  • The only failures were tests whose binary SPIR-V inputs the series doesn't include.

I didn't run a BinaryBuilder build locally.

🤖 Generated with Claude Code

Assisted-by: Claude Code (Opus 5.5)
@vchuravy
vchuravy enabled auto-merge (squash) October 4, 2026 11:01
@vchuravy
vchuravy merged commit a39b592 into JuliaPackaging:master Oct 4, 2026
52 checks passed
vchuravy added a commit to JuliaGPU/KernelAbstractions.jl that referenced this pull request Oct 4, 2026
….2.1+1

pocl_standalone_jll 7.2.1+1 includes the WorkitemLoops fix (pocl/pocl#2239,
JuliaPackaging/Yggdrasil#15001), so implement `KI.sub_group_reduce` and
`KI.sub_group_scan` with the native `cl_khr_subgroups` collectives where they
have Julia's semantics, and only keep the workaround for the fallbacks with
older builds. The version is checked at precompile time, since the compat bound
can't distinguish builds.

Note: PoCL's kernel cache doesn't distinguish 7.2.1+0 and +1, so binaries
miscompiled by the former can be reused by the latter until the cache is
cleared (pocl/pocl#2374, JuliaPackaging/Yggdrasil#15002).

Assisted-by: Claude Code (Opus 5.5)
vchuravy added a commit to JuliaGPU/KernelAbstractions.jl that referenced this pull request Oct 6, 2026
….2.1+1

pocl_standalone_jll 7.2.1+1 includes the WorkitemLoops fix (pocl/pocl#2239,
JuliaPackaging/Yggdrasil#15001), so implement `KI.sub_group_reduce` and
`KI.sub_group_scan` with the native `cl_khr_subgroups` collectives where they
have Julia's semantics, and only keep the workaround for the fallbacks with
older builds. The version is checked at precompile time, since the compat bound
can't distinguish builds.

Note: PoCL's kernel cache doesn't distinguish 7.2.1+0 and +1, so binaries
miscompiled by the former can be reused by the latter until the cache is
cleared (pocl/pocl#2374, JuliaPackaging/Yggdrasil#15002).

Assisted-by: Claude Code (Opus 5.5)
vchuravy added a commit to JuliaGPU/KernelAbstractions.jl that referenced this pull request Oct 10, 2026
….2.1+1

pocl_standalone_jll 7.2.1+1 includes the WorkitemLoops fix (pocl/pocl#2239,
JuliaPackaging/Yggdrasil#15001), so implement `KI.sub_group_reduce` and
`KI.sub_group_scan` with the native `cl_khr_subgroups` collectives where they
have Julia's semantics, and only keep the workaround for the fallbacks with
older builds. The version is checked at precompile time, since the compat bound
can't distinguish builds.

Note: PoCL's kernel cache doesn't distinguish 7.2.1+0 and +1, so binaries
miscompiled by the former can be reused by the latter until the cache is
cleared (pocl/pocl#2374, JuliaPackaging/Yggdrasil#15002).

Assisted-by: Claude Code (Opus 5.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant