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_invoke.c
Go to the documentation of this file.
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
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-2005 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) 2006-2012 Cisco Systems, Inc. All rights reserved.
14  * Copyright (c) 2012 Oak Ridge National Labs. All rights reserved.
15  * Copyright (c) 2016 Los Alamos National Security, LLC. All rights
16  * reserved.
17  * Copyright (c) 2016 Research Organization for Information Science
18  * and Technology (RIST). All rights reserved.
19  * $COPYRIGHT$
20  *
21  * Additional copyrights may follow
22  *
23  * $HEADER$
24  */
25 
26 #include "ompi_config.h"
27 
29 #include "ompi/win/win.h"
30 #include "ompi/file/file.h"
31 #include "ompi/request/request.h"
34 
35 
36 int ompi_errhandler_invoke(ompi_errhandler_t *errhandler, void *mpi_object,
37  int object_type, int err_code, const char *message)
38 {
39  MPI_Fint fortran_handle, fortran_err_code = OMPI_INT_2_FINT(err_code);
40  ompi_communicator_t *comm;
41  ompi_win_t *win;
42  ompi_file_t *file;
43 
44  /* If we got no errorhandler, then just invoke errors_abort */
45  if (NULL == errhandler) {
47  return err_code;
48  }
49 
50  /* Figure out what kind of errhandler it is, figure out if it's
51  fortran or C, and then invoke it */
52 
53  switch (object_type) {
55  comm = (ompi_communicator_t *) mpi_object;
56  switch (errhandler->eh_lang) {
58  errhandler->eh_comm_fn(&comm, &err_code, message, NULL);
59  break;
60 
62  errhandler->eh_cxx_dispatch_fn(&comm, &err_code, message,
64  break;
65 
67  fortran_handle = OMPI_INT_2_FINT(comm->c_f_to_c_index);
68  errhandler->eh_fort_fn(&fortran_handle, &fortran_err_code);
69  err_code = OMPI_FINT_2_INT(fortran_err_code);
70  break;
71  }
72  break;
73 
75  win = (ompi_win_t *) mpi_object;
76  switch (errhandler->eh_lang) {
78  errhandler->eh_win_fn(&win, &err_code, message, NULL);
79  break;
80 
82  errhandler->eh_cxx_dispatch_fn(&win, &err_code, message,
84  break;
85 
87  fortran_handle = OMPI_INT_2_FINT(win->w_f_to_c_index);
88  errhandler->eh_fort_fn(&fortran_handle, &fortran_err_code);
89  err_code = OMPI_FINT_2_INT(fortran_err_code);
90  break;
91  }
92  break;
93 
95  file = (ompi_file_t *) mpi_object;
96  switch (errhandler->eh_lang) {
98  errhandler->eh_file_fn(&file, &err_code, message, NULL);
99  break;
100 
102  errhandler->eh_cxx_dispatch_fn(&file, &err_code, message,
104  break;
105 
107  fortran_handle = OMPI_INT_2_FINT(file->f_f_to_c_index);
108  errhandler->eh_fort_fn(&fortran_handle, &fortran_err_code);
109  err_code = OMPI_FINT_2_INT(fortran_err_code);
110  break;
111  }
112  break;
113  }
114 
115  /* All done */
116  return err_code;
117 }
118 
119 
121  struct ompi_request_t **requests,
122  const char *message)
123 {
124  int i, ec, type;
125  ompi_mpi_object_t mpi_object;
126 
127  /* Find the *first* request that has an error -- that's the one
128  that we'll invoke the exception on. In an error condition, the
129  request will not have been reset back to MPI_REQUEST_NULL, so
130  there's no need to cache values from before we call
131  ompi_request_test(). */
132  for (i = 0; i < count; ++i) {
133  if (MPI_REQUEST_NULL != requests[i] &&
134  MPI_SUCCESS != requests[i]->req_status.MPI_ERROR) {
135  break;
136  }
137  }
138  /* If there were no errors, return SUCCESS */
139  if (i >= count) {
140  return MPI_SUCCESS;
141  }
142 
143  ec = ompi_errcode_get_mpi_code(requests[i]->req_status.MPI_ERROR);
144  mpi_object = requests[i]->req_mpi_object;
145  type = requests[i]->req_type;
146 
147  /* Since errors on requests cause them to not be freed (until we
148  can examine them here), go through and free all requests with
149  errors. We only invoke the exception on the *first* request
150  that had an error. */
151  for (; i < count; ++i) {
152  if (MPI_REQUEST_NULL != requests[i] &&
153  MPI_SUCCESS != requests[i]->req_status.MPI_ERROR) {
154  /* Ignore the error -- what are we going to do? We're
155  already going to invoke an exception */
157  }
158  }
159 
160  /* Invoke the exception */
161  switch (type) {
162  case OMPI_REQUEST_PML:
163  return ompi_errhandler_invoke(mpi_object.comm->error_handler,
164  mpi_object.comm,
165  mpi_object.comm->errhandler_type,
166  ec, message);
167  break;
168  case OMPI_REQUEST_IO:
169  return ompi_errhandler_invoke(mpi_object.file->error_handler,
170  mpi_object.file,
171  mpi_object.file->errhandler_type,
172  ec, message);
173  break;
174  case OMPI_REQUEST_WIN:
175  return ompi_errhandler_invoke(mpi_object.win->error_handler,
176  mpi_object.win,
177  mpi_object.win->errhandler_type,
178  ec, message);
179  break;
180  default:
181  /* Covers REQUEST_GEN, REQUEST_NULL, REQUEST_MAX */
182  return ompi_errhandler_invoke(MPI_COMM_WORLD->error_handler,
183  MPI_COMM_WORLD,
184  MPI_COMM_WORLD->errhandler_type,
185  ec, message);
186  break;
187  }
188 }
OMPI_ERRHANDLER_LANG_CXX
@ OMPI_ERRHANDLER_LANG_CXX
Definition: errhandler.h:72
ompi_mpi_object_t::file
struct ompi_file_t * file
Definition: request.h:117
MPI_Fint
#define MPI_Fint
OMPI-specific Fortran code that should be in ompi_config.h, but not in the other projects.
Definition: ompi_config.h:41
OMPI_ERRHANDLER_LANG_FORTRAN
@ OMPI_ERRHANDLER_LANG_FORTRAN
Definition: errhandler.h:73
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
ompi_errhandler_invoke
int ompi_errhandler_invoke(ompi_errhandler_t *errhandler, void *mpi_object, int object_type, int err_code, const char *message)
Definition: errhandler_invoke.c:36
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_win_t::error_handler
ompi_errhandler_t * error_handler
Definition: win.h:105
ompi_errhandler_request_invoke
int ompi_errhandler_request_invoke(int count, struct ompi_request_t **requests, const char *message)
Invoke an MPI exception on the first request found in the array that has a non-MPI_SUCCESS value for ...
Definition: errhandler_invoke.c:120
file.h
OMPI_ERRHANDLER_TYPE_COMM
@ OMPI_ERRHANDLER_TYPE_COMM
Definition: errhandler.h:83
ompi_communicator_t
Definition: communicator.h:134
OMPI_REQUEST_IO
@ OMPI_REQUEST_IO
MPI-2 IO request.
Definition: request_dbg.h:24
ompi_mpi_object_t::comm
struct ompi_communicator_t * comm
Definition: request.h:116
errhandler.h
ompi_errhandler_t::eh_cxx_dispatch_fn
ompi_errhandler_cxx_dispatch_fn_t * eh_cxx_dispatch_fn
Definition: errhandler.h:130
requests
static opal_list_t requests
Definition: dfs_app.c:97
OMPI_INT_2_FINT
#define OMPI_INT_2_FINT(a)
Definition: fint_2_int.h:40
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
fint_2_int.h
ompi_request_t
Main top-level request struct definition.
Definition: request.h:124
ompi_file_t::error_handler
struct ompi_errhandler_t * error_handler
Error handler.
Definition: file.h:70
OMPI_ERRHANDLER_LANG_C
@ OMPI_ERRHANDLER_LANG_C
Definition: errhandler.h:71
ompi_mpi_object_t::win
struct ompi_win_t * win
Definition: request.h:118
ompi_win_t::errhandler_type
ompi_errhandler_type_t errhandler_type
Definition: win.h:106
win.h
ompi_win_t::w_f_to_c_index
int w_f_to_c_index
Definition: win.h:100
count
void int count
Definition: op.c:237
ompi_request_free
static int ompi_request_free(ompi_request_t **request)
Free a request.
Definition: request.h:378
OMPI_REQUEST_PML
@ OMPI_REQUEST_PML
MPI point-to-point request.
Definition: request_dbg.h:23
request.h
ompi_file_t
Back-end structure for MPI_File.
Definition: file.h:48
ompi_communicator_t::c_f_to_c_index
int c_f_to_c_index
Definition: communicator.h:169
ompi_errhandler_t::eh_fort_fn
ompi_errhandler_fortran_handler_fn_t * eh_fort_fn
Definition: errhandler.h:122
ompi_errhandler_t::eh_comm_fn
MPI_Comm_errhandler_function * eh_comm_fn
Definition: errhandler.h:119
ompi_errcode_get_mpi_code
static int ompi_errcode_get_mpi_code(int errcode)
Return the MPI errcode for a given internal error code.
Definition: errcode-internal.h:57
OMPI_REQUEST_WIN
@ OMPI_REQUEST_WIN
MPI-2 one-sided request.
Definition: request_dbg.h:26
ompi_file_t::f_f_to_c_index
int f_f_to_c_index
Index in Fortran <-> C translation array.
Definition: file.h:65
ompi_mpi_object_t
Union for holding several different MPI pointer types on the request.
Definition: request.h:115
ompi_errhandler_t::eh_win_fn
MPI_Win_errhandler_function * eh_win_fn
Definition: errhandler.h:121
OMPI_FINT_2_INT
#define OMPI_FINT_2_INT(a)
Definition: fint_2_int.h:41
communicator.h
ompi_config.h
ompi_communicator_t::error_handler
ompi_errhandler_t * error_handler
Definition: communicator.h:182
ompi_errhandler_t::eh_lang
ompi_errhandler_lang_t eh_lang
Definition: errhandler.h:113
ompi_communicator_t::errhandler_type
ompi_errhandler_type_t errhandler_type
Definition: communicator.h:183
ompi_win_t
Definition: win.h:77
NULL
#define NULL
Copyright (C) 2000-2004 by Etnus, LLC.
Definition: ompi_msgq_dll.c:136
ompi_file_t::errhandler_type
ompi_errhandler_type_t errhandler_type
Type of the error handler.
Definition: file.h:74
OMPI_ERRHANDLER_TYPE_WIN
@ OMPI_ERRHANDLER_TYPE_WIN
Definition: errhandler.h:84