root/ompi/mpi/tool/cvar_read.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPI_T_cvar_read

   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) 2014 Cisco Systems, Inc.  All rights reserved.
   6  * Copyright (c) 2016      Intel, Inc.  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 #if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES
  18 #pragma weak MPI_T_cvar_read = PMPI_T_cvar_read
  19 #endif
  20 
  21 #if OMPI_PROFILING_DEFINES
  22 #include "ompi/mpi/tool/profile/defines.h"
  23 #endif
  24 
  25 
  26 int MPI_T_cvar_read (MPI_T_cvar_handle handle, void *buf)
  27 {
  28     const mca_base_var_storage_t *value = NULL;
  29     int rc = MPI_SUCCESS;
  30 
  31     if (!mpit_is_initialized ()) {
  32         return MPI_T_ERR_NOT_INITIALIZED;
  33     }
  34 
  35     if (MPI_PARAM_CHECK && NULL == buf) {
  36         return MPI_ERR_ARG;
  37     }
  38 
  39     ompi_mpit_lock ();
  40 
  41     do {
  42         rc = mca_base_var_get_value(handle->var->mbv_index, &value, NULL, NULL);
  43         if (OPAL_SUCCESS != rc || NULL == value) {
  44             /* shouldn't happen */
  45             rc = MPI_ERR_OTHER;
  46             break;
  47         }
  48 
  49         switch (handle->var->mbv_type) {
  50         case MCA_BASE_VAR_TYPE_INT:
  51         case MCA_BASE_VAR_TYPE_UNSIGNED_INT:
  52             ((int *) buf)[0] = value->intval;
  53             break;
  54         case MCA_BASE_VAR_TYPE_INT32_T:
  55         case MCA_BASE_VAR_TYPE_UINT32_T:
  56             ((int32_t *) buf)[0] = value->int32tval;
  57             break;
  58         case MCA_BASE_VAR_TYPE_INT64_T:
  59         case MCA_BASE_VAR_TYPE_UINT64_T:
  60             ((int64_t *) buf)[0] = value->int64tval;
  61             break;
  62         case MCA_BASE_VAR_TYPE_LONG:
  63         case MCA_BASE_VAR_TYPE_UNSIGNED_LONG:
  64             ((unsigned long *) buf)[0] = value->ulval;
  65             break;
  66         case MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG:
  67             ((unsigned long long *) buf)[0] = value->ullval;
  68             break;
  69         case MCA_BASE_VAR_TYPE_SIZE_T:
  70             ((size_t *) buf)[0] = value->sizetval;
  71             break;
  72         case MCA_BASE_VAR_TYPE_BOOL:
  73             ((bool *) buf)[0] = value->boolval;
  74             break;
  75         case MCA_BASE_VAR_TYPE_DOUBLE:
  76             ((double *) buf)[0] = value->lfval;
  77             break;
  78         case MCA_BASE_VAR_TYPE_STRING:
  79             if (NULL == value->stringval) {
  80                 ((char *)buf)[0] = '\0';
  81             } else {
  82                 strcpy ((char *) buf, value->stringval);
  83             }
  84 
  85             break;
  86         default:
  87             rc = MPI_ERR_OTHER;
  88         }
  89     } while (0);
  90 
  91     ompi_mpit_unlock ();
  92 
  93     return rc;
  94 }

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