2 * Program to test that datatypes that are freed with MPI_TYPE_FREE
3 * are not actually deleted until communication that they are a part of
16 /* Prototypes for picky compilers */
17 void Generate_Data ( int *, int );
19 void Generate_Data(buffer, buff_size)
25 for (i = 0; i < buff_size; i++)
29 int main( int argc, char **argv)
31 int rank; /* My Rank (0 or 1) */
32 int tag, count, i, errcnt = 0;
38 MPI_Init(&argc, &argv);
39 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
43 for (i = 0; i < 100; i++)
45 MPI_Type_vector( 10, 1, 10, MPI_DOUBLE, &rowtype );
46 MPI_Type_commit( &rowtype );
48 MPI_Irecv(data, count, rowtype, dest, tag, MPI_COMM_WORLD,
50 MPI_Type_free( &rowtype );
51 MPI_Recv( (void *)0, 0, MPI_INT, dest, tag+1,
52 MPI_COMM_WORLD, &status );
53 MPI_Wait( &handle, &status );
54 /* Check for correct data */
55 for (i = 0; i < 10; i++) if (data[i*10] != i*10) {
58 "[%d](rcv row-row) %d'th element = %f, should be %f\n",
59 rank, i, data[i*10], 10.0*i );
62 } else if (rank == dest) {
63 MPI_Send( (void *)0, 0, MPI_INT, src, tag+1, MPI_COMM_WORLD );
64 /* By using an Ssend first, we make sure that the Irecv doesn't
65 match until after the type has been freed */
66 MPI_Isend( data, count, rowtype, src, tag, MPI_COMM_WORLD,
68 MPI_Type_free( &rowtype );
69 MPI_Wait( &handle, &status );
73 MPI_Allreduce( &i, &errcnt, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD );
75 printf( "Found %d errors in the run\n", errcnt );