Skip to content

Commit e561f15

Browse files
committed
Merge pull request #658 from hjelmn/mpit_fixes
Fix definition of MPI_T_pvar_get_index
2 parents dc1b125 + 4552aff commit e561f15

File tree

9 files changed

+44
-13
lines changed

9 files changed

+44
-13
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ Master (not on release branches yet)
7272
1.8.6
7373
-----
7474

75+
- Fixed incorrect declaration for MPI_T_pvar_get_index and added
76+
missing return code MPI_T_INVALID_NAME.
7577
- Fixed memory leak on Mac OS-X exposed by TCP keepalive
7678
- Fixed keepalive support to ensure that daemon/node failure
7779
results in complete job cleanup

ompi/errhandler/errcode.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ static ompi_mpi_errcode_t ompi_err_rma_attach;
114114
static ompi_mpi_errcode_t ompi_err_rma_flavor;
115115
static ompi_mpi_errcode_t ompi_err_rma_shared;
116116
static ompi_mpi_errcode_t ompi_t_err_invalid;
117+
static ompi_mpi_errcode_t ompi_t_err_invalid_name;
117118

118119
static void ompi_mpi_errcode_construct(ompi_mpi_errcode_t* errcode);
119120
static void ompi_mpi_errcode_destruct(ompi_mpi_errcode_t* errcode);
@@ -214,6 +215,7 @@ int ompi_mpi_errcode_init (void)
214215
CONSTRUCT_ERRCODE( ompi_err_rma_flavor, MPI_ERR_RMA_FLAVOR, "MPI_ERR_RMA_FLAVOR: Invalid type of window" );
215216
CONSTRUCT_ERRCODE( ompi_err_rma_shared, MPI_ERR_RMA_SHARED, "MPI_ERR_RMA_SHARED: Memory cannot be shared" );
216217
CONSTRUCT_ERRCODE( ompi_t_err_invalid, MPI_T_ERR_INVALID, "MPI_T_ERR_INVALID: Invalid use of the interface or bad parameter value(s)" );
218+
CONSTRUCT_ERRCODE( ompi_t_err_invalid_name, MPI_T_ERR_INVALID_NAME, "MPI_T_ERR_INVALID_NAME: The variable or category name is invalid" );
217219

218220
/* Per MPI-3 p353:27-32, MPI_LASTUSEDCODE must be >=
219221
MPI_ERR_LASTCODE. So just start it as == MPI_ERR_LASTCODE. */
@@ -309,6 +311,7 @@ int ompi_mpi_errcode_finalize(void)
309311
OBJ_DESTRUCT(&ompi_err_rma_flavor);
310312
OBJ_DESTRUCT(&ompi_err_rma_shared);
311313
OBJ_DESTRUCT(&ompi_t_err_invalid);
314+
OBJ_DESTRUCT(&ompi_t_err_invalid_name);
312315

313316
OBJ_DESTRUCT(&ompi_mpi_errcodes);
314317
return OMPI_SUCCESS;

