From f1de90a57d0ea8f6edcfca6f586fdb38a7933ef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Mon, 27 Jan 2025 09:17:19 +0100 Subject: [PATCH 1/2] CI: Disable building with OpenMP on Apple Silicon Building with OpenMP causes some test failures for macOS on Apple Silicon, see: https://github.com/ElmerCSC/elmerfem/pull/634#issuecomment-2613840076 The affected tests currently are: `H1BasisEvaluation` and `SD_H1BasisEvaluation`. For the time being, disable building with OpenMP on Apple Silicon in CI. OpenMP is needed as a transitional build dependency of the SuiteSparse package from Homebrew. So, also disable building with CHOLMOD. --- .github/workflows/build-macos-homebrew.yaml | 37 ++++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-macos-homebrew.yaml b/.github/workflows/build-macos-homebrew.yaml index 0f0b2d3058..1b80a42808 100644 --- a/.github/workflows/build-macos-homebrew.yaml +++ b/.github/workflows/build-macos-homebrew.yaml @@ -18,12 +18,28 @@ jobs: runs-on: ${{ matrix.os }} + name: ${{ matrix.os }} (${{ matrix.openmp }} OpenMP) + strategy: # Allow other runners in the matrix to continue if some fail fail-fast: false matrix: - os: [macos-14, macos-13] + os: [macos-14] + openmp: [without] + # Building with OpenMP causes some test failures on macOS on Apple + # Silicon. + # The affected tests currently are: H1BasisEvaluation and + # SD_H1BasisEvaluation. + # For the time being, disable building with OpenMP in CI on Apple + # Silicon. + # OpenMP is also needed as a transitional build dependency of the + # SuiteSparse package from Homebrew. + # FIXME: Consider building with OpenMP again when this (potentially + # upstream) issue has been fixed. + include: + - os: macos-13 + openmp: with steps: - name: get CPU information @@ -49,13 +65,14 @@ jobs: brew install --overwrite python@3.12 python@3.13 brew reinstall gcc brew install \ - cmake libomp openblas open-mpi suitesparse \ + cmake openblas open-mpi \ + ${{ matrix.openmp == 'with' && 'libomp suitesparse' || '' }} \ qwt vtk opencascade echo "HOMEBREW_PREFIX=$(brew --prefix)" >> $GITHUB_ENV - name: configure env: - LDFLAGS: -L${{ env.HOMEBREW_PREFIX }}/opt/libomp/lib -lomp + LDFLAGS: ${{ matrix.openmp == 'with' && format('-L{0}/opt/libomp/lib -lomp', env.HOMEBREW_PREFIX) || '' }} run: | mkdir ${GITHUB_WORKSPACE}/build cd ${GITHUB_WORKSPACE}/build @@ -66,17 +83,19 @@ jobs: -DCMAKE_Fortran_COMPILER=gfortran \ -DCMAKE_INSTALL_PREFIX="${GITHUB_WORKSPACE}/usr" \ -DBLA_VENDOR="OpenBLAS" \ - -DCMAKE_PREFIX_PATH="${HOMEBREW_PREFIX}/opt/libomp;${HOMEBREW_PREFIX}/opt/openblas;${HOMEBREW_PREFIX}/opt/qt;${HOMEBREW_PREFIX}/opt/qwt" \ - -DWITH_OpenMP=ON \ - -DOpenMP_C_FLAGS="-Xclang -fopenmp -I${HOMEBREW_PREFIX}/opt/libomp/include" \ - -DOpenMP_CXX_FLAGS="-Xclang -fopenmp -I${HOMEBREW_PREFIX}/opt/libomp/include" \ - -DOpenMP_Fortran_FLAGS="-fopenmp -I${HOMEBREW_PREFIX}/opt/libomp/include" \ + -DCMAKE_PREFIX_PATH="$( [ "${{ matrix.openmp }}" == "with" ] && echo "${HOMEBREW_PREFIX}/opt/libomp;")${HOMEBREW_PREFIX}/opt/openblas;${HOMEBREW_PREFIX}/opt/qt;${HOMEBREW_PREFIX}/opt/qwt" \ + ${{ matrix.openmp == 'with' + && '-DWITH_OpenMP=ON \ + -DOpenMP_C_FLAGS="-Xclang -fopenmp -I${HOMEBREW_PREFIX}/opt/libomp/include" \ + -DOpenMP_CXX_FLAGS="-Xclang -fopenmp -I${HOMEBREW_PREFIX}/opt/libomp/include" \ + -DOpenMP_Fortran_FLAGS="-fopenmp -I${HOMEBREW_PREFIX}/opt/libomp/include"' + || '-DWITH_OpenMP=OFF' }} \ -DWITH_LUA=ON \ -DWITH_MPI=ON \ -DMPI_TEST_MAXPROC=2 \ -DWITH_Zoltan=OFF \ -DWITH_Mumps=OFF \ - -DWITH_CHOLMOD=ON \ + -DWITH_CHOLMOD=${{ matrix.openmp == 'with' && 'ON' || 'OFF' }} \ -DWITH_ElmerIce=ON \ -DWITH_ELMERGUI=ON \ -DWITH_QT6=ON \ From 2f68c6ce44123d34b19c7bbc41d0be5ed801fe10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Mon, 27 Jan 2025 18:11:40 +0100 Subject: [PATCH 2/2] CI: Build with `-O2` on macOS 13 (Intel CPU) The tests `SD_H1BasisEvaluation` and `SD_LinearFormsAssembly` are failing on macOS 13 (Intel CPU) at optimization level `-O3`. They are passing when ElmerFEM is built with optimization level `-O2`. Switch the build type to "RelWithDebInfo" for that runner as a work-around. --- .github/workflows/build-macos-homebrew.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-macos-homebrew.yaml b/.github/workflows/build-macos-homebrew.yaml index 1b80a42808..a640ba0922 100644 --- a/.github/workflows/build-macos-homebrew.yaml +++ b/.github/workflows/build-macos-homebrew.yaml @@ -73,11 +73,14 @@ jobs: - name: configure env: LDFLAGS: ${{ matrix.openmp == 'with' && format('-L{0}/opt/libomp/lib -lomp', env.HOMEBREW_PREFIX) || '' }} + # The tests `SD_H1BasisEvaluation` and `SD_LinearFormsAssembly` are + # failing on macos-13 (Intel CPU) at optimization level `-O3`. + # They are passing if ElmerFEM is built with optimization level `-O2`. run: | mkdir ${GITHUB_WORKSPACE}/build cd ${GITHUB_WORKSPACE}/build cmake \ - -DCMAKE_BUILD_TYPE="Release" \ + -DCMAKE_BUILD_TYPE=${{ matrix.os == 'macos-13' && 'RelWithDebInfo' || 'Release' }} \ -DCMAKE_C_COMPILER=clang \ -DCMAKE_CXX_COMPILER=clang++ \ -DCMAKE_Fortran_COMPILER=gfortran \