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 scatterv test";
17 int main(int argc, char *argv[])
23 int leftGroup, i, count, rank, rsize, size;
25 MPI_Datatype datatype;
27 MTest_Init(&argc, &argv);
30 /* Get an intercommunicator */
31 while (MTestGetIntercomm(&comm, &leftGroup, 4)) {
32 if (comm == MPI_COMM_NULL)
34 MPI_Comm_remote_size(comm, &rsize);
35 MPI_Comm_rank(comm, &rank);
36 MPI_Comm_size(comm, &size);
38 /* To improve reporting of problems about operations, we
39 * change the error handler to errors return */
40 MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN);
42 for (count = 1; count < 65000; count = 2 * count) {
44 sendcounts = (int *) malloc(rsize * sizeof(int));
45 senddispls = (int *) malloc(rsize * sizeof(int));
46 for (i = 0; i < rsize; i++) {
47 sendcounts[i] = count;
48 senddispls[i] = count * i;
51 buf = (int *) malloc(count * rsize * sizeof(int));
53 for (i = 0; i < count * rsize; i++)
57 for (i = 0; i < count * rsize; i++)
60 err = MTest_Scatterv(buf, sendcounts, senddispls, datatype,
62 (rank == 0) ? MPI_ROOT : MPI_PROC_NULL, comm);
67 /* Test that no other process in this group received the
70 for (i = 0; i < count * rsize; i++) {
73 fprintf(stderr, "Received data on root group!\n");
81 buf = (int *) malloc(count * sizeof(int));
82 /* In the right group */
83 for (i = 0; i < count; i++)
85 err = MTest_Scatterv(NULL, 0, 0, datatype, buf, count, datatype, 0, comm);
90 /* Check that we have received the correct data */
91 for (i = 0; i < count; i++) {
92 if (buf[i] != i + rank * count) {
94 fprintf(stderr, "buf[%d] = %d on %d\n", i, buf[i], rank);
103 MTestFreeComm(&comm);
106 MTest_Finalize(errs);