File: mpit_common.c

package info (click to toggle)
openmpi 5.0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 202,312 kB
  • sloc: ansic: 612,441; makefile: 42,495; sh: 11,230; javascript: 9,244; f90: 7,052; java: 6,404; perl: 5,154; python: 1,856; lex: 740; fortran: 61; cpp: 20; tcl: 12
file content (89 lines) | stat: -rw-r--r-- 2,607 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
 * Copyright (c) 2012-2018 Los Alamos National Security, LLC. All rights
 *                         reserved.
 * Copyright (c) 2015      Research Organization for Information Science
 *                         and Technology (RIST). All rights reserved.
 * Copyright (c) 2017      IBM Corporation. All rights reserved.
 * Copyright (c) 2020      The University of Tennessee and The University
 *                         of Tennessee Research Foundation.  All rights
 *                         reserved.
 * $COPYRIGHT$
 *
 * Additional copyrights may follow
 *
 * $HEADER$
 */

#include "ompi/mpi/tool/mpit-internal.h"

opal_mutex_t ompi_mpit_big_lock = OPAL_MUTEX_STATIC_INIT;

volatile uint32_t ompi_mpit_init_count = 0;

void ompi_mpit_lock (void)
{
    opal_mutex_lock (&ompi_mpit_big_lock);
}

void ompi_mpit_unlock (void)
{
    opal_mutex_unlock (&ompi_mpit_big_lock);
}

static MPI_Datatype mca_to_mpi_datatypes[MCA_BASE_VAR_TYPE_MAX] = {
    [MCA_BASE_VAR_TYPE_INT] = MPI_INT,
    [MCA_BASE_VAR_TYPE_UNSIGNED_INT] = MPI_UNSIGNED,
    [MCA_BASE_VAR_TYPE_UNSIGNED_LONG] = MPI_UNSIGNED_LONG,
    [MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG] = MPI_UNSIGNED_LONG_LONG,

#if SIZEOF_SIZE_T == SIZEOF_UNSIGNED_INT
    [MCA_BASE_VAR_TYPE_SIZE_T] = MPI_UNSIGNED,
#elif SIZEOF_SIZE_T == SIZEOF_UNSIGNED_LONG
    [MCA_BASE_VAR_TYPE_SIZE_T] = MPI_UNSIGNED_LONG,
#elif SIZEOF_SIZE_T == SIZEOF_LONG_LONG
    [MCA_BASE_VAR_TYPE_SIZE_T] = MPI_UNSIGNED_LONG_LONG,
#else
    [MCA_BASE_VAR_TYPE_SIZE_T] = NULL,
#endif

    [MCA_BASE_VAR_TYPE_STRING] = MPI_CHAR,
    [MCA_BASE_VAR_TYPE_VERSION_STRING] = MPI_CHAR,
    [MCA_BASE_VAR_TYPE_BOOL] = MPI_C_BOOL,
    [MCA_BASE_VAR_TYPE_DOUBLE] = MPI_DOUBLE,
    [MCA_BASE_VAR_TYPE_LONG] = MPI_LONG,
    [MCA_BASE_VAR_TYPE_INT32_T] = MPI_INT32_T,
    [MCA_BASE_VAR_TYPE_UINT32_T] = MPI_UINT32_T,
    [MCA_BASE_VAR_TYPE_INT64_T] = MPI_INT64_T,
    [MCA_BASE_VAR_TYPE_UINT64_T] = MPI_UINT64_T,
};

int ompit_var_type_to_datatype (mca_base_var_type_t type, MPI_Datatype *datatype)
{
    if (!datatype) {
        return OMPI_SUCCESS;
    }

    *datatype = mca_to_mpi_datatypes[type];
    assert (*datatype);

    return OMPI_SUCCESS;
}

int ompit_opal_to_mpit_error (int rc)
{
    if (rc >= 0) {
        /* Already an MPI error (always >= 0) */
        return rc;
    }

    switch (rc) {
    case OPAL_ERR_OUT_OF_RESOURCE:
        return MPI_T_ERR_MEMORY;
    case OPAL_ERR_VALUE_OUT_OF_BOUNDS:
    case OPAL_ERR_NOT_BOUND:
        return MPI_T_ERR_INVALID_HANDLE;
    default:
        return MPI_T_ERR_INVALID;
    }
}