1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
3 * Changes to the original code
4 * (C) 2001 by Argonne National Laboratory.
5 * See COPYRIGHT in top-level directory.
10 From: hook@nas.nasa.gov (Edward C. Hook)
20 #define EXIT_SUCCESS 0
21 #define EXIT_FAILURE 1
24 int main( int argc, char *argv[] )
33 MTest_Init(&argc,&argv);
34 MPI_Comm_rank(MPI_COMM_WORLD,&rank);
35 MPI_Comm_size(MPI_COMM_WORLD,&size);
37 for ( i=1 ; i < argc ; ++i ) {
38 if ( argv[i][0] != '-' )
42 chunk = atoi(argv[++i]);
45 fprintf(stderr,"Unrecognized argument %s\n",
47 MPI_Abort(MPI_COMM_WORLD,EXIT_FAILURE);
52 sb = (int *)malloc(size*chunk*sizeof(int));
54 perror( "can't allocate send buffer" );
55 MPI_Abort(MPI_COMM_WORLD,EXIT_FAILURE);
58 rb = (int *)malloc(size*chunk*sizeof(int));
60 perror( "can't allocate recv buffer");
62 MPI_Abort(MPI_COMM_WORLD,EXIT_FAILURE);
65 for ( i=0 ; i < size*chunk ; ++i ) {
70 /* fputs("Before MPI_Alltoall\n",stdout); */
72 /* This should really send MPI_CHAR, but since sb and rb were allocated
73 as chunk*size*sizeof(int), the buffers are large enough */
74 status = MPI_Alltoall(sb,chunk,MPI_INT,rb,chunk,MPI_INT,
77 /* fputs("Before MPI_Allreduce\n",stdout); */
79 MTest_Finalize( status );
86 return MTestReturnValue( status );