[MPICH] help self-defined datatype

Rob Ross rross at mcs.anl.gov
Wed Sep 28 10:06:23 CDT 2005


Hi,

At least one problem is that your displacements are wrong.  All 
displacements are relative to the pointer to the type, not the last 
displacement.  So you want:

>     #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), 2*sizeof(double), 3*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), 2*sizeof(double), 3*sizeof(double), 4*sizeof(double)};
>     #endif

That explains the "FIVE undefined" behavior, but not what you show for 
the defined case.

You should also check that sizeof(Grid) == MPI_Type_extent(GRID), just 
to make sure that the compiler isn't doing any weird padding or anything 
(very unlikely, but types built on structs are tricky).

Regards,

Rob
---
Rob Ross, Math and Comp. Science Division, Argonne National Laboratory




More information about the mpich-discuss mailing list