PoCL drops the stores of a work-group when a value lives across a barrier inside a branch
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 43/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- julia
- Domain
- backend, testing-qa
Research direction
Start with the reproducer in the issue and confirm the failure using the stated OpenCL.jl and PoCL versions; compare the listed variants to isolate the branch/barrier behavior. The payload names no source files or tests, so locate the PoCL compiler path responsible for this behavior and its existing regression tests. Done when the reproducer stores the expected values and a regression test covers it.
Written by the indexing model from the issue text.
Description
PoCL miscompiles a barrier inside a branch when a work-item value computed before the barrier is used after it: a work-group in which that value differs between work-items stores nothing, not even from the work-items for which it holds. The barrier is valid OpenCL, since all work-items of a work-group take the same branch.
using OpenCL, pocl_jll
# In the last work-group only, a per-work-item value is computed before a barrier and used
# after it. That work-group stores nothing.
src = """
kernel void k(global long *A, long n) {
size_t I = get_global_id(0);
if (get_group_id(0) == get_num_groups(0) - 1) {
bool active = I < n;
barrier(CLK_LOCAL_MEM_FENCE);
if (active) A[I] = I + 1;
} else {
A[I] = I + 1;
}
}
"""
prog = cl.Program(; source = src) |> cl.build!
kern = cl.Kernel(prog, "k")
n = 37
A = CLArray(zeros(Int, 40))
clcall(kern, Tuple{CLPtr{Int}, Int}, A, n; global_size = 40, local_size = 8)
@show Array(A)[1:n]
(Array(A))[1:n] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 0, 0, 0, 0, 0]
Work-items 32–36 of the last work-group should have stored 33–37. Variants of the kernel above:
| variant | result |
|---|---|
| as above | wrong |
if (n > 0) around the barrier (all work-groups take it): the last work-group still stores nothing |
wrong |
int instead of long/size_t |
wrong |
I < n evaluated after the barrier instead of before it |
correct |
| no branch around the barrier | correct |
POCL_WORK_GROUP_METHOD=cbs |
correct |
built with -cl-opt-disable |
correct |
Also wrong with PoCL main (b3033f8d3), so it isn't fixed upstream yet. OpenCL.jl 0.10.12, pocl_jll 7.2.2+1 (LLVM 22.1.8), Ryzen 9 9950X.
This came up in KernelAbstractions.jl, when compiling each @kernel body twice, without and with bounds checks, and choosing per work-group which copy runs (an alternative to JuliaGPU/KernelAbstractions.jl#849). With @synchronize that puts a barrier under a group-dependent branch, and the partial last work-group then stored nothing.
- Dominant language
- Julia
- Stars
- 313
- Forks
- 50
- Avg merge
- 23h 33m
- Merged PRs (30d)
- 35
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from JuliaGPU/OpenCL.jl
-
Intel CPU runtime: reports half-precision atomic addition but lacks the atomic_add builtin for halfOpenDrivers Intel CPU upstream
Difficulty 4/5 1-2 days Newbie friendliness 55/100
Maintainers usually reply within 1 day
-
Drivers Intel CPU upstream
Difficulty 4/5 3-5 days Newbie friendliness 43/100
JuliaGPU/OpenCL.jl#559 · 1 comment ·
Maintainers usually reply within 1 day
-
Drivers Intel CPU upstream
Difficulty 4/5 3-5 days Newbie friendliness 35/100
JuliaGPU/OpenCL.jl#558 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 28/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
JuliaGPU/OpenCL.jl#550 · 1 comment ·
Maintainers usually reply within 1 day
All issues in JuliaGPU/OpenCL.jl
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
JuliaGenAI/HuggingFaceDatasets.jl#96 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
JuliaData/DBFTables.jl#50 ·
-
_fit_phylo_binomial_xlv: default start calls undefined logit (UndefVarError without beta_init)Possibly taken A pull request linked to this issue is open or already merged. Opencode-review
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
JuliaNLSolvers/Optim.jl#1296 ·