Skip to content

Commit

Permalink
sessions: add missing errhandler funcs
Browse files Browse the repository at this point in the history
somehow managed to not get into the original sessions pr.
also do some cleanup of the use mpi_f08 profiling functions.

Related to #10388

Related to #9097

Signed-off-by: Howard Pritchard <[email protected]>
  • Loading branch information
hppritcha committed Jun 24, 2022
1 parent 528ff5d commit e5c3795
Show file tree
Hide file tree
Showing 42 changed files with 1,142 additions and 137 deletions.
80 changes: 80 additions & 0 deletions docs/man-openmpi/man3/MPI_Session_call_errhandler.3.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
.. _mpi_session_call_errhandler:

MPI_Session_call_errhandler
===========================

.. include_body
:ref:`MPI_Session_call_errhandler` - Passes the supplied error code to the error
handler assigned to a session

Syntax
------

C Syntax
^^^^^^^^

.. code:: c
#include <mpi.h>
int MPI_Session_call_errhandler(MPI_Session session, int errorcode)
Fortran Syntax
^^^^^^^^^^^^^^

.. code:: Fortran
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_SESSION_CALL_ERRHANDLER(SESSION, ERRORCODE, IERROR)
INTEGER SESSION, ERRORCODE, IERROR
Fortran 2008 Syntax
^^^^^^^^^^^^^^^^^^^

.. code:: Fortran
USE mpi_f08
MPI_Session_call_errhandler(session, errorcode, ierror)
TYPE(MPI_Session), INTENT(IN) :: session
INTEGER, INTENT(IN) :: errorcode
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
Input Parameter
---------------

- session : session with error handler (handle).
- errorcode : error code (integer).

Output Parameters
-----------------

- IERROR : Fortran only: Error status (integer).

Description
-----------

This function invokes the error handler assigned to the session
session with the supplied error code errorcode. If the error handler was
successfully called, the process is not aborted, and the error handler
returns, this function returns MPI_SUCCESS.

Notes
-----

Users should note that the default error handler is
MPI_ERRORS_ARE_FATAL. Thus, calling this function will abort the
processes in session if the default error handler has not been changed.

Errors
------

Almost all MPI routines return an error value; C routines as the value
of the function and Fortran routines in the last argument. See the MPI
man page for a full list of MPI error codes.


.. seealso:: :ref:`MPI_Session_create_errhandler`
80 changes: 80 additions & 0 deletions docs/man-openmpi/man3/MPI_Session_get_errhandler.3.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
.. _mpi_session_get_errhandler:


MPI_Session_get_errhandler
==========================

.. include_body
:ref:`MPI_Session_get_errhandler` - Retrieves error handler associated with a
session.


SYNTAX
------


C Syntax
^^^^^^^^

.. code-block:: c
#include <mpi.h>
int MPI_Session_get_errhandler(MPI_Session session,
MPI_Errhandler *errhandler)
Fortran Syntax
^^^^^^^^^^^^^^

.. code-block:: fortran
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_SESSION_GET_ERRHANDLER(SESSION, ERRHANDLER, IERROR)
INTEGER SESSION, ERRHANDLER, IERROR
Fortran 2008 Syntax
^^^^^^^^^^^^^^^^^^^

.. code-block:: fortran
USE mpi_f08
MPI_Session_get_errhandler(session, errhandler, ierror)
TYPE(MPI_Session), INTENT(IN) :: session
TYPE(MPI_Errhandler), INTENT(OUT) :: errhandler
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
INPUT PARAMETER
---------------
* ``session``: Session (handle).

OUTPUT PARAMETERS
-----------------
* ``errhandler``: New error handler for session (handle).
* ``IERROR``: Fortran only: Error status (integer).

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

:ref:`MPI_Session_get_errhandler` retrieves the error handler currently associated
with a session.


ERRORS
------

Almost all MPI routines return an error value; C routines as the value
of the function and Fortran routines in the last argument.

Before the error value is returned, the current MPI error handler is
called. By default, this error handler aborts the MPI job, except for
I/O function errors. The error handler may be changed with
:ref:`MPI_Session_set_errhandler`; the predefined error handler MPI_ERRORS_RETURN
may be used to cause error values to be returned. Note that MPI does not
guarantee that an MPI program can continue past an error.

See the MPI man page for a full list of MPI error codes.
79 changes: 79 additions & 0 deletions docs/man-openmpi/man3/MPI_Session_set_errhandler.3.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
.. _mpi_session_set_errhandler:


MPI_Session_set_errhandler
==========================

.. include_body
:ref:`MPI_Session_set_errhandler` - Attaches a new error handler to a
session.


SYNTAX
------


C Syntax
^^^^^^^^

