src/Base/ExceptionMPI.h file

Exception macros interoperating with MPI.

Contents

Exception macros interoperating with MPI.

Namespaces

namespace tk
Toolkit declarations and definitions for general purpose utilities.

Defines

#define AssertMPI(expr, ...)
Assert macro that only throws an exception if expr fails.
#define ErrChkMPI(expr, ...)
ErrChkMPI macro that only throws an exception if expr fails.

Define documentation

#define AssertMPI(expr, ...)

Assert macro that only throws an exception if expr fails.

If NDEBUG is defined (e.g. cmake's RELEASE or OPTIMIZED mode), do nothing, expr is not evaluated. If NDEBUG is not defined, evaluate expr. If expr is true, do nothing. If expr is false, throw Exception with arguments passed in. The behavior is similar to libc's assert macro, but throwing an Exception instead will also generate a nice call-trace and will attempt to free memory. This macro should be used to detect programmer errors.

#define ErrChkMPI(expr, ...)

ErrChkMPI macro that only throws an exception if expr fails.

The behavior of this macro is the same whether NDEBUG is defined or not: expr is always evaluated. If expr is true, do nothing. If expr is false, throw Exception with arguments passed in. This macro should be used to detect user or runtime errors. The main difference compared to the vanilla ErrChk macro, defined in Base/Exception.h, is that this macro always does an MPI_Allreduce on the outcome of expr. Since MPI_Allreduce combines values of err from all MPI ranks and distributes the result back to all ranks, the result of expr (err) appear on all ranks, thus if any of the ranks had expr false, all will throw. Thus this macro should be used to detect user or runtime errors from code sections that are executed on multiple MPI ranks. Within asynchrounous Charm++ chares, the simpler ErrChk macro suffices.