1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
4 * (C) 2003 by Argonne National Laboratory.
5 * See COPYRIGHT in top-level directory.
13 static char MTEST_Descrip[] = "Test of type resized with non-zero LB";
16 int main( int argc, char *argv[] )
19 int rank, size, source, dest;
26 MTest_Init( &argc, &argv );
28 comm = MPI_COMM_WORLD;
30 /* Determine the sender and receiver */
31 MPI_Comm_rank( comm, &rank );
32 MPI_Comm_size( comm, &size );
36 /* Create an type that is "* INT * "
37 that is, there is a int-sized pad at the beginning of the type,
38 and the extent is still 3 ints. Note, however, that the INT
39 is still at displacement 0, so the effective pattern i*/
40 MPI_Type_create_resized( MPI_INT, -(int)sizeof(int), 3 * sizeof(int), &newtype );
41 MPI_Type_commit( &newtype );
42 for (count = 1; count < 65000; count = count * 2) {
43 buf = (int *)malloc( count * 3 * sizeof(int) );
48 for (i=0; i<3*count; i++) buf[i] = -1;
50 for (i=0; i<count; i++) buf[3*i] = i;
51 MPI_Send( buf, count, newtype, dest, 0, comm );
52 MPI_Send( buf, count, newtype, dest, 1, comm );
54 else if (rank == dest) {
55 MPI_Recv( buf, count, MPI_INT, source, 0, comm, &status );
56 for (i=0; i<count; i++) {
60 printf( "buf[%d] = %d\n", i, buf[i] );
64 for (i=0; i<count*3; i++) buf[i] = -1;
65 MPI_Recv( buf, count, newtype, source, 1, comm, &status );
66 for (i=0; i<count; i++) {
70 printf( "buf[3*%d] = %d\n", i, buf[i] );
76 MPI_Type_free( &newtype );
78 MTest_Finalize( errs );