diff --git a/CMakeLists.txt b/CMakeLists.txt index 7cf92be13979d34df4f29848627fd742d01d0786..affedaadb61836d16d36237fb041e90fa14e95f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,7 @@ option(IM_USE_CPP_BINDINGS "Use C++ bindings" OFF) option(IM_ENABLE_DIM_SWAP "Enable dimension swap" OFF) option(IM_ENABLE_OPENACC "Enable OpenACC support" OFF) option(IM_ENABLE_OPENMP "Enable OpenMP support" OFF) +set(IM_ENABLE_GPU OFF CACHE STRING "Enable Kokkos GPU support for arch. Valid values: OFF, nvidia-sm80") # GNUInstallDirs issues a warning if CMAKE_SIZEOF_VOID_P is not defined, which # is the case with NAG. One way to circumvent that is to enable C language for @@ -124,6 +125,16 @@ set(Kokkos_ENABLE_IMPL_MDSPAN OFF CACHE BOOL "Experimental mdspan support") set(Kokkos_ENABLE_SERIAL ON CACHE BOOL "Kokkos Serial backend") set(Kokkos_ARCH_NATIVE ON CACHE BOOL "Kokkos native architecture optimisations") +if ("${IM_ENABLE_GPU}" STREQUAL "nvidia-sm80") + # NVIDIA A100 + set(Kokkos_ENABLE_CUDA ON CACHE BOOL "Kokkos CUDA backend") + set(Kokkos_ARCH_AMPERE80 ON CACHE BOOL "CUDA architecture: Ampere cc80") +endif() + +if (${IM_ENABLE_OPENMP}) + set(Kokkos_ENABLE_OPENMP ON CACHE BOOL "Kokkos OpenMP backend") +endif() + FetchContent_MakeAvailable(kokkos) add_subdirectory(src) diff --git a/src/horizontal/CMakeLists.txt b/src/horizontal/CMakeLists.txt index 6cebed9f3630b610fa123802cd2fb85500e07862..d2abe7de8470c35f06f52bc606addebda117c1dd 100644 --- a/src/horizontal/CMakeLists.txt +++ b/src/horizontal/CMakeLists.txt @@ -66,7 +66,8 @@ target_include_directories( target_link_libraries(iconmath-horizontal PUBLIC fortran-support::fortran-support) target_link_libraries(iconmath-horizontal PUBLIC iconmath-support) target_link_libraries(iconmath-horizontal PUBLIC iconmath-interpolation) -target_link_libraries(iconmath-interpolation PRIVATE Kokkos::kokkos) +target_link_libraries(iconmath-horizontal PRIVATE Kokkos::kokkos) +set_target_properties(iconmath-horizontal PROPERTIES LINKER_LANGUAGE Fortran) install(TARGETS iconmath-horizontal EXPORT "${PROJECT_NAME}-targets") diff --git a/src/interpolation/CMakeLists.txt b/src/interpolation/CMakeLists.txt index 9455f9ec92a36507515fe334673f6e405b1ae9de..346aaaae748d8b887da284ad93e5e6eae621bf05 100644 --- a/src/interpolation/CMakeLists.txt +++ b/src/interpolation/CMakeLists.txt @@ -70,6 +70,7 @@ target_include_directories( target_link_libraries(iconmath-interpolation PUBLIC fortran-support::fortran-support) target_link_libraries(iconmath-interpolation PUBLIC iconmath-support) target_link_libraries(iconmath-interpolation PRIVATE Kokkos::kokkos) +set_target_properties(iconmath-interpolation PROPERTIES LINKER_LANGUAGE Fortran) install(TARGETS iconmath-interpolation EXPORT "${PROJECT_NAME}-targets") diff --git a/src/support/CMakeLists.txt b/src/support/CMakeLists.txt index 9f56017022c391e95381da1ee3edb8eea65e0a0d..ed6a4d333a206cb3436ab800e6cda24b7d68bd43 100644 --- a/src/support/CMakeLists.txt +++ b/src/support/CMakeLists.txt @@ -80,6 +80,7 @@ target_link_libraries(iconmath-support PRIVATE Kokkos::kokkos ) +set_target_properties(iconmath-support PROPERTIES LINKER_LANGUAGE Fortran) install(TARGETS iconmath-support EXPORT "${PROJECT_NAME}-targets")