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 scatter test";
17 int main(int argc, char *argv[])
21 int leftGroup, i, count, rank, size, rsize;
23 MPI_Datatype datatype;
25 MTest_Init(&argc, &argv);
28 /* Get an intercommunicator */
29 while (MTestGetIntercomm(&comm, &leftGroup, 4)) {
30 if (comm == MPI_COMM_NULL)
32 MPI_Comm_remote_size(comm, &rsize);
33 MPI_Comm_rank(comm, &rank);
34 MPI_Comm_size(comm, &size);
36 /* To improve reporting of problems about operations, we
37 * change the error handler to errors return */
38 MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN);
40 for (count = 1; count < 65000; count = 2 * count) {
43 buf = (int *) malloc(count * rsize * sizeof(int));
45 for (i = 0; i < count * rsize; i++)
49 for (i = 0; i < count * rsize; i++)
52 err = MTest_Scatter(buf, count, datatype,
54 (rank == 0) ? MPI_ROOT : MPI_PROC_NULL, comm);
59 /* Test that no other process in this group received the
62 for (i = 0; i < count * rsize; i++) {
65 fprintf(stderr, "Received data on root group!\n");
73 buf = (int *) malloc(count * sizeof(int));
74 /* In the right group */
75 for (i = 0; i < count; i++)
77 err = MTest_Scatter(NULL, 0, datatype, buf, count, datatype, 0, comm);
82 /* Check that we have received the correct data */
83 for (i = 0; i < count; i++) {
84 if (buf[i] != i + rank * count) {
86 fprintf(stderr, "buf[%d] = %d on %d\n", i, buf[i], rank);