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.
12 static char MTEST_Descrip[] = "Get with Fence";
15 int main( int argc, char *argv[] )
18 int rank, size, source, dest;
19 int minsize = 2, count;
23 MTestDatatype sendtype, recvtype;
25 MTest_Init( &argc, &argv );
27 /* The following illustrates the use of the routines to
28 run through a selection of communicators and datatypes.
29 Use subsets of these for tests that do not involve combinations
30 of communicators, datatypes, and counts of datatypes */
31 while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
32 if (comm == MPI_COMM_NULL) continue;
33 /* Determine the sender and receiver */
34 MPI_Comm_rank( comm, &rank );
35 MPI_Comm_size( comm, &size );
39 for (count = 1; count < 65000; count = count * 2) {
40 while (MTestGetDatatypes( &sendtype, &recvtype, count )) {
41 /* Make sure that everyone has a recv buffer */
42 recvtype.InitBuf( &recvtype );
43 sendtype.InitBuf( &sendtype );
44 /* By default, print information about errors */
45 recvtype.printErrors = 1;
46 sendtype.printErrors = 1;
48 MPI_Type_extent( sendtype.datatype, &extent );
49 MPI_Win_create( sendtype.buf, sendtype.count * extent,
50 (int)extent, MPI_INFO_NULL, comm, &win );
51 MPI_Win_fence( 0, win );
53 /* The source does not need to do anything besides the
55 MPI_Win_fence( 0, win );
57 else if (rank == dest) {
58 /* To improve reporting of problems about operations, we
59 change the error handler to errors return */
60 MPI_Win_set_errhandler( win, MPI_ERRORS_RETURN );
62 /* This should have the same effect, in terms of
63 transfering data, as a send/recv pair */
64 err = MPI_Get( recvtype.buf, recvtype.count,
65 recvtype.datatype, source, 0,
66 sendtype.count, sendtype.datatype, win );
70 MTestPrintError( err );
73 err = MPI_Win_fence( 0, win );
77 MTestPrintError( err );
80 err = MTestCheckRecv( 0, &recvtype );
86 MPI_Win_fence( 0, win );
89 MTestFreeDatatype( &recvtype );
90 MTestFreeDatatype( &sendtype );
96 MTest_Finalize( errs );