root/ompi/mpi/tool/mpit_common.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. ompi_mpit_lock
  2. ompi_mpit_unlock
  3. ompit_var_type_to_datatype
  4. ompit_opal_to_mpit_error

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2012-2018 Los Alamos National Security, LLC. All rights
   4  *                         reserved.
   5  * Copyright (c) 2015      Research Organization for Information Science
   6  *                         and Technology (RIST). All rights reserved.
   7  * Copyright (c) 2017      IBM Corporation. All rights reserved.
   8  * $COPYRIGHT$
   9  *
  10  * Additional copyrights may follow
  11  *
  12  * $HEADER$
  13  */
  14 
  15 #include "ompi/mpi/tool/mpit-internal.h"
  16 
  17 opal_mutex_t ompi_mpit_big_lock = OPAL_MUTEX_STATIC_INIT;
  18 
  19 volatile uint32_t ompi_mpit_init_count = 0;
  20 
  21 void ompi_mpit_lock (void)
  22 {
  23     opal_mutex_lock (&ompi_mpit_big_lock);
  24 }
  25 
  26 void ompi_mpit_unlock (void)
  27 {
  28     opal_mutex_unlock (&ompi_mpit_big_lock);
  29 }
  30 
  31 static MPI_Datatype mca_to_mpi_datatypes[MCA_BASE_VAR_TYPE_MAX] = {
  32     [MCA_BASE_VAR_TYPE_INT] = MPI_INT,
  33     [MCA_BASE_VAR_TYPE_UNSIGNED_INT] = MPI_UNSIGNED,
  34     [MCA_BASE_VAR_TYPE_UNSIGNED_LONG] = MPI_UNSIGNED_LONG,
  35     [MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG] = MPI_UNSIGNED_LONG_LONG,
  36 
  37 #if SIZEOF_SIZE_T == SIZEOF_UNSIGNED_INT
  38     [MCA_BASE_VAR_TYPE_SIZE_T] = MPI_UNSIGNED,
  39 #elif SIZEOF_SIZE_T == SIZEOF_UNSIGNED_LONG
  40     [MCA_BASE_VAR_TYPE_SIZE_T] = MPI_UNSIGNED_LONG,
  41 #elif SIZEOF_SIZE_T == SIZEOF_LONG_LONG
  42     [MCA_BASE_VAR_TYPE_SIZE_T] = MPI_UNSIGNED_LONG_LONG,
  43 #else
  44     [MCA_BASE_VAR_TYPE_SIZE_T] = NULL,
  45 #endif
  46 
  47     [MCA_BASE_VAR_TYPE_STRING] = MPI_CHAR,
  48     [MCA_BASE_VAR_TYPE_VERSION_STRING] = MPI_CHAR,
  49     [MCA_BASE_VAR_TYPE_BOOL] = MPI_C_BOOL,
  50     [MCA_BASE_VAR_TYPE_DOUBLE] = MPI_DOUBLE,
  51     [MCA_BASE_VAR_TYPE_LONG] = MPI_LONG,
  52     [MCA_BASE_VAR_TYPE_INT32_T] = MPI_INT32_T,
  53     [MCA_BASE_VAR_TYPE_UINT32_T] = MPI_UINT32_T,
  54     [MCA_BASE_VAR_TYPE_INT64_T] = MPI_INT64_T,
  55     [MCA_BASE_VAR_TYPE_UINT64_T] = MPI_UINT64_T,
  56 };
  57 
  58 int ompit_var_type_to_datatype (mca_base_var_type_t type, MPI_Datatype *datatype)
  59 {
  60     if (!datatype) {
  61         return OMPI_SUCCESS;
  62     }
  63 
  64     *datatype = mca_to_mpi_datatypes[type];
  65     assert (*datatype);
  66 
  67     return OMPI_SUCCESS;
  68 }
  69 
  70 int ompit_opal_to_mpit_error (int rc)
  71 {
  72     if (rc >= 0) {
  73         /* Already an MPI error (always >= 0) */
  74         return rc;
  75     }
  76 
  77     switch (rc) {
  78     case OPAL_ERR_OUT_OF_RESOURCE:
  79         return MPI_T_ERR_MEMORY;
  80     case OPAL_ERR_VALUE_OUT_OF_BOUNDS:
  81     case OPAL_ERR_NOT_BOUND:
  82         return MPI_T_ERR_INVALID_HANDLE;
  83     default:
  84         return MPI_ERR_UNKNOWN;
  85     }
  86 }

/* [<][>][^][v][top][bottom][index][help] */