Skip to content
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

Use CCache and GitHub Cache in Actions #1649

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,24 @@ jobs:
# Install MPI
${{matrix.install_deps}}

- name: Install CCache
run: Submodules/AMReX/.github/workflows/dependencies/dependencies_ccache.sh

- name: Set Up Cache
uses: actions/cache@v4
with:
path: ~/.cache/ccache
key: ccache-${{ github.workflow }}-${{ github.job }}-git-${{ github.sha }}
restore-keys: |
ccache-${{ github.workflow }}-${{ github.job }}-git-

- name: Configure CMake
run: |
cmake \
-B${{runner.workspace}}/ERF/build-${{matrix.os}} \
-DCMAKE_INSTALL_PREFIX:PATH=${{runner.workspace}}/ERF/install \
-DCMAKE_BUILD_TYPE:STRING=Debug \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DERF_DIM:STRING=3 \
-DERF_ENABLE_MPI:BOOL=ON \
-DERF_ENABLE_TESTS:BOOL=ON \
Expand All @@ -63,8 +75,16 @@ jobs:

- name: Build
run: |
export CCACHE_COMPRESS=1
export CCACHE_COMPRESSLEVEL=10
export CCACHE_MAXSIZE=600M
ccache -z

cmake --build ${{runner.workspace}}/ERF/build-${{matrix.os}} --parallel ${{env.NPROCS}};

ccache -s
du -hs ~/.cache/ccache

- name: Regression Tests
run: |
ctest -L regression -VV
Expand Down Expand Up @@ -94,3 +114,18 @@ jobs:
# name: build-and-test
# path: |
# ${{runner.workspace}}/ERF/regressioncov.html

save_pr_number:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Save PR number
env:
PR_NUMBER: ${{ github.event.number }}
run: |
echo $PR_NUMBER > pr_number.txt
- uses: actions/upload-artifact@v4
with:
name: pr_number
path: pr_number.txt
retention-days: 1
11 changes: 7 additions & 4 deletions .github/workflows/cleanup-cache-postpr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ on:

jobs:
CleanUpCcacheCachePostPR:
name: Clean Up Ccahe Cache Post PR
name: Clean Up Ccache Cache Post PR
runs-on: ubuntu-latest
permissions:
actions: write
contents: read
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- name: Clean up ccahe
- uses: actions/checkout@v4
- name: Clean up ccache
run: |
gh extension install actions/gh-actions-cache

Expand All @@ -31,7 +31,10 @@ jobs:
set +e

keys=$(gh actions-cache list -L 100 -R $REPO -B $BRANCH | cut -f 1)
# $keys might contain spaces. Thus we set IFS to \n.
IFS=$'\n'
for k in $keys
do
gh actions-cache delete $k -R $REPO -B $BRANCH --confirm
gh actions-cache delete "$k" -R $REPO -B $BRANCH --confirm
done
unset IFS
21 changes: 12 additions & 9 deletions .github/workflows/cleanup-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ name: CleanUpCache

on:
workflow_run:
workflows: [GCC,CUDA,HIP,SYCL]
workflows: [ERF CI, ERF CUDA CI, ERF CI (hip), ERF CI (sycl), Linux GCC, MacOS]
types:
- completed

jobs:
CleanUpCcacheCache:
name: Clean Up Ccahe Cache for ${{ github.event.workflow_run.name }}
name: Clean Up Ccache Cache for ${{ github.event.workflow_run.name }}
runs-on: ubuntu-latest
permissions:
actions: write
contents: read
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- name: Clean up ccahe
- uses: actions/checkout@v4
- name: Clean up ccache
run: |
gh extension install actions/gh-actions-cache

Expand All @@ -27,7 +27,7 @@ jobs:
EVENT=${{ github.event.workflow_run.event }}

# Triggering workflow run name (e.g., LinuxClang)
WORKFLOW_NAME=${{ github.event.workflow_run.name }}
WORKFLOW_NAME="${{ github.event.workflow_run.name }}"

if [[ $EVENT == "pull_request" ]]; then
gh run download ${{ github.event.workflow_run.id }} -n pr_number
Expand All @@ -45,16 +45,19 @@ jobs:
# The goal is to keep the last used key of each job and delete all others.

# something like ccache-LinuxClang-
keyprefix=ccache-${WORKFLOW_NAME}-
keyprefix="ccache-${WORKFLOW_NAME}-"

