Re: [mpich-discuss] Extensible Clang type annotation
[resending to the list, sorry for duplicates] On Wed, Jan 2, 2013 at 7:31 PM, Dave Goodell <[email protected]> wrote:
[adding Hal Finkel and Dmitri Gribenko, who did most of the annotations work]
Hal/Dmitri,
Do you have any ideas about how to handle Jed's case? Will the MPICH_ATTR_TYPE_TAG_LAYOUT_COMPATIBLE macro (reproduced below) help in this case?
----8<---- # define MPICH_ATTR_TYPE_TAG_LAYOUT_COMPATIBLE(type) __attribute__((type_tag_for_datatype(MPI,type,layout_compatible))) ----8<----
-Dave
On Dec 30, 2012, at 11:13 PM CST, Jed Brown wrote:
I upgraded to clang-3.2 and the new type annotations are great. I'd like to have a identified for enum types, e.g.
typedef enum {SOME, VALUES} MyEnum; #define MY_MPI_ENUM MPI_INT // or define some other way static const MPI_Datatype my_mpi_enum MPICH_ATTR_TYPE_TAG(MyEnum) = MY_MPI_ENUM;
Of course the above does not work because the new definition masks the old one, so all the normal 'int' uses are hidden. Unfortunately, the annotation syntax requires compile-time constants, which are not accessible to me.
Is there any hope for something like this, or do I have to choose between (a) ugly cast at all MPI call points and (b) make MY_MPI_ENUM a variable so that the compiler can't check it statically?
Hi everyone, I don't think we can make it work with the way MPICH currently defines type tags (MPI_INT etc). The issue is that these are preprocessor macros, so in the AST we can only see the values they expand to. So MPI_INT and MY_MPI_ENUM become indistinguishable. But, if you create a different datatype (with MPI_Type_contigous, probably), it should be possible. enum MyEnum { Foo }; MPI_Datatype MyEnumDatatype MPICH_ATTR_TYPE_TAG(MyEnum); int main() { ... MPI_Type_contiguous(1, MPI_INT, MyEnumDatatype); } I haven't tried it. Please tell me if it does not work. 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 <[email protected]>*/
participants (1)
-
Dmitri Gribenko