[mpich-discuss] basic datatype for MPI_Offset

Dave Goodell goodell at mcs.anl.gov
Mon Apr 27 08:08:13 CDT 2009


On Apr 26, 2009, at 11:41 PM, Wei-keng Liao wrote:

> What basic MPI datatype one should use in MPI functions
> for variables of MPI_Offset type? For example,
>
> MPI_Offset offsets[nprocs];
> MPI_Allreduce(MPI_IN_PLACE, offsets, nprocs, MPI_???, MPI_MAX,  
> MPI_COMM_WORLD);
>
> Will there be a new base type, MPI_OFFSET (all capitals)?


I have proposed [1] a modification to the MPI standard for the MPI-2.2  
version that will add MPI_AINT and MPI_OFFSET predefined types  
corresponding to MPI_Aint/MPI_ADDRESS_KIND and MPI_Offset/ 
MPI_OFFSET_KIND respectively.  The MPI Forum has not yet voted on this  
proposal, but based on straw votes in the past I think that the  
chances of it passing and making into the 2.2 standard are pretty  
good.  If it does pass, then MPICH2 and many other MPI implementations  
will probably have this feature by early Fall of 2009.

In the interim you can use a hack like the following as long as you  
are not running in a heterogeneous environment:

--------8<---------
MPI_Offset offsets[nprocs];
MPI_Datatype offset_type = MPI_DATATYPE_NULL;
if      (sizeof(MPI_Offset) == sizeof(int))  { offset_type = MPI_INT; }
else if (sizeof(MPI_Offset) == sizeof(long)) { offset_type = MPI_LONG; }
else if (sizeof(MPI_Offset) == sizeof(long long)) { offset_type =  
MPI_LONG_LONG; }
else { MPI_Abort(MPI_COMM_WORLD, 1); }
MPI_Allreduce(MPI_IN_PLACE, offsets, nprocs, offset_type, MPI_MAX,  
MPI_COMM_WORLD);
--------8<---------

If you are running in some sort of heterogeneous environment then this  
code might not work correctly if different processes might select  
different types as aliases for MPI_Offset.

-Dave

[1] https://svn.mpi-forum.org/trac/mpi-forum-web/ticket/18


More information about the mpich-discuss mailing list