Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/buffers.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
MPIBuffertype{T} = Union{Ptr{T}, Array{T}, SubArray{T}, Ref{T}}
MPIBuffertypeOrConst{T} = Union{MPIBuffertype{T}, SentinelPtr}

# Implementation note
# Base.cconvert and Base.unsafe_convert are a matched pair.
# We must implement Base.unsafe_convert(MPIPtr, ::typeof(Base.cconvert(MPIPtr, x))),
# which is not possible to do generically. So we must define them as we find them.

Base.cconvert(::Type{MPIPtr}, x::Union{Ptr{T}, Array{T}, Ref{T}}) where T = Base.cconvert(Ptr{T}, x)
Base.cconvert(::Type{MPIPtr}, x::SubArray{T}) where T = Base.cconvert(Ptr{T}, x)
function Base.unsafe_convert(::Type{MPIPtr}, x::MPIBuffertype{T}) where T
ptr = Base.unsafe_convert(Ptr{T}, x)
reinterpret(MPIPtr, ptr)
end

@static if VERSION >= v"1.14.0-DEV"
function Base.unsafe_convert(::Type{MPIPtr}, x::Base.OffsetCConvert{T}) where {T}
ptr = Base.unsafe_convert(Ptr{T}, x) # Base handles offset arithmetic
reinterpret(MPIPtr, ptr)
end
end

Base.cconvert(::Type{MPIPtr}, x::String) = x
Base.unsafe_convert(::Type{MPIPtr}, x::String) = reinterpret(MPIPtr, pointer(x))
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ testfiles = sort(filter(istest, readdir(testdir)))
# test number of processes.
"JULIA_MPI_TEST_NUM_PROCESSES"=>string(n))
if f == "test_spawn.jl"
# Some command as the others, but always use a single process
# Same command as the others, but always use a single process
run(cmd(1))
elseif f == "test_threads.jl"
# Legacy Intel MPI (before 2020) crashes threads tests:
Expand Down
Loading