Skip to content

Commit 7f89805

Browse files
committed
sessions: fixes for invoking some functions before init
turns out the macro used for checking init/finalize/instance count was using a different counter than that incremented when an app calls MPI_Info_create, etc. prior to MPI_Init. so just remove its use in these functions. related to #10794 Signed-off-by: Howard Pritchard <howardp@lanl.gov>
1 parent 17767a2 commit 7f89805

File tree

6 files changed

+53
-19
lines changed

6 files changed

+53
-19
lines changed

ompi/mpi/c/error_class.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
* All rights reserved.
1212
* Copyright (c) 2015 Research Organization for Information Science
1313
* and Technology (RIST). All rights reserved.
14+
* Copyright (c) 2022 Triad National Security, LLC. All rights
15+
* reserved.
1416
* $COPYRIGHT$
1517
*
1618
* Additional copyrights may follow
@@ -38,6 +40,14 @@ static const char FUNC_NAME[] = "MPI_Error_class";
3840

3941
int MPI_Error_class(int errorcode, int *errorclass)
4042
{
43+
int ret;
44+
45+
/* make sure the infrastructure is initialized */
46+
ret = ompi_mpi_instance_retain ();
47+
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
48+
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(ret, FUNC_NAME);
49+
}
50+
4151
if ( MPI_PARAM_CHECK ) {
4252
if ( ompi_mpi_errcode_is_invalid(errorcode)) {
4353
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_ARG,
@@ -47,5 +57,7 @@ int MPI_Error_class(int errorcode, int *errorclass)
4757

4858

4959
*errorclass = ompi_mpi_errcode_get_class(errorcode);
60+
ompi_mpi_instance_release ();
61+
5062
return MPI_SUCCESS;
5163
}

ompi/mpi/c/error_string.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* Copyright (c) 2015 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
1515
* Copyright (c) 2018 Cisco Systems, Inc. All rights reserved
16+
* Copyright (c) 2022 Triad National Security, LLC. All rights
17+
* reserved.
1618
* $COPYRIGHT$
1719
*
1820
* Additional copyrights may follow
@@ -42,8 +44,16 @@ static const char FUNC_NAME[] = "MPI_Error_string";
4244

4345
int MPI_Error_string(int errorcode, char *string, int *resultlen)
4446
{
47+
int ret;
4548
char *tmpstring;
4649

50+
/* make sure the infrastructure is initialized */
51+
ret = ompi_mpi_instance_retain ();
52+
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
53+
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(ret,
54+
FUNC_NAME);
55+
}
56+
4757
if ( MPI_PARAM_CHECK ) {
4858
if ( ompi_mpi_errcode_is_invalid(errorcode)) {
4959
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_ARG,
@@ -55,5 +65,7 @@ int MPI_Error_string(int errorcode, char *string, int *resultlen)
5565
opal_string_copy(string, tmpstring, MPI_MAX_ERROR_STRING);
5666
*resultlen = (int)strlen(string);
5767

68+
ompi_mpi_instance_release();
69+
5870
return MPI_SUCCESS;
5971
}

ompi/mpi/c/info_f2c.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Copyright (c) 2006-2012 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2015 Research Organization for Information Science
1515
* and Technology (RIST). All rights reserved.
16-
* Copyright (c) 2018-2021 Triad National Security, LLC. All rights
16+
* Copyright (c) 2018-2022 Triad National Security, LLC. All rights
1717
* reserved.
1818
* $COPYRIGHT$
1919
*
@@ -65,15 +65,23 @@ MPI_Info MPI_Info_f2c(MPI_Fint info)
6565
return MPI_INFO_ENV;
6666
}
6767

68-
if (MPI_PARAM_CHECK) {
69-
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
70-
}
68+
/*
69+
* if the application has not created an info object yet
70+
* then the size of the ompi_info_f_to_c_table is zero
71+
* so this check can be done even if an info object has not
72+
* previously been created.
73+
*/
7174

7275
if (info_index < 0 ||
7376
info_index >=
7477
opal_pointer_array_get_size(&ompi_info_f_to_c_table)) {
7578
return NULL;
7679
}
7780

81+
/*
82+
* if we get here, then the info support infrastructure has been initialized
83+
* either via a prior call to MPI_Info_create or one of the MPI initialization
84+
* methods.
85+
*/
7886
return (MPI_Info)opal_pointer_array_get_item(&ompi_info_f_to_c_table, info_index);
7987
}

