openmpi  3.1.6
About: Open MPI is a high performance Message Passing Interface (MPI) library project combining technologies and resources from several other projects (FT-MPI, LA-MPI, LAM/MPI, and PACX-MPI) in order to build the best MPI library available. 3.x series.
  Fossies Dox: openmpi-3.1.6.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

errhandler.c
Go to the documentation of this file.
1 /* -*- Mode: C; c-basic-offset:4 ; -*- */
2 /*
3  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
4  * University Research and Technology
5  * Corporation. All rights reserved.
6  * Copyright (c) 2004-2017 The University of Tennessee and The University
7  * of Tennessee Research Foundation. All rights
8  * reserved.
9  * Copyright (c) 2004-2005 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) 2008-2012 Cisco Systems, Inc. All rights reserved.
14  * Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
15  * Copyright (c) 2015 Research Organization for Information Science
16  * and Technology (RIST). All rights reserved.
17  * Copyright (c) 2015-2016 Intel, Inc. All rights reserved.
18  * $COPYRIGHT$
19  *
20  * Additional copyrights may follow
21  *
22  * $HEADER$
23  */
24 
25 #include "ompi_config.h"
26 
27 #include <string.h>
28 
30 #include "ompi/win/win.h"
34 #include "opal/mca/pmix/pmix.h"
35 
36 
37 /*
38  * Table for Fortran <-> C errhandler handle conversion
39  */
41 
42 /*
43  * default errhandler id
44  */
45 static size_t default_errhandler_id = SIZE_MAX;
46 
47 /*
48  * Class information
49  */
52 
53 
54 /*
55  * Class instance
56  */
59 
60 
61 /*
62  * _addr flavors are for F03 bindings
63  */
76 
77 
78 /*
79  * Initialize OMPI errhandler infrastructure
80  */
82 {
83  /* initialize ompi_errhandler_f_to_c_table */
84 
87  OMPI_FORTRAN_HANDLE_MAX, 16) ) {
88  return OMPI_ERROR;
89  }
90 
91  /* Initialize the predefined error handlers */
94  return OMPI_ERROR;
101  strncpy (ompi_mpi_errhandler_null.eh.eh_name, "MPI_ERRHANDLER_NULL",
102  strlen("MPI_ERRHANDLER_NULL")+1 );
103 
104 
107  return OMPI_ERROR;
114  strncpy (ompi_mpi_errors_are_fatal.eh.eh_name, "MPI_ERRORS_ARE_FATAL",
115  strlen("MPI_ERRORS_ARE_FATAL")+1 );
116 
119  return OMPI_ERROR;
126  strncpy (ompi_mpi_errors_return.eh.eh_name, "MPI_ERRORS_RETURN",
127  strlen("MPI_ERRORS_RETURN")+1 );
128 
129  /* If we're going to use C++, functions will be fixed up during
130  MPI::Init. Note that it is proper to use ERRHANDLER_LANG_C here;
131  the dispatch function is in C (although in libmpi_cxx); the
132  conversion from C handles to C++ handles happens in that dispatch
133  function -- not the errhandler_invoke.c stuff here in libmpi. */
145  strncpy (ompi_mpi_errors_throw_exceptions.eh.eh_name, "MPI_ERRORS_THROW_EXCEPTIONS",
146  strlen("MPI_ERRORS_THROW_EXCEPTIONS")+1 );
147 
148  /* All done */
149 
150  return OMPI_SUCCESS;
151 }
152 
153 
154 /*
155  * Clean up the errorhandler resources
156  */
158 {
163 
164  /* JMS Add stuff here checking for unreleased errorhandlers,
165  similar to communicators, info handles, etc. */
167 
168  /* Remove errhandler F2C table */
169 
171 
172  /* All done */
173 
174  return OMPI_SUCCESS;
175 }
176 
177 
181 {
182  ompi_errhandler_t *new_errhandler;
183 
184  /* Create a new object and ensure that it's valid */
185 
186  new_errhandler = OBJ_NEW(ompi_errhandler_t);
187  if (NULL != new_errhandler) {
188  if (0 > new_errhandler->eh_f_to_c_index) {
189  OBJ_RELEASE(new_errhandler);
190  new_errhandler = NULL;
191  } else {
192 
193  /* We cast the user's callback function to any one of the
194  function pointer types in the union; it doesn't matter which.
195  It only matters that we dereference/use the right member when
196  invoking the callback. */
197 
198  new_errhandler->eh_mpi_object_type = object_type;
199  new_errhandler->eh_lang = lang;
200  switch (object_type ) {
202  new_errhandler->eh_comm_fn = (MPI_Comm_errhandler_function *)func;
203  break;
205  new_errhandler->eh_file_fn = (ompi_file_errhandler_fn *)func;
206  break;
208  new_errhandler->eh_win_fn = (MPI_Win_errhandler_function *)func;
209  break;
210  default:
211  break;
212  }
213 
214  new_errhandler->eh_fort_fn = (ompi_errhandler_fortran_handler_fn_t *)func;
215  }
216  }
217 
218  /* All done */
219 
220  return new_errhandler;
221 }
222 
223 /* registration callback */
225  size_t errhandler_ref,
226  void *cbdata)
227 {
229 
230  default_errhandler_id = errhandler_ref;
231  errtrk->status = status;
232  errtrk->active = false;
233 }
234 
238 void ompi_errhandler_callback(int status,
239  const opal_process_name_t *source,
240  opal_list_t *info, opal_list_t *results,
242  void *cbdata)
243 {
244  /* tell the event chain engine to go no further - we
245  * will handle this */
246  if (NULL != cbfunc) {
248  }
249  /* our default action is to abort */
250  ompi_mpi_abort(MPI_COMM_WORLD, status);
251 }
252 
253 
262 static void ompi_errhandler_construct(ompi_errhandler_t *new_errhandler)
263 {
264  int ret_val;
265 
266  /* assign entry in fortran <-> c translation array */
267 
269  new_errhandler);
270  new_errhandler->eh_f_to_c_index = ret_val;
271 
272  new_errhandler->eh_lang = OMPI_ERRHANDLER_LANG_C;
273 
274  new_errhandler->eh_comm_fn = NULL;
275  new_errhandler->eh_win_fn = NULL;
276  new_errhandler->eh_file_fn = NULL;
277  new_errhandler->eh_fort_fn = NULL;
278 
279  new_errhandler->eh_cxx_dispatch_fn = NULL;
280 
281  memset (new_errhandler->eh_name, 0, MPI_MAX_OBJECT_NAME);
282 }
283 
284 
289 {
290  /* reset the ompi_errhandler_f_to_c_table entry - make sure that the
291  entry is in the table */
292 
294  errhandler->eh_f_to_c_index)) {
296  errhandler->eh_f_to_c_index, NULL);
297  }
298 }
OMPI_ERRHANDLER_NULL_FORTRAN
@ OMPI_ERRHANDLER_NULL_FORTRAN
Definition: errhandler.h:50
ompi_errhandler_finalize
int ompi_errhandler_finalize(void)
Finalize the error handler interface.
Definition: errhandler.c:157
ompi_mpi_errors_return_comm_handler
void ompi_mpi_errors_return_comm_handler(struct ompi_communicator_t **comm, int *error_code,...)
Handler function for MPI_ERRORS_RETURN.
Definition: errhandler_predefined.c:114
OMPI_ERRORS_ARE_FATAL_FORTRAN
@ OMPI_ERRORS_ARE_FATAL_FORTRAN
Definition: errhandler.h:51
ompi_mpi_errors_return_file_handler
void ompi_mpi_errors_return_file_handler(struct ompi_file_t **file, int *error_code,...)
Definition: errhandler_predefined.c:126
OBJ_CONSTRUCT
#define OBJ_CONSTRUCT(object, type)
Construct (initialize) objects that are not dynamically allocated.
Definition: opal_object.h:356
strncpy
#define strncpy
Definition: strncpy.h:33
OBJ_CLASS_INSTANCE
OBJ_CLASS_INSTANCE(ompi_errhandler_t, opal_object_t, ompi_errhandler_construct, ompi_errhandler_destruct)
info
static output_desc_t info[64]
Definition: output.c:114
ompi_errhandler_fortran_handler_fn_t
void() ompi_errhandler_fortran_handler_fn_t(ompi_fortran_integer_t *, ompi_fortran_integer_t *,...)
Typedef for all fortran errhandler functions.
Definition: errhandler.h:59
ompi_errhandler_create
ompi_errhandler_t * ompi_errhandler_create(ompi_errhandler_type_t object_type, ompi_errhandler_generic_handler_fn_t *func, ompi_errhandler_lang_t lang)
Create a ompi_errhandler_t.
Definition: errhandler.c:178
ompi_mpi_errors_return
ompi_predefined_errhandler_t ompi_mpi_errors_return
Global variable for MPI_ERRORS_RETURN (_addr flavor is for F03 bindings)
Definition: errhandler.c:70
ompi_mpi_errors_are_fatal_comm_handler
void ompi_mpi_errors_are_fatal_comm_handler(struct ompi_communicator_t **comm, int *error_code,...)
Handler function for MPI_ERRORS_ARE_FATAL.
Definition: errhandler_predefined.c:54
opal_pointer_array.h
ompi_errhandler_generic_handler_fn_t
void() ompi_errhandler_generic_handler_fn_t(void *, int *,...)
Typedef for generic errhandler function.
Definition: errhandler.h:65
ompi_errhandler_t::eh_file_fn
ompi_file_errhandler_fn * eh_file_fn
Definition: errhandler.h:120
ompi_mpi_errors_are_fatal_addr
ompi_predefined_errhandler_t * ompi_mpi_errors_are_fatal_addr
Definition: errhandler.c:68
OBJ_DESTRUCT
#define OBJ_DESTRUCT(object)
Destruct (finalize) an object that is not dynamically allocated.
Definition: opal_object.h:388
cbfunc
static void cbfunc(int status, void *cbdata)
Definition: show_help.c:619
ompi_mpi_errors_throw_exceptions
ompi_predefined_errhandler_t ompi_mpi_errors_throw_exceptions
Global variable for MPI::ERRORS_THROW_EXCEPTIONS.
Definition: errhandler.c:73
ompi_errhandler_errtrk_t
Callback function to alert the MPI layer of an error or notification from the internal RTE and/or the...
Definition: errhandler.h:390
ompi_mpi_errors_are_fatal_win_handler
void ompi_mpi_errors_are_fatal_win_handler(struct ompi_win_t **win, int *error_code,...)
Definition: errhandler_predefined.c:96
OMPI_ERRORS_RETURN_FORTRAN
@ OMPI_ERRORS_RETURN_FORTRAN
Definition: errhandler.h:52
OMPI_ERRHANDLER_TYPE_COMM
@ OMPI_ERRHANDLER_TYPE_COMM
Definition: errhandler.h:83
ompi_mpi_errhandler_null_addr
ompi_predefined_errhandler_t * ompi_mpi_errhandler_null_addr
Definition: errhandler.c:65
ompi_errhandler_t::eh_mpi_object_type
ompi_errhandler_type_t eh_mpi_object_type
Definition: errhandler.h:110
ompi_errhandler_t::eh_name
char eh_name[MPI_MAX_OBJECT_NAME]
Definition: errhandler.h:107
opal_pmix
opal_pmix_base_module_t opal_pmix
Definition: pmix_base_frame.c:35
opal_object_t
Base object.
Definition: opal_object.h:194
OMPI_SUCCESS
@ OMPI_SUCCESS
Definition: constants.h:35
errhandler.h
ompi_errhandler_t::eh_cxx_dispatch_fn
ompi_errhandler_cxx_dispatch_fn_t * eh_cxx_dispatch_fn
Definition: errhandler.h:130
ompi_errhandler_callback
void ompi_errhandler_callback(int status, const opal_process_name_t *source, opal_list_t *info, opal_list_t *results, opal_pmix_notification_complete_fn_t cbfunc, void *cbdata)
Default errhandler callback.
Definition: errhandler.c:238
ompi_errhandler_type_t
ompi_errhandler_type_t
Enum used to describe what kind MPI object an error handler is used for.
Definition: errhandler.h:81
ompi_mpi_errors_return_win_handler
void ompi_mpi_errors_return_win_handler(struct ompi_win_t **win, int *error_code,...)
Definition: errhandler_predefined.c:138
ompi_mpi_errors_are_fatal
ompi_predefined_errhandler_t ompi_mpi_errors_are_fatal
Global variable for MPI_ERRORS_ARE_FATAL (_addr flavor is for F03 bindings)
Definition: errhandler.c:67
ompi_errhandler_errtrk_t::status
int status
Definition: errhandler.h:392
ompi_predefined_errhandler_t::eh
struct ompi_errhandler_t eh
Definition: errhandler.h:145
OMPI_ERR_HANDLERS_COMPLETE
@ OMPI_ERR_HANDLERS_COMPLETE
Definition: constants.h:67
ompi_errhandler_t
Back-end type for MPI_Errorhandler.
Definition: errhandler.h:104
OMPI_ERRHANDLER_TYPE_FILE
@ OMPI_ERRHANDLER_TYPE_FILE
Definition: errhandler.h:85
ompi_mpi_errhandler_null
ompi_predefined_errhandler_t ompi_mpi_errhandler_null
Global variable for MPI_ERRHANDLER_NULL (_addr flavor is for F03 bindings)
Definition: errhandler.c:64
opal_pointer_array_set_item
int opal_pointer_array_set_item(opal_pointer_array_t *table, int index, void *value)
Set the value of the dynamic array at a specified location.
Definition: opal_pointer_array.c:271
opal_pmix_base_module_t::deregister_evhandler
opal_pmix_base_module_deregister_fn_t deregister_evhandler
Definition: pmix.h:925
opal_process_name_t
Definition: dss_types.h:46
OBJ_NEW
#define OBJ_NEW(type)
Definition: opal_object.h:272
ompi_mpi_errors_are_fatal_file_handler
void ompi_mpi_errors_are_fatal_file_handler(struct ompi_file_t **file, int *error_code,...)
Definition: errhandler_predefined.c:75
ompi_errhandler_t::eh_f_to_c_index
int eh_f_to_c_index
Definition: errhandler.h:133
OMPI_ERRHANDLER_LANG_C
@ OMPI_ERRHANDLER_LANG_C
Definition: errhandler.h:71
opal_pointer_array_add
int opal_pointer_array_add(opal_pointer_array_t *table, void *ptr)
add a pointer to dynamic pointer table
Definition: opal_pointer_array.c:220
opal_pointer_array_init
int opal_pointer_array_init(opal_pointer_array_t *array, int initial_allocation, int max_size, int block_size)
initialize an array object
Definition: opal_pointer_array.c:178
win.h
ompi_errhandler_errtrk_t::active
volatile bool active
Definition: errhandler.h:391
OPAL_SUCCESS
@ OPAL_SUCCESS
Definition: constants.h:29
ompi_errhandler_construct
static void ompi_errhandler_construct(ompi_errhandler_t *eh)
Static functions.
Definition: errhandler.c:262
ompi_mpi_errors_throw_exceptions_addr
ompi_predefined_errhandler_t * ompi_mpi_errors_throw_exceptions_addr
Definition: errhandler.c:74
default_errhandler_id
static size_t default_errhandler_id
Definition: errhandler.c:45
ompi_errhandler_f_to_c_table
opal_pointer_array_t ompi_errhandler_f_to_c_table
Table for Fortran <-> C errhandler handle conversion.
Definition: errhandler.c:40
pmix.h
ompi_predefined_errhandler_t
Definition: errhandler.h:144
ompi_errhandler_t::eh_fort_fn
ompi_errhandler_fortran_handler_fn_t * eh_fort_fn
Definition: errhandler.h:122
opal_pmix_notification_complete_fn_t
void(* opal_pmix_notification_complete_fn_t)(int status, opal_list_t *results, opal_pmix_op_cbfunc_t cbfunc, void *thiscbdata, void *notification_cbdata)
Definition: pmix_types.h:522
ompi_errhandler_t::eh_comm_fn
MPI_Comm_errhandler_function * eh_comm_fn
Definition: errhandler.h:119
opal_list_t
Definition: opal_list.h:152
opal_pointer_array_t
dynamic pointer array
Definition: opal_pointer_array.h:43
errhandler_predefined.h
ompi_errhandler_destruct
static void ompi_errhandler_destruct(ompi_errhandler_t *eh)
Errhandler destructor.
Definition: errhandler.c:288
OMPI_ERRHANDLER_TYPE_PREDEFINED
@ OMPI_ERRHANDLER_TYPE_PREDEFINED
Definition: errhandler.h:82
OMPI_ERROR
@ OMPI_ERROR
Definition: constants.h:36
opal_pointer_array_get_item
static void * opal_pointer_array_get_item(opal_pointer_array_t *table, int element_index)
Get the value of an element in array.
Definition: opal_pointer_array.h:125
ompi_errhandler_t::eh_win_fn
MPI_Win_errhandler_function * eh_win_fn
Definition: errhandler.h:121
ompi_errhandler_lang_t
ompi_errhandler_lang_t
Enum to denote what language the error handler was created from.
Definition: errhandler.h:70
ompi_errhandler_init
int ompi_errhandler_init(void)
Initialize the error handler interface.
Definition: errhandler.c:81
communicator.h
ompi_config.h
ompi_mpi_abort
int ompi_mpi_abort(struct ompi_communicator_t *comm, int errcode)
Abort the processes of comm.
Definition: ompi_mpi_abort.c:121
ompi_errhandler_registration_callback
void ompi_errhandler_registration_callback(int status, size_t errhandler_ref, void *cbdata)
Definition: errhandler.c:224
ompi_mpi_errors_return_addr
ompi_predefined_errhandler_t * ompi_mpi_errors_return_addr
Definition: errhandler.c:71
ompi_errhandler_t::eh_lang
ompi_errhandler_lang_t eh_lang
Definition: errhandler.h:113
OBJ_RELEASE
#define OBJ_RELEASE(object)
Release an object (by decrementing its reference count).
Definition: opal_object.h:338
NULL
#define NULL
Copyright (C) 2000-2004 by Etnus, LLC.
Definition: ompi_msgq_dll.c:136
OMPI_ERRHANDLER_TYPE_WIN
@ OMPI_ERRHANDLER_TYPE_WIN
Definition: errhandler.h:84