示例#1
0
int MPI_T_pvar_handle_free(MPI_T_pvar_session session, MPI_T_pvar_handle *handle)
{
    int ret = MPI_SUCCESS;

    if (!mpit_is_initialized ()) {
        return MPI_T_ERR_NOT_INITIALIZED;
    }

    mpit_lock ();

    do {
        /* Check that this is a valid handle */
        if (MPI_T_PVAR_HANDLE_NULL == *handle ||
            MPI_T_PVAR_ALL_HANDLES == *handle) {
            /* As of MPI 3.0 MPI_T_PVAR_ALL_HANDLES is not a valid handle for
               MPI_T_pvar_handle_free */
            ret = MPI_T_ERR_INVALID_HANDLE;
            break;
        }

        ret = mca_base_pvar_handle_free (*handle);
        if (OPAL_SUCCESS != ret) {
            ret = MPI_ERR_UNKNOWN;
        }

        *handle = MPI_T_PVAR_HANDLE_NULL;
    } while (0);

    mpit_unlock ();

    return ret;
}
示例#2
0
int MPI_T_pvar_handle_alloc(MPI_T_pvar_session session, int pvar_index,
                            void *obj_handle, MPI_T_pvar_handle *handle, int *count)
{
    const mca_base_pvar_t *pvar;
    int ret;

    if (!mpit_is_initialized ()) {
        return MPI_T_ERR_NOT_INITIALIZED;
    }

    ompi_mpit_lock ();

    do {
        /* Find the performance variable. mca_base_pvar_get() handles the
           bounds checking. */
        ret = mca_base_pvar_get (pvar_index, &pvar);
        if (OMPI_SUCCESS != ret) {
            break;
        }

        /* Check the variable binding is something sane */
        if (pvar->bind > MPI_T_BIND_MPI_INFO || pvar->bind < MPI_T_BIND_NO_OBJECT) {
            /* This variable specified an invalid binding (not an MPI object). */
            ret = MPI_T_ERR_INVALID_INDEX;
            break;
        }

        ret = mca_base_pvar_handle_alloc (session, pvar_index, obj_handle,
                                          handle, count);
    } while (0);

    ompi_mpit_unlock ();

    return ompit_opal_to_mpit_error(ret);
}
示例#3
0
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;
    }

    ompi_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);

    ompi_mpit_unlock ();

    return rc;
}
示例#4
0
文件: cvar_read.c 项目: anandhis/ompi
int MPI_T_cvar_read (MPI_T_cvar_handle handle, void *buf)
{
    const mca_base_var_storage_t *value = NULL;
    int rc = MPI_SUCCESS;

    if (!mpit_is_initialized ()) {
        return MPI_T_ERR_NOT_INITIALIZED;
    }

    if (MPI_PARAM_CHECK && NULL == buf) {
        return MPI_ERR_ARG;
    }

    ompi_mpit_lock ();

    do {
        rc = mca_base_var_get_value(handle->var->mbv_index, &value, NULL, NULL);
        if (OPAL_SUCCESS != rc || NULL == value) {
            /* 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:
            ((unsigned long *) buf)[0] = value->ulval;
            break;
        case MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG:
            ((unsigned long long *) buf)[0] = value->ullval;
            break;
        case MCA_BASE_VAR_TYPE_SIZE_T:
            ((size_t *) buf)[0] = value->sizetval;
            break;
        case MCA_BASE_VAR_TYPE_BOOL:
            ((int *) buf)[0] = value->boolval;
            break;
        case MCA_BASE_VAR_TYPE_DOUBLE:
            ((double *) buf)[0] = value->lfval;
            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);

    ompi_mpit_unlock ();

    return rc;
}
示例#5
0
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;
}
示例#6
0
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;
}
示例#7
0
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;
}
示例#8
0
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;
}
示例#9
0
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 || OPAL_ERR_NOT_FOUND == 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 */
        rc = ompit_var_type_to_datatype (var->mbv_type, datatype);
        if (OMPI_SUCCESS != rc) {
            break;
        }

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

        if (NULL != verbosity) {
            *verbosity = var->mbv_info_lvl;
        }
    } while (0);

    mpit_unlock ();

    return rc;
}
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;
}
示例#11
0
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;
    }

    ompi_mpit_lock ();
    *num_cat = mca_base_var_group_get_count ();
    ompi_mpit_unlock ();

    return MPI_SUCCESS;
}
示例#12
0
int MPI_T_pvar_get_index (const char *name, int var_class, 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, var_class, pvar_index);
    mpit_unlock ();
    if (OPAL_SUCCESS != ret) {
        return MPI_T_ERR_INVALID_NAME;
    }

    return MPI_SUCCESS;
}
示例#13
0
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;
}
示例#14
0
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)
{
    const mca_base_pvar_t *pvar;
    int ret;

    if (!mpit_is_initialized ()) {
        return MPI_T_ERR_NOT_INITIALIZED;
    }

    ompi_mpit_lock ();

    do {
        /* Find the performance variable. mca_base_pvar_get() handles the
           bounds checking. */
        ret = mca_base_pvar_get (pvar_index, &pvar);
        if (OMPI_SUCCESS != ret) {
            break;
        }

        /* Check the variable binding is something sane */
        if (pvar->bind > MPI_T_BIND_MPI_INFO || pvar->bind < MPI_T_BIND_NO_OBJECT) {
            /* This variable specified an invalid binding (not an MPI object). */
            ret = MPI_T_ERR_INVALID_INDEX;
            break;
        }

        /* Copy name an description */
        mpit_copy_string (name, name_len, pvar->name);
        mpit_copy_string (desc, desc_len, pvar->description);

        if (verbosity) {
            *verbosity = pvar->verbosity;
        }

        if (var_class) {
            *var_class = pvar->var_class;
        }

        ret = ompit_var_type_to_datatype (pvar->type, datatype);
        if (OMPI_SUCCESS != ret) {
            break;
        }

        if (NULL != enumtype) {
            *enumtype = pvar->enumerator ? (MPI_T_enum) pvar->enumerator : MPI_T_ENUM_NULL;
        }

        if (NULL != bind) {
            *bind = pvar->bind;
        }

        if (NULL != readonly) {
            *readonly = mca_base_pvar_is_readonly (pvar);
        }

        if (NULL != continuous) {
            *continuous = mca_base_pvar_is_continuous (pvar);
        }

        if (NULL != atomic) {
            *atomic = mca_base_pvar_is_atomic (pvar);
        }
    } while (0);

    ompi_mpit_unlock ();

    return ret;
}