ompi/mpi/c/info_free.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
* All rights reserved.
1313
* Copyright (c) 2015 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
15+
* Copyright (c) 2022 Triad National Security, LLC. All rights
16+
* reserved.
17+
*
1518
* $COPYRIGHT$
1619
*
1720
* Additional copyrights may follow
@@ -57,7 +60,6 @@ int MPI_Info_free(MPI_Info *info)
5760
* fashion so that there are no dangling pointers.
5861
*/
5962
if (MPI_PARAM_CHECK) {
60-
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
6163
if (NULL == info || MPI_INFO_NULL == *info ||
6264
ompi_info_is_freed(*info)) {
6365
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_INFO,

ompi/mpi/c/info_get_nthkey.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
* All rights reserved.
1212
* Copyright (c) 2015 Research Organization for Information Science
1313
* and Technology (RIST). All rights reserved.
14+
* Copyright (c) 2022 Triad National Security, LLC. All rights
15+
* reserved.
1416
* $COPYRIGHT$
1517
*
1618
* Additional copyrights may follow
@@ -56,24 +58,23 @@ int MPI_Info_get_nthkey(MPI_Info info, int n, char *key)
5658
int err;
5759

5860
/*
59-
* 1. Check if info is a valid handle
61+
* 1. Check if info is a valid handle
6062
* 2. Check if there are at least (n+1) elements
6163
* 3. If so, give the nth defined key
6264
*/
65+
if (NULL == info || MPI_INFO_NULL == info) {
66+
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_INFO, FUNC_NAME);
67+
}
68+
6369
if (MPI_PARAM_CHECK) {
64-
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
65-
if (NULL == info || MPI_INFO_NULL == info ||
66-
ompi_info_is_freed(info)) {
67-
return OMPI_ERRHANDLER_INVOKE (MPI_COMM_WORLD, MPI_ERR_INFO,
68-
FUNC_NAME);
70+
if (ompi_info_is_freed(info)) {
71+
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_INFO, FUNC_NAME);
6972
}
7073
if (0 > n) {
71-
return OMPI_ERRHANDLER_INVOKE (MPI_COMM_WORLD, MPI_ERR_ARG,
72-
FUNC_NAME);
74+
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_ARG, FUNC_NAME);
7375
}
7476
if (NULL == key) {
75-
return OMPI_ERRHANDLER_INVOKE (MPI_COMM_WORLD, MPI_ERR_INFO_KEY,
76-
FUNC_NAME);
77+
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_INFO_KEY, FUNC_NAME);
7778
}
7879
}
7980

@@ -84,8 +85,7 @@ int MPI_Info_get_nthkey(MPI_Info info, int n, char *key)
8485
err = ompi_info_get_nkeys(info, &nkeys);
8586
OMPI_ERRHANDLER_NOHANDLE_CHECK(err, err, FUNC_NAME);
8687
if (n > (nkeys - 1)) {
87-
return OMPI_ERRHANDLER_INVOKE (MPI_COMM_WORLD, MPI_ERR_INFO_KEY,
88-
FUNC_NAME);
88+
return OMPI_ERRHANDLER_NOHANDLE_INVOKE (MPI_ERR_INFO_KEY, FUNC_NAME);
8989
}
9090

9191
/* Everything seems alright. Call the back end key copy */
@@ -96,5 +96,6 @@ int MPI_Info_get_nthkey(MPI_Info info, int n, char *key)
9696
opal_string_copy(key, key_str->string, MPI_MAX_INFO_KEY);
9797
OBJ_RELEASE(key_str);
9898
}
99+
99100
OMPI_ERRHANDLER_NOHANDLE_RETURN(err, err, FUNC_NAME);
100101
}

ompi/mpi/c/info_get_string.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Copyright (c) 2015 Research Organization for Information Science
1616
* and Technology (RIST). All rights reserved.
1717
* Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
18-
* Copyright (c) 2021 Triad National Security, LLC. All rights
18+
* Copyright (c) 2021-2022 Triad National Security, LLC. All rights
1919
* reserved.
2020
* $COPYRIGHT$
2121
*
@@ -74,7 +74,6 @@ int MPI_Info_get_string(MPI_Info info, const char *key, int *buflen,
7474
* necessary structures.
7575
*/
7676
if (MPI_PARAM_CHECK) {
77-
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
7877
if (NULL == info || MPI_INFO_NULL == info ||
7978
ompi_info_is_freed(info)) {
8079
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_INFO,

0 commit comments

Comments
 (0)