Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Begin using Mac runners #3881

Merged
merged 49 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
21667d9
Add demo workflow file
connorjward Nov 22, 2024
997fbfa
Add conditional to workflow
connorjward Nov 25, 2024
d55bbdb
Attempt at a proper workflow
connorjward Nov 25, 2024
25edec0
try again
connorjward Nov 25, 2024
95bcb06
fixup
connorjward Nov 25, 2024
1906058
fixup
connorjward Nov 25, 2024
ec5d61a
fixup
connorjward Nov 25, 2024
8f9d31b
fixup
connorjward Nov 25, 2024
bf725e9
include necessary env var
connorjward Nov 25, 2024
e52a3ad
include cleanup
connorjward Nov 25, 2024
09eb6af
Use MPI 'on the outside'
connorjward Nov 25, 2024
b43df02
linting
connorjward Nov 25, 2024
d1a4846
testing
connorjward Nov 26, 2024
876babc
silly fixup
connorjward Nov 26, 2024
43ee976
testing, will only work on firedrake-mac1 for now
connorjward Nov 27, 2024
5055c54
Merge remote-tracking branch 'origin/master' into connorjward/test-ma…
connorjward Nov 28, 2024
aace66b
fixup from pyop2 merge
connorjward Nov 28, 2024
e5ee7fe
default to using zsh
connorjward Nov 28, 2024
42dd41b
use correct homebrew path
connorjward Nov 28, 2024
cc8b9e8
try again
connorjward Nov 28, 2024
49b1508
Remove pointer to merged branch
connorjward Nov 28, 2024
36b542a
Do not pin to Python 3.12
connorjward Nov 28, 2024
79f37da
Add pip macOS action
connorjward Nov 29, 2024
7059b66
Also install bison
connorjward Nov 29, 2024
e341a43
fixups
connorjward Nov 29, 2024
ce4ef45
testing
connorjward Nov 29, 2024
86a4af9
testing
connorjward Nov 29, 2024
7c04354
PETSc install bison
connorjward Nov 29, 2024
7582152
fixup
connorjward Dec 3, 2024
8ba6438
Specify HDF5_DIR
connorjward Dec 3, 2024
e96527c
Update .github/workflows/pip-mac.yml
connorjward Dec 3, 2024
3eb9800
fixups
connorjward Dec 3, 2024
82771e4
Update .github/workflows/pip-mac.yml
connorjward Dec 4, 2024
fb90620
mpi4py constraint
connorjward Dec 4, 2024
efb502d
Use our fork of h5py until upstream fixes things
connorjward Dec 4, 2024
93cf647
fix for parallel
connorjward Dec 4, 2024
8f71306
fixup
connorjward Dec 4, 2024
c8abf2f
Apply suggestions from code review
connorjward Dec 5, 2024
d3d1b06
Merge remote-tracking branch 'origin/master' into connorjward/test-ma…
connorjward Dec 5, 2024
830f58c
fixup pyop2 ci
connorjward Dec 5, 2024
97f2cb4
testing
connorjward Dec 5, 2024
00f6f76
Update pyproject.toml
connorjward Dec 5, 2024
20b551f
Very irritating fix
connorjward Dec 5, 2024
a3eb9c9
Apply suggestions from code review
connorjward Dec 5, 2024
126d87d
debugging
connorjward Dec 5, 2024
4bad1f3
Update .github/workflows/pip-mac.yml
connorjward Dec 5, 2024
3f0cc6d
debugging
connorjward Dec 5, 2024
a5bd616
Update .github/workflows/pip-mac.yml
connorjward Dec 5, 2024
b5baa84
purge pip cache every time
connorjward Dec 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/build-mac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Install and test Firedrake (macOS)

on:
push:
branches:
- master
pull_request:
# By default this workflow is run on the "opened", "synchronize" and
# "reopened" events. We add "labelled" so it will run if the PR is given a label.
types: [opened, synchronize, reopened, labeled]

