Hello,
My colleague and I want to implement a compile-time check (warning)
for clang compiler that specified buffer type matches passed
MPI_Datatype.
For example:
MPI_Send(long_buf, 1, MPI_INT, 1, 1, MPI_COMM_WORLD); //
expected-warning {{actual buffer element type 'long' doesn't match
specified MPI_Datatype}}
We've hacked a prototype patch for clang, but first we wanted to
discuss this idea with OpenMPI developers.
Here's what is required on the OpenMPI part: all MPI functions that
accept a buffer and MPI_Datatype should be annotated with
mpi_typed_arg(buffer-arg-index, type-arg-index) attribute. For
example:
int MPI_Send(void *buf, ...etc...) __attribute__(( mpi_typed_arg(1,3) ));
Predefined datatypes should be annotated with corresponding C types:
mpi_datatype(var-decl-with-corresponding-type):
extern int ompi_mpi_int_dummy;
extern struct ompi_predefined_datatype_t ompi_mpi_int
__attribute__(( mpi_datatype(ompi_mpi_int_dummy) ));
Users can annotate their types too:
int my_int_dummy;
MPI_Datatype my_int_type __attribute__(( mpi_datatype(my_int_dummy) ));
This design is not final, I'd really like to have mpi_datatype(type)
(e.g., mpi_datatype(long long)) but clang doesn't currently have
support for parsing that. (But I think that clang developers won't
accept the patch unless we implement that). So type annotations will
probably look like:
extern struct ompi_predefined_datatype_t ompi_mpi_int
__attribute__(( mpi_datatype(int) ));
The attributes can be hidden with macros from compilers that don't
support them, so compatibility should not be a problem.
See attached test and clang output to see what will it look like.
Any comments are welcome. Please also tell me if you have any ideas
for additional compile-time checks.
I would like to hear if there is any issue with this idea or
implementation design that could prevent the corresponding patch for
mpi.h to be accepted.
Dmitri Gribenko
--
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_[hidden]>*/
|