Boost logo

Boost Users :

Subject: Re: [Boost-users] [mpi] enviroment constructor different from MPI_Init
From: Matthias Troyer (troyer_at_[hidden])
Date: 2009-09-15 14:55:00


On Sep 15, 2009, at 8:12 PM, alfC wrote:

> I am using MPI in combination with BLACS and apparently it works with
> MPI_Init but not with boost.MPI
>
> when I use
>
> #include "blacs.h"
> int main(int argc, char* argv[]) {
> MPI_Init(&argc,&argv);
> int nprocs=0;
> int mype=0;
> Cblacs_pinfo( &mype, &nprocs ); // overwrites the pointee, that is
> how Cblacs_pinfo works
> std::cout<<mype<<" "<<nprocs<<std::endl;
>
> the program output (correctly): "0 1"
>
> But when I use
>
> boost::mpi::environment env(argc, argv); //instead of MPI_Init(argc,
> argv);
>
> the programs outputs (incorrectly): "0 -1".
>
> The point being that apparently boost::mpi::environment is not
> equivalent to MPI_Init/MPI_Finalize.
>
> Any idea of what is difference between MPI_Init and
> boost::mpi::environment?

The constructor is equivalent to the following:

   int flag;
   MPI_Initialized(&flag);
   if (!(flag!=0))
     MPI_Init(&argc, &argv);
   MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);

Matthias Troyer


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net