Blame src/mpi_t/cat_get_cvars.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_category_get_cvars */
Packit 0848f5
#if defined(HAVE_PRAGMA_WEAK)
Packit 0848f5
#pragma weak MPI_T_category_get_cvars = PMPI_T_category_get_cvars
Packit 0848f5
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
Packit 0848f5
#pragma _HP_SECONDARY_DEF PMPI_T_category_get_cvars  MPI_T_category_get_cvars
Packit 0848f5
#elif defined(HAVE_PRAGMA_CRI_DUP)
Packit 0848f5
#pragma _CRI duplicate MPI_T_category_get_cvars as PMPI_T_category_get_cvars
Packit 0848f5
#elif defined(HAVE_WEAK_ATTRIBUTE)
Packit 0848f5
int MPI_T_category_get_cvars(int cat_index, int len, int indices[]) __attribute__((weak,alias("PMPI_T_category_get_cvars")));
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_category_get_cvars
Packit 0848f5
#define MPI_T_category_get_cvars PMPI_T_category_get_cvars
Packit 0848f5
Packit 0848f5
/* any non-MPI functions go here, especially non-static ones */
Packit 0848f5
Packit 0848f5
#undef FUNCNAME
Packit 0848f5
#define FUNCNAME MPIR_T_category_get_cvars_impl
Packit 0848f5
#undef FCNAME
Packit 0848f5
#define FCNAME MPL_QUOTE(FUNCNAME)
Packit 0848f5
int MPIR_T_category_get_cvars_impl(int cat_index, int len, int indices[])
Packit 0848f5
{
Packit 0848f5
    int mpi_errno = MPI_SUCCESS;
Packit 0848f5
    cat_table_entry_t *cat;
Packit 0848f5
    int i, num_cvars, count;
Packit 0848f5
Packit 0848f5
    cat = (cat_table_entry_t *)utarray_eltptr(cat_table, cat_index);
Packit 0848f5
    num_cvars = utarray_len(cat->cvar_indices);
Packit 0848f5
    count = len < num_cvars ? len : num_cvars;
Packit 0848f5
Packit 0848f5
    for (i = 0; i < count; i++) {
Packit 0848f5
        indices[i] = *(int *)utarray_eltptr(cat->cvar_indices, i);
Packit 0848f5
    }
Packit 0848f5
Packit 0848f5
fn_exit:
Packit 0848f5
    return mpi_errno;
Packit 0848f5
fn_fail:
Packit 0848f5
    goto fn_exit;
Packit 0848f5
}
Packit 0848f5
Packit 0848f5
#endif /* MPICH_MPI_FROM_PMPI */
Packit 0848f5
Packit 0848f5
#undef FUNCNAME
Packit 0848f5
#define FUNCNAME MPI_T_category_get_cvars
Packit 0848f5
#undef FCNAME
Packit 0848f5
#define FCNAME MPL_QUOTE(FUNCNAME)
Packit 0848f5
/*@
Packit 0848f5
MPI_T_category_get_cvars - Get control variables in a category
Packit 0848f5
Packit 0848f5
Input Parameters:
Packit 0848f5
+ cat_index - index of the category to be queried, in the range [0,N-1] (integer)
Packit 0848f5
- len - the length of the indices array (integer)
Packit 0848f5
Packit 0848f5
Output Parameters:
Packit 0848f5
. indices - an integer array of size len, indicating control variable indices (array of integers)
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_category_get_cvars(int cat_index, int len, int indices[])
Packit 0848f5
{
Packit 0848f5
    int mpi_errno = MPI_SUCCESS;
Packit 0848f5
Packit 0848f5
    MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_CATEGORY_GET_CVARS);
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_CATEGORY_GET_CVARS);
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_CAT_INDEX(cat_index, mpi_errno);
Packit 0848f5
            if (len != 0)
Packit 0848f5
                MPIR_ERRTEST_ARGNULL(indices, "indices", mpi_errno);
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
    if (len == 0) goto fn_exit;
Packit 0848f5
Packit 0848f5
    mpi_errno = MPIR_T_category_get_cvars_impl(cat_index, len, indices);
Packit 0848f5
    if (mpi_errno) MPIR_ERR_POP(mpi_errno);
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_CATEGORY_GET_CVARS);
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_category_get_cvars", "**mpi_t_category_get_cvars %d %d %p", cat_index, len, indices);
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
}