Blame src/mpi_t/pvar_get_info.c

Packit 0848f5
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
Packit 0848f5
/*
Packit 0848f5
 *  (C) 2011 by Argonne National Laboratory.
Packit 0848f5
 *      See COPYRIGHT in top-level directory.
Packit 0848f5
 */
Packit 0848f5
Packit 0848f5
#include "mpiimpl.h"
Packit 0848f5
Packit 0848f5
/* -- Begin Profiling Symbol Block for routine MPI_T_pvar_get_info */
Packit 0848f5
#if defined(HAVE_PRAGMA_WEAK)
Packit 0848f5
#pragma weak MPI_T_pvar_get_info = PMPI_T_pvar_get_info
Packit 0848f5
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
Packit 0848f5
#pragma _HP_SECONDARY_DEF PMPI_T_pvar_get_info  MPI_T_pvar_get_info
Packit 0848f5
#elif defined(HAVE_PRAGMA_CRI_DUP)
Packit 0848f5
#pragma _CRI duplicate MPI_T_pvar_get_info as PMPI_T_pvar_get_info
Packit 0848f5
#elif defined(HAVE_WEAK_ATTRIBUTE)
Packit 0848f5
int MPI_T_pvar_get_info(int pvar_index, char *name, int *name_len, int *verbosity, int *var_class,
Packit 0848f5
                        MPI_Datatype *datatype, MPI_T_enum *enumtype, char *desc, int *desc_len,
Packit 0848f5
                        int *binding, int *readonly, int *continuous, int *atomic) __attribute__((weak,alias("PMPI_T_pvar_get_info")));
Packit 0848f5
#endif
Packit 0848f5
/* -- End Profiling Symbol Block */
Packit 0848f5
Packit 0848f5
/* Define MPICH_MPI_FROM_PMPI if weak symbols are not supported to build
Packit 0848f5
   the MPI routines */
Packit 0848f5
#ifndef MPICH_MPI_FROM_PMPI
Packit 0848f5
#undef MPI_T_pvar_get_info
Packit 0848f5
#define MPI_T_pvar_get_info PMPI_T_pvar_get_info
Packit 0848f5
#endif /* MPICH_MPI_FROM_PMPI */
Packit 0848f5
Packit 0848f5
#undef FUNCNAME
Packit 0848f5
#define FUNCNAME MPI_T_pvar_get_info
Packit 0848f5
#undef FCNAME
Packit 0848f5
#define FCNAME MPL_QUOTE(FUNCNAME)
Packit 0848f5
/*@
Packit 0848f5
MPI_T_pvar_get_info - Get the inforamtion about a performance variable
Packit 0848f5
Packit 0848f5
Input/Output Parameters:
Packit 0848f5
+ name_len - length of the string and/or buffer for name (integer)
Packit 0848f5
- desc_len - length of the string and/or buffer for desc (integer)
Packit 0848f5
Packit 0848f5
Input Parameters:
Packit 0848f5
. pvar_index - index of the performance variable to be queried between 0 and num_pvar-1 (integer)
Packit 0848f5
Packit 0848f5
Output Parameters:
Packit 0848f5
+ name - buffer to return the string containing the name of the performance variable (string)
Packit 0848f5
. verbosity - verbosity level of this variable (integer)
Packit 0848f5
. var_class - class of performance variable (integer)
Packit 0848f5
. datatype - MPI type of the information stored in the performance variable (handle)
Packit 0848f5
. enumtype - optional descriptor for enumeration information (handle)
Packit 0848f5
. desc - buffer to return the string containing a description of the performance variable (string)
Packit 0848f5
. binding - type of MPI object to which this variable must be bound (integer)
Packit 0848f5
. readonly - flag indicating whether the variable can be written/reset (integer)
Packit 0848f5
. continuous - flag indicating whether the variable can be started and stopped or is continuously active (integer)
Packit 0848f5
- atomic - flag indicating whether the variable can be atomically read and reset (integer)
Packit 0848f5
Packit 0848f5
.N ThreadSafe
Packit 0848f5
Packit 0848f5
.N Errors
Packit 0848f5
.N MPI_SUCCESS
Packit 0848f5
.N MPI_T_ERR_NOT_INITIALIZED
Packit 0848f5
.N MPI_T_ERR_INVALID_INDEX
Packit 0848f5
@*/
Packit 0848f5
int MPI_T_pvar_get_info(int pvar_index, char *name, int *name_len, int *verbosity,
Packit 0848f5
    int *var_class, MPI_Datatype *datatype, MPI_T_enum *enumtype, char *desc,
Packit 0848f5
    int *desc_len, int *binding, int *readonly, int *continuous, int *atomic)
