1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
|
/*
* Copyright (C) by Argonne National Laboratory
* See COPYRIGHT in top-level directory
*/
#include <stdio.h>
#include "mpi.h"
#include "mpitest.h"
void MissingKeyval(int rc, const char keyname[]);
int main(int argc, char **argv)
{
int errs = 0;
int rc;
void *v;
int flag;
int vval;
int rank, size;
MTest_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
/* Set errors return so that we can provide better information
* should a routine reject one of the attribute values */
MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
rc = MPI_Attr_get(MPI_COMM_WORLD, MPI_TAG_UB, &v, &flag);
if (rc) {
MissingKeyval(rc, "MPI_TAG_UB");
errs++;
} else {
if (!flag) {
errs++;
fprintf(stderr, "Could not get TAG_UB\n");
} else {
vval = *(int *) v;
if (vval < 32767) {
errs++;
fprintf(stderr, "Got too-small value (%d) for TAG_UB\n", vval);
}
}
}
rc = MPI_Attr_get(MPI_COMM_WORLD, MPI_HOST, &v, &flag);
if (rc) {
MissingKeyval(rc, "MPI_HOST");
errs++;
} else {
if (!flag) {
errs++;
fprintf(stderr, "Could not get HOST\n");
} else {
vval = *(int *) v;
if ((vval < 0 || vval >= size) && vval != MPI_PROC_NULL) {
errs++;
fprintf(stderr, "Got invalid value %d for HOST\n", vval);
}
}
}
rc = MPI_Attr_get(MPI_COMM_WORLD, MPI_IO, &v, &flag);
if (rc) {
MissingKeyval(rc, "MPI_IO");
errs++;
} else {
if (!flag) {
errs++;
fprintf(stderr, "Could not get IO\n");
} else {
vval = *(int *) v;
if ((vval < 0 || vval >= size) && vval != MPI_ANY_SOURCE && vval != MPI_PROC_NULL) {
errs++;
fprintf(stderr, "Got invalid value %d for IO\n", vval);
}
}
}
rc = MPI_Attr_get(MPI_COMM_WORLD, MPI_WTIME_IS_GLOBAL, &v, &flag);
if (rc) {
MissingKeyval(rc, "MPI_WTIME_IS_GLOBAL");
errs++;
} else {
if (flag) {
/* Wtime need not be set */
vval = *(int *) v;
if (vval < 0 || vval > 1) {
errs++;
fprintf(stderr, "Invalid value for WTIME_IS_GLOBAL (got %d)\n", vval);
}
}
}
rc = MPI_Attr_get(MPI_COMM_WORLD, MPI_APPNUM, &v, &flag);
if (rc) {
MissingKeyval(rc, "MPI_APPNUM");
errs++;
} else {
/* appnum need not be set */
if (flag) {
vval = *(int *) v;
if (vval < 0) {
errs++;
fprintf(stderr, "MPI_APPNUM is defined as %d but must be nonnegative\n", vval);
}
}
}
rc = MPI_Attr_get(MPI_COMM_WORLD, MPI_UNIVERSE_SIZE, &v, &flag);
if (rc) {
MissingKeyval(rc, "MPI_UNIVERSE_SIZE");
errs++;
} else {
/* MPI_UNIVERSE_SIZE need not be set */
if (flag) {
vval = *(int *) v;
if (vval < size) {
errs++;
fprintf(stderr, "MPI_UNIVERSE_SIZE = %d, less than comm world (%d)\n", vval, size);
}
}
}
rc = MPI_Attr_get(MPI_COMM_WORLD, MPI_LASTUSEDCODE, &v, &flag);
if (rc) {
MissingKeyval(rc, "MPI_LASTUSEDCODE");
errs++;
} else {
/* Last used code must be defined and >= MPI_ERR_LASTCODE */
if (flag) {
vval = *(int *) v;
if (vval < MPI_ERR_LASTCODE) {
errs++;
fprintf(stderr,
"MPI_LASTUSEDCODE points to an integer (%d) smaller than MPI_ERR_LASTCODE (%d)\n",
vval, MPI_ERR_LASTCODE);
}
} else {
errs++;
fprintf(stderr, "MPI_LASTUSECODE is not defined\n");
}
}
MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL);
MTest_Finalize(errs);
return MTestReturnValue(errs);
}
void MissingKeyval(int errcode, const char keyname[])
{
int errclass, slen;
char string[MPI_MAX_ERROR_STRING];
MPI_Error_class(errcode, &errclass);
MPI_Error_string(errcode, string, &slen);
printf("For key %s: Error class %d (%s)\n", keyname, errclass, string);
fflush(stdout);
}
|