[MPICH] help self-defined datatype

James S Perrin james.s.perrin at manchester.ac.uk
Wed Sep 28 09:53:39 CDT 2005


llwaeva at 21cn.com wrote:


>     #ifndef FIVE
>       int S=4;
>       MPI_Datatype type[4] = { MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE};
>       int blocklen[4] = { 1, 1, 1, 1 };
>       MPI_Aint disp[4] = { 0, sizeof(double), sizeof(double), sizeof(double)};
>     #else
>       int S=5;
>       MPI_Datatype type[5] = { MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE};
>       int blocklen[5] = { 1, 1, 1, 1, 1 };
>       MPI_Aint disp[5] = { 0, sizeof(double), sizeof(double), sizeof(double), sizeof(double)};
>     #endif

Surely the displacements should be:

MPI_Aint disp[5] = { 0, sizeof(double), 2*sizeof(double), 3*sizeof(double), etc.

as they are from the start of the structure.

In general it is better to use the MPI_Address() routine to create the disp 
values and then substruct disp[0] from each before setting that to zero.

Regards
James
-- 
-----------------------------------------------------------------------------
James S. Perrin,                   | email: james.perrin at manchester.ac.uk
Manchester Visualization Centre,   | www.sve.man.ac.uk/General/Staff/perrin
Kilburn Building, The University,  | tel: +44 161 275 6945
Manchester, England. M13 9PL.      | fax: +44 161 275 6800/6040
-----------------------------------------------------------------------------
"The test of intellect is the refusal to belabour the obvious" -Alfred Bester
-----------------------------------------------------------------------------




More information about the mpich-discuss mailing list