Packit 0848f5
{
Packit 0848f5
    int mpi_errno = MPI_SUCCESS;
Packit 0848f5
    const pvar_table_entry_t *entry;
Packit 0848f5
    const pvar_table_entry_t *info;
Packit 0848f5
Packit 0848f5
    MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_PVAR_GET_INFO);
Packit 0848f5
    MPIR_ERRTEST_MPIT_INITIALIZED(mpi_errno);
Packit 0848f5
    MPIR_T_THREAD_CS_ENTER();
Packit 0848f5
    MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_T_PVAR_GET_INFO);
Packit 0848f5
Packit 0848f5
    /* Validate parameters */
Packit 0848f5
#   ifdef HAVE_ERROR_CHECKING
Packit 0848f5
    {
Packit 0848f5
        MPID_BEGIN_ERROR_CHECKS
Packit 0848f5
        {
Packit 0848f5
            MPIR_ERRTEST_PVAR_INDEX(pvar_index, mpi_errno);
Packit 0848f5
            /* Do not do _TEST_ARGNULL for other arguments, since this is
Packit 0848f5
             * allowed or will be allowed by MPI_T standard.
Packit 0848f5
             */
Packit 0848f5
        }
Packit 0848f5
        MPID_END_ERROR_CHECKS
Packit 0848f5
    }
Packit 0848f5
#   endif /* HAVE_ERROR_CHECKING */
Packit 0848f5
Packit 0848f5
    /* ... body of routine ...  */
Packit 0848f5
Packit 0848f5
    entry = (pvar_table_entry_t *) utarray_eltptr(pvar_table, pvar_index);
Packit 0848f5
    if (!entry->active) {
Packit 0848f5
        mpi_errno = MPI_T_ERR_INVALID_INDEX;
Packit 0848f5
        goto fn_fail;
Packit 0848f5
    }
Packit 0848f5
Packit 0848f5
    info = (pvar_table_entry_t *) utarray_eltptr(pvar_table, pvar_index);
Packit 0848f5
Packit 0848f5
    MPIR_T_strncpy(name, info->name, name_len);
Packit 0848f5
    MPIR_T_strncpy(desc, info->desc, desc_len);
Packit 0848f5
Packit 0848f5
    if (verbosity != NULL)
Packit 0848f5
        *verbosity = info->verbosity;
Packit 0848f5
Packit 0848f5
    if (var_class != NULL)
Packit 0848f5
        *var_class = info->varclass;
Packit 0848f5
Packit 0848f5
    if (datatype != NULL)
Packit 0848f5
        *datatype = info->datatype;
Packit 0848f5
Packit 0848f5
    if (enumtype != NULL)
Packit 0848f5
        *enumtype = info->enumtype;
Packit 0848f5
Packit 0848f5
    if (binding != NULL)
Packit 0848f5
        *binding = info->bind;
Packit 0848f5
Packit 0848f5
    if (readonly != NULL)
Packit 0848f5
        *readonly = info->flags & MPIR_T_PVAR_FLAG_READONLY;
Packit 0848f5
Packit 0848f5
    if (continuous != NULL)
Packit 0848f5
        *continuous = info->flags & MPIR_T_PVAR_FLAG_CONTINUOUS;
Packit 0848f5
Packit 0848f5
    if (atomic != NULL)
Packit 0848f5
        *atomic = info->flags & MPIR_T_PVAR_FLAG_ATOMIC;
Packit 0848f5
Packit 0848f5
    /* ... end of body of routine ... */
Packit 0848f5
Packit 0848f5
fn_exit:
Packit 0848f5
    MPID_MPI_FUNC_EXIT(MPID_STATE_MPI_T_PVAR_GET_INFO);
Packit 0848f5
    MPIR_T_THREAD_CS_EXIT();
Packit 0848f5
    return mpi_errno;
Packit 0848f5
Packit 0848f5
fn_fail:
Packit 0848f5
    /* --BEGIN ERROR HANDLING-- */
Packit 0848f5
#   ifdef HAVE_ERROR_CHECKING
Packit 0848f5
    {
Packit 0848f5
        mpi_errno = MPIR_Err_create_code(
Packit 0848f5
            mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OTHER,
Packit 0848f5
            "**mpi_t_pvar_get_info", "**mpi_t_pvar_get_info %d %p %p %p %p %p %p %p %p %p %p %p %p",
Packit 0848f5
            pvar_index, name, name_len, verbosity, var_class, datatype, enumtype, desc, desc_len,
Packit 0848f5
            binding, readonly, continuous, atomic);
Packit 0848f5
    }
Packit 0848f5
#   endif
Packit 0848f5
    mpi_errno = MPIR_Err_return_comm(NULL, FCNAME, mpi_errno);
Packit 0848f5
    goto fn_exit;
Packit 0848f5
    /* --END ERROR HANDLING-- */
Packit 0848f5
}