CI and Build System Improvements (#75) #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: FerroX CI (cuda) | |
| on: | |
| push: | |
| # branches: [development] | |
| paths-ignore: | |
| - Docs | |
| - README.md | |
| - license.txt | |
| pull_request: | |
| branches: [development] | |
| concurrency: | |
| group: ${{ github.ref }}-${{ github.head_ref }}-cuda-ci | |
| cancel-in-progress: true | |
| jobs: | |
| cuda-build: | |
| runs-on: ubuntu-22.04 | |
| name: CUDA v${{matrix.cuda_ver}} - SUNDIALS ${{matrix.sundials}} - AMReX ${{matrix.amrex_mode}} | |
| strategy: | |
| matrix: | |
| cuda_pkg: [12-0] | |
| sundials: [OFF, ON] | |
| amrex_mode: [internal, external_src] | |
| include: | |
| - cuda_ver: "12.0" | |
| cuda_pkg: 12-0 | |
| - cuda_arch: "8.0" | |
| cuda_pkg: 12-0 | |
| steps: | |
| - name: Cancel previous runs | |
| uses: styfle/[email protected] | |
| with: | |
| access_token: ${{github.token}} | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: Clone AMReX for dependency scripts | |
| run: | | |
| git clone https://github.com/AMReX-Codes/amrex.git ${{runner.workspace}}/amrex | |
| - name: Setup | |
| run: | | |
| if [ "${{matrix.amrex_mode}}" == "external_src" ]; then | |
| echo "AMREX_SRC_DIR=${{runner.workspace}}/amrex" >> $GITHUB_ENV | |
| if [ "${{matrix.sundials}}" == "ON" ]; then | |
| git clone https://github.com/LLNL/sundials.git ${{runner.workspace}}/sundials | |
| echo "SUNDIALS_SRC_DIR=${{runner.workspace}}/sundials" >> $GITHUB_ENV | |
| fi | |
| fi | |
| - name: Free up disk space | |
| uses: ./.github/actions/free-space-ubuntu | |
| - name: Prepare CUDA environment | |
| run: ${{runner.workspace}}/amrex/.github/workflows/dependencies/dependencies_nvcc.sh ${{matrix.cuda_ver}} | |
| - name: Install Additional Dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libfftw3-dev | |
| - name: Install CCache | |
| run: ${{runner.workspace}}/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: Show disk space | |
| run: df -h | |
| - 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!" | |
| if [ "${{matrix.amrex_mode}}" == "external_src" ]; then | |
| if [ "${{matrix.sundials}}" == "ON" ]; then | |
| cmake -Bbuild-${{matrix.cuda_pkg}}-${{matrix.sundials}}-${{matrix.amrex_mode}} \ | |
| -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 \ | |
| -DAMReX_CUDA_ARCH=${{matrix.cuda_arch}} \ | |
| -DFerroX_MPI:BOOL=ON \ | |
| -DFerroX_COMPUTE:STRING=CUDA \ | |
| -DFerroX_SUNDIALS:BOOL=ON \ | |
| -DFerroX_ENABLE_ALL_WARNINGS:BOOL=ON \ | |
| -DFerroX_amrex_src:PATH=${{env.AMREX_SRC_DIR}} \ | |
| -DFerroX_sundials_src:PATH=${{env.SUNDIALS_SRC_DIR}} . | |
| else | |
| cmake -Bbuild-${{matrix.cuda_pkg}}-${{matrix.sundials}}-${{matrix.amrex_mode}} \ | |
| -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 \ | |
| -DAMReX_CUDA_ARCH=${{matrix.cuda_arch}} \ | |
| -DFerroX_MPI:BOOL=ON \ | |
| -DFerroX_COMPUTE:STRING=CUDA \ | |
| -DFerroX_SUNDIALS:BOOL=OFF \ | |
| -DFerroX_ENABLE_ALL_WARNINGS:BOOL=ON \ | |
| -DFerroX_amrex_src:PATH=${{env.AMREX_SRC_DIR}} . | |
| fi | |
| else | |
| cmake -Bbuild-${{matrix.cuda_pkg}}-${{matrix.sundials}}-${{matrix.amrex_mode}} \ | |
| -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 \ | |
| -DAMReX_CUDA_ARCH=${{matrix.cuda_arch}} \ | |
| -DFerroX_MPI:BOOL=ON \ | |
| -DFerroX_COMPUTE:STRING=CUDA \ | |
| -DFerroX_SUNDIALS:BOOL=${{matrix.sundials}} \ | |
| -DFerroX_ENABLE_ALL_WARNINGS:BOOL=ON . | |
| fi | |
| echo "Building with $(nproc) processes" | |
| cmake --build build-${{matrix.cuda_pkg}}-${{matrix.sundials}}-${{matrix.amrex_mode}} --parallel $(nproc) \ | |
| 2>&1 | tee -a ${{runner.workspace}}/build-${{matrix.cuda_pkg}}-${{matrix.sundials}}-${{matrix.amrex_mode}}-output.txt; | |
| ccache -s | |
| du -hs ~/.cache/ccache | |
| - name: Report | |
| run: | | |
| egrep "warning:|error:" ${{runner.workspace}}/build-${{matrix.cuda_pkg}}-${{matrix.sundials}}-${{matrix.amrex_mode}}-output.txt \ | |
| | egrep -v "_deps/.*amrex" | egrep -v "_deps/.*sundials" | egrep -v "${{runner.workspace}}/amrex" | egrep -v "${{runner.workspace}}/sundials" | egrep -v "lto-wrapper: warning:" | sort | uniq \ | |
| | awk 'BEGIN{i=0}{print $0}{i++}END{print "Warnings: "i}' > ${{runner.workspace}}/build-${{matrix.cuda_pkg}}-${{matrix.sundials}}-${{matrix.amrex_mode}}-output-warnings.txt | |
| cat ${{runner.workspace}}/build-${{matrix.cuda_pkg}}-${{matrix.sundials}}-${{matrix.amrex_mode}}-output-warnings.txt | |
| export return=$(tail -n 1 ${{runner.workspace}}/build-${{matrix.cuda_pkg}}-${{matrix.sundials}}-${{matrix.amrex_mode}}-output-warnings.txt | awk '{print $2}') | |
| exit ${return} |