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
main(int argc,char ** argv)10 int main(int argc, char **argv)
11 {
12 int errs = 0;
13 void *v;
14 int flag;
15 int vval;
16 int rank, size;
17
18 MTest_Init(&argc, &argv);
19 MPI_Comm_size(MPI_COMM_WORLD, &size);
20 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
21
22 MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_TAG_UB, &v, &flag);
23 if (!flag) {
24 errs++;
25 fprintf(stderr, "Could not get TAG_UB\n");
26 } else {
27 vval = *(int *) v;
28 if (vval < 32767) {
29 errs++;
30 fprintf(stderr, "Got too-small value (%d) for TAG_UB\n", vval);
31 }
32 }
33
34 MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_HOST, &v, &flag);
35 if (!flag) {
36 errs++;
37 fprintf(stderr, "Could not get HOST\n");
38 } else {
39 vval = *(int *) v;
40 if ((vval < 0 || vval >= size) && vval != MPI_PROC_NULL) {
41 errs++;
42 fprintf(stderr, "Got invalid value %d for HOST\n", vval);
43 }
44 }
45 MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_IO, &v, &flag);
46 if (!flag) {
47 errs++;
48 fprintf(stderr, "Could not get IO\n");
49 } else {
50 vval = *(int *) v;
51 if ((vval < 0 || vval >= size) && vval != MPI_ANY_SOURCE && vval != MPI_PROC_NULL) {
52 errs++;
53 fprintf(stderr, "Got invalid value %d for IO\n", vval);
54 }
55 }
56
57 MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_WTIME_IS_GLOBAL, &v, &flag);
58 if (flag) {
59 /* Wtime need not be set */
60 vval = *(int *) v;
61 if (vval < 0 || vval > 1) {
62 errs++;
63 fprintf(stderr, "Invalid value for WTIME_IS_GLOBAL (got %d)\n", vval);
64 }
65 }
66
67 /* MPI 2.0, section 5.5.3 - MPI_APPNUM should be set if the program is
68 * started with more than one executable name (e.g., in MPMD instead
69 * of SPMD mode). This is independent of the dynamic process routines,
70 * and should be supported even if MPI_COMM_SPAWN and friends are not. */
71 MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_APPNUM, &v, &flag);
72 /* appnum need not be set */
73 if (flag) {
74 vval = *(int *) v;
75 if (vval < 0) {
76 errs++;
77 fprintf(stderr, "MPI_APPNUM is defined as %d but must be nonnegative\n", vval);
78 }
79 }
80
81 /* MPI 2.0 section 5.5.1. MPI_UNIVERSE_SIZE need not be set, but
82 * should be present. */
83 MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_UNIVERSE_SIZE, &v, &flag);
84 /* MPI_UNIVERSE_SIZE need not be set */
85 if (flag) {
86 /* But if it is set, it must be at least the size of comm_world */
87 vval = *(int *) v;
88 if (vval < size) {
89 errs++;
90 fprintf(stderr, "MPI_UNIVERSE_SIZE = %d, less than comm world (%d)\n", vval, size);
91 }
92 }
93
94 MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_LASTUSEDCODE, &v, &flag);
95 /* Last used code must be defined and >= MPI_ERR_LASTCODE */
96 if (flag) {
97 vval = *(int *) v;
98 if (vval < MPI_ERR_LASTCODE) {
99 errs++;
100 fprintf(stderr,
101 "MPI_LASTUSEDCODE points to an integer (%d) smaller than MPI_ERR_LASTCODE (%d)\n",
102 vval, MPI_ERR_LASTCODE);
103 }
104 } else {
105 errs++;
106 fprintf(stderr, "MPI_LASTUSECODE is not defined\n");
107 }
108
109 MTest_Finalize(errs);
110
111 return MTestReturnValue(errs);
112 }
113