Open MPI logo

Open MPI Development Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Development mailing list

Subject: Re: [OMPI devel] Compile-time MPI_Datatype checking
From: Dmitri Gribenko (gribozavr_at_[hidden])
Date: 2012-02-01 17:36:27


On Wed, Feb 1, 2012 at 10:01 PM, Jeff Squyres <jsquyres_at_[hidden]> wrote:
> On Jan 28, 2012, at 6:07 PM, Dmitri Gribenko wrote:
>> 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) ));
>
> This isn't terrible; we do similar things throughout the code base.
>
> Will you be able to do this for MPI functions that take 2 choice buffers?  E.g., MPI_Gather.

Yes, just put two attributes: __attribute__(( mpi_typed_arg(1,3),
mpi_typed_arg(4,6) ))

>> 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) ));
>
> Just to make sure I understand this syntax: is ompi_mpi_int_dummy just to indicate the *type* that is congruent with the ompi_predefined_datatype_t?

Yes, I did it that way because parsing a type-name as attribute
argument is not possible currently in clang, but I wanted to check how
it will work as quickly as possible. But I'm now hacking the parser
to support the cleaner syntax.

> I.e., I'd do something like this for MPI_DOUBLE:
>
> extern double ompi_mpi_double_dummy;
> extern struct ompi_predefined_datatype_t ompi_mpi_double
>   __attribute__(( mpi_datatype(ompi_mpi_double_dummy) ));
>
> ?

Right, but I'm going for the cleaner syntax anyway.

>> Users can annotate their types too:
>> int my_int_dummy;
>> MPI_Datatype my_int_type __attribute__(( mpi_datatype(my_int_dummy) ));
>
> More importantly, can they do:
>
> struct my_struct_t my_struct_dummy;
> MPI_Datatype my_struct_type __attribute__(( mpi_datatype(my_struct_dummy) ));
>
> ?

Yes, specifying any type is possible.

>> 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.
>
> I'm supportive of this (mpi.h.in, you mean :-) ).
>
> Depending on the patch, however, we might need a signed Open MPI contribution agreement from you/your employer

That's fine for us.

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]>*/