Skip to content

Commit 03ca435

Browse files
authored
Use UnsafeAtomics 0.3 (#709)
* Use UnsafeAtomics 0.3 * fixup! Use UnsafeAtomics 0.3
1 parent 83d0fd8 commit 03ca435

File tree

5 files changed

+8
-15
lines changed

5 files changed

+8
-15
lines changed

Project.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
3131
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
3232
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
3333
UnsafeAtomics = "013be700-e6cd-48c3-b4a1-df204f14c38f"
34-
UnsafeAtomicsLLVM = "d80eeb9a-aca5-4d75-85e5-170c8b632249"
3534

3635
[weakdeps]
3736
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
@@ -60,6 +59,5 @@ Random123 = "1.6"
6059
RandomNumbers = "1.5"
6160
SpecialFunctions = "2"
6261
StaticArraysCore = "1"
63-
UnsafeAtomics = "0.2"
64-
UnsafeAtomicsLLVM = "0.2"
62+
UnsafeAtomics = "0.3"
6563
julia = "1.10"

src/AMDGPU.jl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ using Printf
1111

1212
import AcceleratedKernels as AK
1313
import UnsafeAtomics
14-
import UnsafeAtomicsLLVM
1514
import Atomix
1615
import Atomix: @atomic, @atomicswap, @atomicreplace
1716
import Core: LLVMPtr
@@ -130,14 +129,12 @@ include("random.jl")
130129

131130
# Enable hardware FP atomics for +/- ops.
132131
const ROCIndexableRef{Indexable <: ROCDeviceArray} = Atomix.IndexableRef{Indexable}
133-
134-
function Atomix.modify!(ref::ROCIndexableRef, op::OP, x, ord) where {
135-
OP <: Union{typeof(+), typeof(-)}
136-
}
132+
const agent = UnsafeAtomics.Internal.LLVMSyncScope{:agent}()
133+
function Atomix.modify!(ref::ROCIndexableRef, op::OP, x, ord) where OP <: Union{typeof(+), typeof(-)}
137134
x = Atomix.asstorable(ref, x)
138135
ptr = Atomix.pointer(ref)
139136
root = Atomix.gcroot(ref)
140-
GC.@preserve root UnsafeAtomics.modify!(ptr, op, x, ord, Val(:agent))
137+
GC.@preserve root UnsafeAtomics.modify!(ptr, op, x, ord, agent)
141138
end
142139

143140
include("ROCKernels.jl")

src/ROCKernels.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import AMDGPU.Device: @device_override
88
import Adapt
99
import KernelAbstractions as KA
1010
import LLVM
11-
import UnsafeAtomicsLLVM
1211

1312
using StaticArraysCore: MArray
1413

src/device/Device.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ using ..LLVM.Interop
77
import ..Adapt
88
import Core: LLVMPtr
99
import ..LinearAlgebra
10-
import UnsafeAtomicsLLVM
1110

1211
import ..HSA
1312
import ..HIP

src/device/runtime.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ exception_flag() = kernel_state().exception_flag
1313
function err_buffer!()
1414
st = kernel_state()
1515
counter_ptr = reinterpret(LLVMPtr{Int32, AS.Global}, st.buffers_counter)
16-
idx, _ = UnsafeAtomicsLLVM.Internal.atomic_pointermodify(
17-
counter_ptr, +, Int32(1), Val{:acquire_release}())
16+
idx, _ = UnsafeAtomics.atomic_pointermodify(
17+
counter_ptr, +, Int32(1), UnsafeAtomics.acquire_release)
1818
idx += Int32(1)
1919
idx > st.n_buffers && return reinterpret(LLVMPtr{UInt64, AS.Global}, 0)
2020

@@ -25,8 +25,8 @@ end
2525
function err_str_buffer!()
2626
st = kernel_state()
2727
counter_ptr = reinterpret(LLVMPtr{Int32, AS.Global}, st.str_buffers_counter)
28-
idx, _ = UnsafeAtomicsLLVM.Internal.atomic_pointermodify(
29-
counter_ptr, +, Int32(1), Val{:acquire_release}())
28+
idx, _ = UnsafeAtomics.atomic_pointermodify(
29+
counter_ptr, +, Int32(1), UnsafeAtomics.acquire_release)
3030
idx += Int32(1)
3131
idx > st.n_str_buffers && return reinterpret(LLVMPtr{UInt8, AS.Global}, 0)
3232

0 commit comments

Comments
 (0)