Skip to content

Commit

Permalink
Adding support to control mpi use in meson.
Browse files Browse the repository at this point in the history
Disabling mpi in macos brew build (bug in the MPI lib).
  • Loading branch information
vitenti committed Apr 3, 2024
1 parent d2deb81 commit 2aa6fd9
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ jobs:
python-version: '3.x'
- name: Brew install pre-requisites
run: |
brew install gobject-introspection gsl gmp mpfr fftw cfitsio libfyaml nlopt gfortran gtk-doc glib openblas open-mpi
brew install gobject-introspection gsl gmp mpfr fftw cfitsio libfyaml nlopt gfortran gtk-doc glib openblas
- name: Pip install pre-requisites
run: |
pip3 install meson ninja pytest pytest-tap numpy pygobject
- name: Ensure clear Jupyter Notebooks
uses: ResearchSoftwareActions/EnsureCleanNotebooksAction@1.1
- name: Configure NumCosmo
run: |
meson setup build -Dbuildtype=release -Dnumcosmo_py=true --prefix=/usr || (cat build/meson-logs/meson-log.txt && exit 1)
meson setup build -Dbuildtype=release -Dnumcosmo_py=true -Dmpi=disabled --prefix=/usr || (cat build/meson-logs/meson-log.txt && exit 1)
- name: Building NumCosmo
run: |
meson compile -C build
Expand Down
47 changes: 30 additions & 17 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -360,26 +360,39 @@ flint_req = '>= 3.0'
#######################################################################################
message('Checking for MPI')

mpi_c_dep = dependency(
'mpi',
language: 'c',
required: false,
)
if get_option('mpi').auto() or get_option('mpi').enabled()

mpi_fortran_dep = dependency(
'mpi',
language: 'fortran',
required: false,
)
mpi_c_dep = dependency(
'mpi',
language: 'c',
required: false,
)

# MPICH is not found by the mpi dependency, so we need to check for it manually
if not mpi_c_dep.found()
mpi_c_dep = dependency('mpich', required: false)
endif
mpi_fortran_dep = dependency(
'mpi',
language: 'fortran',
required: false,
)

# MPICH is not found by the mpi dependency, so we need to check for it manually
if not mpi_fortran_dep.found()
mpi_fortran_dep = dependency('mpichf90', required: false)
# MPICH is not found by the mpi dependency, so we need to check for it manually
if (not mpi_c_dep.found())
mpi_c_dep = dependency('mpich', required: false)
endif

# MPICH is not found by the mpi dependency, so we need to check for it manually
if (not mpi_fortran_dep.found())
mpi_fortran_dep = dependency('mpichf90', required: false)
endif

if get_option('mpi').enabled() and not mpi_c_dep.found()
error(
'''MPI support requested but not found. Both attempts to locate MPI dependency, \
using Meson's generic finder and MPICH specifically, failed.''',
)
endif
else
mpi_c_dep = not_found
mpi_fortran_dep = not_found
endif

if mpi_c_dep.found()
Expand Down
7 changes: 7 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,10 @@ option(
value: false,
description: 'Enable MPI debug messages',
)

option(
'mpi',
type: 'feature',
value: 'auto',
description: 'Enable MPI support',
)

0 comments on commit 2aa6fd9

Please sign in to comment.