trixi-framework / P4est.jl

P4est.jl is lightweight Julia wrapper for the p4est C library, which allows to manage multiple connected adaptive quadtrees/octrees in parallel.

Home Page:https://trixi-framework.github.io/P4est.jl

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow to substitute p4est library with system-installed library with MPI support

ranocha opened this issue · comments

Once #4 and #5 are resolved, we should also allow build P4est.jl with a custom MPI-build of libp4est.

Actually, I am wondering if we should start with this issue before moving on to #4. I did succeed in finding a solution for #4 a few days ago, however, it does not make much sense before it is not possible to substitute the underlying library with a system-installed library first (i.e., the present issue). Otherwise, we effectively prevent anyone using P4est.jl from switching the underlying MPI implementation in MPI.jl from the default MPICH_jll.jl, as P4est_jll.jl links against that library.

However, trying to use JULIA_P4EST_PATH to switch to a library compiled with MPI support causes errors at package build time for P4est.jl, as the C binding generator cannot find mpi.h. Since mpi.h can include implementation-defined values/types, we must use the mpi.h that corresponds to the MPI implementation that is selected by MPI.jl, as the MPI version that p4est was built against must match the one that is used in MPI.jl.

But where do we get this include directory from? It would make most sense to somehow get it from MPI.jl, which seems to be impossible though (no include paths stored). Alternatively, one could just use env vars such as JULIA_P4EST_MPI_INCLUDE, but what to set this value to if the default MPICH_jll.jl is to be used? Or, worse, another BinaryBuilder-provided MPI version such as OpenMPI_jll.jl?

I don't know if my ramblings make much sense to you, but the gist is that I think we need to figure out this issue first before we should think about #4.

That sounds like a reasonable suggestion. Can we get the include paths etc. from mpicxx etc. and that one from MPI.jl?

Unfortunately not. The only portable "export" of the underlying library in MPI.jl so far is the mpiexec path (and if that one's on the PATH, it is not even an absolute path). mpicxx is Linux- and compiler-specific and might not be available for all jll packages, it certainly is not available for MicrosoftMPI_jll.

Right now, I don't really have a solution for this issue, but I created an issue at MPI.jl (JuliaParallel/MPI.jl#425) and I hope that they might have an idea about this...

Hmm, you're right (of course!). It would be really great if we could get everything from MPI.jl. I hope they have an idea.