From 333d0715de1ae010654d8a441d851b081f8bf4a3 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Wed, 10 Apr 2024 16:34:55 -0600 Subject: [PATCH 1/2] cmake: add CMake language support for CUDA/HIP --- CMakeLists.txt | 3 +++ cmake/kokkoskernels_tribits.cmake | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c02d71c49..3217ef2aa9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,6 +127,9 @@ ELSE() IF (NOT KOKKOSKERNELS_HAS_TRILINOS AND NOT KOKKOSKERNELS_HAS_PARENT) # This is a standalone build FIND_PACKAGE(Kokkos REQUIRED) + IF(Kokkos_COMPILE_LANGUAGE) + ENABLE_LANGUAGE(${Kokkos_COMPILE_LANGUAGE}) + ENDIF() IF(${Kokkos_VERSION} VERSION_GREATER_EQUAL "4.2.00") MESSAGE(STATUS "Found Kokkos version ${Kokkos_VERSION} at ${Kokkos_DIR}") IF((${Kokkos_VERSION} VERSION_GREATER "4.3.99")) diff --git a/cmake/kokkoskernels_tribits.cmake b/cmake/kokkoskernels_tribits.cmake index 2d70f656ad..e47e201161 100644 --- a/cmake/kokkoskernels_tribits.cmake +++ b/cmake/kokkoskernels_tribits.cmake @@ -85,6 +85,11 @@ ENDIF() IF(PARSE_SOURCES) LIST(REMOVE_DUPLICATES PARSE_SOURCES) ENDIF() +IF(Kokkos_COMPILE_LANGUAGE) + FOREACH(source ${PARSE_SOURCES}) + SET_SOURCE_FILES_PROPERTIES(${source} PROPERTIES LANGUAGE ${Kokkos_COMPILE_LANGUAGE}) + ENDFOREACH() +ENDIF() ADD_LIBRARY( ${LIBRARY_NAME} From 6fc03a8f2d64f8716aae6ee891e4a03d95b97b09 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Tue, 30 Jul 2024 20:19:22 -0600 Subject: [PATCH 2/2] Apply suggestions of @brian-kelley --- CMakeLists.txt | 6 ++++++ cmake/kokkoskernels_tribits.cmake | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3217ef2aa9..d8cdd203f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -129,6 +129,12 @@ ELSE() FIND_PACKAGE(Kokkos REQUIRED) IF(Kokkos_COMPILE_LANGUAGE) ENABLE_LANGUAGE(${Kokkos_COMPILE_LANGUAGE}) + IF(Kokkos_COMPILE_LANGUAGE STREQUAL CUDA) + SET(CMAKE_CUDA_ARCHITECTURES ${Kokkos_CUDA_ARCHITECTURES}) + ENDIF() + IF(Kokkos_COMPILE_LANGUAGE STREQUAL HIP) + SET(CMAKE_HIP_ARCHITECTURES ${Kokkos_HIP_ARCHITECTURES}) + ENDIF() ENDIF() IF(${Kokkos_VERSION} VERSION_GREATER_EQUAL "4.2.00") MESSAGE(STATUS "Found Kokkos version ${Kokkos_VERSION} at ${Kokkos_DIR}") diff --git a/cmake/kokkoskernels_tribits.cmake b/cmake/kokkoskernels_tribits.cmake index e47e201161..f7d11c9ef1 100644 --- a/cmake/kokkoskernels_tribits.cmake +++ b/cmake/kokkoskernels_tribits.cmake @@ -156,6 +156,12 @@ IF (IS_ENABLED) SOURCES ${PARSE_SOURCES} TESTONLYLIBS ${PARSE_TESTONLYLIBS}) ELSE() + # Set the correct CMake language on all source files for this exe + IF(Kokkos_COMPILE_LANGUAGE) + FOREACH(source ${PARSE_SOURCES}) + SET_SOURCE_FILES_PROPERTIES(${source} PROPERTIES LANGUAGE ${Kokkos_COMPILE_LANGUAGE}) + ENDFOREACH() + ENDIF() ADD_EXECUTABLE(${EXE_NAME} ${PARSE_SOURCES}) #AJP, BMK altered: IF(KOKKOSKERNELS_ENABLE_TESTS_AND_PERFSUITE)