Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/mapreduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@
# perform a reduction
d = 1
while d < items
barrier(0)
# Fence local memory: `barrier(0)` lowers to an OpControlBarrier without the
# WorkgroupMemory storage-class bit, which does not order the shared-local tree
# accesses across the barrier. Fence local memory so each tree step sees the
# previous step's `shared[]` writes.
barrier(SPIRVIntrinsics.LOCAL_MEM_FENCE)
index = 2 * d * (item-1) + 1
@inbounds if index <= items
other_val = if index + d <= items
Expand Down
8 changes: 7 additions & 1 deletion src/oneAPIKernels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,13 @@ end
## Synchronization and Printing

@device_override @inline function KA.__synchronize()
barrier(0)
# Fence both local and global memory across the workgroup barrier, matching CUDA
# `__syncthreads` semantics. `barrier(0)` lowers to `OpControlBarrier` with
# `SequentiallyConsistent` but WITHOUT any storage-class bit, which the SPIR-V spec
# treats as ordering *no* memory — so shared-local or global writes are not guaranteed
# visible to other work-items after the barrier. `LOCAL_MEM_FENCE | GLOBAL_MEM_FENCE`
# ORs in the WorkgroupMemory/CrossWorkgroupMemory fence bits.
barrier(SPIRVIntrinsics.LOCAL_MEM_FENCE | SPIRVIntrinsics.GLOBAL_MEM_FENCE)
end

@device_override @inline function KA.__print(args...)
Expand Down
Loading