Re: [Boost-bugs] [Boost C++ Libraries] #5596: MPI: problem creating communicator

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #5596: MPI: problem creating communicator
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-08-08 12:26:04


#5596: MPI: problem creating communicator
----------------------------------------+-----------------------------------
  Reporter: irek.szczesniak@… | Owner: dgregor
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: mpi
   Version: Boost 1.42.0 | Severity: Problem
Resolution: | Keywords:
----------------------------------------+-----------------------------------

Comment (by tapir2@…):

 {{{

 #include <vector>
 #include <boost/mpi.hpp>
 namespace mpi = boost::mpi;
 int main(int argc, char** argv)
 {
         mpi::environment env(argc, argv);
         mpi::communicator world;

         std::vector<int> ranks(1); // {0}
         mpi::group g = world.group(); // getting group from
 MPI_COMM_WORLD...
         g = g.include(ranks.begin(), ranks.end()); // ...and selecting
 only one (first) host from it

         /*
 ---------------------------------------------------------------------------------
         //sample 1: not work, inappropriate using MPI library calls
         //MPI_Comm_create (called from a mpi::communicator constructor) is
 a collective
         //operation and this function must be called on each host from
 parent communicator ("world" in this case)
         if (!world.rank())
         {
                 mpi::communicator myComm(world, g);
         }
         some_useful_function(); // <- we don't reach this place
         */

         /*
 ---------------------------------------------------------------------------------
         //sample 2: still not working
         //remove a condition (but still using local variable scope)
         //we call MPI_Comm_create on each host, but, only one host create
 communicator,
         //each other get MPI_COMM_NULL
         {
                 mpi::communicator myComm(world, g);
         } // <- at this place we have trouble with
 MPI_Comm_free(MPI_COMM_NULL)
           // because boost::mpi::communicator::comm_free don't check
 this
         */


         /*
 ---------------------------------------------------------------------------------
         //sample 3: work, but with restriction
         //manually call MPI_Finalize before myComm destructor
         //
         */
         mpi::communicator myComm(world, g);
         MPI::Finalize();

         return 0;
 }

 }}}

 as i think, decision for this problem is a small fix for communicator.hpp
 (i'm using boost 1.45):

 {{{
         struct comm_free
         {
                 void operator()(MPI_Comm* comm) const
                 {
                         int finalized;
                         BOOST_MPI_CHECK_RESULT(MPI_Finalized,
 (&finalized));
                         if (!finalized && (MPI_Comm)comm != MPI_COMM_NULL)
 //fix here
                                 BOOST_MPI_CHECK_RESULT(MPI_Comm_free,
 (comm));
                         delete comm;
                 }
         };
 }}}

 P.S. sorry for my english, it's not my first language :)

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/5596#comment:7>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:07 UTC