MPI.jl icon indicating copy to clipboard operation
MPI.jl copied to clipboard

Recv

Open iendjinn opened this issue 9 years ago • 3 comments

In mpi-base.jl Recv has the following declaration:

function Recv{T<:MPIDatatype}(::Type{T}, src::Integer, tag::Integer, comm::Comm)

However:

MPI.Recv(Int64, Int(rank + txOffst), Int(i), comm) and MPI.Recv(typeof(rxVal), Int(rank + txOffst), Int(i), comm)

Both throw the error

ERROR: LoadError: MethodError: Recv! has no method matching Recv!(::Type{Ref{Int64}}, ::Int64, ::Int64, ::MPI.Comm)

It appears that Recv calls Recv! which then expects an array type, am I missing something or is this a bug? I notice that there are no tests or examples for sending single objects.

iendjinn avatar Apr 12 '16 14:04 iendjinn

Yes, it seems the definition of Recv! lacks the Ref type; it only handles Ptr and Array. And yes, test coverage is lacking here.

In your examples, the explicit conversions to Int are not necessary.

eschnett avatar Apr 12 '16 14:04 eschnett

Perhaps out of ignorance of what is best practice I have omitted any type declaration for the variables i, rank and txOffst. If I do not explicitly convert to an int I found that the function MPI.Send fails with a no matching method error.

Could the issue with Recv be solved in the same way as single object sends appear to be handled in MPI.Send? I.e. function Recv{T<:MPIDatatype}(obj::T, src::Integer, tag::Integer, comm::Comm) buf = [obj] Recv!(buf, src, tag, comm)

iendjinn avatar Apr 12 '16 14:04 iendjinn

That should work, but is less efficient than changing the declaration of Recv! to include Ref as well: Change buf::Union{Ptr{T},Array{T}} there to buf::Union{Ptr{T},Ref{T},Array{T}}. (Untested; will look at it later today.)

eschnett avatar Apr 12 '16 15:04 eschnett