.. code-block:: c
#include <mpi.h>
int MPI_Session_set_errhandler(MPI_Session session,
MPI_Errhandler errhandler)
Fortran Syntax
^^^^^^^^^^^^^^

.. code-block:: fortran
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_SESSION_SET_ERRHANDLER(SESSION, ERRHANDLER, IERROR)
INTEGER SESSION, ERRHANDLER, IERROR
Fortran 2008 Syntax
^^^^^^^^^^^^^^^^^^^

.. code-block:: fortran
USE mpi_f08
MPI_Session_set_errhandler(session, errhandler, ierror)
TYPE(MPI_Session), INTENT(IN) :: session
TYPE(MPI_Errhandler), INTENT(IN) :: errhandler
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
INPUT/OUTPUT PARAMETER
----------------------
* ``session``: Session (handle).

OUTPUT PARAMETERS
-----------------
* ``errhandler``: New error handler for session (handle).
* ``IERROR``: Fortran only: Error status (integer).

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

:ref:`MPI_Session_set_errhandler` attaches a new error handler to a session.
The error handler must be either a predefined error handler or an error
handler created by a call to :ref:`MPI_Session_create_errhandler`.


ERRORS
------

Almost all MPI routines return an error value; C routines as the value
of the function and Fortran routines in the last argument.