cached_jobs=$(gh actions-cache list -L 100 -R $REPO -B $BRANCH --key $keyprefix | awk -F '-git-' '{print $1}' | sort | uniq)
cached_jobs=$(gh actions-cache list -L 100 -R $REPO -B $BRANCH --key "$keyprefix" | awk -F '-git-' '{print $1}' | sort | uniq)

# cached_jobs is something like "ccache-LinuxClang-configure-1d ccache-LinuxClang-configure-2d".
# It might also contain spaces. Thus we set IFS to \n.
IFS=$'\n'
for j in $cached_jobs
do
old_keys=$(gh actions-cache list -L 100 -R $REPO -B $BRANCH --key ${j}-git- --sort last-used | cut -f 1 | tail -n +2)
old_keys=$(gh actions-cache list -L 100 -R $REPO -B $BRANCH --key "${j}-git-" --sort last-used | cut -f 1 | tail -n +2)
for k in $old_keys
do
gh actions-cache delete $k -R $REPO -B $BRANCH --confirm
gh actions-cache delete "$k" -R $REPO -B $BRANCH --confirm
done
done
unset IFS
34 changes: 34 additions & 0 deletions .github/workflows/cuda-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,51 @@ jobs:
submodules: true
- name: Prepare CUDA environment
run: Submodules/AMReX/.github/workflows/dependencies/dependencies_nvcc.sh ${{matrix.cuda_ver}}
- name: Install CCache
run: Submodules/AMReX/.github/workflows/dependencies/dependencies_ccache.sh
- name: Set Up Cache
uses: actions/cache@v4
with:
path: ~/.cache/ccache
key: ccache-${{ github.workflow }}-${{ github.job }}-git-${{ github.sha }}
restore-keys: |
ccache-${{ github.workflow }}-${{ github.job }}-git-
- name: Configure and build
run: |
export CCACHE_COMPRESS=1
export CCACHE_COMPRESSLEVEL=10
export CCACHE_MAXSIZE=600M
ccache -z

export PATH=/usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH}
export LD_LIBRARY_PATH=/usr/local/nvidia/lib:/usr/local/nvidia/lib64:/usr/local/cuda/lib64:${LD_LIBRARY_PATH}
which nvcc || echo "nvcc not in PATH!"
cmake -Bbuild-${{matrix.cuda_pkg}} \
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_CUDA_COMPILER_LAUNCHER=ccache \
-DAMReX_CUDA_ERROR_CROSS_EXECUTION_SPACE_CALL=ON \
-DAMReX_CUDA_ERROR_CAPTURE_THIS=ON \
-DERF_DIM:STRING=3 \
-DERF_ENABLE_MPI:BOOL=ON \
-DERF_ENABLE_CUDA:BOOL=ON \
-DERF_ENABLE_REGRESSION_TESTS_ONLY:BOOL=ON .
cmake --build build-${{matrix.cuda_pkg}} -- -j $(nproc)

ccache -s
du -hs ~/.cache/ccache

save_pr_number:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Save PR number
env:
PR_NUMBER: ${{ github.event.number }}
run: |
echo $PR_NUMBER > pr_number.txt
- uses: actions/upload-artifact@v4
with:
name: pr_number
path: pr_number.txt
retention-days: 1
35 changes: 35 additions & 0 deletions .github/workflows/gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,24 @@ jobs:
- name: Install Dependencies
run: Submodules/AMReX/.github/workflows/dependencies/dependencies.sh

- name: Install CCache
run: Submodules/AMReX/.github/workflows/dependencies/dependencies_ccache.sh

- name: Set Up Cache
uses: actions/cache@v4
with:
path: ~/.cache/ccache
key: ccache-${{ github.workflow }}-${{ github.job }}-git-${{ github.sha }}
restore-keys: |
ccache-${{ github.workflow }}-${{ github.job }}-git-

- name: Configure Project and Generate Build System
run: |
cmake \
-B${{runner.workspace}}/ERF/build \
-DCMAKE_INSTALL_PREFIX:PATH=${{runner.workspace}}/ERF/install \
-DCMAKE_BUILD_TYPE:STRING=Debug \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DERF_DIM:STRING=3 \
-DERF_ENABLE_MPI:BOOL=ON \
-DERF_ENABLE_TESTS:BOOL=ON \
Expand All @@ -34,9 +46,32 @@ jobs:

