MPI_Aint is always signed, as it is supposed to be able to hold any relative difference between two memory locations. This it is a good match for ptrdiff_t.
There is no direct match for size_t, at least not directly exposed by the MPI standard (using the MPI-2.2 POSIX types, e.g MPI_UINT64_T). My understanding is that size_t is unsigned, and ssize_t is the signed synonym.
On Mar 13, 2013, at 23:30 , Gus Correa <gus_at_[hidden]> wrote:
> Dear Open MPI Pros
> Which MPI data type corresponds to ptrdiff_t in C?
> I guess the same question can be asked about size_t.
> The FFTW3.3 MPI API has lots of stuff declared as
> ptrdiff_t, and I need to pass them around with MPI,
> hopefully without size or sign mistakes.
> I am using Open MPI 1.6.3, if this matters.
> My C goes as far as ABC, and in my naive view
> ptrdiff_t is signed and has 64-bits on my x86_64 Linux computer,
> whereas size_t is unsigned also 64-bits, right?
> If I grep mpi.h for ptrdiff I see that OPAL_PTRDIFF_TYPE is
> MPI_Aint, which is indeed an MPI pointer/address type.
> However, this is OPAL, not generic MPI.
> Moreover, MPI_Aint seems to be unsigned, right?
> [And this would make it a bad match for ptrdiff_t,
> but maybe a good match for size_t.]
> Or is MPI_Aint signed?
> [grep result:]
> 147:/* type to use for ptrdiff_t, if it does not exist, set to ptrdiff_t if it does exist */
> 148:#define OPAL_PTRDIFF_TYPE ptrdiff_t
> 218:/* include for ptrdiff_t */
> 317:typedef OPAL_PTRDIFF_TYPE MPI_Aint;
> OTOH, there are bunches of signed and unsigned integer MPI types
> in mpi.h.
> In a 64-bit machine, besides MPI_Aint,
> I guess possible candidates would be
> MPI_INT64_T and MPI_UINT64_T.
> But which one: signed or unsigned?
> Even if I write a little function to find an MPI integer type
> with the same extent as sizeof(ptrdiff_t), it may still
> return more than one type, and be problematic to pick one
> (e.g., signed or unsigned?).
> Any help is appreciated.
> Gus Correa
> users mailing list