[mpich-discuss] Extensible Clang type annotation

Dmitri Gribenko gribozavr at gmail.com
Wed Jan 2 13:23:28 CST 2013


On Wed, Jan 2, 2013 at 9:01 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote:
> On Wed, Jan 2, 2013 at 12:09 PM, Dmitri Gribenko <gribozavr at gmail.com>
> wrote:
>>
>> Sorry if what I wrote was unclear.  Here's a complete example:
>>
>> $ cat t.cc
>> #include <mpi.h>
>>
>> enum MyEnum { Foo };
>> MPI_Datatype MyEnumDatatype MPICH_ATTR_TYPE_TAG(MyEnum);
>
>
> Oh, fantastic. I didn't realize this could be applied to uninitialized
> variables (and somehow didn't recognize that you were saying as much in the
> first email). In light of this, can mpi.h change all the static declarations
> to extern

Unfortunately we can not, because user-defined datatypes are
syntactically different from builtin datatypes in MPICH.  MPI_INT is a
macro, so what Clang sees is essentially a magic number.  With
user-defined datatypes there's an identifier (MyEnumDatatype) that
actually shows up in the AST.  There's a separate quirk in Clang for
handling these magic numbers and corresponding 'static const'
variables (not needed for OpenMPI, btw).

> so that the symbols are guaranteed to only show up once in
> executables (rather than once per compilation unit)?

A smart enough compiler (and Clang is smart enough) will eliminate
those even at -O0.

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 gmail.com>*/



More information about the discuss mailing list