Skip to content

Commit

Permalink
Neater caching and saving binary artifacts for benchmarks (#78)
Browse files Browse the repository at this point in the history
* Save binary as artifact

* Remove steps duplicated from install.sh

* Add back wget and zlib installs

* Source intel compiler on macos

* Do not skip hdf5

* Reinstall gcc with brew

* debug

* Some workarounds for macos

* Memcpy error and other fixes (#4)

* add macos library path

* link brew's gcc compiler

* remove unnecessary vars

* brew reinstall gcc

* debug install dir

* Revert "debug install dir"

This reverts commit 6297348.

* debug prints

* debug prints

* install with cp -rf

* Revert "install with cp -rf"

This reverts commit 39e6ebb.

* don't cp ifort bin into include dir

* remove debug prints

* Add artifact download path

* Set +x permission to mcfost in benchmark

* Consolidate macos and linux dependency workflows

* fix typo

* Add dependency workflow file to hash

Also some debugging output for macos cache paths

* Exclude Cellar from cache

Since it is enormous.

* remove debug step

* Swap linux intel to manual install

i.e. remove container since its huge.

* single install at a time

* export intel compiler path to github env

* typo

* Swap macos and linux env

Was wrong way round

* sudo the install script

* Change include dir permissions

* Update chmod with sudo

* Set o+w

* chmod lib too

* Combine chmods

* debug cached file sizes

* typo

* typo

* add sudo

* Remove debugging

* Specify cache directories exactly

* debug cache size for ifort linux

* Further specify cached lib path

* Fix cache path for different compilers

* Remove debugging

* Adjust include and lib permissions

* recursive chmod before cache restore

* add +x permission

* debugging permissions

* try 777 as a last resort

* grant tar root o+x

* typo

* Deal with tar only for linux-intel

---------

Co-authored-by: Conrad Chan <[email protected]>
  • Loading branch information
bmsykes and conradtchan authored Oct 3, 2023
1 parent 64ee441 commit cad0964
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 154 deletions.
4 changes: 3 additions & 1 deletion .github/actions/benchmark/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ runs:
working-directory: src
env:
MCFOST_UTILS: ${{ github.workspace }}/utils
run: ./mcfost -setup
run: |
chmod +x mcfost
./mcfost -setup
- name: download phantom input file
shell: bash
Expand Down
69 changes: 69 additions & 0 deletions .github/actions/dependencies/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: "dependencies"
description: "macos and linux dependencies"

# Note: needs GCC > 12, and sudo, wherever you're building
# Using gcc-11 will return a bug when compiling gas/wavelengths_gas.f90

runs:
using: "composite"
steps:
# Each OS has some quirk for each compiler, so these 4 steps deal with those
- name: install wget (GNU / linux)
if: matrix.compiler == 'gfortran' && matrix.os == 'linux'
shell: bash
run: dnf install -y sudo wget epel-release

- name: install intel compilers (intel / linux)
if: matrix.compiler == 'ifort' && matrix.os == 'linux'
shell: bash
run: |
wget -nv https://registrationcenter-download.intel.com/akdlm/IRC_NAS/ebf5d9aa-17a7-46a4-b5df-ace004227c0e/l_dpcpp-cpp-compiler_p_2023.2.1.8_offline.sh &
wget -nv https://registrationcenter-download.intel.com/akdlm/IRC_NAS/0d65c8d4-f245-4756-80c4-6712b43cf835/l_fortran-compiler_p_2023.2.1.8_offline.sh &
wait
chmod +x l_dpcpp-cpp-compiler_p_2023.2.1.8_offline.sh
./l_dpcpp-cpp-compiler_p_2023.2.1.8_offline.sh -a --silent --eula accept
chmod +x l_fortran-compiler_p_2023.2.1.8_offline.sh
./l_fortran-compiler_p_2023.2.1.8_offline.sh -a --silent --eula accept
echo "INTEL_PATH=/home/runner/intel/oneapi" >> "$GITHUB_ENV"
sudo chown root /bin/tar && sudo chmod u+s /bin/tar
- name: fix gcc issue on the runner (GNU / macos)
if: matrix.compiler == 'gfortran' && matrix.os == 'macos'
shell: bash
run: |
brew reinstall gcc@13
ln -s /usr/local/bin/gcc-13 /usr/local/bin/gcc
ln -s /usr/local/bin/g++-13 /usr/local/bin/g++
- name: install intel compilers (intel / macos)
if: matrix.compiler == 'ifort' && matrix.os == 'macos'
shell: bash
run: |
wget -nv https://registrationcenter-download.intel.com/akdlm/IRC_NAS/2fbce033-15f4-4e13-8d14-f5a2016541ce/m_fortran-compiler-classic_p_2023.2.0.49001_offline.dmg &
wget -nv https://registrationcenter-download.intel.com/akdlm/IRC_NAS/ebba13f8-1690-4d30-9d43-1e2fa2d536cd/m_cpp-compiler-classic_p_2023.2.0.48999_offline.dmg &
wait
hdiutil attach m_fortran-compiler-classic_p_2023.2.0.49001_offline.dmg
sudo /Volumes/m_fortran-compiler-classic_p_2023.2.0.49001_offline/bootstrapper.app/Contents/MacOS/install.sh --silent --eula accept
hdiutil attach m_cpp-compiler-classic_p_2023.2.0.48999_offline.dmg
sudo /Volumes/m_cpp-compiler-classic_p_2023.2.0.48999_offline/bootstrapper.app/Contents/MacOS/install.sh --silent --eula accept
echo "INTEL_PATH=/opt/intel/oneapi" >> "$GITHUB_ENV"
# Cache other dependencies for mcfost to avoid downloading/installing them each time this workflow runs
- name: cache dependencies
id: cache-deps
uses: actions/cache@v3
with:
path: |
${{ env.MCFOST_INSTALL }}/include
${{ env.MCFOST_INSTALL }}/lib/${{ matrix.compiler }}
key: mcfost-deps-${{ runner.os }}-${{ matrix.compiler }}-${{ hashFiles('lib/install.sh') }}

# Only do this (lengthy) setup if dependency cache not found
- name: prepare mcfost environment
if: ${{ steps.cache-deps.outputs.cache-hit != 'true' }}
shell: bash -e {0}
working-directory: lib
run: |
[ ! "$SETVARS_COMPLETED" == 1 ] && test -f "$INTEL_PATH"/setvars.sh && . "$INTEL_PATH"/setvars.sh
sudo chmod o+w /usr/local/include /usr/local/lib
./install.sh
57 changes: 0 additions & 57 deletions .github/actions/dependencies/linux/action.yml

This file was deleted.

73 changes: 0 additions & 73 deletions .github/actions/dependencies/macos/action.yml

This file was deleted.

41 changes: 18 additions & 23 deletions .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
env:
MCFOST_NO_XGBOOST: yes
MCFOST_GIT: "1"
SKIP_HDF5: yes
SKIP_HDF5: no

jobs:
build-and-test:
Expand All @@ -35,9 +35,6 @@ jobs:
- os: linux
compiler: gfortran
container: "quay.io/pypa/manylinux_2_28_x86_64"
- os: linux
compiler: ifort
container: "intel/oneapi-hpckit:2023.2-devel-ubuntu22.04"

runs-on: ${{ matrix.os-version }}
container: ${{ matrix.container }}
Expand All @@ -52,25 +49,27 @@ jobs:

- run: git config --global --add safe.directory $PWD

# Actions doesn't seem to have a way to evaluate expressions in paths so these 'uses' are hardcoded in
- name: build and install dependencies (linux)
if: matrix.os == 'linux'
uses: ./.github/actions/dependencies/linux

- name: build and install dependencies (macos)
if: matrix.os == 'macos'
uses: ./.github/actions/dependencies/macos
- name: build and install dependencies
uses: ./.github/actions/dependencies

- name: compile mcfost
working-directory: src
shell: bash -e {0}
run: |
[ ! "$SETVARS_COMPLETED" == 1 ] && test -f /opt/intel/oneapi/setvars.sh && . /opt/intel/oneapi/setvars.sh
make all
[ ! "$SETVARS_COMPLETED" == 1 ] && test -f "$INTEL_PATH"/setvars.sh && . "$INTEL_PATH"/setvars.sh
make static=yes all
- name: test
uses: ./.github/actions/test

# Saving the binaries from the macos builds since the runner is the same for both compilers -> might be more consistent
- name: save binary for benchmarking
if: matrix.os == 'macos' && matrix.openmp == 'yes'
uses: actions/upload-artifact@v3
with:
name: mcfost-binary-${{ matrix.compiler }}
path: src/mcfost

benchmark:
needs: build-and-test
strategy:
Expand All @@ -85,15 +84,11 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: install dependencies
uses: ./.github/actions/dependencies/macos

- name: compile mcfost
working-directory: src
shell: bash -e {0}
run: |
[ ! "$SETVARS_COMPLETED" == 1 ] && test -f /opt/intel/oneapi/setvars.sh && . /opt/intel/oneapi/setvars.sh
make
- name: restore binary artifact
uses: actions/download-artifact@v3
with:
name: mcfost-binary-${{ matrix.compiler }}
path: src/

- name: benchmark
uses: ./.github/actions/benchmark
Expand Down

0 comments on commit cad0964

Please sign in to comment.