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.
11 /* Test bsend with a buffer with arbitrary alignment */
12 #define BUFSIZE 2000*4
13 int main( int argc, char *argv[] )
18 char buf[BUFSIZE+8], *bptr;
19 int bl, i, j, rank, size;
23 MPI_Comm_rank( MPI_COMM_WORLD, &rank );
24 MPI_Comm_size( MPI_COMM_WORLD, &size );
25 for (align = 0; align < 7; align++) {
26 MPI_Buffer_attach( buf+align, BUFSIZE);
28 for (j=0; j<10; j++) {
29 for (i=0; i<10; i++) {
30 a[i] = (rank + 10 * j) * size + i;
32 MPI_Bsend( a, 10, MPI_INT, 0, 27+j, MPI_COMM_WORLD );
36 for (i=0; i<size; i++) {
37 for (j=0; j<10; j++) {
40 status.MPI_SOURCE = -20;
41 MPI_Recv( b, 10, MPI_INT, i, 27+j, MPI_COMM_WORLD, &status );
43 if (status.MPI_TAG != 27+j) {
45 printf( "Wrong tag = %d\n", status.MPI_TAG );
47 if (status.MPI_SOURCE != i) {
49 printf( "Wrong source = %d\n", status.MPI_SOURCE );
51 for (k=0; k<10; k++) {
52 if (b[k] != (i + 10 * j) * size + k) {
54 printf( "(Align=%d) received b[%d] = %d (expected %d) from %d tag %d\n",
55 align, k, b[k], (i+10*j), i, 27+j );
61 MPI_Buffer_detach( &bptr, &bl );
62 if (bptr != buf+align) {
64 printf( "Did not recieve the same buffer on detach that was provided on init (%p vs %p)\n", bptr, buf );
68 MTest_Finalize( errs );