File: groupnullincl.c

package info (click to toggle)
mpich 4.3.0%2Breally4.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 419,120 kB
  • sloc: ansic: 1,215,557; cpp: 74,755; javascript: 40,763; f90: 20,649; sh: 18,463; xml: 14,418; python: 14,397; perl: 13,772; makefile: 9,279; fortran: 8,063; java: 4,553; asm: 324; ruby: 176; lisp: 19; php: 8; sed: 4
file content (70 lines) | stat: -rw-r--r-- 1,948 bytes parent folder | download | duplicates (4)
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
/*
 * Copyright (C) by Argonne National Laboratory
 *     See COPYRIGHT in top-level directory
 */

#include "mpi.h"
#include <stdio.h>
#include "mpitest.h"

int main(int argc, char *argv[])
{
    int errs = 0;
    int rc, result;
    int ranks[1];
    MPI_Group group, outgroup;
    MPI_Comm comm;

    MTest_Init(&argc, &argv);
    /* To improve reporting of problems about operations, we
     * change the error handler to errors return */
    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);

    while (MTestGetComm(&comm, 1)) {
        if (comm == MPI_COMM_NULL)
            continue;

        MPI_Comm_group(comm, &group);
        rc = MPI_Group_incl(group, 0, 0, &outgroup);
        if (rc) {
            errs++;
            MTestPrintError(rc);
            printf("Error in creating an empty group with (0,0)\n");

            /* Some MPI implementations may reject a null "ranks" pointer */
            rc = MPI_Group_incl(group, 0, ranks, &outgroup);
            if (rc) {
                errs++;
                MTestPrintError(rc);
                printf("Error in creating an empty group with (0,ranks)\n");
            }
        }

        if (outgroup != MPI_GROUP_EMPTY) {
            /* Is the group equivalent to group empty? */
            rc = MPI_Group_compare(outgroup, MPI_GROUP_EMPTY, &result);
            if (result != MPI_IDENT) {
                errs++;
                MTestPrintError(rc);
                printf("Did not create a group equivalent to an empty group\n");
            }
        }
        rc = MPI_Group_free(&group);
        if (rc) {
            errs++;
            MTestPrintError(rc);
        }
        if (outgroup != MPI_GROUP_NULL) {
            rc = MPI_Group_free(&outgroup);
            if (rc) {
                errs++;
                MTestPrintError(rc);
            }
        }

        MTestFreeComm(&comm);
    }

    MTest_Finalize(errs);
    return MTestReturnValue(errs);
}