Newsgroups: comp.parallel.mpi
From: Wolfram Webers <wwebers@cs.tu-berlin.de>
Subject: Re: sending various datatypes in MPI
Organization: TU-Berlin
Date: Thu, 07 May 1998 09:44:29 +0200
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <3551665D.548B9A9D@cs.tu-berlin.de>

Ben Kao wrote:

> Forgive me if this is a silly question, but I can't figure out how to
> send datatypes which do not fall into the standard MPI_INT, MPI_CHAR,
> etc datatypes.  Thus, for example, how would one go about sending
> something which is defined as a C++ class?
>
> Thanks,
>
> - ben
> bkao@eecs.uic.edu

Normally all C++ classes are bases on atomic C-Datatypes that are
supported by MPI. All you have to do is to create member-functions
pack/unpack/packsize in your class your want to communicate. This
functions must code the class-entries into a byte-buffer (or in a
structure defined by MPI_Type_struct). On recursiv datatypes the
construction of the buffer must be resursiv, too. But this is not a
problem
if you create a base-class with the three member functions an overload
them in all inherited classes.

Ciao, Wolfram.



