You should be able to use normal MPI_TYPE_CREATE_STRUCT functionality to skip members that you don't want represented in a struct.
The general idea is to instantiate one of the classes and then use the addresses of the members to compute the displacement(s) from the base. The same thing works for C/C++ structs. Google around to find some examples; I believe there are plenty of them out on the interwebs. On Dec 13, 2010, at 8:42 AM, Riccardo Murri wrote: > Hi, > > On Fri, Dec 10, 2010 at 2:51 AM, Santosh Ansumali <ansum...@gmail.com> wrote: >>> - 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); >> >> Yes! I agree that i is global as far as different instances of class >> is concern. I don't even want it to be part of MPI datatype. >> However, I am concern >> that as the given class has a static member, is it ok to just ignore >> its existence while creating MPI datatype? >> > > It *should* be. However, an authoritative answer requires good > knowledge of the C++ standard and extensive experience with the > compiler (none of which I personally have), so my suggestion would be > to post the question on comp.lang.c++ or StackOverflow. > > >>> - 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. >> >> True! on what computers there is no memory allocation for static const >> int member. > > As far as I understand it, the "const" is a hint to the compiler that > the value will never change, so the storage *could* be optimized out. > Whether this happens or not, depends on the compiler and the > optimization level (e.g., GCC will never optimize a value out with > -O0, but can do it at -O2), and on the actual code as well: if your > code references "&i" at some point, then the compiler has to create > actual storage for "i". > > >> True! I just want to show the essential part of the class. The real >> class is inheriting from other class which has no data member. > > Beware: if you are using virtual functions in any class of the > hierarchy, then the vtable pointer will be a hidden field in the > class' storage, and you definitely do not want to overwrite it -- this > can influence the start address and/or the displacement of the data. > In a simple case like "class test { double data[5]; }" you can just > use "&data" as the address of your MPI data, but things may be > different in the general case. Again, my adivce would be to post a > question in a dedicated C++ forum for a comprehensive answer. > > If you are going to send C++ classes via MPI, you might want to have a > look at Boost.MPI, which provides an easier interface to sending C++ > classes around, possibly at some performance and/or memory cost. > > Best regards, > Riccardo > > _______________________________________________ > users mailing list > us...@open-mpi.org > http://www.open-mpi.org/mailman/listinfo.cgi/users -- Jeff Squyres jsquy...@cisco.com For corporate legal information go to: http://www.cisco.com/web/about/doing_business/legal/cri/