Skip to content

Commit a4dc686

Browse files
authored
Explicitly link MPI in setup.py (#4762)
* Explicitly link MPI in setup.py This should allow us to stop needing to hackily set CC=mpicc and CXX=mpicxx.
1 parent 2fe48b8 commit a4dc686

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

docker/Dockerfile.vanilla

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ ENV SLEPC_DIR=$PETSC_DIR/$PETSC_ARCH
132132
ENV PATH="$PETSC_DIR/$PETSC_ARCH/bin:$PATH"
133133

134134
ENV HDF5_MPI=ON
135-
ENV CC=mpicc CXX=mpicxx
136-
ENV MPICC=$CC
135+
ENV MPICC=mpicc
137136
ENV CFLAGS="-O3 -mtune=generic" CPPFLAGS="-O3 -mtune=generic"
138137

139138
# Install Firedrake

docs/source/install.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ install Firedrake. To do this perform the following steps:
226226

227227
.. code-block:: text
228228
229-
CC=mpicc CXX=mpicxx PETSC_DIR=/path/to/petsc PETSC_ARCH=arch-firedrake-{default,complex} HDF5_MPI=ON
229+
PETSC_DIR=/path/to/petsc PETSC_ARCH=arch-firedrake-{default,complex} HDF5_MPI=ON
230230
231231
.. note::
232232
This command will only work if you have the right starting directory.

scripts/firedrake-configure

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,6 @@ def prepare_environment_vars(
487487
arch: FiredrakeArch,
488488
) -> tuple[str, ...]:
489489
vars = {
490-
"CC": "mpicc",
491-
"CXX": "mpicxx",
492490
"PETSC_DIR": f"{os.getcwd()}/petsc",
493491
"PETSC_ARCH": f"arch-firedrake-{arch.value}",
494492
"HDF5_MPI": "ON",

setup.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ def __getitem__(self, key):
5454
raise KeyError(f"Key {key} not present")
5555

5656

57+
# MPI
58+
# strip the leading 'gcc' or equivalent
59+
mpi_args = petsctools.get_petscvariables()["MPICC_SHOW"].split()[1:]
60+
mpi_ = ExternalDependency(
61+
extra_compile_args=mpi_args,
62+
)
63+
64+
5765
# Pybind11
5866
# example:
5967
# gcc -I/pyind11/include ...
@@ -158,56 +166,56 @@ def extensions():
158166
name="firedrake.cython.dmcommon",
159167
language="c",
160168
sources=[os.path.join("firedrake", "cython", "dmcommon.pyx")],
161-
**(petsc_ + numpy_)
169+
**(mpi_ + petsc_ + numpy_)
162170
))
163171
# firedrake/cython/extrusion_numbering.pyx: petsc, numpy
164172
cython_list.append(Extension(
165173
name="firedrake.cython.extrusion_numbering",
166174
language="c",
167175
sources=[os.path.join("firedrake", "cython", "extrusion_numbering.pyx")],
168-
**(petsc_ + numpy_)
176+
**(mpi_ + petsc_ + numpy_)
169177
))
170178
# firedrake/cython/hdf5interface.pyx: petsc, numpy, hdf5
171179
cython_list.append(Extension(
172180
name="firedrake.cython.hdf5interface",
173181
language="c",
174182
sources=[os.path.join("firedrake", "cython", "hdf5interface.pyx")],
175-
**(petsc_ + numpy_ + hdf5_)
183+
**(mpi_ + petsc_ + numpy_ + hdf5_)
176184
))
177185
# firedrake/cython/mgimpl.pyx: petsc, numpy
178186
cython_list.append(Extension(
179187
name="firedrake.cython.mgimpl",
180188
language="c",
181189
sources=[os.path.join("firedrake", "cython", "mgimpl.pyx")],
182-
**(petsc_ + numpy_)
190+
**(mpi_ + petsc_ + numpy_)
183191
))
184192
# firedrake/cython/patchimpl.pyx: petsc, numpy
185193
cython_list.append(Extension(
186194
name="firedrake.cython.patchimpl",
187195
language="c",
188196
sources=[os.path.join("firedrake", "cython", "patchimpl.pyx")],
189-
**(petsc_ + numpy_)
197+
**(mpi_ + petsc_ + numpy_)
190198
))
191199
# firedrake/cython/spatialindex.pyx: numpy, spatialindex
192200
cython_list.append(Extension(
193201
name="firedrake.cython.spatialindex",
194202
language="c",
195203
sources=[os.path.join("firedrake", "cython", "spatialindex.pyx")],
196-
**(numpy_ + spatialindex_)
204+
**(mpi_ + numpy_ + spatialindex_)
197205
))
198206
# firedrake/cython/supermeshimpl.pyx: petsc, numpy, supermesh
199207
cython_list.append(Extension(
200208
name="firedrake.cython.supermeshimpl",
201209
language="c",
202210
sources=[os.path.join("firedrake", "cython", "supermeshimpl.pyx")],
203-
**(petsc_ + numpy_ + libsupermesh_)
211+
**(mpi_ + petsc_ + numpy_ + libsupermesh_)
204212
))
205213
# pyop2/sparsity.pyx: petsc, numpy,
206214
cython_list.append(Extension(
207215
name="pyop2.sparsity",
208216
language="c",
209217
sources=[os.path.join("pyop2", "sparsity.pyx")],
210-
**(petsc_ + numpy_)
218+
**(mpi_ + petsc_ + numpy_)
211219
))
212220
# PYBIND11 EXTENSIONS
213221
pybind11_list = []
@@ -216,7 +224,7 @@ def extensions():
216224
name="tinyasm._tinyasm",
217225
language="c++",
218226
sources=sorted(glob("tinyasm/*.cpp")), # Sort source files for reproducibility
219-
**(petsc_ + pybind11_)
227+
**(mpi_ + petsc_ + pybind11_)
220228
))
221229
return cythonize(cython_list) + pybind11_list
222230

0 commit comments

Comments
 (0)