The first bit of code is the C example. My translation into boost::mpi follows it. It keeps the same irecv / send pattern but incorporates serialization etc.

Nick

On Jun 15, 2009, at 4:04 PM, Brian Wood wrote:

Nick Collier writes:
> Hmm, I think it should work. Thanks though. The example I posted was
> modified from:

> http://ci-tutor.ncsa.illinois.edu/content.php?cid=1137

> Namely,

> /* deadlock avoided */
> #include <stdio.h>
> #include <mpi.h>

> void main (int argc, char **argv) {

> int myrank;
> MPI_Request request;
> MPI_Status status;
> double a[100], b[100];

> MPI_Init(&argc, &argv);  /* Initialize MPI */
> MPI_Comm_rank(MPI_COMM_WORLD, &myrank); /* Get rank */
> if( myrank == 0 ) {
>   /* Post a receive, send a message, then wait */
>   MPI_Irecv( b, 100, MPI_DOUBLE, 1, 19, MPI_COMM_WORLD, &request );
>   MPI_Send( a, 100, MPI_DOUBLE, 1, 17, MPI_COMM_WORLD );
>   MPI_Wait( &request, &status );
>  }
>  else if( myrank == 1 ) {
>   /* Post a receive, send a message, then wait */
>   MPI_Irecv( b, 100, MPI_DOUBLE, 0, 17, MPI_COMM_WORLD, &request );
>   MPI_Send( a, 100, MPI_DOUBLE, 0, 19, MPI_COMM_WORLD );
>   MPI_Wait( &request, &status );
>  }

> MPI_Finalize();          /* Terminate MPI */

> }
>
 
I am not sure why MPI was added to Boost.  Recently there was an
effort to get Boost libs ready for the next C++ standard.  I don't think
the MPI library was considered in that as it's ties to C are so strong. 
Having to specify MPI_DOUBLE above when a and b are both declared
of type double is sad.  Naming it "Message Passing Interface" when
you are restricted to messages of a single type is hardly an apt name.
If it's going to be in Boost, it may wind up being called the Most Pitiful
Interface.

--
Brian Wood
Ebenezer Enterprises
www.webEbenezer.net

"The New Deal and Great Society entrenched a welfare mentality in
[the US].  The idea of the federal government as the great provider
has even moved to the level of corporate America, with business
'leaders' flying to Washington in private jets to beg Congress for
handouts to keep their companies afloat."    Bill Ragle


_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users