Newsgroups: comp.parallel.mpi
From: singhai@cs.uiuc.edu (Ashish Singhai)
Subject: Re: Passing non contiguous data of various size
Organization: University of Illinois at Urbana
Date: 14 Dec 1996 06:09:37 GMT
Message-ID: <58tgb1$ee7@vixen.cso.uiuc.edu>

L'Excellent Jean Yves <excelle@cerfacs.fr> writes:

>Is there any way with MPI to send, for example, an integer LIWK and an
>array of length LIWK in a single message ?

>Defining an MPI type is not possible here because the type doesn't have
>a fixed length, and I would like to avoid sending several messages.

>The use of PACK and UNPACK does not look very efficient also because of
>the copy into a buffer. (in PVM this was possible using the "data in
>place" mode)

How about:
	typedef struct myData_t {int liwk; int *array} myData;
	myData data;
	data.liwk = <length of the array>;
	data.array = (int *)malloc(<length of the array>);
	int disp[2];
	disp[0] = (char *)(&data.liwk) - (char *)&data;
	disp[1] = (char *)(&data.array[0]) - (char *)&data;
	MPI_Datatype typ;
	typ = MPI_Type_struct(count=2, blocklengths={1,liwk},
				displacements=disp,
				old_types = {MPI_Integer, MPI_Integer});
	
	then use "typ" for sending.  I am not sure how will you receive
it though, you will have to use the maximum possible length for receive
as far as I can think.

	Comments?

- ashish
Ashish Singhai
singhai@uiuc.EDU

