1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
3 * (C) 2014 by Argonne National Laboratory.
4 * See COPYRIGHT in top-level directory.
12 /* Inspired by the Intel MPI_Type_hvector_blklen test.
13 Added to include a test of a dataloop optimization that failed.
15 int main( int argc, char *argv[] )
17 MPI_Datatype ot, ot2, newtype;
18 int position, psize, insize, outsize;
19 signed char *inbuf=0, *outbuf=0, *pbuf=0, *p;
22 int veccount=16, stride=16;
24 MTest_Init( &argc, &argv );
26 * Create a type with some padding
28 MPI_Type_contiguous( 59, MPI_CHAR, &ot );
29 MPI_Type_create_resized( ot, 0, 64, &ot2 );
31 Use a vector type with a block size equal to the stride - thus
32 tiling the target memory with copies of old type. This is not
33 a contiguous copy since oldtype has a gap at the end.
35 MPI_Type_hvector( veccount, stride, stride*64, ot2, &newtype );
36 MPI_Type_commit( &newtype );
38 insize = veccount * stride * 64;
40 inbuf = (char *)malloc( insize );
41 outbuf = (char *)malloc( outsize );
42 for (i=0; i<outsize; i++) {
47 MPI_Pack_size( 1, newtype, MPI_COMM_WORLD, &psize );
48 pbuf = (char *)malloc( psize );
51 MPI_Pack( inbuf, 1, newtype, pbuf, psize, &position, MPI_COMM_WORLD );
54 MPI_Unpack( pbuf, psize, &position, outbuf, 1, newtype, MPI_COMM_WORLD );
57 /* Check the output */
59 for (i=0; i<veccount; i++) {
60 for (j=0; j<stride; j++) {
61 for (k=0; k<59; k++) {
64 fprintf( stderr, "[%d,%d,%d]expected %d but saw %d\n",
65 i, j, k, (k%64), *p );
69 for (k=59; k<64; k++) {
72 fprintf( stderr, "[%d,%d,%d]expected -1 but saw %d\n",
85 MPI_Type_free( &ot2 );
86 MPI_Type_free( &newtype );
87 MTest_Finalize( errs );