Skip to content

Commit 41a68b5

Browse files
authored
Merge pull request #13384 from naughtont3/tjn-mpi41-remove-errorclass2
add MPI_Remove_error_{string,code,class}
2 parents 868fff3 + da50804 commit 41a68b5

27 files changed

+868
-43
lines changed

docs/Makefile.am

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,9 @@ OMPI_MAN3 = \
392392
MPI_Reduce_scatter_block_init.3 \
393393
MPI_Reduce_scatter_init.3 \
394394
MPI_Register_datarep.3 \
395+
MPI_Remove_error_class.3 \
396+
MPI_Remove_error_code.3 \
397+
MPI_Remove_error_string.3 \
395398
MPI_Request_c2f.3 \
396399
MPI_Request_f2c.3 \
397400
MPI_Request_free.3 \
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
.. _mpi_remove_error_class:
2+
3+
4+
MPI_Remove_error_class
5+
======================
6+
7+
.. include_body
8+
9+
:ref:`MPI_Remove_error_class` |mdash| Removes a user-created error class.
10+
11+
.. The following file was automatically generated
12+
.. include:: ./bindings/mpi_remove_error_class.rst
13+
14+
INPUT PARAMETERS
15+
----------------
16+
* ``errorclass``: New error class (integer).
17+
18+
OUTPUT PARAMETERS
19+
-----------------
20+
* ``ierror``: Fortran only: Error status (integer).
21+
22+
DESCRIPTION
23+
-----------
24+
25+
The function :ref:`MPI_Remove_error_class` removes a user-created error class.
26+
It is erroneous to call :ref:`MPI_Remove_error_class` with a value for
27+
*errorclass* that was not added by a call to :ref:`MPI_Add_error_class`.
28+
It is erroneous to remove an error class when its associated error codes
29+
have not been removed before.
30+
31+
ERRORS
32+
------
33+
34+
.. include:: ./ERRORS.rst
35+
36+
.. seealso::
37+
* :ref:`MPI_Add_error_class`
38+
* :ref:`MPI_Remove_error_code`
39+
* :ref:`MPI_Remove_error_string`
40+
* :ref:`MPI_Error_class`
41+
* :ref:`MPI_Error_string`
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
.. _mpi_remove_error_code:
2+
3+
4+
MPI_Remove_error_code
5+
=====================
6+
7+
.. include_body
8+
9+
:ref:`MPI_Remove_error_code` |mdash| Remove a user-created error code associated with
10+
*errorcode*
11+
12+
.. The following file was automatically generated
13+
.. include:: ./bindings/mpi_remove_error_code.rst
14+
15+
INPUT PARAMETER
16+
---------------
17+
* ``errorcode``: MPI error code (integer).
18+
19+
OUTPUT PARAMETERS
20+
-----------------
21+
* ``ierror``: Fortran only: Error status (integer).
22+
23+
DESCRIPTION
24+
-----------
25+
26+
Removes a user-created error code associated with *errorcode*.
27+
It is erroneous to call :ref:`MPI_Remove_error_code` with a value for
28+
*errorcode* that was not added by a call to :ref:`MPI_Add_error_code`.
29+
It is erroneous to remove an error code when its associated error string has
30+
not been removed before.
31+
32+
ERRORS
33+
------
34+
35+
.. include:: ./ERRORS.rst
36+
37+
.. seealso::
38+
* :ref:`MPI_Add_error_code`
39+
* :ref:`MPI_Remove_error_class`
40+
* :ref:`MPI_Remove_error_string`
41+
* :ref:`MPI_Error_class`
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
.. _mpi_remove_error_string:
2+
3+
4+
MPI_Remove_error_string
5+
=======================
6+
7+
.. include_body
8+
9+
:ref:`MPI_Remove_error_string` |mdash| Removes the error string associated with
10+
a user-created error code.
11+
12+
.. The following file was automatically generated
13+
.. include:: ./bindings/mpi_remove_error_string.rst
14+
15+
INPUT PARAMETERS
16+
----------------
17+
* ``errorcode``: MPI error code, returned by an MPI routine (integer).
18+
19+
OUTPUT PARAMETER
20+
----------------
21+
* ``ierror``: Fortran only: Error status (integer).
22+
23+
DESCRIPTION
24+
-----------
25+
26+
This routine removes an error string associated with a user-created error code.
27+
It is erroneous to call :ref:`MPI_Remove_error_string` with a value for *errorcode*
28+
that does not have an error string added by a call to :ref:`MPI_Add_error_string`.
29+
30+
ERRORS
31+
------
32+
33+
.. include:: ./ERRORS.rst
34+
35+
.. seealso::
36+
* :ref:`MPI_Add_error_string`
37+
* :ref:`MPI_Remove_error_class`
38+
* :ref:`MPI_Remove_error_code`
39+
* :ref:`MPI_Error_class`
40+
* :ref:`MPI_Error_string`

