Skip to content

Commit 28590f8

Browse files
committed
sessions: add missing errhandler funcs
somehow managed to not get into the original sessions pr. also do some cleanup of the use mpi_f08 profiling functions. Related to open-mpi#10388 Signed-off-by: Howard Pritchard <[email protected]>
1 parent 528ff5d commit 28590f8

37 files changed

+961
-137
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
.. _mpi_session_call_errhandler:
2+
3+
MPI_Session_call_errhandler
4+
========================
5+
6+
.. include_body
7+
8+
:ref:`MPI_Session_call_errhandler` - Passes the supplied error code to the error
9+
handler assigned to a session
10+
11+
Syntax
12+
------
13+
14+
C Syntax
15+
^^^^^^^^
16+
17+
.. code:: c
18+
19+
#include <mpi.h>
20+
21+
int MPI_Session_call_errhandler(MPI_Session session, int errorcode)
22+
23+
Fortran Syntax
24+
^^^^^^^^^^^^^^
25+
26+
.. code:: Fortran
27+
28+
USE MPI
29+
! or the older form: INCLUDE 'mpif.h'
30+
31+
MPI_SESSION_CALL_ERRHANDLER(SESSION, ERRORCODE, IERROR)
32+
INTEGER SESSION, ERRORCODE, IERROR
33+
34+
Fortran 2008 Syntax
35+
^^^^^^^^^^^^^^^^^^^
36+
37+
.. code:: Fortran
38+
39+
USE mpi_f08
40+
41+
MPI_Session_call_errhandler(session, errorcode, ierror)
42+
TYPE(MPI_Session), INTENT(IN) :: session
43+
INTEGER, INTENT(IN) :: errorcode
44+
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
45+
46+
Input Parameter
47+
---------------
48+
49+
- session : session with error handler (handle).
50+
- errorcode : error code (integer).
51+
52+
Output Parameters
53+
-----------------
54+
55+
- IERROR : Fortran only: Error status (integer).
56+
57+
Description
58+
-----------
59+
60+
This function invokes the error handler assigned to the session
61+
session with the supplied error code errorcode. If the error handler was
62+
successfully called, the process is not aborted, and the error handler
63+
returns, this function returns MPI_SUCCESS.
64+
65+
Notes
66+
-----
67+
68+
Users should note that the default error handler is
69+
MPI_ERRORS_ARE_FATAL. Thus, calling this function will abort the
70+
processes in session if the default error handler has not been changed.
71+
72+
Errors
73+
------
74+
75+
Almost all MPI routines return an error value; C routines as the value
76+
of the function and Fortran routines in the last argument. See the MPI
77+
man page for a full list of MPI error codes.
78+
79+
80+
.. seealso:: :ref:`MPI_Session_create_errhandler`
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
.. _mpi_session_set_errhandler:
2+
3+
4+
MPI_Session_set_errhandler
5+
=======================
6+
7+
.. include_body
8+
9+
:ref:`MPI_Session_set_errhandler` - Attaches a new error handler to a
10+
session.
11+
12+
13+
SYNTAX
14+
------
15+
16+
17+
C Syntax
18+
^^^^^^^^
19+
20+
.. code-block:: c
21+
22+
#include <mpi.h>
23+
24+
int MPI_Session_set_errhandler(MPI_Session session,
25+
MPI_Errhandler errhandler)
26+
27+
28+
Fortran Syntax
29+
^^^^^^^^^^^^^^
30+
31+
.. code-block:: fortran
32+
33+
USE MPI
34+
! or the older form: INCLUDE 'mpif.h'
35+
MPI_SESSION_SET_ERRHANDLER(SESSION, ERRHANDLER, IERROR)
36+
INTEGER SESSION, ERRHANDLER, IERROR
37+
38+
39+
Fortran 2008 Syntax
40+
^^^^^^^^^^^^^^^^^^^
41+
42+
.. code-block:: fortran
43+
44+
USE mpi_f08
45+
MPI_Session_set_errhandler(session, errhandler, ierror)
46+
TYPE(MPI_Session), INTENT(IN) :: session
47+
TYPE(MPI_Errhandler), INTENT(IN) :: errhandler
48+
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
49+
50+
51+
INPUT/OUTPUT PARAMETER
52+
----------------------
53+
* ``session``: Session (handle).
54+
55+
OUTPUT PARAMETERS
56+
-----------------
57+
* ``errhandler``: New error handler for session (handle).
58+
* ``IERROR``: Fortran only: Error status (integer).
59+
60+
DESCRIPTION
61+
-----------
62+
63+
:ref:`MPI_Session_set_errhandler` attaches a new error handler to a session.
64+
The error handler must be either a predefined error handler or an error
65+
handler created by a call to :ref:`MPI_Session_create_errhandler`.
66+
67+
68+
ERRORS
69+
------
70+
71+
Almost all MPI routines return an error value; C routines as the value
72+
of the function and Fortran routines in the last argument.
73+
74+
Before the error value is returned, the current MPI error handler is
75+
called. By default, this error handler aborts the MPI job, except for
76+
I/O function errors. The error handler may be changed with
77+
:ref:`MPI_Session_set_errhandler`; the predefined error handler MPI_ERRORS_RETURN
78+
may be used to cause error values to be returned. Note that MPI does not
79+
guarantee that an MPI program can continue past an error.

