diff --git a/.ci/azure-pipelines-aarch64-hwasan.yml b/.ci/azure-pipelines-aarch64-hwasan.yml new file mode 100644 index 000000000..9dfbe7186 --- /dev/null +++ b/.ci/azure-pipelines-aarch64-hwasan.yml @@ -0,0 +1,41 @@ +# Starter pipeline +# Start with a minimal pipeline that you can customize to build and deploy your code. +# Add steps that build, run tests, deploy, and more: +# https://aka.ms/yaml + +trigger: +- development + +pr: + autoCancel: true + branches: + include: + - development + +jobs: +- job: BuildAndTest + timeoutInMinutes: 180 # how long to run the job before automatically cancelling + pool: oracle-cloud + steps: + - task: CMake@1 + displayName: 'Configure CMake' + inputs: + cmakeArgs: '.. -DCMAKE_BUILD_TYPE=Release -DENABLE_HWASAN=ON -DCMAKE_CXX_FLAGS="-fPIC" -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" -DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=lld" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DAMReX_SPACEDIM=1' + + - task: CMake@1 + displayName: 'Build Quokka' + inputs: + cmakeArgs: '--build .' + + - task: CMake@1 + displayName: 'Run CTest' + inputs: + cmakeArgs: '-E chdir . ctest -j 2 -T Test --output-on-failure' + + - task: PublishTestResults@2 + inputs: + testResultsFormat: cTest + testResultsFiles: build/Testing/*/Test.xml + testRunTitle: $(Agent.JobName) + condition: succeededOrFailed() + displayName: Publish test results diff --git a/.ci/azure-pipelines-asan.yml b/.ci/azure-pipelines-asan.yml deleted file mode 100644 index e5b97c68c..000000000 --- a/.ci/azure-pipelines-asan.yml +++ /dev/null @@ -1,40 +0,0 @@ -# Starter pipeline -# Start with a minimal pipeline that you can customize to build and deploy your code. -# Add steps that build, run tests, deploy, and more: -# https://aka.ms/yaml - -trigger: -- development - -pr: - autoCancel: true - branches: - include: - - development - -pool: avatar - -steps: - -- task: CMake@1 - displayName: 'Configure CMake' - inputs: - cmakeArgs: '.. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DAMReX_SPACEDIM=1 -DAMReX_GPU_BACKEND=CUDA -DQUOKKA_PYTHON=OFF -DENABLE_ASAN=ON -G Ninja' - -- task: CMake@1 - displayName: 'Build Quokka' - inputs: - cmakeArgs: '--build .' - -- task: CMake@1 - displayName: 'Run CTest' - inputs: - cmakeArgs: '-E chdir . ctest -E "MatterEnergyExchange*" -T Test --output-on-failure' - -- task: PublishTestResults@2 - inputs: - testResultsFormat: cTest - testResultsFiles: build/Testing/*/Test.xml - testRunTitle: $(Agent.JobName) - condition: succeededOrFailed() - displayName: Publish test results diff --git a/.ci/azure-pipelines-build-llvm.yml b/.ci/azure-pipelines-build-llvm.yml deleted file mode 100644 index bf45ccf99..000000000 --- a/.ci/azure-pipelines-build-llvm.yml +++ /dev/null @@ -1,35 +0,0 @@ -trigger: -- development - -pr: - autoCancel: true - branches: - include: - - development - -pool: avatar - -steps: - -- task: CMake@1 - displayName: 'Configure CMake' - inputs: - cmakeArgs: '.. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CUDA_COMPILER=clang -DAMReX_SPACEDIM=3 -DAMReX_GPU_BACKEND=CUDA -DCMAKE_CUDA_ARCHITECTURES=70 -DQUOKKA_PYTHON=OFF -G Ninja' - -- task: CMake@1 - displayName: 'Build Quokka' - inputs: - cmakeArgs: '--build .' - -- task: CMake@1 - displayName: 'Run CTest' - inputs: - cmakeArgs: '-E chdir . ctest -E "MatterEnergyExchange*" -T Test --output-on-failure' - -- task: PublishTestResults@2 - inputs: - testResultsFormat: cTest - testResultsFiles: build/Testing/*/Test.xml - testRunTitle: $(Agent.JobName) - condition: succeededOrFailed() - displayName: Publish test results \ No newline at end of file diff --git a/.ci/azure-pipelines-debug.yml b/.ci/azure-pipelines-debug.yml deleted file mode 100644 index 1ef6b68b6..000000000 --- a/.ci/azure-pipelines-debug.yml +++ /dev/null @@ -1,40 +0,0 @@ -# Starter pipeline -# Start with a minimal pipeline that you can customize to build and deploy your code. -# Add steps that build, run tests, deploy, and more: -# https://aka.ms/yaml - -trigger: -- development - -pr: - autoCancel: true - branches: - include: - - development - -pool: avatar - -steps: - -- task: CMake@1 - displayName: 'Configure CMake' - inputs: - cmakeArgs: '.. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DAMReX_SPACEDIM=1 -DAMReX_GPU_BACKEND=CUDA -DQUOKKA_PYTHON=OFF -G Ninja' - -- task: CMake@1 - displayName: 'Build Quokka' - inputs: - cmakeArgs: '--build .' - -- task: CMake@1 - displayName: 'Run CTest' - inputs: - cmakeArgs: '-E chdir . ctest -E "MatterEnergyExchange*" -T Test --output-on-failure' - -- task: PublishTestResults@2 - inputs: - testResultsFormat: cTest - testResultsFiles: build/Testing/*/Test.xml - testRunTitle: $(Agent.JobName) - condition: succeededOrFailed() - displayName: Publish test results \ No newline at end of file diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 000000000..ae613abeb --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,110 @@ +name: CodeQL + +on: + push: + branches: [ "development" ] + pull_request: + branches: [ "development" ] + schedule: + - cron: "27 3 * * 0" + +concurrency: + group: ${{ github.ref }}-${{ github.head_ref }}-codeql + cancel-in-progress: true + +jobs: + analyze: + if: ${{ github.repository == 'quokka-astro/quokka' || github.event_name != 'schedule' }} + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ python, cpp ] + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: true + fetch-depth: 0 + + - name: Install Packages (C++) + if: ${{ matrix.language == 'cpp' }} + run: | + sudo apt-get update + sudo apt-get install --yes cmake openmpi-bin libopenmpi-dev libhdf5-openmpi-dev + .github/workflows/dependencies/dependencies_ccache.sh + sudo ln -s /usr/local/bin/ccache /usr/local/bin/g++ + + - name: Set Up Cache + if: ${{ matrix.language == 'cpp' }} + 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 (C++) + if: ${{ matrix.language == 'cpp' }} + run: | + cmake -S . -B build \ + -DQUOKKA_PYTHON=OFF \ + -DCMAKE_VERBOSE_MAKEFILE=ON \ + -DCMAKE_CXX_COMPILER="/usr/local/bin/g++" + + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + queries: +security-and-quality + config-file: ./.github/workflows/codeql/codeql-config.yml + + - name: Build (py) + uses: github/codeql-action/autobuild@v3 + if: ${{ matrix.language == 'python' }} + + - name: Build (C++) + if: ${{ matrix.language == 'cpp' }} + run: | + export CCACHE_COMPRESS=1 + export CCACHE_COMPRESSLEVEL=10 + export CCACHE_MAXSIZE=30M + ccache -z + + cmake --build build -j 4 + + ccache -s + du -hs ~/.cache/ccache + + # Make sure CodeQL has something to do + touch src/main.cpp + export CCACHE_DISABLE=1 + cd build + make -j 4 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{ matrix.language }}" + + 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 diff --git a/.github/workflows/codeql/codeql-config.yml b/.github/workflows/codeql/codeql-config.yml new file mode 100644 index 000000000..90eaf7ad5 --- /dev/null +++ b/.github/workflows/codeql/codeql-config.yml @@ -0,0 +1,10 @@ +query-filters: + - exclude: + id: + - cpp/commented-out-code + - cpp/complex-condition + - cpp/equality-on-floats + - cpp/fixme-comment + - cpp/path-injection + - cpp/poorly-documented-function + - cpp/use-of-goto diff --git a/CMakeLists.txt b/CMakeLists.txt index 9bbb5cebc..d0b58a3cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,7 @@ set(AMReX_TINY_PROFILE ON CACHE BOOL "" FORCE) option(QUOKKA_PYTHON "Compile with Python support (on/off)" ON) option(DISABLE_FMAD "Disable fused multiply-add instructions on GPU (on/off)" ON) option(ENABLE_ASAN "Enable AddressSanitizer and UndefinedBehaviorSanitizer" OFF) +option(ENABLE_HWASAN "Enable HWAddressSanitizer" OFF) option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" OFF) option(QUOKKA_OPENPMD "Enable OpenPMD output (on/off)" OFF) diff --git a/extern/Microphysics b/extern/Microphysics index 7de212422..fbeddb367 160000 --- a/extern/Microphysics +++ b/extern/Microphysics @@ -1 +1 @@ -Subproject commit 7de212422501a88c1c1f536b93217721e3dc6701 +Subproject commit fbeddb367c6ef7d71052e23c20deda164243e643 diff --git a/extern/amrex b/extern/amrex index b96b731d4..689144d15 160000 --- a/extern/amrex +++ b/extern/amrex @@ -1 +1 @@ -Subproject commit b96b731d4a6fa496f80e54c2c0476a50b9dd4e86 +Subproject commit 689144d157a0106faf3d0ae89f8d90b0250cf975 diff --git a/extern/fmt b/extern/fmt index a5bacf3fe..6321a97d6 160000 --- a/extern/fmt +++ b/extern/fmt @@ -1 +1 @@ -Subproject commit a5bacf3fefcbe927b8aafac2ab17d5c6895cabe2 +Subproject commit 6321a97d6bd1096274b4e1b22f6210cc9031cab4 diff --git a/extern/openPMD-api b/extern/openPMD-api index a3fe9b75d..d9fce66dd 160000 --- a/extern/openPMD-api +++ b/extern/openPMD-api @@ -1 +1 @@ -Subproject commit a3fe9b75d81aa1df569b9fb73ad67b772638961f +Subproject commit d9fce66ddf256beb527c3d3e98e212725dae7f47 diff --git a/extern/yaml-cpp b/extern/yaml-cpp index 94710bb22..4afd53b0d 160000 --- a/extern/yaml-cpp +++ b/extern/yaml-cpp @@ -1 +1 @@ -Subproject commit 94710bb2213cb6793121eaaa4edfb15abcca7af9 +Subproject commit 4afd53b0d3140ba2eb85816bfced209cf37ff096 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f066647de..5d7856695 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -60,6 +60,13 @@ if(ENABLE_ASAN) add_link_options(-fsanitize=address -fsanitize=undefined) endif(ENABLE_ASAN) +if(ENABLE_HWASAN) + # enable HWAddressSanitizer for debugging + message(STATUS "Compiling with HWAddressSanitizer *enabled*") + add_compile_options(-fsanitize=hwaddress) + add_link_options(-fsanitize=hwaddress) +endif(ENABLE_HWASAN) + if(DISABLE_FMAD) message(STATUS "Fused multiply-add (FMAD) is disabled for device code.") add_compile_options($<$:-ffp-contract=off>)