2015-05-21 19:39:09 +03:00
|
|
|
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
2004-06-18 02:40:16 +04:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
2007-12-21 09:02:00 +03:00
|
|
|
* Copyright (c) 2004-2007 The University of Tennessee and The University
|
2005-11-05 22:57:48 +03:00
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2015-06-24 06:59:57 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
2004-11-28 23:09:25 +03:00
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2006-12-05 22:07:02 +03:00
|
|
|
* Copyright (c) 2006 University of Houston. All rights reserved.
|
2015-06-29 18:32:46 +03:00
|
|
|
* Copyright (c) 2007-2015 Cisco Systems, Inc. All rights reserved.
|
2015-05-21 19:39:09 +03:00
|
|
|
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
|
|
|
|
* reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
* $COPYRIGHT$
|
2015-06-24 06:59:57 +03:00
|
|
|
*
|
2004-11-22 04:38:40 +03:00
|
|
|
* Additional copyrights may follow
|
2015-06-24 06:59:57 +03:00
|
|
|
*
|
2004-06-18 02:40:16 +04:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
/** @file **/
|
|
|
|
|
|
|
|
#ifndef OMPI_MPI_ERRCODE_H
|
|
|
|
#define OMPI_MPI_ERRCODE_H
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
|
|
|
|
|
|
|
#include "mpi.h"
|
2005-07-03 20:06:07 +04:00
|
|
|
#include "opal/class/opal_object.h"
|
2007-12-21 09:02:00 +03:00
|
|
|
#include "opal/class/opal_pointer_array.h"
|
2004-06-18 02:40:16 +04:00
|
|
|
|
2007-12-21 09:02:00 +03:00
|
|
|
BEGIN_C_DECLS
|
2004-06-18 02:40:16 +04:00
|
|
|
|
|
|
|
/**
|
2015-06-24 06:59:57 +03:00
|
|
|
* Back-end type for MPI error codes.
|
|
|
|
* Please note:
|
|
|
|
* if code == MPI_UNDEFINED, than the according structure
|
2006-12-05 22:07:02 +03:00
|
|
|
* represents an error class.
|
2006-12-21 22:36:31 +03:00
|
|
|
* For the predefined error codes and classes, code and
|
|
|
|
* cls are both set to the according value.
|
2004-06-18 02:40:16 +04:00
|
|
|
*/
|
|
|
|
struct ompi_mpi_errcode_t {
|
2005-07-03 20:06:07 +04:00
|
|
|
opal_object_t super;
|
2004-06-18 02:40:16 +04:00
|
|
|
int code;
|
2006-12-05 22:07:02 +03:00
|
|
|
int cls;
|
2004-06-18 02:40:16 +04:00
|
|
|
char errstring[MPI_MAX_ERROR_STRING];
|
|
|
|
};
|
|
|
|
typedef struct ompi_mpi_errcode_t ompi_mpi_errcode_t;
|
|
|
|
|
2007-12-21 09:02:00 +03:00
|
|
|
OMPI_DECLSPEC extern opal_pointer_array_t ompi_mpi_errcodes;
|
2004-10-22 20:06:05 +04:00
|
|
|
OMPI_DECLSPEC extern int ompi_mpi_errcode_lastused;
|
2006-12-21 22:36:31 +03:00
|
|
|
OMPI_DECLSPEC extern int ompi_mpi_errcode_lastpredefined;
|
2004-06-18 02:40:16 +04:00
|
|
|
|
2006-11-08 19:56:17 +03:00
|
|
|
OMPI_DECLSPEC extern ompi_mpi_errcode_t ompi_err_unknown;
|
|
|
|
|
2015-06-24 06:59:57 +03:00
|
|
|
/**
|
2004-06-18 02:40:16 +04:00
|
|
|
* Check for a valid error code
|
|
|
|
*/
|
|
|
|
static inline bool ompi_mpi_errcode_is_invalid(int errcode)
|
|
|
|
{
|
2006-12-21 22:36:31 +03:00
|
|
|
if ( errcode >= 0 && errcode <= ompi_mpi_errcode_lastused )
|
2004-06-18 02:40:16 +04:00
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the error class
|
|
|
|
*/
|
|
|
|
static inline int ompi_mpi_errcode_get_class (int errcode)
|
|
|
|
{
|
2015-05-21 19:39:09 +03:00
|
|
|
ompi_mpi_errcode_t *err = NULL;
|
|
|
|
|
|
|
|
if (errcode >= 0) {
|
|
|
|
err = (ompi_mpi_errcode_t *)opal_pointer_array_get_item(&ompi_mpi_errcodes, errcode);
|
|
|
|
/* If we get a bogus errcode, return MPI_ERR_UNKNOWN */
|
|
|
|
}
|
2004-06-18 02:40:16 +04:00
|
|
|
|
2006-10-25 17:37:45 +04:00
|
|
|
if (NULL != err) {
|
2015-06-24 06:59:57 +03:00
|
|
|
if ( err->code != MPI_UNDEFINED ) {
|
2006-12-05 22:07:02 +03:00
|
|
|
return err->cls;
|
|
|
|
}
|
2006-10-25 17:37:45 +04:00
|
|
|
}
|
2006-12-05 22:07:02 +03:00
|
|
|
return ompi_err_unknown.cls;
|
2004-06-18 02:40:16 +04:00
|
|
|
}
|
2006-12-21 22:36:31 +03:00
|
|
|
|
2015-06-24 06:59:57 +03:00
|
|
|
static inline int ompi_mpi_errcode_is_predefined ( int errcode )
|
2006-12-21 22:36:31 +03:00
|
|
|
{
|
2015-06-24 06:59:57 +03:00
|
|
|
if ( errcode >= 0 && errcode <= ompi_mpi_errcode_lastpredefined )
|
2006-12-21 22:36:31 +03:00
|
|
|
return true;
|
2015-06-24 06:59:57 +03:00
|
|
|
|
2006-12-21 22:36:31 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-06-24 06:59:57 +03:00
|
|
|
static inline int ompi_mpi_errnum_is_class ( int errnum )
|
2006-12-21 22:36:31 +03:00
|
|
|
{
|
|
|
|
ompi_mpi_errcode_t *err;
|
|
|
|
|
2015-06-29 18:32:46 +03:00
|
|
|
if (errnum < 0) {
|
2015-05-21 19:39:09 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-12-21 22:36:31 +03:00
|
|
|
if ( errnum <= ompi_mpi_errcode_lastpredefined ) {
|
2015-06-24 06:59:57 +03:00
|
|
|
/* Predefined error values represent an error code and
|
2006-12-21 22:36:31 +03:00
|
|
|
an error class at the same time */
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-12-21 09:02:00 +03:00
|
|
|
err = (ompi_mpi_errcode_t *)opal_pointer_array_get_item(&ompi_mpi_errcodes, errnum);
|
2006-12-21 22:36:31 +03:00
|
|
|
if (NULL != err) {
|
2015-06-24 06:59:57 +03:00
|
|
|
if ( MPI_UNDEFINED == err->code) {
|
|
|
|
/* Distinction between error class and error code is that for the
|
2006-12-21 22:36:31 +03:00
|
|
|
first one the code section is set to MPI_UNDEFINED */
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2015-06-24 06:59:57 +03:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the error string
|
2004-06-18 02:40:16 +04:00
|
|
|
*/
|
2006-12-05 22:07:02 +03:00
|
|
|
static inline char* ompi_mpi_errnum_get_string (int errnum)
|
2004-06-18 02:40:16 +04:00
|
|
|
{
|
2015-05-21 19:39:09 +03:00
|
|
|
ompi_mpi_errcode_t *err = NULL;
|
|
|
|
|
|
|
|
if (errnum >= 0) {
|
|
|
|
err = (ompi_mpi_errcode_t *)opal_pointer_array_get_item(&ompi_mpi_errcodes, errnum);
|
|
|
|
/* If we get a bogus errcode, return a string indicating that this
|
|
|
|
truly should not happen */
|
|
|
|
}
|
|
|
|
|
2006-10-25 17:37:45 +04:00
|
|
|
if (NULL != err) {
|
|
|
|
return err->errstring;
|
|
|
|
} else {
|
|
|
|
return "Unknown error (this should not happen!)";
|
|
|
|
}
|
2004-06-18 02:40:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-21 09:02:00 +03:00
|
|
|
/**
|
|
|
|
* Initialize the error codes
|
|
|
|
*
|
|
|
|
* @returns OMPI_SUCCESS Upon success
|
|
|
|
* @returns OMPI_ERROR Otherwise
|
|
|
|
*
|
|
|
|
* Invoked from ompi_mpi_init(); sets up all static MPI error codes,
|
|
|
|
*/
|
|
|
|
int ompi_mpi_errcode_init(void);
|
2015-06-24 06:59:57 +03:00
|
|
|
|
2007-12-21 09:02:00 +03:00
|
|
|
/**
|
|
|
|
* Finalize the error codes.
|
|
|
|
*
|
|
|
|
* @returns OMPI_SUCCESS Always
|
|
|
|
*
|
|
|
|
* Invokes from ompi_mpi_finalize(); tears down the error code array.
|
|
|
|
*/
|
|
|
|
int ompi_mpi_errcode_finalize(void);
|
2015-06-24 06:59:57 +03:00
|
|
|
|
|
|
|
/**
|
2007-12-21 09:02:00 +03:00
|
|
|
* Add an error code
|
|
|
|
*
|
|
|
|
* @param: error class to which this new error code belongs to
|
|
|
|
*
|
|
|
|
* @returns the new error code on SUCCESS (>0)
|
|
|
|
* @returns OMPI_ERROR otherwise
|
2015-06-24 06:59:57 +03:00
|
|
|
*
|
2007-12-21 09:02:00 +03:00
|
|
|
*/
|
|
|
|
int ompi_mpi_errcode_add (int errclass);
|
|
|
|
|
2015-06-24 06:59:57 +03:00
|
|
|
/**
|
2007-12-21 09:02:00 +03:00
|
|
|
* Add an error class
|
|
|
|
*
|
|
|
|
* @param: none
|
|
|
|
*
|
|
|
|
* @returns the new error class on SUCCESS (>0)
|
|
|
|
* @returns OMPI_ERROR otherwise
|
2015-06-24 06:59:57 +03:00
|
|
|
*
|
2007-12-21 09:02:00 +03:00
|
|
|
*/
|
|
|
|
int ompi_mpi_errclass_add (void);
|
2004-06-18 02:40:16 +04:00
|
|
|
|
2007-12-21 09:02:00 +03:00
|
|
|
/**
|
|
|
|
* Add an error string to an error code
|
|
|
|
*
|
|
|
|
* @param: error code for which the string is defined
|
|
|
|
* @param: error string to add
|
|
|
|
* @param: length of the string
|
|
|
|
*
|
|
|
|
* @returns OMPI_SUCCESS on success
|
|
|
|
* @returns OMPI_ERROR on error
|
|
|
|
*/
|
2013-09-27 01:56:20 +04:00
|
|
|
int ompi_mpi_errnum_add_string (int errnum, const char* string, int len);
|
2015-06-24 06:59:57 +03:00
|
|
|
|
2007-12-21 09:02:00 +03:00
|
|
|
END_C_DECLS
|
2004-06-18 02:40:16 +04:00
|
|
|
|
|
|
|
#endif /* OMPI_MPI_ERRCODE_H */
|