2 * This file checks to see if the collective routine MPI_Allreduce uses
3 * MPI_Send or MPI_Isend to implement the operation. It should use either
4 * a PMPI routine or a non-MPI routine.
10 static int used_send = 0,
13 int main( int argc, char *argv[] )
17 int in_sends[3], out_sends[3];
19 MPI_Init( &argc, &argv );
21 MPI_Comm_rank( MPI_COMM_WORLD, &rank );
23 MPI_Allreduce( &in, &out, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD );
25 /* Now, see whether MPI routines were used */
26 in_sends[0] = used_send;
27 in_sends[1] = used_isend;
28 in_sends[2] = used_sendrecv;
29 MPI_Reduce( in_sends, out_sends, 3, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD );
32 if (in_sends[0] > 0) {
33 printf( " Allreduce used MPI_SEND (%d)\n", in_sends[0] );
36 if (in_sends[1] > 0) {
37 printf( " Allreduce used MPI_ISEND (%d)\n", in_sends[1] );
40 if (in_sends[2] > 0) {
41 printf( " Allreduce used MPI_SENDRECV (%d)\n", in_sends[2] );
45 printf( " No Errors\n" );
54 * Replacements for MPI_Send, Isend, and Sendrecv that detect their use
57 int MPI_Send( void *buf, int count, MPI_Datatype datatype, int dest,
58 int tag, MPI_Comm comm )
61 return PMPI_Send( buf, count, datatype, dest, tag, comm );
64 int MPI_Sendrecv( void *sendbuf, int sendcount, MPI_Datatype sendtype,
65 int dest, int sendtag,
66 void *recvbuf, int recvcount, MPI_Datatype recvtype,
67 int source, int recvtag, MPI_Comm comm, MPI_Status *status )
70 return PMPI_Sendrecv( sendbuf, sendcount, sendtype, dest, sendtag,
71 recvbuf, recvcount, recvtype, source, recvtag,
75 int MPI_Isend( void *buf, int count, MPI_Datatype datatype, int dest, int tag,
76 MPI_Comm comm, MPI_Request *request )
79 return PMPI_Isend( buf, count, datatype, dest, tag, comm, request );