You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using KernelAbstractions
@kernelfunctionmykernel(y)
z =length(y)
for i in1:z
@synchronizeendend
x =zeros(3)
backend =get_backend(x)
mykernel(backend)(x; ndrange=length(x))
KernelAbstractions.synchronize(backend)
This MWE yields:
ERROR: UndefVarError: `z` not defined in `Main`
Suggestion: check for spelling errors or missing imports.
Stacktrace:
[1] cpu_mykernel
@ ~/.julia/packages/KernelAbstractions/lGrz7/src/macros.jl:307 [inlined]
[2] cpu_mykernel(__ctx__::KernelAbstractions.CompilerMetadata{…}, x::Vector{…})
@ Main ./none:0
[3] __thread_run(tid::Int64, len::Int64, rem::Int64, obj::KernelAbstractions.Kernel{…}, ndrange::Tuple{…}, iterspace::KernelAbstractions.NDIteration.NDRange{…}, args::Tuple{…}, dynamic::KernelAbstractions.NDIteration.NoDynamicCheck)
@ KernelAbstractions ~/.julia/packages/KernelAbstractions/lGrz7/src/cpu.jl:145
[4] __run(obj::KernelAbstractions.Kernel{…}, ndrange::Tuple{…}, iterspace::KernelAbstractions.NDIteration.NDRange{…}, args::Tuple{…}, dynamic::KernelAbstractions.NDIteration.NoDynamicCheck, static_threads::Bool)
@ KernelAbstractions ~/.julia/packages/KernelAbstractions/lGrz7/src/cpu.jl:112
[5] (::KernelAbstractions.Kernel{…})(args::Vector{…}; ndrange::Int64, workgroupsize::Nothing)
@ KernelAbstractions ~/.julia/packages/KernelAbstractions/lGrz7/src/cpu.jl:46
[6] top-level scope
@ Untitled-2:14
Some type information was truncated. Use `show(err)` to see complete types.
Update: It seems to work on the GPU, but I would love to run it on the CPU for debugging because I'm getting illegal memory access on the GPU with my larger kernel.
Activity
efaulhaber commentedon Oct 24, 2025
Update: It seems to work on the GPU, but I would love to run it on the CPU for debugging because I'm getting illegal memory access on the GPU with my larger kernel.
yolhan83 commentedon Oct 24, 2025
Are you on main ? otherwise use
@uniform,edit : it does not work, synchronize in loops doesn't work on the old CPU backend.
use
add KernelAbstraction#mainand your code it works thanks to the Pocl backend. So its fixed on main.maleadt commentedon Oct 19, 2026
Fixed by #556, released in 0.10: with the PoCL-based
CPUbackend,@synchronizeinside a loop works and the MWE runs unchanged.