[Dune-devel] The importance of MPIHelper in sequential programs

Christian Engwer christian.engwer at uni-muenster.de
Fri Oct 19 21:54:15 CEST 2018


Hi Oli,

I agree that MPI initialization of a sequential program is kind of
odd. On the other hand, you are not running a sequential program. Just
by accident you run a parallel program on a single node.

The problem is that you are not aware of the fact that the program is
MPI-parallel because Dune decided this for you.

One thing that (I think) would be less odd would be to state that we
have to call some Dune::Init(...) and this can do what ever is
necessary to properly setup dune. Currently the only thing that needs
to be done is initialize MPI, if MPI is available, but in the future
we could initialize other things, once we have this hook.

Ciao
Christian

On Fri, Oct 19, 2018 at 09:19:16PM +0200, Oliver Sander wrote:
> Dear Dune,
> 
> I often find myself in the situation of writing purely sequential Dune programs.
> They use grids like UGGrid or YaspGrid, but they are not supposed to be run in
> a distributed setting ever.
> 
> I nevertheless have to begin each such program with
> 
>   MPIHelper::instance(argc, argv);
> 
> This is because I do have MPI installed on my machine, and Dune has picked it up.
> Next, most grids have a CollectiveCommunication object somewhere, and the constructor
> of this will throw an exception if MPI_Init hasn't been called previously.
> 
> While this is easy to understand from a developer point of view, it still strikes
> me as odd from the user POV.  Why should I init MPI in a program that will never
> actually use it (except for deep under the hood, of course)?  On the other hand
> I have to admit that I do not know an obvious solution to this problem.
> Have the constructor of CollectiveCommunication call MPI_Init if necessary?
> Make it fall back to a sequential implementation if the communicator size is 1?
> 
> Anyhow, I'd be curious to hear other people's opinions on this.
> 
> Cheers,
> Oliver




More information about the Dune-devel mailing list