|
Packit |
0848f5 |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit |
0848f5 |
/*
|
|
Packit |
0848f5 |
*
|
|
Packit |
0848f5 |
* (C) 2003 by Argonne National Laboratory.
|
|
Packit |
0848f5 |
* See COPYRIGHT in top-level directory.
|
|
Packit |
0848f5 |
*/
|
|
Packit |
0848f5 |
#include "mpi.h"
|
|
Packit |
0848f5 |
#include <stdio.h>
|
|
Packit |
0848f5 |
#include <string.h>
|
|
Packit |
0848f5 |
#include "mpitest.h"
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/* These counts allow reasonable sizes for the large tests */
|
|
Packit |
0848f5 |
#define LARGE_CNT_CONTIG 550000000
|
|
Packit |
0848f5 |
#define LARGE_CNT_NONCONTIG 150000000
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/*
|
|
Packit |
0848f5 |
static char MTEST_Descrip[] = "Put with Fence";
|
|
Packit |
0848f5 |
*/
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
static inline int test(MPI_Comm comm, int rank, int source, int dest,
|
|
Packit |
0848f5 |
MTestDatatype * sendtype, MTestDatatype * recvtype)
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
int errs = 0, err;
|
|
Packit |
0848f5 |
MPI_Aint extent, lb;
|
|
Packit |
0848f5 |
MPI_Win win;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MTestPrintfMsg(1,
|
|
Packit |
0848f5 |
"Putting count = %ld of sendtype %s - count = %ld receive type %s\n",
|
|
Packit |
0848f5 |
sendtype->count, MTestGetDatatypeName(sendtype), recvtype->count,
|
|
Packit |
0848f5 |
MTestGetDatatypeName(recvtype));
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/* Make sure that everyone has a recv buffer */
|
|
Packit |
0848f5 |
recvtype->InitBuf(recvtype);
|
|
Packit |
0848f5 |
MPI_Type_extent(recvtype->datatype, &extent);
|
|
Packit |
0848f5 |
MPI_Type_lb(recvtype->datatype, &lb);
|
|
Packit |
0848f5 |
MPI_Win_create(recvtype->buf, recvtype->count * extent + lb, extent, MPI_INFO_NULL, comm, &win);
|
|
Packit |
0848f5 |
MPI_Win_fence(0, win);
|
|
Packit |
0848f5 |
if (rank == source) {
|
|
Packit |
0848f5 |
/* To improve reporting of problems about operations, we
|
|
Packit |
0848f5 |
* change the error handler to errors return */
|
|
Packit |
0848f5 |
MPI_Win_set_errhandler(win, MPI_ERRORS_RETURN);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
sendtype->InitBuf(sendtype);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
err = MPI_Put(sendtype->buf, sendtype->count,
|
|
Packit |
0848f5 |
sendtype->datatype, dest, 0, recvtype->count, recvtype->datatype, win);
|
|
Packit |
0848f5 |
if (err) {
|
|
Packit |
0848f5 |
errs++;
|
|
Packit |
0848f5 |
if (errs < 10) {
|
|
Packit |
0848f5 |
MTestPrintError(err);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
err = MPI_Win_fence(0, win);
|
|
Packit |
0848f5 |
if (err) {
|
|
Packit |
0848f5 |
errs++;
|
|
Packit |
0848f5 |
if (errs < 10) {
|
|
Packit |
0848f5 |
MTestPrintError(err);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
else if (rank == dest) {
|
|
Packit |
0848f5 |
MPI_Win_fence(0, win);
|
|
Packit |
0848f5 |
/* This should have the same effect, in terms of
|
|
Packit |
0848f5 |
* transfering data, as a send/recv pair */
|
|
Packit |
0848f5 |
err = MTestCheckRecv(0, recvtype);
|
|
Packit |
0848f5 |
if (err) {
|
|
Packit |
0848f5 |
if (errs < 10) {
|
|
Packit |
0848f5 |
printf
|
|
Packit |
0848f5 |
("Data in target buffer did not match for destination datatype %s (put with source datatype %s)\n",
|
|
Packit |
0848f5 |
MTestGetDatatypeName(recvtype), MTestGetDatatypeName(sendtype));
|
|
Packit |
0848f5 |
/* Redo the test, with the errors printed */
|
|
Packit |
0848f5 |
recvtype->printErrors = 1;
|
|
Packit |
0848f5 |
(void) MTestCheckRecv(0, recvtype);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
errs += err;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
else {
|
|
Packit |
0848f5 |
MPI_Win_fence(0, win);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
MPI_Win_free(&win);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
return errs;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
int main(int argc, char *argv[])
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
int errs = 0;
|
|
Packit |
0848f5 |
int rank, size, source, dest;
|
|
Packit |
0848f5 |
int minsize = 2, count;
|
|
Packit |
0848f5 |
MPI_Comm comm;
|
|
Packit |
0848f5 |
MTestDatatype sendtype, recvtype;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MTest_Init(&argc, &argv);
|
|
Packit |
0848f5 |
/* The following illustrates the use of the routines to
|
|
Packit |
0848f5 |
* run through a selection of communicators and datatypes.
|
|
Packit |
0848f5 |
* Use subsets of these for tests that do not involve combinations
|
|
Packit |
0848f5 |
* of communicators, datatypes, and counts of datatypes */
|
|
Packit |
0848f5 |
while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
|
|
Packit |
0848f5 |
if (comm == MPI_COMM_NULL)
|
|
Packit |
0848f5 |
continue;
|
|
Packit |
0848f5 |
/* Determine the sender and receiver */
|
|
Packit |
0848f5 |
MPI_Comm_rank(comm, &rank;;
|
|
Packit |
0848f5 |
MPI_Comm_size(comm, &size);
|
|
Packit |
0848f5 |
source = 0;
|
|
Packit |
0848f5 |
dest = size - 1;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MTEST_DATATYPE_FOR_EACH_COUNT(count) {
|
|
Packit |
0848f5 |
while (MTestGetDatatypes(&sendtype, &recvtype, count)) {
|
|
Packit |
0848f5 |
errs += test(comm, rank, source, dest, &sendtype, &recvtype);
|
|
Packit |
0848f5 |
MTestFreeDatatype(&sendtype);
|
|
Packit |
0848f5 |
MTestFreeDatatype(&recvtype);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
MTestFreeComm(&comm);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/* Part #2: simple large size test - contiguous and noncontiguous */
|
|
Packit |
0848f5 |
if (sizeof(void *) > 4) { /* Only if > 32-bit architecture */
|
|
Packit |
0848f5 |
MPI_Comm_rank(MPI_COMM_WORLD, &rank;;
|
|
Packit |
0848f5 |
MPI_Comm_size(MPI_COMM_WORLD, &size);
|
|
Packit |
0848f5 |
source = 0;
|
|
Packit |
0848f5 |
dest = size - 1;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MTestGetDatatypes(&sendtype, &recvtype, LARGE_CNT_CONTIG);
|
|
Packit |
0848f5 |
errs += test(MPI_COMM_WORLD, rank, source, dest, &sendtype, &recvtype);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
do {
|
|
Packit |
0848f5 |
MTestFreeDatatype(&sendtype);
|
|
Packit |
0848f5 |
MTestFreeDatatype(&recvtype);
|
|
Packit |
0848f5 |
MTestGetDatatypes(&sendtype, &recvtype, LARGE_CNT_NONCONTIG);
|
|
Packit |
0848f5 |
} while (strstr(MTestGetDatatypeName(&sendtype), "vector") == NULL);
|
|
Packit |
0848f5 |
errs += test(MPI_COMM_WORLD, rank, source, dest, &sendtype, &recvtype);
|
|
Packit |
0848f5 |
MTestFreeDatatype(&sendtype);
|
|
Packit |
0848f5 |
MTestFreeDatatype(&recvtype);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MTest_Finalize(errs);
|
|
Packit |
0848f5 |
MPI_Finalize();
|
|
Packit |
0848f5 |
return 0;
|
|
Packit |
0848f5 |
}
|