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[] = "Put 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 )) {
43 "Putting count = %d of sendtype %s receive type %s\n",
44 count, MTestGetDatatypeName( &sendtype ),
45 MTestGetDatatypeName( &recvtype ) );
47 /* Make sure that everyone has a recv buffer */
48 recvtype.InitBuf( &recvtype );
50 MPI_Type_extent( recvtype.datatype, &extent );
51 MPI_Win_create( recvtype.buf, recvtype.count * extent,
52 extent, MPI_INFO_NULL, comm, &win );
53 MPI_Win_fence( 0, win );
55 /* To improve reporting of problems about operations, we
56 change the error handler to errors return */
57 MPI_Win_set_errhandler( win, MPI_ERRORS_RETURN );
59 sendtype.InitBuf( &sendtype );
61 err = MPI_Put( sendtype.buf, sendtype.count,
62 sendtype.datatype, dest, 0,
63 recvtype.count, recvtype.datatype, win );
67 MTestPrintError( err );
70 err = MPI_Win_fence( 0, win );
74 MTestPrintError( err );
78 else if (rank == dest) {
79 MPI_Win_fence( 0, win );
80 /* This should have the same effect, in terms of
81 transfering data, as a send/recv pair */
82 err = MTestCheckRecv( 0, &recvtype );
85 printf( "Data in target buffer did not match for destination datatype %s (put with source datatype %s)\n",
86 MTestGetDatatypeName( &recvtype ),
87 MTestGetDatatypeName( &sendtype ) );
88 /* Redo the test, with the errors printed */
89 recvtype.printErrors = 1;
90 (void)MTestCheckRecv( 0, &recvtype );
96 MPI_Win_fence( 0, win );
99 MTestFreeDatatype( &sendtype );
100 MTestFreeDatatype( &recvtype );
103 MTestFreeComm(&comm);
106 MTest_Finalize( errs );