On Sep 29, 2007, at 12:36 PM, XMATX web.de wrote:
> i'm still very new to MPI. I want to use it within my
C++ code.
> I'm wondering why for example the Send(..) or Recv(..)
routines in
> C do have an bool return value
> and in C++ are void.
>
> Now how should i do this in C++?
>
> Perhaps something like that?
> try
> {
> MPI::COMM_WORLD.Recv(&n, 1, MPI::INT,
MPI::ANY_SOURCE,
> MPI::ANY_TAG, status);
> }
> catch(MPI::Exception e)
> {
> ...//do something
> }
>
> is this the usual way or do i forget something?
By default (for both C and C++), errors on MPI communication
will
case MPI to abort. So unless you're resetting the error
handler on
the communicator in use, there's no need to check error
conditions at
all. However, if you are (or plan to) reset the error
handler, the C+
+ bindings throw exceptions on errors. So your example
would be
correct.
There is nothing that says you should use the C++ MPI
bindings if you
are writing C++ code. A high percentage of the C++ codes I
deal with
use the C bindings to MPI. If you are more comfortable with
the C
bindings to MPI, by all means use them. There are few
advantages to
using the C++ bindings, and there can be a number of
disadvantages.
Hope this helps,
Brian
_______________________________________________
This list is archived at http://www.l
am-mpi.org/MailArchives/lam/
|