Boost logo

Boost-MPI :

Subject: Re: [Boost-mpi] Attempting to use an MPI routine before initializing MPI. BGPL
From: Matthias Troyer (troyer_at_[hidden])
Date: 2013-10-13 05:03:37


On 13 Oct 2013, at 10:10, Николай Кинаш <peroksid90_at_[hidden]> wrote:

>
> Hi all.
>
> -bash-4.1$ cat network.cpp
> #include <boost/graph/use_mpi.hpp>
> #include <boost/mpi/environment.hpp>
> #include <boost/mpi/communicator.hpp>
> #include <iostream>
> #include <boost/graph/distributed/mpi_process_group.hpp>
> #include <boost/graph/parallel/process_group.hpp>
> #include <boost/graph/adjacency_list.hpp>
> #include <boost/graph/distributed/adjacency_list.hpp>
> #include <boost/graph/small_world_generator.hpp>
> #include <boost/random/linear_congruential.hpp>
>
> namespace mpi = boost::mpi;
>
> using namespace boost;
> using namespace graph;
> using namespace distributed;
>
> typedef boost::graph::distributed::mpi_process_group process_group;
>
> typedef boost::adjacency_list<listS,
> distributedS<mpi_process_group,vecS>,
> undirectedS> Graph;
>
> typedef boost::small_world_iterator<boost::minstd_rand, Graph> SWGen;
>
> int main(int argc, char* argv[])
> {
> boost::minstd_rand gen;
> Graph g(SWGen(gen, 10, 2, 0.03), SWGen(), 10);
> return 0;
> }
>
> -bash-4.1$ make
> mpiicc network.cpp -Wl,-rpath /opt/boost_1_54_0_icc/stage/lib/ -L/opt/boost_1_54_0_icc/stage/lib -lboost_mpi -lboost_graph_parallel -lboost_system -lboost_serialization -Wl,-rpath /opt/intel/composer_xe_2013.1.117/compiler/lib/intel64/ -L/opt/intel/composer_xe_2013.1.117/compiler/lib/intel64/ -limf -lirng -lintlc -lsvml -I/opt/boost_1_54_0_icc/ -o network
> -bash-4.1$ mpirun -np 2 ./network
> Attempting to use an MPI routine before initializing MPI
> Attempting to use an MPI routine before initializing MPI
> What`s wrong?
>
> Simple test:
> -bash-4.1$ cat boost_mpi.cpp
> #include <boost/mpi/environment.hpp>
> #include <boost/mpi/communicator.hpp>
> #include <iostream>
> namespace mpi = boost::mpi;
>
> int main(int argc, char* argv[])
> {
> mpi::environment env(argc, argv);
> mpi::communicator world;
> std::cout << "I am process " << world.rank() << " of " << world.size()
> << "." << std::endl;
> return 0;
> }
> -bash-4.1$ make boost_mpi
> mpiicc boost_mpi.cpp -I/opt/boost_1_54_0_icc/ -L/opt/boost_1_54_0_icc/stage/lib -lboost_mpi -lboost_serialization -Wl,-rpath /opt/boost_1_54_0_icc/stage/lib -L/opt/boost_1_54_0_icc/stage/lib -lboost_mpi -lboost_serialization -o boost_mpi
> -bash-4.1$ mpirun -np 3 ./boost_mpi
> I am process 0 of I am process I am process 3.
> 1 of 3.
> 2 of 3.
>

In the second, working, example you initialize MPI with the call to

mpi::environment env(argc, argv);

This is missing in your first example.

Matthias


Boost-Commit list run by troyer at boostpro.com