diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index 9a48049b..32147102 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -1,4 +1,11 @@ name: "Linux Build" + +inputs: + use-mumps: + description: 'Indicates if GMGPolar should be built with mumps support' + type: bool + required: true + runs: using: "composite" steps: @@ -7,12 +14,36 @@ runs: run: | apt-get -qq update apt-get -qq -y install lcov + - name: Install METIS + shell: bash + if: inputs.use-mumps == 'true' + run: | + apt-get -qq -y install gfortran + git clone -b v5.1.0.4 https://github.com/scivision/METIS.git + cd METIS + cmake -Bbuild -DCMAKE_INSTALL_PREFIX=$(pwd)/install -DCMAKE_BUILD_TYPE=Release + cmake --build build + cmake --install build + ls install/* + echo "METIS_DIR=$(pwd)/install" >> $GITHUB_ENV + echo "METIS_ROOT=$(pwd)/install" >> $GITHUB_ENV + - name: Install MUMPS + shell: bash + if: inputs.use-mumps == 'true' + run: | + git clone -b v5.5.1.11 https://github.com/scivision/mumps.git + cd mumps + cmake -Bbuild -DBUILD_SINGLE=on -DBUILD_DOUBLE=on -Dmetis=on -Dopenmp=on -Dparallel=off -DCMAKE_INSTALL_PREFIX=$(pwd)/install -DCMAKE_BUILD_TYPE=Release -S . + cmake --build build + cmake --install build + ls install/* + echo "MUMPS_DIR=$(pwd)/install" >> $GITHUB_ENV - name: Build - shell: + shell: bash # ensure that the installed compiler version is used run: | mkdir build && cd build - cmake -DCMAKE_BUILD_TYPE=Debug -DGMGPOLAR_ENABLE_COVERAGE=ON .. + cmake -DCMAKE_BUILD_TYPE=Debug -DGMGPOLAR_ENABLE_COVERAGE=ON -DGMGPOLAR_USE_MUMPS=${{ inputs.use-mumps }} .. make -j4 - name: create build dir archive shell: bash @@ -21,6 +52,6 @@ runs: - name: Upload build dir archive uses: actions/upload-artifact@v4 with: - name: build-cpp-linux-gmgpolar + name: build-cpp-linux-gmgpolar${{ inputs.use-mumps == 'true' && '-mumps' || ''}} path: build.tar.gz retention-days: 1 diff --git a/.github/actions/test/action.yml b/.github/actions/test/action.yml index d25e4d06..556b0020 100644 --- a/.github/actions/test/action.yml +++ b/.github/actions/test/action.yml @@ -4,6 +4,10 @@ inputs: build-artifact: description: "Name of the build artifact that contains the unit test" required: true + use-mumps: + description: 'Indicates if GMGPolar should be built with mumps support' + type: bool + required: true runs: using: "composite" @@ -13,10 +17,14 @@ runs: run: | apt-get -qq update apt-get -qq -y install lcov + - name: Install MUMPS Dependencies + shell: bash + run: | + apt-get -qq -y install gfortran - name: Download build test directory uses: actions/download-artifact@v4 with: - name: ${{ inputs.build-artifact }} + name: ${{ inputs.build-artifact }}${{ inputs.use-mumps == 'true' && '-mumps' || ''}} - name: extract build archive shell: bash run: | @@ -38,14 +46,14 @@ runs: - name: Upload test report uses: actions/upload-artifact@v4 with: - name: test-report + name: test-report${{ inputs.use-mumps == 'true' && '-mumps' || ''}} path: build/tests/testreport.xml if-no-files-found: error retention-days: 3 - name: Upload coverage reports uses: actions/upload-artifact@v4 with: - name: test-coverage-reports + name: test-coverage-reports${{ inputs.use-mumps == 'true' && '-mumps' || ''}} path: | build/coverage-filtered.info build/coverage diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 65529cdc..7f679fd5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,16 +13,25 @@ jobs: install-and-build: if: github.event.pull_request.draft == false runs-on: ubuntu-latest + strategy: + matrix: + USE_MUMPS: [false, true] + name: 'install-and-build (USE_MUMPS=${{matrix.USE_MUMPS}})' container: image: ghcr.io/gyselax/gyselalibxx_env:latest options: --user root steps: - uses: actions/checkout@v4 - uses: ./.github/actions/build + with: + use-mumps: ${{ matrix.USE_MUMPS }} run-unit-test: needs: install-and-build runs-on: ubuntu-latest + strategy: + matrix: + USE_MUMPS: [false, true] container: image: ghcr.io/gyselax/gyselalibxx_env:latest options: --user root @@ -31,6 +40,7 @@ jobs: - uses: ./.github/actions/test with: build-artifact: build-cpp-linux-gmgpolar + use-mumps: ${{ matrix.USE_MUMPS }} codecov: if: github.event.pull_request.draft == false @@ -42,9 +52,15 @@ jobs: uses: actions/download-artifact@v4 with: name: test-coverage-reports + path: coverage + - name: Download mumps cpp coverage report + uses: actions/download-artifact@v4 + with: + name: test-coverage-reports-mumps + path: coverage-mumps - name: Deploy to codecov.io uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} - files: coverage-filtered.info + files: coverage/coverage-filtered.info,coverage-mumps/coverage-filtered.info verbose: true diff --git a/CMakeLists.txt b/CMakeLists.txt index 4670da20..47cad7d8 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,4 @@ cmake_minimum_required(VERSION 3.12) -project(GMGPolar VERSION 2.0.0 LANGUAGES CXX) # Options should be defined before they're used option(GMGPOLAR_BUILD_TESTS "Build GMGPolar unit tests." ON) @@ -7,6 +6,13 @@ option(GMGPOLAR_USE_LIKWID "Use LIKWID to measure code (regions)." OFF) option(GMGPOLAR_USE_MUMPS "Use MUMPS to solve linear systems." OFF) option(GMGPOLAR_ENABLE_COVERAGE "Enable code coverage reporting (requires GCC/Clang)" OFF) +if (${GMGPOLAR_USE_MUMPS}) + # MUMPS does not automatically provide Fortran libraries + project(GMGPolar VERSION 2.0.0 LANGUAGES CXX Fortran) +else() + project(GMGPolar VERSION 2.0.0 LANGUAGES CXX) +endif() + set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED True) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index db892c3c..3cf596c1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -192,17 +192,39 @@ endif() # Handle MUMPS configuration if(GMGPOLAR_USE_MUMPS) - if(DEFINED ENV{MUMPS_DIR}) + find_package(MUMPS COMPONENTS OpenMP METIS) + if (${MUMPS_FOUND}) + target_link_libraries(GMGPolarLib PUBLIC MUMPS::MUMPS) + target_compile_definitions(GMGPolarLib PUBLIC GMGPOLAR_USE_MUMPS) + elseif(DEFINED ENV{MUMPS_DIR}) set(MUMPS_DIR $ENV{MUMPS_DIR}) - + if(EXISTS "${MUMPS_DIR}/include" AND EXISTS "${MUMPS_DIR}/lib") set(MUMPS_INCLUDE_DIR "${MUMPS_DIR}/include") set(MUMPS_LIBRARY_DIR "${MUMPS_DIR}/lib") - + target_include_directories(GMGPolarLib PUBLIC ${MUMPS_INCLUDE_DIR}) target_link_directories(GMGPolarLib PUBLIC ${MUMPS_LIBRARY_DIR}) + + if (EXISTS "${MUMPS_DIR}/libseq") + target_include_directories(GMGPolarLib PUBLIC "${MUMPS_DIR}/libseq") + target_link_directories(GMGPolarLib PUBLIC "${MUMPS_DIR}/libseq") + endif() + set(MUMPS_FOUND TRUE) endif() + + if(MUMPS_FOUND) + target_link_libraries(GMGPolarLib PUBLIC + mumps_common + smumps + dmumps + mpiseq + ) + target_compile_definitions(GMGPolarLib PUBLIC GMGPOLAR_USE_MUMPS) + else() + message(SEND_ERROR "MUMPS not found") + endif() endif() if(DEFINED ENV{METIS_DIR}) @@ -211,25 +233,17 @@ if(GMGPOLAR_USE_MUMPS) if(EXISTS "${METIS_DIR}/include" AND EXISTS "${METIS_DIR}/lib") set(METIS_INCLUDE_DIR "${METIS_DIR}/include") set(METIS_LIBRARY_DIR "${METIS_DIR}/lib") - + target_include_directories(GMGPolarLib PUBLIC ${METIS_INCLUDE_DIR}) target_link_directories(GMGPolarLib PUBLIC ${METIS_LIBRARY_DIR}) set(METIS_FOUND TRUE) endif() - endif() - - if(MUMPS_FOUND) - target_link_libraries(GMGPolarLib PUBLIC - mumps_common - smumps - dmumps - mpiseq - ) - target_compile_definitions(GMGPolarLib PUBLIC GMGPOLAR_USE_MUMPS) - endif() - if(METIS_FOUND) - target_link_libraries(GMGPolarLib PUBLIC metis) + if(METIS_FOUND) + target_link_libraries(GMGPolarLib PUBLIC metis) + else() + message(SEND_ERROR "METIS not found") + endif() endif() endif()