mirror of
https://github.com/cp2k/cp2k.git
synced 2026-07-21 14:35:15 -04:00
CMake: Add support for cuSOLVERMp
This commit is contained in:
parent
52376581b9
commit
7b9fbda797
6 changed files with 98 additions and 15 deletions
|
|
@ -514,7 +514,9 @@ endif()
|
|||
set(CP2K_USE_HIP OFF)
|
||||
set(CP2K_USE_CUDA OFF)
|
||||
|
||||
option(CP2K_USE_PW_GPU "Enable GPU in CUDA" OFF)
|
||||
if(CP2K_USE_ACCEL MATCHES "CUDA")
|
||||
option(CP2K_WITH_CUDA_PROFILING "Enable CUDA profiling" OFF)
|
||||
# P100 is the default target.
|
||||
set(CMAKE_CUDA_ARCHITECTURES 60)
|
||||
|
||||
|
|
@ -539,10 +541,10 @@ if(CP2K_USE_ACCEL MATCHES "CUDA")
|
|||
endif()
|
||||
|
||||
set(CMAKE_CUDA_ARCHITECTURES ${CP2K_GPU_ARCH_NUMBER_${CP2K_WITH_GPU}})
|
||||
|
||||
message(STATUS "GPU target architecture: ${CP2K_WITH_GPU}\n"
|
||||
"GPU architecture number: ${CMAKE_CUDA_ARCHITECTURES}\n"
|
||||
"GPU profiling enabled: ${CP2K_WITH_CUDA_PROFILING}\n")
|
||||
set(CP2K_ACC_ARCH_NUMBER ${CMAKE_CUDA_ARCHITECTURES})
|
||||
|
||||
if(WITH_CUDA_PROFILING)
|
||||
find_library(
|
||||
|
|
@ -554,11 +556,13 @@ if(CP2K_USE_ACCEL MATCHES "CUDA")
|
|||
endif()
|
||||
|
||||
set(CP2K_USE_CUDA ON)
|
||||
set(CP2K_USE_PW_GPU 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)
|
||||
# Find hip
|
||||
|
|
@ -577,7 +581,9 @@ elseif(CP2K_USE_ACCEL MATCHES "HIP")
|
|||
endif()
|
||||
|
||||
set(CMAKE_HIP_ARCHITECTURES "${CP2K_GPU_ARCH_NUMBER_${CP2K_WITH_GPU}}")
|
||||
set(CP2K_ACC_ARCH_NUMBER ${CP2K_GPU_ARCH_NUMBER_${CP2K_WITH_GPU}})
|
||||
set(CP2K_USE_HIP ON)
|
||||
set(CP2K_USE_PW_GPU ON)
|
||||
|
||||
# use hardware atomic operations on Mi250X.
|
||||
if(CMAKE_HIP_ARCGITECTURES MATCHES "gfx90a|gfx942")
|
||||
|
|
@ -813,7 +819,7 @@ if((CP2K_USE_ACCEL MATCHES "CUDA") OR (CP2K_USE_ACCEL MATCHES "HIP"))
|
|||
if(CP2K_USE_ACCEL MATCHES "CUDA")
|
||||
message(
|
||||
" - CUDA:\n" " - GPU target architecture : ${CP2K_WITH_GPU}\n"
|
||||
" - GPU architecture number : ${CP2K_ACC_ARCH_NUMBER}"
|
||||
" - GPU architecture number : ${CP2K_ACC_ARCH_NUMBER}\n"
|
||||
" - GPU profiling enabled : ${CP2K_WITH_CUDA_PROFILING}\n\n")
|
||||
endif()
|
||||
|
||||
|
|
@ -824,9 +830,20 @@ if((CP2K_USE_ACCEL MATCHES "CUDA") OR (CP2K_USE_ACCEL MATCHES "HIP"))
|
|||
|
||||
message(
|
||||
"Note : Enabling hardware acceleration enable acceleration of the grid, pw, and dbm modules by default\n"
|
||||
" - GRID module : ${CP2K_USE_GRID_GPU}\n"
|
||||
" - PW module : ${CP2K_USE_PW_GPU}\n"
|
||||
" - DBM module : ${CP2K_USE_DBM_GPU}\n\n")
|
||||
"\n")
|
||||
endif()
|
||||
|
||||
if(CP2K_USE_CUSOLVER_MP)
|
||||
message(
|
||||
" - CUSolverMP: \n"
|
||||
" - library: ${CP2K_CUSOLVER_MP_LINK_LIBRARIES} \n"
|
||||
" - include: ${CP2K_CUSOLVER_MP_INCLUDE_DIRS} \n"
|
||||
" - CAL library: ${CP2K_CAL_LINK_LIBRARIES} \n"
|
||||
" - CAL include: ${CP2K_CAL_INCLUDE_DIRS} \n"
|
||||
" - ucc library: ${CP2K_UCC_LINK_LIBRARIES} \n"
|
||||
" - ucx library: ${CP2K_UCX_LINK_LIBRARIES} \n"
|
||||
" - ucc include: ${CP2K_UCC_INCLUDE_DIRS} \n")
|
||||
endif()
|
||||
|
||||
if(CP2K_USE_LIBXC)
|
||||
|
|
|
|||
|
|
@ -12,20 +12,22 @@
|
|||
include(FindPackageHandleStandardArgs)
|
||||
include(cp2k_utils)
|
||||
|
||||
cp2k_set_default_paths(LIBCAL "Cal")
|
||||
cp2k_set_default_paths(CAL "Cal")
|
||||
|
||||
cp2k_find_libraries(LIBCAL "cal")
|
||||
cp2k_include_dirs(LIBCAL "cal.h")
|
||||
cp2k_find_libraries(CAL "cal")
|
||||
cp2k_include_dirs(CAL "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)
|
||||
if(CP2K_CAL_FOUND AND NOT TARGET cp2k::CAL::cal)
|
||||
add_library(cp2k::CAL::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}")
|
||||
else()
|
||||
message(FATAL_ERROR "Cal required by CuSolverMP")
|
||||
endif()
|
||||
|
||||
mark_as_advanced(CP2K_CAL_LINK_LIBRARIES)
|
||||
|
|
|
|||
|
|
@ -12,8 +12,11 @@
|
|||
include(FindPackageHandleStandardArgs)
|
||||
include(cp2k_utils)
|
||||
|
||||
find_package(Cal Required)
|
||||
find_package(ucc REQUIRED)
|
||||
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")
|
||||
|
||||
|
|
@ -25,11 +28,14 @@ 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")
|
||||
PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES
|
||||
"${CP2K_CUSOLVER_MP_LINK_LIBRARIES};cp2k::CAL::cal;cp2k::UCC::ucc")
|
||||
set_target_properties(
|
||||
cp2k::CUSOLVER_MP::cusolver_mp
|
||||
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CP2K_CUSOLVER_MP_INCLUDE_DIRS}")
|
||||
else()
|
||||
message(FATAL_ERROR "CuSolverMP requested, but not found")
|
||||
endif()
|
||||
|
||||
mark_as_advanced(CP2K_CUSOLVER_MP_LINK_LIBRARIES)
|
||||
|
|
|
|||
48
cmake/modules/Finducc.cmake
Normal file
48
cmake/modules/Finducc.cmake
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
#!-------------------------------------------------------------------------------------------------!
|
||||
#! CP2K: A general program to perform molecular dynamics simulations !
|
||||
#! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
|
||||
#! !
|
||||
#! SPDX-License-Identifier: GPL-2.0-or-later !
|
||||
#!-------------------------------------------------------------------------------------------------!
|
||||
|
||||
# authors : JVP find ucc needed CuSolverMP
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
include(cp2k_utils)
|
||||
|
||||
cp2k_set_default_paths(UCC "ucc")
|
||||
|
||||
cp2k_find_libraries(UCC "ucc")
|
||||
cp2k_find_libraries(UCX "ucs")
|
||||
|
||||
if(NOT CP2K_UCC_INCLUDE_DIRS)
|
||||
cp2k_include_dirs(UCC "ucc.h;ucc/api/ucc.h")
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args(
|
||||
ucc DEFAULT_MSG CP2K_UCC_INCLUDE_DIRS CP2K_UCC_LINK_LIBRARIES
|
||||
CP2K_UCX_LINK_LIBRARIES)
|
||||
|
||||
if(CP2K_UCX_FOUND AND NOT TARGET cp2k::UCC::ucx)
|
||||
add_library(cp2k::UCC::ucx INTERFACE IMPORTED)
|
||||
set_target_properties(cp2k::UCC::ucx PROPERTIES INTERFACE_LINK_LIBRARIES
|
||||
"${CP2K_UCX_LINK_LIBRARIES}")
|
||||
else()
|
||||
message(FATAL_ERROR "ucx required by CuSolverMP")
|
||||
endif()
|
||||
|
||||
if(CP2K_UCC_FOUND AND NOT TARGET cp2k::UCC::ucc)
|
||||
add_library(cp2k::UCC::ucc INTERFACE IMPORTED)
|
||||
set_target_properties(
|
||||
cp2k::UCC::ucc PROPERTIES INTERFACE_LINK_LIBRARIES
|
||||
"${CP2K_UCC_LINK_LIBRARIES};cp2k::UCC::ucx")
|
||||
set_target_properties(cp2k::UCC::ucc PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${CP2K_UCC_INCLUDE_DIRS}")
|
||||
else()
|
||||
message(FATAL_ERROR "ucc required by CuSolverMP")
|
||||
endif()
|
||||
|
||||
mark_as_advanced(CP2K_UCX_LINK_LIBRARIES)
|
||||
mark_as_advanced(CP2K_UCC_LINK_LIBRARIES)
|
||||
mark_as_advanced(CP2K_UCC_INCLUDE_DIRS)
|
||||
mark_as_advanced(CP2K_UCC_FOUND)
|
||||
|
|
@ -109,6 +109,16 @@ CP2K is GPU-accelerated. In order to enable GPU acceleration with \[CUDA\] or \[
|
|||
|
||||
The target architecture can be selected with `-DCP2K_WITH_GPU`.
|
||||
|
||||
CUDA can either be build using the NVIDIA HPC package (`-DCP2K_USE_NVHPC=ON`) or the CUDA toolkit
|
||||
package(`-DCP2K_USE_NVHPC=OFF`).
|
||||
|
||||
### cuSOLVERMp
|
||||
|
||||
cuSOLVERMp is activated with `-DCP2K_USE_CUSOLVER_MP=ON` has two dependicies:
|
||||
|
||||
- `CAL`: requires libcal.\* in the Path
|
||||
- `UCC`: requires libucc.\* libucs.\* in the Path
|
||||
|
||||
## Example
|
||||
|
||||
Build CP2K with CUDA acceleration for Nvidia A100 GPUs, with multiple optional dependencies:
|
||||
|
|
|
|||
|
|
@ -1494,9 +1494,9 @@ if(CP2K_USE_CUDA)
|
|||
else()
|
||||
target_link_libraries(
|
||||
cp2k_cuda_libs
|
||||
INTERFACE $<$<BOOL:${CP2K_USE_CUSOLVER_MP}>:cp2k::CUSOLVER_MP::cusolvermp>
|
||||
CUDA::cufft CUDA::cufftw CUDA::cublas CUDA::cudart
|
||||
CUDA::cuda_driver)
|
||||
INTERFACE
|
||||
$<$<BOOL:${CP2K_USE_CUSOLVER_MP}>:cp2k::CUSOLVER_MP::cusolver_mp>
|
||||
CUDA::cufft CUDA::cufftw CUDA::cublas CUDA::cudart CUDA::cuda_driver)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue