Newsgroups: comp.parallel.mpi
From: Jonathan Stanton <jonathan@cs.jhu.edu>
Subject: Problem transmitting a non-contiguous block of structures to another processor (fwd)
Organization: HCF - Johns Hopkins University, Baltimore, Maryland, USA
Date: Sun, 29 Oct 1995 21:45:16 -0500
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Message-ID: <Pine.SUN.3.91.951029214011.22285A-100000@condor.cs.jhu.edu>


Hello,

	If anyone out there has an idea of how to either solve this problem or 
a diffeent way to transmit this kind of data using MPI I'd appreciate any 
help.  I've thought of several varients but none ofthem really work for 
this exact problem.

	 I'm not sure if this is a bug, a feature or a hole in the 
specification, but here is the problem. I'm using mpich on a network of 
Spark 20's using the ch_p4 library.

	I'm trying to send a collection of data structures(they represent 
molecules) from one processor to another.  The collection of molecules to 
be transmitted needs to be computed dynamically, so I build up a datatype 
using MPI_Type_hindexed consisting of the correct molecules, commit the 
type and send it to the other processor.  The other processor first 
probes to findout the bytes sent, then calls MPI_Get_count to find out 
how many molecules were sent. I would then use this number to allocate a 
buffer and call receive.  The problem occus with Get_count.  The number 
of bytes sent is the "size" of the created datatype on P0.  This size 
includes(for example) 8 molecules each of which has 676 bytes of data and 
a pad of 4 bytes, so the formula used to compute the size of the hindexed 
datatype is 8*676+7*4. So the size includes the padding between each 
molecule.

	Now the Get_count takes this size(5436 bytes) mod the molecule 
type size (676) and if the result is not 0 returns an MPI_UNDEFINED value 
instead of a valid count.  I.e. it checks if the number of bytes received 
represent an integer number of the molecules that are trying to be 
received(which seems a valid kind of thing to check) but in this case 
although I sent 8 molecules and want to receive 8 molecules, becasue of 
the padding 5436 mod 676 NOT equal to 0, so it gives me the error.

	Now if the original molecule type had had zero padding this 
method would have worked, but for datatypes with padding I don't see how 
to send an hindexed type of them and have another processor receive them 
given the way mpich is implemented with get_count.

Please reply in this newsgroup or by email as appropiate.
Thanks for any assistance,

Jonathan Stanton
Computer Science Department
Johns Hopkins University 
jonathan@cs.jhu.edu



