Skip to content

Pass device pointers to kernels as global LLVMPtrs - #711

Merged
maleadt merged 1 commit into
mainfrom
tb/zeptr-kernel-arg
Oct 19, 2026
Merged

maleadt merged 1 commit into
mainfrom
tb/zeptr-kernel-arg

Conversation

@maleadt

@maleadt maleadt commented Oct 19, 2026

Copy link
Copy Markdown
Member

ZePtr kernel arguments were converted to Ptr, which lowers to an addrspace(0) pointer. In SPIR-V that address space is private memory, so a kernel storing through pointer(a) never wrote to the array, regardless of the buffer type:

function memset(ptr, val)
    unsafe_store!(ptr, val)
    return
end
a = oneVector{Int}([1])
@oneapi memset(pointer(a), 42)
Array(a)  # [1]

They are now passed as LLVMPtr{T,AS.CrossWorkgroup}, matching the pointer oneDeviceArray wraps. Kernels with an argument explicitly typed ::Ptr{T} no longer match a ZePtr, but such kernels never worked.

The NEO#172 test passes an explicit Ptr now, so that it keeps exercising the integer-to-pointer conversion it was written for.

The original broadcast reproducer from the issue already works on current main.

Fixes #458

ZePtr kernel arguments were converted to Ptr, an addrspace(0) pointer,
which SPIR-V treats as private memory: stores through `pointer(a)` in a
kernel were lost for every buffer type. Convert them to
LLVMPtr{T,AS.CrossWorkgroup} instead, like the pointer oneDeviceArray wraps.

Fixes #458
@maleadt maleadt added the kernels Writing and compiling kernels: device intrinsics, codegen, KernelAbstractions back-end. label Oct 19, 2026
@codecov

codecov Bot commented Oct 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.48%. Comparing base (e95e38f) to head (667e2e9).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #711      +/-   ##
==========================================
- Coverage   84.08%   83.48%   -0.60%     
==========================================
  Files          52       51       -1     
  Lines        4386     4263     -123     
==========================================
- Hits         3688     3559     -129     
- Misses        698      704       +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@maleadt
maleadt merged commit a0adaa1 into main Oct 19, 2026
5 checks passed
@maleadt
maleadt deleted the tb/zeptr-kernel-arg branch October 19, 2026 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernels Writing and compiling kernels: device intrinsics, codegen, KernelAbstractions back-end.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copying HostBuffer is broken

1 participant