File: baseattrcomm.c

package info (click to toggle)
mpich 3.3-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 131,836 kB
  • sloc: ansic: 975,868; cpp: 57,437; f90: 53,762; perl: 19,562; xml: 12,464; sh: 12,303; fortran: 7,875; makefile: 7,078; ruby: 126; java: 100; python: 98; lisp: 19; php: 8; sed: 4
file content (113 lines) | stat: -rw-r--r-- 3,483 bytes parent folder | download
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
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
/*
 *
 *  (C) 2001 by Argonne National Laboratory.
 *      See COPYRIGHT in top-level directory.
 */
#include <stdio.h>
#include "mpi.h"
#include "mpitest.h"

int main(int argc, char **argv)
{
    int errs = 0;
    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);

    MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_TAG_UB, &v, &flag);
    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);
        }
    }

    MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_HOST, &v, &flag);
    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);
        }
    }
    MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_IO, &v, &flag);
    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);
        }
    }

    MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_WTIME_IS_GLOBAL, &v, &flag);
    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);
        }
    }

    /* MPI 2.0, section 5.5.3 - MPI_APPNUM should be set if the program is
     * started with more than one executable name (e.g., in MPMD instead
     * of SPMD mode).  This is independent of the dynamic process routines,
     * and should be supported even if MPI_COMM_SPAWN and friends are not. */
    MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_APPNUM, &v, &flag);
    /* 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);
        }
    }

    /* MPI 2.0 section 5.5.1.  MPI_UNIVERSE_SIZE need not be set, but
     * should be present.  */
    MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_UNIVERSE_SIZE, &v, &flag);
    /* MPI_UNIVERSE_SIZE need not be set */
    if (flag) {
        /* But if it is set, it must be at least the size of comm_world */
        vval = *(int *) v;
        if (vval < size) {
            errs++;
            fprintf(stderr, "MPI_UNIVERSE_SIZE = %d, less than comm world (%d)\n", vval, size);
        }
    }

    MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_LASTUSEDCODE, &v, &flag);
    /* 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");
    }

    MTest_Finalize(errs);

    return MTestReturnValue(errs);
}