Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,9 @@ OMPI_MAN3 = \
MPI_Reduce_scatter_block_init.3 \
MPI_Reduce_scatter_init.3 \
MPI_Register_datarep.3 \
MPI_Remove_error_class.3 \
MPI_Remove_error_code.3 \
MPI_Remove_error_string.3 \
MPI_Request_c2f.3 \
MPI_Request_f2c.3 \
MPI_Request_free.3 \
Expand Down
41 changes: 41 additions & 0 deletions docs/man-openmpi/man3/MPI_Remove_error_class.3.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
.. _mpi_remove_error_class:


MPI_Remove_error_class
======================

.. include_body

:ref:`MPI_Remove_error_class` |mdash| Removes a user-created error class.

.. The following file was automatically generated
.. include:: ./bindings/mpi_remove_error_class.rst

INPUT PARAMETERS
----------------
* ``errorclass``: New error class (integer).

OUTPUT PARAMETERS
-----------------
* ``ierror``: Fortran only: Error status (integer).

DESCRIPTION
-----------

The function :ref:`MPI_Remove_error_class` removes a user-created error class.
It is erroneous to call :ref:`MPI_Remove_error_class` with a value for
*errorclass* that was not added by a call to :ref:`MPI_Add_error_class`.
It is erroneous to remove an error class when its associated error codes
have not been removed before.

ERRORS
------

.. include:: ./ERRORS.rst

.. seealso::
* :ref:`MPI_Add_error_class`
* :ref:`MPI_Remove_error_code`
* :ref:`MPI_Remove_error_string`
* :ref:`MPI_Error_class`
* :ref:`MPI_Error_string`
41 changes: 41 additions & 0 deletions docs/man-openmpi/man3/MPI_Remove_error_code.3.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
.. _mpi_remove_error_code:


MPI_Remove_error_code
=====================

.. include_body

:ref:`MPI_Remove_error_code` |mdash| Remove a user-created error code associated with
*errorcode*

.. The following file was automatically generated
.. include:: ./bindings/mpi_remove_error_code.rst

INPUT PARAMETER
---------------
* ``errorcode``: MPI error code (integer).

OUTPUT PARAMETERS
-----------------
* ``ierror``: Fortran only: Error status (integer).

DESCRIPTION
-----------

Removes a user-created error code associated with *errorcode*.
It is erroneous to call :ref:`MPI_Remove_error_code` with a value for
*errorcode* that was not added by a call to :ref:`MPI_Add_error_code`.
It is erroneous to remove an error code when its associated error string has
not been removed before.

ERRORS
------

.. include:: ./ERRORS.rst

.. seealso::
* :ref:`MPI_Add_error_code`
* :ref:`MPI_Remove_error_class`
* :ref:`MPI_Remove_error_string`
* :ref:`MPI_Error_class`
40 changes: 40 additions & 0 deletions docs/man-openmpi/man3/MPI_Remove_error_string.3.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.. _mpi_remove_error_string:


MPI_Remove_error_string
=======================

.. include_body

:ref:`MPI_Remove_error_string` |mdash| Removes the error string associated with
a user-created error code.

.. The following file was automatically generated
.. include:: ./bindings/mpi_remove_error_string.rst

INPUT PARAMETERS
----------------
* ``errorcode``: MPI error code, returned by an MPI routine (integer).

OUTPUT PARAMETER
----------------
* ``ierror``: Fortran only: Error status (integer).

DESCRIPTION
-----------

This routine removes an error string associated with a user-created error code.
It is erroneous to call :ref:`MPI_Remove_error_string` with a value for *errorcode*
that does not have an error string added by a call to :ref:`MPI_Add_error_string`.

ERRORS
------

.. include:: ./ERRORS.rst

