jipolanco / PencilArrays.jl

Distributed Julia arrays using the MPI protocol
https://jipolanco.github.io/PencilArrays.jl/dev/
MIT License
60 stars 8 forks source link

`MPITopology` usage with `comm_cart` not as presented in docs #71

Closed chowland closed 1 year ago

chowland commented 1 year ago

I've noticed that the usage of MPITopology with a pre-existing Cartesian communicator doesn't work following the documentation. Simply passing

dims = (2,3)
MPI.Init()
comm_cart = MPI.Cart_create(MPI.COMM_WORLD, dims)
topo = MPITopology(comm_cart)

gives an error, which is fixed by specifying

topo = MPITopology{2}(comm_cart)

I'm not sure whether this is intended (and should then be changed in the docs) or whether another method for MPITopology should be defined to make things work as suggested by the documentation

jipolanco commented 1 year ago

You're right, it's a documentation issue. It should be MPITopology{2}(comm_cart) as you noticed. Thanks for catching that.

Note that in the docs for the MPITopology type the right constructor is used:

comm = MPI.COMM_WORLD
@assert MPI.Comm_size(comm) == 8
pdims = (4, 2)
comm_cart = MPI.Cart_create(comm, pdims)
topology = MPITopology{2}(comm_cart)