Logo AND Algorithmique Numérique Distribuée

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