Using atomic operations in Julia 1.6

Depending on what you’re doing, this might be fine, but it really depends. The main differences w.r.t ordering are that you can’t control what ordering is used for Threads.Atomic{T}; for example, atomic_add! always uses acquire-release ordering. If this is what you need, and your element type is supported, then it’ll be mostly equivalent to using @atomic :acquire_release x.a += y (and thus performance should be similar).

I recommend checking out base/atomics.jl in the Julia repository and cross-referencing with what’s in LLVM Language Reference Manual — LLVM 16.0.0git documentation to determine if the available calls suit your needs.

3 Likes