1 /*
2 * Copyright (C) by Argonne National Laboratory
3 * See COPYRIGHT in top-level directory
4 */
5
6 #include <stdio.h>
7 #include "mpi.h"
8 #include "mpitest.h"
9
10 /*
11 * This program checks that MPI_Iprobe and MPI_Probe correctly handle
12 * a source of MPI_PROC_NULL
13 */
14
main(int argc,char ** argv)15 int main(int argc, char **argv)
16 {
17 int flag;
18 int errs = 0;
19 MPI_Status status;
20
21 MTest_Init(&argc, &argv);
22
23 MPI_Iprobe(MPI_PROC_NULL, 10, MPI_COMM_WORLD, &flag, &status);
24 if (!flag) {
25 errs++;
26 printf("Iprobe of source=MPI_PROC_NULL returned flag=false\n");
27 } else {
28 if (status.MPI_SOURCE != MPI_PROC_NULL) {
29 printf("Status.MPI_SOURCE was %d, should be MPI_PROC_NULL\n", status.MPI_SOURCE);
30 errs++;
31 }
32 if (status.MPI_TAG != MPI_ANY_TAG) {
33 printf("Status.MPI_TAG was %d, should be MPI_ANY_TAGL\n", status.MPI_TAG);
34 errs++;
35 }
36 }
37 /* If Iprobe failed, probe is likely to as well. Avoid a possible hang
38 * by testing Probe only if Iprobe test passed */
39 if (errs == 0) {
40 MPI_Probe(MPI_PROC_NULL, 10, MPI_COMM_WORLD, &status);
41 if (status.MPI_SOURCE != MPI_PROC_NULL) {
42 printf("Status.MPI_SOURCE was %d, should be MPI_PROC_NULL\n", status.MPI_SOURCE);
43 errs++;
44 }
45 if (status.MPI_TAG != MPI_ANY_TAG) {
46 printf("Status.MPI_TAG was %d, should be MPI_ANY_TAGL\n", status.MPI_TAG);
47 errs++;
48 }
49 }
50
51 MTest_Finalize(errs);
52 return MTestReturnValue(errs);
53 }
54