Skip to content

Commit

Permalink
cmake: add CMake language support for CUDA/HIP (#2173)
Browse files Browse the repository at this point in the history
* cmake: add CMake language support for CUDA/HIP

* Apply suggestions of @brian-kelley
  • Loading branch information
rbberger authored Aug 1, 2024
1 parent a231875 commit 3d5e57a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ 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})
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}")
IF((${Kokkos_VERSION} VERSION_GREATER "4.3.99"))
Expand Down
11 changes: 11 additions & 0 deletions cmake/kokkoskernels_tribits.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -151,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)
Expand Down

0 comments on commit 3d5e57a

Please sign in to comment.