From 264092b54b9e06f3281433813274e14d8fc7b13b Mon Sep 17 00:00:00 2001 From: Thomas Padioleau Date: Thu, 20 Feb 2025 14:20:48 +0100 Subject: [PATCH] Test macOS CI (#781) * Test macOS CI * Rework macos test * Fix junit path report * Add PDI * Silence some warnings * Rename workflow * Install Google Test and benchmark with homebrew --- .github/workflows/tests-macos.yml | 192 ++++++++++++++++++ .../workflows/{tests.yml => tests-ubuntu.yml} | 2 +- benchmarks/splines.cpp | 34 ++-- 3 files changed, 210 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/tests-macos.yml rename .github/workflows/{tests.yml => tests-ubuntu.yml} (99%) diff --git a/.github/workflows/tests-macos.yml b/.github/workflows/tests-macos.yml new file mode 100644 index 000000000..0e755dea8 --- /dev/null +++ b/.github/workflows/tests-macos.yml @@ -0,0 +1,192 @@ +# Copyright (C) The DDC development team, see COPYRIGHT.md file +# +# SPDX-License-Identifier: MIT + +name: Tests on macOS + +on: + schedule: + - cron: "0 1 * * *" # every day at 1am + pull_request: + push: + branches: + - main + +concurrency: + group: ${{ github.workflow }}-${{ github.ref == github.ref_protected && github.run_id || github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + id_repo: + runs-on: macos-latest + steps: + - name: Identify repository + id: identify_repo + run: | + echo "in_base_repo=${{ (github.event_name == 'push' && github.repository == 'CExA-project/ddc') || github.event.pull_request.head.repo.full_name == 'CExA-project/ddc' }}" >> "$GITHUB_OUTPUT" + outputs: { in_base_repo: '${{ steps.identify_repo.outputs.in_base_repo }}' } + + test-macos: + if: github.ref_name != 'main' + strategy: + fail-fast: false + matrix: + backend: + - name: 'cpu' + c_compiler: 'clang' + cxx_compiler: 'clang++' + ddc_extra_cxx_flags: '-Wextra-semi -Wextra-semi-stmt -Wold-style-cast' + kokkos_extra_cmake_flags: '' + cxx_version: ['17', '20', '23'] + cmake_build_type: ['Debug', 'Release'] + exclude: + - cxx_version: '20' # To be removed as soon as PDI supports C++20 with clang + - cxx_version: '23' # To be removed as soon as PDI supports C++20 with clang + runs-on: macos-latest + needs: [id_repo] + env: + DDC_ROOT: ${{github.workspace}}/opt/ddc + Ginkgo_ROOT: ${{github.workspace}}/opt/ginkgo + Kokkos_ROOT: ${{github.workspace}}/opt/kokkos + KokkosFFT_ROOT: ${{github.workspace}}/opt/kokkos-fft + KokkosKernels_ROOT: ${{github.workspace}}/opt/kokkos-kernels + PDI_ROOT: ${{github.workspace}}/opt/pdi + CMAKE_BUILD_PARALLEL_LEVEL: 4 + PKG_CONFIG_PATH: /opt/homebrew/opt/lapack/lib/pkgconfig + LAPACKE_DIR: /opt/homebrew/opt/lapack + CC: ${{matrix.backend.c_compiler}} + CXX: ${{matrix.backend.cxx_compiler}} + CMAKE_BUILD_TYPE: ${{matrix.cmake_build_type}} + steps: + - name: Checkout built branch + uses: actions/checkout@v4 + with: { submodules: true } + - name: Install PDI+user code plugin and dependencies + run: | + git clone --branch 1.8.1 --depth 1 https://github.com/pdidev/pdi.git + # PATCH: remove for macOS + sed -i.bak 's|#include ||g' pdi/plugins/user_code/user_code.cxx + rm -f pdi/plugins/user_code/user_code.cxx.bak + cmake \ + -DBUILD_BENCHMARKING=OFF \ + -DBUILD_DECL_HDF5_PLUGIN=OFF \ + -DBUILD_DECL_NETCDF_PLUGIN=OFF \ + -DBUILD_DEISA_PLUGIN=OFF \ + -DBUILD_DOCUMENTATION=OFF \ + -DBUILD_FORTRAN=OFF \ + -DBUILD_MPI_PLUGIN=OFF \ + -DBUILD_PYCALL_PLUGIN=OFF \ + -DBUILD_SERIALIZE_PLUGIN=OFF \ + -DBUILD_SET_VALUE_PLUGIN=OFF \ + -DBUILD_TESTING=OFF \ + -DBUILD_TRACE_PLUGIN=OFF \ + -DBUILD_USER_CODE_PLUGIN=ON \ + -DCMAKE_CXX_FLAGS="-Wno-unqualified-std-cast-call" \ + -DCMAKE_CXX_STANDARD=${{matrix.cxx_version}} \ + -B build \ + -S ./pdi + cmake --build build + cmake --install build --prefix $PDI_ROOT + rm -rf build + - name: Install fftw + run: brew install fftw + - name: Install lapack + run: brew install lapack + - name: Install Google Test + run: brew install googletest + - name: Install Google benchmark + run: brew install google-benchmark + - run: git config --global --add safe.directory '*' + - name: Install Ginkgo + run: | + git clone --branch v1.8.0 --depth 1 https://github.com/ginkgo-project/ginkgo.git + cmake \ + -DCMAKE_CXX_STANDARD=${{matrix.cxx_version}} \ + -DGINKGO_BUILD_BENCHMARKS=OFF \ + -DGINKGO_BUILD_EXAMPLES=OFF \ + -DGINKGO_BUILD_MPI=OFF \ + -DGINKGO_BUILD_REFERENCE=ON \ + -DGINKGO_BUILD_TESTS=OFF \ + -B build \ + -S ./ginkgo + cmake --build build + cmake --install build --prefix $Ginkgo_ROOT + rm -rf build + - name: Install Kokkos + run: | + cmake \ + -DCMAKE_CXX_STANDARD=${{matrix.cxx_version}} \ + -DKokkos_ENABLE_DEPRECATED_CODE_4=OFF \ + -DKokkos_ENABLE_DEPRECATION_WARNINGS=OFF \ + -DKokkos_ENABLE_SERIAL=ON \ + ${{matrix.backend.kokkos_extra_cmake_flags}} \ + -B build \ + -S ./vendor/kokkos + cmake --build build + cmake --install build --prefix $Kokkos_ROOT + rm -rf build + - name: Install Kokkos-fft + run: | + cmake \ + -DCMAKE_CXX_STANDARD=${{matrix.cxx_version}} \ + -DKokkosFFT_ENABLE_HOST_AND_DEVICE=ON \ + -B build \ + -S ./vendor/kokkos-fft + cmake --build build + cmake --install build --prefix $KokkosFFT_ROOT + rm -rf build + - name: Install Kokkos Kernels + run: | + cmake \ + -DCMAKE_CXX_STANDARD=${{matrix.cxx_version}} \ + -DKokkosKernels_ADD_DEFAULT_ETI=OFF \ + -DKokkosKernels_ENABLE_ALL_COMPONENTS=OFF \ + -DKokkosKernels_ENABLE_COMPONENT_BLAS=ON \ + -DKokkosKernels_ENABLE_COMPONENT_BATCHED=ON \ + -DKokkosKernels_ENABLE_COMPONENT_LAPACK=OFF \ + -DKokkosKernels_ENABLE_TPL_BLAS=OFF \ + -DKokkosKernels_ENABLE_TPL_CUSOLVER=OFF \ + -DKokkosKernels_ENABLE_TPL_LAPACK=OFF \ + -B build \ + -S ./vendor/kokkos-kernels + cmake --build build + cmake --install build --prefix $KokkosKernels_ROOT + rm -rf build + - name: Build DDC + run: | + cmake \ + -DCMAKE_CXX_FLAGS="-Werror -Wall -Wextra -Wpedantic -Wno-sign-compare -pedantic-errors ${{matrix.backend.ddc_extra_cxx_flags}}" \ + -DCMAKE_CXX_STANDARD=${{matrix.cxx_version}} \ + -DDDC_BUILD_BENCHMARKS=ON \ + -DDDC_benchmark_DEPENDENCY_POLICY=INSTALLED \ + -DDDC_GTest_DEPENDENCY_POLICY=INSTALLED \ + -DDDC_Kokkos_DEPENDENCY_POLICY=INSTALLED \ + -DDDC_KokkosFFT_DEPENDENCY_POLICY=INSTALLED \ + -DBLA_PREFER_PKGCONFIG=ON \ + -B build + cmake --build build + - name: Run unit tests + run: ctest --test-dir build --output-on-failure --timeout 10 --output-junit tests.xml + - name: Publish Test Report + uses: mikepenz/action-junit-report@v5 + if: ( success() || failure() ) # always run even if the previous step fails + with: + report_paths: '${{github.workspace}}/build/tests.xml' + - name: Run examples + run: | + ./build/examples/characteristics_advection + ./build/examples/game_of_life + ./build/examples/heat_equation_spectral + ./build/examples/heat_equation + ./build/examples/non_uniform_heat_equation + ./build/examples/uniform_heat_equation + - name: Install DDC + run: | + cmake --install build --prefix $DDC_ROOT + rm -rf build + - name: Run install tests + run: | + cmake \ + -B build \ + -S ./install_test + cmake --build build diff --git a/.github/workflows/tests.yml b/.github/workflows/tests-ubuntu.yml similarity index 99% rename from .github/workflows/tests.yml rename to .github/workflows/tests-ubuntu.yml index 568171902..92ce7ad29 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests-ubuntu.yml @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: MIT -name: Tests +name: Tests on Ubuntu on: schedule: diff --git a/benchmarks/splines.cpp b/benchmarks/splines.cpp index fa59bba56..3a4a1267c 100644 --- a/benchmarks/splines.cpp +++ b/benchmarks/splines.cpp @@ -228,35 +228,35 @@ void characteristics_advection_unitary(benchmark::State& state) void characteristics_advection(benchmark::State& state) { - long const host = 0; - long const dev = 1; - long const uniform = 0; - long const non_uniform = 1; + std::int64_t const host = 0; + std::int64_t const dev = 1; + std::int64_t const uniform = 0; + std::int64_t const non_uniform = 1; // Preallocate 12 unitary benchmarks for each combination of cpu/gpu execution space, uniform/non-uniform and spline degree we may want to benchmark (those are determined at compile-time, that's why we need to build explicitly 12 variants of the bench even if we call only one of them) - std::map, std::function> benchmarks; - benchmarks[std::array {host, uniform, 3L}] + std::map, std::function> benchmarks; + benchmarks[std::array {host, uniform, std::int64_t(3)}] = characteristics_advection_unitary; - benchmarks[std::array {host, uniform, 4L}] + benchmarks[std::array {host, uniform, std::int64_t(4)}] = characteristics_advection_unitary; - benchmarks[std::array {host, uniform, 5L}] + benchmarks[std::array {host, uniform, std::int64_t(5)}] = characteristics_advection_unitary; - benchmarks[std::array {host, non_uniform, 3L}] + benchmarks[std::array {host, non_uniform, std::int64_t(3)}] = characteristics_advection_unitary; - benchmarks[std::array {host, non_uniform, 4L}] + benchmarks[std::array {host, non_uniform, std::int64_t(4)}] = characteristics_advection_unitary; - benchmarks[std::array {host, non_uniform, 5L}] + benchmarks[std::array {host, non_uniform, std::int64_t(5)}] = characteristics_advection_unitary; - benchmarks[std::array {dev, uniform, 3L}] + benchmarks[std::array {dev, uniform, std::int64_t(3)}] = characteristics_advection_unitary; - benchmarks[std::array {dev, uniform, 4L}] + benchmarks[std::array {dev, uniform, std::int64_t(4)}] = characteristics_advection_unitary; - benchmarks[std::array {dev, uniform, 5L}] + benchmarks[std::array {dev, uniform, std::int64_t(5)}] = characteristics_advection_unitary; - benchmarks[std::array {dev, non_uniform, 3L}] + benchmarks[std::array {dev, non_uniform, std::int64_t(3)}] = characteristics_advection_unitary; - benchmarks[std::array {dev, non_uniform, 4L}] + benchmarks[std::array {dev, non_uniform, std::int64_t(4)}] = characteristics_advection_unitary; - benchmarks[std::array {dev, non_uniform, 5L}] + benchmarks[std::array {dev, non_uniform, std::int64_t(5)}] = characteristics_advection_unitary; // Run the desired bench