cat_get_info.c 3.94 KB
Newer Older
1
2
3
4
5
6
7
8
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
/*
 *  (C) 2011 by Argonne National Laboratory.
 *      See COPYRIGHT in top-level directory.
 */

#include "mpiimpl.h"

9
/* -- Begin Profiling Symbol Block for routine MPI_T_category_get_info */
10
#if defined(HAVE_PRAGMA_WEAK)
11
#pragma weak MPI_T_category_get_info = PMPI_T_category_get_info
12
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
13
#pragma _HP_SECONDARY_DEF PMPI_T_category_get_info  MPI_T_category_get_info
14
#elif defined(HAVE_PRAGMA_CRI_DUP)
15
#pragma _CRI duplicate MPI_T_category_get_info as PMPI_T_category_get_info
16
17
18
#elif defined(HAVE_WEAK_ATTRIBUTE)
int MPI_T_category_get_info(int cat_index, char *name, int *name_len, char *desc, int *desc_len,
                            int *num_cvars, int *num_pvars, int *num_categories) __attribute__((weak,alias("PMPI_T_category_get_info")));
19
20
21
22
23
24
#endif
/* -- End Profiling Symbol Block */

/* Define MPICH_MPI_FROM_PMPI if weak symbols are not supported to build
   the MPI routines */
#ifndef MPICH_MPI_FROM_PMPI
25
26
#undef MPI_T_category_get_info
#define MPI_T_category_get_info PMPI_T_category_get_info
27
28
29
#endif /* MPICH_MPI_FROM_PMPI */

#undef FUNCNAME
30
#define FUNCNAME MPI_T_category_get_info
31
32
33
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
/*@
34
MPI_T_category_get_info - Get the information about a category
35
36
37
38
39
40
41
42
43
44
45

Input/Output Parameters:
+ name_len - length of the string and/or buffer for name (integer)
- desc_len - length of the string and/or buffer for desc (integer)

Input Parameters:
. cat_index - index of the category to be queried (integer)

Output Parameters:
+ name - buffer to return the string containing the name of the category (string)
. desc - buffer to return the string containing the description of the category (string)
46
. num_cvars - number of control variables contained in the category (integer)
47
48
49
50
51
52
. num_pvars - number of performance variables contained in the category (integer)
- num_categories - number of categories contained in the category (integer)

.N ThreadSafe

.N Errors
53
54
55
.N MPI_SUCCESS
.N MPI_T_ERR_NOT_INITIALIZED
.N MPI_T_ERR_INVALID_INDEX
56
@*/
57
58
int MPI_T_category_get_info(int cat_index, char *name, int *name_len, char *desc,
        int *desc_len, int *num_cvars, int *num_pvars, int *num_categories)
59
60
61
{
    int mpi_errno = MPI_SUCCESS;

62
    MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_CATEGORY_GET_INFO);
Junchao Zhang's avatar
Junchao Zhang committed
63
    MPIR_ERRTEST_MPIT_INITIALIZED(mpi_errno);
64
    MPIR_T_THREAD_CS_ENTER();
65
    MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_T_CATEGORY_GET_INFO);
66

67
    /* Validate parameters */
68
69
70
71
#   ifdef HAVE_ERROR_CHECKING
    {
        MPID_BEGIN_ERROR_CHECKS
        {
Junchao Zhang's avatar
Junchao Zhang committed
72
73
            MPIR_ERRTEST_CAT_INDEX(cat_index, mpi_errno);
            /* Do not do _TEST_ARGNULL for other arguments, since this is
74
75
             * allowed or will be allowed by MPI_T standard.
             */
76
77
78
79
80
        }
        MPID_END_ERROR_CHECKS
    }
#   endif /* HAVE_ERROR_CHECKING */

81
    /* ... body of routine ...  */
82

83
84
85
86
87
88
89
    cat_table_entry_t *cat;
    cat = (cat_table_entry_t *)utarray_eltptr(cat_table, cat_index);
    MPIR_T_strncpy(name, cat->name, name_len);
    MPIR_T_strncpy(desc, cat->desc, desc_len);

    if (num_cvars != NULL)
        *num_cvars = utarray_len(cat->cvar_indices);
90

91
92
    if (num_pvars != NULL)
        *num_pvars = utarray_len(cat->pvar_indices);
93

94
95
    if (num_categories != NULL)
        *num_categories = utarray_len(cat->subcat_indices);
96
97
98
    /* ... end of body of routine ... */

fn_exit:
99
    MPID_MPI_FUNC_EXIT(MPID_STATE_MPI_T_CATEGORY_GET_INFO);
100
    MPIR_T_THREAD_CS_EXIT();
101
102
103
104
105
106
107
108
    return mpi_errno;

fn_fail:
    /* --BEGIN ERROR HANDLING-- */
#   ifdef HAVE_ERROR_CHECKING
    {
        mpi_errno = MPIR_Err_create_code(
            mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OTHER,
109
110
            "**mpi_t_category_get_info", "**mpi_t_category_get_info %d %p %p %p %p %p %p %p",
            cat_index, name, name_len, desc, desc_len, num_cvars, num_pvars, num_categories);
111
112
113
114
115
116
    }
#   endif
    mpi_errno = MPIR_Err_return_comm(NULL, FCNAME, mpi_errno);
    goto fn_exit;
    /* --END ERROR HANDLING-- */
}