docs/man-openmpi/man3/index.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,9 @@ MPI API manual pages (section 3)
312312
MPI_Reduce_scatter_block_init.3.rst
313313
MPI_Reduce_scatter_init.3.rst
314314
MPI_Register_datarep.3.rst
315+
MPI_Remove_error_class.3.rst
316+
MPI_Remove_error_code.3.rst
317+
MPI_Remove_error_string.3.rst
315318
MPI_Request_c2f.3.rst
316319
MPI_Request_f2c.3.rst
317320
MPI_Request_free.3.rst

ompi/errhandler/errcode.c

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
* and Technology (RIST). All rights reserved.
2020
* Copyright (c) 2022 Triad National Security, LLC. All rights
2121
* reserved.
22+
* Copyright (c) 2025 UT-Battelle, LLC. All rights reserved.
2223
* $COPYRIGHT$
2324
*
2425
* Additional copyrights may follow
@@ -419,6 +420,90 @@ int ompi_mpi_errnum_add_string(int errnum, const char *errstring, int len)
419420
return OMPI_SUCCESS;
420421
}
421422

423+
int ompi_mpi_errcode_remove(int errnum)
424+
{
425+
int ret = OMPI_ERROR;
426+
ompi_mpi_errcode_t *errcodep = NULL;
427+
428+
opal_mutex_lock(&errcode_lock);
429+
430+
errcodep = (ompi_mpi_errcode_t *)opal_pointer_array_get_item(&ompi_mpi_errcodes, errnum);
431+
if ( NULL == errcodep ) {
432+
opal_mutex_unlock(&errcode_lock);
433+
return OMPI_ERROR;
434+
}
435+
436+
/* Must have already removed estring before remove error code */
437+
if (errcodep->errstring[0] == '\0') {
438+
if (MPI_UNDEFINED != errcodep->code) {
439+
ret = opal_pointer_array_set_item(&ompi_mpi_errcodes, errnum, NULL);
440+
if (OPAL_SUCCESS == ret) {
441+
if (errnum == ompi_mpi_errcode_lastused) {
442+
ompi_mpi_errcode_lastused--;
443+
}
444+
}
445+
}
446+
}
447+
448+
opal_mutex_unlock(&errcode_lock);
449+
450+
return ret;
451+
}
452+
453+
int ompi_mpi_errclass_remove(int errclass)
454+
{
455+
int ret = OMPI_ERROR;
456+
ompi_mpi_errcode_t *errcodep = NULL;
457+
458+
opal_mutex_lock(&errcode_lock);
459+
460+
errcodep = (ompi_mpi_errcode_t *)opal_pointer_array_get_item(&ompi_mpi_errcodes, errclass);
461+
if ( NULL == errcodep ) {
462+
opal_mutex_unlock(&errcode_lock);
463+
return OMPI_ERROR;
464+
}
465+
466+
/* Must have already removed estring before remove error class */
467+
if (errcodep->errstring[0] == '\0') {
468+
/* Must have already removed ecode before remove error class */
469+
if (MPI_UNDEFINED == errcodep->code) {
470+
if (MPI_UNDEFINED != errcodep->cls) {
471+
ret = opal_pointer_array_set_item(&ompi_mpi_errcodes, errcodep->cls, NULL);
472+
if (OPAL_SUCCESS == ret) {
473+
if (errclass == ompi_mpi_errcode_lastused) {
474+
ompi_mpi_errcode_lastused--;
475+
}
476+
}
477+
}
478+
}
479+
}
480+
481+
opal_mutex_unlock(&errcode_lock);
482+
483+
return ret;
484+
}
485+
486+
int ompi_mpi_errnum_remove_string(int errnum)
487+
{
488+
ompi_mpi_errcode_t *errcodep = NULL;
489+
490+
opal_mutex_lock(&errcode_lock);
491+
492+
errcodep = (ompi_mpi_errcode_t *)opal_pointer_array_get_item(&ompi_mpi_errcodes, errnum);
493+
if ( NULL == errcodep ) {
494+
opal_mutex_unlock(&errcode_lock);
495+
return OMPI_ERROR;
496+
}
497+
498+
if (errcodep->errstring[0] != '\0') {
499+
memset ( errcodep->errstring, 0, MPI_MAX_ERROR_STRING);
500+
}
501+
502+
opal_mutex_unlock(&errcode_lock);
503+
504+
return OMPI_SUCCESS;
505+
}
506+
422507
static void ompi_mpi_errcode_construct(ompi_mpi_errcode_t *errcode)
423508
{
424509
errcode->code = MPI_UNDEFINED;

ompi/errhandler/errcode.h

Lines changed: 32 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,38 @@ int ompi_mpi_errclass_add (void);
110110
*/
111111
int ompi_mpi_errnum_add_string (int errnum, const char* string, int len);
112112

113+
/**
114+
* Remove an error code
115+
*
116+
* @param: error code to be removed
117+
*
118+
* @returns OMPI_SUCCESS on success
119+
* @returns OMPI_ERROR otherwise
120+
*
121+
*/
122+
int ompi_mpi_errcode_remove (int errcode);
123+
124+
/**
125+
* Remove an error class
126+
*
127+
* @param: none
128+
*
129+
* @returns OMPI_SUCCESS on success
130+
* @returns OMPI_ERROR otherwise
131+
*
132+
*/
133+
int ompi_mpi_errclass_remove (int errclass);
134+
135+
/**
136+
* Remove an error string to an error code
137+
*
138+
* @param: error code for which the string is defined
139+
*
140+
* @returns OMPI_SUCCESS on success
141+
* @returns OMPI_ERROR on error
142+
*/
143+
int ompi_mpi_errnum_remove_string (int errnum);
144+
113145
/**
114146
* Check for a valid error code
115147
*/
@@ -217,49 +249,6 @@ static inline char* ompi_mpi_errnum_get_string (int errnum)
217249
}
218250