.. seealso::
* :ref:`MPI_Add_error_string`
* :ref:`MPI_Remove_error_class`
* :ref:`MPI_Remove_error_code`
* :ref:`MPI_Error_class`
* :ref:`MPI_Error_string`
3 changes: 3 additions & 0 deletions docs/man-openmpi/man3/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@ MPI API manual pages (section 3)
MPI_Reduce_scatter_block_init.3.rst
MPI_Reduce_scatter_init.3.rst
MPI_Register_datarep.3.rst
MPI_Remove_error_class.3.rst
MPI_Remove_error_code.3.rst
MPI_Remove_error_string.3.rst
MPI_Request_c2f.3.rst
MPI_Request_f2c.3.rst
MPI_Request_free.3.rst
Expand Down
85 changes: 85 additions & 0 deletions ompi/errhandler/errcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* and Technology (RIST). All rights reserved.
* Copyright (c) 2022 Triad National Security, LLC. All rights
* reserved.
* Copyright (c) 2025 UT-Battelle, LLC. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -419,6 +420,90 @@ int ompi_mpi_errnum_add_string(int errnum, const char *errstring, int len)
return OMPI_SUCCESS;
}

int ompi_mpi_errcode_remove(int errnum)
{
int ret = OMPI_ERROR;
ompi_mpi_errcode_t *errcodep = NULL;

opal_mutex_lock(&errcode_lock);

errcodep = (ompi_mpi_errcode_t *)opal_pointer_array_get_item(&ompi_mpi_errcodes, errnum);
if ( NULL == errcodep ) {
opal_mutex_unlock(&errcode_lock);
return OMPI_ERROR;
}

/* Must have already removed estring before remove error code */
if (errcodep->errstring[0] == '\0') {
if (MPI_UNDEFINED != errcodep->code) {
ret = opal_pointer_array_set_item(&ompi_mpi_errcodes, errnum, NULL);
if (OPAL_SUCCESS == ret) {
if (errnum == ompi_mpi_errcode_lastused) {
ompi_mpi_errcode_lastused--;
}
}
}
}

opal_mutex_unlock(&errcode_lock);

return ret;
}

int ompi_mpi_errclass_remove(int errclass)
{
int ret = OMPI_ERROR;
ompi_mpi_errcode_t *errcodep = NULL;

opal_mutex_lock(&errcode_lock);

errcodep = (ompi_mpi_errcode_t *)opal_pointer_array_get_item(&ompi_mpi_errcodes, errclass);
if ( NULL == errcodep ) {
opal_mutex_unlock(&errcode_lock);
return OMPI_ERROR;
}

/* Must have already removed estring before remove error class */
if (errcodep->errstring[0] == '\0') {
/* Must have already removed ecode before remove error class */
if (MPI_UNDEFINED == errcodep->code) {
if (MPI_UNDEFINED != errcodep->cls) {
ret = opal_pointer_array_set_item(&ompi_mpi_errcodes, errcodep->cls, NULL);
if (OPAL_SUCCESS == ret) {
if (errclass == ompi_mpi_errcode_lastused) {
ompi_mpi_errcode_lastused--;
}
}
}
}
}

opal_mutex_unlock(&errcode_lock);

return ret;
}

int ompi_mpi_errnum_remove_string(int errnum)
{
ompi_mpi_errcode_t *errcodep = NULL;

opal_mutex_lock(&errcode_lock);

errcodep = (ompi_mpi_errcode_t *)opal_pointer_array_get_item(&ompi_mpi_errcodes, errnum);
if ( NULL == errcodep ) {
opal_mutex_unlock(&errcode_lock);
return OMPI_ERROR;
}

if (errcodep->errstring[0] != '\0') {
memset ( errcodep->errstring, 0, MPI_MAX_ERROR_STRING);
}

opal_mutex_unlock(&errcode_lock);

return OMPI_SUCCESS;
}

static void ompi_mpi_errcode_construct(ompi_mpi_errcode_t *errcode)
{
errcode->code = MPI_UNDEFINED;
Expand Down
75 changes: 32 additions & 43 deletions ompi/errhandler/errcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,38 @@ int ompi_mpi_errclass_add (void);
*/
int ompi_mpi_errnum_add_string (int errnum, const char* string, int len);

/**
* Remove an error code
*
* @param: error code to be removed
*
* @returns OMPI_SUCCESS on success
* @returns OMPI_ERROR otherwise
*
*/
int ompi_mpi_errcode_remove (int errcode);

/**
* Remove an error class
*
* @param: none
*
* @returns OMPI_SUCCESS on success
* @returns OMPI_ERROR otherwise
*
*/
int ompi_mpi_errclass_remove (int errclass);

/**
* Remove an error string to an error code
*
* @param: error code for which the string is defined
*
* @returns OMPI_SUCCESS on success
* @returns OMPI_ERROR on error
*/
int ompi_mpi_errnum_remove_string (int errnum);

/**
* Check for a valid error code
*/
Expand Down Expand Up @@ -217,49 +249,6 @@ static inline char* ompi_mpi_errnum_get_string (int errnum)
}


