-
Notifications
You must be signed in to change notification settings - Fork 8
Build cache coherence across PETSc version switches #120
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
Changes from all commits
499f813
9b7c359
61675b5
15f8e1d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| #!/usr/bin/env bash | ||
| # activate-petsc-arch.sh — sourced by pixi on environment activation. | ||
| # | ||
| # Dynamically sets PETSC_ARCH for AMR environments (custom PETSc builds) | ||
| # by combining the active pixi environment name with the PETSc version | ||
| # pinned in petsc-custom/.petsc-version. | ||
| # | ||
| # This replaces hardcoded PETSC_ARCH entries in pixi.toml so that | ||
| # switching PETSc versions (via ./uw petsc switch <tag>) does not require | ||
| # editing tracked configuration. | ||
|
|
||
| _uw_mpi="" | ||
| _uw_suffix="" | ||
|
|
||
| # Default MPI for AMR envs is platform-dependent and mirrors the conda deps | ||
| # pinned in pixi.toml: openmpi on macOS (feature.amr.target.osx-arm64), | ||
| # mpich on Linux (feature.amr.target.linux-64). | ||
| _uw_default_mpi="mpich" | ||
| [ "$(uname -s)" = "Darwin" ] && _uw_default_mpi="openmpi" | ||
|
|
||
| case "${PIXI_ENVIRONMENT_NAME:-}" in | ||
| amr|amr-runtime|amr-dev) _uw_mpi="$_uw_default_mpi" ;; | ||
| amr-mpich|amr-mpich-dev) _uw_mpi="mpich" ;; | ||
| amr-openmpi|amr-openmpi-dev) _uw_mpi="openmpi" ;; | ||
| amr-debug) _uw_mpi="$_uw_default_mpi"; _uw_suffix="-debug" ;; | ||
| esac | ||
|
|
||
| if [ -n "$_uw_mpi" ]; then | ||
| # Match the version-discovery logic in ./uw (petsc_version_short): | ||
| # prefer .petsc-version, strip whitespace, fall back to 324. | ||
| _uw_ver="324" | ||
| _uw_ver_file="${PIXI_PROJECT_ROOT:-.}/petsc-custom/.petsc-version" | ||
| if [ -f "$_uw_ver_file" ]; then | ||
| _uw_read=$(tr -d '[:space:]' < "$_uw_ver_file" 2>/dev/null) | ||
| [ -n "$_uw_read" ] && _uw_ver="$_uw_read" | ||
| fi | ||
|
|
||
| export PETSC_ARCH="petsc-${_uw_ver}-uw-${_uw_mpi}${_uw_suffix}" | ||
| fi | ||
|
|
||
| unset _uw_mpi _uw_suffix _uw_default_mpi _uw_ver _uw_ver_file _uw_read | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -165,6 +165,9 @@ cmake = ">=3.31,<4" | |
| make = ">=4.4,<5" | ||
| mpi4py = ">=4,<5" | ||
|
|
||
| [feature.amr.activation] | ||
| scripts = ["petsc-custom/activate-petsc-arch.sh"] | ||
|
|
||
| [feature.amr.activation.env] | ||
| PETSC_DIR = "$PIXI_PROJECT_ROOT/petsc-custom/petsc" | ||
|
|
||
|
|
@@ -173,16 +176,10 @@ openmpi = ">=5.0,<6" | |
| hdf5 = { version = ">=1.14,<2", build = "*openmpi*" } | ||
| h5py = { version = ">=3.12,<4", build = "*openmpi*" } | ||
|
|
||
| [feature.amr.target.osx-arm64.activation.env] | ||
| PETSC_ARCH = "petsc-4-uw-openmpi" | ||
|
|
||
| [feature.amr.target.linux-64.dependencies] | ||
| hdf5 = { version = ">=1.14,<2", build = "*mpich*" } | ||
| h5py = { version = ">=3.12,<4", build = "*mpich*" } | ||
|
|
||
| [feature.amr.target.linux-64.activation.env] | ||
| PETSC_ARCH = "petsc-4-uw-mpich" | ||
|
|
||
| [feature.amr.tasks] | ||
| petsc-local-build = { cmd = "./build-petsc.sh", cwd = "petsc-custom" } | ||
| petsc-local-clean = { cmd = "./build-petsc.sh clean", cwd = "petsc-custom" } | ||
|
|
@@ -202,9 +199,11 @@ mpi4py = ">=4,<5" | |
| hdf5 = { version = ">=1.14,<2", build = "*mpich*" } | ||
| h5py = { version = ">=3.12,<4", build = "*mpich*" } | ||
|
|
||
| [feature.amr-mpich.activation] | ||
| scripts = ["petsc-custom/activate-petsc-arch.sh"] | ||
|
|
||
| [feature.amr-mpich.activation.env] | ||
| PETSC_DIR = "$PIXI_PROJECT_ROOT/petsc-custom/petsc" | ||
| PETSC_ARCH = "petsc-4-uw-mpich" | ||
|
|
||
| [feature.amr-mpich.tasks] | ||
| petsc-local-build = { cmd = "./build-petsc.sh", cwd = "petsc-custom" } | ||
|
|
@@ -221,9 +220,11 @@ mpi4py = ">=4,<5" | |
| hdf5 = { version = ">=1.14,<2", build = "*openmpi*" } | ||
| h5py = { version = ">=3.12,<4", build = "*openmpi*" } | ||
|
|
||
| [feature.amr-openmpi.activation] | ||
| scripts = ["petsc-custom/activate-petsc-arch.sh"] | ||
|
|
||
| [feature.amr-openmpi.activation.env] | ||
| PETSC_DIR = "$PIXI_PROJECT_ROOT/petsc-custom/petsc" | ||
| PETSC_ARCH = "petsc-4-uw-openmpi" | ||
|
|
||
| [feature.amr-openmpi.tasks] | ||
| petsc-local-build = { cmd = "./build-petsc.sh", cwd = "petsc-custom" } | ||
|
|
@@ -236,19 +237,26 @@ petsc-local-clean = { cmd = "./build-petsc.sh clean", cwd = "petsc-custom" } | |
| # Uses the same conda deps as amr but points to a separate PETSC_ARCH | ||
| # so the optimised build is untouched. | ||
| # | ||
| # Setup: | ||
| # PETSC_ARCH is set dynamically by petsc-custom/activate-petsc-arch.sh | ||
| # and resolves to: petsc-<ver>-uw-<mpi>-debug | ||
| # where <ver> comes from petsc-custom/.petsc-version and <mpi> follows | ||
| # the platform default (openmpi on macOS, mpich on Linux). | ||
| # | ||
| # Setup (inside a pixi shell -e amr-debug, so $PETSC_ARCH is already set): | ||
| # cd petsc-custom/petsc | ||
| # pixi run -e amr-debug python3 ./configure \ | ||
| # --with-petsc-arch=petsc-4-uw-openmpi-debug --with-debugging=1 \ | ||
| # --with-petsc-arch="$PETSC_ARCH" --with-debugging=1 \ | ||
| # --with-mpi-dir="$CONDA_PREFIX" --with-hdf5=0 \ | ||
| # --download-mpich=0 --download-openmpi=0 --download-mpi4py=0 \ | ||
| # --with-petsc4py=0 --with-x=0 --with-pragmatic=0 --with-slepc=0 \ | ||
| # "--COPTFLAGS=-g -O0" "--CXXOPTFLAGS=-g -O0" "--FOPTFLAGS=-g -O0" | ||
| # make PETSC_DIR=$(pwd) PETSC_ARCH=petsc-4-uw-openmpi-debug all | ||
| # make PETSC_DIR=$(pwd) PETSC_ARCH="$PETSC_ARCH" all | ||
|
|
||
| [feature.amr-debug.activation] | ||
| scripts = ["petsc-custom/activate-petsc-arch.sh"] | ||
|
|
||
| [feature.amr-debug.activation.env] | ||
| PETSC_DIR = "$PIXI_PROJECT_ROOT/petsc-custom/petsc" | ||
|
Comment on lines
+255
to
259
|
||
| PETSC_ARCH = "petsc-4-uw-openmpi-debug" | ||
|
|
||
| # ============================================ | ||
| # HPC CLUSTER FEATURE | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
activate-petsc-arch.shdefaults_uw_verto4and reads.petsc-versionwithout trimming whitespace. Elsewhere (uwandpetsc-custom/build-petsc.sh) the version defaults to324and.petsc-versionis expected to contain the short numeric form (e.g.325). On a fresh checkout where.petsc-versionis missing (or contains whitespace), this can export a legacy/invalidPETSC_ARCHand break downstream builds (notablypip installof petsc4py which relies onPETSC_ARCH). Align the default/version-parsing logic withpetsc_version_short()(default324, strip whitespace, and ideally fall back to tag detection when the file is absent).