Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Threads.Atomic{Ptr} #29943

Closed
oxinabox opened this issue Nov 6, 2018 · 2 comments · Fixed by #37847
Closed

Support Threads.Atomic{Ptr} #29943

oxinabox opened this issue Nov 6, 2018 · 2 comments · Fixed by #37847
Labels
multithreading Base.Threads and related functionality

Comments

@oxinabox
Copy link
Contributor

oxinabox commented Nov 6, 2018

There is a TODO for this in the code, but no open issue AFAICT.

# TODO: Support Ptr

That todo used to be for Bool as well, but that was solved in #26542

Without atomic operations on pointers, it is impossible to make lock-free multithreaded data structures.
which is a huge bummer for:
https://github.com/JuliaCollections/ThreadSafeDataStructures.jl

@chethega
Copy link
Contributor

chethega commented Nov 6, 2018

Which operations do we want, anything else besides atomic_cas! and atomic_xchg!?

@oxinabox
Copy link
Contributor Author

oxinabox commented Nov 7, 2018

We should support as much of the Ptr methods as can be done atomically.

julia> methodswith(Ptr)
[1] +(x::Integer, y::Ptr) in Base at pointer.jl:157
[2] +(x::Ptr, y::Integer) in Base at pointer.jl:155
[3] -(x::Ptr, y::Ptr) in Base at pointer.jl:153
[4] -(x::Ptr, y::Integer) in Base at pointer.jl:156
[5] <(x::Ptr, y::Ptr) in Base at pointer.jl:152
[6] ==(x::Ptr, y::Ptr) in Base at pointer.jl:151
[7] ==(x::Union{Cstring, Cwstring}, y::Ptr) in Base at c.jl:190
[8] ==(x::Ptr, y::Union{Cstring, Cwstring}) in Base at c.jl:191
[9] convert(::Type{T}, x::Ptr) where T<:Integer in Base at pointer.jl:23
[10] convert(::Type{Ptr{T}}, p::Ptr{T}) where T in Base at pointer.jl:29
[11] convert(::Type{Ptr{T}}, p::Ptr) where T in Base at pointer.jl:30
[12] dump(io::IOContext, x::Ptr, n::Int64, indent) in Base at show.jl:1641
[13] isequal(x::Ptr, y::Ptr) in Base at pointer.jl:148
[14] isless(x::Ptr{T}, y::Ptr{T}) where T in Base at pointer.jl:149
[15] show(io::IO, p::Ptr) in Base at show.jl:572
[16] unsafe_copyto!(dest::Ptr{T}, src::Ptr{T}, n) where T in Base at array.jl:225
[17] unsafe_load(p::Ptr) in Base at pointer.jl:105
[18] unsafe_load(p::Ptr, i::Integer) in Base at pointer.jl:105
[19] unsafe_pointer_to_objref(x::Ptr) in Base at pointer.jl:128
[20] unsafe_read(s::IO, p::Ptr, n::Integer) in Base at io.jl:585
[21] unsafe_store!(p::Ptr{T}, x) where T in Base at pointer.jl:118
[22] unsafe_store!(p::Ptr{T}, x, i::Integer) where T in Base at pointer.jl:118
[23] unsafe_wrap(::Union{Type{Array{T,N} where N}, Type{Array{T,N}}, Type{Array}}, p::Ptr{T}, dims::Tuple{Vararg{Int64,N}}) where {T, N} in Base at pointer.jl:84
[24] unsafe_wrap(::Union{Type{Array{T,N} where N}, Type{Array{T,1}}, Type{Array}}, p::Ptr{T}, d::Integer) where T in Base at pointer.jl:89
[25] unsafe_wrap(Atype::Type, p::Ptr, dims::Tuple{Vararg{#s55,N}} where #s55<:Integer) where N in Base at pointer.jl:92
[26] unsafe_write(s::IO, p::Ptr, n::Integer) in Base at io.jl:509
[27] write(to::IO, p::Ptr) in Base at io.jl:517
[28] dlclose(p::Ptr) in Libdl at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Libdl\src\Libdl.jl:119
[29] dlsym(hnd::Ptr, s::Union{AbstractString, Symbol}) in Libdl at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Libdl\src\Libdl.jl:54
[30] dlsym_e(hnd::Ptr, s::Union{AbstractString, Symbol}) in Libdl at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Libdl\src\Libdl.jl:64
[31] serialize(s::Serialization.AbstractSerializer, p::Ptr) in Serialization at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Serialization\src\Serialization.jl:181

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
multithreading Base.Threads and related functionality
Projects
None yet
3 participants