Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: [OMPI users] Which MPI data types correspond to ptrdiff_t and to size_t in C?
From: Gus Correa (gus_at_[hidden])
Date: 2013-03-13 18:30:43


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