From 24462b558e63d8000be01fa9265065731c988d32 Mon Sep 17 00:00:00 2001 From: Connor Ward Date: Mon, 11 Dec 2023 11:06:39 +0000 Subject: [PATCH 01/19] Fix cython files for Cython 3.0 --- firedrake/cython/dmcommon.pyx | 10 +++++----- firedrake/cython/mgimpl.pyx | 2 +- firedrake/cython/petschdr.pxi | 2 +- scripts/firedrake-install | 27 ++++----------------------- 4 files changed, 11 insertions(+), 30 deletions(-) diff --git a/firedrake/cython/dmcommon.pyx b/firedrake/cython/dmcommon.pyx index cbe124ae67..5a61aecc28 100644 --- a/firedrake/cython/dmcommon.pyx +++ b/firedrake/cython/dmcommon.pyx @@ -675,7 +675,7 @@ def closure_ordering(PETSc.DM dm, incident = 1 break if incident == 0: - face_indices[nfaces] += v * 10**(1-fi) + face_indices[nfaces] += v * 10**(1-fi) fi += 1 nfaces += 1 @@ -1019,7 +1019,7 @@ cdef inline PetscInt _compute_orientation_interval_tensor_product(PetscInt *fiat # io += (2**(dim - 1 - i)) * 0 pass elif plex_cone_copy[2 * j + 1] == fiat_cone[2 * i] and plex_cone_copy[2 * j] == fiat_cone[2 * i + 1]: - io += (2**(dim - 1 - i)) * 1 + io += (2**(dim - 1 - i)) * 1 else: raise RuntimeError("Found inconsistent fiat_cone and plex_cone") eo += np.math.factorial(dim - 1 - i) * j @@ -1031,7 +1031,7 @@ cdef inline PetscInt _compute_orientation_interval_tensor_product(PetscInt *fiat else: raise RuntimeError("Found inconsistent fiat_cone and plex_cone") assert dim1 == 0 - return (2**dim) * eo + io + return (2**dim) * eo + io cdef inline PetscInt _compute_orientation(PETSc.DM dm, @@ -2440,7 +2440,7 @@ cdef struct CommFacet: PetscInt global_u, global_v PetscInt local_facet -cdef int CommFacet_cmp(void *x_, void *y_) nogil: +cdef int CommFacet_cmp(void *x_, void *y_) noexcept nogil: """Three-way comparison C function for CommFacet structs.""" cdef: CommFacet *x = x_ @@ -3259,7 +3259,7 @@ cdef int DMPlexGetAdjacency_Facet_Support(PETSc.PetscDM dm, PetscInt p, PetscInt *adjSize, PetscInt adj[], - void *ctx) nogil: + void *ctx) noexcept nogil: """Custom adjacency callback for halo growth. :arg dm: The DMPlex object. diff --git a/firedrake/cython/mgimpl.pyx b/firedrake/cython/mgimpl.pyx index bd7f9d13f8..2867b5e79f 100644 --- a/firedrake/cython/mgimpl.pyx +++ b/firedrake/cython/mgimpl.pyx @@ -254,7 +254,7 @@ def coarse_to_fine_cells(mc, mf, clgmaps, flgmaps): cdm = mc.topology_dm fdm = mf.topology_dm dim = cdm.getDimension() - nref = 2 ** dim + nref = 2 ** dim ncoarse = mc.cell_set.size nfine = mf.cell_set.size co2n, _ = get_entity_renumbering(cdm, mc._cell_numbering, "cell") diff --git a/firedrake/cython/petschdr.pxi b/firedrake/cython/petschdr.pxi index b64a5620f5..f5e4bb2d53 100644 --- a/firedrake/cython/petschdr.pxi +++ b/firedrake/cython/petschdr.pxi @@ -175,7 +175,7 @@ cdef inline int SETERR(int ierr) with gil: PyErr_SetObject(PyExc_RuntimeError, ierr) return ierr -cdef inline int CHKERR(int ierr) nogil except -1: +cdef inline int CHKERR(int ierr) except -1 nogil: if ierr == 0: return 0 # no error else: diff --git a/scripts/firedrake-install b/scripts/firedrake-install index d893fad161..395b709d04 100755 --- a/scripts/firedrake-install +++ b/scripts/firedrake-install @@ -1003,14 +1003,6 @@ def run_pip_install_wrap(reqs, parallel_compiler_env): if package_name in parallel_packages: with environment(**parallel_compiler_env): run_pip_install([req]) - elif package_name == "numpy": - # Downgrade setuptools and wheel for numpy - run_pip(["install", "-U", "setuptools==59.2.0"]) - run_pip(["install", "-U", "wheel==0.37.0"]) - run_pip_install(["numpy==1.24"]) - # Upgrade setuptools and wheel for everything else - run_pip(["install", "-U", "setuptools"]) - run_pip(["install", "-U", "wheel"]) else: run_pip_install([req]) @@ -1750,14 +1742,10 @@ if mode == "install": os.environ["VIRTUAL_ENV"] = firedrake_env # Ensure pip, setuptools, hatchling and wheel are at the latest version. -# numpy requires setuptools==59.2.0 and wheel==0.37.0 until it moves to meson build -run_pip(["install", "-U", "setuptools==59.2.0"]) +run_pip(["install", "-U", "setuptools"]) run_pip(["install", "-U", "hatch"]) run_pip(["install", "-U", "pip"]) -run_pip(["install", "-U", "wheel==0.37.0"]) - -# Pin Cython because it's causing multiple packages to fail to build -run_pip(["install", "-U", "Cython==0.29.36"]) +run_pip(["install", "-U", "wheel"]) # Loopy has additional build dependencies run_pip(["install", "-U", "scikit-build"]) @@ -1856,7 +1844,7 @@ if mode == "install": build_update_script() # Force Cython to install first to work around pip dependency issues. - run_pip_install(["Cython>=0.22"]) + run_pip_install(["Cython"]) # Pre-install requested packages if args.pip_packages is not None: @@ -1928,14 +1916,7 @@ if mode == "install": with environment(**compiler_env, **link_env): run_pip_install(["--no-cache-dir", "mpi4py"]) - # numpy requires old setuptools (+wheel) - log.info("Installing numpy using setuptools==59.2.0 and wheel==0.37.0 and Cython==0.29.36") - log.info("Installing numpy==1.24 due to performance regression") - # https://github.com/inducer/pytential/issues/211 - run_pip_install(["numpy==1.24"]) - log.info("Updating setuptools and wheel to latest versions") - run_pip(["install", "-U", "setuptools"]) - run_pip(["install", "-U", "wheel"]) + run_pip_install(["numpy"]) for p in packages: pip_requirements(p, compiler_env) From abeb70b42da2dda4860bb0608b6b5201f7d1f080 Mon Sep 17 00:00:00 2001 From: Connor Ward Date: Mon, 11 Dec 2023 11:20:30 +0000 Subject: [PATCH 02/19] update firedrake-install for numpy deps --- scripts/firedrake-install | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/scripts/firedrake-install b/scripts/firedrake-install index 395b709d04..9da87bb02e 100755 --- a/scripts/firedrake-install +++ b/scripts/firedrake-install @@ -676,7 +676,6 @@ def check_output(args): raise -pyinstall = [python, "setup.py", "install"] if "PYTHONPATH" in os.environ and not args.honour_pythonpath: quit("""The PYTHONPATH environment variable is set. This is probably an error. If you really want to use your own Python packages, please run again with the @@ -983,14 +982,10 @@ def run_pip_install(pipargs): # subprocesses wrote out. # Particularly important for debugging petsc fails. with environment(**blas): - pipargs = ["-vvv"] + pipargs + pipargs = ["-v"] + pipargs check_call(pipinstall + pipargs) -def run_cmd(args): - check_call(args) - - def get_requirements(reqfname): with open(reqfname, "r") as f: reqs = f.readlines() @@ -1747,6 +1742,11 @@ run_pip(["install", "-U", "hatch"]) run_pip(["install", "-U", "pip"]) run_pip(["install", "-U", "wheel"]) +# Extra numpy dependendencies, see +# https://github.com/numpy/numpy/blob/main/pyproject.toml +run_pip(["meson-python>=0.15.0"]) +run_pip_install(["Cython>=3.0"]) + # Loopy has additional build dependencies run_pip(["install", "-U", "scikit-build"]) run_pip(["install", "-U", "nanobind"]) @@ -1843,9 +1843,6 @@ if mode == "install": # recovery can be attempted if required. build_update_script() - # Force Cython to install first to work around pip dependency issues. - run_pip_install(["Cython"]) - # Pre-install requested packages if args.pip_packages is not None: for package in args.pip_packages: From 432203014e3ad15d1c4e2615538c0bd3decd4c67 Mon Sep 17 00:00:00 2001 From: Connor Ward Date: Mon, 11 Dec 2023 11:22:40 +0000 Subject: [PATCH 03/19] lint --- scripts/firedrake-install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/firedrake-install b/scripts/firedrake-install index 9da87bb02e..7a59f206f9 100755 --- a/scripts/firedrake-install +++ b/scripts/firedrake-install @@ -1742,7 +1742,7 @@ run_pip(["install", "-U", "hatch"]) run_pip(["install", "-U", "pip"]) run_pip(["install", "-U", "wheel"]) -# Extra numpy dependendencies, see +# Extra numpy dependendencies, see # https://github.com/numpy/numpy/blob/main/pyproject.toml run_pip(["meson-python>=0.15.0"]) run_pip_install(["Cython>=3.0"]) From 7856e787728a09324e86f25ca8e638cb32c7231e Mon Sep 17 00:00:00 2001 From: Connor Ward Date: Mon, 11 Dec 2023 11:25:49 +0000 Subject: [PATCH 04/19] Silly fixes --- scripts/firedrake-install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/firedrake-install b/scripts/firedrake-install index 7a59f206f9..8c2f430415 100755 --- a/scripts/firedrake-install +++ b/scripts/firedrake-install @@ -1744,8 +1744,8 @@ run_pip(["install", "-U", "wheel"]) # Extra numpy dependendencies, see # https://github.com/numpy/numpy/blob/main/pyproject.toml -run_pip(["meson-python>=0.15.0"]) -run_pip_install(["Cython>=3.0"]) +run_pip(["install", "-U", "meson-python>=0.15.0"]) +run_pip(["install", "-U", "Cython>=3.0"]) # Loopy has additional build dependencies run_pip(["install", "-U", "scikit-build"]) From 97394e7f145c0df2e2870a38044d81591951b1eb Mon Sep 17 00:00:00 2001 From: Connor Ward Date: Mon, 11 Dec 2023 11:34:27 +0000 Subject: [PATCH 05/19] Add ninja system dependency --- docs/source/download.rst | 1 + scripts/firedrake-install | 2 ++ 2 files changed, 3 insertions(+) diff --git a/docs/source/download.rst b/docs/source/download.rst index 7037f49cc2..d10fa49900 100644 --- a/docs/source/download.rst +++ b/docs/source/download.rst @@ -135,6 +135,7 @@ they have the system dependencies: * CMake * zlib * flex, bison +* Ninja Firedrake has been successfully installed on Windows 10 using the Windows Subsystem for Linux. There are more detailed instructions for diff --git a/scripts/firedrake-install b/scripts/firedrake-install index 8c2f430415..01dbd8ca29 100755 --- a/scripts/firedrake-install +++ b/scripts/firedrake-install @@ -1580,6 +1580,7 @@ if mode == "install" or not args.update_script: "make", "automake", "cmake", + "ninja", "libtool", "boost"] if args.with_blas is None and mode == "install": @@ -1598,6 +1599,7 @@ if mode == "install" or not args.update_script: "pkgconf", # for p4est "libtool", "libxml2-dev", + "ninja-build", # for meson/numpy "python3-dev", "python3-pip", "python3-tk", From 2fd6535d3ca2cfd5775cd2025695e0179afccfcd Mon Sep 17 00:00:00 2001 From: Connor Ward Date: Mon, 11 Dec 2023 11:46:35 +0000 Subject: [PATCH 06/19] Since we are using the docker container --- .github/workflows/build.yml | 2 ++ docker/Dockerfile.env | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 70411ea4a3..ae9c2e226e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,6 +57,8 @@ jobs: - name: Build Firedrake run: | cd .. + # DO NOT MERGE: just until we rebuild the Docker container + sudo apt install ninja-build # Linting should ignore unquoted shell variable $COMPLEX # shellcheck disable=SC2086 ./firedrake/scripts/firedrake-install \ diff --git a/docker/Dockerfile.env b/docker/Dockerfile.env index 6f3d17251f..a839d45f3e 100644 --- a/docker/Dockerfile.env +++ b/docker/Dockerfile.env @@ -13,7 +13,7 @@ RUN apt-get update \ cmake gfortran git libopenblas-serial-dev \ libtool python3-dev python3-pip python3-tk python3-venv \ python3-requests zlib1g-dev libboost-dev sudo gmsh \ - bison flex \ + bison flex ninja-build \ liboce-ocaf-dev \ swig graphviz \ libcurl4-openssl-dev libxml2-dev \ From a061ff185fff7eee6d928017d3dfda8a14313a19 Mon Sep 17 00:00:00 2001 From: Connor Ward Date: Mon, 11 Dec 2023 11:52:36 +0000 Subject: [PATCH 07/19] fixup --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ae9c2e226e..608408ac1a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -58,7 +58,8 @@ jobs: run: | cd .. # DO NOT MERGE: just until we rebuild the Docker container - sudo apt install ninja-build + sudo apt-get update + sudo apt-get -y install ninja-build # Linting should ignore unquoted shell variable $COMPLEX # shellcheck disable=SC2086 ./firedrake/scripts/firedrake-install \ From 2460c07e73db79b2b62d03bd88b6bac46c667a0e Mon Sep 17 00:00:00 2001 From: Connor Ward Date: Thu, 11 Apr 2024 09:06:21 +0100 Subject: [PATCH 08/19] Install with numpy 2.0 release candidate --- scripts/firedrake-install | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/firedrake-install b/scripts/firedrake-install index 01dbd8ca29..7ecf505f6e 100755 --- a/scripts/firedrake-install +++ b/scripts/firedrake-install @@ -1747,7 +1747,7 @@ run_pip(["install", "-U", "wheel"]) # Extra numpy dependendencies, see # https://github.com/numpy/numpy/blob/main/pyproject.toml run_pip(["install", "-U", "meson-python>=0.15.0"]) -run_pip(["install", "-U", "Cython>=3.0"]) +run_pip(["install", "-U", "Cython>=3.0.6"]) # Loopy has additional build dependencies run_pip(["install", "-U", "scikit-build"]) @@ -1915,7 +1915,9 @@ if mode == "install": with environment(**compiler_env, **link_env): run_pip_install(["--no-cache-dir", "mpi4py"]) - run_pip_install(["numpy"]) + # 11/04/24 Install a 2.0 release candidate because 2.0 has not yet been + # officially released but we cannot build petsc4py without it. + run_pip_install(["numpy==2.0.0rc1"]) for p in packages: pip_requirements(p, compiler_env) From fbe58f14ae97d7437959f04ee1df8495cd69a891 Mon Sep 17 00:00:00 2001 From: Connor Ward Date: Thu, 11 Apr 2024 09:22:56 +0100 Subject: [PATCH 09/19] fixup --- scripts/firedrake-install | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/scripts/firedrake-install b/scripts/firedrake-install index b1ad67bca4..fccadc1077 100755 --- a/scripts/firedrake-install +++ b/scripts/firedrake-install @@ -1723,6 +1723,11 @@ run_pip(["install", "-U", "wheel"]) run_pip(["install", "-U", "meson-python>=0.15.0"]) run_pip(["install", "-U", "Cython>=3.0.6"]) +# 11/04/24 Install a 2.0 release candidate because 2.0 has not yet been +# officially released but we cannot build petsc4py without it. +run_pip_install(["numpy==2.0.0rc1"]) + + # Loopy has additional build dependencies run_pip(["install", "-U", "scikit-build"]) run_pip(["install", "-U", "nanobind"]) @@ -1815,15 +1820,6 @@ if mode == "install": log.info("Pip installing %s to venv" % package) run_pip_install_wrap(package.split(), {}) - # numpy requires old setuptools (+wheel) - log.info("Installing numpy using setuptools==59.2.0 and wheel==0.37.0 and Cython==0.29.36") - log.info("Installing numpy==1.24 due to performance regression") - # https://github.com/inducer/pytential/issues/211 - run_pip_install(["numpy==1.24"]) - log.info("Updating setuptools and wheel to latest versions") - run_pip(["install", "-U", "setuptools"]) - run_pip(["install", "-U", "wheel"]) - # Install VTK if not args.no_vtk: log.info("Pip installing VTK to venv") @@ -1875,10 +1871,6 @@ if mode == "install": with environment(**compiler_env, **link_env): run_pip_install(["--no-cache-dir", "mpi4py"]) - # 11/04/24 Install a 2.0 release candidate because 2.0 has not yet been - # officially released but we cannot build petsc4py without it. - run_pip_install(["numpy==2.0.0rc1"]) - for p in packages: pip_requirements(p, compiler_env) From ad32e6c7fb8f16322d74a64d7f36d689f92c95ed Mon Sep 17 00:00:00 2001 From: Connor Ward Date: Thu, 11 Apr 2024 11:10:16 +0100 Subject: [PATCH 10/19] fixup --- scripts/firedrake-install | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/firedrake-install b/scripts/firedrake-install index fccadc1077..99bae96899 100755 --- a/scripts/firedrake-install +++ b/scripts/firedrake-install @@ -1725,8 +1725,7 @@ run_pip(["install", "-U", "Cython>=3.0.6"]) # 11/04/24 Install a 2.0 release candidate because 2.0 has not yet been # officially released but we cannot build petsc4py without it. -run_pip_install(["numpy==2.0.0rc1"]) - +run_pip(["install", "-U", "numpy==2.0.0rc1"]) # Loopy has additional build dependencies run_pip(["install", "-U", "scikit-build"]) From 81801ca6613ace0f6554389e8928fa3fef78e6d9 Mon Sep 17 00:00:00 2001 From: Connor Ward Date: Thu, 11 Apr 2024 11:50:59 +0100 Subject: [PATCH 11/19] fixup --- .github/workflows/build.yml | 1 + scripts/firedrake-install | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ea2f76b4ef..da0089fff1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -87,6 +87,7 @@ jobs: --install defcon \ --install gadopt \ --install asQ \ + --package-branch fiat connorjward/numpy2 \ || (cat firedrake-install.log && /bin/false) - name: Install test dependencies run: | diff --git a/scripts/firedrake-install b/scripts/firedrake-install index 99bae96899..b74e155adc 100755 --- a/scripts/firedrake-install +++ b/scripts/firedrake-install @@ -1334,7 +1334,8 @@ def build_and_install_torch(): raise InstallError("CUDA installation is not available on MacOS.") if sys.version_info >= (3, 10): run_pip_install(["typing_extensions"]) - extra_index_url = ["--extra-index-url", "https://download.pytorch.org/whl/cpu"] if args.torch == "cpu" else [] + # FIXME: use nightly to see if that makes numpy 2.0 happy + extra_index_url = ["--extra-index-url", "https://download.pytorch.org/whl/nightly/cpu"] if args.torch == "cpu" else [] run_pip_install(["torch"] + extra_index_url) From ef73ae78e3cfa2a2ece5df7656e9c0539fda1f6a Mon Sep 17 00:00:00 2001 From: Connor Ward Date: Thu, 11 Apr 2024 12:09:40 +0100 Subject: [PATCH 12/19] fixup --- scripts/firedrake-install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/firedrake-install b/scripts/firedrake-install index b74e155adc..f6083d7914 100755 --- a/scripts/firedrake-install +++ b/scripts/firedrake-install @@ -1336,7 +1336,7 @@ def build_and_install_torch(): run_pip_install(["typing_extensions"]) # FIXME: use nightly to see if that makes numpy 2.0 happy extra_index_url = ["--extra-index-url", "https://download.pytorch.org/whl/nightly/cpu"] if args.torch == "cpu" else [] - run_pip_install(["torch"] + extra_index_url) + run_pip_install(["--pre", "torch"] + extra_index_url) def build_and_install_slepc(): From 08f10020186564316f94605fb822a33120840281 Mon Sep 17 00:00:00 2001 From: Connor Ward Date: Thu, 11 Apr 2024 15:11:48 +0100 Subject: [PATCH 13/19] fixup --- firedrake/cython/dmcommon.pyx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/firedrake/cython/dmcommon.pyx b/firedrake/cython/dmcommon.pyx index e6addac272..825c5f271e 100644 --- a/firedrake/cython/dmcommon.pyx +++ b/firedrake/cython/dmcommon.pyx @@ -2,6 +2,7 @@ # Utility functions common to all DMs used in Firedrake import functools +import math import cython import numpy as np import firedrake @@ -970,7 +971,7 @@ cdef inline PetscInt _compute_orientation_simplex(PetscInt *fiat_cone, coneSize1 -= 1 assert n == coneSize for k in range(n): - o += np.math.factorial(n - 1 - k) * inds[k] + o += math.factorial(n - 1 - k) * inds[k] CHKERR(PetscFree(cone1)) CHKERR(PetscFree(inds)) return o @@ -1022,7 +1023,7 @@ cdef inline PetscInt _compute_orientation_interval_tensor_product(PetscInt *fiat io += (2**(dim - 1 - i)) * 1 else: raise RuntimeError("Found inconsistent fiat_cone and plex_cone") - eo += np.math.factorial(dim - 1 - i) * j + eo += math.factorial(dim - 1 - i) * j for k in range(j, dim1 - 1): plex_cone_copy[2 * k] = plex_cone_copy[2 * k + 2] plex_cone_copy[2 * k + 1] = plex_cone_copy[2 * k + 3] From 0c2d63c19951bb92fe2e34c75c3d289232588fdc Mon Sep 17 00:00:00 2001 From: Connor Ward Date: Thu, 11 Apr 2024 15:46:16 +0100 Subject: [PATCH 14/19] PYOP2 branch --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index da0089fff1..fee99cf9c4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -88,6 +88,7 @@ jobs: --install gadopt \ --install asQ \ --package-branch fiat connorjward/numpy2 \ + --package-branch pyop2 connorjward/numpy2 \ || (cat firedrake-install.log && /bin/false) - name: Install test dependencies run: | From 1bba98b15a1b0abdaa3a1c70326667714446df72 Mon Sep 17 00:00:00 2001 From: Connor Ward Date: Thu, 11 Apr 2024 17:13:03 +0100 Subject: [PATCH 15/19] fixup --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fee99cf9c4..48fd5518c6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -89,6 +89,7 @@ jobs: --install asQ \ --package-branch fiat connorjward/numpy2 \ --package-branch pyop2 connorjward/numpy2 \ + --package-branch tsfc connorjward/numpy2 \ || (cat firedrake-install.log && /bin/false) - name: Install test dependencies run: | From 9abe4fc41f9148c9504f7d83915656fa2a267fc0 Mon Sep 17 00:00:00 2001 From: Connor Date: Fri, 12 Apr 2024 09:34:50 +0100 Subject: [PATCH 16/19] fixup --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 48fd5518c6..4bf21300c6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -90,6 +90,7 @@ jobs: --package-branch fiat connorjward/numpy2 \ --package-branch pyop2 connorjward/numpy2 \ --package-branch tsfc connorjward/numpy2 \ + --package-branch loopy connorjward/numpy2 \ || (cat firedrake-install.log && /bin/false) - name: Install test dependencies run: | From 1b0d679a04b9d91288faa2679706186783f6e339 Mon Sep 17 00:00:00 2001 From: Connor Date: Fri, 12 Apr 2024 13:17:57 +0100 Subject: [PATCH 17/19] fixup --- firedrake/checkpointing.py | 2 +- firedrake/preconditioners/patch.py | 11 +++++++---- tests/output/test_io_function.py | 6 +++--- tests/output/test_io_timestepping.py | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/firedrake/checkpointing.py b/firedrake/checkpointing.py index e207b84a14..c52e6c7bc4 100644 --- a/firedrake/checkpointing.py +++ b/firedrake/checkpointing.py @@ -1359,7 +1359,7 @@ def _load_function_topology(self, tmesh, element, tf_name, idx=None): if element.family() == "Real": assert not isinstance(element, (finat.ufl.VectorElement, finat.ufl.TensorElement)) value = self.get_attr(path, "_".join([PREFIX, "value" if idx is None else "value_" + str(idx)])) - tf.dat.data.itemset(value) + tf.dat.data[...] = value else: if path in self.h5pyfile: timestepping = self.has_attr(os.path.join(path, tf.name()), "timestepping") diff --git a/firedrake/preconditioners/patch.py b/firedrake/preconditioners/patch.py index e73c41b129..ff7bf4e01a 100644 --- a/firedrake/preconditioners/patch.py +++ b/firedrake/preconditioners/patch.py @@ -816,10 +816,13 @@ def initialize(self, obj): is_snes = False if len(bcs) > 0: - ghost_bc_nodes = numpy.unique(numpy.concatenate([bcdofs(bc, ghost=True) - for bc in bcs])) - global_bc_nodes = numpy.unique(numpy.concatenate([bcdofs(bc, ghost=False) - for bc in bcs])) + ghost_bc_nodes = numpy.unique( + numpy.concatenate([bcdofs(bc, ghost=True) for bc in bcs], + dtype=PETSc.IntType) + ) + global_bc_nodes = numpy.unique( + numpy.concatenate([bcdofs(bc, ghost=False) for bc in bcs], + dtype=PETSc.IntType)) else: ghost_bc_nodes = numpy.empty(0, dtype=PETSc.IntType) global_bc_nodes = numpy.empty(0, dtype=PETSc.IntType) diff --git a/tests/output/test_io_function.py b/tests/output/test_io_function.py index d5dcd0f7f8..fc48a220b4 100644 --- a/tests/output/test_io_function.py +++ b/tests/output/test_io_function.py @@ -218,7 +218,7 @@ def test_io_function_real(cell_type, tmpdir): VA = FunctionSpace(meshA, "Real", 0) fA = Function(VA, name=func_name) valueA = 3.14 - fA.dat.data.itemset(valueA) + fA.dat.data[...] = valueA with CheckpointFile(filename, 'w', comm=COMM_WORLD) as afile: afile.save_function(fA) # Load -> View cycle @@ -281,7 +281,7 @@ def test_io_function_mixed_real(cell_family_degree_tuples, tmpdir): fA = Function(VA, name=func_name) fA0, fA1 = fA.subfunctions _initialise_function(fA0, _get_expr(VA[0]), method) - fA1.dat.data.itemset(3.14) + fA1.dat.data[...] = 3.14 with CheckpointFile(filename, 'w', comm=COMM_WORLD) as afile: afile.save_function(fA) # Load -> View cycle @@ -297,7 +297,7 @@ def test_io_function_mixed_real(cell_family_degree_tuples, tmpdir): fBe = Function(VB) fBe0, fBe1 = fBe.subfunctions _initialise_function(fBe0, _get_expr(VB[0]), method) - fBe1.dat.data.itemset(3.14) + fBe1.dat.data[...] = 3.14 assert assemble(inner(fB - fBe, fB - fBe) * dx) < 1.e-16 with CheckpointFile(filename, 'w', comm=comm) as afile: afile.save_function(fB) diff --git a/tests/output/test_io_timestepping.py b/tests/output/test_io_timestepping.py index f00d008285..c12c30d74a 100644 --- a/tests/output/test_io_timestepping.py +++ b/tests/output/test_io_timestepping.py @@ -29,7 +29,7 @@ def _get_expr(V, i): def _project(f, expr, method): if f.function_space().ufl_element().family() == "Real": - f.dat.data.itemset(expr) + f.dat.data[...] = expr elif method == "project": getattr(f, method)(expr, solver_parameters={"ksp_rtol": 1.e-16}) elif method == "interpolate": From 58dddbfb21b06fd0e16939b74792cacb2102a589 Mon Sep 17 00:00:00 2001 From: Connor Date: Fri, 12 Apr 2024 15:02:02 +0100 Subject: [PATCH 18/19] fixup --- firedrake/mesh.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/firedrake/mesh.py b/firedrake/mesh.py index a09092fe62..2a24ebd006 100644 --- a/firedrake/mesh.py +++ b/firedrake/mesh.py @@ -21,7 +21,7 @@ from pyop2.mpi import ( MPI, COMM_WORLD, internal_comm, is_pyop2_comm, temp_internal_comm ) -from pyop2.utils import as_tuple, tuplify +from pyop2.utils import as_tuple import firedrake.cython.dmcommon as dmcommon import firedrake.cython.extrusion_numbering as extnum @@ -1444,7 +1444,14 @@ def make_dofs_per_plex_entity(self, entity_dofs): dofs_per_entity = np.zeros((1 + self._base_mesh.cell_dimension(), 2), dtype=IntType) for (b, v), entities in entity_dofs.items(): dofs_per_entity[b, v] += len(entities[0]) - return tuplify(dofs_per_entity) + + # Convert to a tuple of tuples with int (not numpy.intXX) values. This is + # to give us a string representation like ((0, 1), (2, 3)) instead of + # ((numpy.int32(0), numpy.int32(1)), (numpy.int32(2), numpy.int32(3))). + return tuple( + tuple(int(d_) for d_ in d) + for d in dofs_per_entity + ) @PETSc.Log.EventDecorator() def node_classes(self, nodes_per_entity, real_tensorproduct=False): From bd8d5d8a1c0212a579c1556e2b79373d3b11cf3f Mon Sep 17 00:00:00 2001 From: Connor Ward Date: Tue, 16 Apr 2024 18:47:54 +0100 Subject: [PATCH 19/19] loopy is now updated --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4bf21300c6..48fd5518c6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -90,7 +90,6 @@ jobs: --package-branch fiat connorjward/numpy2 \ --package-branch pyop2 connorjward/numpy2 \ --package-branch tsfc connorjward/numpy2 \ - --package-branch loopy connorjward/numpy2 \ || (cat firedrake-install.log && /bin/false) - name: Install test dependencies run: |