Skip to content

Commit d99f43f

Browse files
committed
ci: persist ccache across ephemeral runner pods via actions/cache
1 parent 18a0da0 commit d99f43f

2 files changed

Lines changed: 122 additions & 5 deletions

File tree

.github/workflows/cuda.yml

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ jobs:
1717
name: Test on CUDA Build
1818
runs-on: gpu
1919
if: github.repository_owner == 'deepmodeling'
20+
env:
21+
CCACHE_BASEDIR: ${{ github.workspace }}
22+
CCACHE_MAXSIZE: 5G
2023
container:
2124
image: ghcr.io/deepmodeling/abacus-cuda
2225
volumes:
@@ -25,14 +28,22 @@ jobs:
2528

2629
steps:
2730
- name: Checkout
28-
uses: actions/checkout@v7
31+
uses: actions/checkout@v7.0.1
2932
with:
3033
submodules: recursive
3134

35+
- name: Report runner info
36+
run: |
37+
echo "runner_name=$RUNNER_NAME"
38+
case "$RUNNER_NAME" in
39+
gpu-runner-*) echo "runner_type=pod" ;;
40+
*) echo "runner_type=vm" ;;
41+
esac
42+
3243
- name: Install CI tools
3344
run: |
3445
sudo apt-get update
35-
sudo apt-get install -y ccache xz-utils ninja-build pkg-config
46+
sudo apt-get install -y ccache xz-utils ninja-build pkg-config zstd
3647
3748
- name: Install external tools from toolchain
3849
run: |
@@ -41,15 +52,60 @@ jobs:
4152
./scripts/stage4/install_stage4.sh
4253
cd ..
4354
55+
- name: Restore ccache
56+
id: ccache
57+
if: startsWith(runner.name, 'gpu-runner-')
58+
uses: actions/cache/restore@v4
59+
with:
60+
path: /tmp/ccache.tar.zst
61+
key: ccache-cuda-${{ github.sha }}
62+
restore-keys: |
63+
ccache-cuda-
64+
65+
- name: Unpack ccache
66+
if: steps.ccache.outputs.cache-hit == 'true'
67+
run: |
68+
sudo mkdir -p /github/home/.ccache
69+
sudo tar -I zstd -xf /tmp/ccache.tar.zst -C /github/home
70+
sudo chown -R $(whoami) /github/home/.ccache
71+
72+
- name: ccache stats (before build)
73+
run: |
74+
ccache --zero-stats || true
75+
ccache -s
76+
4477
- name: Configure & Build
4578
run: |
4679
nvidia-smi
4780
source toolchain/install/setup
4881
rm -rf build
49-
cmake -B build -G Ninja -DUSE_CUDA=ON -DBUILD_TESTING=ON -DENABLE_FLOAT_FFTW=ON
50-
cmake --build build -j4
82+
cmake -B build -G Ninja -DUSE_CUDA=ON -DBUILD_TESTING=ON -DENABLE_FLOAT_FFTW=ON \
83+
-DCMAKE_CUDA_ARCHITECTURES=70
84+
cmake --build build -j "$(nproc)"
5185
cmake --install build
5286
87+
- name: ccache stats (after build)
88+
if: always()
89+
run: ccache -s
90+
91+
- name: Pack ccache
92+
if: always()
93+
run: tar -I 'zstd -T0' -cf /tmp/ccache.tar.zst -C /github/home .ccache
94+
95+
- name: Save ccache
96+
if: always()
97+
uses: actions/cache/save@v4
98+
with:
99+
path: /tmp/ccache.tar.zst
100+
key: ccache-cuda-${{ github.sha }}
101+
102+
- name: Module_LCAO CUDA Unittests
103+
env:
104+
GTEST_COLOR: 'yes'
105+
OMP_NUM_THREADS: '2'
106+
run: |
107+
ctest --test-dir build -V --timeout 1700 -R '^(MODULE_LCAO_tddft_radial_interpolation_cuda_test|MODULE_LCAO_tddft_snap_psibeta_half_test)$'
108+
53109
- name: Test 11_PW_GPU
54110
run: |
55111
cd tests/11_PW_GPU
@@ -74,3 +130,15 @@ jobs:
74130
run: |
75131
cd tests/16_SDFT_GPU
76132
bash ../integrate/Autotest.sh -n 2 -f CASES_GPU.txt
133+
134+
- name: Test 01_PW on GPU
135+
run: |
136+
cd tests/01_PW
137+
find . -name INPUT | while read f; do
138+
if grep -q "^device" "$f"; then
139+
sed -i 's/^device.*/device gpu/' "$f"
140+
else
141+
echo "device gpu" >> "$f"
142+
fi
143+
done
144+
bash ../integrate/Autotest.sh -n 1 -a abacus -f CASES_GPU.txt

