Skip to content

Commit 947406c

Browse files
committed
removing @atomic macro
1 parent 1f878e0 commit 947406c

File tree

2 files changed

+11
-51
lines changed

2 files changed

+11
-51
lines changed

lib/CUDAKernels/src/CUDAKernels.jl

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ else
320320
end
321321

322322
import KernelAbstractions: ConstAdaptor, SharedMemory, Scratchpad, __synchronize, __size
323-
import KernelAbstractions: __atomic, atomic_add!, atomic_and!, atomic_cas!, atomic_dec!, atomic_inc!, atomic_max!, atomic_min!, atomic_op!, atomic_or!, atomic_sub!, atomic_xchg!, atomic_xor!
323+
import KernelAbstractions: atomic_add!, atomic_and!, atomic_cas!, atomic_dec!, atomic_inc!, atomic_max!, atomic_min!, atomic_op!, atomic_or!, atomic_sub!, atomic_xchg!, atomic_xor!
324324

325325
###
326326
# GPU implementation of shared memory
@@ -386,11 +386,6 @@ end
386386
# GPU implementation of atomics
387387
###
388388

389-
@inline function Cassette.overdub(::CUDACtx, ::typeof(__atomic), ex)
390-
#CUDA.@atomic(ex)
391-
KernelAbstractions.@print(ex)
392-
end
393-
394389
afxs = Dict(
395390
atomic_add! => CUDA.atomic_add!,
396391
atomic_and! => CUDA.atomic_and!,

src/atomics.jl

Lines changed: 10 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Atomics
33
###
44

5-
export @atomic, atomic_add!, atomic_sub!, atomic_and!, atomic_or!, atomic_xor!,
5+
export atomic_add!, atomic_sub!, atomic_and!, atomic_or!, atomic_xor!,
66
atomic_min!, atomic_max!, atomic_inc!, atomic_dec!, atomic_xchg!,
77
atomic_op!, atomic_cas!
88

@@ -15,33 +15,6 @@ function inc(a::T,b::T) where T
1515
(a >= b) ? T(0) : (a+T(1))
1616
end
1717

18-
"""
19-
@atomic macro
20-
21-
This is a unified atomic interface
22-
23-
# Platform differences
24-
- `GPU`: This uses standard `@atomic` calls from CUDA.jl
25-
- `CPU`: This reorganized the command to use atomic pointer logic
26-
"""
27-
28-
# TODO: Remove?
29-
#const atomic_acquire = LLVM.API.LLVMAtomicOrderingAcquire
30-
#const atomic_release = LLVM.API.LLVMAtomicOrderingRelease
31-
#const atomic_acquire_release = LLVM.API.LLVMAtomicOrderingAcquireRelease
32-
33-
# NOTE: This only grabs the first symbol of the expression, not the entire expr
34-
macro atomic(ex)
35-
quote
36-
$__atomic($ex)
37-
end
38-
end
39-
40-
# Implement CPU macro here?
41-
function __atomic(ex)
42-
error("@atomic macro incomplete!")
43-
end
44-
4518
# arithmetic, bitwise, min/max, and inc/dec operations
4619
const ops = Dict(
4720
:atomic_add! => +,
@@ -107,18 +80,10 @@ function atomic_op!(ptr::Ptr{T}, op, b::T) where T
10780
Core.Intrinsics.atomic_pointermodify(ptr::Ptr{T}, op, b::T, :monotonic)
10881
end
10982

110-
###
111-
# CPU implementation of atomic macro
112-
###
113-
114-
#@inline function Cassette.overdub(::CPUCtx, ::typeof(__atomic), ex)
115-
# println(ex)
116-
#end
117-
11883
# Other Documentation
11984

12085
"""
121-
atomic_add!(ptr::LLVMPtr{T}, val::T)
86+
atomic_add!(ptr::Ptr{T}, val::T)
12287
12388
This is an atomic addition.
12489
It reads the value `old` located at address `ptr`, computes `old + val`, and stores the result back to memory at the same address.
@@ -131,7 +96,7 @@ Additionally, on GPU hardware with compute capability 6.0+, values of type Float
13196
atomic_add!
13297

13398
"""
134-
atomic_sub!(ptr::LLVMPtr{T}, val::T)
99+
atomic_sub!(ptr::Ptr{T}, val::T)
135100
136101
This is an atomic subtraction.
137102
It reads the value `old` located at address `ptr`, computes `old - val`, and stores the result back to memory at the same address.
@@ -143,7 +108,7 @@ This operation is supported for values of type Int32, Int64, UInt32 and UInt64.
143108
atomic_sub!
144109

145110
"""
146-
atomic_and!(ptr::LLVMPtr{T}, val::T)
111+
atomic_and!(ptr::Ptr{T}, val::T)
147112
148113
This is an atomic and.
149114
It reads the value `old` located at address `ptr`, computes `old & val`, and stores the result back to memory at the same address.
@@ -155,7 +120,7 @@ This operation is supported for values of type Int32, Int64, UInt32 and UInt64.
155120
atomic_and!
156121

157122
"""
158-
atomic_or!(ptr::LLVMPtr{T}, val::T)
123+
atomic_or!(ptr::Ptr{T}, val::T)
159124
160125
This is an atomic or.
161126
It reads the value `old` located at address `ptr`, computes `old | val`, and stores the result back to memory at the same address.
@@ -167,7 +132,7 @@ This operation is supported for values of type Int32, Int64, UInt32 and UInt64.
167132
atomic_or!
168133

169134
"""
170-
atomic_xor!(ptr::LLVMPtr{T}, val::T)
135+
atomic_xor!(ptr::Ptr{T}, val::T)
171136
172137
This is an atomic xor.
173138
It reads the value `old` located at address `ptr`, computes `old ⊻ val`, and stores the result back to memory at the same address.
@@ -179,7 +144,7 @@ This operation is supported for values of type Int32, Int64, UInt32 and UInt64.
179144
atomic_xor!
180145

181146
"""
182-
atomic_min!(ptr::LLVMPtr{T}, val::T)
147+
atomic_min!(ptr::Ptr{T}, val::T)
183148
184149
This is an atomic min.
185150
It reads the value `old` located at address `ptr`, computes `min(old, val)`, and st ores the result back to memory at the same address.
@@ -191,7 +156,7 @@ This operation is supported for values of type Int32, Int64, UInt32 and UInt64.
191156
atomic_min!
192157

193158
"""
194-
atomic_max!(ptr::LLVMPtr{T}, val::T)
159+
atomic_max!(ptr::Ptr{T}, val::T)
195160
196161
This is an atomic max.
197162
It reads the value `old` located at address `ptr`, computes `max(old, val)`, and st ores the result back to memory at the same address.
@@ -203,7 +168,7 @@ This operation is supported for values of type Int32, Int64, UInt32 and UInt64.
203168
atomic_max!
204169

205170
"""
206-
atomic_inc!(ptr::LLVMPtr{T}, val::T)
171+
atomic_inc!(ptr::Ptr{T}, val::T)
207172
208173
This is an atomic increment function that counts up to a certain number before starting again at 0.
209174
It reads the value `old` located at address `ptr`, computes `((old >= val) ? 0 : (o ld+1))`, and stores the result back to memory at the same address.
@@ -215,7 +180,7 @@ This operation is only supported for values of type Int32.
215180
atomic_inc!
216181

217182
"""
218-
atomic_dec!(ptr::LLVMPtr{T}, val::T)
183+
atomic_dec!(ptr::Ptr{T}, val::T)
219184
220185
This is an atomic decrement function that counts down to 0 from a defined value `val`.
221186
It reads the value `old` located at address `ptr`, computes `(((old == 0) | (old > val)) ? val : (old-1))`, and stores the result back to memory at the same address.

0 commit comments

Comments
 (0)