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 int main(int argc, char *argv[])
29 MTest_Init(&argc, &argv);
30 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
31 MPI_Comm_size(MPI_COMM_WORLD, &size);
33 for (i = 1; i < argc; ++i) {
34 if (argv[i][0] != '-')
38 chunk = atoi(argv[++i]);
41 fprintf(stderr, "Unrecognized argument %s\n", argv[i]);
42 MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
46 sb = (int *) malloc(size * chunk * sizeof(int));
48 perror("can't allocate send buffer");
49 MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
51 rb = (int *) malloc(size * chunk * sizeof(int));
53 perror("can't allocate recv buffer");
55 MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
57 for (i = 0; i < size * chunk; ++i) {
62 /* fputs("Before MPI_Alltoall\n",stdout); */
64 /* This should really send MPI_CHAR, but since sb and rb were allocated
65 * as chunk*size*sizeof(int), the buffers are large enough */
66 status = MPI_Alltoall(sb, chunk, MPI_INT, rb, chunk, MPI_INT, MPI_COMM_WORLD);
68 /* fputs("Before MPI_Allreduce\n",stdout); */
70 MTest_Finalize(status);
77 return MTestReturnValue(status);