From low-level API in MPI.jl, we know
MPI.API.MPI_Reduce_scatter(sendbuf, recvbuf, recvcounts, datatype, op, comm)
When I ran the code below with mpiexecjl -n 3 julia testReduce_scatter.jl:
# testReduce_scatter.jl
using MPI, LinearAlgebra
MPI.Init()
comm = MPI.COMM_WORLD
rank = MPI.Comm_rank(comm)
counts = [2, 2, 1]
V = ones(3,5)
V_vbuf = VBuffer(V, counts .* 3)
Y = zeros(3,counts[rank+1])
Y_buf = MPI.Buffer(Y)
MPI.API.MPI_Reduce_scatter(V, Y, Y_buf.count, V_vbuf.datatype, +, comm)
println(rank, Y)
I got:
ERROR: MethodError: Cannot `convert` an object of type typeof(+) to an object of type Int32
Closest candidates are:
convert(::Type{T}, ::T) where T<:Number at /export/pkgs/linux-u22/julia-1.7.3/share/julia/base/number.jl:6
convert(::Type{T}, ::Number) where T<:Number at /export/pkgs/linux-u22/julia-1.7.3/share/julia/base/number.jl:7
convert(::Type{T}, ::Base.TwicePrecision) where T<:Number at /export/pkgs/linux-u22/julia-1.7.3/share/julia/base/twiceprecision.jl:262
...
Stacktrace:
[1] Type, x::Type, x::VBuffer{Matrix{Float64}})
@ VBuffer{Matrix{Float64}})
@ cconvert(Base ./Base ./T::essentials.jl:417
[2] MPI_Reduce_scatter(sendbuf::VBuffer{Matrix{Float64}}, recvbuf::Matrix{Float64}, recvcounts::Int32, datatype::MPI.Datatype, op::Function, comm::MPI.Comm)
@ MPI.API ~/.julia/packages/MPI/tJjHF/src/api/generated_api.jl:765
[3] top-level scope
@ /export/users/neo/Documents/testReduce_scatter.jl:11
Does anyone happen to know how to fix this? Why it converts an operator + to Int32?