File: syshints.c

package info (click to toggle)
openmpi 5.0.8-4
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 201,684 kB
  • sloc: ansic: 613,078; makefile: 42,353; sh: 11,194; javascript: 9,244; f90: 7,052; java: 6,404; perl: 5,179; python: 1,859; lex: 740; fortran: 61; cpp: 20; tcl: 12
file content (59 lines) | stat: -rw-r--r-- 1,654 bytes parent folder | download | duplicates (7)
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
/*
 * Copyright (C) by Argonne National Laboratory
 *     See COPYRIGHT in top-level directory
 */

#include <mpi.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

static void handle_error(int errcode, const char *str)
{
    char msg[MPI_MAX_ERROR_STRING];
    int resultlen;
    MPI_Error_string(errcode, msg, &resultlen);
    fprintf(stderr, "%s: %s\n", str, msg);
    MPI_Abort(MPI_COMM_WORLD, 1);
}

#define CHECK(fn) {int errcode; errcode = (fn); if (errcode != MPI_SUCCESS) handle_error(errcode, #fn); }

static int hint_check(MPI_Info info_used, const char *key, const char *expected)
{
    char value[MPI_MAX_INFO_VAL + 1];
    int flag;

    CHECK(MPI_Info_get(info_used, key, MPI_MAX_INFO_VAL, value, &flag));
    if (strcmp(expected, value)) {
        fprintf(stderr, "expected value \"%s\" for key \"%s\" got \"%s\"\n", expected, key, value);
        return 1;
    }
    return 0;
}

int main(int argc, char **argv)
{
    setenv("ROMIO_HINTS", argv[1], 1);
    MPI_File fh;
    MPI_Info info_used, info_mine;
    int nr_errors = 0;

    MPI_Init(&argc, &argv);
    MPI_Info_create(&info_mine);
    MPI_Info_set(info_mine, "romio_cb_read", "disable");
    CHECK(MPI_File_open(MPI_COMM_WORLD, argv[1], MPI_MODE_RDONLY, info_mine, &fh));
    CHECK(MPI_File_get_info(fh, &info_used));

    nr_errors += hint_check(info_used, "ind_rd_buffer_size", "49");
    nr_errors += hint_check(info_used, "romio_no_indep_rw", "true");

    if (nr_errors == 0)
        printf(" No Errors\n");

    CHECK(MPI_Info_free(&info_mine));
    CHECK(MPI_Info_free(&info_used));
    CHECK(MPI_File_close(&fh));
    MPI_Finalize();
    return nr_errors;
}