# Julia 0.6 and MPI wrapper

**URL:** <https://discourse.julialang.org/t/julia-0-6-and-mpi-wrapper/6575>\
**Category:** General Usage\
**Created:** [October 19, 2017, 10:20pm UTC](https://discourse.julialang.org/t/julia-0-6-and-mpi-wrapper/6575 "2017-10-19T22:20:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthias.taus](https://avatars.discourse-cdn.com/v4/letter/m/bcef8e/32.png) [@matthias.taus](https://discourse.julialang.org/u/matthias.taus)\
**Post date:** [October 19, 2017, 10:20pm UTC](https://discourse.julialang.org/t/julia-0-6-and-mpi-wrapper/6575/1 "2017-10-19T22:20:39Z")

</div>

Hi,

I just updated to Julia 0.6 and am using the MPI wrapper. When I try to send a vector using MPI, the sending command never finishes. For example the following code does not finish:

```julia
using MPI

MPI.Init()
x = rand( Complex128, 300 )
sreq = MPI.Isend( x, 1, 0, MPI.COMM_WORLD )
MPI.Wait!(sreq)
MPI.Finalize()

```

Am I doing something wrong? Did anybody else experience similar issues?

When using Julia 0.5 I never ran into such issues. Also, if I do not request to wait for the send request and receive the message, only the first part of the vector is received. If I use smaller vectors, everything works well also.

Thank you,  
Matthias

---

<div class="post-metadata">

**Author:** ![JaredCrean2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jaredcrean2/32/3574_2.png) [@JaredCrean2](https://discourse.julialang.org/u/JaredCrean2)\
**Post date:** [October 20, 2017, 3:39am UTC](https://discourse.julialang.org/t/julia-0-6-and-mpi-wrapper/6575/2 "2017-10-20T03:39:30Z")

</div>

Can you post a complete minimal example? Whether or not this behavior is expected depends on what code is running on MPI rank 1.

---

<div class="post-metadata">

**Author:** ![matthias.taus](https://avatars.discourse-cdn.com/v4/letter/m/bcef8e/32.png) [@matthias.taus](https://discourse.julialang.org/u/matthias.taus)\
**Post date:** [October 20, 2017, 1:46pm UTC](https://discourse.julialang.org/t/julia-0-6-and-mpi-wrapper/6575/4 "2017-10-20T13:46:51Z")

</div>

Hi Jared,

My file test.jl looks like that:

```julia
using MPI
MPI.Init()
rank = MPI.Comm_rank(MPI.COMM_WORLD)
if( rank==0 )
  x = rand(Complex128,200)
  sreq = Vector{MPI.Request}(0)
  for pp=1:MPI.Comm_size(MPI.COMM_WORLD)
    push!( sreq, MPI.Isend( x, pp-1, pp, MPI.COMM_WORLD ) )
  end
  MPI.Waitall!(sreq)
end
println("done")
MPI.Finalize()

```

I then run the code with

```julia
mpirun -np 2 julia test.jl

```

and it does not finish.

If I change test.jl to just send a shorter (10-element) vector:

```julia
using MPI
MPI.Init()
rank = MPI.Comm_rank(MPI.COMM_WORLD)
if( rank==0 )
  x = rand(Complex128,10)
  sreq = Vector{MPI.Request}(0)
  for pp=1:MPI.Comm_size(MPI.COMM_WORLD)
    push!( sreq, MPI.Isend( x, pp-1, pp, MPI.COMM_WORLD ) )
  end
  MPI.Waitall!(sreq)
end
println("done")
MPI.Finalize()

```

Then, when I run the file as

```julia
mpirun -np 2 julia test.jl

```

it finishes with no problems.

Thank you,  
Matthias

---

<div class="post-metadata">

**Author:** ![JaredCrean2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jaredcrean2/32/3574_2.png) [@JaredCrean2](https://discourse.julialang.org/u/JaredCrean2)\
**Post date:** [October 20, 2017, 3:57pm UTC](https://discourse.julialang.org/t/julia-0-6-and-mpi-wrapper/6575/5 "2017-10-20T15:57:13Z")

</div>

This behavior is expected. The reason is that there is no MPI receive to match the MPI.Isend, so, in general, the MPI.Waitall is waiting for the send to finish, which will never happen. In some special case (small vectors, for example) MPI will do the send even if there is no receive yet, buffer the data internally, and then copy it into the receive buffer when the receive is finally posted.
