File: sessioncall.c

package info (click to toggle)
mpich 5.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 251,828 kB
  • sloc: ansic: 1,323,147; cpp: 82,869; f90: 72,420; javascript: 40,763; perl: 28,296; sh: 19,399; python: 16,191; xml: 14,418; makefile: 9,468; fortran: 8,046; java: 4,635; pascal: 352; asm: 324; ruby: 176; awk: 27; lisp: 19; php: 8; sed: 4
file content (58 lines) | stat: -rw-r--r-- 1,296 bytes parent folder | download | duplicates (3)
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
/*
 * Copyright (C) by Argonne National Laboratory
 *     See COPYRIGHT in top-level directory
 */

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

/* Test for MPI_Session_call_errhandler() with user-defined error handler */

static int calls = 0;
static int errs = 0;
static MPI_Session mysession;

void eh(MPI_Session * session, int *err, ...)
{
    if (*err != MPI_ERR_OTHER) {
        errs++;
        fprintf(stderr, "Unexpected error code\n");
    }
    if (*session != mysession) {
        errs++;
        fprintf(stderr, "Unexpected session\n");
    }
    calls++;
    return;
}

int main(int argc, char *argv[])
{
    MPI_Session session;
    MPI_Errhandler newerr;

    MPI_Session_create_errhandler(eh, &newerr);

    MPI_Session_init(MPI_INFO_NULL, newerr, &session);

    mysession = session;

    MPI_Session_set_errhandler(session, newerr);
    MPI_Session_call_errhandler(session, MPI_ERR_OTHER);
    MPI_Errhandler_free(&newerr);
    if (calls != 1) {
        errs++;
        fprintf(stderr, "Error handler called %d times (expected exactly 1 call)\n", calls);
    }

    MPI_Session_finalize(&session);

    if (errs == 0) {
        fprintf(stdout, " No Errors\n");
    } else {
        fprintf(stderr, "%d Errors\n", errs);
    }

    return MTestReturnValue(errs);
}