root/ompi/errhandler/errhandler_invoke.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. ompi_errhandler_invoke
  2. ompi_errhandler_request_invoke

   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 
  28 #include "ompi/communicator/communicator.h"
  29 #include "ompi/win/win.h"
  30 #include "ompi/file/file.h"
  31 #include "ompi/request/request.h"
  32 #include "ompi/errhandler/errhandler.h"
  33 #include "ompi/mpi/fortran/base/fint_2_int.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) {
  46         ompi_mpi_errors_are_fatal_comm_handler(NULL, NULL, message);
  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) {
  54     case OMPI_ERRHANDLER_TYPE_COMM:
  55         comm = (ompi_communicator_t *) mpi_object;
  56         switch (errhandler->eh_lang) {
  57         case OMPI_ERRHANDLER_LANG_C:
  58             errhandler->eh_comm_fn(&comm, &err_code, message, NULL);
  59             break;
  60 
  61         case OMPI_ERRHANDLER_LANG_CXX:
  62             errhandler->eh_cxx_dispatch_fn(&comm, &err_code, message,
  63                                            (ompi_errhandler_generic_handler_fn_t *)errhandler->eh_comm_fn);
  64             break;
  65 
  66         case OMPI_ERRHANDLER_LANG_FORTRAN:
  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 
  74     case OMPI_ERRHANDLER_TYPE_WIN:
  75         win = (ompi_win_t *) mpi_object;
  76         switch (errhandler->eh_lang) {
  77         case OMPI_ERRHANDLER_LANG_C:
  78             errhandler->eh_win_fn(&win, &err_code, message, NULL);
  79             break;
  80 
  81         case OMPI_ERRHANDLER_LANG_CXX:
  82             errhandler->eh_cxx_dispatch_fn(&win, &err_code, message,
  83                                            (ompi_errhandler_generic_handler_fn_t *)errhandler->eh_win_fn);
  84             break;
  85 
  86         case OMPI_ERRHANDLER_LANG_FORTRAN:
  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 
  94     case OMPI_ERRHANDLER_TYPE_FILE:
  95         file = (ompi_file_t *) mpi_object;
  96         switch (errhandler->eh_lang) {
  97         case OMPI_ERRHANDLER_LANG_C:
  98             errhandler->eh_file_fn(&file, &err_code, message, NULL);
  99             break;
 100 
 101         case OMPI_ERRHANDLER_LANG_CXX:
 102             errhandler->eh_cxx_dispatch_fn(&file, &err_code, message,
 103                                            (ompi_errhandler_generic_handler_fn_t *)errhandler->eh_file_fn);
 104             break;
 105 
 106         case OMPI_ERRHANDLER_LANG_FORTRAN:
 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 
 120 int ompi_errhandler_request_invoke(int count,
 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 */
 156             ompi_request_free(&(requests[i]));
 157         }
 158     }
 159 
 160     /* Invoke the exception */
 161     switch (type) {
 162     case OMPI_REQUEST_PML:
 163     case OMPI_REQUEST_COLL:
 164         return ompi_errhandler_invoke(mpi_object.comm->error_handler,
 165                                       mpi_object.comm,
 166                                       mpi_object.comm->errhandler_type,
 167                                       ec, message);
 168         break;
 169     case OMPI_REQUEST_IO:
 170         return ompi_errhandler_invoke(mpi_object.file->error_handler,
 171                                       mpi_object.file,
 172                                       mpi_object.file->errhandler_type,
 173                                       ec, message);
 174         break;
 175     case OMPI_REQUEST_WIN:
 176         return ompi_errhandler_invoke(mpi_object.win->error_handler,
 177                                       mpi_object.win,
 178                                       mpi_object.win->errhandler_type,
 179                                       ec, message);
 180         break;
 181     default:
 182         /* Covers REQUEST_GEN, REQUEST_NULL, REQUEST_MAX */
 183         return ompi_errhandler_invoke(MPI_COMM_WORLD->error_handler,
 184                                       MPI_COMM_WORLD,
 185                                       MPI_COMM_WORLD->errhandler_type,
 186                                       ec, message);
 187         break;
 188     }
 189 }

/* [<][>][^][v][top][bottom][index][help] */