/**
* Initialize the error codes
*
* @returns OMPI_SUCCESS Upon success
* @returns OMPI_ERROR Otherwise
*
* Invoked from ompi_mpi_init(); sets up all static MPI error codes,
*/
int ompi_mpi_errcode_init(void);

/**
* Add an error code
*
* @param: error class to which this new error code belongs to
*
* @returns the new error code on SUCCESS (>0)
* @returns OMPI_ERROR otherwise
*
*/
int ompi_mpi_errcode_add (int errclass);

/**
* Add an error class
*
* @param: none
*
* @returns the new error class on SUCCESS (>0)
* @returns OMPI_ERROR otherwise
*
*/
int ompi_mpi_errclass_add (void);

/**
* Add an error string to an error code
*
* @param: error code for which the string is defined
* @param: error string to add
* @param: length of the string
*
* @returns OMPI_SUCCESS on success
* @returns OMPI_ERROR on error
*/
int ompi_mpi_errnum_add_string (int errnum, const char* string, int len);

END_C_DECLS

Expand Down
7 changes: 7 additions & 0 deletions ompi/include/mpi.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* reserved.
* Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved
* Copyright (c) 2025 Jeffrey M. Squyres. All rights reserved.
* Copyright (c) 2025 UT-Battelle, LLC. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -2246,6 +2247,9 @@ OMPI_DECLSPEC int MPI_Register_datarep_c(const char *datarep,
MPI_Datarep_conversion_function_c *write_conversion_fn,
MPI_Datarep_extent_function *dtype_file_extent_fn,
void *extra_state);
OMPI_DECLSPEC int MPI_Remove_error_class(int errorclass);
OMPI_DECLSPEC int MPI_Remove_error_code(int errorcode);
OMPI_DECLSPEC int MPI_Remove_error_string(int errorcode);
OMPI_DECLSPEC MPI_Fint MPI_Request_c2f(MPI_Request request);
OMPI_DECLSPEC MPI_Request MPI_Request_f2c(MPI_Fint request);
OMPI_DECLSPEC int MPI_Request_free(MPI_Request *request);
Expand Down Expand Up @@ -3419,6 +3423,9 @@ OMPI_DECLSPEC int PMPI_Register_datarep_c(const char *datarep,
MPI_Datarep_conversion_function_c *write_conversion_fn,
MPI_Datarep_extent_function *dtype_file_extent_fn,
void *extra_state);
OMPI_DECLSPEC int PMPI_Remove_error_class(int errorclass);
OMPI_DECLSPEC int PMPI_Remove_error_code(int errorcode);
OMPI_DECLSPEC int PMPI_Remove_error_string(int errorcode);
OMPI_DECLSPEC MPI_Fint PMPI_Request_c2f(MPI_Request request);
OMPI_DECLSPEC MPI_Request PMPI_Request_f2c(MPI_Fint request);
OMPI_DECLSPEC int PMPI_Request_free(MPI_Request *request);
Expand Down
4 changes: 4 additions & 0 deletions ompi/mpi/c/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# reserved.
# Copyright (c) 2025 Advanced Micro Devices, Inc. All Rights reserved.
# Copyright (c) 2025 Triad National Security, LLC. All rights reserved.
# Copyright (c) 2025 UT-Battelle, LLC. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
Expand Down Expand Up @@ -351,6 +352,9 @@ prototype_sources = \
register_datarep.c.in \
request_c2f.c.in \
request_f2c.c.in \
remove_error_class.c.in \
remove_error_code.c.in \
remove_error_string.c.in \
request_free.c.in \
request_get_status.c.in \
request_get_status_all.c.in \
Expand Down
Loading