annotate DEPENDENCIES/generic/include/boost/mpi/exception.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // Copyright (C) 2005-2006 Douglas Gregor <doug.gregor -at- gmail.com>.
Chris@16 2
Chris@16 3 // Use, modification and distribution is subject to the Boost Software
Chris@16 4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 5 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6
Chris@16 7 /** @file exception.hpp
Chris@16 8 *
Chris@16 9 * This header provides exception classes that report MPI errors to
Chris@16 10 * the user and macros that translate MPI error codes into Boost.MPI
Chris@16 11 * exceptions.
Chris@16 12 */
Chris@16 13 #ifndef BOOST_MPI_EXCEPTION_HPP
Chris@16 14 #define BOOST_MPI_EXCEPTION_HPP
Chris@16 15
Chris@16 16 #include <boost/mpi/config.hpp>
Chris@16 17 #include <exception>
Chris@16 18 #include <string>
Chris@16 19 #include <boost/config.hpp>
Chris@16 20 #include <boost/throw_exception.hpp>
Chris@16 21
Chris@16 22 namespace boost { namespace mpi {
Chris@16 23
Chris@16 24 /** @brief Catch-all exception class for MPI errors.
Chris@16 25 *
Chris@16 26 * Instances of this class will be thrown when an MPI error
Chris@16 27 * occurs. MPI failures that trigger these exceptions may or may not
Chris@16 28 * be recoverable, depending on the underlying MPI
Chris@16 29 * implementation. Consult the documentation for your MPI
Chris@16 30 * implementation to determine the effect of MPI errors.
Chris@16 31 */
Chris@16 32 class BOOST_MPI_DECL exception : public std::exception
Chris@16 33 {
Chris@16 34 public:
Chris@16 35 /**
Chris@16 36 * Build a new @c exception exception.
Chris@16 37 *
Chris@16 38 * @param routine The MPI routine in which the error
Chris@16 39 * occurred. This should be a pointer to a string constant: it
Chris@16 40 * will not be copied.
Chris@16 41 *
Chris@16 42 * @param result_code The result code returned from the MPI
Chris@16 43 * routine that aborted with an error.
Chris@16 44 */
Chris@16 45 exception(const char* routine, int result_code);
Chris@16 46
Chris@16 47 virtual ~exception() throw();
Chris@16 48
Chris@16 49 /**
Chris@16 50 * A description of the error that occurred.
Chris@16 51 */
Chris@16 52 virtual const char * what () const throw ()
Chris@16 53 {
Chris@16 54 return this->message.c_str();
Chris@16 55 }
Chris@16 56
Chris@16 57 /** Retrieve the name of the MPI routine that reported the error. */
Chris@16 58 const char* routine() const { return routine_; }
Chris@16 59
Chris@16 60 /**
Chris@16 61 * @brief Retrieve the result code returned from the MPI routine
Chris@16 62 * that reported the error.
Chris@16 63 */
Chris@16 64 int result_code() const { return result_code_; }
Chris@16 65
Chris@16 66 /**
Chris@16 67 * @brief Returns the MPI error class associated with the error that
Chris@16 68 * triggered this exception.
Chris@16 69 */
Chris@16 70 int error_class() const
Chris@16 71 {
Chris@16 72 int result;
Chris@16 73 MPI_Error_class(result_code_, &result);
Chris@16 74 return result;
Chris@16 75 }
Chris@16 76
Chris@16 77 protected:
Chris@16 78 /// The MPI routine that triggered the error
Chris@16 79 const char* routine_;
Chris@16 80
Chris@16 81 /// The failed result code reported by the MPI implementation.
Chris@16 82 int result_code_;
Chris@16 83
Chris@16 84 /// The formatted error message
Chris@16 85 std::string message;
Chris@16 86 };
Chris@16 87
Chris@16 88 /**
Chris@16 89 * Call the MPI routine MPIFunc with arguments Args (surrounded by
Chris@16 90 * parentheses). If the result is not MPI_SUCCESS, use
Chris@16 91 * boost::throw_exception to throw an exception or abort, depending on
Chris@16 92 * BOOST_NO_EXCEPTIONS.
Chris@16 93 */
Chris@16 94 #define BOOST_MPI_CHECK_RESULT( MPIFunc, Args ) \
Chris@16 95 { \
Chris@16 96 int _check_result = MPIFunc Args; \
Chris@16 97 if (_check_result != MPI_SUCCESS) \
Chris@16 98 boost::throw_exception(boost::mpi::exception(#MPIFunc, \
Chris@16 99 _check_result)); \
Chris@16 100 }
Chris@16 101
Chris@16 102 } } // end namespace boost::mpi
Chris@16 103
Chris@16 104 #endif // BOOST_MPI_EXCEPTION_HPP