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 Post/Start/Complete/Wait";
15 int main( int argc, char *argv[] )
18 int rank, size, source, dest;
19 int minsize = 2, count;
23 MPI_Group wingroup, neighbors;
24 MTestDatatype sendtype, recvtype;
26 MTest_Init( &argc, &argv );
28 /* The following illustrates the use of the routines to
29 run through a selection of communicators and datatypes.
30 Use subsets of these for tests that do not involve combinations
31 of communicators, datatypes, and counts of datatypes */
32 while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
33 if (comm == MPI_COMM_NULL) continue;
34 /* Determine the sender and receiver */
35 MPI_Comm_rank( comm, &rank );
36 MPI_Comm_size( comm, &size );
40 for (count = 1; count < 65000; count = count * 2) {
41 while (MTestGetDatatypes( &sendtype, &recvtype, count )) {
42 /* Make sure that everyone has a recv buffer */
43 recvtype.InitBuf( &recvtype );
45 MPI_Type_extent( recvtype.datatype, &extent );
46 MPI_Win_create( recvtype.buf, recvtype.count * extent,
47 (int)extent, MPI_INFO_NULL, comm, &win );
48 MPI_Win_get_group( win, &wingroup );
50 /* To improve reporting of problems about operations, we
51 change the error handler to errors return */
52 MPI_Win_set_errhandler( win, MPI_ERRORS_RETURN );
53 sendtype.InitBuf( &sendtype );
55 /* Neighbor is dest only */
56 MPI_Group_incl( wingroup, 1, &dest, &neighbors );
57 err = MPI_Win_start( neighbors, 0, win );
61 MTestPrintError( err );
64 MPI_Group_free( &neighbors );
65 err = MPI_Put( sendtype.buf, sendtype.count,
66 sendtype.datatype, dest, 0,
67 recvtype.count, recvtype.datatype, win );
70 MTestPrintError( err );
72 err = MPI_Win_complete( win );
76 MTestPrintError( err );
80 else if (rank == dest) {
81 MPI_Group_incl( wingroup, 1, &source, &neighbors );
82 MPI_Win_post( neighbors, 0, win );
83 MPI_Group_free( &neighbors );
85 /* This should have the same effect, in terms of
86 transfering data, as a send/recv pair */
87 err = MTestCheckRecv( 0, &recvtype );
93 /* Nothing; the other processes need not call any
98 MTestFreeDatatype( &sendtype );
99 MTestFreeDatatype( &recvtype );
100 MPI_Group_free( &wingroup );
103 MTestFreeComm( &comm );
106 MTest_Finalize( errs );