[mpich2-dev] Compile-time MPI_Datatype checking

Dmitri Gribenko gribozavr at gmail.com
Tue May 29 08:58:16 CDT 2012


Hello,

I've implemented a patch for clang that enables compile-time checking
of <pointer, type tag> arguments to functions.  When applied to MPI,
this enables the compiler to check that buffer type and MPI_Datatype
match.

Latest version of clang patch can be found here. [1]  Please note that
clang patch was not yet accepted to clang trunk.

On the MPICH2 side we need to:
* add attributes to MPI functions to mark them as accepting pointers
with type tags;
* because MPICH2 uses magic values for type tags we need to introduce
declarations to which we attach attributes that mark them as type
tags.

All in all, the changes boil down to:
1. Introduce declarations like:
static const MPI_Datatype mpich_mpi_float
    MPICH_ATTR_TYPE_TAG(float) = MPI_FLOAT;

2. Annotate functions:
int MPI_Send(void*, int, MPI_Datatype, int, int, MPI_Comm)
    MPICH_ATTR_POINTER_WITH_TYPE_TAG(1,3);

where MPICH_ATTR* are macros that are defined to attributes when
compiling under clang with this feature.

Attached is the MPICH2 patch I've arrived to.  Please pay extreme
attention to changes to hairy Perl scripts that generate bindings.

Although I tried to be attentive, changes to mpi.h are very repetitive
and error-prone, so please review them closely, too.

Dmitri

[1] http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20120521/058137.html

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mpich2-v2.patch
Type: application/octet-stream
Size: 60227 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/mpich2-dev/attachments/20120529/67ef59c1/attachment-0001.obj>


More information about the mpich2-dev mailing list