.github/workflows/test.yml

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@ jobs:
1616
name: Test
1717
runs-on: X64
1818
if: github.repository_owner == 'deepmodeling'
19+
env:
20+
CCACHE_BASEDIR: ${{ github.workspace }}
21+
CCACHE_MAXSIZE: 5G
1922
container:
2023
image: ghcr.io/deepmodeling/abacus-gnu
2124
volumes:
2225
- /tmp/ccache:/github/home/.ccache
2326
steps:
2427
- name: Checkout repository
25-
uses: actions/checkout@v7
28+
uses: actions/checkout@v7.0.1
2629
with:
2730
fetch-depth: 0
2831
# We will handle submodules manually after fixing ownership
@@ -33,12 +36,21 @@ jobs:
3336
sudo chown -R $(whoami) .
3437
git submodule update --init --recursive
3538
39+
- name: Report runner info
40+
run: |
41+
echo "runner_name=$RUNNER_NAME"
42+
case "$RUNNER_NAME" in
43+
gpu-runner-*) echo "runner_type=pod" ;;
44+
*) echo "runner_type=vm" ;;
45+
esac
46+
3647
- name: Install CI tools
3748
run: |
3849
sudo apt-get update
3950
sudo apt-get install -y \
4051
gfortran \
4152
ccache \
53+
zstd \
4254
ca-certificates \
4355
pkg-config \
4456
python-is-python3 \
@@ -54,6 +66,28 @@ jobs:
5466
./scripts/stage4/install_stage4.sh
5567
cd ..
5668
69+
- name: Restore ccache
70+
id: ccache
71+
if: startsWith(runner.name, 'gpu-runner-')
72+
uses: actions/cache/restore@v4
73+
with:
74+
path: /tmp/ccache.tar.zst
75+
key: ccache-gnu-${{ github.sha }}
76+
restore-keys: |
77+
ccache-gnu-
78+
79+
- name: Unpack ccache
80+
if: steps.ccache.outputs.cache-hit == 'true'
81+
run: |
82+
sudo mkdir -p /github/home/.ccache
83+
sudo tar -I zstd -xf /tmp/ccache.tar.zst -C /github/home
84+
sudo chown -R $(whoami) /github/home/.ccache
85+
86+
- name: ccache stats (before build)
87+
run: |
88+
ccache --zero-stats || true
89+
ccache -s
90+
5791
- name: Configure
5892
run: |
5993
source toolchain/install/setup
@@ -85,6 +119,21 @@ jobs:
85119
cmake --build build -j8
86120
cmake --install build
87121
122+
- name: ccache stats (after build)
123+
if: always()
124+
run: ccache -s
125+
126+
- name: Pack ccache
127+
if: always()
128+
run: tar -I 'zstd -T0' -cf /tmp/ccache.tar.zst -C /github/home .ccache
129+
130+
- name: Save ccache
131+
if: always()
132+
uses: actions/cache/save@v4
133+
with:
134+
path: /tmp/ccache.tar.zst
135+
key: ccache-gnu-${{ github.sha }}
136+
88137
- name: Check documentation consistency
89138
run: |
90139
ABACUS_BIN=$(find build -name "abacus_*" -type f -executable | head -1)

0 commit comments

Comments
 (0)