[Dune] [Dune-Commit] dune-common r6227 - trunk/dune/common
Martin Nolte
nolte at mathematik.uni-freiburg.de
Thu Nov 4 19:10:21 CET 2010
Hi Markus,
thanks for the hint (reading an MPI standard you never see when it was
introduced). I actually only checked with OpenMPI.
The reason for introducing the was that I had third party software that
brought a dummy implementation of MPI_Init. It took me about 2 hours to find
the problem. Now, the second assertion would fail. The reason for the other
assertion is exactly opposite: Make sure that third party software does not
initialize MPI before we do.
How should we deal with the situation? Simply reverting it will obviously
solve the insecurity, loosing the debugging hours, again. Another option would
be a configure check for MPI 2.0 (or specifically for MPI_Initialized). Since
a few interesting features have been introduced in MPI 2.0, we might want to
be aware of them anyway. The last possibility I can think of is waiting until
someone complains and keeping this in mind.
Best,
Martin
On 11/04/2010 04:18 PM, Markus Blatt wrote:
> Hey Martin,
>
> I am not 100% sure, but I think MPI_INITIALIZED is not part of the older
> MPI standards (e.g. 1.1, 1.0). Therefore this might break the code
> with some MPI implementations. Have you checked by using e.g. lam?
>
>
> Regards,
>
> Markus
>
> On Thu, Nov 04, 2010 at 11:19:26AM +0100, mnolte at dune-project.org wrote:
>> Author: mnolte
>> Date: 2010-11-04 11:19:25 +0100 (Thu, 04 Nov 2010)
>> New Revision: 6227
>>
>> Modified:
>> trunk/dune/common/mpihelper.hh
>> Log:
>> assert MPI_INITIALIZED returns the state we expect
>>
>>
>> Modified: trunk/dune/common/mpihelper.hh
>> ===================================================================
>> --- trunk/dune/common/mpihelper.hh 2010-11-03 15:37:16 UTC (rev 6226)
>> +++ trunk/dune/common/mpihelper.hh 2010-11-04 10:19:25 UTC (rev 6227)
>> @@ -202,14 +202,27 @@
>> int rank_;
>> int size_;
>> void prevent_warning(int){}
>> +
>> + static bool wasInitialized ()
>> + {
>> + int wasInitialized = -1;
>> + MPI_Initialized(&wasInitialized );
>> + return bool( wasInitialized );
>> + }
>>
>> //! \brief calls MPI_Init with argc and argv as parameters
>> MPIHelper(int& argc, char**& argv)
>> {
>> rank_ = -1;
>> size_ = -1;
>> +
>> + assert( !wasInitialized() );
>> static int is_initialized = MPI_Init(&argc,&argv);
>> prevent_warning(is_initialized);
>> +
>> + MPI_Init(&argc,&argv);
>> + assert( wasInitialized() );
>> +
>> MPI_Comm_rank(MPI_COMM_WORLD,&rank_);
>> MPI_Comm_size(MPI_COMM_WORLD,&size_);
>>
>>
>>
>> _______________________________________________
>> Dune-Commit mailing list
>> Dune-Commit at dune-project.org
>> http://lists.dune-project.org/mailman/listinfo/dune-commit
>>
>
--
Martin Nolte <nolte at mathematik.uni-freiburg.de>
Universität Freiburg phone: +49-761-203-5642
Abteilung für angewandte Mathematik fax: +49-761-203-5632
Hermann-Herder-Straße 10
79104 Freiburg, Germany
More information about the Dune
mailing list