Skip to content

Commit

Permalink
Mini update of cmake macro to detect kokkos.
Browse files Browse the repository at this point in the history
  • Loading branch information
pkestene committed Feb 18, 2024
1 parent fbf0f3a commit 2c84d86
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions cmake/build_or_find_kokkos.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ set(PPKMHD_BACKEND "Undefined" CACHE STRING
set_property(CACHE PPKMHD_BACKEND PROPERTY STRINGS
"OpenMP" "Cuda" "HIP" "Undefined")


# raise the minimum C++ standard level if not already done
# when build kokkos, it defaults to c++-17
# when using installed kokkos, it is not set, so defaulting to c++-17
# kokkos 4.0.00 requires c++-17 anyway
if (NOT "${CMAKE_CXX_STANDARD}")
set(CMAKE_CXX_STANDARD 17)
endif()

# check if user requested a build of kokkos
if(PPKMHD_BUILD_KOKKOS)

Expand Down Expand Up @@ -105,11 +114,12 @@ if(PPKMHD_BUILD_KOKKOS)
if (PPKMHD_USE_GIT_KOKKOS)
FetchContent_Declare( kokkos_external
GIT_REPOSITORY https://github.com/kokkos/kokkos.git
GIT_TAG 4.0.00
GIT_TAG 4.2.00
)
else()
FetchContent_Declare( kokkos_external
URL https://github.com/kokkos/kokkos/archive/refs/tags/4.0.00.tar.gz
#URL https://github.com/kokkos/kokkos/archive/refs/tags/4.2.00.tar.gz
SOURCE_DIR ${PROJECT_SOURCE_DIR}/external/kokkos
)
endif()

Expand All @@ -131,19 +141,10 @@ else()
#
# check if an already installed kokkos exists
#
find_package(Kokkos 3.7.00 REQUIRED)
find_package(Kokkos 4.0.00 CONFIG REQUIRED)

if(TARGET Kokkos::kokkos)

# set default c++ standard according to Kokkos version
# Kokkos >= 4.0.00 requires c++-17
if (NOT "${CMAKE_CXX_STANDARD}")
if ( ${Kokkos_VERSION} VERSION_LESS 4.0.00)
set(CMAKE_CXX_STANDARD 14)
else()
set(CMAKE_CXX_STANDARD 17)
endif()
endif()

# kokkos_check is defined in KokkosConfigCommon.cmake
kokkos_check( DEVICES "OpenMP" RETURN_VALUE KOKKOS_DEVICE_ENABLE_OPENMP)
Expand All @@ -169,7 +170,7 @@ else()

else()

message(FATAL_ERROR "[ppkmhd / kokkos] Kokkos is required but not found by find_package. Please adjet your env variable CMAKE_PREFIX_PATH (or Kokkos_ROOT) to where Kokkos is installed on your machine !")
message(FATAL_ERROR "[ppkmhd / kokkos] Kokkos is required but not found by find_package. Please adjust your env variable CMAKE_PREFIX_PATH (or Kokkos_ROOT) to where Kokkos is installed on your machine !")

endif()

Expand Down

0 comments on commit 2c84d86

Please sign in to comment.