1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
3 * (C) 2001 by Argonne National Laboratory.
4 * See COPYRIGHT in top-level directory.
11 int main( int argc, char *argv[] )
16 int buf[BUFSIZE], *bptr, bl, i, j, rank, size, errs=0;
19 MPI_Comm_rank( MPI_COMM_WORLD, &rank );
20 MPI_Comm_size( MPI_COMM_WORLD, &size );
21 MPI_Buffer_attach( buf, BUFSIZE );
23 for (j=0; j<10; j++) {
24 for (i=0; i<10; i++) {
25 a[i] = (rank + 10 * j) * size + i;
27 MPI_Ibsend( a, 10, MPI_INT, 0, 27+j, MPI_COMM_WORLD, &request );
28 MPI_Wait( &request, &status );
32 for (i=0; i<size; i++) {
33 for (j=0; j<10; j++) {
36 status.MPI_SOURCE = -20;
37 MPI_Recv( b, 10, MPI_INT, i, 27+j, MPI_COMM_WORLD, &status );
39 if (status.MPI_TAG != 27+j) {
41 printf( "Wrong tag = %d\n", status.MPI_TAG );
43 if (status.MPI_SOURCE != i) {
45 printf( "Wrong source = %d\n", status.MPI_SOURCE );
47 for (k=0; k<10; k++) {
48 if (b[k] != (i + 10 * j) * size + k) {
50 printf( "received b[%d] = %d from %d tag %d\n",
57 MPI_Buffer_detach( &bptr, &bl );
59 MTest_Finalize( errs );