-
Notifications
You must be signed in to change notification settings - Fork 67
Enable using Kokkos with CUDA backend for MIRCO and in general #2012
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
d15acc8
701569c
b261b1c
3011610
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| name: Trilinos with shared memory parallelism enabled through OpenMP and CUDA backends (through Kokkos) | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| schedule: | ||
| - cron: '0 8 * * 6' | ||
|
|
||
| env: | ||
| IMAGE_NAME: ghcr.io/4c-multiphysics/4c-dependencies-trilinos | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| build-and-push-trilinos-image: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| attestations: write | ||
| id-token: write | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
| - name: Log in to the Container registry | ||
| uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Extract metadata (tags, labels) for Docker | ||
| id: meta | ||
| uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0 | ||
| with: | ||
| images: ${{ env.IMAGE_NAME }} | ||
| labels: | | ||
| org.opencontainers.image.description=Image containing all the dependencies required for building and testing 4C based on the specified Trilinos commit ref | ||
| - name: Build and push Docker image | ||
| id: push | ||
| uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0 | ||
| with: | ||
| context: . | ||
| file: docker/trilinos_kokkosparallel/Dockerfile | ||
| push: true | ||
| tags: ${{ env.IMAGE_NAME }}:kokkosparallel | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
|
|
||
| build_kokkoscuda: | ||
| needs: build-and-push-trilinos-image | ||
| runs-on: ubuntu-latest | ||
| container: | ||
| image: ghcr.io/4c-multiphysics/4c-dependencies-trilinos:kokkosparallel | ||
| options: --user root --env OMPI_ALLOW_RUN_AS_ROOT=1 --env OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 | ||
| defaults: | ||
| run: | ||
| shell: bash | ||
| env: | ||
| OMPI_CXX: ${{ github.workspace }}/utilities/clangcuda++ | ||
| OMPI_CC: /usr/bin/clang | ||
| CLANGCUDA_CLANG_PATH: /usr/bin/clang++ | ||
| CLANGCUDA_CUDA_PATH: /usr/local/cuda | ||
| CLANGCUDA_ARCH: sm_90 | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: ./.github/actions/build_4C | ||
| with: | ||
| cmake-preset: docker_kokkoscuda_clangcuda | ||
| build-targets: full | ||
| build-directory: ${{ github.workspace }}/build | ||
| use-ccache: "false" | ||
|
|
||
| build_kokkosopenmp: | ||
| needs: build-and-push-trilinos-image | ||
| runs-on: ubuntu-latest | ||
| container: | ||
| image: ghcr.io/4c-multiphysics/4c-dependencies-trilinos:kokkosparallel | ||
| options: --user root --env OMPI_ALLOW_RUN_AS_ROOT=1 --env OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 | ||
| defaults: | ||
| run: | ||
| shell: bash | ||
| outputs: | ||
| test-chunks: ${{ steps.set-matrix.outputs.chunk-array }} | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: ./.github/actions/build_4C | ||
| with: | ||
| cmake-preset: docker_kokkosopenmp | ||
| build-targets: full | ||
| build-directory: ${{ github.workspace }}/build | ||
| use-ccache: "false" | ||
| - uses: ./.github/actions/upload_directory | ||
| with: | ||
| directory: ${{ github.workspace }}/build | ||
| retention-days: 1 | ||
| name: trilinos_kokkosopenmp_build | ||
| - uses: ./.github/actions/chunk_test_suite | ||
| id: set-matrix | ||
| with: | ||
| build-directory: ${{ github.workspace }}/build | ||
| source-directory: ${{ github.workspace }} | ||
| number-of-chunks: 15 | ||
| junit-report-artifact-name: trilinos_test_report.xml | ||
|
|
||
| test_openmp: | ||
| needs: build_kokkosopenmp | ||
| runs-on: ubuntu-latest | ||
| container: | ||
| image: ghcr.io/4c-multiphysics/4c-dependencies-trilinos:kokkosparallel | ||
| options: --user root --env OMPI_ALLOW_RUN_AS_ROOT=1 --env OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| test-chunk: ${{fromJson(needs.build_kokkosopenmp.outputs.test-chunks)}} | ||
| defaults: | ||
| run: | ||
| shell: bash | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - name: Setup developer environment for testing | ||
| run: | | ||
| cd $GITHUB_WORKSPACE | ||
| git config --global --add safe.directory $GITHUB_WORKSPACE | ||
| - uses: ./.github/actions/download_directory | ||
| with: | ||
| name: trilinos_kokkosopenmp_build | ||
| destination: ${{ github.workspace }}/build | ||
| - name: Test | ||
| run: | | ||
| cd $GITHUB_WORKSPACE/build | ||
| ctest -I $TEST_CHUNK -j `nproc` --output-on-failure --output-junit $GITHUB_WORKSPACE/trilinos_test_report-$TEST_CHUNK.xml | ||
| env: | ||
| TEST_CHUNK: ${{ matrix.test-chunk }} | ||
| - name: Upload test report | ||
| if: success() || failure() | ||
| uses: actions/upload-artifact@v7 | ||
| with: | ||
| name: trilinos_test_report-${{ matrix.test-chunk }}.xml | ||
| path: | | ||
| ${{ github.workspace }}/trilinos_test_report-${{ matrix.test-chunk }}.xml | ||
| retention-days: 1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,6 +71,24 @@ find_package(Trilinos REQUIRED) | |
| message(STATUS "Trilinos version: ${Trilinos_VERSION}") | ||
| message(STATUS "Trilinos packages: ${Trilinos_PACKAGE_LIST}") | ||
|
|
||
| if(FOUR_C_CLANGCUDA) | ||
| set(CMAKE_CXX_COMPILER_LAUNCHER | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please do not silently mess with these global user-defined variables. What you should do instead is report a combination of variables that is impossible with a clear error. So I would check that all these variables are indeed empty in the case of |
||
| "" | ||
| CACHE STRING "" FORCE | ||
| ) | ||
| set(CMAKE_C_COMPILER_LAUNCHER | ||
| "" | ||
| CACHE STRING "" FORCE | ||
| ) | ||
| set(CMAKE_CUDA_COMPILER_LAUNCHER | ||
| "" | ||
| CACHE STRING "" FORCE | ||
| ) | ||
|
|
||
| set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "") | ||
| set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "") | ||
| endif() | ||
|
|
||
| # Figure out the version. | ||
| if(EXISTS "${Trilinos_DIR}/../../../TrilinosRepoVersion.txt") | ||
| file(STRINGS "${Trilinos_DIR}/../../../TrilinosRepoVersion.txt" TrilinosRepoVersionFile) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,18 @@ function(four_c_auto_define_module) | |
| # them on other users of the library. | ||
| target_link_libraries(${_target}_objs PRIVATE four_c_private_compile_interface) | ||
|
|
||
| if(FOUR_C_CLANGCUDA) | ||
| set_target_properties( | ||
| ${_target}_objs | ||
| PROPERTIES CXX_COMPILER_LAUNCHER "" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure, but this seems duplicated with the global var checks in configure_Trilinos. |
||
| C_COMPILER_LAUNCHER "" | ||
| CUDA_COMPILER_LAUNCHER "" | ||
| RULE_LAUNCH_COMPILE "" | ||
| RULE_LAUNCH_LINK "" | ||
| ) | ||
| target_compile_definitions(${_target}_objs PRIVATE CLANGCUDA_MODE_HOST) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it might be better to add this to our |
||
| endif() | ||
|
|
||
| if(FOUR_C_ENABLE_IWYU) | ||
| set_target_properties( | ||
| ${_target}_objs PROPERTIES CXX_INCLUDE_WHAT_YOU_USE ${FOUR_C_IWYU_EXECUTABLE} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -235,6 +235,20 @@ four_c_process_global_option( | |
| OFF | ||
| ) | ||
|
|
||
| four_c_process_global_option( | ||
| FOUR_C_CLANGCUDA | ||
| DESCRIPTION | ||
| "Enable the relevant CMake compile definitions needed to use utilities/clangcuda++ as the compiler. This is currently necessary to use the CUDA backend of Kokkos in 4C, e.g. along with MIRCO." | ||
| DEFAULT | ||
| OFF | ||
| ) | ||
| if(FOUR_C_CLANGCUDA AND FOUR_C_WITH_ARBORX) | ||
| message( | ||
| WARNING | ||
| "Enabling both FOUR_C_CLANGCUDA and FOUR_C_WITH_ARBORX is not advised. This requires using an external CUDA-enabled ArborX installation and has not been tested." | ||
| ) | ||
| endif() | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move the check for FOUR_C_CUDACLANG here please (and add the flags to four_c_private_compile_interface here). |
||
| ## | ||
| # Optimization flags | ||
| # These flags are reasonable defaults. Users may amend them by setting FOUR_C_CXX_FLAGS and/or FOUR_C_CXX_FLAGS_<CONFIG>. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be obsolete if you use four_c_private_compile_interface