docs/man-openmpi/man3/index.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,14 +320,17 @@ MPI API manual pages (section 3)
320320
MPI_Send_init.3.rst
321321
MPI_Sendrecv.3.rst
322322
MPI_Sendrecv_replace.3.rst
323+
MPI_Session_call_errhandler.3.rst
323324
MPI_Session_create_errhandler.3.rst
324325
MPI_Session_f2c.3.rst
325326
MPI_Session_finalize.3.rst
327+
MPI_Session_get_errhandler.3.rst
326328
MPI_Session_get_info.3.rst
327329
MPI_Session_get_nth_pset.3.rst
328330
MPI_Session_get_num_psets.3.rst
329331
MPI_Session_get_pset_info.3.rst
330332
MPI_Session_init.3.rst
333+
MPI_Session_set_errhandler.3.rst
331334
MPI_Sizeof.3.rst
332335
MPI_Ssend.3.rst
333336
MPI_Ssend_init.3.rst

ompi/include/mpi.h.in

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* reserved.
2727
* Copyright (c) 2021 Bull S.A.S. All rights reserved.
2828
* Copyright (c) 2018 Triad National Security, LLC. All rights
29-
* Copyright (c) 2018-2021 Triad National Security, LLC. All rights
29+
* Copyright (c) 2018-2022 Triad National Security, LLC. All rights
3030
* reserved.
3131
* $COPYRIGHT$
3232
*
@@ -513,7 +513,6 @@ typedef int (MPI_Type_delete_attr_function)(MPI_Datatype, int,
513513
typedef int (MPI_Win_copy_attr_function)(MPI_Win, int, void *,
514514
void *, void *, int *);
515515
typedef int (MPI_Win_delete_attr_function)(MPI_Win, int, void *, void *);
516-
typedef int (MPI_Session_delete_attr_function)(MPI_Session, int, void *, void *);
517516
typedef int (MPI_Grequest_query_function)(void *, MPI_Status *);
518517
typedef int (MPI_Grequest_free_function)(void *);
519518
typedef int (MPI_Grequest_cancel_function)(void *, int);
@@ -1939,16 +1938,19 @@ OMPI_DECLSPEC int MPI_Sendrecv_replace(void * buf, int count, MPI_Datatype data
19391938
int dest, int sendtag, int source, int recvtag,
19401939
MPI_Comm comm, MPI_Status *status);
19411940
OMPI_DECLSPEC MPI_Fint MPI_Session_c2f (const MPI_Session session);
1941+
OMPI_DECLSPEC int MPI_Session_call_errhandler(MPI_Session session, int errorcode);
19421942
OMPI_DECLSPEC int MPI_Session_create_errhandler (MPI_Session_errhandler_function *session_errhandler_fn,
19431943
MPI_Errhandler *errhandler);
19441944
OMPI_DECLSPEC int MPI_Session_finalize (MPI_Session *session);
1945+
OMPI_DECLSPEC int MPI_Session_get_errhandler(MPI_Session session, MPI_Errhandler *erhandler);
19451946
OMPI_DECLSPEC int MPI_Session_get_info (MPI_Session session, MPI_Info *info_used);
19461947
OMPI_DECLSPEC int MPI_Session_get_num_psets (MPI_Session session, MPI_Info info, int *npset_names);
19471948
OMPI_DECLSPEC int MPI_Session_get_nth_pset (MPI_Session session, MPI_Info info, int n, int *len, char *pset_name);
19481949
OMPI_DECLSPEC int MPI_Session_get_pset_info (MPI_Session session, const char *pset_name, MPI_Info *info_used);
19491950
OMPI_DECLSPEC int MPI_Session_init (MPI_Info info, MPI_Errhandler errhandler,
19501951
MPI_Session *session);
19511952
OMPI_DECLSPEC MPI_Session MPI_Session_f2c (MPI_Fint session);
1953+
OMPI_DECLSPEC int MPI_Session_set_errhandler(MPI_Session session, MPI_Errhandler errhandler);
19521954
OMPI_DECLSPEC int MPI_Session_set_info (MPI_Session session, MPI_Info info);
19531955
OMPI_DECLSPEC int MPI_Ssend_init(const void *buf, int count, MPI_Datatype datatype,
19541956
int dest, int tag, MPI_Comm comm,
@@ -2700,16 +2702,19 @@ OMPI_DECLSPEC int PMPI_Sendrecv_replace(void * buf, int count, MPI_Datatype dat
27002702
int dest, int sendtag, int source, int recvtag,
27012703
MPI_Comm comm, MPI_Status *status);
27022704
OMPI_DECLSPEC MPI_Fint PMPI_Session_c2f (const MPI_Session session);
2705+
OMPI_DECLSPEC int PMPI_Session_call_errhandler(MPI_Session session, int errorcode);
27032706
OMPI_DECLSPEC int PMPI_Session_create_errhandler (MPI_Session_errhandler_function *session_errhandler_fn,
27042707
MPI_Errhandler *errhandler);
27052708
OMPI_DECLSPEC int PMPI_Session_finalize (MPI_Session *session);
2709+
OMPI_DECLSPEC int PMPI_Session_get_errhandler(MPI_Session session, MPI_Errhandler *erhandler);
27062710
OMPI_DECLSPEC int PMPI_Session_get_info (MPI_Session session, MPI_Info *info_used);
27072711
OMPI_DECLSPEC int PMPI_Session_get_num_psets (MPI_Session session, MPI_Info info, int *npset_names);
27082712
OMPI_DECLSPEC int PMPI_Session_get_nth_pset (MPI_Session session, MPI_Info info, int n, int *len, char *pset_name);
27092713
OMPI_DECLSPEC int PMPI_Session_get_pset_info (MPI_Session session, const char *pset_name, MPI_Info *info_used);
27102714
OMPI_DECLSPEC int PMPI_Session_init (MPI_Info info, MPI_Errhandler errhandler,
27112715
MPI_Session *session);
27122716
OMPI_DECLSPEC MPI_Session PMPI_Session_f2c (MPI_Fint session);
2717+
OMPI_DECLSPEC int PMPI_Session_set_errhandler(MPI_Session session, MPI_Errhandler erhandler);
27132718
OMPI_DECLSPEC int PMPI_Session_set_info (MPI_Session session, MPI_Info info);
27142719
OMPI_DECLSPEC int PMPI_Ssend_init(const void *buf, int count, MPI_Datatype datatype,
27152720
int dest, int tag, MPI_Comm comm,

ompi/mpi/c/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,13 +370,15 @@ interface_profile_sources = \
370370
sendrecv_replace.c \
371371
session_c2f.c \
372372
session_create_errhandler.c \
373+
session_get_errhandler.c \
373374
session_get_info.c \
374375
session_get_num_psets.c \
375376
session_get_nth_pset.c \
376377
session_get_pset_info.c \
377378
session_init.c \
378379
session_f2c.c \
379380
session_finalize.c \
381+
session_set_errhandler.c \
380382
session_set_info.c \
381383
ssend_init.c \
382384
ssend.c \

ompi/mpi/c/session_call_errhandler.c

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
3+
* University Research and Technology
4+
* Corporation. All rights reserved.
5+
* Copyright (c) 2004-2020 The University of Tennessee and The University
6+
* of Tennessee Research Foundation. All rights
7+
* reserved.
8+
* Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
9+
* University of Stuttgart. All rights reserved.
10+
* Copyright (c) 2004-2005 The Regents of the University of California.
11+
* All rights reserved.
12+
* Copyright (c) 2015 Research Organization for Information Science
13+
* and Technology (RIST). All rights reserved.
14+
* Copyright (c) 2022 Triad National Security, LLC. All rights
15+
* reserved.
16+
* $COPYRIGHT$
17+
*
18+
* Additional copyrights may follow
19+
*
20+
* $HEADER$
21+
*/
22+
#include "ompi_config.h"
23+
#include <stdio.h>
24+
25+
#include "ompi/mpi/c/bindings.h"
26+
#include "ompi/runtime/params.h"
27+
#include "ompi/sessionunicator/sessionunicator.h"
28+
#include "ompi/errhandler/errhandler.h"
29+
#include "ompi/memchecker.h"
30+
31+
#if OMPI_BUILD_MPI_PROFILING
32+
#if OPAL_HAVE_WEAK_SYMBOLS
33+
#pragma weak MPI_Session_call_errhandler = PMPI_Session_call_errhandler
34+
#endif
35+
#define MPI_Session_call_errhandler PMPI_Session_call_errhandler
36+
#endif
37+
38+
39+
static const char FUNC_NAME[] = "MPI_Session_call_errhandler";
40+
41+
42+
int MPI_Session_call_errhandler(MPI_Session session, int errorcode)
43+
{
44+
/* Error checking */
45+
46+
if (MPI_PARAM_CHECK) {
47+
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
48+
if (NULL == session) {
49+
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_ARG, FUNC_NAME);
50+
}
51+
}
52+
53+
/* Invoke the errhandler */
54+
55+
OMPI_ERRHANDLER_INVOKE(session, errorcode, FUNC_NAME);
56+
57+
return MPI_SUCCESS;
58+
}
59+

ompi/mpi/c/session_get_errhandler.c

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2+
/*
3+
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
4+
* University Research and Technology
5+
* Corporation. All rights reserved.
6+
* Copyright (c) 2004-2020 The University of Tennessee and The University
7+
* of Tennessee Research Foundation. All rights
8+
* reserved.
9+
* Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
10+
* University of Stuttgart. All rights reserved.
11+
* Copyright (c) 2004-2005 The Regents of the University of California.
12+
* All rights reserved.
13+
* Copyright (c) 2007-2009 Cisco Systems, Inc. All rights reserved.
14+
* Copyright (c) 2015-2017 Research Organization for Information Science
15+
* and Technology (RIST). All rights reserved.
16+
* Copyright (c) 2016-2017 Los Alamos National Security, LLC. All rights
17+
* reserved.
18+
* Copyright (c) 2022 Triad National Security, LLC. All rights
19+
* reserved.
20+
* $COPYRIGHT$
21+
*
22+
* Additional copyrights may follow
23+
*
24+
* $HEADER$
25+
*/
26+
#include "ompi_config.h"
27+
#include <stdio.h>
28+
29+
#include "ompi/mpi/c/bindings.h"
30+
#include "ompi/runtime/params.h"
31+
#include "ompi/errhandler/errhandler.h"
32+
#include "ompi/instance/instance.h"
33+
34+
#if OMPI_BUILD_MPI_PROFILING
35+
#if OPAL_HAVE_WEAK_SYMBOLS
36+
#pragma weak MPI_Session_get_errhandler = PMPI_Session_get_errhandler
37+
#endif
38+
#define MPI_Session_get_errhandler PMPI_Session_get_errhandler
39+
#endif
40+
41+
42+
static const char FUNC_NAME[] = "MPI_Session_get_errhandler";
43+
44+
45+
int MPI_Session_get_errhandler(MPI_Session session, MPI_Errhandler *errhandler)
46+
{
47+
int ret = MPI_SUCCESS;
48+
49+
/* Error checking */
50+
51+
if (MPI_PARAM_CHECK) {
52+
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
53+
if (NULL == session) {
54+
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_ARG, FUNC_NAME);
55+
}
56+
}
57+
58+
#if 0
59+
OPAL_THREAD_LOCK(&(comm->c_lock));
60+
#endif
61+
/* Retain the errhandler, corresponding to object refcount decrease
62+
in errhandler_free.c. */
63+
OBJ_RETAIN(session->error_handler);
64+
*errhandler = session->error_handler;
65+
#if 0
66+
OPAL_THREAD_UNLOCK(&(comm->c_lock));
67+
#endif
68+
69+
/* make sure the infrastructure is initialized */
70+
ret = ompi_mpi_instance_retain ();
71+
72+
/* All done */
73+
74+
return ret;
75+
}

0 commit comments

Comments
 (0)