#1082085 libsundials-dev: sundials_config.h sets SUNDIALS_MPI_ENABLED=1 even for serial jobs

Package:
libsundials-dev
Source:
libsundials-dev
Description:
Package providing everything for SUNDIALS dev work
Submitter:
Drew Parsons
Date:
2025-07-26 23:21:01 UTC
Severity:
normal
#1082085#5
Date:
2024-09-18 07:59:13 UTC
From:
To:
The build for sundials 7.1.1 seems to hardcode support for MPI, placing
#define SUNDIALS_MPI_ENABLED 1
in /usr/include/sundials/sundials_config.h

This makes it more difficult than it should be to use components of
SUNDIALS in serial applications, which get an error like

In file included from /usr/include/arkode/arkode_butcher.h:21,
                 from /usr/include/arkode/arkode.h:31,
                 from /usr/include/arkode/arkode_erkstep.h:20,
                 from include/opendrop/younglaplace.hpp:9,
                 from opendrop/fit/younglaplace/.checkpoints/shape.cpp:1239:
/usr/include/sundials/sundials_types.h:57:10: fatal error: mpi.h: No such file or directory
   57 | #include <mpi.h>
      |          ^~~~~~~
compilation terminated.

#1082085#10
Date:
2024-09-18 08:22:57 UTC
From:
To:
The issue is known upstream, and in fact is deliberate.  In that sense it is not a bug, but may be
an issue for reverse dependencies.

The change in behaviour comes from the introduction of SUNComm in PR#370
https://github.com/LLNL/sundials/pull/370
committed at https://github.com/LLNL/sundials/commit/947ad4b68dc8add194422237bc16934324ac0730

From the commit description:
"Requires MPI to be linked to SUNDIALS core if it is enabled thus all-in-one MPI and non-MPI builds are no longer supported. Instead user will have to separately build and install with and without MPI."

To keep both would require packaging a separate serial build, as is done with HDF5 and ADIOS2.
This will require a bit of Debian maintainer work, which I personally an not in a rush to do.

Upstream mainly expects client apps to use cmake, in which case there is no operational problem (just means such applications
will be linked to libmpi.so even if they're not using MPI directly).

Some applications such as opendrop do not use cmake. If we keep sundials 7 as-is (with MPI support), then these
non-cmake apps will need to be patched to enable access to mpi.h. Setting CXX=mpicxx might be sufficient.

It'probably s reasonable for the default build oSUNDIALS to support MPI.
More complex client applications such as deal.ii would want it.