concurrency:
# Cancels jobs running if new commits are pushed
group: >
${{ github.workflow }}-
${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build Firedrake (macOS)
runs-on: [self-hosted, macOS]
# Only run this action if we are pushing to master or the PR is labelled "macOS"
if: ${{ (github.ref == 'refs/heads/master') || contains(github.event.pull_request.labels.*.name, 'macOS') }}
env:
FIREDRAKE_CI_TESTS: 1 # needed to symlink the checked out branch into the venv
OMP_NUM_THREADS: 1
OPENBLAS_NUM_THREADS: 1
steps:
- name: Add homebrew to PATH
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#adding-a-system-path
run: echo "/opt/homebrew/bin" >> "$GITHUB_PATH"
- uses: actions/checkout@v4
- name: Pre-run cleanup
if: ${{ always() }}
run: |
cd ..
rm -rf firedrake_venv
- name: Install Python
run: brew install python python-setuptools
- name: Build Firedrake
run: |
cd ..
"$(brew --prefix)/bin/python3" \
firedrake/scripts/firedrake-install \
--venv-name firedrake_venv \
--disable-ssh \
|| (cat firedrake-install.log && /bin/false)
- name: Run smoke tests
run: |
. ../firedrake_venv/bin/activate
python -m pytest -v tests/firedrake/regression/ -k "poisson_strong or stokes_mini or dg_advection"
timeout-minutes: 30
- name: Post-run cleanup
if: ${{ always() }}
run: |
cd ..
rm -rf firedrake_venv
124 changes: 124 additions & 0 deletions .github/workflows/pip-mac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: Pip install Firedrake (macOS)

on:
push:
branches:
- master
pull_request:
# By default this workflow is run on the "opened", "synchronize" and
# "reopened" events. We add "labelled" so it will run if the PR is given a label.
types: [opened, synchronize, reopened, labeled]

concurrency:
# Cancels jobs running if new commits are pushed
group: >
${{ github.workflow }}-
${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
name: "Build Firedrake using pip (macOS)"
runs-on: [self-hosted, macOS]
# Only run this action if we are pushing to master or the PR is labelled "macOS"
if: ${{ (github.ref == 'refs/heads/master') || contains(github.event.pull_request.labels.*.name, 'macOS') }}
env:
OMP_NUM_THREADS: 1
OPENBLAS_NUM_THREADS: 1
steps:
- name: Cleanup (pre)
if: ${{ always() }}
run: rm -rf pip_venv

- name: Add homebrew to PATH
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#adding-a-system-path
run: echo "/opt/homebrew/bin" >> "$GITHUB_PATH"

- name: Install homebrew packages
run: brew install gcc autoconf pkg-config make automake cmake ninja libtool boost openblas python python-setuptools mpich

- name: Create a virtual environment
run: |
"$(brew --prefix)/bin/python3" -m venv pip_venv
mkdir pip_venv/src

- name: Install PETSc
run: |
cd pip_venv/src
git clone https://github.com/firedrakeproject/petsc.git
cd petsc
./configure PETSC_DIR="$PWD" PETSC_ARCH=default \
--with-shared-libraries=1 \
--with-mpi-dir=/opt/homebrew \
--with-zlib \
--download-bison \
--download-hdf5 \
--download-hwloc \
--download-hypre \
--download-metis \
--download-mumps \
--download-netcdf \
--download-pastix \
--download-pnetcdf \
--download-ptscotch \
--download-scalapack \
--download-suitesparse \
--download-superlu_dist
make

- name: Install libsupermesh
run: |
source pip_venv/bin/activate
pip install 'rtree>=1.2'
connorjward marked this conversation as resolved.
Show resolved Hide resolved
cd pip_venv/src
git clone https://github.com/firedrakeproject/libsupermesh.git
mkdir -p libsupermesh/build
cd libsupermesh/build
cmake .. \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_INSTALL_PREFIX="$VIRTUAL_ENV" \
-DMPI_C_COMPILER=/opt/homebrew/bin/mpicc \
-DMPI_CXX_COMPILER=/opt/homebrew/bin/mpicxx \
-DMPI_Fortran_COMPILER=/opt/homebrew/bin/mpif90 \
-DCMAKE_Fortran_COMPILER=/opt/homebrew/bin/mpif90 \
-DMPIEXEC_EXECUTABLE=/opt/homebrew/bin/mpiexec
make
make install

- uses: actions/checkout@v4
with:
path: pip_venv/src/firedrake

- name: Pip install
run: |
export PETSC_DIR="$PWD/pip_venv/src/petsc"
export PETSC_ARCH=default
export HDF5_DIR="$PETSC_DIR/$PETSC_ARCH"
export HDF5_MPI=ON
export CC=/opt/homebrew/bin/mpicc
export CXX=/opt/homebrew/bin/mpicxx
export MPICC="$CC"
source pip_venv/bin/activate
cd pip_venv/src
pip install \
connorjward marked this conversation as resolved.
Show resolved Hide resolved
--log=firedrake-install.log \
connorjward marked this conversation as resolved.
Show resolved Hide resolved
--no-cache \
--no-binary mpi4py,h5py \
-v -e './firedrake[test]'

- name: Install CI-specific test dependencies
run: |
source pip_venv/bin/activate
pip install -U pytest-timeout
connorjward marked this conversation as resolved.
Show resolved Hide resolved

- name: Run Firedrake smoke tests
run: |
source pip_venv/bin/activate
cd pip_venv/src/firedrake
pytest --timeout=1800 -v tests/firedrake/regression \
connorjward marked this conversation as resolved.
Show resolved Hide resolved
-k "poisson_strong or stokes_mini or dg_advection"
timeout-minutes: 30

- name: Cleanup (post)
if: ${{ always() }}
run: rm -rf pip_venv
connorjward marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 4 additions & 1 deletion .github/workflows/pyop2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ jobs:
working-directory: PyOP2
run: |
source ../venv/bin/activate
python -m pip install -v ".[test]"
export CC=mpicc
export HDF5_DIR="$PETSC_DIR/$PETSC_ARCH"
export HDF5_MPI=ON
python -m pip install --no-binary h5py -v ".[test]"

- name: Run tests
shell: bash
Expand Down
4 changes: 2 additions & 2 deletions docs/source/download.rst
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,10 @@ type::

You should now be able to run ``firedrake-update``.

Installing Firedrake with pip (experimental, Linux only)
Installing Firedrake with pip (experimental)
--------------------------------------------------------

Firedrake has experimental support for installing using ``pip``, avoiding the need for the ``firedrake-install`` script. At present only Linux is tested using this install method.
Firedrake has experimental support for installing using ``pip``, avoiding the need for the ``firedrake-install`` script.

Requirements
~~~~~~~~~~~~
Expand Down
12 changes: 9 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ requires-python = ">=3.10"
dependencies = [
"cachetools",
"decorator<=4.4.2",
"mpi4py",
"h5py",
"mpi4py>3; python_version >= '3.13'",
"mpi4py; python_version < '3.13'",
# TODO: We are only using our fork here because the most recent PyPI release
# does not yet work with build isolation for Python 3.13. Once a version
# newer than 3.12.1 is released we can revert to simply using "h5py".
"h5py @ git+https://github.com/firedrakeproject/h5py.git; python_version >= '3.13'",
connorjward marked this conversation as resolved.
Show resolved Hide resolved
"h5py; python_version < '3.13'",
"petsc4py",
"numpy",
"packaging",
Expand Down Expand Up @@ -91,7 +96,8 @@ requires = [
"pybind11",
"pkgconfig",
"numpy",
"mpi4py",
"mpi4py>3; python_version >= '3.13'",
"mpi4py; python_version < '3.13'",
"petsc4py",
"rtree>=1.2",
]
Expand Down
21 changes: 14 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
from dataclasses import dataclass, field
from setuptools import setup, find_packages, Extension
from glob import glob
from pathlib import Path
from Cython.Build import cythonize
import os
import platform
import sys
import site
import numpy as np
import pybind11
import petsc4py
import rtree
import pkgconfig
from dataclasses import dataclass, field
from setuptools import setup, find_packages, Extension
from glob import glob
from pathlib import Path
from Cython.Build import cythonize

# Define the compilers to use if not already set
if "CC" not in os.environ:
Expand Down Expand Up @@ -87,7 +88,14 @@ def __getitem__(self, key):
# Pybind11
# example:
# gcc -I/pyind11/include ...
pybind11_ = ExternalDependency(include_dirs=[pybind11.get_include()])
pybind11_extra_compile_args = []
if platform.uname().system == "Darwin":
# Clang needs to specify at least C++11
pybind11_extra_compile_args.append("-std=c++11")
pybind11_ = ExternalDependency(
include_dirs=[pybind11.get_include()],
extra_compile_args=pybind11_extra_compile_args,
)

# numpy
# example:
Expand Down Expand Up @@ -225,7 +233,6 @@ def extensions():
## PYBIND11 EXTENSIONS
pybind11_list = []
# tinyasm/tinyasm.cpp: petsc, pybind11
# tinyasm/tinyasm.cpp: petsc, pybind11
pybind11_list.append(Extension(
name="tinyasm._tinyasm",
language="c++",
Expand Down
12 changes: 10 additions & 2 deletions tests/firedrake/regression/test_dg_advection.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,16 @@ def run_test(mesh):
t = 0.0
T = 10*dt

problem = LinearVariationalProblem(a_mass, action(arhs, D1), dD1)
solver = LinearVariationalSolver(problem, solver_parameters={'ksp_type': 'cg'})
problem = LinearVariationalProblem(a_mass, action(arhs, D1), dD1,
constant_jacobian=True)
solver = LinearVariationalSolver(
problem,
solver_parameters={
'ksp_type': 'preonly',
'pc_type': 'bjacobi',
'sub_pc_type': 'ilu'
}
)

L2_0 = norm(D)
Dbar_0 = assemble(D*dx)
Expand Down
10 changes: 5 additions & 5 deletions tests/firedrake/regression/test_poisson_strong_bcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from firedrake import *


def run_test(r, degree, parameters={}, quadrilateral=False):
def run_test(r, degree, parameters, quadrilateral=False):
# Create mesh and define function space
mesh = UnitSquareMesh(2 ** r, 2 ** r, quadrilateral=quadrilateral)
x = SpatialCoordinate(mesh)
Expand All @@ -41,7 +41,7 @@ def run_test(r, degree, parameters={}, quadrilateral=False):
return sqrt(assemble(inner(u - f, u - f) * dx))


def run_test_linear(r, degree, parameters={}, quadrilateral=False):
def run_test_linear(r, degree, parameters, quadrilateral=False):
# Create mesh and define function space
mesh = UnitSquareMesh(2 ** r, 2 ** r, quadrilateral=quadrilateral)
x = SpatialCoordinate(mesh)
Expand Down Expand Up @@ -86,7 +86,7 @@ def test_poisson_analytic_linear(params, degree, quadrilateral):

@pytest.mark.parallel(nprocs=2)
def test_poisson_analytic_linear_parallel():
from mpi4py import MPI
error = run_test_linear(1, 1)
print('[%d]' % MPI.COMM_WORLD.rank, 'error:', error)
# specify superlu_dist as MUMPS fails in parallel on MacOS
solver_parameters = {'pc_factor_mat_solver_type': 'superlu_dist'}
error = run_test_linear(1, 1, solver_parameters)
assert error < 5e-6
Loading