|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* (C) 2003 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
* See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
#include "mpi.h"
|
|
Packit Service |
c5cf8c |
#include <stdio.h>
|
|
Packit Service |
c5cf8c |
#include <stdlib.h>
|
|
Packit Service |
c5cf8c |
#include "mpitest.h"
|
|
Packit Service |
c5cf8c |
#include "mpicolltest.h"
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
static char MTEST_Descrip[] = "Simple intercomm gather test";
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int main(int argc, char *argv[])
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int errs = 0, err;
|
|
Packit Service |
c5cf8c |
int *buf = 0;
|
|
Packit Service |
c5cf8c |
int leftGroup, i, count, rank, rsize, size;
|
|
Packit Service |
c5cf8c |
MPI_Comm comm;
|
|
Packit Service |
c5cf8c |
MPI_Datatype datatype;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MTest_Init(&argc, &argv);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
datatype = MPI_INT;
|
|
Packit Service |
c5cf8c |
/* Get an intercommunicator */
|
|
Packit Service |
c5cf8c |
while (MTestGetIntercomm(&comm, &leftGroup, 4)) {
|
|
Packit Service |
c5cf8c |
if (comm == MPI_COMM_NULL)
|
|
Packit Service |
c5cf8c |
continue;
|
|
Packit Service |
c5cf8c |
MPI_Comm_rank(comm, &rank;;
|
|
Packit Service |
c5cf8c |
MPI_Comm_remote_size(comm, &rsize);
|
|
Packit Service |
c5cf8c |
MPI_Comm_size(comm, &size);
|
|
Packit Service |
c5cf8c |
/* To improve reporting of problems about operations, we
|
|
Packit Service |
c5cf8c |
* change the error handler to errors return */
|
|
Packit Service |
c5cf8c |
MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN);
|
|
Packit Service |
c5cf8c |
for (count = 1; count < 65000; count = 2 * count) {
|
|
Packit Service |
c5cf8c |
if (leftGroup) {
|
|
Packit Service |
c5cf8c |
buf = (int *) malloc(count * rsize * sizeof(int));
|
|
Packit Service |
c5cf8c |
for (i = 0; i < count * rsize; i++)
|
|
Packit Service |
c5cf8c |
buf[i] = -1;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
err = MTest_Gather(NULL, 0, datatype,
|
|
Packit Service |
c5cf8c |
buf, count, datatype,
|
|
Packit Service |
c5cf8c |
(rank == 0) ? MPI_ROOT : MPI_PROC_NULL, comm);
|
|
Packit Service |
c5cf8c |
if (err) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
MTestPrintError(err);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
/* Test that no other process in this group received the
|
|
Packit Service |
c5cf8c |
* broadcast */
|
|
Packit Service |
c5cf8c |
if (rank != 0) {
|
|
Packit Service |
c5cf8c |
for (i = 0; i < count; i++) {
|
|
Packit Service |
c5cf8c |
if (buf[i] != -1) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
/* Check for the correct data */
|
|
Packit Service |
c5cf8c |
for (i = 0; i < count * rsize; i++) {
|
|
Packit Service |
c5cf8c |
if (buf[i] != i) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
/* In the right group */
|
|
Packit Service |
c5cf8c |
buf = (int *) malloc(count * sizeof(int));
|
|
Packit Service |
c5cf8c |
for (i = 0; i < count; i++)
|
|
Packit Service |
c5cf8c |
buf[i] = rank * count + i;
|
|
Packit Service |
c5cf8c |
err = MTest_Gather(buf, count, datatype, NULL, 0, datatype, 0, comm);
|
|
Packit Service |
c5cf8c |
if (err) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
MTestPrintError(err);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
free(buf);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MTestFreeComm(&comm);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MTest_Finalize(errs);
|
|
Packit Service |
c5cf8c |
return MTestReturnValue(errs);
|
|
Packit Service |
c5cf8c |
}
|