219251

220-
/**
221-
* Initialize the error codes
222-
*
223-
* @returns OMPI_SUCCESS Upon success
224-
* @returns OMPI_ERROR Otherwise
225-
*
226-
* Invoked from ompi_mpi_init(); sets up all static MPI error codes,
227-
*/
228-
int ompi_mpi_errcode_init(void);
229-
230-
/**
231-
* Add an error code
232-
*
233-
* @param: error class to which this new error code belongs to
234-
*
235-
* @returns the new error code on SUCCESS (>0)
236-
* @returns OMPI_ERROR otherwise
237-
*
238-
*/
239-
int ompi_mpi_errcode_add (int errclass);
240-
241-
/**
242-
* Add an error class
243-
*
244-
* @param: none
245-
*
246-
* @returns the new error class on SUCCESS (>0)
247-
* @returns OMPI_ERROR otherwise
248-
*
249-
*/
250-
int ompi_mpi_errclass_add (void);
251-
252-
/**
253-
* Add an error string to an error code
254-
*
255-
* @param: error code for which the string is defined
256-
* @param: error string to add
257-
* @param: length of the string
258-
*
259-
* @returns OMPI_SUCCESS on success
260-
* @returns OMPI_ERROR on error
261-
*/
262-
int ompi_mpi_errnum_add_string (int errnum, const char* string, int len);
263252

264253
END_C_DECLS
265254

ompi/include/mpi.h.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
* reserved.
3030
* Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved
3131
* Copyright (c) 2025 Jeffrey M. Squyres. All rights reserved.
32+
* Copyright (c) 2025 UT-Battelle, LLC. All rights reserved.
3233
* $COPYRIGHT$
3334
*
3435
* Additional copyrights may follow
@@ -2246,6 +2247,9 @@ OMPI_DECLSPEC int MPI_Register_datarep_c(const char *datarep,
22462247
MPI_Datarep_conversion_function_c *write_conversion_fn,
22472248
MPI_Datarep_extent_function *dtype_file_extent_fn,
22482249
void *extra_state);
2250+
OMPI_DECLSPEC int MPI_Remove_error_class(int errorclass);
2251+
OMPI_DECLSPEC int MPI_Remove_error_code(int errorcode);
2252+
OMPI_DECLSPEC int MPI_Remove_error_string(int errorcode);
22492253
OMPI_DECLSPEC MPI_Fint MPI_Request_c2f(MPI_Request request);
22502254
OMPI_DECLSPEC MPI_Request MPI_Request_f2c(MPI_Fint request);
22512255
OMPI_DECLSPEC int MPI_Request_free(MPI_Request *request);
@@ -3419,6 +3423,9 @@ OMPI_DECLSPEC int PMPI_Register_datarep_c(const char *datarep,
34193423
MPI_Datarep_conversion_function_c *write_conversion_fn,
34203424
MPI_Datarep_extent_function *dtype_file_extent_fn,
34213425
void *extra_state);
3426+
OMPI_DECLSPEC int PMPI_Remove_error_class(int errorclass);
3427+
OMPI_DECLSPEC int PMPI_Remove_error_code(int errorcode);
3428+
OMPI_DECLSPEC int PMPI_Remove_error_string(int errorcode);
34223429
OMPI_DECLSPEC MPI_Fint PMPI_Request_c2f(MPI_Request request);
34233430
OMPI_DECLSPEC MPI_Request PMPI_Request_f2c(MPI_Fint request);
34243431
OMPI_DECLSPEC int PMPI_Request_free(MPI_Request *request);

ompi/mpi/c/Makefile.am

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# reserved.
2222
# Copyright (c) 2025 Advanced Micro Devices, Inc. All Rights reserved.
2323
# Copyright (c) 2025 Triad National Security, LLC. All rights reserved.
24+
# Copyright (c) 2025 UT-Battelle, LLC. All rights reserved.
2425
# $COPYRIGHT$
2526
#
2627
# Additional copyrights may follow
@@ -351,6 +352,9 @@ prototype_sources = \
351352
register_datarep.c.in \
352353
request_c2f.c.in \
353354
request_f2c.c.in \
355+
remove_error_class.c.in \
356+
remove_error_code.c.in \
357+
remove_error_string.c.in \
354358
request_free.c.in \
355359
request_get_status.c.in \
356360
request_get_status_all.c.in \

0 commit comments

Comments
 (0)