Use MKL implementation of fftw3 by default when mkl is found

This commit is contained in:
Taillefumier Mathieu 2023-10-24 20:39:01 +02:00 committed by GitHub
parent 01090ebf07
commit 3302655999
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 32 deletions

View file

@ -114,7 +114,10 @@ option(CP2K_USE_METIS "enable metis library support" OFF)
option(CP2K_USE_LIBXSMM "Use libxsmm for small gemms (supports x86 platforms)"
OFF)
option(BUILD_SHARED_LIBS "Build cp2k shared library" ON)
option(
CP2K_USE_FFTW3_WITH_MKL
"MKL has its own compatible implementation of the fftw. This option when ON will use the original implementation of the fftw library"
OFF)
cmake_dependent_option(CP2K_ENABLE_ELPA_OPENMP_SUPPORT
"Enable elpa openmp support" ON "CP2K_USE_ELPA" OFF)
cmake_dependent_option(CP2K_ENABLE_FFTW3_OPENMP_SUPPORT
@ -577,27 +580,35 @@ endif()
# FFTW3
# we set this variable to ON when we want fftw3 support (with or without MKL).
set(CP2K_USE_FFTW3_ OFF)
if(CP2K_USE_FFTW3)
find_package(Fftw REQUIRED)
if(CP2K_ENABLE_FFTW3_THREADS_SUPPORT AND CP2K_ENABLE_FFTW3_OPENMP_SUPPORT)
message(
FATAL_ERROR
"Fftw3 threads and openmp supports can not be used at the same time")
endif()
if(NOT CP2K_BLAS_VENDOR MATCHES "MKL" OR CP2K_USE_FFTW3_WITH_MKL)
find_package(Fftw REQUIRED)
if(CP2K_ENABLE_FFTW3_THREADS_SUPPORT AND CP2K_ENABLE_FFTW3_OPENMP_SUPPORT)
message(
FATAL_ERROR
"Fftw3 threads and openmp supports can not be used at the same time")
endif()
if((CP2K_ENABLE_FFTW3_THREADS_SUPPORT) AND (NOT TARGET
cp2k::FFTW3::fftw3_threads))
message(
FATAL_ERROR
"fftw3 was compiled without multithreading support (--enable-threads option in the fftw build system)."
)
endif()
if((CP2K_ENABLE_FFTW3_THREADS_SUPPORT) AND (NOT TARGET
cp2k::FFTW3::fftw3_threads))
message(
FATAL_ERROR
"fftw3 was compiled without multithreading support (--enable-threads option in the fftw build system)."
)
endif()
if((CP2K_ENABLE_FFTW3_OPENMP_SUPPORT) AND (NOT TARGET cp2k::FFTW3::fftw3_omp))
message(
FATAL_ERROR
"fftw3 was compiled without openmp support (--enable-openmp option in the fftw build system)."
)
if((CP2K_ENABLE_FFTW3_OPENMP_SUPPORT) AND (NOT TARGET cp2k::FFTW3::fftw3_omp
))
message(
FATAL_ERROR
"fftw3 was compiled without openmp support (--enable-openmp option in the fftw build system)."
)
endif()
set(CP2K_USE_FFTW3_ ON)
else()
message("-- Using the MKL implementation of FFTW3.")
endif()
endif()

View file

@ -23,7 +23,7 @@ if(NOT TARGET cp2k::cp2k)
set(CP2K_BLAS_LINK_LIBRARIES @CP2K_BLAS_LINK_LIBRARIES@)
set(CP2K_LAPACK_LINK_LIBRARIES @CP2K_LAPACK_LINK_LIBRARIES@)
set(CP2K_SCALAPACK_LINK_LIBRARIES @CP2K_SCALAPACK_LINK_LIBRARIES@)
set(CP2K_USE_FFTW3_WITH_MKL @CP2K_USE_FFTW3_WITH_MKL@)
set(CP2K_CONFIG_PACKAGE ON)
find_dependency(Lapack REQUIRED)
@ -67,7 +67,7 @@ if(NOT TARGET cp2k::cp2k)
find_dependency(MPI REQUIRED)
endif()
if(@CP2K_USE_FFTW3@)
if(@CP2K_USE_FFTW3_@)
find_dependency(Fftw REQUIRED)
endif()
# QUIP

View file

@ -456,8 +456,6 @@ if(MKL_FOUND)
unset(__mkl_scalapack_lib)
unset(__mkl_scalapack_inc)
set(CP2K_BLAS_VENDOR "MKL")
set(CP2K_MKL_SCALAPACK_VENDOR TRUE)
mark_as_advanced(CP2K_BLAS_VENDOR)
mark_as_advanced(CP2K_MKL_FOUND)
mark_as_advanced(CP2K_MKL_SCALAPACK_VENDOR)
endif()

View file

@ -98,7 +98,6 @@ if(CP2K_LIBSCI_FOUND)
endif()
set(CP2K_BLAS_VENDOR "SCI")
endif()
# prevent clutter in cache

View file

@ -1550,9 +1550,9 @@ target_link_libraries(
$<$<BOOL:${CP2K_USE_SPGLIB}>:cp2k::LIBSPG::libspg>
$<$<BOOL:${CP2K_USE_LIBXC}>:cp2k::Libxc::xc>
$<$<BOOL:${CP2K_USE_ELPA}>:cp2k::ELPA::elpa>
$<$<BOOL:${CP2K_USE_FFTW3}>:cp2k::FFTW3::fftw3>
$<$<BOOL:${CP2K_ENABLE_FFTW3_THREADS_SUPPORT}>:cp2k::FFTW3::fftw3_threads>
$<$<BOOL:${CP2K_ENABLE_FFTW3_OPENMP_SUPPORT}>:cp2k::FFTW3::fftw3_omp>
$<$<BOOL:${CP2K_USE_FFTW3_}>:cp2k::FFTW3::fftw3>
$<$<AND:$<BOOL:${CP2K_USE_FFTW3_}>,$<BOOL:${CP2K_ENABLE_FFTW3_THREADS_SUPPORT}>>:cp2k::FFTW3::fftw3_threads>
$<$<AND:$<BOOL:${CP2K_USE_FFTW3_}>,$<BOOL:${CP2K_ENABLE_FFTW3_OPENMP_SUPPORT}>>:cp2k::FFTW3::fftw3_omp>
$<$<BOOL:${CP2K_USE_SPLA}>:SPLA::spla>
$<$<BOOL:${CP2K_USE_LIBINT2}>:cp2k::Libint2::int2>
$<$<BOOL:${CP2K_USE_TORCH}>:${TORCH_LIBRARIES}>
@ -1560,7 +1560,8 @@ target_link_libraries(
$<$<BOOL:${CP2K_USE_COSMA}>:cosma::cosma>
DBCSR::dbcsr
$<$<BOOL:${CP2K_USE_MPI}>:cp2k::SCALAPACK::scalapack>
cp2k_linalg_libs)
cp2k_linalg_libs
$<$<AND:$<CONFIG:COVERAGE>,$<Fortran_COMPILER_ID:GNU>>:gcov>)
string(TIMESTAMP CP2K_TIMESTAMP "%Y-%m-%d %H:%M:%S")
@ -1569,7 +1570,7 @@ target_compile_definitions(
cp2k
PUBLIC $<$<BOOL:${CP2K_USE_MPI}>:__parallel>
$<$<BOOL:${CP2K_USE_MPI}>:__SCALAPACK>
$<$<BOOL:${CP2K_USE_F08_MPI}>:__MPI_F08>
$<$<BOOL:${CP2K_USE_MPI_F08}>:__MPI_F08>
__COMPILE_DATE=\"${CP2K_TIMESTAMP}\"
__COMPILE_HOST=\"${CP2K_HOST_NAME}\"
__COMPILE_REVISION=\"${CP2K_GIT_HASH}\"
@ -1591,7 +1592,7 @@ target_compile_definitions(
$<$<BOOL:${CP2K_USE_SPLA_GEMM_OFFLOADING}>:__OFFLOAD_GEMM>
$<$<BOOL:${CP2K_USE_ELPA}>:__ELPA>
$<$<BOOL:${CP2K_USE_LIBXC}>:__LIBXC>
$<$<BOOL:${CP2K_USE_FFTW3}>:__FFTW3>
$<$<BOOL:${CP2K_USE_FFTW3_}>:__FFTW3>
$<$<BOOL:${CP2K_USE_LIBINT2}>:__LIBINT>
$<$<BOOL:${CP2K_USE_PEXSI}>:__LIBPEXSI>
$<$<BOOL:${CP2K_USE_LIBTORCH}>:__LIBTORCH>
@ -1752,7 +1753,10 @@ foreach(__app grid_miniapp grid_unittest dbm_miniapp)
$<$<BOOL:${CP2K_USE_CUDA}>:${CMAKE_CUDA_INCLUDE_DIRECTORIES}>
$<$<BOOL:${CP2K_USE_HIP}>:${CMAKE_HIP_INCLUDE_DIRECTORIES}>)
target_link_libraries(${__app} PUBLIC cp2k_linalg_libs m)
target_link_libraries(
${__app}
PUBLIC cp2k_linalg_libs
$<$<AND:$<CONFIG:COVERAGE>,$<Fortran_COMPILER_ID:GNU>>:gcov> m)
endforeach()
# ##############################################################################

View file

@ -28,7 +28,6 @@ if ! cmake \
-DCP2K_USE_LIBXC=ON \
-DCP2K_USE_LIBTORCH=OFF \
-DCP2K_USE_MPI=ON \
-DCP2K_USE_MPI_F08=ON \
-DCP2K_ENABLE_REGTESTS=ON \
.. &> ./cmake.log; then
tail -n 100 cmake.log