root/ompi/mca/io/romio321/romio/adio/include/adioi_error.h

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

INCLUDED FROM


   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
   2 /*
   3  *  (C) 2001 by Argonne National Laboratory.
   4  *      See COPYRIGHT in top-level directory.
   5  */
   6 
   7 #include <string.h> /* for strerror() */
   8 
   9 /* MPIO_CHECK_XXX macros are used to clean up error checking and
  10  * handling in many of the romio/mpi-io/ source files.
  11  */
  12 #define MPIO_CHECK_FILE_HANDLE(fh, myname, error_code)          \
  13 if ((fh <= (ADIO_File) 0) ||                                    \
  14     ((fh)->cookie != ADIOI_FILE_COOKIE)) {                      \
  15     error_code = MPIO_Err_create_code(MPI_SUCCESS,              \
  16                                       MPIR_ERR_RECOVERABLE,     \
  17                                       myname, __LINE__,         \
  18                                       MPI_ERR_FILE,             \
  19                                       "**iobadfh", 0);          \
  20     error_code = MPIO_Err_return_file(MPI_FILE_NULL, error_code);\
  21     goto fn_exit;                                               \
  22 }
  23 
  24 /* TODO could add more glue code to help check for handle validity, or perhaps
  25  * do some sort of always-safe attribute/info call to check for handle validity */
  26 #define MPIO_CHECK_COMM(comm_, myname_, error_code_)                          \
  27     do {                                                                      \
  28         if ((comm_) == MPI_COMM_NULL) {                                       \
  29             error_code = MPIO_Err_create_code(MPI_SUCCESS,                    \
  30                                               MPIR_ERR_RECOVERABLE,           \
  31                                               (myname_), __LINE__,            \
  32                                               MPI_ERR_COMM,                   \
  33                                               "**commnull", 0);               \
  34             error_code_ = MPIO_Err_return_file(MPI_FILE_NULL, (error_code_)); \
  35             goto fn_exit;                                                     \
  36         }                                                                     \
  37     } while (0)
  38 
  39 #define MPIO_CHECK_COUNT(fh, count, myname, error_code)         \
  40 if (count < 0) {                                                \
  41     error_code = MPIO_Err_create_code(MPI_SUCCESS,              \
  42                                       MPIR_ERR_RECOVERABLE,     \
  43                                       myname, __LINE__,         \
  44                                       MPI_ERR_COUNT,            \
  45                                       "**iobadcount", 0);       \
  46     error_code = MPIO_Err_return_file(fh, error_code);          \
  47     goto fn_exit;                                               \
  48 }
  49 
  50 #define MPIO_CHECK_COUNT_SIZE(fh, count, datatype_size, myname, error_code)         \
  51 if (count*datatype_size != (ADIO_Offset)(unsigned)count*(ADIO_Offset)datatype_size) {   \
  52     error_code = MPIO_Err_create_code(MPI_SUCCESS,              \
  53                                       MPIR_ERR_RECOVERABLE,     \
  54                                       myname, __LINE__,         \
  55                                       MPI_ERR_ARG,              \
  56                                       "**iobadcount", 0);       \
  57     error_code = MPIO_Err_return_file(fh, error_code);          \
  58     goto fn_exit;                                               \
  59 }
  60 
  61 #define MPIO_CHECK_DATATYPE(fh, datatype, myname, error_code)       \
  62     do {                                                            \
  63         if (datatype == MPI_DATATYPE_NULL) {                        \
  64             error_code = MPIO_Err_create_code(MPI_SUCCESS,          \
  65                                               MPIR_ERR_RECOVERABLE, \
  66                                               myname, __LINE__,     \
  67                                               MPI_ERR_TYPE,         \
  68                                               "**dtypenull", 0);    \
  69         }                                                           \
  70         else {                                                      \
  71             MPIO_DATATYPE_ISCOMMITTED(datatype, error_code);        \
  72         }                                                           \
  73         if (error_code != MPI_SUCCESS) {                            \
  74             error_code = MPIO_Err_return_file(fh, error_code);      \
  75             goto fn_exit;                                           \
  76         }                                                           \
  77     } while (0)
  78 
  79 #define MPIO_CHECK_READABLE(fh, myname, error_code)             \
  80 if (fh->access_mode & ADIO_WRONLY) {                    \
  81     error_code = MPIO_Err_create_code(MPI_SUCCESS,              \
  82                                       MPIR_ERR_RECOVERABLE,     \
  83                                       myname, __LINE__,         \
  84                                       MPI_ERR_ACCESS,           \
  85                                       "**iowronly", 0);         \
  86     error_code = MPIO_Err_return_file(fh, error_code);          \
  87     goto fn_exit;                                               \
  88 }
  89 
  90 #define MPIO_CHECK_WRITABLE(fh, myname, error_code)             \
  91 if (fh->access_mode & ADIO_RDONLY) {                    \
  92     error_code = MPIO_Err_create_code(MPI_SUCCESS,              \
  93                                       MPIR_ERR_RECOVERABLE,     \
  94                                       myname, __LINE__,         \
  95                                       MPI_ERR_READ_ONLY,        \
  96                                       "**iordonly",             \
  97                                       0);                       \
  98     error_code = MPIO_Err_return_file(fh, error_code);          \
  99     goto fn_exit;                                               \
 100 }
 101 
 102 #define MPIO_CHECK_NOT_SEQUENTIAL_MODE(fh, myname, error_code)          \
 103 if (fh->access_mode & ADIO_SEQUENTIAL) {                                \
 104     error_code = MPIO_Err_create_code(MPI_SUCCESS,                      \
 105                                       MPIR_ERR_RECOVERABLE,             \
 106                                       myname, __LINE__,                 \
 107                                       MPI_ERR_UNSUPPORTED_OPERATION,    \
 108                                       "**ioamodeseq", 0);               \
 109     error_code = MPIO_Err_return_file(fh, error_code);                  \
 110     goto fn_exit;                                                       \
 111 }
 112 
 113 #define MPIO_CHECK_INTEGRAL_ETYPE(fh, count, dtype_size, myname, error_code) \
 114 if ((count*dtype_size) % fh->etype_size != 0) {                              \
 115     error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,     \
 116                                       myname, __LINE__, MPI_ERR_IO,          \
 117                                       "**ioetype", 0);                       \
 118     error_code = MPIO_Err_return_file(fh, error_code);                       \
 119     goto fn_exit;                                                            \
 120 }
 121 
 122 #define MPIO_CHECK_FS_SUPPORTS_SHARED(fh, myname, error_code)           \
 123 if (!ADIO_Feature(fh, ADIO_SHARED_FP))                                  \
 124 {                                                                       \
 125     error_code = MPIO_Err_create_code(MPI_SUCCESS,                      \
 126                                       MPIR_ERR_RECOVERABLE,             \
 127                                       myname, __LINE__,                 \
 128                                       MPI_ERR_UNSUPPORTED_OPERATION,    \
 129                                       "**iosharedunsupported", 0);      \
 130     error_code = MPIO_Err_return_file(fh, error_code);                  \
 131     goto fn_exit;                                                       \
 132 }
 133 
 134 /* MPIO_ERR_CREATE_CODE_XXX macros are used to clean up creation of
 135  * error codes for common cases in romio/adio/
 136  */
 137 #define MPIO_ERR_CREATE_CODE_ERRNO(myname, myerrno, error_code_p) \
 138 *(error_code_p) = MPIO_Err_create_code(MPI_SUCCESS,               \
 139                                        MPIR_ERR_RECOVERABLE,      \
 140                                        myname, __LINE__,          \
 141                                        MPI_ERR_IO,                \
 142                                        "System call I/O error",   \
 143                                        "Syscall error from %s: %s",       \
 144                                        myname,                    \
 145                                        strerror(myerrno));
 146 
 147 #define MPIO_ERR_CREATE_CODE_INFO_NOT_SAME(myname, key, error_code_p)         \
 148 *(error_code_p) = MPIO_Err_create_code(MPI_SUCCESS,                           \
 149                                        MPIR_ERR_RECOVERABLE,                  \
 150                                        myname, __LINE__,                      \
 151                                        MPI_ERR_NOT_SAME,                      \
 152                                        "Value for info key not same across processes",  \
 153                                        "Value for info key %s not same across processes",\
 154                                        key);
 155 
 156 
 157 /* TODO: handle the independent io case more gracefully  */
 158 #define ADIOI_TEST_DEFERRED(fh, myname, error_code)\
 159     if(! (fh)->is_open ) {\
 160             ADIO_ImmediateOpen((fh), (error_code)); }
 161 
 162 /* Check MPI_Info object by calling MPI_Info_dup, if the info object is valid
 163 then the dup operation will succeed */
 164 /* a collective check for error makes this macro collective */
 165 #define MPIO_CHECK_INFO_ALL(info, error_code, comm) {     \
 166     MPI_Info dupinfo;                           \
 167     int tmp_err = MPI_SUCCESS;                  \
 168     if (info == MPI_INFO_NULL) {                \
 169         dupinfo = MPI_INFO_NULL;                    \
 170         error_code = MPI_SUCCESS;                   \
 171     } else {                                        \
 172         error_code = MPI_Info_dup(info, &dupinfo);  \
 173     }                                               \
 174     MPI_Allreduce(&error_code, &tmp_err, 1, MPI_INT, MPI_MAX, comm); \
 175     if(tmp_err != MPI_SUCCESS) {                                            \
 176         error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, \
 177                 myname, __LINE__, MPI_ERR_OTHER, "**info", 0); \
 178         goto fn_fail; \
 179     }                                           \
 180     if (dupinfo != MPI_INFO_NULL) {             \
 181         MPI_Info_free(&dupinfo);                \
 182     }                                           \
 183 }

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