diff --git a/ompi/Makefile.am b/ompi/Makefile.am index e2f98fefbf..85a2cb4136 100644 --- a/ompi/Makefile.am +++ b/ompi/Makefile.am @@ -180,6 +180,7 @@ include tools/Makefile.am include mpi/Makefile.am include mpi/man/man3/Makefile.extra include mpiext/Makefile.am +include mpit/Makefile.am include patterns/net/Makefile.am include patterns/comm/Makefile.am diff --git a/ompi/include/mpi.h.in b/ompi/include/mpi.h.in index 91ca652d7c..7f4fdaf39e 100644 --- a/ompi/include/mpi.h.in +++ b/ompi/include/mpi.h.in @@ -328,6 +328,10 @@ typedef struct ompi_request_t *MPI_Request; typedef struct ompi_message_t *MPI_Message; typedef struct ompi_status_public_t MPI_Status; typedef struct ompi_win_t *MPI_Win; +typedef struct mca_base_var_enum_t *MPI_T_enum; +typedef struct ompi_mpit_cvar_handle_t *MPI_T_cvar_handle; +typedef struct ompi_mpit_pvar_handle_t *MPI_T_pvar_handle; +typedef struct ompi_mpit_pvar_session_t *MPI_T_pvar_session; /* * MPI_Status @@ -562,10 +566,24 @@ enum { #define MPI_ERR_UNSUPPORTED_DATAREP 51 #define MPI_ERR_UNSUPPORTED_OPERATION 52 #define MPI_ERR_WIN 53 +#define MPI_T_ERR_MEMORY 54 +#define MPI_T_ERR_NOT_INITIALIZED 55 +#define MPI_T_ERR_CANNOT_INIT 56 +#define MPI_T_ERR_INVALID_INDEX 57 +#define MPI_T_ERR_INVALID_ITEM 58 +#define MPI_T_ERR_INVALID_HANDLE 59 +#define MPI_T_ERR_OUT_OF_HANDLES 60 +#define MPI_T_ERR_OUT_OF_SESSIONS 61 +#define MPI_T_ERR_INVALID_SESSION 62 +#define MPI_T_ERR_CVAR_SET_NOT_NOW 63 +#define MPI_T_ERR_CVAR_SET_NEVER 64 +#define MPI_T_ERR_PVAR_NO_STARTSTOP 65 +#define MPI_T_ERR_PVAR_NO_WRITE 66 +#define MPI_T_ERR_PVAR_NO_ATOMIC 67 /* Per MPI-3 p349 47, MPI_ERR_LASTCODE must be >= the last predefined MPI_ERR_ code. So just set it equal to the last code -- - MPI_ERR_WIN, in this case. */ -#define MPI_ERR_LASTCODE MPI_ERR_WIN + MPI_T_ERR_PVAR_NO_ATOMIC, in this case. */ +#define MPI_ERR_LASTCODE MPI_T_ERR_PVAR_NO_ATOMIC #define MPI_ERR_SYSRESOURCE -2 @@ -629,6 +647,66 @@ enum { MPI_COMM_TYPE_SHARED }; +/* + * MPIT Verbosity Levels + */ +enum { + MPI_T_VERBOSITY_USER_BASIC, + MPI_T_VERBOSITY_USER_DETAIL, + MPI_T_VERBOSITY_USER_ALL, + MPI_T_VERBOSITY_TUNER_BASIC, + MPI_T_VERBOSITY_TUNER_DETAIL, + MPI_T_VERBOSITY_TUNER_ALL, + MPI_T_VERBOSITY_MPIDEV_BASIC, + MPI_T_VERBOSITY_MPIDEV_DETAIL, + MPI_T_VERBOSITY_MPIDEV_ALL +}; + +/* + * MPIT Scopes + */ +enum { + MPI_T_SCOPE_CONSTANT, + MPI_T_SCOPE_READONLY, + MPI_T_SCOPE_LOCAL, + MPI_T_SCOPE_GROUP, + MPI_T_SCOPE_GROUP_EQ, + MPI_T_SCOPE_ALL, + MPI_T_SCOPE_ALL_EQ +}; + +/* + * MPIT Object Binding + */ +enum { + MPI_T_BIND_NO_OBJECT, + MPI_T_BIND_MPI_COMM, + MPI_T_BIND_MPI_DATATYPE, + MPI_T_BIND_MPI_ERRHANDLER, + MPI_T_BIND_MPI_FILE, + MPI_T_BIND_MPI_GROUP, + MPI_T_BIND_MPI_OP, + MPI_T_BIND_MPI_REQUEST, + MPI_T_BIND_MPI_WIN, + MPI_T_BIND_MPI_MESSAGE, + MPI_T_BIND_MPI_INFO +}; + +/* + * MPIT pvar classes + */ +enum { + MPI_T_PVAR_CLASS_STATE, + MPI_T_PVAR_CLASS_LEVEL, + MPI_T_PVAR_CLASS_SIZE, + MPI_T_PVAR_CLASS_PERCENTAGE, + MPI_T_PVAR_CLASS_HIGHWATERMARK, + MPI_T_PVAR_CLASS_LOWWATERMARK, + MPI_T_PVAR_CLASS_COUNTER, + MPI_T_PVAR_CLASS_AGGREGATE, + MPI_T_PVAR_CLASS_TIMER, + MPI_T_PVAR_CLASS_GENERIC +}; /* * NULL handles @@ -644,6 +722,7 @@ enum { #if OMPI_PROVIDE_MPI_FILE_INTERFACE #define MPI_FILE_NULL OMPI_PREDEFINED_GLOBAL(MPI_File, ompi_mpi_file_null) #endif +#define MPI_T_ENUM_NULL NULL /* * MPI_INFO_ENV handle @@ -2224,6 +2303,53 @@ OMPI_DECLSPEC int PMPI_Win_wait(MPI_Win win); OMPI_DECLSPEC double PMPI_Wtick(void); OMPI_DECLSPEC double PMPI_Wtime(void); + /* + * Tool MPI API + */ +OMPI_DECLSPEC int MPI_T_init_thread (int required, int *provided); +OMPI_DECLSPEC int MPI_T_finalize (void); +OMPI_DECLSPEC int MPI_T_cvar_get_num (int *num_cvar); +OMPI_DECLSPEC int MPI_T_cvar_get_info (int cvar_index, char *name, int *name_len, + int *verbosity, MPI_Datatype *datatype, + MPI_T_enum *enumtype, char *desc, + int *desc_len, int *bind, int *scope); +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); +OMPI_DECLSPEC int MPI_T_cvar_read (MPI_T_cvar_handle handle, void *buf); +OMPI_DECLSPEC int MPI_T_cvar_write (MPI_T_cvar_handle handle, const void *buf); +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_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[]); +OMPI_DECLSPEC int MPI_T_category_changed(int *stamp); + +OMPI_DECLSPEC int MPI_T_pvar_get_num(int *num_pvar); +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_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, + void *obj_handle, MPI_T_pvar_handle *handle, int *count); +OMPI_DECLSPEC int MPI_T_pvar_handle_free(MPI_T_pvar_session session, MPI_T_pvar_handle *handle); +OMPI_DECLSPEC int MPI_T_pvar_start(MPI_T_pvar_session session, MPI_T_pvar_handle handle); +OMPI_DECLSPEC int MPI_T_pvar_stop(MPI_T_pvar_session session, MPI_T_pvar_handle handle); +OMPI_DECLSPEC int MPI_T_pvar_read(MPI_T_pvar_session session, MPI_T_pvar_handle handle, + void *buf); +OMPI_DECLSPEC int MPI_T_pvar_write(MPI_T_pvar_session session, MPI_T_pvar_handle handle, + const void *buf); +OMPI_DECLSPEC int MPI_T_pvar_reset(MPI_T_pvar_session session, MPI_T_pvar_handle handle); +OMPI_DECLSPEC int MPI_T_pvar_readreset(MPI_T_pvar_session session, MPI_T_pvar_handle handle, + void *buf); +OMPI_DECLSPEC int MPI_T_enum_get_info(MPI_T_enum enumtype, int *num, char *name, int *name_len); +OMPI_DECLSPEC int MPI_T_enum_get_item(MPI_T_enum enumtype, int index, int *value, char *name, + int *name_len); + #if defined(c_plusplus) || defined(__cplusplus) } #endif diff --git a/ompi/include/mpif-values.pl b/ompi/include/mpif-values.pl index 6f5e94e5ab..2c99def8f2 100755 --- a/ompi/include/mpif-values.pl +++ b/ompi/include/mpif-values.pl @@ -299,7 +299,23 @@ $constants->{MPI_ERR_SPAWN} = 50; $constants->{MPI_ERR_UNSUPPORTED_DATAREP} = 51; $constants->{MPI_ERR_UNSUPPORTED_OPERATION} = 52; $constants->{MPI_ERR_WIN} = 53; -$constants->{MPI_ERR_LASTCODE} = $constants->{MPI_ERR_WIN}; +# these error codes will never be returned by a fortran function +# since there are no fortran bindings for MPI_T +$constants->{MPI_T_ERR_MEMORY} = 54; +$constants->{MPI_T_ERR_NOT_INITIALIZED} = 55; +$constants->{MPI_T_ERR_CANNOT_INIT} = 56; +$constants->{MPI_T_ERR_INVALID_INDEX} = 57; +$constants->{MPI_T_ERR_INVALID_ITEM} = 58; +$constants->{MPI_T_ERR_INVALID_HANDLE} = 59; +$constants->{MPI_T_ERR_OUT_OF_HANDLES} = 60; +$constants->{MPI_T_ERR_OUT_OF_SESSIONS} = 61; +$constants->{MPI_T_ERR_INVALID_SESSION} = 62; +$constants->{MPI_T_ERR_CVAR_SET_NOT_NOW} = 63; +$constants->{MPI_T_ERR_CVAR_SET_NEVER} = 64; +$constants->{MPI_T_ERR_PVAR_NO_STARTSTOP} = 65; +$constants->{MPI_T_ERR_PVAR_NO_WRITE} = 66; +$constants->{MPI_T_ERR_PVAR_NO_ATOMIC} = 67; +$constants->{MPI_ERR_LASTCODE} = $constants->{MPI_T_ERR_PVAR_NO_ATOMIC}; $constants->{MPI_ERR_SYSRESOURCE} = -2; diff --git a/ompi/mpit/Makefile.am b/ompi/mpit/Makefile.am new file mode 100644 index 0000000000..305083ee33 --- /dev/null +++ b/ompi/mpit/Makefile.am @@ -0,0 +1,31 @@ +# -*- makefile -*- +# +# Copyright (c) 2004-2006 The University of Tennessee and The University +# of Tennessee Research Foundation. All rights +# 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 +# reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +# This Makefile.am does not stand on its own - it is included from ompi/Makefile.am + +headers += mpit/mpit-internal.h + +libmpi_la_SOURCES += mpit/init_thread.c mpit/finalize.c mpit/cvar_get_num.c \ + mpit/cvar_get_info.c mpit/cvar_read.c mpit/cvar_write.c \ + mpit/cvar_handle_alloc.c mpit/cvar_handle_free.c \ + mpit/catagory_get_num.c mpit/catagory_get_info.c \ + mpit/catagory_get_cvars.c mpit/catagory_get_pvars.c \ + mpit/catagory_get_catagories.c mpit/catagory_changed.c \ + mpit/pvar_get_info.c mpit/pvar_get_num.c mpit/pvar_handle_alloc.c \ + mpit/pvar_handle_free.c mpit/pvar_read.c mpit/pvar_readreset.c \ + mpit/pvar_reset.c mpit/pvar_session_create.c mpit/pvar_session_free.c \ + mpit/pvar_start.c mpit/pvar_stop.c mpit/pvar_write.c \ + mpit/enum_get_info.c mpit/enum_get_item.c diff --git a/ompi/mpit/catagory_changed.c b/ompi/mpit/catagory_changed.c new file mode 100644 index 0000000000..3e9bb213de --- /dev/null +++ b/ompi/mpit/catagory_changed.c @@ -0,0 +1,27 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi/mpit/mpit-internal.h" + +static const char FUNC_NAME[] = "MPI_T_category_changed"; + +int MPI_T_category_changed(int *stamp) +{ + if (!mpit_is_initialized ()) { + return MPI_T_ERR_NOT_INITIALIZED; + } + + mpit_lock (); + *stamp = mca_base_var_group_get_stamp (); + mpit_unlock (); + + return MPI_SUCCESS; +} diff --git a/ompi/mpit/catagory_get_catagories.c b/ompi/mpit/catagory_get_catagories.c new file mode 100644 index 0000000000..a88f9b16f5 --- /dev/null +++ b/ompi/mpit/catagory_get_catagories.c @@ -0,0 +1,47 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi/mpit/mpit-internal.h" + +static const char FUNC_NAME[] = "MPI_T_category_get_categories"; + +int MPI_T_category_get_categories(int cat_index, int len, int indices[]) +{ + const mca_base_var_group_t *group; + const int *subgroups; + int rc = MPI_SUCCESS; + int i, size; + + if (!mpit_is_initialized ()) { + return MPI_T_ERR_NOT_INITIALIZED; + } + + mpit_lock (); + + do { + rc = mca_base_var_group_get (cat_index, &group); + if (0 > rc) { + rc = (OPAL_ERR_NOT_FOUND == rc) ? MPI_T_ERR_INVALID_INDEX : MPI_ERR_OTHER; + break; + } + + size = opal_value_array_get_size((opal_value_array_t *) &group->group_subgroups); + subgroups = OPAL_VALUE_ARRAY_GET_BASE(&group->group_subgroups, int); + + for (i = 0 ; i < len && i < size ; ++i) { + indices[i] = subgroups[i]; + } + } while (0); + + mpit_unlock (); + + return rc; +} diff --git a/ompi/mpit/catagory_get_cvars.c b/ompi/mpit/catagory_get_cvars.c new file mode 100644 index 0000000000..76b7f064b8 --- /dev/null +++ b/ompi/mpit/catagory_get_cvars.c @@ -0,0 +1,47 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi/mpit/mpit-internal.h" + +static const char FUNC_NAME[] = "MPI_T_category_get_cvars"; + +int MPI_T_category_get_cvars(int cat_index, int len, int indices[]) +{ + const mca_base_var_group_t *group; + int rc = MPI_SUCCESS; + const int *vars; + int i, size; + + if (!mpit_is_initialized ()) { + return MPI_T_ERR_NOT_INITIALIZED; + } + + mpit_lock (); + + do { + rc = mca_base_var_group_get (cat_index, &group); + if (0 > rc) { + rc = (OPAL_ERR_NOT_FOUND == rc) ? MPI_T_ERR_INVALID_INDEX : MPI_ERR_OTHER; + break; + } + + size = opal_value_array_get_size((opal_value_array_t *) &group->group_vars); + vars = OPAL_VALUE_ARRAY_GET_BASE(&group->group_vars, int); + + for (i = 0 ; i < len && i < size ; ++i) { + indices[i] = vars[i]; + } + } while (0); + + mpit_unlock (); + + return rc; +} diff --git a/ompi/mpit/catagory_get_info.c b/ompi/mpit/catagory_get_info.c new file mode 100644 index 0000000000..3538b2c617 --- /dev/null +++ b/ompi/mpit/catagory_get_info.c @@ -0,0 +1,56 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi/mpit/mpit-internal.h" + +static const char FUNC_NAME[] = "MPI_T_category_get_info"; + +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) +{ + const mca_base_var_group_t *group; + int rc = MPI_SUCCESS; + + if (!mpit_is_initialized ()) { + return MPI_T_ERR_NOT_INITIALIZED; + } + + mpit_lock (); + + do { + rc = mca_base_var_group_get (cat_index, &group); + if (0 > rc) { + rc = (OPAL_ERR_NOT_FOUND == rc) ? MPI_T_ERR_INVALID_INDEX : MPI_ERR_OTHER; + break; + } + + /* XXX -- TODO -- Implement me */ + if (NULL != num_pvars) { + *num_pvars = 0; + } + + if (NULL != num_cvars) { + *num_cvars = opal_value_array_get_size ((opal_value_array_t *) &group->group_vars); + } + + if (NULL != num_categories) { + *num_categories = opal_value_array_get_size ((opal_value_array_t *) &group->group_subgroups); + } + + mpit_copy_string (name, name_len, group->group_full_name); + mpit_copy_string (desc, desc_len, group->group_description); + } while (0); + + mpit_unlock (); + + return rc; +} diff --git a/ompi/mpit/catagory_get_num.c b/ompi/mpit/catagory_get_num.c new file mode 100644 index 0000000000..cbc86dec72 --- /dev/null +++ b/ompi/mpit/catagory_get_num.c @@ -0,0 +1,31 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi/mpit/mpit-internal.h" + +static const char FUNC_NAME[] = "MPI_T_catagory_get_num"; + +int MPI_T_category_get_num (int *num_cat) +{ + if (!mpit_is_initialized ()) { + return MPI_T_ERR_NOT_INITIALIZED; + } + + if (MPI_PARAM_CHECK && NULL == num_cat) { + return MPI_ERR_ARG; + } + + mpit_lock (); + *num_cat = mca_base_var_group_get_count (); + mpit_unlock (); + + return MPI_SUCCESS; +} diff --git a/ompi/mpit/catagory_get_pvars.c b/ompi/mpit/catagory_get_pvars.c new file mode 100644 index 0000000000..4076d99942 --- /dev/null +++ b/ompi/mpit/catagory_get_pvars.c @@ -0,0 +1,24 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-213 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi/mpit/mpit-internal.h" + +static const char FUNC_NAME[] = "MPI_T_category_get_pvars"; + +int MPI_T_category_get_pvars(int cat_index, int len, int indices[]) +{ + if (!mpit_is_initialized ()) { + return MPI_T_ERR_NOT_INITIALIZED; + } + /* XXX -- TODO -- add pvar support */ + + return MPI_ERR_UNSUPPORTED_OPERATION; +} diff --git a/ompi/mpit/cvar_get_info.c b/ompi/mpit/cvar_get_info.c new file mode 100644 index 0000000000..27f74534ef --- /dev/null +++ b/ompi/mpit/cvar_get_info.c @@ -0,0 +1,85 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi/mpit/mpit-internal.h" + +static const char FUNC_NAME[] = "MPI_T_cvar_get_info"; + +int MPI_T_cvar_get_info(int cvar_index, char *name, int *name_len, int *verbosity, + MPI_Datatype *datatype, MPI_T_enum *enumtype, char *desc, + int *desc_len, int *bind, int *scope) +{ + const mca_base_var_t *var; + int rc = MPI_SUCCESS; + + if (!mpit_is_initialized ()) { + return MPI_T_ERR_NOT_INITIALIZED; + } + + mpit_lock (); + + do { + rc = mca_base_var_get (cvar_index, &var); + if (OPAL_SUCCESS != rc) { + rc = (OPAL_ERR_VALUE_OUT_OF_BOUNDS == rc) ? MPI_T_ERR_INVALID_INDEX : + MPI_ERR_OTHER; + break; + } + + mpit_copy_string (name, name_len, var->mbv_full_name); + mpit_copy_string (desc, desc_len, var->mbv_description); + + /* find the corresponding mpi type for an mca type */ + switch (var->mbv_type) { + case MCA_BASE_VAR_TYPE_INT: + case MCA_BASE_VAR_TYPE_BOOL: + *datatype = MPI_INT; + break; + case MCA_BASE_VAR_TYPE_UNSIGNED_INT: + *datatype = MPI_UNSIGNED; + break; + case MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG: + *datatype = MPI_UNSIGNED_LONG_LONG; + break; + case MCA_BASE_VAR_TYPE_SIZE_T: + if (sizeof(size_t) == sizeof (unsigned long long)) { + *datatype = MPI_UNSIGNED_LONG_LONG; + } else { + *datatype = MPI_UNSIGNED; + } + case MCA_BASE_VAR_TYPE_STRING: + *datatype = MPI_CHAR; + break; + default: + /* Internal error! Did the MCA variable system change? */ + assert (0); + mpit_unlock (); + return MPI_ERR_OTHER; + } + + if (NULL != enumtype) { + *enumtype = var->mbv_enumerator ? (MPI_T_enum) var->mbv_enumerator : MPI_T_ENUM_NULL; + } + + if (NULL != scope) { + *scope = var->mbv_scope; + } + + /* XXX -- TODO -- All bindings are currently 0. Add support for variable binding. */ + if (NULL != bind) { + *bind = var->mbv_bind; + } + } while (0); + + mpit_unlock (); + + return rc; +} diff --git a/ompi/mpit/cvar_get_num.c b/ompi/mpit/cvar_get_num.c new file mode 100644 index 0000000000..12ffc697de --- /dev/null +++ b/ompi/mpit/cvar_get_num.c @@ -0,0 +1,30 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi/mpit/mpit-internal.h" + +static const char FUNC_NAME[] = "MPI_T_cvar_get_num"; + +int MPI_T_cvar_get_num (int *num_cvar) { + if (!mpit_is_initialized ()) { + return MPI_T_ERR_NOT_INITIALIZED; + } + + if (MPI_PARAM_CHECK && NULL == num_cvar) { + return MPI_ERR_ARG; + } + + mpit_lock (); + *num_cvar = mca_base_var_group_get_count(); + mpit_unlock (); + + return MPI_SUCCESS; +} diff --git a/ompi/mpit/cvar_handle_alloc.c b/ompi/mpit/cvar_handle_alloc.c new file mode 100644 index 0000000000..201696ea55 --- /dev/null +++ b/ompi/mpit/cvar_handle_alloc.c @@ -0,0 +1,66 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi/mpit/mpit-internal.h" + +static const char FUNC_NAME[] = "MPI_T_cvar_handle_alloc"; + +int MPI_T_cvar_handle_alloc (int cvar_index, void *obj_handle, + MPI_T_cvar_handle *handle, int *count) +{ + ompi_mpit_cvar_handle_t *new_handle; + int rc = MPI_SUCCESS;; + + if (!mpit_is_initialized ()) { + return MPI_T_ERR_NOT_INITIALIZED; + } + + if (MPI_PARAM_CHECK && (NULL == handle || NULL == count)) { + return MPI_ERR_ARG; + } + + mpit_lock (); + + *handle = NULL; + + do { + new_handle = (ompi_mpit_cvar_handle_t *) malloc (sizeof (ompi_mpit_cvar_handle_t)); + if (NULL == new_handle) { + rc = MPI_T_ERR_MEMORY; + break; + } + + rc = mca_base_var_get(cvar_index, &new_handle->var); + if (OPAL_SUCCESS != rc) { + rc = (OPAL_ERR_VALUE_OUT_OF_BOUNDS == rc) ? MPI_T_ERR_INVALID_INDEX: + MPI_ERR_OTHER; + free (new_handle); + break; + } + + new_handle->bound_object = obj_handle; + + if (MCA_BASE_VAR_TYPE_STRING == new_handle->var->mbv_type) { + /* Arbitrary string limit. Is there a better way to do this? */ + *count = 2048; + } else { + /* MCA only supports a single integer at this time. Change me if + this assumption changes. */ + *count = 1; + } + + *handle = (MPI_T_cvar_handle) new_handle; + } while (0); + + mpit_unlock (); + + return rc; +} diff --git a/ompi/mpit/cvar_handle_free.c b/ompi/mpit/cvar_handle_free.c new file mode 100644 index 0000000000..471e018cf3 --- /dev/null +++ b/ompi/mpit/cvar_handle_free.c @@ -0,0 +1,24 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi/mpit/mpit-internal.h" + +int MPI_T_cvar_handle_free (MPI_T_cvar_handle *handle) +{ + if (!mpit_is_initialized ()) { + return MPI_T_ERR_NOT_INITIALIZED; + } + + free (*handle); + *handle = NULL; + + return MPI_SUCCESS; +} diff --git a/ompi/mpit/cvar_read.c b/ompi/mpit/cvar_read.c new file mode 100644 index 0000000000..9d42883e14 --- /dev/null +++ b/ompi/mpit/cvar_read.c @@ -0,0 +1,69 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi/mpit/mpit-internal.h" + +static const char FUNC_NAME[] = "MPI_T_cvar_read"; + +int MPI_T_cvar_read (MPI_T_cvar_handle handle, void *buf) +{ + const mca_base_var_storage_t *value; + int rc = MPI_SUCCESS; + + if (!mpit_is_initialized ()) { + return MPI_T_ERR_NOT_INITIALIZED; + } + + if (MPI_PARAM_CHECK && NULL == buf) { + return MPI_ERR_ARG; + } + + mpit_lock (); + + do { + rc = mca_base_var_get_value(handle->var->mbv_index, &value, NULL, NULL); + if (OPAL_SUCCESS != rc) { + /* shouldn't happen */ + rc = MPI_ERR_OTHER; + break; + } + + switch (handle->var->mbv_type) { + case MCA_BASE_VAR_TYPE_INT: + case MCA_BASE_VAR_TYPE_UNSIGNED_INT: + ((int *) buf)[0] = value->intval; + break; + case MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG: + ((unsigned long long *) buf)[0] = value->ullval; + break; + case MCA_BASE_VAR_TYPE_SIZE_T: + ((int *) buf)[0] = value->sizetval; + break; + case MCA_BASE_VAR_TYPE_BOOL: + ((int *) buf)[0] = value->boolval; + break; + case MCA_BASE_VAR_TYPE_STRING: + if (NULL == value->stringval) { + ((char *)buf)[0] = '\0'; + } else { + strcpy ((char *) buf, value->stringval); + } + + break; + default: + rc = MPI_ERR_OTHER; + } + } while (0); + + mpit_unlock (); + + return rc; +} diff --git a/ompi/mpit/cvar_write.c b/ompi/mpit/cvar_write.c new file mode 100644 index 0000000000..ea12756574 --- /dev/null +++ b/ompi/mpit/cvar_write.c @@ -0,0 +1,83 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi/mpit/mpit-internal.h" + +static const char FUNC_NAME[] = "MPI_T_cvar_write"; + +int MPI_T_cvar_write (MPI_T_cvar_handle handle, const void *buf) +{ + mca_base_var_storage_t value; + int rc = MPI_SUCCESS; + + if (!mpit_is_initialized ()) { + return MPI_T_ERR_NOT_INITIALIZED; + } + + if (MPI_PARAM_CHECK && NULL == buf) { + return MPI_ERR_ARG; + } + + mpit_lock (); + + do { + if (MCA_BASE_VAR_SCOPE_CONSTANT == handle->var->mbv_scope || + MCA_BASE_VAR_SCOPE_READONLY == handle->var->mbv_scope) { + rc = MPI_T_ERR_CVAR_SET_NEVER; + break; + } + + if (!(MCA_BASE_VAR_FLAG_SETTABLE & handle->var->mbv_flags)) { + rc = MPI_T_ERR_CVAR_SET_NOT_NOW; + break; + } + + switch (handle->var->mbv_type) { + case MCA_BASE_VAR_TYPE_STRING: + value.stringval = (char *) buf; + + break; + case MCA_BASE_VAR_TYPE_INT: + case MCA_BASE_VAR_TYPE_UNSIGNED_INT: + value.intval = ((int *) buf)[0]; + + break; + case MCA_BASE_VAR_TYPE_BOOL: + /* we expose boolean values as integers */ + value.boolval = !!(((int *) buf)[0]); + break; + case MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG: + value.ullval = ((unsigned long long *) buf)[0]; + break; + case MCA_BASE_VAR_TYPE_SIZE_T: + if (sizeof(size_t) == sizeof(unsigned long long)) { + value.ullval = ((unsigned long long *) buf)[0]; + } else { + value.intval = ((int *) buf)[0]; + } + break; + default: + rc = MPI_T_ERR_CVAR_SET_NEVER; + break; + } + } while (0); + + if (MPI_SUCCESS == rc) { + rc = mca_base_var_set_value(handle->var->mbv_index, &value, sizeof(value), MCA_BASE_VAR_SOURCE_SET, NULL); + if (OPAL_SUCCESS != rc) { + rc = MPI_T_ERR_CVAR_SET_NOT_NOW; + } + } + + mpit_unlock (); + + return rc; +} diff --git a/ompi/mpit/enum_get_info.c b/ompi/mpit/enum_get_info.c new file mode 100644 index 0000000000..7fe33de034 --- /dev/null +++ b/ompi/mpit/enum_get_info.c @@ -0,0 +1,41 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi/mpit/mpit-internal.h" + +static const char FUNC_NAME[] = "MPI_T_enum_get_info"; + +int MPI_T_enum_get_info(MPI_T_enum enumtype, int *num, char *name, int *name_len) +{ + int rc; + + if (!mpit_is_initialized ()) { + return MPI_T_ERR_NOT_INITIALIZED; + } + + mpit_lock (); + + do { + if (num) { + rc = enumtype->get_count (enumtype, num); + if (OPAL_SUCCESS != rc) { + rc = MPI_ERR_OTHER; + break; + } + } + + mpit_copy_string (name, name_len, enumtype->enum_name); + } while (0); + + mpit_unlock (); + + return rc; +} diff --git a/ompi/mpit/enum_get_item.c b/ompi/mpit/enum_get_item.c new file mode 100644 index 0000000000..6165dd00cd --- /dev/null +++ b/ompi/mpit/enum_get_item.c @@ -0,0 +1,52 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi/mpit/mpit-internal.h" + +static const char FUNC_NAME[] = "MPI_T_enum_get_item"; + +int MPI_T_enum_get_item(MPI_T_enum enumtype, int index, int *value, char *name, + int *name_len) +{ + const char *tmp; + int rc, count; + + if (!mpit_is_initialized ()) { + return MPI_T_ERR_NOT_INITIALIZED; + } + + mpit_lock (); + + do { + rc = enumtype->get_count (enumtype, &count); + if (OPAL_SUCCESS != rc) { + rc = MPI_ERR_OTHER; + break; + } + + if (index >= count) { + rc = MPI_T_ERR_INVALID_INDEX; + break; + } + + rc = enumtype->get_value(enumtype, index, value, &tmp); + if (OPAL_SUCCESS != rc) { + rc = MPI_ERR_OTHER; + break; + } + + mpit_copy_string(name, name_len, tmp); + } while (0); + + mpit_unlock (); + + return rc; +} diff --git a/ompi/mpit/finalize.c b/ompi/mpit/finalize.c new file mode 100644 index 0000000000..d7a119e1d8 --- /dev/null +++ b/ompi/mpit/finalize.c @@ -0,0 +1,36 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + + +#include "ompi/mpit/mpit-internal.h" + +#include "opal/include/opal/sys/atomic.h" +#include "opal/runtime/opal.h" + +static const char FUNC_NAME[] = "MPI_T_finalize"; + +int MPI_T_finalize (void) +{ + mpit_lock (); + + if (!mpit_is_initialized ()) { + mpit_unlock (); + return MPI_T_ERR_NOT_INITIALIZED; + } + + if (0 == --mpit_init_count) { + (void) opal_finalize_util (); + } + + mpit_unlock (); + + return MPI_SUCCESS; +} diff --git a/ompi/mpit/init_thread.c b/ompi/mpit/init_thread.c new file mode 100644 index 0000000000..cf300ba967 --- /dev/null +++ b/ompi/mpit/init_thread.c @@ -0,0 +1,82 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + + +#include "ompi/mpit/mpit-internal.h" + +#include + +#include "ompi/runtime/ompi_info_support.h" +#include "opal/include/opal/sys/atomic.h" +#include "opal/runtime/opal.h" + +static const char FUNC_NAME[] = "MPI_T_init_thread"; + +opal_mutex_t mpit_big_lock; + +volatile uint32_t mpit_init_count = 0; +static volatile int32_t initted = 0; + +void mpit_lock (void) +{ + if (initted) { + opal_mutex_lock (&mpit_big_lock); + } +} + +void mpit_unlock (void) +{ + if (initted) { + opal_mutex_unlock (&mpit_big_lock); + } +} + +int MPI_T_init_thread (int required, int *provided) +{ + static volatile int32_t first_init = 1; + int rc = MPI_SUCCESS; + + if (opal_atomic_cmpset (&first_init, 1, 0) == 1) { + OBJ_CONSTRUCT(&mpit_big_lock, opal_mutex_t); + initted = 1; + } + + while (!initted) { + sched_yield (); + usleep (1000); + } + + mpit_lock (); + + do { + if (0 != mpit_init_count++) { + break; + } + + /* call opal_init_util to intialize the MCA system */ + rc = opal_init_util (NULL, NULL); + if (OPAL_SUCCESS != rc) { + rc = MPI_ERR_OTHER; + break; + } + + rc = ompi_info_register_framework_params (NULL); + if (OMPI_SUCCESS != rc) { + rc = MPI_ERR_OTHER; + break; + } + ompi_mpi_thread_level (required, provided); + } while (0); + + mpit_unlock (); + + return rc; +} diff --git a/ompi/mpit/mpit-internal.h b/ompi/mpit/mpit-internal.h new file mode 100644 index 0000000000..f10c15891c --- /dev/null +++ b/ompi/mpit/mpit-internal.h @@ -0,0 +1,78 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2011-2012 Los Alamos National Security, LLC. All rights + * reserved. + * Copyright (c) 2011 UT-Battelle, LLC. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#if !defined(MPIT_INTERNAL_H) +#define MPIT_INTERNAL_H + +#include "ompi/include/ompi_config.h" +#include "opal/mca/base/mca_base_var.h" +#include "ompi/runtime/params.h" +#include "ompi/communicator/communicator.h" +#include "ompi/constants.h" + +#include "mpi.h" + +#include + +#define MPI_T_ENUM_NULL NULL + +typedef struct ompi_mpit_cvar_handle_t { + const mca_base_var_t *var; + /* XXX -- TODO -- allow binding objects */ + void *bound_object; +} ompi_mpit_cvar_handle_t; + +typedef struct ompi_mpi_pvar_handle_t { + int dummy; +} ompi_mpi_pvar_handle_t; + +typedef struct ompi_mpi_pvar_session_t { + int dummy; +} ompi_mpi_pvar_session_t; + +typedef struct ompi_mpit_enum_t { + mca_base_var_enum_t *enumerator; +} ompi_mpit_enum_t; + +void mpit_lock (void); +void mpit_unlock (void); + +extern volatile uint32_t mpit_init_count; + +static inline int mpit_is_initialized (void) +{ + return !!mpit_init_count; +} + +static inline void mpit_copy_string (char *dest, int *len, const char *source) +{ + if (NULL == len) + return; + + if (NULL == source) { + *len = 0; + if (NULL != dest) { + dest[0] = '\0'; + } + + return; + } + + if ((int) strlen (source) < *len) { + *len = strlen (source) + 1; + } + + strncpy (dest, source, *len); + dest[*len - 1] = '\0'; +} + +#endif /* !defined(MPIT_INTERNAL_H) */ diff --git a/ompi/mpit/pvar_get_info.c b/ompi/mpit/pvar_get_info.c new file mode 100644 index 0000000000..01f72d4f66 --- /dev/null +++ b/ompi/mpit/pvar_get_info.c @@ -0,0 +1,27 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi/mpit/mpit-internal.h" + +static const char FUNC_NAME[] = "MPI_T_pvar_get_info"; + +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) +{ + if (!mpit_is_initialized ()) { + return MPI_T_ERR_NOT_INITIALIZED; + } + + /* XXX -- TODO -- Implement me */ + return MPI_T_ERR_INVALID_INDEX; +} diff --git a/ompi/mpit/pvar_get_num.c b/ompi/mpit/pvar_get_num.c new file mode 100644 index 0000000000..1087473bfa --- /dev/null +++ b/ompi/mpit/pvar_get_num.c @@ -0,0 +1,31 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi/mpit/mpit-internal.h" + +static const char FUNC_NAME[] = "MPI_T_pvar_get_num"; + +int MPI_T_pvar_get_num(int *num_pvar) +{ + if (!mpit_is_initialized ()) { + return MPI_T_ERR_NOT_INITIALIZED; + } + + if (MPI_PARAM_CHECK && NULL == num_pvar) { + return MPI_ERR_ARG; + } + + /* XXX -- TODO -- Add pvars */ + *num_pvar = 0; + + return MPI_SUCCESS; +} + diff --git a/ompi/mpit/pvar_handle_alloc.c b/ompi/mpit/pvar_handle_alloc.c new file mode 100644 index 0000000000..f22ab479ae --- /dev/null +++ b/ompi/mpit/pvar_handle_alloc.c @@ -0,0 +1,25 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi/mpit/mpit-internal.h" + +static const char FUNC_NAME[] = "MPI_T_pvar_handle_alloc"; + +int MPI_T_pvar_handle_alloc(MPI_T_pvar_session session, int pvar_index, + void *obj_handle, MPI_T_pvar_handle *handle, int *count) +{ + if (!mpit_is_initialized ()) { + return MPI_T_ERR_NOT_INITIALIZED; + } + + /* XXX -- TODO -- Implement me */ + return MPI_T_ERR_INVALID_INDEX; +} diff --git a/ompi/mpit/pvar_handle_free.c b/ompi/mpit/pvar_handle_free.c new file mode 100644 index 0000000000..bee1ca3fd3 --- /dev/null +++ b/ompi/mpit/pvar_handle_free.c @@ -0,0 +1,24 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi/mpit/mpit-internal.h" + +static const char FUNC_NAME[] = "MPI_T_pvar_handle_free"; + +int MPI_T_pvar_handle_free(MPI_T_pvar_session session, MPI_T_pvar_handle *handle) +{ + if (!mpit_is_initialized ()) { + return MPI_T_ERR_NOT_INITIALIZED; + } + + /* XXX -- TODO -- Implement me */ + return MPI_T_ERR_INVALID_INDEX; +} diff --git a/ompi/mpit/pvar_read.c b/ompi/mpit/pvar_read.c new file mode 100644 index 0000000000..d80848dc59 --- /dev/null +++ b/ompi/mpit/pvar_read.c @@ -0,0 +1,25 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi/mpit/mpit-internal.h" + +static const char FUNC_NAME[] = "MPI_T_pvar_read"; + +int MPI_T_pvar_read(MPI_T_pvar_session session, MPI_T_pvar_handle handle, + void* buf) +{ + if (!mpit_is_initialized ()) { + return MPI_T_ERR_NOT_INITIALIZED; + } + + /* XXX -- TODO -- Implement me */ + return MPI_T_ERR_INVALID_HANDLE; +} diff --git a/ompi/mpit/pvar_readreset.c b/ompi/mpit/pvar_readreset.c new file mode 100644 index 0000000000..9bd8b8e5f9 --- /dev/null +++ b/ompi/mpit/pvar_readreset.c @@ -0,0 +1,25 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi/mpit/mpit-internal.h" + +static const char FUNC_NAME[] = "MPI_T_pvar_readreset"; + +int MPI_T_pvar_readreset(MPI_T_pvar_session session, MPI_T_pvar_handle handle, + void *buf) +{ + if (!mpit_is_initialized ()) { + return MPI_T_ERR_NOT_INITIALIZED; + } + + /* XXX -- TODO -- Implement me */ + return MPI_T_ERR_INVALID_HANDLE; +} diff --git a/ompi/mpit/pvar_reset.c b/ompi/mpit/pvar_reset.c new file mode 100644 index 0000000000..2d2873730e --- /dev/null +++ b/ompi/mpit/pvar_reset.c @@ -0,0 +1,24 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi/mpit/mpit-internal.h" + +static const char FUNC_NAME[] = "MPI_T_pvar_reset"; + +int MPI_T_pvar_reset(MPI_T_pvar_session session, MPI_T_pvar_handle handle) +{ + if (!mpit_is_initialized ()) { + return MPI_T_ERR_NOT_INITIALIZED; + } + + /* XXX -- TODO -- Implement me */ + return MPI_T_ERR_INVALID_HANDLE; +} diff --git a/ompi/mpit/pvar_session_create.c b/ompi/mpit/pvar_session_create.c new file mode 100644 index 0000000000..8fc3836bfa --- /dev/null +++ b/ompi/mpit/pvar_session_create.c @@ -0,0 +1,24 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi/mpit/mpit-internal.h" + +static const char FUNC_NAME[] = "MPI_T_pvar_session_create"; + +int MPI_T_pvar_session_create(MPI_T_pvar_session *session) +{ + if (!mpit_is_initialized ()) { + return MPI_T_ERR_NOT_INITIALIZED; + } + + /* XXX -- TODO -- Implement me */ + return MPI_ERR_OTHER; +} diff --git a/ompi/mpit/pvar_session_free.c b/ompi/mpit/pvar_session_free.c new file mode 100644 index 0000000000..31ce8772fd --- /dev/null +++ b/ompi/mpit/pvar_session_free.c @@ -0,0 +1,24 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi/mpit/mpit-internal.h" + +static const char FUNC_NAME[] = "MPI_T_pvar_session_free"; + +int MPI_T_pvar_session_free(MPI_T_pvar_session *session) +{ + if (!mpit_is_initialized ()) { + return MPI_T_ERR_NOT_INITIALIZED; + } + + /* XXX -- TODO -- Implement me */ + return MPI_ERR_OTHER; +} diff --git a/ompi/mpit/pvar_start.c b/ompi/mpit/pvar_start.c new file mode 100644 index 0000000000..35ddab09ff --- /dev/null +++ b/ompi/mpit/pvar_start.c @@ -0,0 +1,24 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi/mpit/mpit-internal.h" + +static const char FUNC_NAME[] = "MPI_T_pvar_start"; + +int MPI_T_pvar_start(MPI_T_pvar_session session, MPI_T_pvar_handle handle) +{ + if (!mpit_is_initialized ()) { + return MPI_T_ERR_NOT_INITIALIZED; + } + + /* XXX -- TODO -- Implement me */ + return MPI_T_ERR_INVALID_HANDLE; +} diff --git a/ompi/mpit/pvar_stop.c b/ompi/mpit/pvar_stop.c new file mode 100644 index 0000000000..010f2882b2 --- /dev/null +++ b/ompi/mpit/pvar_stop.c @@ -0,0 +1,24 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi/mpit/mpit-internal.h" + +static const char FUNC_NAME[] = "MPI_T_pvar_stop"; + +int MPI_T_pvar_stop(MPI_T_pvar_session session, MPI_T_pvar_handle handle) +{ + if (!mpit_is_initialized ()) { + return MPI_T_ERR_NOT_INITIALIZED; + } + + /* XXX -- TODO -- Implement me */ + return MPI_T_ERR_INVALID_HANDLE; +} diff --git a/ompi/mpit/pvar_write.c b/ompi/mpit/pvar_write.c new file mode 100644 index 0000000000..ac1450b641 --- /dev/null +++ b/ompi/mpit/pvar_write.c @@ -0,0 +1,25 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi/mpit/mpit-internal.h" + +static const char FUNC_NAME[] = "MPI_T_pvar_write"; + +int MPI_T_pvar_write(MPI_T_pvar_session session, MPI_T_pvar_handle handle, + const void* buf) +{ + if (!mpit_is_initialized ()) { + return MPI_T_ERR_NOT_INITIALIZED; + } + + /* XXX -- TODO -- Implement me */ + return MPI_T_ERR_INVALID_HANDLE; +} diff --git a/ompi/runtime/Makefile.am b/ompi/runtime/Makefile.am index 63716b48e5..3129752255 100644 --- a/ompi/runtime/Makefile.am +++ b/ompi/runtime/Makefile.am @@ -25,7 +25,8 @@ headers += \ runtime/mpiruntime.h \ runtime/ompi_cr.h \ runtime/params.h \ - runtime/ompi_module_exchange.h + runtime/ompi_module_exchange.h \ + runtime/ompi_info_support.h libmpi_la_SOURCES += \ runtime/ompi_mpi_abort.c \ @@ -34,4 +35,5 @@ libmpi_la_SOURCES += \ runtime/ompi_mpi_params.c \ runtime/ompi_mpi_preconnect.c \ runtime/ompi_cr.c \ - runtime/ompi_module_exchange.c + runtime/ompi_module_exchange.c \ + runtime/ompi_info_support.c diff --git a/ompi/runtime/mpiruntime.h b/ompi/runtime/mpiruntime.h index 5866631426..574720b1bb 100644 --- a/ompi/runtime/mpiruntime.h +++ b/ompi/runtime/mpiruntime.h @@ -140,6 +140,14 @@ OMPI_DECLSPEC extern const char ompi_version_string[]; OMPI_DECLSPEC void ompi_warn_fork(void); +/** + * Determine the thread level + * + * @param requested Thread support that is requested (IN) + * @param provided Thread support that is provided (OUT) + */ +void ompi_mpi_thread_level(int requested, int *provided); + /** * Initialize the Open MPI MPI environment * diff --git a/ompi/runtime/ompi_mpi_init.c b/ompi/runtime/ompi_mpi_init.c index 5c555642ec..78077d579c 100644 --- a/ompi/runtime/ompi_mpi_init.c +++ b/ompi/runtime/ompi_mpi_init.c @@ -314,6 +314,36 @@ bool ompi_enable_timing; extern bool ompi_mpi_yield_when_idle; extern int ompi_mpi_event_tick_rate; + +void ompi_mpi_thread_level(int requested, int *provided) +{ + /** + * These values are monotonic; MPI_THREAD_SINGLE < MPI_THREAD_FUNNELED + * < MPI_THREAD_SERIALIZED < MPI_THREAD_MULTIPLE. + * If possible, the call will return provided = required. Failing this, + * the call will return the least supported level such that + * provided > required. Finally, if the user requirement cannot be + * satisfied, then the call will return in provided the highest + * supported level. + */ + ompi_mpi_thread_requested = requested; + + if (OMPI_ENABLE_THREAD_MULTIPLE == 1) { + ompi_mpi_thread_provided = *provided = requested; + ompi_mpi_main_thread = opal_thread_get_self(); + } else { + if (MPI_THREAD_MULTIPLE == requested) { + ompi_mpi_thread_provided = *provided = MPI_THREAD_SERIALIZED; + } else { + ompi_mpi_thread_provided = *provided = requested; + } + ompi_mpi_main_thread = (OPAL_ENABLE_MULTI_THREADS ? opal_thread_get_self() : NULL); + } + + ompi_mpi_thread_multiple = (ompi_mpi_thread_provided == + MPI_THREAD_MULTIPLE); +} + static int ompi_register_mca_variables(void) { int ret; @@ -459,31 +489,8 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided) MPI_THREAD_MULTIPLE. Set this stuff up here early in the process so that other components can make decisions based on this value. */ - /** - * These values are monotonic; MPI_THREAD_SINGLE < MPI_THREAD_FUNNELED - * < MPI_THREAD_SERIALIZED < MPI_THREAD_MULTIPLE. - * If possible, the call will return provided = required. Failing this, - * the call will return the least supported level such that - * provided > required. Finally, if the user requirement cannot be - * satisfied, then the call will return in provided the highest - * supported level. - */ - ompi_mpi_thread_requested = requested; - if (OMPI_ENABLE_THREAD_MULTIPLE == 1) { - ompi_mpi_thread_provided = *provided = requested; - ompi_mpi_main_thread = opal_thread_get_self(); - } else { - if (MPI_THREAD_MULTIPLE == requested) { - ompi_mpi_thread_provided = *provided = MPI_THREAD_SERIALIZED; - } else { - ompi_mpi_thread_provided = *provided = requested; - } - ompi_mpi_main_thread = (OPAL_ENABLE_MULTI_THREADS ? opal_thread_get_self() : NULL); - } - - ompi_mpi_thread_multiple = (ompi_mpi_thread_provided == - MPI_THREAD_MULTIPLE); + ompi_mpi_thread_level(requested, provided); /* determine the bitflag belonging to the threadlevel_support provided */ memset ( &threadlevel_bf, 0, sizeof(uint8_t)); diff --git a/ompi/tools/ompi_info/components.c b/ompi/tools/ompi_info/components.c index 7c1120ba86..98876c71a8 100644 --- a/ompi/tools/ompi_info/components.c +++ b/ompi/tools/ompi_info/components.c @@ -74,60 +74,6 @@ * Private variables */ -static int info_register_framework (mca_base_framework_t *framework, opal_pointer_array_t *component_map) { - opal_info_component_map_t *map; - int rc; - - rc = mca_base_framework_register(framework, MCA_BASE_REGISTER_ALL); - if (OPAL_SUCCESS != rc && OPAL_ERR_BAD_PARAM != rc) { - return rc; - } - - map = OBJ_NEW(opal_info_component_map_t); - map->type = strdup(framework->framework_name); - map->components = &framework->framework_components; - opal_pointer_array_add(component_map, map); - - return rc; -} - -int ompi_info_register_framework_params(opal_pointer_array_t *component_map) -{ - int i, rc; - char *str; - - /* Register the MPI layer's MCA parameters */ - if (OMPI_SUCCESS != (rc = ompi_mpi_register_params())) { - str = "ompi_mpi_register_params"; - if (OMPI_ERR_BAD_PARAM == rc) { - goto breakout; - } - goto error; - } - - /* MPI frameworks */ - for (i=0; NULL != ompi_frameworks[i]; i++) { - if (OPAL_SUCCESS != (rc = info_register_framework(ompi_frameworks[i], component_map))) { - fprintf (stderr, "rc = %d\n", rc); - str = ompi_frameworks[i]->framework_name; - break; - } - } - - breakout: - if (OPAL_ERR_BAD_PARAM == rc) { - fprintf(stderr, "\nA \"bad parameter\" error was encountered when opening the OMPI %s framework\n", str); - fprintf(stderr, "The output received from that framework includes the following parameters:\n\n"); - } - return rc; - - error: - fprintf(stderr, "ompi_info_register: %s failed\n", str); - fprintf(stderr, "ompi_info will likely not display all configuration information\n"); - return OMPI_ERROR; -} - - void ompi_info_close_components() { int i; diff --git a/ompi/tools/ompi_info/ompi_info.c b/ompi/tools/ompi_info/ompi_info.c index 7bcd672a85..0421aeb56f 100644 --- a/ompi/tools/ompi_info/ompi_info.c +++ b/ompi/tools/ompi_info/ompi_info.c @@ -54,6 +54,7 @@ #include "ompi/include/ompi/frameworks.h" #include "ompi/communicator/communicator.h" #include "ompi/tools/ompi_info/ompi_info.h" +#include "ompi/runtime/ompi_info_support.h" /* * Public variables diff --git a/ompi/tools/ompi_info/ompi_info.h b/ompi/tools/ompi_info/ompi_info.h index 78e6aec3f0..723417af4b 100644 --- a/ompi/tools/ompi_info/ompi_info.h +++ b/ompi/tools/ompi_info/ompi_info.h @@ -43,7 +43,6 @@ void ompi_info_do_version(bool want_all, opal_cmd_line_t *cmd_line, void ompi_info_show_ompi_version(const char *scope); -int ompi_info_register_framework_params(opal_pointer_array_t *component_map); void ompi_info_close_components(void); void ompi_info_do_config(bool want_all); diff --git a/opal/mca/base/mca_base_var.c b/opal/mca/base/mca_base_var.c index 4c4df565b9..7ee9ad990f 100644 --- a/opal/mca/base/mca_base_var.c +++ b/opal/mca/base/mca_base_var.c @@ -1585,7 +1585,7 @@ int mca_base_var_register_synonym (int synonym_for, const char *project_name, } return register_variable (project_name, framework_name, component_name, - synonym_name, NULL, var->mbv_type, var->mbv_enumerator, + synonym_name, var->mbv_description, var->mbv_type, var->mbv_enumerator, var->mbv_bind, var_flags, var->mbv_info_lvl, var->mbv_scope, synonym_for, NULL); } diff --git a/opal/runtime/opal_info_support.c b/opal/runtime/opal_info_support.c index cbe15e0ded..6e792f8caf 100644 --- a/opal/runtime/opal_info_support.c +++ b/opal/runtime/opal_info_support.c @@ -83,6 +83,7 @@ const char *opal_info_ver_mca = "mca"; const char *opal_info_ver_type = "type"; const char *opal_info_ver_component = "component"; +static bool opal_info_registered = false; static void component_map_construct(opal_info_component_map_t *map) { @@ -214,7 +215,8 @@ void opal_info_finalize(void) opal_finalize_util(); } -static int info_register_framework (mca_base_framework_t *framework, opal_pointer_array_t *component_map) { +static int info_register_framework (mca_base_framework_t *framework, opal_pointer_array_t *component_map) +{ opal_info_component_map_t *map; int rc; @@ -223,10 +225,35 @@ static int info_register_framework (mca_base_framework_t *framework, opal_pointe return rc; } - map = OBJ_NEW(opal_info_component_map_t); - map->type = strdup(framework->framework_name); - map->components = &framework->framework_components; - opal_pointer_array_add(component_map, map); + if (NULL != component_map) { + map = OBJ_NEW(opal_info_component_map_t); + map->type = strdup(framework->framework_name); + map->components = &framework->framework_components; + opal_pointer_array_add(component_map, map); + } + + return rc; +} + +int opal_info_register_project_frameworks (const char *project_name, mca_base_framework_t **frameworks, + opal_pointer_array_t *component_map) +{ + int i, rc; + + for (i=0; NULL != frameworks[i]; i++) { + if (OPAL_SUCCESS != (rc = info_register_framework(frameworks[i], component_map))) { + if (OPAL_ERR_BAD_PARAM == rc) { + fprintf(stderr, "\nA \"bad parameter\" error was encountered when opening the %s %s framework\n", + project_name, frameworks[i]->framework_name); + fprintf(stderr, "The output received from that framework includes the following parameters:\n\n"); + } else { + fprintf(stderr, "%s_info_register: %s failed\n", project_name, frameworks[i]->framework_name); + rc = OPAL_ERROR; + } + + break; + } + } return rc; } @@ -247,29 +274,27 @@ void opal_info_register_types(opal_pointer_array_t *mca_types) int opal_info_register_framework_params(opal_pointer_array_t *component_map) { - int i, rc; - char *str; + int rc; + + if (opal_info_registered) { + return OPAL_SUCCESS; + } + + opal_info_registered = true; + + /* Register mca/base parameters */ + if( OPAL_SUCCESS != mca_base_open() ) { + opal_show_help("help-opal_info.txt", "lib-call-fail", true, "mca_base_open", __FILE__, __LINE__ ); + return OPAL_ERROR; + } /* Register the OPAL layer's MCA parameters */ if (OPAL_SUCCESS != (rc = opal_register_params())) { - str = "opal_register_params"; - goto error; + fprintf(stderr, "opal_info_register: opal_register_params failed\n"); + return rc; } - /* OPAL frameworks */ - for (i=0; NULL != opal_frameworks[i]; i++) { - if (OPAL_SUCCESS != (rc = info_register_framework(opal_frameworks[i], component_map))) { - fprintf (stderr, "rc = %d\n", rc); - str = opal_frameworks[i]->framework_name; - goto error; - } - } - - return OPAL_SUCCESS; - - error: - fprintf(stderr, "opal_info_register: %s failed\n", str); - return OPAL_ERROR; + return opal_info_register_project_frameworks("opal", opal_frameworks, component_map); } diff --git a/opal/runtime/opal_info_support.h b/opal/runtime/opal_info_support.h index efa8897458..f21b965f5e 100644 --- a/opal/runtime/opal_info_support.h +++ b/opal/runtime/opal_info_support.h @@ -103,6 +103,10 @@ OPAL_DECLSPEC void opal_info_out_int(const char *pretty_message, const char *plain_message, int value); +OPAL_DECLSPEC int opal_info_register_project_frameworks (const char *project_name, + mca_base_framework_t **frameworks, + opal_pointer_array_t *component_map); + END_C_DECLS #endif diff --git a/orte/runtime/orte_info_support.c b/orte/runtime/orte_info_support.c index 57aaa6964d..f9261aa2a1 100644 --- a/orte/runtime/orte_info_support.c +++ b/orte/runtime/orte_info_support.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana * University Research and Technology @@ -37,6 +38,8 @@ const char *orte_info_type_orte = "orte"; +static bool orte_info_registered = false; + void orte_info_register_types(opal_pointer_array_t *mca_types) { int i; @@ -50,55 +53,30 @@ void orte_info_register_types(opal_pointer_array_t *mca_types) } } -static int info_register_framework (mca_base_framework_t *framework, opal_pointer_array_t *component_map) { - opal_info_component_map_t *map; - int rc; - - rc = mca_base_framework_register(framework, MCA_BASE_REGISTER_ALL); - if (OPAL_SUCCESS != rc && OPAL_ERR_BAD_PARAM != rc) { - return rc; - } - - map = OBJ_NEW(opal_info_component_map_t); - map->type = strdup(framework->framework_name); - map->components = &framework->framework_components; - opal_pointer_array_add(component_map, map); - - return rc; -} - int orte_info_register_framework_params(opal_pointer_array_t *component_map) { - char *str=NULL; - int i, rc; + int rc; + + if (orte_info_registered) { + return ORTE_SUCCESS; + } + + orte_info_registered = true; /* Register the ORTE layer's MCA parameters */ if (ORTE_SUCCESS != (rc = orte_register_params()) && ORTE_ERR_BAD_PARAM != rc) { - str = "orte_register_params"; - goto error; - } - - for (i=0; NULL != orte_frameworks[i]; i++) { - if (OPAL_SUCCESS != (rc = info_register_framework(orte_frameworks[i], component_map))) { - fprintf (stderr, "rc = %d\n", rc); - str = orte_frameworks[i]->framework_name; - goto error; - } + fprintf(stderr, "orte_info_register: orte_register_params failed\n"); + return rc; } - if (ORTE_ERR_BAD_PARAM == rc) { - fprintf(stderr, "\nA \"bad parameter\" error was encountered when opening the ORTE %s framework\n", - (NULL == str) ? "NULL" : str); - fprintf(stderr, "The output received from that framework includes the following parameters:\n\n"); + rc = opal_info_register_framework_params(component_map); + if (OPAL_SUCCESS != rc) { + return rc; } - return rc; - - error: - fprintf(stderr, "orte_info_register: %s failed\n", str); - return ORTE_ERROR; + return opal_info_register_project_frameworks("orte", orte_frameworks, component_map); } void orte_info_close_components(void)