[MPICH] help self-defined datatype

llwaeva at 21cn.com llwaeva at 21cn.com
Wed Sep 28 10:21:11 CDT 2005


on 2005-9-28 23:06:23, Rob Ross <rross at mcs.anl.gov> wrote:
> 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
Thanks all of you. The problem is solved now. 




More information about the mpich-discuss mailing list