Before the error value is returned, the current MPI error handler is
called. By default, this error handler aborts the MPI job, except for
I/O function errors. The error handler may be changed with
:ref:`MPI_Session_set_errhandler`; the predefined error handler MPI_ERRORS_RETURN
may be used to cause error values to be returned. Note that MPI does not
guarantee that an MPI program can continue past an error.
3 changes: 3 additions & 0 deletions docs/man-openmpi/man3/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -320,14 +320,17 @@ MPI API manual pages (section 3)
MPI_Send_init.3.rst
MPI_Sendrecv.3.rst
MPI_Sendrecv_replace.3.rst
MPI_Session_call_errhandler.3.rst
MPI_Session_create_errhandler.3.rst
MPI_Session_f2c.3.rst
MPI_Session_finalize.3.rst
MPI_Session_get_errhandler.3.rst
MPI_Session_get_info.3.rst
MPI_Session_get_nth_pset.3.rst
MPI_Session_get_num_psets.3.rst
MPI_Session_get_pset_info.3.rst
MPI_Session_init.3.rst
MPI_Session_set_errhandler.3.rst
MPI_Sizeof.3.rst
MPI_Ssend.3.rst
MPI_Ssend_init.3.rst
Expand Down
9 changes: 7 additions & 2 deletions ompi/include/mpi.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* reserved.
* Copyright (c) 2021 Bull S.A.S. All rights reserved.
* Copyright (c) 2018 Triad National Security, LLC. All rights
* Copyright (c) 2018-2021 Triad National Security, LLC. All rights
* Copyright (c) 2018-2022 Triad National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
Expand Down Expand Up @@ -513,7 +513,6 @@ typedef int (MPI_Type_delete_attr_function)(MPI_Datatype, int,
typedef int (MPI_Win_copy_attr_function)(MPI_Win, int, void *,
void *, void *, int *);
typedef int (MPI_Win_delete_attr_function)(MPI_Win, int, void *, void *);
typedef int (MPI_Session_delete_attr_function)(MPI_Session, int, void *, void *);
typedef int (MPI_Grequest_query_function)(void *, MPI_Status *);
typedef int (MPI_Grequest_free_function)(void *);
typedef int (MPI_Grequest_cancel_function)(void *, int);
Expand Down Expand Up @@ -1939,16 +1938,19 @@ OMPI_DECLSPEC int MPI_Sendrecv_replace(void * buf, int count, MPI_Datatype data
int dest, int sendtag, int source, int recvtag,
MPI_Comm comm, MPI_Status *status);
OMPI_DECLSPEC MPI_Fint MPI_Session_c2f (const MPI_Session session);
OMPI_DECLSPEC int MPI_Session_call_errhandler(MPI_Session session, int errorcode);
OMPI_DECLSPEC int MPI_Session_create_errhandler (MPI_Session_errhandler_function *session_errhandler_fn,
MPI_Errhandler *errhandler);
OMPI_DECLSPEC int MPI_Session_finalize (MPI_Session *session);
OMPI_DECLSPEC int MPI_Session_get_errhandler(MPI_Session session, MPI_Errhandler *erhandler);
OMPI_DECLSPEC int MPI_Session_get_info (MPI_Session session, MPI_Info *info_used);
OMPI_DECLSPEC int MPI_Session_get_num_psets (MPI_Session session, MPI_Info info, int *npset_names);
OMPI_DECLSPEC int MPI_Session_get_nth_pset (MPI_Session session, MPI_Info info, int n, int *len, char *pset_name);
OMPI_DECLSPEC int MPI_Session_get_pset_info (MPI_Session session, const char *pset_name, MPI_Info *info_used);
OMPI_DECLSPEC int MPI_Session_init (MPI_Info info, MPI_Errhandler errhandler,
MPI_Session *session);
OMPI_DECLSPEC MPI_Session MPI_Session_f2c (MPI_Fint session);
OMPI_DECLSPEC int MPI_Session_set_errhandler(MPI_Session session, MPI_Errhandler errhandler);
OMPI_DECLSPEC int MPI_Session_set_info (MPI_Session session, MPI_Info info);
OMPI_DECLSPEC int MPI_Ssend_init(const void *buf, int count, MPI_Datatype datatype,
int dest, int tag, MPI_Comm comm,
Expand Down Expand Up @@ -2700,16 +2702,19 @@ OMPI_DECLSPEC int PMPI_Sendrecv_replace(void * buf, int count, MPI_Datatype dat
int dest, int sendtag, int source, int recvtag,
MPI_Comm comm, MPI_Status *status);
OMPI_DECLSPEC MPI_Fint PMPI_Session_c2f (const MPI_Session session);
OMPI_DECLSPEC int PMPI_Session_call_errhandler(MPI_Session session, int errorcode);
OMPI_DECLSPEC int PMPI_Session_create_errhandler (MPI_Session_errhandler_function *session_errhandler_fn,
MPI_Errhandler *errhandler);
OMPI_DECLSPEC int PMPI_Session_finalize (MPI_Session *session);
OMPI_DECLSPEC int PMPI_Session_get_errhandler(MPI_Session session, MPI_Errhandler *erhandler);
OMPI_DECLSPEC int PMPI_Session_get_info (MPI_Session session, MPI_Info *info_used);
OMPI_DECLSPEC int PMPI_Session_get_num_psets (MPI_Session session, MPI_Info info, int *npset_names);
OMPI_DECLSPEC int PMPI_Session_get_nth_pset (MPI_Session session, MPI_Info info, int n, int *len, char *pset_name);
OMPI_DECLSPEC int PMPI_Session_get_pset_info (MPI_Session session, const char *pset_name, MPI_Info *info_used);
OMPI_DECLSPEC int PMPI_Session_init (MPI_Info info, MPI_Errhandler errhandler,
MPI_Session *session);
OMPI_DECLSPEC MPI_Session PMPI_Session_f2c (MPI_Fint session);
OMPI_DECLSPEC int PMPI_Session_set_errhandler(MPI_Session session, MPI_Errhandler erhandler);
OMPI_DECLSPEC int PMPI_Session_set_info (MPI_Session session, MPI_Info info);
OMPI_DECLSPEC int PMPI_Ssend_init(const void *buf, int count, MPI_Datatype datatype,
int dest, int tag, MPI_Comm comm,
Expand Down
8 changes: 7 additions & 1 deletion ompi/instance/instance.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,16 @@ static void ompi_instance_construct (ompi_instance_t *instance)
instance->i_name[0] = '\0';
instance->i_flags = 0;
instance->i_keyhash = NULL;
OBJ_CONSTRUCT(&instance->s_lock, opal_mutex_t);
instance->errhandler_type = OMPI_ERRHANDLER_TYPE_INSTANCE;
}

OBJ_CLASS_INSTANCE(ompi_instance_t, opal_infosubscriber_t, ompi_instance_construct, NULL);
static void ompi_instance_destruct(ompi_instance_t *instance)
{
OBJ_DESTRUCT(&instance->s_lock);
}

OBJ_CLASS_INSTANCE(ompi_instance_t, opal_infosubscriber_t, ompi_instance_construct, ompi_instance_destruct);

/* NTH: frameworks needed by MPI */
static mca_base_framework_t *ompi_framework_dependencies[] = {
Expand Down
1 change: 1 addition & 0 deletions ompi/instance/instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct ompi_group_t;

struct ompi_instance_t {
opal_infosubscriber_t super;
opal_mutex_t s_lock;
int i_thread_level;
char i_name[MPI_MAX_OBJECT_NAME];
uint32_t i_flags;
Expand Down
3 changes: 3 additions & 0 deletions ompi/mpi/c/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -369,14 +369,17 @@ interface_profile_sources = \
sendrecv.c \
sendrecv_replace.c \
session_c2f.c \
session_call_errhandler.c \
session_create_errhandler.c \
session_get_errhandler.c \
session_get_info.c \
session_get_num_psets.c \
session_get_nth_pset.c \
session_get_pset_info.c \
session_init.c \
session_f2c.c \
session_finalize.c \
session_set_errhandler.c \
session_set_info.c \
ssend_init.c \
ssend.c \
Expand Down
Loading

0 comments on commit e5c3795

Please sign in to comment.