- name: Compile and Link
run: |
export CCACHE_COMPRESS=1
export CCACHE_COMPRESSLEVEL=10
export CCACHE_MAXSIZE=300M
ccache -z

cmake --build ${{runner.workspace}}/ERF/build --parallel 2 --verbose

ccache -s
du -hs ~/.cache/ccache

- name: CMake Tests # see file ERF/Tests/CTestList.cmake
run: |
ctest -L regression -VV
working-directory: ${{runner.workspace}}/ERF/build

save_pr_number:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Save PR number
env:
PR_NUMBER: ${{ github.event.number }}
run: |
echo $PR_NUMBER > pr_number.txt
- uses: actions/upload-artifact@v4
with:
name: pr_number
path: pr_number.txt
retention-days: 1
35 changes: 35 additions & 0 deletions .github/workflows/hip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,24 @@ jobs:
- name: Dependencies
run: Submodules/AMReX/.github/workflows/dependencies/dependencies_hip.sh

- name: Install CCache
run: Submodules/AMReX/.github/workflows/dependencies/dependencies_ccache.sh

- name: Set Up Cache
uses: actions/cache@v4
with:
path: ~/.cache/ccache
key: ccache-${{ github.workflow }}-${{ github.job }}-git-${{ github.sha }}
restore-keys: |
ccache-${{ github.workflow }}-${{ github.job }}-git-

- name: Build & Install
run: |
export CCACHE_COMPRESS=1
export CCACHE_COMPRESSLEVEL=10
export CCACHE_MAXSIZE=300M
ccache -z

source /etc/profile.d/rocm.sh
hipcc --version
which clang
Expand All @@ -59,6 +75,7 @@ jobs:
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DCMAKE_INSTALL_PREFIX:PATH=${{runner.workspace}}/ERF/install \
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DERF_DIM:STRING=3 \
-DERF_ENABLE_MPI:BOOL=ON \
-DERF_ENABLE_HIP:BOOL=ON \
Expand All @@ -81,6 +98,9 @@ jobs:
# make -j ${{env.NPROCS}};
make -j 2;

ccache -s
du -hs ~/.cache/ccache

# - name: Regression Tests
# run: |
# ctest -L regression -VV
Expand Down Expand Up @@ -119,3 +139,18 @@ jobs:
name: build-and-test
path: |
${{runner.workspace}}/ERF/regressioncov.xml

save_pr_number:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Save PR number
env:
PR_NUMBER: ${{ github.event.number }}
run: |
echo $PR_NUMBER > pr_number.txt
- uses: actions/upload-artifact@v4
with:
name: pr_number
path: pr_number.txt
retention-days: 1
31 changes: 31 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,22 @@ jobs:
- name: Install Dependencies
run: Submodules/AMReX/.github/workflows/dependencies/dependencies_mac.sh

- name: Set Up Cache
uses: actions/cache@v4
with:
path: /Users/runner/Library/Caches/ccache
key: ccache-${{ github.workflow }}-${{ github.job }}-git-${{ github.sha }}
restore-keys: |
ccache-${{ github.workflow }}-${{ github.job }}-git-

- name: Configure Project and Generate Build System
run: |
cmake \
-B${{runner.workspace}}/ERF/build \
-DBUILD_SHARED_LIBS:BOOL=TRUE \
-DCMAKE_CXX_COMPILER_LAUNCHER=$(which ccache) \
-DCMAKE_BUILD_TYPE:STRING=Debug \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DERF_DIM:STRING=3 \
-DERF_ENABLE_MPI:BOOL=TRUE \
-DERF_ENABLE_TESTS:BOOL=TRUE \
Expand All @@ -35,9 +44,31 @@ jobs:

- name: Compile and Link
run: |
export CCACHE_COMPRESS=1
export CCACHE_COMPRESSLEVEL=10
export CCACHE_MAXSIZE=250M
ccache -z

cmake --build ${{runner.workspace}}/ERF/build --parallel 2 --verbose

ccache -s

- name: CMake Tests # see file ERF/Tests/CTestList.cmake
run: |
ctest -L regression -VV
working-directory: ${{runner.workspace}}/ERF/build

save_pr_number:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Save PR number
env:
PR_NUMBER: ${{ github.event.number }}
run: |
echo $PR_NUMBER > pr_number.txt
- uses: actions/upload-artifact@v4
with:
name: pr_number
path: pr_number.txt
retention-days: 1
Loading
Loading