Skip to content

Commit 6f36c95

Browse files
authored
Azure CI: Cache (BLAST-WarpX#2615)
* run_test: WARPX_CI_TMP Allow to use a fixed instead of a unique temporary directory. This will help `ccache` to cache compliation, because absolute paths do not change anymore between builds. * Azure CI: Cache Try to use caching for as much as possible on Azure. This might help to reuse AMReX objects between our weekly updates. It might also be just way too large and get evicted quickly.
1 parent 42fb1ee commit 6f36c95

2 files changed

Lines changed: 59 additions & 15 deletions

File tree

.azure-pipelines.yml

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ pr:
1010
jobs:
1111
- job:
1212
variables:
13-
WARPX_CI_NUM_MAKE_JOBS: 2
13+
BLASPP_HOME: '/usr/local'
14+
CEI_SUDO: 'sudo'
15+
CEI_TMP: '/tmp/cei'
16+
FFTW_HOME: '/usr'
17+
LAPACKPP_HOME: '/usr/local'
18+
OMP_NUM_THREADS: 1
1419
WARPX_CI_CCACHE: 'TRUE'
20+
WARPX_CI_NUM_MAKE_JOBS: 2
1521
WARPX_CI_OPENPMD: 'TRUE'
16-
FFTW_HOME: '/usr/'
17-
BLASPP_HOME: '/usr/local/'
18-
LAPACKPP_HOME: '/usr/local/'
19-
OMP_NUM_THREADS: 1
22+
WARPX_CI_TMP: '/tmp/ci'
2023

2124
strategy:
2225
matrix:
@@ -42,12 +45,39 @@ jobs:
4245
timeoutInMinutes: 90
4346

4447
steps:
45-
- script: |
48+
# set up caches:
49+
# - once stored under a key, they become immutable (even if cache content changes)
50+
# - for a refresh the key has to change, e.g., hash of a tracked file in the key
51+
- task: Cache@2
52+
inputs:
53+
key: 'Ccache | "$(System.JobName)" | cmake/dependencies/AMReX.cmake | run_test.sh'
54+
restoreKeys: |
55+
Ccache | "$(System.JobName)" | cmake/dependencies/AMReX.cmake | run_test.sh
56+
Ccache | "$(System.JobName)" | cmake/dependencies/AMReX.cmake
57+
Ccache | "$(System.JobName)"
58+
Ccache
59+
path: /home/vsts/.ccache
60+
cacheHitVar: CCACHE_CACHE_RESTORED
61+
displayName: Cache Ccache Objects
62+
63+
- task: Cache@2
64+
inputs:
65+
key: 'Python3 | "$(System.JobName)" | run_test.sh'
66+
restoreKeys: |
67+
Python3 | "$(System.JobName)" | run_test.sh
68+
Python3 | "$(System.JobName)"
69+
Python3
70+
path: /home/vsts/.local/lib/python3.8
71+
cacheHitVar: PYTHON38_CACHE_RESTORED
72+
displayName: Cache Python Libraries
73+
74+
- bash: |
4675
cat /proc/cpuinfo | grep "model name" | sort -u
47-
sudo apt update
76+
df -h
4877
sudo apt install -y ccache gcc gfortran g++ openmpi-bin libopenmpi-dev \
4978
libfftw3-dev libfftw3-mpi-dev libhdf5-openmpi-dev pkg-config make \
5079
python3 python3-pip python3-venv python3-setuptools libblas-dev liblapack-dev
80+
ccache --set-config=max_size=10.0G
5181
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 2
5282
sudo update-alternatives --set python /usr/bin/python3
5383
python -m pip install --upgrade pip
@@ -57,22 +87,31 @@ jobs:
5787
python -m pipx ensurepath
5888
export PATH="$HOME/.local/bin:$PATH"
5989
python -m pip install --upgrade matplotlib mpi4py numpy scipy yt
60-
export CEI_SUDO="sudo"
6190
sudo curl -L -o /usr/local/bin/cmake-easyinstall https://git.io/JvLxY
6291
sudo chmod a+x /usr/local/bin/cmake-easyinstall
6392
if [ "${WARPX_CI_OPENPMD:-FALSE}" == "TRUE" ]; then
64-
cmake-easyinstall --prefix=/usr/local git+https://github.com/openPMD/openPMD-api.git@0.14.3 \
93+
cmake-easyinstall --prefix=/usr/local \
94+
git+https://github.com/openPMD/openPMD-api.git@0.14.3 \
95+
-DCMAKE_CXX_COMPILER_LAUNCHER=$(which ccache) \
96+
-DCMAKE_VERBOSE_MAKEFILE=ON \
6597
-DopenPMD_USE_PYTHON=OFF -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF -DBUILD_CLI_TOOLS=OFF
6698
python -m pip install --upgrade openpmd-api
6799
fi
68100
if [[ "${WARPX_CI_RZ_OR_NOMPI:-FALSE}" == "TRUE" || "${WARPX_CI_PYTHON_MAIN:-FALSE}" == "TRUE" ]]; then
69101
cmake-easyinstall --prefix=/usr/local git+https://bitbucket.org/icl/blaspp.git \
102+
-DCMAKE_CXX_COMPILER_LAUNCHER=$(which ccache) \
70103
-Duse_openmp=OFF -Dbuild_tests=OFF -DCMAKE_VERBOSE_MAKEFILE=ON
71104
cmake-easyinstall --prefix=/usr/local git+https://bitbucket.org/icl/lapackpp.git \
105+
-DCMAKE_CXX_COMPILER_LAUNCHER=$(which ccache) \
72106
-Duse_cmake_find_lapack=ON -Dbuild_tests=OFF -DCMAKE_VERBOSE_MAKEFILE=ON
73107
fi
108+
rm -rf ${CEI_TMP}
109+
df -h
74110
displayName: 'Install dependencies'
75111
76-
- script: |
112+
- bash: |
113+
df -h
77114
./run_test.sh
115+
rm -rf ${WARPX_CI_TMP}
116+
df -h
78117
displayName: 'Build & test'

run_test.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,19 @@ tests_run=${tests_arg:+--tests=${tests_arg}}
3232
# Remove contents and link to a previous test directory (intentionally two arguments)
3333
rm -rf test_dir/* test_dir
3434
# Create a temporary test directory
35-
tmp_dir=$(mktemp --help >/dev/null 2>&1 && mktemp -d -t ci-XXXXXXXXXX || mktemp -d "${TMPDIR:-/tmp}"/ci-XXXXXXXXXX)
36-
if [ $? -ne 0 ]; then
37-
echo "Cannot create temporary directory"
38-
exit 1
35+
if [ -z "${WARPX_CI_TMP}" ]; then
36+
tmp_dir=$(mktemp --help >/dev/null 2>&1 && mktemp -d -t ci-XXXXXXXXXX || mktemp -d "${TMPDIR:-/tmp}"/ci-XXXXXXXXXX)
37+
if [ $? -ne 0 ]; then
38+
echo "Cannot create temporary directory"
39+
exit 1
40+
fi
41+
else
42+
tmp_dir=${WARPX_CI_TMP}
3943
fi
4044

4145
# Copy WarpX into current test directory
42-
mkdir ${tmp_dir}/warpx
46+
rm -rf ${tmp_dir}/warpx
47+
mkdir -p ${tmp_dir}/warpx
4348
cp -r ./* ${tmp_dir}/warpx
4449

4550
# Link the test directory

0 commit comments

Comments
 (0)