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-10-26 12:48:24


On Fri, Oct 26, 2012 at 6:37 PM, Jeff Squyres <jsquyres_at_[hidden]> wrote:
> This all now looks good to me

Thank you for reviewing and helping me to get this up to the project's
standards!

> For me to commit this, can you do two things:
>
> 1. I hate to do this, but this is more than a "trivial" patch that we could accept without attribution. Can you do one of two things:
> 1a. Sign a contributor agreement (almost identical to the Apache contributor agreement): http://www.open-mpi.org/community/contribute/

I sent it synchronously with v1 of the patch. I understand that it
was a while ago, but it should be sitting somewhere in your mail.
IIRC, I sent a "corporate" one as an employee of High Performance
Computing Center at NTUU "KPI". If you can not find it -- I can send
another one (but it is a bit complicated to get legal documents like
this signed, so please try to find the one I sent).

> 1b. Send a v6 of your patch to this public mailing list with a BSD-compatible license at the top, thereby releasing your patch under that license (which is compatible with OMPI's).

Attached.

> 2. Give me a short description that I can use to put into the README / FAQ / etc. about what this functionality does, what prerequisites are needed (e.g., version of clang, etc.).

Here's what I came up with. Feel free to edit or ask for clarifications.

=== NEWS entry ===
mpi.h header was annotated to enable compile-time type checking of
buffers and type tags. These annotations are understood by Clang 3.2
and later versions. This imposes no requirements on the compiler
which is used to compile OpenMPI itself (for example, one can compile
OpenMPI with GCC and use Clang to compile an MPI application).

=== FAQ entry ===
How to diagnose mismatches between buffer type and type tag?

In OpenMPI communication functions' declarations and predefined type
tags are annotated with <tt>pointer_with_type_tag</tt> and
<tt>type_tag_for_datatype</tt> attributes. These attributes allow
compilers to check that buffer type matches the type tag.

These attributes are understood by Clang 3.2 and later versions.
Please note that this imposes no requirements on the compiler which is
used to compile OpenMPI itself (for example, one can compile OpenMPI
with GCC and use Clang to compile an MPI application).

For example, consider the following code:

double *double_buf = /* ... */;
MPI_Send(double_buf, 1, MPI_INT, /* ... */);

Clang produces a diagnostic:

wrong.c:151:12: warning: argument type 'double *' doesn't match
specified 'mpi' type tag that requires 'int *' [-Wtype-safety]
  MPI_Send(double_buf, 1, MPI_INT);
           ^~~~~~~~~~ ~~~~~~~

Dmitri

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