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 OpenMPI side we need to: * add attributes to MPI functions to mark them as accepting pointers with type tags; * add attributes to ompi_mpi_* declarations to mark them as type tags. All in all, the changes boil down to: 1. Annotate type tags: OMPI_DECLSPEC extern struct ompi_predefined_datatype_t ompi_mpi_float OMPI_ATTR_TYPE_TAG(float); 2. Annotate functions: OMPI_DECLSPEC int MPI_Send(void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) OMPI_ATTR_POINTER_WITH_TYPE_TAG(1,3); where OMPI_ATTR* are macros that are defined to attributes when compiling under clang with this feature. Attached is the OpenMPI patch I've arrived to. Although I tried to be attentive, changes to mpi.h are very repetitive and error-prone, so please review them closely. I've implemented a similar patch for MPICH2. [2] OpenMPI developers might want to follow that discussion, too. Dmitri [1] http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20120521/058137.html [2] http://lists.mcs.anl.gov/pipermail/mpich2-dev/2012-May/000938.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 <griboz...@gmail.com>*/
ompi-v2.patch
Description: Binary data