From 4b42ecae7b17f6a0a4ee2d8656244f690c8ad3ba Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Tue, 10 Mar 2026 12:47:30 -0400 Subject: [PATCH 1/2] Support `Base.OffsetCConvert` in Julia 1.14 --- src/buffers.jl | 7 ++++++- test/runtests.jl | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/buffers.jl b/src/buffers.jl index 57d848d6c..cccd367cb 100644 --- a/src/buffers.jl +++ b/src/buffers.jl @@ -7,7 +7,12 @@ 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)) diff --git a/test/runtests.jl b/test/runtests.jl index 30d27b674..351c87564 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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: From a26c6673a8db4cfc238add575d1c7850fb20005d Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Wed, 18 Mar 2026 12:28:48 +0100 Subject: [PATCH 2/2] add an implementation note --- src/buffers.jl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/buffers.jl b/src/buffers.jl index cccd367cb..156c76805 100644 --- a/src/buffers.jl +++ b/src/buffers.jl @@ -1,6 +1,11 @@ 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