[cmake] Add cmake module for finding the cusolver library

This commit is contained in:
Taillefumier Mathieu 2023-08-30 10:59:06 +02:00 committed by GitHub
parent 26828f2f1c
commit 6aa93c4aec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 77 additions and 2 deletions

View file

@ -527,6 +527,10 @@ if(CP2K_USE_ACCEL MATCHES "CUDA")
endif()
set(CP2K_USE_CUDA ON)
if(CP2K_USE_CUSOLVER_MP)
find_package(CuSolverMP REQUIRED)
endif()
message(STATUS ``"-- CUDA compiler and libraries found")
elseif(CP2K_USE_ACCEL MATCHES "HIP")
enable_language(HIP)

33
cmake/FindCal.cmake Normal file
View file

@ -0,0 +1,33 @@
#!-------------------------------------------------------------------------------------------------!
#! CP2K: A general program to perform molecular dynamics simulations !
#! Copyright 2000-2023 CP2K developers group <https://cp2k.org> !
#! !
#! SPDX-License-Identifier: GPL-2.0-or-later !
#!-------------------------------------------------------------------------------------------------!
# Copyright (c) 2022- ETH Zurich
#
# authors : Mathieu Taillefumier
include(FindPackageHandleStandardArgs)
include(cp2k_utils)
cp2k_set_default_paths(LIBCAL "Cal")
cp2k_find_libraries(LIBCAL "cal")
cp2k_include_dirs(LIBCAL "cal.h")
find_package_handle_standard_args(Cal DEFAULT_MSG CP2K_CAL_LINK_LIBRARIES
CP2K_CAL_INCLUDE_DIRS)
if(CP2K_LIBCAL_FOUND AND not TARGET CP2K::CAL::cal)
add_library(CP2K::CAL INTERFACE IMPORTED)
set_target_properties(CP2K::CAL::cal PROPERTIES INTERFACE_LINK_LIBRARIES
"${CP2K_CAL_LINK_LIBRARIES}")
set_target_properties(CP2K::CAL::cal PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"${CP2K_CAL_INCLUDE_DIRS}")
endif()
mark_as_advanced(CP2K_CAL_LINK_LIBRARIES)
mark_as_advanced(CP2K_CAL_INCLUDE_DIRS)
mark_as_advanced(CP2K_CAL_FOUND)

View file

@ -0,0 +1,37 @@
#!-------------------------------------------------------------------------------------------------!
#! CP2K: A general program to perform molecular dynamics simulations !
#! Copyright 2000-2023 CP2K developers group <https://cp2k.org> !
#! !
#! SPDX-License-Identifier: GPL-2.0-or-later !
#!-------------------------------------------------------------------------------------------------!
# Copyright (c) 2022- ETH Zurich
#
# authors : Mathieu Taillefumier
include(FindPackageHandleStandardArgs)
include(cp2k_utils)
find_package(Cal Required)
cp2k_set_default_paths(CUSOLVER_MP "CUSOLVER_MP")
cp2k_find_libraries(CUSOLVER_MP "cusolverMp")
cp2k_include_dirs(CUSOLVER_MP "cusolverMp.h")
find_package_handle_standard_args(
CuSolverMP DEFAULT_MSG CP2K_CUSOLVER_MP_LINK_LIBRARIES
CP2K_CUSOLVER_MP_INCLUDE_DIRS)
if(CP2K_CUSOLVER_MP_FOUND AND NOT TARGET CP2K::CUSOLVER_MP::cusolver_mp)
add_library(CP2K::CUSOLVER_MP::cusolver_mp INTERFACE IMPORTED)
set_target_properties(
CP2K::CUSOLVER_MP::cusolver_mp
PROPERTIES INTERFACE_LINK_LIBRARIES
"${CP2K_CUSOLVER_MP_LINK_LIBRARIES};CP2K::CAL::cal")
set_target_properties(
CP2K::CUSOLVER_MP::cusolver_mp
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CP2K_CUSOLVER_MP_INCLUDE_DIRS}")
endif()
mark_as_advanced(CP2K_CUSOLVER_MP_LINK_LIBRARIES)
mark_as_advanced(CP2K_CUSOLVER_MP_INCLUDE_DIRS)
mark_as_advanced(CP2K_CUSOLVER_MP_FOUND)

View file

@ -1433,8 +1433,9 @@ if(CP2K_USE_CUDA)
else()
target_link_libraries(
cp2k_cuda_libs
INTERFACE $<$<BOOL:${CP2K_USE_CUSOLVER_MP}>:CUDA::cusolver> CUDA::cufft
CUDA::cufftw CUDA::cublas CUDA::cudart CUDA::cuda_driver)
INTERFACE $<$<BOOL:${CP2K_USE_CUSOLVER_MP}>:CP2K::CUSOLVER_MP::cusolvermp>
CUDA::cufft CUDA::cufftw CUDA::cublas CUDA::cudart
CUDA::cuda_driver)
endif()
endif()