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, color, errs=0;
19 MPI_Comm_rank( MPI_COMM_WORLD, &rank );
21 MPI_Comm_split( MPI_COMM_WORLD, color, rank, &scomm );
22 MPI_Intercomm_create( scomm, 0, MPI_COMM_WORLD, 1-color, 52, &comm);
23 MPI_Comm_rank( comm, &rank );
24 MPI_Comm_remote_size( comm, &size );
25 MPI_Buffer_attach( buf, BUFSIZE );
27 for (j=0; j<10; j++) {
28 for (i=0; i<10; i++) {
29 a[i] = (rank + 10 * j) * size + i;
31 MPI_Bsend( a, 10, MPI_INT, 0, 27+j, comm );
35 for (i=0; i<size; i++) {
36 for (j=0; j<10; j++) {
39 status.MPI_SOURCE = -20;
40 MPI_Recv( b, 10, MPI_INT, i, 27+j, comm, &status );
42 if (status.MPI_TAG != 27+j) {
44 printf( "Wrong tag = %d\n", status.MPI_TAG );
46 if (status.MPI_SOURCE != i) {
48 printf( "Wrong source = %d\n", status.MPI_SOURCE );
50 for (k=0; k<10; k++) {
51 if (b[k] != (i + 10 * j) * size + k) {
53 printf( "received b[%d] = %d from %d tag %d\n",
60 MPI_Buffer_detach( &bptr, &bl );
62 MPI_Comm_free(&scomm);
65 MTest_Finalize( errs );