From c173344141fe240efbba127dbcb36cd282183836 Mon Sep 17 00:00:00 2001 From: Nathan Hjelm Date: Wed, 12 Mar 2014 16:03:39 +0000 Subject: [PATCH] Add new MPI-3.1 tools interface functions. See https://svn.mpi-forum.org/trac/mpi-forum-web/ticket/377 This ticket adds the following functions to the standard: - MPI_T_cvar_get_index, MPI_T_pvar_get_index, and MPI_T_category_get_index The ticket has passed and the functions are part of MPI-3.1 that will be released sometime later this year. In Open MPI the functions expose existing internal functionality so they are low-risk to add to 1.8.0. I will leave it up to Ralph whether he wants to accept these into 1.8. cmr=v1.8:reviewer=rhc This commit was SVN r31037. --- ompi/include/mpi.h.in | 6 +++++ ompi/mpi/tool/Makefile.am | 5 ++-- ompi/mpi/tool/category_get_index.c | 41 ++++++++++++++++++++++++++++++ ompi/mpi/tool/cvar_get_index.c | 41 ++++++++++++++++++++++++++++++ ompi/mpi/tool/profile/Makefile.am | 3 +++ ompi/mpi/tool/profile/defines.h | 3 +++ ompi/mpi/tool/pvar_get_index.c | 41 ++++++++++++++++++++++++++++++ 7 files changed, 138 insertions(+), 2 deletions(-) create mode 100644 ompi/mpi/tool/category_get_index.c create mode 100644 ompi/mpi/tool/cvar_get_index.c create mode 100644 ompi/mpi/tool/pvar_get_index.c diff --git a/ompi/include/mpi.h.in b/ompi/include/mpi.h.in index 9954bef3cc..2f26a27353 100644 --- a/ompi/include/mpi.h.in +++ b/ompi/include/mpi.h.in @@ -2553,6 +2553,7 @@ OMPI_DECLSPEC int PMPI_T_cvar_get_info (int cvar_index, char *name, int *name_l int *verbosity, MPI_Datatype *datatype, MPI_T_enum *enumtype, char *desc, int *desc_len, int *bind, int *scope); +OMPI_DECLSPEC int PMPI_T_cvar_get_index (const char *name, int *cvar_index); OMPI_DECLSPEC int PMPI_T_cvar_handle_alloc (int cvar_index, void *obj_handle, MPI_T_cvar_handle *handle, int *count); OMPI_DECLSPEC int PMPI_T_cvar_handle_free (MPI_T_cvar_handle *handle); @@ -2562,6 +2563,7 @@ OMPI_DECLSPEC int PMPI_T_category_get_num(int *num_cat); OMPI_DECLSPEC int PMPI_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); +OMPI_DECLSPEC int PMPI_T_category_get_index (const char *name, int *category_index); OMPI_DECLSPEC int PMPI_T_category_get_cvars(int cat_index, int len, int indices[]); OMPI_DECLSPEC int PMPI_T_category_get_pvars(int cat_index, int len, int indices[]); OMPI_DECLSPEC int PMPI_T_category_get_categories(int cat_index, int len, int indices[]); @@ -2572,6 +2574,7 @@ OMPI_DECLSPEC int PMPI_T_pvar_get_info(int pvar_index, char *name, int *name_le int *verbosity, int *var_class, MPI_Datatype *datatype, MPI_T_enum *enumtype, char *desc, int *desc_len, int *bind, int *readonly, int *continuous, int *atomic); +OMPI_DECLSPEC int PMPI_T_pvar_get_index (const char *name, int *pvar_index); OMPI_DECLSPEC int PMPI_T_pvar_session_create(MPI_T_pvar_session *session); OMPI_DECLSPEC int PMPI_T_pvar_session_free(MPI_T_pvar_session *session); OMPI_DECLSPEC int PMPI_T_pvar_handle_alloc(MPI_T_pvar_session session, int pvar_index, @@ -2600,6 +2603,7 @@ OMPI_DECLSPEC int MPI_T_cvar_get_info (int cvar_index, char *name, int *name_le int *verbosity, MPI_Datatype *datatype, MPI_T_enum *enumtype, char *desc, int *desc_len, int *bind, int *scope); +OMPI_DECLSPEC int MPI_T_cvar_get_index (const char *name, int *cvar_index); OMPI_DECLSPEC int MPI_T_cvar_handle_alloc (int cvar_index, void *obj_handle, MPI_T_cvar_handle *handle, int *count); OMPI_DECLSPEC int MPI_T_cvar_handle_free (MPI_T_cvar_handle *handle); @@ -2609,6 +2613,7 @@ OMPI_DECLSPEC int MPI_T_category_get_num(int *num_cat); OMPI_DECLSPEC 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); +OMPI_DECLSPEC int MPI_T_category_get_index (const char *name, int *category_index); OMPI_DECLSPEC int MPI_T_category_get_cvars(int cat_index, int len, int indices[]); OMPI_DECLSPEC int MPI_T_category_get_pvars(int cat_index, int len, int indices[]); OMPI_DECLSPEC int MPI_T_category_get_categories(int cat_index, int len, int indices[]); @@ -2619,6 +2624,7 @@ OMPI_DECLSPEC int MPI_T_pvar_get_info(int pvar_index, char *name, int *name_len int *verbosity, int *var_class, MPI_Datatype *datatype, MPI_T_enum *enumtype, char *desc, int *desc_len, int *bind, int *readonly, int *continuous, int *atomic); +OMPI_DECLSPEC int MPI_T_pvar_get_index (const char *name, int *pvar_index); OMPI_DECLSPEC int MPI_T_pvar_session_create(MPI_T_pvar_session *session); OMPI_DECLSPEC int MPI_T_pvar_session_free(MPI_T_pvar_session *session); OMPI_DECLSPEC int MPI_T_pvar_handle_alloc(MPI_T_pvar_session session, int pvar_index, diff --git a/ompi/mpi/tool/Makefile.am b/ompi/mpi/tool/Makefile.am index 79b50f5002..4f6741d711 100644 --- a/ompi/mpi/tool/Makefile.am +++ b/ompi/mpi/tool/Makefile.am @@ -4,7 +4,7 @@ # reserved. # Copyright (c) 2004-2006 High Performance Computing Center Stuttgart, # University of Stuttgart. All rights reserved. -# Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights +# Copyright (c) 2012-2014 Los Alamos National Security, LLC. All rights # reserved. # $COPYRIGHT$ # @@ -37,7 +37,8 @@ libmpi_mpit_la_SOURCES = init_thread.c finalize.c cvar_get_num.c \ pvar_handle_free.c pvar_read.c pvar_readreset.c \ pvar_reset.c pvar_session_create.c pvar_session_free.c \ pvar_start.c pvar_stop.c pvar_write.c \ - enum_get_info.c enum_get_item.c + enum_get_info.c enum_get_item.c cvar_get_index.c \ + pvar_get_index.c category_get_index.c # Conditionally install the header files diff --git a/ompi/mpi/tool/category_get_index.c b/ompi/mpi/tool/category_get_index.c new file mode 100644 index 0000000000..3fab242d71 --- /dev/null +++ b/ompi/mpi/tool/category_get_index.c @@ -0,0 +1,41 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2014 Los Alamos National Security, LLC. All rights + * reserved. + * Copyright (c) 2014 Cisco Systems, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi/mpi/tool/mpit-internal.h" + +#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES +#pragma weak MPI_T_category_get_index = PMPI_T_category_get_index +#endif + +#if OMPI_PROFILING_DEFINES +#include "ompi/mpi/tool/profile/defines.h" +#endif + + +int MPI_T_category_get_index (const char *name, int *category_index) +{ + int ret; + + if (!mpit_is_initialized ()) { + return MPI_T_ERR_NOT_INITIALIZED; + } + + if (MPI_PARAM_CHECK && (NULL == category_index || NULL == name)) { + return MPI_ERR_ARG; + } + + mpit_lock (); + ret = mca_base_var_group_find_by_name (name, category_index); + mpit_unlock (); + + return ompit_opal_to_mpit_error (ret); +} diff --git a/ompi/mpi/tool/cvar_get_index.c b/ompi/mpi/tool/cvar_get_index.c new file mode 100644 index 0000000000..7ac919b0ac --- /dev/null +++ b/ompi/mpi/tool/cvar_get_index.c @@ -0,0 +1,41 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2014 Los Alamos National Security, LLC. All rights + * reserved. + * Copyright (c) 2014 Cisco Systems, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi/mpi/tool/mpit-internal.h" + +#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES +#pragma weak MPI_T_cvar_get_index = PMPI_T_cvar_get_index +#endif + +#if OMPI_PROFILING_DEFINES +#include "ompi/mpi/tool/profile/defines.h" +#endif + + +int MPI_T_cvar_get_index (const char *name, int *cvar_index) +{ + int ret; + + if (!mpit_is_initialized ()) { + return MPI_T_ERR_NOT_INITIALIZED; + } + + if (MPI_PARAM_CHECK && (NULL == cvar_index || NULL == name)) { + return MPI_ERR_ARG; + } + + mpit_lock (); + ret = mca_base_var_find_by_name (name, cvar_index); + mpit_unlock (); + + return ompit_opal_to_mpit_error (ret); +} diff --git a/ompi/mpi/tool/profile/Makefile.am b/ompi/mpi/tool/profile/Makefile.am index ff2957cf43..7d431f5b03 100644 --- a/ompi/mpi/tool/profile/Makefile.am +++ b/ompi/mpi/tool/profile/Makefile.am @@ -48,9 +48,11 @@ nodist_libmpi_pmpit_la_SOURCES = \ pcategory_get_categories.c \ pcategory_get_cvars.c \ pcategory_get_info.c \ + pcategory_get_index.c \ pcategory_get_num.c \ pcategory_get_pvars.c \ pcvar_get_info.c \ + pcvar_get_index.c \ pcvar_get_num.c \ pcvar_handle_alloc.c \ pcvar_handle_free.c \ @@ -61,6 +63,7 @@ nodist_libmpi_pmpit_la_SOURCES = \ pfinalize.c \ pinit_thread.c \ ppvar_get_info.c \ + ppvar_get_index.c \ ppvar_get_num.c \ ppvar_handle_alloc.c \ ppvar_handle_free.c \ diff --git a/ompi/mpi/tool/profile/defines.h b/ompi/mpi/tool/profile/defines.h index afabc15146..ae6dd4d7f4 100644 --- a/ompi/mpi/tool/profile/defines.h +++ b/ompi/mpi/tool/profile/defines.h @@ -33,9 +33,11 @@ #define MPI_T_category_get_categories PMPI_T_category_get_categories #define MPI_T_category_get_cvars PMPI_T_category_get_cvars #define MPI_T_category_get_info PMPI_T_category_get_info +#define MPI_T_category_get_index PMPI_T_category_get_index #define MPI_T_category_get_num PMPI_T_category_get_num #define MPI_T_category_get_pvars PMPI_T_category_get_pvars #define MPI_T_cvar_get_info PMPI_T_cvar_get_info +#define MPI_T_cvar_get_index PMPI_T_cvar_get_index #define MPI_T_cvar_get_num PMPI_T_cvar_get_num #define MPI_T_cvar_handle_alloc PMPI_T_cvar_handle_alloc #define MPI_T_cvar_handle_free PMPI_T_cvar_handle_free @@ -46,6 +48,7 @@ #define MPI_T_finalize PMPI_T_finalize #define MPI_T_init_thread PMPI_T_init_thread #define MPI_T_pvar_get_info PMPI_T_pvar_get_info +#define MPI_T_pvar_get_index PMPI_T_pvar_get_index #define MPI_T_pvar_get_num PMPI_T_pvar_get_num #define MPI_T_pvar_handle_alloc PMPI_T_pvar_handle_alloc #define MPI_T_pvar_handle_free PMPI_T_pvar_handle_free diff --git a/ompi/mpi/tool/pvar_get_index.c b/ompi/mpi/tool/pvar_get_index.c new file mode 100644 index 0000000000..03d15da91a --- /dev/null +++ b/ompi/mpi/tool/pvar_get_index.c @@ -0,0 +1,41 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2014 Los Alamos National Security, LLC. All rights + * reserved. + * Copyright (c) 2014 Cisco Systems, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi/mpi/tool/mpit-internal.h" + +#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES +#pragma weak MPI_T_pvar_get_index = PMPI_T_pvar_get_index +#endif + +#if OMPI_PROFILING_DEFINES +#include "ompi/mpi/tool/profile/defines.h" +#endif + + +int MPI_T_pvar_get_index (const char *name, int *pvar_index) +{ + int ret; + + if (!mpit_is_initialized ()) { + return MPI_T_ERR_NOT_INITIALIZED; + } + + if (MPI_PARAM_CHECK && (NULL == pvar_index || NULL == name)) { + return MPI_ERR_ARG; + } + + mpit_lock (); + ret = mca_base_pvar_find_by_name (name, pvar_index); + mpit_unlock (); + + return ompit_opal_to_mpit_error (ret); +}