Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 141 additions & 0 deletions .github/workflows/trilinos-kokkosparallel.yml
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
12 changes: 11 additions & 1 deletion apps/global_full/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,17 @@ set_target_properties(
${FOUR_C_EXECUTABLE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}
)
four_c_set_up_executable(${FOUR_C_EXECUTABLE_NAME})

if(FOUR_C_CLANGCUDA)

Copy link
Copy Markdown
Member

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

set_target_properties(
${FOUR_C_EXECUTABLE_NAME}
PROPERTIES CXX_COMPILER_LAUNCHER ""
C_COMPILER_LAUNCHER ""
CUDA_COMPILER_LAUNCHER ""
RULE_LAUNCH_COMPILE ""
RULE_LAUNCH_LINK ""
)
target_compile_definitions(${FOUR_C_EXECUTABLE_NAME} PRIVATE CLANGCUDA_MODE_HOST)
endif()
if(FOUR_C_ENABLE_METADATA_GENERATION)
if(FOUR_C_WITH_PYTHON)
add_custom_command(
Expand Down
23 changes: 17 additions & 6 deletions cmake/configure/configure_MIRCO.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ four_c_process_global_option(
OFF
)
if(FOUR_C_MIRCO_FIND_INSTALLED)

# Note that MIRCO and 4C must point to the same Kokkos and Kokkos-Kernels installation. Otherwise, there will be errors.
message(STATUS "FOUR_C_MIRCO_FIND_INSTALLED is enabled")

# MIRCO provides a package configuration file if installed.
Expand All @@ -27,13 +27,24 @@ if(FOUR_C_MIRCO_FIND_INSTALLED)
endif()

else() # Fetch MIRCO from GIT repository
# Turn off googletest and Trilinos in MIRCO so that they don't interfere with 4C
# Turn off googletest in MIRCO so that it does not interfere with 4C.
set(GTEST_IN_MIRCO "OFF")
set(TRILINOS_IN_MIRCO "OFF")
# Explicitly turn off `*_IN_MIRCO`, so that MIRCO uses upstream targets
set(RYML_IN_MIRCO "OFF")
set(KOKKOS_IN_MIRCO "OFF")
set(KOKKOS_KERNELS_IN_MIRCO "OFF")

# Propagate
if(FOUR_C_CLANGCUDA)
set(MIRCO_CLANGCUDA "ON")
else()
set(MIRCO_CLANGCUDA "OFF")
endif()

set(MIRCO_GIT_REPO "https://github.com/imcs-compsim/MIRCO.git")
set(MIRCO_GIT_TAG "b9d0c4ba27ff8463a3d2b17163fead8800b2650c") # latest hash 03.04.2026
set(MIRCO_GIT_TAG "8b049a6462eba5809d7cffe039a77f3bc5593767") # latest hash 02.06.2026

set(FETCHCONTENT_TRY_FIND_PACKAGE_MODE NEVER)
fetchcontent_declare(
mirco
GIT_REPOSITORY ${MIRCO_GIT_REPO}
Expand All @@ -42,8 +53,8 @@ else() # Fetch MIRCO from GIT repository
fetchcontent_makeavailable(mirco)
# MIRCO requires a specific path, possibly due to inconsistent naming "mirco" vs "mirco_lib".
set(FOUR_C_MIRCO_ROOT "${CMAKE_INSTALL_PREFIX}/lib/cmake/mirco")

four_c_add_external_dependency(four_c_all_enabled_external_dependencies mirco::mirco_lib)
endif()

four_c_add_external_dependency(four_c_all_enabled_external_dependencies mirco::mirco_lib)

four_c_remember_variable_for_install(FOUR_C_MIRCO_ROOT)
18 changes: 18 additions & 0 deletions cmake/configure/configure_Trilinos.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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 FOUR_C_CLANGCUDA and otherwise abort.

""
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)
Expand Down
12 changes: 12 additions & 0 deletions cmake/functions/four_c_auto_define_module.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be better to add this to our four_c_private_compile_interface which is used for everything we build.

endif()

if(FOUR_C_ENABLE_IWYU)
set_target_properties(
${_target}_objs PROPERTIES CXX_INCLUDE_WHAT_YOU_USE ${FOUR_C_IWYU_EXECUTABLE}
Expand Down
14 changes: 14 additions & 0 deletions cmake/setup_global_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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>.
Expand Down
Loading
Loading