File: adderr.c

package info (click to toggle)
mpich 4.0.2-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 423,384 kB
  • sloc: ansic: 1,088,434; cpp: 71,364; javascript: 40,763; f90: 22,829; sh: 17,463; perl: 14,773; xml: 14,418; python: 10,265; makefile: 9,246; fortran: 8,008; java: 4,355; asm: 324; ruby: 176; lisp: 19; php: 8; sed: 4
file content (83 lines) | stat: -rw-r--r-- 2,610 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
/*
 * Copyright (C) by Argonne National Laboratory
 *     See COPYRIGHT in top-level directory
 */

#include "mpi.h"
#include <stdio.h>
#include <stdlib.h>
#include "mpitest.h"
#include "mpitestconf.h"
#ifdef HAVE_STRING_H
#include <string.h>
#endif

/* Create NCLASSES new classes, each with 5 codes (160 total) */
#define NCLASSES 32
#define NCODES   5

int main(int argc, char *argv[])
{
    int errs = 0;
    char string[MPI_MAX_ERROR_STRING], outstring[MPI_MAX_ERROR_STRING];
    int newclass[NCLASSES], newcode[NCLASSES][NCODES];
    int i, j, slen, outclass;

    MTest_Init(&argc, &argv);

#if MPI_VERSION >= 4
    /* add and delete a bunch of times */
    for (int k = 0; k < 10000; k++) {
        for (i = 0; i < NCLASSES; i++) {
            MPI_Add_error_class(&newclass[i]);
            for (j = 0; j < NCODES; j++) {
                MPI_Add_error_code(newclass[i], &newcode[i][j]);
                sprintf(string, "random incorrect string\n");
                MPI_Add_error_string(newcode[i][j], string);
            }
        }
        for (i = 0; i < NCLASSES; i++) {
            for (j = 0; j < NCODES; j++) {
                MPI_Delete_error_string(newcode[i][j]);
                MPI_Delete_error_code(newcode[i][j]);
            }
            MPI_Delete_error_class(newclass[i]);
        }
    }
#endif

    /* Initialize the new codes */
    for (i = 0; i < NCLASSES; i++) {
        MPI_Add_error_class(&newclass[i]);
        for (j = 0; j < NCODES; j++) {
            MPI_Add_error_code(newclass[i], &newcode[i][j]);
            sprintf(string, "code for class %d code %d\n", i, j);
            MPI_Add_error_string(newcode[i][j], string);
        }
    }

    /* check the values */
    for (i = 0; i < NCLASSES; i++) {
        MPI_Error_class(newclass[i], &outclass);
        if (outclass != newclass[i]) {
            errs++;
            printf("Error class %d is not a valid error code %x %x\n", i, outclass, newclass[i]);
        }
        for (j = 0; j < NCODES; j++) {
            MPI_Error_class(newcode[i][j], &outclass);
            if (outclass != newclass[i]) {
                errs++;
                printf("Class of code for %d is not correct %x %x\n", j, outclass, newclass[i]);
            }
            MPI_Error_string(newcode[i][j], outstring, &slen);
            sprintf(string, "code for class %d code %d\n", i, j);
            if (strcmp(outstring, string)) {
                errs++;
                printf("Error string is :%s: but should be :%s:\n", outstring, string);
            }
        }
    }

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