ompi/include/mpi.h.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ enum {
604604
#define MPI_ERR_RMA_FLAVOR 70
605605
#define MPI_ERR_RMA_SHARED 71
606606
#define MPI_T_ERR_INVALID 72
607+
#define MPI_T_ERR_INVALID_NAME 73
607608

608609
/* Per MPI-3 p349 47, MPI_ERR_LASTCODE must be >= the last predefined
609610
MPI_ERR_<foo> code. Set the last code to allow some room for adding
@@ -2594,7 +2595,7 @@ OMPI_DECLSPEC int PMPI_T_pvar_get_info(int pvar_index, char *name, int *name_le
25942595
int *verbosity, int *var_class, MPI_Datatype *datatype,
25952596
MPI_T_enum *enumtype, char *desc, int *desc_len, int *bind,
25962597
int *readonly, int *continuous, int *atomic);
2597-
OMPI_DECLSPEC int PMPI_T_pvar_get_index (const char *name, int *pvar_index);
2598+
OMPI_DECLSPEC int PMPI_T_pvar_get_index (const char *name, int var_class, int *pvar_index);
25982599
OMPI_DECLSPEC int PMPI_T_pvar_session_create(MPI_T_pvar_session *session);
25992600
OMPI_DECLSPEC int PMPI_T_pvar_session_free(MPI_T_pvar_session *session);
26002601
OMPI_DECLSPEC int PMPI_T_pvar_handle_alloc(MPI_T_pvar_session session, int pvar_index,
@@ -2644,7 +2645,7 @@ OMPI_DECLSPEC int MPI_T_pvar_get_info(int pvar_index, char *name, int *name_len
26442645
int *verbosity, int *var_class, MPI_Datatype *datatype,
26452646
MPI_T_enum *enumtype, char *desc, int *desc_len, int *bind,
26462647
int *readonly, int *continuous, int *atomic);
2647-
OMPI_DECLSPEC int MPI_T_pvar_get_index (const char *name, int *pvar_index);
2648+
OMPI_DECLSPEC int MPI_T_pvar_get_index (const char *name, int var_class, int *pvar_index);
26482649
OMPI_DECLSPEC int MPI_T_pvar_session_create(MPI_T_pvar_session *session);
26492650
OMPI_DECLSPEC int MPI_T_pvar_session_free(MPI_T_pvar_session *session);
26502651
OMPI_DECLSPEC int MPI_T_pvar_handle_alloc(MPI_T_pvar_session session, int pvar_index,

ompi/mpi/tool/category_get_index.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ int MPI_T_category_get_index (const char *name, int *category_index)
3636
mpit_lock ();
3737
ret = mca_base_var_group_find_by_name (name, category_index);
3838
mpit_unlock ();
39+
if (OPAL_SUCCESS != ret) {
40+
return MPI_T_ERR_INVALID_NAME;
41+
}
3942

40-
return ompit_opal_to_mpit_error (ret);
43+
return MPI_SUCCESS;
4144
}

ompi/mpi/tool/cvar_get_index.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ int MPI_T_cvar_get_index (const char *name, int *cvar_index)
3636
mpit_lock ();
3737
ret = mca_base_var_find_by_name (name, cvar_index);
3838
mpit_unlock ();
39+
if (OPAL_SUCCESS != ret) {
40+
return MPI_T_ERR_INVALID_NAME;
41+
}
3942

40-
return ompit_opal_to_mpit_error (ret);
43+
return MPI_SUCCESS;
4144
}

ompi/mpi/tool/mpit_common.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ void mpit_unlock (void)
3434

3535
int ompit_var_type_to_datatype (mca_base_var_type_t type, MPI_Datatype *datatype)
3636
{
37+
if (!datatype) {
38+
return OMPI_SUCCESS;
39+
}
40+
3741
switch (type) {
3842
case MCA_BASE_VAR_TYPE_INT:
3943
*datatype = MPI_INT;

ompi/mpi/tool/pvar_get_index.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
22
/*
3-
* Copyright (c) 2012-2014 Los Alamos National Security, LLC. All rights
3+
* Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights
44
* reserved.
55
* Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
66
* $COPYRIGHT$
@@ -21,7 +21,7 @@
2121
#endif
2222

2323

24-
int MPI_T_pvar_get_index (const char *name, int *pvar_index)
24+
int MPI_T_pvar_get_index (const char *name, int var_class, int *pvar_index)
2525
{
2626
int ret;
2727

@@ -34,8 +34,11 @@ int MPI_T_pvar_get_index (const char *name, int *pvar_index)
3434
}
3535

3636
mpit_lock ();
37-
ret = mca_base_pvar_find_by_name (name, pvar_index);
37+
ret = mca_base_pvar_find_by_name (name, var_class, pvar_index);
3838
mpit_unlock ();
39+
if (OPAL_SUCCESS != ret) {
40+
return MPI_T_ERR_INVALID_NAME;
41+
}
3942

40-
return ompit_opal_to_mpit_error (ret);
43+
return MPI_SUCCESS;
4144
}

opal/mca/base/mca_base_pvar.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
22
/*
3-
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
3+
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
44
* reserved.
55
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
66
* $COPYRIGHT$
@@ -76,16 +76,17 @@ int mca_base_pvar_find (const char *project, const char *framework, const char *
7676
return OPAL_ERROR;
7777
}
7878

79-
ret = mca_base_pvar_find_by_name (full_name, &index);
79+
ret = mca_base_pvar_find_by_name (full_name, MCA_BASE_PVAR_CLASS_ANY, &index);
8080
free (full_name);
8181

8282
/* NTH: should we verify the name components match the returned variable? */
8383

8484
return (OPAL_SUCCESS != ret) ? ret : index;
8585
}
8686

87-
int mca_base_pvar_find_by_name (const char *full_name, int *index)
87+
int mca_base_pvar_find_by_name (const char *full_name, int var_class, int *index)
8888
{
89+
mca_base_pvar_t *pvar;
8990
void *tmp;
9091
int rc;
9192

@@ -95,6 +96,15 @@ int mca_base_pvar_find_by_name (const char *full_name, int *index)
9596
return rc;
9697
}
9798

99+
rc = mca_base_pvar_get_internal ((int)(uintptr_t) tmp, &pvar, false);
100+
if (OPAL_SUCCESS != rc) {
101+
return rc;
102+
}
103+
104+
if (MCA_BASE_PVAR_CLASS_ANY != var_class && pvar->var_class != var_class) {
105+
return OPAL_ERR_NOT_FOUND;
106+
}
107+
98108
*index = (int)(uintptr_t) tmp;
99109

100110
return OPAL_SUCCESS;

opal/mca/base/mca_base_pvar.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
22
/*
3-
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
3+
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
44
* reserved.
55
*
66
* Additional copyrights may follow
@@ -91,6 +91,8 @@ enum {
9191
MCA_BASE_PVAR_CLASS_GENERIC
9292
};
9393

94+
#define MCA_BASE_PVAR_CLASS_ANY -1
95+
9496
/*
9597
* Reserved bindings; passed when registering a new pvar. OPAL will
9698
* ignore any other binding type.
@@ -356,7 +358,7 @@ OPAL_DECLSPEC int mca_base_pvar_find (const char *project, const char *framework
356358
*
357359
* See mca_base_pvar_find().
358360
*/
359-
OPAL_DECLSPEC int mca_base_pvar_find_by_name (const char *full_name, int *index);
361+
OPAL_DECLSPEC int mca_base_pvar_find_by_name (const char *full_name, int var_class, int *index);
360362

361363
/****************************************************************************
362364
* The following functions are the back-end to the MPI_T API functions

0 commit comments

Comments
 (0)