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 gatherv 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 while (MTestGetIntercomm(&comm, &leftGroup, 4)) {
31 if (comm == MPI_COMM_NULL)
33 MPI_Comm_rank(comm, &rank);
34 MPI_Comm_remote_size(comm, &rsize);
35 MPI_Comm_size(comm, &size);
37 /* To improve reporting of problems about operations, we
38 * change the error handler to errors return */
39 MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN);
41 for (count = 1; count < 65000; count = 2 * count) {
42 /* Get an intercommunicator */
43 recvcounts = (int *) malloc(rsize * sizeof(int));
44 recvdispls = (int *) malloc(rsize * sizeof(int));
45 /* This simple test duplicates the Gather test,
46 * using the same lengths for all messages */
47 for (i = 0; i < rsize; i++) {
48 recvcounts[i] = count;
49 recvdispls[i] = count * i;
52 buf = (int *) malloc(count * rsize * sizeof(int));
53 for (i = 0; i < count * rsize; i++)
56 err = MTest_Gatherv(NULL, 0, datatype,
57 buf, recvcounts, recvdispls, datatype,
58 (rank == 0) ? MPI_ROOT : MPI_PROC_NULL, comm);
63 /* Test that no other process in this group received the
66 for (i = 0; i < count; i++) {
73 /* Check for the correct data */
74 for (i = 0; i < count * rsize; i++) {
82 /* In the right group */
83 buf = (int *) malloc(count * sizeof(int));
84 for (i = 0; i < count; i++)
85 buf[i] = rank * count + i;
86 err = MTest_Gatherv(buf, count, datatype, NULL, 0, 0, datatype, 0, comm);