Skip to content
Open
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
8 changes: 8 additions & 0 deletions ext/AtomixOpenCLExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module AtomixOpenCLExt

using Atomix: Atomix, IndexableRef
using OpenCL: SPIRVIntrinsics, CLDeviceArray
using UnsafeAtomics: Ordering

const CLIndexableRef{Indexable<:CLDeviceArray} = IndexableRef{Indexable}

Expand Down Expand Up @@ -55,5 +56,12 @@ end
return old => op(old, x)
end

@inline function Atomix.swap!(ref::CLIndexableRef, x, order::Ordering)
x = convert(eltype(ref), x)
ptr = Atomix.pointer(ref)
old = SPIRVIntrinsics.atomic_xchg!(ptr, x)
return old
end

end # module AtomixOpenCLExt