Error handling

MPL performs some consistency checks when the macro MPL_DEBUG has been defined. In case of an error, an exception may be thrown with an object having one of the following types.

class error : public exception

Base class for all MPL exception classes that will be thrown in case of run-time errors.

Subclassed by invalid_argument, invalid_count, invalid_datatype_bound, invalid_dim, invalid_displacement, invalid_layout, invalid_rank, invalid_size, invalid_tag, mpi_error

Public Functions

inline error()
inline explicit error(const std::string &message)
Parameters:

message – error message that will be returned by what method

inline explicit error(const char *const message)
Parameters:

message – error message that will be returned by what method

inline const char *what() const noexcept override
Returns:

character pointer to error message

class invalid_rank : public error

Will be thrown in case of invalid rank argument.

Public Functions

inline invalid_rank()
inline const char *what() const noexcept override
Returns:

character pointer to error message

class invalid_tag : public error

Will be thrown in case of invalid tag argument.

Public Functions

inline invalid_tag()
inline const char *what() const noexcept override
Returns:

character pointer to error message

class invalid_size : public error

Will be thrown in case of invalid size argument.

Public Functions

inline invalid_size()
inline const char *what() const noexcept override
Returns:

character pointer to error message

class invalid_count : public error

Will be thrown in case of invalid count argument.

Public Functions

inline invalid_count()
inline const char *what() const noexcept override
Returns:

character pointer to error message

class invalid_layout : public error

Will be thrown in case of invalid layout argument.

Public Functions

inline invalid_layout()
inline const char *what() const noexcept override
Returns:

character pointer to error message

class invalid_dim : public error

Will be thrown in case of invalid dimension.

Public Functions

inline invalid_dim()
inline const char *what() const noexcept override
Returns:

character pointer to error message

class invalid_datatype_bound : public error

Will be thrown when an error occurs while manipulating layouts.

Public Functions

inline invalid_datatype_bound()
inline const char *what() const noexcept override
Returns:

character pointer to error message

class invalid_argument : public error

Will be thrown in case of invalid arguments.

Public Functions

inline invalid_argument()
inline const char *what() const noexcept override
Returns:

character pointer to error message

class mpi_error : public error

Base class for all exceptions that originate from a failed MPI call.

In contrast to the other exception classes, which are thrown by MPL before MPI is called, this class carries the MPI error code and the MPI error class. Constructing an mpi_error with a valid MPI error code is safe before MPI initialization and after finalization. Failed inquiries use a conservative class and numeric message.

Subclassed by io_failure, request_error

Public Functions

inline explicit mpi_error(const int mpi_code)
Parameters:

mpi_code – valid MPI error code returned by an MPI function

inline int error_code() const noexcept
Returns:

MPI error code

inline int error_class() const noexcept
Returns:

MPI error class

inline const char *what() const noexcept override
Returns:

character pointer to error message

class io_failure : public mpi_error

Will be thrown in case of file-related io errors.

Public Functions

inline explicit io_failure(const int code)
inline int error_code() const noexcept
Returns:

MPI error code

inline int error_class() const noexcept
Returns:

MPI error class

inline const char *what() const noexcept override
Returns:

character pointer to error message

class request_error : public mpi_error

Will be thrown if one or more requests of a multi-request completion call failed.

The lists describe outcomes reported by the failing call, not the entire pool state. Unlisted requests are not necessarily pending; null or inactive persistent slots may be reported as successfully completed with empty statuses. Statuses reported by the failing call are available from the request pool.

Public Functions

inline request_error(const int code, std::vector<int> failed, std::vector<int> completed = {})
Parameters:
  • code – error code of the first failed request

  • failed – indices of the requests that completed with an error

  • completed – indices of the requests that completed successfully

inline const std::vector<int> &failed_requests() const noexcept
Returns:

indices of the requests that completed with an error

inline const std::vector<int> &completed_requests() const noexcept
Returns:

indices of the requests that completed successfully in the failed call

inline int error_code() const noexcept
Returns:

MPI error code

inline int error_class() const noexcept
Returns:

MPI error class

inline const char *what() const noexcept override
Returns:

character pointer to error message

MPI errors

When a checked MPI call returns an error, MPL throws mpl::mpi_error (or a subclass), carrying the MPI error code (error_code()), class (error_class()) and message (what()). MPL argument exceptions such as mpl::invalid_rank derive directly from mpl::error and carry no MPI code. Classification is by MPI error class: recognized I/O classes become mpl::io_failure even outside a file operation, while other classes returned by file operations remain mpl::mpi_error.

When multiple-completion calls report per-request errors, mpl::request_error lists failed and successful indices reported by that call. These lists are not a complete partition of pool state: unlisted slots are not necessarily pending, and null or inactive persistent slots can produce empty successful statuses. Statuses of reported completions are stored in the pool; per-request error fields are meaningful on the prescribed MPI_ERR_IN_STATUS path, not an unsuccessful testall poll.

MPL installs MPI_ERRORS_RETURN on communicators it creates or wraps. With external MPI initialization, MPI_COMM_WORLD and MPI_COMM_SELF are changed when the MPL environment is first accessed, not necessarily by earlier datatype or info operations. Borrowed mpi_communicator and mpi_inter_communicator adapters change the original handle’s handler immediately, do not restore it, and do not free the handle. Other MPI calls, including file and objectless operations, may use different handlers. A fatal handler can abort before MPI returns, so MPL cannot convert that failure into an exception; install an appropriate returning handler when needed.

Note

Error reporting does not guarantee that execution can continue after an MPI error. An exception on one process in a collective operation may leave other processes blocked. Destructors do not throw; cleanup and finalization errors are ignored.