MPI_Aint in MPI_(I)NEIGHBOR_ALLTOALLW() vs int in MPI_(I)ALLTOALLW()
mpi
Solution
`MPI_Aint` is a portable C data type that can hold memory addresses and it could be larger than the usual `int`. The policy of the MPI Forum is to not change the signature of existing MPI calls (as it could break existing applications - see here). Rather new calls are introduced that supersede the old ones. The rationale is that `int` worked well before LP64 64-bit architectures become popular at which point `int` could no longer be used to address the whole virtual address space of a single process. After this realisation some MPI calls got new versions in later versions that use `MPI_Aint` or `MPI_Count` (large integer type) instead of `int`. For example, `MPI_Get_count_x` supersedes `MPI_Get_count` and uses `MPI_Count` instead of `int`.
In this respect `MPI_Alltoallw` is an old call (it comes from MPI-2.0) and it retains its signature of using `int` offsets while `MPI_(I)Neighbor_alltoallw` is a new one (it comes with MPI-3.0) and it uses the address type in order to be able to work with data located (almost) anywhere in memory.
The same applies to the Fortran bindings.
Problem
With MPI3.0 neighborhood collective communications were introduced. And in 2 of them (`MPI_NEIGHBOR_ALLTOALLW` and `MPI_INEIGHBOR_ALLTOALLW`) displacements (`sdispls` and `rdispls`) are arrays of `const MPI_Aint`. Contrariwise of how the same, but collective, funcions (`MPI_ALLTOALLW` and `MPI_ALLTOALLW`) are defined -arrays of `const int`. Also considering what the MPI Standard v3.0 says about MPI_Aint (page 16): 2.5.6 Addresses Some MPI procedures use address arguments that represent an absolute address in the calling program. The datatype of such an argument is MPI_Aint in C and INTEGER (KIND=MPI_ADDRESS_KIND) in Fortran. These types must have the same width and encode address values in the same manner such that address values in one language may be passed directly to another language without conversion. There is the MPI constant MPI_BOTTOM to indicate the start of the address range. I still don't get the point and, if exist, the difference (in addition that `MPI_Aint` can't be negative) between `int` and `MPI_Aint`!