Skip to content

Commit 263dca3

Browse files
authored
Merge pull request #10672 from hppritcha/address_issue_10592
Sessions: various fixes for some error cases
2 parents 1da4d20 + 1c31c96 commit 263dca3

File tree

8 files changed

+79
-34
lines changed

8 files changed

+79
-34
lines changed

ompi/instance/instance.c

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,7 @@ static int ompi_instance_get_pmix_pset_size (ompi_instance_t *instance, const ch
12851285
OPAL_PMIX_CONVERT_NAME(&p, &name);
12861286
rc = PMIx_Get(&p, PMIX_PSET_NAME, NULL, 0, &pval);
12871287
if (OPAL_UNLIKELY(PMIX_SUCCESS != rc)) {
1288-
return rc;
1288+
return opal_pmix_convert_status(rc);
12891289
}
12901290

12911291
PMIX_VALUE_UNLOAD(rc,
@@ -1296,6 +1296,7 @@ static int ompi_instance_get_pmix_pset_size (ompi_instance_t *instance, const ch
12961296
size += (0 == strcmp (pset_name, stmp));
12971297
PMIX_VALUE_RELEASE(pval);
12981298
free(stmp);
1299+
stmp = NULL;
12991300

13001301
++size;
13011302
}
@@ -1336,7 +1337,7 @@ int ompi_instance_get_pset_info (ompi_instance_t *instance, const char *pset_nam
13361337
ompi_info_t *info = ompi_info_allocate ();
13371338
char tmp[16];
13381339
size_t size = 0UL;
1339-
int ret;
1340+
int ret = OMPI_SUCCESS ;
13401341

13411342
*info_used = (opal_info_t *) MPI_INFO_NULL;
13421343

@@ -1346,25 +1347,31 @@ int ompi_instance_get_pset_info (ompi_instance_t *instance, const char *pset_nam
13461347

13471348
if (0 == strncmp (pset_name, "mpi://", 6)) {
13481349
pset_name += 6;
1349-
if (0 == strcmp (pset_name, "world")) {
1350+
if (0 == strcasecmp (pset_name, "WORLD")) {
13501351
size = ompi_process_info.num_procs;
1351-
} else if (0 == strcmp (pset_name, "self")) {
1352+
} else if (0 == strcasecmp (pset_name, "SELF")) {
13521353
size = 1;
1353-
} else if (0 == strcmp (pset_name, "shared")) {
1354+
}
1355+
} else if (0 == strncmp (pset_name, "mpix://", 7)) {
1356+
pset_name += 7;
1357+
if (0 == strcasecmp (pset_name, "SHARED")) {
13541358
size = ompi_process_info.num_local_peers + 1;
13551359
}
13561360
} else {
1357-
ompi_instance_get_pmix_pset_size (instance, pset_name, &size);
1361+
ret = ompi_instance_get_pmix_pset_size (instance, pset_name, &size);
13581362
}
13591363

1360-
snprintf (tmp, 16, "%" PRIsize_t, size);
1361-
ret = opal_info_set (&info->super, MPI_INFO_KEY_SESSION_PSET_SIZE, tmp);
1362-
if (OPAL_UNLIKELY(OPAL_SUCCESS != ret)) {
1364+
if (OMPI_SUCCESS == ret) {
1365+
snprintf (tmp, 16, "%" PRIsize_t, size);
1366+
ret = opal_info_set (&info->super, MPI_INFO_KEY_SESSION_PSET_SIZE, tmp);
1367+
if (OPAL_UNLIKELY(OPAL_SUCCESS != ret)) {
1368+
ompi_info_free (&info);
1369+
return ret;
1370+
}
1371+
*info_used = &info->super;
1372+
} else {
13631373
ompi_info_free (&info);
1364-
return ret;
13651374
}
13661375

1367-
*info_used = &info->super;
1368-
1369-
return OMPI_SUCCESS;
1376+
return ret;
13701377
}

ompi/instance/instance.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,12 @@ OMPI_DECLSPEC int ompi_instance_get_pset_info (ompi_instance_t *instance, const
156156
*/
157157
extern opal_atomic_int32_t ompi_instance_count;
158158

159+
static inline int ompi_instance_invalid (const ompi_instance_t* instance)
160+
{
161+
if ((NULL == instance) || (MPI_SESSION_NULL == instance))
162+
return true;
163+
else
164+
return false;
165+
}
166+
159167
#endif /* !defined(OMPI_INSTANCE_H) */

ompi/mpi/c/group_from_session_pset.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,27 @@ int MPI_Group_from_session_pset (MPI_Session session, const char *pset_name, MPI
3131
int rc;
3232

3333
if ( MPI_PARAM_CHECK ) {
34-
if (NULL == session || NULL == pset_name || NULL == newgroup) {
34+
if (ompi_instance_invalid(session)) {
3535
if (NULL != session) {
36-
return OMPI_ERRHANDLER_INVOKE(session, MPI_ERR_ARG, FUNC_NAME);
36+
return OMPI_ERRHANDLER_INVOKE(session, MPI_ERR_SESSION, FUNC_NAME);
3737
} else {
38-
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_ARG, FUNC_NAME);
38+
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_SESSION, FUNC_NAME);
3939
}
40+
} else if (NULL == pset_name || NULL == newgroup) {
41+
return OMPI_ERRHANDLER_INVOKE(session, MPI_ERR_ARG, FUNC_NAME);
4042
}
4143
}
4244

4345
rc = ompi_group_from_pset (session, pset_name, newgroup);
46+
/*
47+
* if process set was not found, OMPI_ERR_NOT_FOUND is the return value.
48+
* we want to map this to MPI_ERR_ARG but we have to do it manually here
49+
* since the OMPI error to MPI error code code maps this to MPI_ERR_INTERN
50+
*/
51+
if (OMPI_ERR_NOT_FOUND == rc) {
52+
rc = MPI_ERR_ARG;
53+
}
54+
4455

4556
OMPI_ERRHANDLER_RETURN (rc, (NULL == session) ? MPI_SESSION_NULL : session,
4657
rc, FUNC_NAME);

ompi/mpi/c/session_get_errhandler.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ int MPI_Session_get_errhandler(MPI_Session session, MPI_Errhandler *errhandler)
5050

5151
if (MPI_PARAM_CHECK) {
5252
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
53-
if (NULL == session) {
54-
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_ARG, FUNC_NAME);
53+
if (ompi_instance_invalid(session)) {
54+
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_SESSION, FUNC_NAME);
5555
}
5656
}
5757

@@ -66,6 +66,5 @@ int MPI_Session_get_errhandler(MPI_Session session, MPI_Errhandler *errhandler)
6666
ret = ompi_mpi_instance_retain ();
6767

6868
/* All done */
69-
70-
return ret;
69+
OMPI_ERRHANDLER_RETURN (ret, session, ret, FUNC_NAME);
7170
}

ompi/mpi/c/session_get_nth_pset.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ int MPI_Session_get_nth_pset (MPI_Session session, MPI_Info info, int n, int *le
3131
int rc = MPI_SUCCESS;
3232

3333
if ( MPI_PARAM_CHECK ) {
34-
if (NULL == session || (NULL == pset_name && *len > 0) || n < 0) {
34+
if (ompi_instance_invalid(session)) {
3535
if (NULL != session) {
36-
return OMPI_ERRHANDLER_INVOKE(session, MPI_ERR_ARG, FUNC_NAME);
36+
return OMPI_ERRHANDLER_INVOKE(session, MPI_ERR_SESSION, FUNC_NAME);
3737
} else {
38-
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_ARG, FUNC_NAME);
38+
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_SESSION, FUNC_NAME);
3939
}
40+
} else if ((NULL == pset_name && *len > 0) || n < 0) {
41+
return OMPI_ERRHANDLER_INVOKE(session, MPI_ERR_ARG, FUNC_NAME);
4042
}
4143
}
4244

ompi/mpi/c/session_get_num_psets.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ int MPI_Session_get_num_psets (MPI_Session session, MPI_Info info, int *npset_na
3131
int rc;
3232

3333
if ( MPI_PARAM_CHECK ) {
34-
if (NULL == session || NULL == npset_names) {
34+
if (ompi_instance_invalid(session)) {
3535
if (NULL != session) {
36-
return OMPI_ERRHANDLER_INVOKE(session, MPI_ERR_ARG, FUNC_NAME);
36+
return OMPI_ERRHANDLER_INVOKE(session, MPI_ERR_SESSION, FUNC_NAME);
3737
} else {
38-
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_ARG, FUNC_NAME);
38+
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_SESSION, FUNC_NAME);
3939
}
40+
} else if (NULL == npset_names) {
41+
return OMPI_ERRHANDLER_INVOKE(session, MPI_ERR_ARG, FUNC_NAME);
4042
}
4143
}
4244

ompi/mpi/c/session_get_pset_info.c

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Copyright (c) 2015 Research Organization for Information Science
55
* and Technology (RIST). All rights reserved.
66
* Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
7-
* Copyright (c) 2018 Triad National Security, LLC. All rights
7+
* Copyright (c) 2018-2022 Triad National Security, LLC. All rights
88
* reserved.
99
* $COPYRIGHT$
1010
*
@@ -35,18 +35,34 @@ static const char FUNC_NAME[] = "MPI_Session_get_pset_info";
3535

3636
int MPI_Session_get_pset_info (MPI_Session session, const char *pset_name, MPI_Info *info_used)
3737
{
38-
int ret;
38+
int rc;
3939

4040
if (MPI_PARAM_CHECK) {
4141
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
42-
if (NULL == session || MPI_SESSION_NULL == session) {
43-
return MPI_ERR_ARG;
42+
if (ompi_instance_invalid(session)) {
43+
if (NULL != session) {
44+
return OMPI_ERRHANDLER_INVOKE(session, MPI_ERR_SESSION, FUNC_NAME);
45+
} else {
46+
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_SESSION, FUNC_NAME);
47+
}
4448
}
4549
if (NULL == info_used) {
4650
return OMPI_ERRHANDLER_INVOKE (session, MPI_ERR_INFO, FUNC_NAME);
4751
}
52+
if (NULL == pset_name) {
53+
return OMPI_ERRHANDLER_INVOKE (session, MPI_ERR_ARG, FUNC_NAME);
54+
}
55+
}
56+
57+
rc = ompi_instance_get_pset_info (session, pset_name, (opal_info_t **) info_used);
58+
/*
59+
* if process set was not found, OMPI_ERR_NOT_FOUND is the return value.
60+
* we want to map this to MPI_ERR_ARG but we have to do it manually here
61+
* since the OMPI error to MPI error code code maps this to MPI_ERR_INTERN
62+
*/
63+
if (OMPI_ERR_NOT_FOUND == rc) {
64+
rc = MPI_ERR_ARG;
4865
}
4966

50-
ret = ompi_instance_get_pset_info (session, pset_name, (opal_info_t **) info_used);
51-
return OMPI_ERRHANDLER_INVOKE(session, ret, FUNC_NAME);
67+
return OMPI_ERRHANDLER_INVOKE(session, rc, FUNC_NAME);
5268
}

ompi/mpi/c/session_set_errhandler.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ int MPI_Session_set_errhandler(MPI_Session session, MPI_Errhandler errhandler)
4747
/* Error checking */
4848

4949
if (MPI_PARAM_CHECK) {
50-
if (NULL == session) {
51-
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_ARG, FUNC_NAME);
50+
if (ompi_instance_invalid(session)) {
51+
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_SESSION, FUNC_NAME);
5252
} else if (NULL == errhandler ||
5353
MPI_ERRHANDLER_NULL == errhandler ||
5454
( OMPI_ERRHANDLER_TYPE_INSTANCE != errhandler->eh_mpi_object_type &&

0 commit comments

Comments
 (0)