Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: Re: [OMPI users] C++ Exceptions
From: Jeff Squyres (jsquyres_at_[hidden])
Date: 2008-10-28 10:28:30

Your question is quite timely -- we had a long discussion about C++
exceptions just last week at the MPI Forum... :-)

OMPI disables MPI throwing exceptions by default because it can cause
a [slight] performance penalty in some compilers. You can enable it
by adding --enable-cxx-exceptions to the OMPI configure command line.
The issue is that C++ exceptions have to pass through C (and possibly
Fortran) code, so the compiler has to add some extra instrumentation
in each function call to all the exceptions to pass through (my
understanding only, which may not be entirely correct). Here's what

   application (in C, C++, or Fortran)
     -> calls MPI_Foo()
     -> an error occurs, OMPI calls its error handling routines
     -> if MPI::ERRORS_THROW_EXCEPTIONS was set, this triggers a
function pointer call into libmpi_cxx.*
     -> the underlying C++ function then invokes "throw ..." to throw
the MPI exception
     -> the exception leaves the C++ code and goes into OMPI's C code
     -> the exception has to travel through the C code back up to the
     -> the exceptions it keeps going upward until it is either caught
or the application aborts

Hence, you have to tell C and Fortran compilers to enable this "pass
exceptions through" behavior. With the GNU compilers, you have to
specify -fexceptions when you compile C / Fortran codes. There's a
bug in the OMPI v1.2 series that we just discovered last week while
doing 1.3 release testing (this is actually what triggered the long
discussion and code fixes about C++ exceptions last week) such that
you need to manually specify the exceptions flags for your compiler.
Something like this:

   ./configure --enable-cxx-exceptions \
       CFLAGS=-fexceptions CXXFLAGS=-fexceptions FFLAGS=-fexceptions
FCFLAGS=-fexceptions \
       --with-wrapper-cflags=-fexceptions \
       --with-wrapper-cxxflags=-fexceptions \
       --with-wrapper-fflags=-fexceptions \
       --with-wrapper-fcflags=-fexceptions \
       ...your other configure arguments...

In the v1.3 series, this is fixed such that you only need to specify:

   ./configure --enable-cxx-exceptions ...

...although in checking all the technical data for this e-mail, I
found a mistake in our commits from last week on the SVN trunk; I just
committed a fix in r19819 (sorry for the configure-changing commit in
the middle of the day, folks!). The v1.3 branch will be updated to
get this fix shortly.

It is unlikely that we'll port this fix back to the 1.2 series, so
you'll need to enable all the extra flags if you want exception support.

Hopefully that all made sense... :-)

On Oct 28, 2008, at 9:26 AM, Gabriele Fatigati wrote:

> Dear OpenMPi developers,
> i'm developing parallel C++ application under OpenMPI 1.2.5. At the
> moment, i'm using MPI Exception Handlers, but some processors returns
> the error below:
> "MPI 2 C++ exception throwing is disabled, MPI::mpi_errno has the
> error code"
> Why this, and why only in some nodes?
> Thanks in advance,
> --
> Ing. Gabriele Fatigati
> CINECA Systems & Tecnologies Department
> Supercomputing Group
> Via Magnanelli 6/3, Casalecchio di Reno (BO) Italy
> Tel: +39 051 6171722
> g.fatigati_at_[hidden]
> _______________________________________________
> users mailing list
> users_at_[hidden]

Jeff Squyres
Cisco Systems