root/ompi/mpi/tool/cvar_handle_alloc.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPI_T_cvar_handle_alloc

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights
   4  *                         reserved.
   5  * Copyright (c) 2014 Cisco Systems, Inc.  All rights reserved.
   6  * Copyright (c) 2017      IBM Corporation. All rights reserved.
   7  * $COPYRIGHT$
   8  *
   9  * Additional copyrights may follow
  10  *
  11  * $HEADER$
  12  */
  13 
  14 #include "ompi/mpi/tool/mpit-internal.h"
  15 
  16 #if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES
  17 #pragma weak MPI_T_cvar_handle_alloc = PMPI_T_cvar_handle_alloc
  18 #endif
  19 
  20 #if OMPI_PROFILING_DEFINES
  21 #include "ompi/mpi/tool/profile/defines.h"
  22 #endif
  23 
  24 
  25 int MPI_T_cvar_handle_alloc (int cvar_index, void *obj_handle,
  26                              MPI_T_cvar_handle *handle, int *count)
  27 {
  28     ompi_mpit_cvar_handle_t *new_handle;
  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 == handle || NULL == count)) {
  36         return MPI_ERR_ARG;
  37     }
  38 
  39     ompi_mpit_lock ();
  40 
  41     *handle = NULL;
  42 
  43     do {
  44         new_handle = (ompi_mpit_cvar_handle_t *) malloc (sizeof (ompi_mpit_cvar_handle_t));
  45         if (NULL == new_handle) {
  46             rc = MPI_T_ERR_MEMORY;
  47             break;
  48         }
  49 
  50         rc = mca_base_var_get(cvar_index, &new_handle->var);
  51         if (OPAL_SUCCESS != rc) {
  52             rc = (OPAL_ERR_VALUE_OUT_OF_BOUNDS == rc || OPAL_ERR_NOT_FOUND == rc) ? MPI_T_ERR_INVALID_INDEX:
  53                 MPI_ERR_OTHER;
  54             free (new_handle);
  55             break;
  56         }
  57 
  58         new_handle->bound_object = obj_handle;
  59 
  60         if (MCA_BASE_VAR_TYPE_STRING == new_handle->var->mbv_type) {
  61             /* Arbitrary string limit. Is there a better way to do this? */
  62             *count = 2048;
  63         } else {
  64             /* MCA only supports a single integer at this time. Change me if
  65                this assumption changes. */
  66             *count = 1;
  67         }
  68 
  69         *handle = (MPI_T_cvar_handle) new_handle;
  70     } while (0);
  71 
  72     ompi_mpit_unlock ();
  73 
  74     return rc;
  75 }

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