1 /* 2 * Copyright (C) by Argonne National Laboratory 3 * See COPYRIGHT in top-level directory 4 */ 5 6 #ifndef MPIR_ERR_H_INCLUDED 7 #define MPIR_ERR_H_INCLUDED 8 9 /* Error severity */ 10 #define MPIR_ERR_FATAL 1 11 #define MPIR_ERR_RECOVERABLE 0 12 13 struct MPIR_Comm; 14 struct MPIR_Win; 15 16 /* Bindings for internal routines */ 17 MPICH_API_PUBLIC int MPIR_Err_return_comm(struct MPIR_Comm *, const char[], int); 18 MPICH_API_PUBLIC int MPIR_Err_return_win(struct MPIR_Win *, const char[], int); 19 #ifdef MPI__FILE_DEFINED 20 /* Only define if we have MPI_File */ 21 MPICH_API_PUBLIC int MPIR_Err_return_file(MPI_File, const char[], int); /* Romio version */ 22 #endif 23 /* FIXME: 24 * Update this description to match the current version of the routine, 25 * in particular, the pseudo-format types (even better, fix it so that 26 * the pseudo format types can work with the format attribute check). 27 */ 28 /*@ 29 MPIR_Err_create_code - Create an error code and associated message 30 to report an error 31 32 Input Parameters: 33 + lastcode - Previous error code (see notes) 34 . severity - Indicates severity of error 35 . fcname - Name of the function in which the error has occurred. 36 . line - Line number (usually '__LINE__') 37 . class - Error class 38 . generic_msg - A generic message to be used if not instance-specific 39 message is available 40 . instance_msg - A message containing printf-style formatting commands 41 that, when combined with the instance_parameters, specify an error 42 message containing instance-specific data. 43 - instance_parameters - The remaining parameters. These must match 44 the formatting commands in 'instance_msg'. 45 46 Notes: 47 A typical use is\: 48 .vb 49 mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, 50 __func__, __LINE__, MPI_ERR_RANK, 51 "Invalid Rank", "Invalid rank %d", rank); 52 .ve 53 54 Predefined message may also be used. Any message that uses the 55 prefix '"**"' will be looked up in a table. This allows standardized 56 messages to be used for a message that is used in several different locations 57 in the code. For example, the name '"**rank"' might be used instead of 58 '"Invalid Rank"'; this would also allow the message to be made more 59 specific and useful, such as 60 .vb 61 Invalid rank provided. The rank must be between 0 and the 1 less than 62 the size of the communicator in this call. 63 .ve 64 This interface is compatible with the 'gettext' interface for 65 internationalization, in the sense that the 'generic_msg' and 'instance_msg' 66 may be used as arguments to 'gettext' to return a string in the appropriate 67 language; the implementation of 'MPID_Err_create_code' can then convert 68 this text into the appropriate code value. 69 70 The current set of formatting commands is undocumented and will change. 71 You may safely use '%d' and '%s' (though only use '%s' for names of 72 objects, not text messages, as using '%s' for a message breaks support for 73 internationalization. 74 75 This interface allows error messages to be chained together. The first 76 argument is the last error code; if there is no previous error code, 77 use 'MPI_SUCCESS'. 78 79 Extended Format Specifiers: 80 In addition to the standard format specifies (e.g., %d for an int value), 81 MPIR_Err_create_code accepts some additional values that correspond to 82 various MPI types: 83 + i - an MPI rank; recognizes 'MPI_ANY_SOURCE', 'MPI_PROC_NULL', and 84 'MPI_ROOT' 85 . t - an MPI tag; recognizes 'MPI_ANY_TAG'. 86 . A - an MPI assert value. 87 . C - an MPI communicator. 88 . D - an MPI datatype. 89 . E - an MPI Errhandler. 90 . F - an MPI File object. 91 . G - an MPI Group. 92 . I - an MPI info object. 93 . O - an MPI Op. 94 . R - an MPI Request. 95 - W - an MPI Window object. 96 97 98 Module: 99 Error 100 101 @*/ 102 MPICH_API_PUBLIC int MPIR_Err_create_code(int, int, const char[], int, int, const char[], 103 const char[], ...); 104 105 #ifdef USE_ERR_CODE_VALIST 106 int MPIR_Err_create_code_valist(int, int, const char[], int, int, const char[], const char[], 107 va_list); 108 #endif 109 110 /*@ 111 MPIR_Err_combine_codes - Combine two error codes, or more importantly 112 two lists of error messages. The list associated with the second error 113 code is appended to the list associated with the first error code. If 114 the list associated with the first error code has a dangling tail, which 115 is possible if the ring has wrapped and overwritten entries that were 116 once part of the list, then the append operation is not performed and 117 the error code for the first list is returned. 118 119 Input Parameter: 120 + errorcode1 - the error code associated with the first list 121 - errorcode2 - the error code associated with the second list 122 123 Return value: 124 An error code which resolves to the combined list of error messages 125 126 Notes: 127 If errorcode1 is equal to MPI_SUCCESS, then errorcode2 is returned. 128 Likewise, if errorcode2 is equal to MPI_SUCCESS, then errorcode1 is 129 returned. 130 131 Module: 132 Error 133 @*/ 134 int MPIR_Err_combine_codes(int, int); 135 136 int MPIR_Err_is_fatal(int); 137 void MPIR_Err_init(void); 138 void MPIR_Err_preOrPostInit(void); 139 140 int MPIR_Err_set_msg(int code, const char *msg_string); 141 142 /* This routine is called when there is a fatal error. Now public because file 143 * error handling is defined in a separate file from comm and win, but all 144 * three need to call it */ 145 void MPIR_Handle_fatal_error(struct MPIR_Comm *comm_ptr, const char fcname[], int errcode); 146 147 #define MPIR_ERR_CLASS_MASK 0x0000007f 148 #define MPIR_ERR_CLASS_SIZE 128 149 #define MPIR_ERR_GET_CLASS(mpi_errno_) (mpi_errno_ & MPIR_ERR_CLASS_MASK) 150 151 152 /* ------------------------------------------------------------------------- */ 153 /* mpir_err.h */ 154 /* ------------------------------------------------------------------------- */ 155 156 /* 157 === BEGIN_MPI_T_CVAR_INFO_BLOCK === 158 159 cvars: 160 - name : MPIR_CVAR_COLL_ALIAS_CHECK 161 category : COLLECTIVE 162 type : int 163 default : 1 164 class : none 165 verbosity : MPI_T_VERBOSITY_USER_BASIC 166 scope : MPI_T_SCOPE_ALL_EQ 167 description : >- 168 Enable checking of aliasing in collective operations 169 170 === END_MPI_T_CVAR_INFO_BLOCK === 171 */ 172 173 /* Error checking (see --enable-error-checking for control of this) */ 174 #ifdef HAVE_ERROR_CHECKING 175 176 #define MPID_ERROR_LEVEL_ALL 1 177 #define MPID_ERROR_LEVEL_RUNTIME 2 178 /* Use MPID_ERROR_DECL to wrap declarations that are needed only when 179 error checking is turned on */ 180 #define MPID_ERROR_DECL(a) a 181 182 #if HAVE_ERROR_CHECKING == MPID_ERROR_LEVEL_ALL 183 #define MPID_BEGIN_ERROR_CHECKS 184 #define MPID_END_ERROR_CHECKS 185 #define MPID_ELSE_ERROR_CHECKS 186 #elif HAVE_ERROR_CHECKING == MPID_ERROR_LEVEL_RUNTIME 187 #define MPID_BEGIN_ERROR_CHECKS if (MPIR_Process.do_error_checks) { 188 #define MPID_ELSE_ERROR_CHECKS }else{ 189 #define MPID_END_ERROR_CHECKS } 190 #else 191 #error "Unknown value for error checking" 192 #endif 193 194 #else 195 #define MPID_BEGIN_ERROR_CHECKS 196 #define MPID_END_ERROR_CHECKS 197 #define MPID_ERROR_DECL(a) 198 #endif /* HAVE_ERROR_CHECKING */ 199 200 /* 201 * Standardized error checking macros. These provide the correct tests for 202 * common tests. These set err with the encoded error value. 203 */ 204 #define MPIR_ERRTEST_SEND_TAG(tag,err) \ 205 if ((tag) < 0 || (tag) > MPIR_Process.attrs.tag_ub) { \ 206 err = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, __func__, __LINE__, \ 207 MPI_ERR_TAG, "**tag", "**tag %d", tag); \ 208 goto fn_fail; \ 209 } 210 211 #define MPIR_ERRTEST_RECV_TAG(tag,err) \ 212 if ((tag) < MPI_ANY_TAG || (tag) > MPIR_Process.attrs.tag_ub) { \ 213 err = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, __func__, __LINE__, \ 214 MPI_ERR_TAG, "**tag", "**tag %d", tag); \ 215 goto fn_fail; \ 216 } 217 218 #define MPIR_ERRTEST_RANK(comm_ptr,rank,err) \ 219 if ((rank) < 0 || (rank) >= (comm_ptr)->remote_size) { \ 220 err = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, __func__, __LINE__, \ 221 MPI_ERR_RANK, "**rank", "**rank %d %d", rank, \ 222 (comm_ptr)->remote_size); \ 223 goto fn_fail; \ 224 } 225 226 #define MPIR_ERRTEST_SEND_RANK(comm_ptr,rank,err) \ 227 if ((rank) < MPI_PROC_NULL || (rank) >= (comm_ptr)->remote_size) { \ 228 err = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, __func__, __LINE__, \ 229 MPI_ERR_RANK, "**rank", "**rank %d %d", rank, \ 230 (comm_ptr)->remote_size); \ 231 goto fn_fail; \ 232 } 233 234 #define MPIR_ERRTEST_RECV_RANK(comm_ptr,rank,err) \ 235 if ((rank) < MPI_ANY_SOURCE || (rank) >= (comm_ptr)->remote_size) { \ 236 err = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, __func__, __LINE__, \ 237 MPI_ERR_RANK, "**rank", "**rank %d %d", rank, \ 238 (comm_ptr)->remote_size); \ 239 goto fn_fail; \ 240 } 241 242 #define MPIR_ERRTEST_COUNT(count,err) \ 243 if ((count) < 0) { \ 244 err = MPIR_Err_create_code(MPI_SUCCESS, \ 245 MPIR_ERR_RECOVERABLE, \ 246 __func__, __LINE__, \ 247 MPI_ERR_COUNT, \ 248 "**countneg", \ 249 "**countneg %d", \ 250 count); \ 251 goto fn_fail; \ 252 } 253 254 #define MPIR_ERRTEST_DISP(disp,err) \ 255 if ((disp) < 0) { \ 256 err = MPIR_Err_create_code(MPI_SUCCESS, \ 257 MPIR_ERR_RECOVERABLE, \ 258 __func__, __LINE__, \ 259 MPI_ERR_DISP, \ 260 "**rmadisp", 0); \ 261 goto fn_fail; \ 262 } 263 264 #define MPIR_ERRTEST_ALIAS(ptr1,ptr2,err) \ 265 if ((ptr1)==(ptr2) && (ptr1) != MPI_BOTTOM) { \ 266 err = MPIR_Err_create_code(MPI_SUCCESS, \ 267 MPIR_ERR_RECOVERABLE, \ 268 __func__, __LINE__, \ 269 MPI_ERR_BUFFER, \ 270 "**bufalias", 0); \ 271 goto fn_fail; \ 272 } 273 274 /* FIXME this test is probably too broad. Comparing the (buffer,type,count) 275 * tuples is really what is needed to check for aliasing. */ 276 #define MPIR_ERRTEST_ALIAS_COLL(ptr1,ptr2,err) \ 277 if (MPIR_CVAR_COLL_ALIAS_CHECK && (ptr1)==(ptr2)) { \ 278 err = MPIR_Err_create_code(MPI_SUCCESS, \ 279 MPIR_ERR_RECOVERABLE, \ 280 __func__, __LINE__, \ 281 MPI_ERR_BUFFER, \ 282 "**bufalias", 0); \ 283 goto fn_fail; \ 284 } 285 286 #define MPIR_ERRTEST_ARGNULL(arg,arg_name,err) \ 287 if (!(arg)) { \ 288 err = MPIR_Err_create_code(MPI_SUCCESS, \ 289 MPIR_ERR_RECOVERABLE, \ 290 __func__, __LINE__, \ 291 MPI_ERR_ARG, \ 292 "**nullptr", \ 293 "**nullptr %s", \ 294 arg_name); \ 295 goto fn_fail; \ 296 } 297 298 #define MPIR_ERRTEST_ARGNEG(arg,arg_name,err) \ 299 if ((arg) < 0) { \ 300 err = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, \ 301 __func__, __LINE__, MPI_ERR_ARG, \ 302 "**argneg", \ 303 "**argneg %s %d", arg_name, arg); \ 304 goto fn_fail; \ 305 } 306 307 #define MPIR_ERRTEST_ARGNONPOS(arg,arg_name,err,errclass) \ 308 if ((arg) <= 0) { \ 309 err = MPIR_Err_create_code(MPI_SUCCESS, \ 310 MPIR_ERR_RECOVERABLE, \ 311 __func__, __LINE__, \ 312 errclass, \ 313 "**argnonpos", \ 314 "**argnonpos %s %d", \ 315 arg_name, arg); \ 316 goto fn_fail; \ 317 } 318 319 /* An intracommunicator must have a root between 0 and local_size-1. */ 320 /* intercomm can be between MPI_PROC_NULL (or MPI_ROOT) and remote_size-1 */ 321 #define MPIR_ERRTEST_INTRA_ROOT(comm_ptr,root,err) \ 322 if ((root) < 0 || (root) >= (comm_ptr)->local_size) { \ 323 err = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, __func__, __LINE__, \ 324 MPI_ERR_ROOT, "**root", "**root %d", root); \ 325 goto fn_fail; \ 326 } 327 328 /* We use -2 (MPI_PROC_NULL and MPI_ROOT are negative) for the 329 intercomm test */ 330 #define MPIR_ERRTEST_INTER_ROOT(comm_ptr,root,err) \ 331 if ((root) < -3 || (root) >= (comm_ptr)->remote_size) { \ 332 err = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, __func__, __LINE__, \ 333 MPI_ERR_ROOT, "**root", "**root %d", root); \ 334 goto fn_fail; \ 335 } 336 337 #define MPIR_ERRTEST_PERSISTENT(reqp,err) \ 338 if ((reqp)->kind != MPIR_REQUEST_KIND__PREQUEST_SEND && (reqp)->kind != MPIR_REQUEST_KIND__PREQUEST_RECV) { \ 339 err = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, __func__, __LINE__, \ 340 MPI_ERR_REQUEST, "**requestnotpersist", 0); \ 341 goto fn_fail; \ 342 } 343 344 #define MPIR_ERRTEST_PERSISTENT_ACTIVE(reqp,err) \ 345 if (((reqp)->kind == MPIR_REQUEST_KIND__PREQUEST_SEND || \ 346 (reqp)->kind == MPIR_REQUEST_KIND__PREQUEST_RECV) && (reqp)->u.persist.real_request != NULL) { \ 347 err = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, __func__, __LINE__, \ 348 MPI_ERR_REQUEST, "**requestpersistactive", 0); \ 349 goto fn_fail; \ 350 } 351 352 #define MPIR_ERRTEST_COMM_INTRA(comm_ptr, err) \ 353 if ((comm_ptr)->comm_kind != MPIR_COMM_KIND__INTRACOMM) { \ 354 err = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, __func__, __LINE__, \ 355 MPI_ERR_COMM,"**commnotintra",0); \ 356 goto fn_fail; \ 357 } 358 359 #define MPIR_ERRTEST_COMM_TAG(tag,err) \ 360 if ((tag) < 0 || (tag) > MPIR_Process.attrs.tag_ub) { \ 361 err = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, __func__, __LINE__, \ 362 MPI_ERR_TAG, "**tag", "**tag %d", tag); \ 363 goto fn_fail; \ 364 } 365 366 /* Tests for totally meaningless datatypes first, then for 367 * MPI_DATATYPE_NULL as a separate case. 368 */ 369 #define MPIR_ERRTEST_DATATYPE(datatype, name_, err_) \ 370 { \ 371 if (HANDLE_GET_MPI_KIND(datatype) != MPIR_DATATYPE || \ 372 (HANDLE_GET_KIND(datatype) == HANDLE_KIND_INVALID && \ 373 datatype != MPI_DATATYPE_NULL)) \ 374 { \ 375 err_ = MPIR_Err_create_code(MPI_SUCCESS, \ 376 MPIR_ERR_RECOVERABLE, \ 377 __func__, __LINE__, \ 378 MPI_ERR_TYPE, \ 379 "**dtype", 0); \ 380 goto fn_fail; \ 381 } \ 382 if (datatype == MPI_DATATYPE_NULL) \ 383 { \ 384 err_ = MPIR_Err_create_code(MPI_SUCCESS, \ 385 MPIR_ERR_RECOVERABLE, \ 386 __func__, __LINE__, \ 387 MPI_ERR_TYPE, \ 388 "**dtypenull", \ 389 "**dtypenull %s", \ 390 name_); \ 391 goto fn_fail; \ 392 } \ 393 } 394 395 #define MPIR_ERRTEST_TYPE_RMA_ATOMIC(datatype_, err_) \ 396 do { \ 397 if (!MPIR_Type_is_rma_atomic(datatype_)) { \ 398 err_ = MPIR_Err_create_code(MPI_SUCCESS, \ 399 MPIR_ERR_RECOVERABLE, \ 400 __func__, __LINE__, \ 401 MPI_ERR_TYPE, \ 402 "**rmatypenotatomic", \ 403 "**rmatypenotatomic %D", \ 404 datatype); \ 405 goto fn_fail; \ 406 } \ 407 } while (0) 408 409 #define MPIR_ERRTEST_WIN_FLAVOR(win_, flavor_, err_) \ 410 do { \ 411 if ((win_)->create_flavor != (flavor_)) { \ 412 MPIR_ERR_SETANDSTMT1((err_), MPI_ERR_RMA_FLAVOR, \ 413 goto fn_fail, "**winflavor", \ 414 "**winflavor %s", #flavor_); \ 415 } \ 416 } while (0) 417 418 #define MPIR_ERRTEST_SENDBUF_INPLACE(sendbuf,count,err) \ 419 if (count > 0 && sendbuf == MPI_IN_PLACE) { \ 420 err = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, __func__, __LINE__, \ 421 MPI_ERR_BUFFER, "**sendbuf_inplace", 0); \ 422 goto fn_fail; \ 423 } 424 425 #define MPIR_ERRTEST_RECVBUF_INPLACE(recvbuf,count,err) \ 426 if (count > 0 && recvbuf == MPI_IN_PLACE) { \ 427 err = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, __func__, __LINE__, \ 428 MPI_ERR_BUFFER, "**recvbuf_inplace", 0); \ 429 goto fn_fail; \ 430 } 431 432 #define MPIR_ERRTEST_BUF_INPLACE(buf,count,err) \ 433 if (count > 0 && buf == MPI_IN_PLACE) { \ 434 err = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, __func__, __LINE__, \ 435 MPI_ERR_BUFFER, "**buf_inplace", 0); \ 436 goto fn_fail; \ 437 } 438 439 #define MPIR_ERRTEST_NAMED_BUF_INPLACE(buf, bufname, count, err) \ 440 do { \ 441 if (count > 0 && buf == MPI_IN_PLACE) { \ 442 MPIR_ERR_SETANDJUMP1(err, MPI_ERR_BUFFER, "**buf_inplace", \ 443 "**buf_inplace %s", bufname); \ 444 } \ 445 } while (0) 446 447 /* 448 * Check that the triple (buf,count,datatype) does not specify a null 449 * buffer. This does not guarantee that the buffer is valid but does 450 * catch the most common problems. 451 * Question: 452 * Should this be an (inlineable) routine? 453 * Since it involves extracting the datatype pointer for non-builtin 454 * datatypes, should it take a dtypeptr argument (valid only if not 455 * builtin)? 456 */ 457 #define MPIR_ERRTEST_USERBUFFER(buf,count,dtype,err) \ 458 if (count > 0 && buf == 0) { \ 459 int ferr = 0; \ 460 if (HANDLE_IS_BUILTIN((dtype))) { ferr=1; } \ 461 else { \ 462 MPI_Aint errsize; \ 463 MPIR_Datatype *errdtypeptr; \ 464 MPIR_Datatype_get_ptr(dtype,errdtypeptr); \ 465 MPIR_Datatype_get_size_macro(dtype,errsize); \ 466 if (errdtypeptr && errdtypeptr->true_lb == 0 && \ 467 errsize > 0) { ferr=1; } \ 468 } \ 469 if (ferr) { \ 470 err = MPIR_Err_create_code(MPI_SUCCESS, \ 471 MPIR_ERR_RECOVERABLE, \ 472 __func__, __LINE__, \ 473 MPI_ERR_BUFFER, \ 474 "**bufnull", 0); \ 475 goto fn_fail; \ 476 } \ 477 } 478 479 /* The following are placeholders. We haven't decided yet whether these 480 should take a handle or pointer, or if they should take a handle and return 481 a pointer if the handle is valid. These need to be rationalized with the 482 MPID_xxx_valid_ptr and MPID_xxx_get_ptr. 483 484 [BRT] They should not take a handle and return a pointer if they will be 485 placed inside of a #ifdef HAVE_ERROR_CHECKING block. Personally, I think 486 the macros should take handles. We already have macros for validating 487 pointers to various objects. 488 */ 489 /* --BEGIN ERROR MACROS-- */ 490 #define MPIR_ERRTEST_VALID_HANDLE(handle_,kind_,err_,errclass_,gmsg_) { \ 491 if (HANDLE_GET_MPI_KIND(handle_) != kind_ || \ 492 HANDLE_GET_KIND(handle_) == HANDLE_KIND_INVALID) { \ 493 MPIR_ERR_SETANDSTMT(err_,errclass_,goto fn_fail,gmsg_); \ 494 } \ 495 } 496 /* --END ERROR MACROS-- */ 497 498 #define MPIR_ERRTEST_OP(op,err) \ 499 do { \ 500 if (op == MPI_OP_NULL) { \ 501 MPIR_ERR_SETANDSTMT(err,MPI_ERR_OP,goto fn_fail,"**opnull"); \ 502 } \ 503 else if (op == MPI_NO_OP || op == MPI_REPLACE) { \ 504 MPIR_ERR_SETANDSTMT(err,MPI_ERR_OP,goto fn_fail,"**opnotallowed"); \ 505 } \ 506 else { \ 507 MPIR_ERRTEST_VALID_HANDLE(op,MPIR_OP,err,MPI_ERR_OP,"**op"); \ 508 } \ 509 } while (0) 510 511 #define MPIR_ERRTEST_OP_ACC(op,err) \ 512 do { \ 513 if (op == MPI_OP_NULL) { \ 514 MPIR_ERR_SETANDSTMT(err,MPI_ERR_OP,goto fn_fail,"**opnull"); \ 515 } \ 516 else if (op == MPI_NO_OP) { \ 517 MPIR_ERR_SETANDSTMT(err,MPI_ERR_OP,goto fn_fail,"**opnotallowed"); \ 518 } \ 519 else { \ 520 MPIR_ERRTEST_VALID_HANDLE(op,MPIR_OP,err,MPI_ERR_OP,"**op"); \ 521 } \ 522 if (!HANDLE_IS_BUILTIN((op))) { \ 523 MPIR_ERR_SETANDSTMT(err,MPI_ERR_OP,goto fn_fail,"**opnotpredefined"); \ 524 } \ 525 } while (0) 526 527 #define MPIR_ERRTEST_OP_GACC(op,err) \ 528 do { \ 529 if (op == MPI_OP_NULL) { \ 530 MPIR_ERR_SETANDSTMT(err,MPI_ERR_OP,goto fn_fail,"**opnull"); \ 531 } \ 532 else { \ 533 MPIR_ERRTEST_VALID_HANDLE(op,MPIR_OP,err,MPI_ERR_OP,"**op"); \ 534 } \ 535 if (!HANDLE_IS_BUILTIN((op))) { \ 536 MPIR_ERR_SETANDSTMT(err,MPI_ERR_OP,goto fn_fail,"**opnotpredefined"); \ 537 } \ 538 } while (0) 539 540 #define MPIR_ERRTEST_GROUP(group,err) \ 541 if (group == MPI_GROUP_NULL) { \ 542 MPIR_ERR_SETANDSTMT(err,MPI_ERR_GROUP,goto fn_fail,"**groupnull"); \ 543 } \ 544 else { \ 545 MPIR_ERRTEST_VALID_HANDLE(group,MPIR_GROUP,err,MPI_ERR_GROUP,"**group"); \ 546 } 547 548 #define MPIR_ERRTEST_COMM(comm_, err_) \ 549 { \ 550 if ((comm_) == MPI_COMM_NULL) \ 551 { \ 552 MPIR_ERR_SETANDSTMT((err_), MPI_ERR_COMM,goto fn_fail,"**commnull"); \ 553 } \ 554 else \ 555 { \ 556 MPIR_ERRTEST_VALID_HANDLE((comm_), MPIR_COMM, (err_), MPI_ERR_COMM, "**comm"); \ 557 } \ 558 } 559 560 #define MPIR_ERRTEST_WIN(win_, err_) \ 561 { \ 562 if ((win_) == MPI_WIN_NULL) \ 563 { \ 564 MPIR_ERR_SETANDSTMT((err_), MPI_ERR_WIN,goto fn_fail, "**winnull"); \ 565 } \ 566 else \ 567 { \ 568 MPIR_ERRTEST_VALID_HANDLE((win_), MPIR_WIN, (err_), MPI_ERR_WIN, "**win"); \ 569 } \ 570 } 571 572 #define MPIR_ERRTEST_REQUEST(request_, err_) \ 573 { \ 574 if ((request_) == MPI_REQUEST_NULL) \ 575 { \ 576 MPIR_ERR_SETANDSTMT((err_), MPI_ERR_REQUEST,goto fn_fail, "**requestnull"); \ 577 } \ 578 else \ 579 { \ 580 MPIR_ERRTEST_VALID_HANDLE((request_), MPIR_REQUEST, (err_), MPI_ERR_REQUEST, "**request"); \ 581 } \ 582 } 583 584 #define MPIR_ERRTEST_REQUEST_OR_NULL(request_, err_) \ 585 { \ 586 if ((request_) != MPI_REQUEST_NULL) \ 587 { \ 588 MPIR_ERRTEST_VALID_HANDLE((request_), MPIR_REQUEST, (err_), MPI_ERR_REQUEST, "**request"); \ 589 } \ 590 } 591 592 /* This macro does *NOT* jump to fn_fail - all uses check mpi_errno */ 593 #define MPIR_ERRTEST_ARRAYREQUEST_OR_NULL(request_, i_, err_) \ 594 { \ 595 if ((request_) != MPI_REQUEST_NULL) \ 596 { \ 597 if (HANDLE_GET_MPI_KIND(request_) != MPIR_REQUEST) { \ 598 MPIR_ERR_SETANDSTMT2(err_,MPI_ERR_REQUEST,goto fn_fail, \ 599 "**request_invalid_kind","**request_invalid_kind %d %d", \ 600 i_, HANDLE_GET_MPI_KIND(request_)); \ 601 } \ 602 else if (HANDLE_GET_KIND(request_) == HANDLE_KIND_INVALID) { \ 603 MPIR_ERR_SETANDSTMT1(err_,MPI_ERR_REQUEST,goto fn_fail, \ 604 "**request","**request %d", i_); \ 605 } \ 606 } \ 607 } 608 609 #define MPIR_ERRTEST_ERRHANDLER(errhandler_,err_) \ 610 if (errhandler_ == MPI_ERRHANDLER_NULL) { \ 611 MPIR_ERR_SETANDSTMT(err_,MPI_ERR_ARG,goto fn_fail,"**errhandlernull"); \ 612 } \ 613 else { \ 614 MPIR_ERRTEST_VALID_HANDLE(errhandler_,MPIR_ERRHANDLER, \ 615 err_,MPI_ERR_ARG,"**errhandler"); \ 616 } 617 618 #define MPIR_ERRTEST_INFO(info_, err_) \ 619 { \ 620 if ((info_) == MPI_INFO_NULL) \ 621 { \ 622 MPIR_ERR_SETANDSTMT(err_, MPI_ERR_ARG,goto fn_fail, "**infonull"); \ 623 } \ 624 else \ 625 { \ 626 MPIR_ERRTEST_VALID_HANDLE((info_), MPIR_INFO, (err_), MPI_ERR_ARG, "**info"); \ 627 } \ 628 } 629 630 #define MPIR_ERRTEST_INFO_OR_NULL(info_, err_) \ 631 { \ 632 if ((info_) != MPI_INFO_NULL) \ 633 { \ 634 MPIR_ERRTEST_VALID_HANDLE((info_), MPIR_INFO, (err_), MPI_ERR_ARG, "**info"); \ 635 } \ 636 } 637 638 #define MPIR_ERRTEST_KEYVAL(keyval_, object_, objectdesc_, err_) \ 639 { \ 640 if ((keyval_) == MPI_KEYVAL_INVALID) \ 641 { \ 642 MPIR_ERR_SETANDSTMT(err_, MPI_ERR_KEYVAL,goto fn_fail, "**keyvalinvalid"); \ 643 } \ 644 else if (HANDLE_GET_MPI_KIND(keyval_) != MPIR_KEYVAL) \ 645 { \ 646 MPIR_ERR_SETANDSTMT(err_, MPI_ERR_KEYVAL,goto fn_fail, "**keyval"); \ 647 } \ 648 else if ((((keyval_) & 0x03c00000) >> 22) != (object_)) \ 649 { \ 650 MPIR_ERR_SETANDSTMT1(err_, MPI_ERR_KEYVAL,goto fn_fail, "**keyvalobj", \ 651 "**keyvalobj %s", (objectdesc_)); \ 652 } \ 653 } 654 655 #define MPIR_ERRTEST_KEYVAL_PERM(keyval_, err_) \ 656 { \ 657 if (HANDLE_GET_MPI_KIND(keyval_) == MPIR_KEYVAL && \ 658 HANDLE_IS_BUILTIN((keyval_))) \ 659 { \ 660 MPIR_ERR_SETANDSTMT(err_, MPI_ERR_KEYVAL,goto fn_fail, "**permattr"); \ 661 } \ 662 } 663 664 #ifdef HAVE_ERROR_CHECKING 665 #define MPIR_ERRTEST_MPIT_INITIALIZED(err_) \ 666 do { \ 667 if (!MPIR_T_is_initialized()) { \ 668 MPIR_ERR_SETANDSTMT(err_, MPI_T_ERR_NOT_INITIALIZED, goto fn_fail, "**mpitinit"); \ 669 } \ 670 } while (0) 671 #else 672 #define MPIR_ERRTEST_MPIT_INITIALIZED(err_) 673 #endif 674 675 #define MPIR_ERRTEST_CAT_INDEX(index_,err_) \ 676 do { \ 677 if ((index_) < 0 || ((unsigned) index_) >= utarray_len(cat_table)) \ 678 { \ 679 MPIR_ERR_SETANDSTMT(err_, MPI_T_ERR_INVALID_INDEX, goto fn_fail, "**catindex"); \ 680 } \ 681 } while (0) 682 683 #define MPIR_ERRTEST_ENUM_HANDLE(handle_, err_) \ 684 do { \ 685 if ((handle_) == MPI_T_ENUM_NULL) \ 686 { \ 687 MPIR_ERR_SETANDSTMT(err_, MPI_T_ERR_INVALID_HANDLE, goto fn_fail, "**enumhandlenull"); \ 688 } \ 689 else if ((handle_)->kind != MPIR_T_ENUM_HANDLE) \ 690 { \ 691 MPIR_ERR_SETANDSTMT(err_, MPI_T_ERR_INVALID_HANDLE, goto fn_fail, "**enumhandle"); \ 692 } \ 693 } while (0) 694 695 #define MPIR_ERRTEST_ENUM_ITEM(enum_, index_, err_) \ 696 do { \ 697 if ((index_) < 0 || ((unsigned) index_) >= utarray_len((enum_)->items)) \ 698 { \ 699 MPIR_ERR_SETANDSTMT(err_, MPI_T_ERR_INVALID_ITEM, goto fn_fail, "**itemindex"); \ 700 } \ 701 } while (0) 702 703 #define MPIR_ERRTEST_CVAR_INDEX(index_,err_) \ 704 do { \ 705 if ((index_) < 0 || ((unsigned) index_) >= utarray_len(cvar_table)) \ 706 { \ 707 MPIR_ERR_SETANDSTMT(err_, MPI_T_ERR_INVALID_INDEX, goto fn_fail, "**cvarindex"); \ 708 } \ 709 } while (0) 710 711 #define MPIR_ERRTEST_CVAR_HANDLE(handle_, err_) \ 712 do { \ 713 if ((handle_) == MPI_T_CVAR_HANDLE_NULL) \ 714 { \ 715 MPIR_ERR_SETANDSTMT(err_, MPI_T_ERR_INVALID_HANDLE, goto fn_fail, "**cvarhandlenull"); \ 716 } \ 717 else if ((handle_)->kind != MPIR_T_CVAR_HANDLE) \ 718 { \ 719 MPIR_ERR_SETANDSTMT(err_, MPI_T_ERR_INVALID_HANDLE, goto fn_fail, "**cvarhandle"); \ 720 } \ 721 } while (0) 722 723 #define MPIR_ERRTEST_PVAR_INDEX(index_,err_) \ 724 do { \ 725 if ((index_) < 0 || ((unsigned) index_) >= utarray_len(pvar_table)) \ 726 { \ 727 MPIR_ERR_SETANDSTMT(err_, MPI_T_ERR_INVALID_INDEX, goto fn_fail, "**pvarindex"); \ 728 } \ 729 } while (0) 730 731 #define MPIR_ERRTEST_PVAR_HANDLE(handle_, err_) \ 732 do { \ 733 if (handle_ == MPI_T_PVAR_HANDLE_NULL) \ 734 { \ 735 MPIR_ERR_SETANDSTMT(err_,MPI_T_ERR_INVALID_HANDLE, goto fn_fail,"**pvarhandlenull"); \ 736 } \ 737 else if ((handle_)->kind != MPIR_T_PVAR_HANDLE) \ 738 { \ 739 MPIR_ERR_SETANDSTMT(err_, MPI_T_ERR_INVALID_HANDLE, goto fn_fail, "**pvarhandle"); \ 740 } \ 741 } while (0) 742 743 #define MPIR_ERRTEST_PVAR_SESSION(session_,err_) \ 744 do { \ 745 if ((session_) == MPI_T_PVAR_SESSION_NULL) \ 746 { \ 747 MPIR_ERR_SETANDSTMT(err_,MPI_T_ERR_INVALID_SESSION, goto fn_fail,"**pvarsessionnull"); \ 748 } \ 749 else if ((session_)->kind != MPIR_T_PVAR_SESSION) \ 750 { \ 751 MPIR_ERR_SETANDSTMT(err_, MPI_T_ERR_INVALID_SESSION, goto fn_fail, "**pvarsession"); \ 752 } \ 753 } while (0) 754 755 /* some simple memcpy aliasing checks */ 756 #define MPIR_ERR_CHKMEMCPYANDSTMT(err_,stmt_,src_,dst_,len_) \ 757 MPIR_ERR_CHKANDSTMT3(MPIR_MEM_RANGES_OVERLAP((dst_),(len_),(src_),(len_)),err_,MPI_ERR_INTERN,stmt_,"**memcpyalias","**memcpyalias %p %p %L",(src_),(dst_),(long long)(len_)) 758 #define MPIR_ERR_CHKMEMCPYANDJUMP(err_,src_,dst_,len_) \ 759 MPIR_ERR_CHKMEMCPYANDSTMT((err_),goto fn_fail,(src_),(dst_),(len_)) 760 761 /* Special MPI error "class/code" for out of memory */ 762 /* FIXME: not yet done */ 763 #define MPIR_ERR_MEMALLOCFAILED MPI_ERR_INTERN 764 765 /* 766 * Standardized error setting and checking macros 767 * These are intended to simplify the insertion of standardized error 768 * checks 769 * 770 */ 771 /* --BEGIN ERROR MACROS-- */ 772 #ifdef HAVE_ERROR_CHECKING 773 #define MPIR_ERR_POP(err_) \ 774 MPIR_ERR_SETANDSTMT(err_,MPI_ERR_OTHER,goto fn_fail,"**fail") 775 #define MPIR_ERR_POP_LABEL(err_, label_) \ 776 MPIR_ERR_SETANDSTMT(err_,MPI_ERR_OTHER,goto label_,"**fail") 777 #define MPIR_ERR_POPFATAL(err_) \ 778 MPIR_ERR_SETFATALANDSTMT(err_,MPI_ERR_OTHER,goto fn_fail,"**fail") 779 #define MPIR_ERR_POPFATAL_LABEL(err_, label_) \ 780 MPIR_ERR_SETFATALANDSTMT(err_,MPI_ERR_OTHER,goto label_,"**fail") 781 #define MPIR_ERR_CHECK(err_) \ 782 if (unlikely(err_)) MPIR_ERR_SETANDSTMT(err_,MPI_ERR_OTHER,goto fn_fail,"**fail") 783 #else 784 #define MPIR_ERR_POP(err_) goto fn_fail 785 #define MPIR_ERR_POP_LABEL(err_, label_) goto label_ 786 #define MPIR_ERR_POPFATAL(err_) goto fn_fail 787 #define MPIR_ERR_POPFATAL_LABEL(err_, label_) goto label_ 788 #define MPIR_ERR_CHECK(err_) if (unlikely(err_)) goto fn_fail 789 #endif 790 791 /* If you add any macros to this list, make sure that you update 792 maint/extracterrmsgs to handle the additional macros (see the hash 793 KnownErrRoutines in that script) 794 ERR_SETSIMPLE is like ERR_SET except that it just sets the error, it 795 doesn't add it to an existing error. This is appropriate in cases 796 where there can be no pre-existing error, and MPI_SUCCESS is needed for the 797 first argument to MPIR_Err_create_code . 798 */ 799 #ifdef HAVE_ERROR_CHECKING 800 #define MPIR_ERR_SETSIMPLE(err_,class_,msg_) \ 801 err_ = MPIR_Err_create_code(MPI_SUCCESS,MPIR_ERR_RECOVERABLE,__func__, \ 802 __LINE__, class_, msg_, 0) 803 #define MPIR_ERR_SET(err_,class_,msg_) \ 804 err_ = MPIR_Err_create_code(err_,MPIR_ERR_RECOVERABLE,__func__, \ 805 __LINE__, class_, msg_, 0) 806 #define MPIR_ERR_SET1(err_,class_,gmsg_,smsg_,arg1_) \ 807 err_ = MPIR_Err_create_code(err_,MPIR_ERR_RECOVERABLE,__func__, \ 808 __LINE__, class_, gmsg_, smsg_, arg1_) 809 #define MPIR_ERR_SET2(err_,class_,gmsg_,smsg_,arg1_,arg2_) \ 810 err_ = MPIR_Err_create_code(err_,MPIR_ERR_RECOVERABLE,__func__, \ 811 __LINE__, class_, gmsg_, smsg_, arg1_, arg2_) 812 #define MPIR_ERR_SETANDSTMT(err_,class_,stmt_,msg_) \ 813 do { \ 814 err_ = MPIR_Err_create_code(err_,MPIR_ERR_RECOVERABLE,__func__, \ 815 __LINE__, class_, msg_, 0); \ 816 assert(err_); \ 817 stmt_ ; \ 818 } while (0) 819 #define MPIR_ERR_SETANDSTMT1(err_,class_,stmt_,gmsg_,smsg_,arg1_) \ 820 do { \ 821 err_ = MPIR_Err_create_code(err_,MPIR_ERR_RECOVERABLE,__func__, \ 822 __LINE__, class_, gmsg_, smsg_, arg1_); \ 823 assert(err_); \ 824 stmt_ ; \ 825 } while (0) 826 #define MPIR_ERR_SETANDSTMT2(err_,class_,stmt_,gmsg_,smsg_,arg1_,arg2_) \ 827 do { \ 828 err_ = MPIR_Err_create_code(err_,MPIR_ERR_RECOVERABLE,__func__, \ 829 __LINE__, class_, gmsg_, smsg_, arg1_, arg2_); \ 830 assert(err_); \ 831 stmt_ ; \ 832 } while (0) 833 #define MPIR_ERR_SETANDSTMT3(err_,class_,stmt_,gmsg_,smsg_,arg1_,arg2_, arg3_) \ 834 do { \ 835 err_ = MPIR_Err_create_code(err_,MPIR_ERR_RECOVERABLE,__func__, \ 836 __LINE__, class_, gmsg_, smsg_, arg1_, arg2_, arg3_); \ 837 assert(err_); \ 838 stmt_ ; \ 839 } while (0) 840 #define MPIR_ERR_SETANDSTMT4(err_,class_,stmt_,gmsg_,smsg_,arg1_,arg2_, arg3_, arg4_) \ 841 do { \ 842 err_ = MPIR_Err_create_code(err_,MPIR_ERR_RECOVERABLE,__func__, \ 843 __LINE__, class_, gmsg_, smsg_, arg1_, \ 844 arg2_, arg3_, arg4_); \ 845 assert(err_); \ 846 stmt_ ; \ 847 } while (0) 848 849 #define MPIR_ERR_SETFATALSIMPLE(err_,class_,msg_) \ 850 err_ = MPIR_Err_create_code(MPI_SUCCESS,MPIR_ERR_FATAL,__func__, \ 851 __LINE__, class_, msg_, 0) 852 #define MPIR_ERR_SETFATAL(err_,class_,msg_) \ 853 err_ = MPIR_Err_create_code(err_,MPIR_ERR_FATAL,__func__, \ 854 __LINE__, class_, msg_, 0) 855 #define MPIR_ERR_SETFATAL1(err_,class_,gmsg_,smsg_,arg1_) \ 856 err_ = MPIR_Err_create_code(err_,MPIR_ERR_FATAL,__func__, \ 857 __LINE__, class_, gmsg_, smsg_, arg1_) 858 #define MPIR_ERR_SETFATAL2(err_,class_,gmsg_,smsg_,arg1_,arg2_) \ 859 err_ = MPIR_Err_create_code(err_,MPIR_ERR_FATAL,__func__, \ 860 __LINE__, class_, gmsg_, smsg_, arg1_, arg2_) 861 #define MPIR_ERR_SETFATALANDSTMT(err_,class_,stmt_,msg_) \ 862 do { \ 863 err_ = MPIR_Err_create_code(err_,MPIR_ERR_FATAL,__func__, \ 864 __LINE__, class_, msg_, 0); stmt_ ; \ 865 } while (0) 866 #define MPIR_ERR_SETFATALANDSTMT1(err_,class_,stmt_,gmsg_,smsg_,arg1_) \ 867 do { \ 868 err_ = MPIR_Err_create_code(err_,MPIR_ERR_FATAL,__func__, \ 869 __LINE__, class_, gmsg_, smsg_, arg1_); stmt_ ; \ 870 } while (0) 871 #define MPIR_ERR_SETFATALANDSTMT2(err_,class_,stmt_,gmsg_,smsg_,arg1_,arg2_) \ 872 do { \ 873 err_ = MPIR_Err_create_code(err_,MPIR_ERR_FATAL,__func__, \ 874 __LINE__, class_, gmsg_, smsg_, arg1_, arg2_); stmt_ ; \ 875 } while (0) 876 #define MPIR_ERR_SETFATALANDSTMT3(err_,class_,stmt_,gmsg_,smsg_,arg1_,arg2_, arg3_) \ 877 do { \ 878 err_ = MPIR_Err_create_code(err_,MPIR_ERR_FATAL,__func__, \ 879 __LINE__, class_, gmsg_, smsg_, arg1_, arg2_, arg3_); stmt_ ; \ 880 } while (0) 881 #define MPIR_ERR_SETFATALANDSTMT4(err_,class_,stmt_,gmsg_,smsg_,arg1_,arg2_, arg3_, arg4_) \ 882 do { \ 883 err_ = MPIR_Err_create_code(err_,MPIR_ERR_FATAL,__func__, \ 884 __LINE__, class_, gmsg_, smsg_, arg1_, arg2_, arg3_, arg4_); stmt_ ; \ 885 } while (0) 886 #define MPIR_ERR_ADD(err_, newerr_) \ 887 do { \ 888 (err_) = MPIR_Err_combine_codes((err_), (newerr_)); \ 889 } while (0) 890 #else 891 /* Simply set the class, being careful not to override a previously 892 set class. */ 893 #define MPIR_ERR_SETSIMPLE(err_,class_,msg_) \ 894 do { \ 895 err_ = class_; \ 896 } while (0) 897 #define MPIR_ERR_SET(err_,class_,msg_) \ 898 do { \ 899 if (!err_) { \ 900 err_=class_; \ 901 } \ 902 } while (0) 903 #define MPIR_ERR_SET1(err_,class_,gmsg_,smsg_,arg1_) \ 904 MPIR_ERR_SET(err_,class_,msg_) 905 #define MPIR_ERR_SET2(err_,class_,gmsg_,smsg_,arg1_,arg2_) \ 906 MPIR_ERR_SET(err_,class_,msg_) 907 #define MPIR_ERR_SETANDSTMT(err_,class_,stmt_,msg_) \ 908 do { \ 909 if (!err_) { \ 910 err_ = class_; \ 911 } \ 912 stmt_; \ 913 } while (0) 914 #define MPIR_ERR_SETANDSTMT1(err_,class_,stmt_,gmsg_,smsg_,arg1_) \ 915 MPIR_ERR_SETANDSTMT(err_,class_,stmt_,gmsg_) 916 #define MPIR_ERR_SETANDSTMT2(err_,class_,stmt_,gmsg_,smsg_,arg1_,arg2_) \ 917 MPIR_ERR_SETANDSTMT(err_,class_,stmt_,gmsg_) 918 #define MPIR_ERR_SETANDSTMT3(err_,class_,stmt_,gmsg_,smsg_,arg1_,arg2_,arg3_) \ 919 MPIR_ERR_SETANDSTMT(err_,class_,stmt_,gmsg_) 920 #define MPIR_ERR_SETANDSTMT4(err_,class_,stmt_,gmsg_,smsg_,arg1_,arg2_,arg3_,arg4_) \ 921 MPIR_ERR_SETANDSTMT(err_,class_,stmt_,gmsg_) 922 923 #define MPIR_ERR_SETFATALSIMPLE(err_,class_,msg_) \ 924 do { \ 925 err_ = class_; \ 926 } while (0) 927 #define MPIR_ERR_SETFATAL(err_,class_,msg_) \ 928 do { \ 929 if (!err_) { \ 930 err_=class_; \ 931 } \ 932 } while (0) 933 #define MPIR_ERR_SETFATAL1(err_,class_,gmsg_,smsg_,arg1_) \ 934 MPIR_ERR_SET(err_,class_,msg_) 935 #define MPIR_ERR_SETFATAL2(err_,class_,gmsg_,smsg_,arg1_,arg2_) \ 936 MPIR_ERR_SET(err_,class_,msg_) 937 #define MPIR_ERR_SETFATALANDSTMT(err_,class_,stmt_,msg_) \ 938 MPIR_ERR_SETANDSTMT(err_,class_,stmt_,msg_) 939 #define MPIR_ERR_SETFATALANDSTMT1(err_,class_,stmt_,gmsg_,smsg_,arg1_) \ 940 MPIR_ERR_SETANDSTMT(err_,class_,stmt_,gmsg_) 941 #define MPIR_ERR_SETFATALANDSTMT2(err_,class_,stmt_,gmsg_,smsg_,arg1_,arg2_) \ 942 MPIR_ERR_SETANDSTMT(err_,class_,stmt_,gmsg_) 943 #define MPIR_ERR_SETFATALANDSTMT3(err_,class_,stmt_,gmsg_,smsg_,arg1_,arg2_,arg3_) \ 944 MPIR_ERR_SETANDSTMT(err_,class_,stmt_,gmsg_) 945 #define MPIR_ERR_SETFATALANDSTMT4(err_,class_,stmt_,gmsg_,smsg_,arg1_,arg2_,arg3_,arg4_) \ 946 MPIR_ERR_SETANDSTMT(err_,class_,stmt_,gmsg_) 947 /* No-op - use original error class; discard newerr_ unless err is 948 * MPI_SUCCESS */ 949 #define MPIR_ERR_ADD(err_, newerr_) \ 950 do { \ 951 if (!err_) \ 952 err_ = newerr_; \ 953 } while (0) 954 #endif 955 956 /* The following definitions are the same independent of the choice of 957 HAVE_ERROR_CHECKING */ 958 #define MPIR_ERR_SETANDJUMP(err_,class_,msg_) \ 959 MPIR_ERR_SETANDSTMT(err_,class_,goto fn_fail,msg_) 960 #define MPIR_ERR_SETFATALANDJUMP(err_,class_,msg_) \ 961 MPIR_ERR_SETFATALANDSTMT(err_,class_,goto fn_fail,msg_) 962 #define MPIR_ERR_CHKANDSTMT(cond_,err_,class_,stmt_,msg_) \ 963 do { \ 964 if (cond_) { \ 965 MPIR_ERR_SETANDSTMT(err_,class_,stmt_,msg_); \ 966 } \ 967 } while (0) 968 #define MPIR_ERR_CHKFATALANDSTMT(cond_,err_,class_,stmt_,msg_) \ 969 do { \ 970 if (cond_) { \ 971 MPIR_ERR_SETFATALANDSTMT(err_,class_,stmt_,msg_); \ 972 } \ 973 } while (0) 974 #define MPIR_ERR_CHKANDJUMP(cond_,err_,class_,msg_) \ 975 MPIR_ERR_CHKANDSTMT(cond_,err_,class_,goto fn_fail,msg_) 976 #define MPIR_ERR_CHKFATALANDJUMP(cond_,err_,class_,msg_) \ 977 MPIR_ERR_CHKFATALANDSTMT(cond_,err_,class_,goto fn_fail,msg_) 978 979 #define MPIR_ERR_SETANDJUMP1(err_,class_,gmsg_,smsg_,arg1_) \ 980 MPIR_ERR_SETANDSTMT1(err_,class_,goto fn_fail,gmsg_,smsg_,arg1_) 981 #define MPIR_ERR_SETFATALANDJUMP1(err_,class_,gmsg_,smsg_,arg1_) \ 982 MPIR_ERR_SETFATALANDSTMT1(err_,class_,goto fn_fail,gmsg_,smsg_,arg1_) 983 #define MPIR_ERR_CHKANDSTMT1(cond_,err_,class_,stmt_,gmsg_,smsg_,arg1_) \ 984 do { \ 985 if (cond_) { \ 986 MPIR_ERR_SETANDSTMT1(err_,class_,stmt_,gmsg_,smsg_,arg1_); \ 987 } \ 988 } while (0) 989 #define MPIR_ERR_CHKFATALANDSTMT1(cond_,err_,class_,stmt_,gmsg_,smsg_,arg1_) \ 990 do { \ 991 if (cond_) { \ 992 MPIR_ERR_SETFATALANDSTMT1(err_,class_,stmt_,gmsg_,smsg_,arg1_); \ 993 } \ 994 } while (0) 995 #define MPIR_ERR_CHKANDJUMP1(cond_,err_,class_,gmsg_,smsg_,arg1_) \ 996 MPIR_ERR_CHKANDSTMT1(cond_,err_,class_,goto fn_fail,gmsg_,smsg_,arg1_) 997 #define MPIR_ERR_CHKFATALANDJUMP1(cond_,err_,class_,gmsg_,smsg_,arg1_) \ 998 MPIR_ERR_CHKFATALANDSTMT1(cond_,err_,class_,goto fn_fail,gmsg_,smsg_,arg1_) 999 1000 #define MPIR_ERR_SETANDJUMP2(err_,class_,gmsg_,smsg_,arg1_,arg2_) \ 1001 MPIR_ERR_SETANDSTMT2(err_,class_,goto fn_fail,gmsg_,smsg_,arg1_,arg2_) 1002 #define MPIR_ERR_SETFATALANDJUMP2(err_,class_,gmsg_,smsg_,arg1_,arg2_) \ 1003 MPIR_ERR_SETFATALANDSTMT2(err_,class_,goto fn_fail,gmsg_,smsg_,arg1_,arg2_) 1004 #define MPIR_ERR_CHKANDSTMT2(cond_,err_,class_,stmt_,gmsg_,smsg_,arg1_,arg2_) \ 1005 do { \ 1006 if (cond_) { \ 1007 MPIR_ERR_SETANDSTMT2(err_,class_,stmt_,gmsg_,smsg_,arg1_,arg2_); \ 1008 } \ 1009 } while (0) 1010 #define MPIR_ERR_CHKFATALANDSTMT2(cond_,err_,class_,stmt_,gmsg_,smsg_,arg1_,arg2_) \ 1011 do { \ 1012 if (cond_) { \ 1013 MPIR_ERR_SETFATALANDSTMT2(err_,class_,stmt_,gmsg_,smsg_,arg1_,arg2_); \ 1014 } \ 1015 } while (0) 1016 #define MPIR_ERR_CHKANDJUMP2(cond_,err_,class_,gmsg_,smsg_,arg1_,arg2_) \ 1017 MPIR_ERR_CHKANDSTMT2(cond_,err_,class_,goto fn_fail,gmsg_,smsg_,arg1_,arg2_) 1018 #define MPIR_ERR_CHKFATALANDJUMP2(cond_,err_,class_,gmsg_,smsg_,arg1_,arg2_) \ 1019 MPIR_ERR_CHKFATALANDSTMT2(cond_,err_,class_,goto fn_fail,gmsg_,smsg_,arg1_,arg2_) 1020 1021 #define MPIR_ERR_SETANDJUMP3(err_,class_,gmsg_,smsg_,arg1_,arg2_,arg3_) \ 1022 MPIR_ERR_SETANDSTMT3(err_,class_,goto fn_fail,gmsg_,smsg_,arg1_,arg2_,arg3_) 1023 #define MPIR_ERR_SETFATALANDJUMP3(err_,class_,gmsg_,smsg_,arg1_,arg2_,arg3_) \ 1024 MPIR_ERR_SETFATALANDSTMT3(err_,class_,goto fn_fail,gmsg_,smsg_,arg1_,arg2_,arg3_) 1025 #define MPIR_ERR_CHKANDSTMT3(cond_,err_,class_,stmt_,gmsg_,smsg_,arg1_,arg2_,arg3_) \ 1026 do { \ 1027 if (cond_) { \ 1028 MPIR_ERR_SETANDSTMT3(err_,class_,stmt_,gmsg_,smsg_,arg1_,arg2_,arg3_); \ 1029 } \ 1030 } while (0) 1031 #define MPIR_ERR_CHKFATALANDSTMT3(cond_,err_,class_,stmt_,gmsg_,smsg_,arg1_,arg2_,arg3_) \ 1032 do { \ 1033 if (cond_) { \ 1034 MPIR_ERR_SETFATALANDSTMT3(err_,class_,stmt_,gmsg_,smsg_,arg1_,arg2_,arg3_); \ 1035 } \ 1036 } while (0) 1037 #define MPIR_ERR_CHKANDJUMP3(cond_,err_,class_,gmsg_,smsg_,arg1_,arg2_,arg3_) \ 1038 MPIR_ERR_CHKANDSTMT3(cond_,err_,class_,goto fn_fail,gmsg_,smsg_,arg1_,arg2_,arg3_) 1039 #define MPIR_ERR_CHKFATALANDJUMP3(cond_,err_,class_,gmsg_,smsg_,arg1_,arg2_,arg3_) \ 1040 MPIR_ERR_CHKFATALANDSTMT3(cond_,err_,class_,goto fn_fail,gmsg_,smsg_,arg1_,arg2_,arg3_) 1041 1042 #define MPIR_ERR_SETANDJUMP4(err_,class_,gmsg_,smsg_,arg1_,arg2_,arg3_,arg4_) \ 1043 MPIR_ERR_SETANDSTMT4(err_,class_,goto fn_fail,gmsg_,smsg_,arg1_,arg2_,arg3_,arg4_) 1044 #define MPIR_ERR_SETFATALANDJUMP4(err_,class_,gmsg_,smsg_,arg1_,arg2_,arg3_,arg4_) \ 1045 MPIR_ERR_SETFATALANDSTMT4(err_,class_,goto fn_fail,gmsg_,smsg_,arg1_,arg2_,arg3_,arg4_) 1046 #define MPIR_ERR_CHKANDSTMT4(cond_,err_,class_,stmt_,gmsg_,smsg_,arg1_,arg2_,arg3_, arg4_) \ 1047 do { \ 1048 if (cond_) { \ 1049 MPIR_ERR_SETANDSTMT4(err_,class_,stmt_,gmsg_,smsg_,arg1_,arg2_,arg3_,arg4_); \ 1050 } \ 1051 } while (0) 1052 #define MPIR_ERR_CHKFATALANDSTMT4(cond_,err_,class_,stmt_,gmsg_,smsg_,arg1_,arg2_,arg3_, arg4_) \ 1053 do { \ 1054 if (cond_) { \ 1055 MPIR_ERR_SETFATALANDSTMT4(err_,class_,stmt_,gmsg_,smsg_,arg1_,arg2_,arg3_,arg4_); \ 1056 } \ 1057 } while (0) 1058 #define MPIR_ERR_CHKANDJUMP4(cond_,err_,class_,gmsg_,smsg_,arg1_,arg2_,arg3_,arg4_) \ 1059 MPIR_ERR_CHKANDSTMT4(cond_,err_,class_,goto fn_fail,gmsg_,smsg_,arg1_,arg2_,arg3_,arg4_) 1060 #define MPIR_ERR_CHKFATALANDJUMP4(cond_,err_,class_,gmsg_,smsg_,arg1_,arg2_,arg3_,arg4_) \ 1061 MPIR_ERR_CHKFATALANDSTMT4(cond_,err_,class_,goto fn_fail,gmsg_,smsg_,arg1_,arg2_,arg3_,arg4_) 1062 1063 #define MPIR_ERR_INTERNAL(err_, msg_) \ 1064 MPIR_ERR_SETFATAL1(err_, MPI_ERR_INTERN, "**intern", "**intern %s", msg_) 1065 #define MPIR_ERR_INTERNALANDSTMT(err_, msg_, stmt_) \ 1066 MPIR_ERR_SETANDSTMT1(err_, MPI_ERR_INTERN, stmt_, "**intern", "**intern %s", msg_) 1067 #define MPIR_ERR_INTERNALANDJUMP(err_, msg_) \ 1068 MPIR_ERR_INTERNALANDSTMT(err_, msg_, goto fn_fail) 1069 #define MPIR_ERR_CHKINTERNAL(cond_, err_, msg_) \ 1070 do { \ 1071 if (cond_) \ 1072 MPIR_ERR_INTERNALANDJUMP(err_, msg_); \ 1073 } while (0) 1074 1075 /* --END ERROR MACROS-- */ 1076 1077 /* 1078 * Special case for "is initialized". 1079 * This should be used in cases where there is no 1080 * additional error checking 1081 */ 1082 #ifdef HAVE_ERROR_CHECKING 1083 #define MPIR_ERRTEST_INITIALIZED_ORDIE() \ 1084 do { \ 1085 if (MPL_atomic_load_int(&MPIR_Process.mpich_state) == MPICH_MPI_STATE__PRE_INIT || \ 1086 MPL_atomic_load_int(&MPIR_Process.mpich_state) == MPICH_MPI_STATE__POST_FINALIZED) \ 1087 { \ 1088 MPIR_Err_preOrPostInit(); \ 1089 } \ 1090 } while (0) 1091 #else 1092 #define MPIR_ERRTEST_INITIALIZED_ORDIE() do {} while (0) 1093 #endif 1094 1095 /* ------------------------------------------------------------------------- */ 1096 /* end of mpir_err.h */ 1097 /* ------------------------------------------------------------------------- */ 1098 1099 #endif /* MPIR_ERR_H_INCLUDED */ 1100