[Mpi-forum] how to get MPI::Exception behavior from C bindings?

Darius Buntinas buntinas at mcs.anl.gov
Tue Nov 1 17:29:56 CDT 2011


Create an error handler (function) that throws a C++ exception, then wherever the original code set the error handler to MPI:ERRORS_THROW_EXCEPTIONS, use your new error handler.

I haven't looked up the standard here, but it might say that the error handler must return.  If it does, then this would not be allowed, otherwise, this should work.

-d


On Nov 1, 2011, at 4:18 PM, Jeff Hammond wrote:

> Can someone explain how one can migrate (backwards) from the C++ to
> the C bindings if they currently use MPI::Exception in a try-catch
> block like this:
> 
> ===================================
>        try {
>            ((ThreadBase*)(self))->run();
>        }
>        catch (const MPI::Exception& e) {
>            error("caught an MPI exception");
>        }
> ===================================
> 
> This is taken from MADNESS, btw.
> 
> I think it is only fair for those who want to kill the C++ bindings to
> provide a clear description of how this will not break existing codes
> that use C++ bindings.  Clearly, many things, e.g. MPI::BYTE ->
> MPI_BYTE, are trivial, but I see error handling as being fundamentally
> nontrivial.
> 
> Thanks,
> 
> Jeff
> 
> -- 
> Jeff Hammond
> Argonne Leadership Computing Facility
> University of Chicago Computation Institute
> jhammond at alcf.anl.gov / (630) 252-5381
> http://www.linkedin.com/in/jeffhammond
> https://wiki.alcf.anl.gov/index.php/User:Jhammond
> _______________________________________________
> mpi-forum mailing list
> mpi-forum at lists.mpi-forum.org
> http://lists.mpi-forum.org/mailman/listinfo.cgi/mpi-forum





More information about the mpi-forum mailing list