[mpi] enviroment constructor different from MPI_Init
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<
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<
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
ok I tried your code and MPI_Init-like version still works and
boost::mpi::environment version doesn't (i.e. Blacs returns the wrong
nprocs)
In fact the Blacs_pinfo returns just the same as if I don't define
anything so effectivelly the boost::mpi::environment is doing nothing.
I even checked that boost::mpi::environment::initialized() is false
before constructing boost::mpi::environment and true after, but still
Blacs_pinfo reports as if MPI is not initialized.
On Sep 15, 11:55 am, Matthias Troyer
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<
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 mailing list Boost-us...@lists.boost.orghttp://lists.boost.org/mailman/listinfo.cgi/boost-users- Hide quoted text -
- Show quoted text -
AlfC wrote:
ok I tried your code and MPI_Init-like version still works and boost::mpi::environment version doesn't (i.e. Blacs returns the wrong nprocs)
In fact the Blacs_pinfo returns just the same as if I don't define anything so effectivelly the boost::mpi::environment is doing nothing.
I even checked that boost::mpi::environment::initialized() is false before constructing boost::mpi::environment and true after, but still Blacs_pinfo reports as if MPI is not initialized.
What platform are you using? Are you sure that BLACS and boost::mpi are using the same MPI library? If BLACS is linked against a different MPI library, for example, then you might see something like this. HTH, Ian McCulloch
On Sep 16, 2009, at 6:38 AM, Ian McCulloch wrote:
AlfC wrote:
ok I tried your code and MPI_Init-like version still works and boost::mpi::environment version doesn't (i.e. Blacs returns the wrong nprocs)
In fact the Blacs_pinfo returns just the same as if I don't define anything so effectivelly the boost::mpi::environment is doing nothing.
I even checked that boost::mpi::environment::initialized() is false before constructing boost::mpi::environment and true after, but still Blacs_pinfo reports as if MPI is not initialized.
What platform are you using? Are you sure that BLACS and boost::mpi are using the same MPI library? If BLACS is linked against a different MPI library, for example, then you might see something like this.
That was just my next question. Do you link with the same MPI when you use Boost.MPI or the C API? Matthias
Are you sure that BLACS and boost::mpi are using the same MPI library? If BLACS is linked against a different MPI library, for example, then you might see something like this.
I can confirm that the problem was that. I was using some libraries from the distribution (Ubuntu) and some of them were compiled with different mpi implementations, it was difficult to track which one was which. So I decided to compile MPICH, Blacs, and Boost from scratch and now it works. Thank you Matthias and Ian. Alfredo
participants (4)
-
alfC
-
AlfC
-
Ian McCulloch
-
Matthias Troyer