JuliaConcurrent / Atomix.jl

https://juliaconcurrent.github.io/Atomix.jl/dev/
MIT License
20 stars 2 forks source link

Error with non-integer types #34

Closed leios closed 2 years ago

leios commented 2 years ago
julia> using Atomix: @atomic, @atomicswap, @atomicreplace

julia> A = ones(Int, 3);

julia> @atomic A[1] += 1;

julia> B = ones(3);

julia> @atomic B[1] += 1;
ERROR: MethodError: no method matching modify!(::Ptr{Float64}, ::typeof(+), ::Float64, ::UnsafeAtomics.Internal.LLVMOrdering{:seq_cst})
Closest candidates are:
  modify!(::Any, ::Any, ::Any) at ~/.julia/packages/UnsafeAtomics/7h3VM/src/core.jl:4
  modify!(::Ptr{UInt16}, ::typeof(+), ::UInt16, ::UnsafeAtomics.Internal.LLVMOrdering{:seq_cst}) at ~/.julia/packages/UnsafeAtomics/7h3VM/src/core.jl:135
  modify!(::Ptr{UInt8}, ::typeof(+), ::UInt8, ::UnsafeAtomics.Internal.LLVMOrdering{:seq_cst}) at ~/.julia/packages/UnsafeAtomics/7h3VM/src/core.jl:135
  ...
Stacktrace:
 [1] modify!(ref::Atomix.Internal.IndexableRef{Vector{Float64}, Tuple{Int64}}, op::typeof(+), x::Int64, ord::UnsafeAtomics.Internal.LLVMOrdering{:seq_cst})
   @ Atomix.Internal ~/.julia/packages/Atomix/YUCHG/src/core.jl:33
 [2] top-level scope
   @ REPL[5]:1

I have been running into this error with some KA testing. I am not really sure what I am doing wrong or how to fix this.

vchuravy commented 2 years ago

cc: @tkf

tkf commented 2 years ago

I think https://github.com/JuliaConcurrent/UnsafeAtomics.jl/pull/9 solved this (included in UnsafeAtomics v0.2.1 https://github.com/JuliaConcurrent/UnsafeAtomics.jl/releases/tag/v0.2.1)