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 #include "mpicolltest.h"
14 static char MTEST_Descrip[] = "Simple intercomm alltoall test";
17 int main(int argc, char *argv[])
20 int *sendbuf = 0, *recvbuf = 0;
21 int leftGroup, i, j, idx, count, rrank, rsize;
23 MPI_Datatype datatype;
25 MTest_Init(&argc, &argv);
28 while (MTestGetIntercomm(&comm, &leftGroup, 4)) {
29 if (comm == MPI_COMM_NULL)
31 for (count = 1; count < 66000; count = 2 * count) {
32 /* Get an intercommunicator */
33 MPI_Comm_remote_size(comm, &rsize);
34 MPI_Comm_rank(comm, &rrank);
35 sendbuf = (int *) malloc(rsize * count * sizeof(int));
36 recvbuf = (int *) malloc(rsize * count * sizeof(int));
37 for (i = 0; i < rsize * count; i++)
41 for (j = 0; j < rsize; j++) {
42 for (i = 0; i < count; i++) {
43 sendbuf[idx++] = i + rrank;
46 err = MTest_Alltoall(sendbuf, count, datatype, NULL, 0, datatype, comm);
55 MPI_Comm_rank(comm, &rank);
56 MPI_Comm_size(comm, &size);
58 /* In the right group */
59 err = MTest_Alltoall(NULL, 0, datatype, recvbuf, count, datatype, comm);
64 /* Check that we have received the correct data */
66 for (j = 0; j < rsize; j++) {
67 for (i = 0; i < count; i++) {
68 if (recvbuf[idx++] != i + j) {
71 fprintf(stderr, "buf[%d] = %d on %d\n", i, recvbuf[i], rank);