|
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 |
|
|
Packit Service |
c5cf8c |
static char MTEST_Descrip[] = "";
|
|
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 rank, size, source, dest;
|
|
Packit Service |
c5cf8c |
int minsize = 2, count;
|
|
Packit Service |
c5cf8c |
MPI_Comm comm;
|
|
Packit Service |
c5cf8c |
MPI_Status status;
|
|
Packit Service |
c5cf8c |
MTestDatatype sendtype, recvtype;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MTest_Init(&argc, &argv);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* The following illustrates the use of the routines to
|
|
Packit Service |
c5cf8c |
* run through a selection of communicators and datatypes.
|
|
Packit Service |
c5cf8c |
* Use subsets of these for tests that do not involve combinations
|
|
Packit Service |
c5cf8c |
* of communicators, datatypes, and counts of datatypes */
|
|
Packit Service |
c5cf8c |
while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
|
|
Packit Service |
c5cf8c |
if (comm == MPI_COMM_NULL)
|
|
Packit Service |
c5cf8c |
continue;
|
|
Packit Service |
c5cf8c |
/* Determine the sender and receiver */
|
|
Packit Service |
c5cf8c |
MPI_Comm_rank(comm, &rank;;
|
|
Packit Service |
c5cf8c |
MPI_Comm_size(comm, &size);
|
|
Packit Service |
c5cf8c |
source = 0;
|
|
Packit Service |
c5cf8c |
dest = size - 1;
|
|
Packit Service |
c5cf8c |
|
|
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 |
|
|
Packit Service |
c5cf8c |
MTEST_DATATYPE_FOR_EACH_COUNT(count) {
|
|
Packit Service |
c5cf8c |
while (MTestGetDatatypes(&sendtype, &recvtype, count)) {
|
|
Packit Service |
c5cf8c |
if (rank == source) {
|
|
Packit Service |
c5cf8c |
sendtype.InitBuf(&sendtype);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
err = MPI_Send(sendtype.buf, sendtype.count, sendtype.datatype, dest, 0, comm);
|
|
Packit Service |
c5cf8c |
if (err) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
MTestPrintError(err);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MTestFreeDatatype(&sendtype);
|
|
Packit Service |
c5cf8c |
} else if (rank == dest) {
|
|
Packit Service |
c5cf8c |
recvtype.InitBuf(&recvtype);
|
|
Packit Service |
c5cf8c |
err = MPI_Recv(recvtype.buf, recvtype.count,
|
|
Packit Service |
c5cf8c |
recvtype.datatype, source, 0, comm, &status);
|
|
Packit Service |
c5cf8c |
if (err) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "Error with communicator %s and datatype %s\n",
|
|
Packit Service |
c5cf8c |
MTestGetIntracommName(), MTestGetDatatypeName(&recvtype));
|
|
Packit Service |
c5cf8c |
MTestPrintError(err);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
err = MTestCheckRecv(&status, &recvtype);
|
|
Packit Service |
c5cf8c |
if (err) {
|
|
Packit Service |
c5cf8c |
errs += errs;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MTestFreeDatatype(&recvtype);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
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 |
}
|