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[] = "Accumulate/Replace 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 );
44 MPI_Type_extent( recvtype.datatype, &extent );
45 MPI_Win_create( recvtype.buf, recvtype.count * extent,
46 (int)extent, MPI_INFO_NULL, comm, &win );
47 MPI_Win_fence( 0, win );
49 sendtype.InitBuf( &sendtype );
51 /* To improve reporting of problems about operations, we
52 change the error handler to errors return */
53 MPI_Win_set_errhandler( win, MPI_ERRORS_RETURN );
55 /* MPI_REPLACE on accumulate is almost the same
56 as MPI_Put; the only difference is in the
57 handling of overlapping accumulate operations,
58 which are not tested here */
59 err = MPI_Accumulate( sendtype.buf, sendtype.count,
60 sendtype.datatype, dest, 0,
61 recvtype.count, recvtype.datatype,
66 printf( "Accumulate types: send %s, recv %s\n",
67 MTestGetDatatypeName( &sendtype ),
68 MTestGetDatatypeName( &recvtype ) );
69 MTestPrintError( err );
72 err = MPI_Win_fence( 0, win );
76 MTestPrintError( err );
80 else if (rank == dest) {
81 MPI_Win_fence( 0, win );
82 /* This should have the same effect, in terms of
83 transfering data, as a send/recv pair */
84 err = MTestCheckRecv( 0, &recvtype );
90 MPI_Win_fence( 0, win );
93 MTestFreeDatatype( &sendtype );
94 MTestFreeDatatype( &recvtype );
100 MTest_Finalize( errs );