1
1

Per RFC add initial support for the MPI 3.0 tools interface.

Current MPI_T support:
  - Full cvar interface.
  - Full categories interface.
  - No pvar support at this time.

This commit was SVN r28376.
This commit is contained in:
Nathan Hjelm 2013-04-24 15:59:23 +00:00
parent bdd6d35eeb
commit bccf8c657a
43 changed files with 1470 additions and 146 deletions

View File

@ -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

View File

@ -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_<foo> 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

View File

@ -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;

31
ompi/mpit/Makefile.am Normal file
View File

@ -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

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

85
ompi/mpit/cvar_get_info.c Normal file
View File

@ -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;
}

30
ompi/mpit/cvar_get_num.c Normal file
View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

69
ompi/mpit/cvar_read.c Normal file
View File

@ -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;
}

83
ompi/mpit/cvar_write.c Normal file
View File

@ -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;
}

41
ompi/mpit/enum_get_info.c Normal file
View File

@ -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;
}

52
ompi/mpit/enum_get_item.c Normal file
View File

@ -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;
}

36
ompi/mpit/finalize.c Normal file
View File

@ -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;
}

82
ompi/mpit/init_thread.c Normal file
View File

@ -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 <sched.h>
#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;
}

78
ompi/mpit/mpit-internal.h Normal file
View File

@ -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 <string.h>
#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) */

27
ompi/mpit/pvar_get_info.c Normal file
View File

@ -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;
}

31
ompi/mpit/pvar_get_num.c Normal file
View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

25
ompi/mpit/pvar_read.c Normal file
View File

@ -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;
}

View File

@ -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;
}

24
ompi/mpit/pvar_reset.c Normal file
View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

24
ompi/mpit/pvar_start.c Normal file
View File

@ -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;
}

24
ompi/mpit/pvar_stop.c Normal file
View File

@ -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;
}

25
ompi/mpit/pvar_write.c Normal file
View File

@ -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)
{