On Feb 16, 2006, at 6:43 AM, Márcia Marra wrote:
> I'm trying to send a collection of data, packed with the funcion
> MPI::PACK and have not had any luck getting it to work. When I execute
> the program, I receive the error "MPI_Pack_size: invalid datatype
> argument: Invalid argument (rank 0, MPI_COMM_WORLD)". I think that the
> problem is that I am not passing the datatype for the methods
> MPI::Pack_size() and MPI::Pack() but I don't know how to to this. The
> header of these methods are:
<snip>
> Here is the portion of the code that deals with the pack and unpack:
>
> int Classe1::sendPack() {
>
> int inteiro1, inteiro2, procs, i;
> int position = 0;
>
> char *message;
> int memberSize, maxSize;
>
> MPI::Datatype problemType;
>
> procs = MPI::COMM_WORLD.Get_size();
>
> memberSize = problemType.Pack_size(1, MPI::COMM_WORLD);
Unless you cut out the uninteresting bits of your code to make it
smaller, it looks like the problem is that you never initialize
problemType. You need to create the datatype first, then call member
functions on it. A trivial example would be:
int Classe1::sendPack() {
int inteiro1, inteiro2, procs, i;
int position = 0;
char *message;
int memberSize, maxSize;
MPI::Datatype problemType = MPI::INT.Dup();
procs = MPI::COMM_WORLD.Get_size();
memberSize = problemType.Pack_size(1, MPI::COMM_WORLD);
maxSize = memberSize;
....
Of course, you need to create the datatype appropriate for what you
are sending.
Brian
--
Brian Barrett
LAM/MPI developer and all around nice guy
Have a LAM/MPI day: http://www.lam-mpi.org/
|