On Wed, Dec 8, 2010 at 10:04 PM, Santosh Ansumali <ansum...@gmail.com> wrote: > I am confused with the use of MPI derived datatype for classes with > static member. How to create derived datatype for something like > class test{ > static const int i=5; > double data[5]; > } >
This looks like C++ code, and I think there can be a couple of problems with sending this as an MPI derived datatype: - the "static" data member is shared between all instances of the class, so it cannot be part of the MPI datatype (it will likely be at a fixed memory location); - in addition, the "i" member is "static const" of a POD type, meaning the compiler is allowed to optimize it out and not allocate any actual memory location for it; This boils down to: the only data you need to send around in a "class test" instance is the "double data[5]" array. If the static member were not "const", you could send it in a separate message. Best regards, Riccardo P.S. Besides, all members in a "class" are private by default and "class test" does not have a constructor, so there's no way you can put any useful values into this "test" class. (But I guess this is just an oversight when stripping down the code for the example...)