From: Pascal Proulx <pascal.proulx@cdott.com>
Newsgroups: comp.parallel.mpi
Subject: Re: is it possible to send objects ?
Date: Thu, 15 Apr 1999 13:27:16 -0400
Organization: Computing Devices Canada
Message-Id: <37162174.F1FA4584@cdott.com>
References: <924170828.773010@www3.netland.nl>
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="------------FC1C7F70058FAE5ABDD88506"
Xref: ukc comp.parallel.mpi:4932


This is a multi-part message in MIME format.
--------------FC1C7F70058FAE5ABDD88506
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I used MPI in my C++ software.

What there is to do is simply to teach your objects how to send themselves.
Write a method that will send and another that will receive all data feilds.

Ex.:
Encapsulate mpi send/receive in matrix class of float (Using blocking
send/receive)
const int TAG_ROW = 1;
const int TAG_COL = 2;
const int TAG_DATA = 3;

matrix::send(int destination, MPI_Comm communicator)
{
//send number of rows
MPI_Send(&row, 1, MPI_INT, destination, TAG_ROW, communiator);
//send number of columns (
MPI_Send(&col, 1, MPI_INT, destination, TAG_COL, communicator);
//send data (row*col) of data
MPI_Send(&data[0], row*col, MPI_FLOAT, destination, TAG_DATA, communicator);

}

matrix::receive(int source, MPI_Comm communicator)
{
   int recvRow, recvCol;
MPI_Status status;
//Get number of row
MPI_Recv(&recvRow, 1, MPI_INT, source, TAG_ROW, communicator, &status);
//Get number of columns
MPI_Recv(&recvCol, 1, MPI_INT, source, TAG_COL, communicator, &status);
//resize itself if row or column are not equal to curent dimensions
if ((row!=recvRow)||(col!=recvCol))
    {
        delete [] data;
        data = new float[recvRow*recvCol];
        row = recvRow;
        col = recvCol;
    }
//receive data (row*col) of data
MPI_Recv(&data[0], row*col, MPI_FLOAT, source, TAG_DATA, communicator,
&status);
}

As simple as that.
Of course, this is a crude example...  but you get the general idea.

Pascal Proulx
pascal.proulx@cdott.com

chiwai wrote:

> Hi thanx for helping me out with the permission denied problem.. it is
> finally solved now.. I have an another question can I send objects to an
> another process as a derived datatype ?
>
> MPI_Send(object,.......) ?
>
> is that possible ?
>
> My boss has a object oriented program  and he wants to know if it is
> possible to embed the mpi functions to make it work faster.
>
> Thanx !



--------------FC1C7F70058FAE5ABDD88506
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Pascal Proulx
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Pascal Proulx
n:              Proulx;Pascal
org:            Computing Devices Canada, a General Dynamic Company
email;internet: pascal.proulx@cdott.com
title:          Software Engineer
x-mozilla-cpt:  ;0
x-mozilla-html: FALSE
version:        2.1
end:            vcard


--------------FC1C7F70058FAE5ABDD88506--

