diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bf675101a..9595718bc8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/cmake/cp2kConfig.cmake.in b/cmake/cp2kConfig.cmake.in index a9e0eb5a58..f119c8bdfb 100644 --- a/cmake/cp2kConfig.cmake.in +++ b/cmake/cp2kConfig.cmake.in @@ -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 diff --git a/cmake/modules/FindMKL.cmake b/cmake/modules/FindMKL.cmake index 87bd80de1d..8bc6979d9c 100644 --- a/cmake/modules/FindMKL.cmake +++ b/cmake/modules/FindMKL.cmake @@ -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() diff --git a/cmake/modules/FindSCI.cmake b/cmake/modules/FindSCI.cmake index 3a540b2024..c6c9d202c5 100644 --- a/cmake/modules/FindSCI.cmake +++ b/cmake/modules/FindSCI.cmake @@ -98,7 +98,6 @@ if(CP2K_LIBSCI_FOUND) endif() set(CP2K_BLAS_VENDOR "SCI") - endif() # prevent clutter in cache diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8ee82a8579..bec6eff26e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1550,9 +1550,9 @@ target_link_libraries( $<$:cp2k::LIBSPG::libspg> $<$:cp2k::Libxc::xc> $<$:cp2k::ELPA::elpa> - $<$:cp2k::FFTW3::fftw3> - $<$:cp2k::FFTW3::fftw3_threads> - $<$:cp2k::FFTW3::fftw3_omp> + $<$:cp2k::FFTW3::fftw3> + $<$,$>:cp2k::FFTW3::fftw3_threads> + $<$,$>:cp2k::FFTW3::fftw3_omp> $<$:SPLA::spla> $<$:cp2k::Libint2::int2> $<$:${TORCH_LIBRARIES}> @@ -1560,7 +1560,8 @@ target_link_libraries( $<$:cosma::cosma> DBCSR::dbcsr $<$:cp2k::SCALAPACK::scalapack> - cp2k_linalg_libs) + cp2k_linalg_libs + $<$,$>:gcov>) string(TIMESTAMP CP2K_TIMESTAMP "%Y-%m-%d %H:%M:%S") @@ -1569,7 +1570,7 @@ target_compile_definitions( cp2k PUBLIC $<$:__parallel> $<$:__SCALAPACK> - $<$:__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( $<$:__OFFLOAD_GEMM> $<$:__ELPA> $<$:__LIBXC> - $<$:__FFTW3> + $<$:__FFTW3> $<$:__LIBINT> $<$:__LIBPEXSI> $<$:__LIBTORCH> @@ -1752,7 +1753,10 @@ foreach(__app grid_miniapp grid_unittest dbm_miniapp) $<$:${CMAKE_CUDA_INCLUDE_DIRECTORIES}> $<$:${CMAKE_HIP_INCLUDE_DIRECTORIES}>) - target_link_libraries(${__app} PUBLIC cp2k_linalg_libs m) + target_link_libraries( + ${__app} + PUBLIC cp2k_linalg_libs + $<$,$>:gcov> m) endforeach() # ############################################################################## diff --git a/tools/docker/scripts/test_regtest_cmake.sh b/tools/docker/scripts/test_regtest_cmake.sh index d042d5d19d..9a89787052 100755 --- a/tools/docker/scripts/test_regtest_cmake.sh +++ b/tools/docker/scripts/test_regtest_cmake.sh @@ -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