mirror of
https://github.com/cp2k/cp2k.git
synced 2026-07-21 06:25:15 -04:00
Use cmake to build cp2k
This commit is contained in:
parent
bb1178b0dd
commit
b0f1689a08
41 changed files with 5338 additions and 0 deletions
762
CMakeLists.txt
Normal file
762
CMakeLists.txt
Normal file
|
|
@ -0,0 +1,762 @@
|
|||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
# include our cmake snippets
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||
|
||||
# =================================================================================================
|
||||
# REQUIRE OUT-OF-SOURCE BUILDS
|
||||
file(TO_CMAKE_PATH "${PROJECT_BINARY_DIR}/CMakeLists.txt" LOC_PATH)
|
||||
if(EXISTS "${LOC_PATH}")
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"You cannot build in a source directory (or any directory with a CMakeLists.txt file). Please make a build subdirectory."
|
||||
)
|
||||
endif()
|
||||
|
||||
# =================================================================================================
|
||||
# PROJECT AND VERSION
|
||||
include(GetGitRevisionDescription)
|
||||
include(CMakeDependentOption)
|
||||
cmake_policy(SET CMP0048 NEW)
|
||||
|
||||
git_describe(GIT_DESC)
|
||||
|
||||
if(GIT_DESC)
|
||||
string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${GIT_DESC}")
|
||||
string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR
|
||||
"${GIT_DESC}")
|
||||
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH
|
||||
"${GIT_DESC}")
|
||||
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+(.*)" "\\1" VERSION_GIT
|
||||
"${GIT_DESC}")
|
||||
|
||||
git_local_changes(GIT_STATE)
|
||||
if("${GIT_STATE}" STREQUAL "DIRTY")
|
||||
set(VERSION_GIT "${VERSION_GIT}-dirty")
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND git log -1 --format=%ai
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_COMMIT_DATE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
# take only the date from the git timestamp:
|
||||
string(REGEX REPLACE "^([0-9\\-]+) .*" "\\1" VERSION_DATE
|
||||
"${GIT_COMMIT_DATE}")
|
||||
else()
|
||||
set(VERSION_MAJOR 21)
|
||||
set(VERSION_MINOR 10)
|
||||
set(VERSION_PATCH 00)
|
||||
endif()
|
||||
|
||||
project(
|
||||
cp2k
|
||||
DESCRIPTION "CP2K"
|
||||
HOMEPAGE_URL "https://www.cp2k.org"
|
||||
VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
|
||||
LANGUAGES Fortran C CXX)
|
||||
|
||||
set(cp2k_APIVERSION ${cp2k_VERSION_MAJOR}.${cp2k_VERSION_MINOR})
|
||||
|
||||
if(NOT DEFINED CMAKE_CUDA_STANDARD)
|
||||
set(CMAKE_CUDA_STANDARD 11)
|
||||
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
|
||||
endif()
|
||||
|
||||
# set language and standard
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
find_package(PkgConfig)
|
||||
|
||||
# ##############################################################################
|
||||
# Define the paths for static libraries and executables
|
||||
# ##############################################################################
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
|
||||
${cp2k_BINARY_DIR}/lib
|
||||
CACHE PATH "Single output directory for building all libraries.")
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
|
||||
${cp2k_BINARY_DIR}/bin
|
||||
CACHE PATH "Single output directory for building all executables.")
|
||||
|
||||
# Search for rocm in common locations
|
||||
foreach(__var ROCM_ROOT CRAY_ROCM_ROOT ORNL_ROCM_ROOT CRAY_ROCM_PREFIX
|
||||
ROCM_PREFIX CRAY_ROCM_DIR)
|
||||
if($ENV{${__var}})
|
||||
list(APPEND CMAKE_PREFIX_PATH $ENV{__var})
|
||||
set(ROCM_PATH
|
||||
$ENV{__var}
|
||||
CACHE PATH "Path to ROCm installation")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# =================================================================================================
|
||||
# OPTIONS
|
||||
|
||||
option(CMAKE_POSITION_INDEPENDENT_CODE "Enable position independent code" ON)
|
||||
|
||||
option(CP2K_USE_SIRIUS "Enable plane wave dft calculations with sirius" OFF)
|
||||
option(CP2K_USE_FFTW3 "Use fftw3 for the calculating fast fourier transforms"
|
||||
ON)
|
||||
option(CP2K_USE_ELPA "Enable elpa support" OFF)
|
||||
option(CP2K_USE_PEXSI "Enable pexsi support" OFF)
|
||||
option(CP2K_USE_SUPERLU "Enable superlu support" OFF)
|
||||
option(CP2K_USE_COSMA "COSMA is a drop in replacement of scalapack dgemm" ON)
|
||||
option(CP2K_USE_LIBINT2 "Enable libint2 support" ON)
|
||||
option(CP2K_USE_VORI "Enable libvori support" OFF)
|
||||
option(CP2K_USE_PEXSI "Enable pexsi support" OFF)
|
||||
option(CP2K_USE_QUIP "Enable quip support" OFF)
|
||||
option(CP2K_USE_SPGLIB "Enable spglib support" ON)
|
||||
|
||||
option(CP2K_USE_LIBXC "Enable libxc support" ON)
|
||||
|
||||
option(CP2K_USE_STATIC_BLAS "Link against static version of BLAS/LAPACK" OFF)
|
||||
|
||||
option(CP2K_USE_SPLA
|
||||
"Use SPLA offloading gemm feature to the GPU if it is beneficial. " OFF)
|
||||
|
||||
option(CP2K_USE_METIS "enable metis library support" OFF)
|
||||
|
||||
option(CP2K_USE_LIBXSMM "Use libxsmm for small gemms (supports x86 platforms)"
|
||||
ON)
|
||||
|
||||
cmake_dependent_option(CP2K_ENABLE_ELPA_OPENMP_SUPPORT
|
||||
"Enable elpa openmp support" OFF "CP2K_USE_ELPA" OFF)
|
||||
|
||||
set(CP2K_SCALAPACK_VENDOR_LIST "MKL" "SCI" "GENERIC")
|
||||
set(CP2K_SCALAPACK_VENDOR
|
||||
"GENERIC"
|
||||
CACHE STRING "scalapack vendor/generic backend")
|
||||
set_property(CACHE CP2K_SCALAPACK_VENDOR PROPERTY STRINGS
|
||||
${CP2K_SCALAPACK_VENDOR_LIST})
|
||||
|
||||
if(NOT ${CP2K_SCALAPACK_VENDOR} IN_LIST CP2K_SCALAPACK_VENDOR_LIST)
|
||||
message(FATAL_ERROR "Invalid scalapack vendor backend")
|
||||
endif()
|
||||
|
||||
# ##############################################################################
|
||||
# # gpu related options # #
|
||||
# ##############################################################################
|
||||
|
||||
set(CP2K_SUPPORTED_ACCELERATION_TARGETS CUDA HIP NONE)
|
||||
set(CP2K_SUPPORTED_CUDA_ARCHITECTURES K20X K40 K80 P100 V100 A100)
|
||||
set(CP2K_SUPPORTED_HIP_ARCHITECTURES
|
||||
Mi50
|
||||
Mi100
|
||||
Mi210
|
||||
Mi250X
|
||||
K20X
|
||||
K40
|
||||
K80
|
||||
P100
|
||||
V100
|
||||
A100)
|
||||
|
||||
set(CP2K_WITH_GPU
|
||||
"P100"
|
||||
CACHE STRING
|
||||
"Set the CUDA GPU architecture if HIP is enabled (default: P100)")
|
||||
|
||||
set_property(
|
||||
CACHE CP2K_WITH_GPU PROPERTY STRINGS ${CP2K_SUPPORTED_CUDA_ARCHITECTURES}
|
||||
${CP2K_SUPPORTED_HIP_ARCHITECTURES})
|
||||
|
||||
option(CP2K_DEBUG_MODE OFF
|
||||
"Enable several additional options for debugging cp2k.")
|
||||
|
||||
set(CP2K_USE_ACCEL
|
||||
"NONE"
|
||||
CACHE STRING "Set hardware acceleartion support: CUDA, HIP")
|
||||
|
||||
set_property(CACHE CP2K_USE_ACCEL
|
||||
PROPERTY STRINGS ${CP2K_SUPPORTED_ACCELERATION_TARGETS})
|
||||
|
||||
cmake_dependent_option(
|
||||
CP2K_USE_SPLA_GEMM_OFFLOADING ON
|
||||
"Enable SPLA dgemm offloading (only valid with gpu support on)"
|
||||
"(NOT CP2K_USE_ACCEL MATCHES \"NONE\") AND (CP2K_USE_SPLA)" OFF)
|
||||
|
||||
# ##############################################################################
|
||||
#
|
||||
# GPU debug options
|
||||
#
|
||||
# ##############################################################################
|
||||
|
||||
cmake_dependent_option(CP2K_DEBUG_MODE OFF "Enable CP2K debug options"
|
||||
"NOT CP2K_USE_ACCEL MATCHES \"NONE\" " OFF)
|
||||
cmake_dependent_option(
|
||||
CP2K_DISABLE_GRID_GPU
|
||||
OFF
|
||||
"disable the hardware accelerated backend for grid related functions. It is only effective when general gpu support is enabled."
|
||||
"CP2K_DEBUG_MODE"
|
||||
OFF)
|
||||
cmake_dependent_option(
|
||||
CP2K_DISABLE_PW_GPU
|
||||
OFF
|
||||
"disable the ffts accelerated (mostly GPU) backend. It is only effective when general gpu support is enabled."
|
||||
"CP2K_DEBUG_MODE"
|
||||
OFF)
|
||||
cmake_dependent_option(
|
||||
CP2K_DISABLE_DBM_GPU
|
||||
OFF
|
||||
"disable the dbm accelerated (mostly GPU) backend. It is only effective when general gpu support is enabled."
|
||||
"CP2K_DEBUG_MODE"
|
||||
OFF)
|
||||
cmake_dependent_option(
|
||||
CP2K_DBCSR_CPU_ONLY "Use DBCSR compiled without GPU support." OFF
|
||||
"CP2K_DEBUG_MODE" OFF)
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ${CP2K_SET_POSITION_INDEPENDENT_CODE})
|
||||
|
||||
find_package(PkgConfig)
|
||||
|
||||
# =================================== Python this module looks preferably for
|
||||
# version 3 of Python. If not found, version 2 is searched. In CMake 3.15, if a
|
||||
# python virtual environment is activated, it will search the virtual
|
||||
# environment for a python interpreter before searching elsewhere in the system.
|
||||
# In CMake <3.15, the system is searched before the virtual environment.
|
||||
|
||||
if(NOT Python_EXECUTABLE)
|
||||
# If the python interpreter isn't specified as a command line option, look for
|
||||
# it:
|
||||
find_package(
|
||||
Python
|
||||
COMPONENTS Interpreter
|
||||
REQUIRED)
|
||||
endif()
|
||||
|
||||
# get the git hash Get the latest abbreviated commit hash of the working branch
|
||||
execute_process(
|
||||
COMMAND git log -1 --format=%h
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
||||
OUTPUT_VARIABLE CP2K_GIT_HASH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
execute_process(
|
||||
COMMAND hostnamectl --transient
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
||||
OUTPUT_VARIABLE CP2K_HOST_NAME
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
add_custom_target(
|
||||
AlwaysCheckGit
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -DRUN_CHECK_GIT_VERSION=1
|
||||
-Dpre_configure_dir=${pre_configure_dir}
|
||||
-Dpost_configure_file=${post_configure_dir}
|
||||
-DGIT_HASH_CACHE=${GIT_HASH_CACHE} -P ${CURRENT_LIST_DIR}/CheckGit.cmake
|
||||
BYPRODUCTS ${post_configure_file})
|
||||
|
||||
# =================================== MPI
|
||||
|
||||
# if (CP2K_USE_MPI)
|
||||
get_property(REQUIRED_MPI_COMPONENTS GLOBAL PROPERTY ENABLED_LANGUAGES)
|
||||
list(REMOVE_ITEM REQUIRED_MPI_COMPONENTS CUDA) # CUDA does not have an MPI
|
||||
# component
|
||||
if(NOT CMAKE_CROSSCOMPILING) # when cross compiling, assume the users know
|
||||
# what they are doing
|
||||
set(MPI_DETERMINE_LIBRARY_VERSION TRUE)
|
||||
endif()
|
||||
find_package(
|
||||
MPI
|
||||
COMPONENTS ${REQUIRED_MPI_COMPONENTS}
|
||||
REQUIRED)
|
||||
|
||||
if(NOT MPI_Fortran_HAVE_F90_MODULE)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"\
|
||||
The listed MPI implementation does not provide the required mpi.mod interface. \
|
||||
When using the GNU compiler in combination with Intel MPI, please use the \
|
||||
Intel MPI compiler wrappers. Check the INSTALL.md for more information.")
|
||||
endif()
|
||||
if("${MPI_Fortran_LIBRARY_VERSION_STRING}" MATCHES "Open MPI v2.1"
|
||||
OR "${MPI_Fortran_LIBRARY_VERSION_STRING}" MATCHES "Open MPI v3.1")
|
||||
message(
|
||||
WARNING
|
||||
"RMA with ${MPI_Fortran_LIBRARY_VERSION_STRING} is not supported due to issues with its implementation."
|
||||
" Please use a newer version of OpenMPI or switch to MPICH if you plan on using MPI-RMA."
|
||||
)
|
||||
endif()
|
||||
# endif () =================================== BLAS & LAPACK, PkgConfig
|
||||
find_package(Lapack REQUIRED) # also calls find_package(BLAS)
|
||||
|
||||
# =================================== SMM (Small Matrix-Matrix multiplication)
|
||||
if(CP2K_USE_LIBXSMM)
|
||||
find_package(LibXSMM REQUIRED)
|
||||
message(STATUS "-- Using libxsmm for Small Matrix Multiplication")
|
||||
endif()
|
||||
|
||||
# in practice it is always for any decent configuration. But I add a flags to
|
||||
# turn it off
|
||||
find_package(SCALAPACK REQUIRED)
|
||||
|
||||
# ================================== CUDA / ROCM easy for cuda a moving target
|
||||
# for hip
|
||||
# ======================================
|
||||
|
||||
if((CP2K_USE_ACCEL MATCHES CUDA) OR (CP2K_USE_ACCEL MATCHES HIP))
|
||||
set(CP2K_GPU_ARCH_NUMBER_K20X 35)
|
||||
set(CP2K_GPU_ARCH_NUMBER_K40 35)
|
||||
set(CP2K_GPU_ARCH_NUMBER_K80 37)
|
||||
set(CP2K_GPU_ARCH_NUMBER_P100 60)
|
||||
set(CP2K_GPU_ARCH_NUMBER_V100 70)
|
||||
set(CP2K_GPU_ARCH_NUMBER_A100 80)
|
||||
set(CP2K_GPU_ARCH_NUMBER_Mi50 gfx906)
|
||||
set(CP2K_GPU_ARCH_NUMBER_Mi100 gfx908)
|
||||
set(CP2K_GPU_ARCH_NUMBER_Mi200 gfx90a)
|
||||
set(CP2K_GPU_ARCH_NUMBER_Mi250X gfx90a)
|
||||
endif()
|
||||
|
||||
set(CP2K_USE_HIP OFF)
|
||||
set(CP2K_USE_CUDA OFF)
|
||||
|
||||
if(CP2K_USE_ACCEL MATCHES "CUDA")
|
||||
# P100 is the default target.
|
||||
set(CMAKE_CUDA_ARCHITECTURES 60)
|
||||
|
||||
# allow for unsupported compilers (gcc/cuda version mismatch)
|
||||
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -allow-unsupported-compiler")
|
||||
|
||||
enable_language(CUDA)
|
||||
find_package(CUDAToolkit REQUIRED)
|
||||
|
||||
list(FIND CP2K_SUPPORTED_CUDA_ARCHITECTURES ${CP2K_WITH_GPU}
|
||||
CP2K_GPU_SUPPORTED)
|
||||
|
||||
if(CP2K_GPU_SUPPORTED EQUAL -1)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"GPU architecture (${CP2K_WITH_GPU}) is not supported. Please choose from: ${CP2K_SUPPORTED_CUDA_ARCHITECTURES}"
|
||||
)
|
||||
endif()
|
||||
|
||||
# set cuda architecture number and compilation flags. Taken from dbcsr
|
||||
set(CP2K_ACC_ARCH_NUMBER ${CP2K_GPU_ARCH_NUMBER_${CP2K_WITH_GPU}})
|
||||
set(CMAKE_CUDA_ARCHITECTURES ${CP2K_ACC_ARCH_NUMBER})
|
||||
set(CUDA_ARCHITECTURES ${CP2K_ACC_ARCH_NUMBER})
|
||||
|
||||
message(STATUS "GPU target architecture: " ${CP2K_WITH_GPU})
|
||||
message(STATUS "GPU architecture number: " ${CP2K_ACC_ARCH_NUMBER})
|
||||
message(STATUS "GPU profiling enabled: " ${CP2K_WITH_CUDA_PROFILING})
|
||||
|
||||
if(WITH_CUDA_PROFILING)
|
||||
find_library(
|
||||
CUDA_NVTOOLSEXT nvToolsExt
|
||||
PATHS ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}
|
||||
DOC "Building with CUDA profiling requires the nvToolsExt CUDA library"
|
||||
REQUIRED)
|
||||
message(STATUS "Found nvToolsExt: ${CUDA_NVTOOLSEXT}")
|
||||
endif()
|
||||
|
||||
set(CP2K_USE_CUDA ON)
|
||||
message(STATUS "-- CUDA compiler and libraries found")
|
||||
elseif(CP2K_USE_ACCEL MATCHES "HIP")
|
||||
enable_language(HIP)
|
||||
# Find hip
|
||||
find_package(hip REQUIRED IMPORTED CONFIG)
|
||||
find_package(hipfft REQUIRED IMPORTED CONFIG)
|
||||
find_package(hipblas REQUIRED IMPORTED CONFIG)
|
||||
|
||||
set(CMAKE_HIP_ARCHITECTURES gfx801 gfx900 gfx90a)
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(HIP_RELEASE_OPTIONS "-O3 -g -DNDEBUG")
|
||||
elseif(${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo")
|
||||
set(HIP_RELEASE_OPTIONS "-O3 -g -DNDEBUG")
|
||||
elseif(${CMAKE_BUILD_TYPE} STREQUAL "Release")
|
||||
set(HIP_RELEASE_OPTIONS "-O3 -DNDEBUG")
|
||||
elseif(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
|
||||
set(HIP_RELEASE_OPTIONS "-O0 -g")
|
||||
endif()
|
||||
|
||||
set(CP2K_ACC_ARCH_NUMBER ${CP2K_GPU_ARCH_NUMBER_${CP2K_WITH_GPU}})
|
||||
set(CP2K_USE_HIP ON)
|
||||
endif()
|
||||
|
||||
find_package(DBCSR 2.2.0 REQUIRED)
|
||||
|
||||
# =================================================================================================
|
||||
# PACKAGE DISCOVERY (compiler configuration can impact package discovery)
|
||||
|
||||
find_package(OpenMP REQUIRED COMPONENTS Fortran C CXX)
|
||||
|
||||
# ==================================
|
||||
if(CP2K_USE_ELPA)
|
||||
find_package(Elpa REQUIRED)
|
||||
endif()
|
||||
|
||||
if(CP2K_USE_LIBXC)
|
||||
find_package(LibXC 6.0.0 REQUIRED)
|
||||
endif()
|
||||
|
||||
if(CP2K_USE_COSMA)
|
||||
find_package(cosma REQUIRED)
|
||||
get_target_property(COSMA_INCLUDE_DIRS cosma::cosma
|
||||
INTERFACE_INCLUDE_DIRECTORIES)
|
||||
if(NOT COSMA_INCLUDE_DIRS)
|
||||
set(COSMA_INCLUDE_DIRS "/usr/include;/usr/include/cosma")
|
||||
endif()
|
||||
|
||||
# check that cosma::cosma_pxgemm and cosma::cosma_prefixed_pxgemm exist
|
||||
if(NOT TARGET cosma::cosma_pxgemm OR NOT TARGET cosma::cosma_prefixed_pxgemm)
|
||||
message(ERROR " COSMA needs tor be build with scalapack offloading support")
|
||||
message(
|
||||
FATAL
|
||||
" COSTA_SCALAPACK and COSMA_SCALAPACK should probably be set properly")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CP2K_USE_VORI)
|
||||
find_package(LibVORI REQUIRED)
|
||||
endif()
|
||||
|
||||
# =================================== CP2K_FFTW3
|
||||
# ===========================================
|
||||
|
||||
if(CP2K_USE_FFTW3)
|
||||
find_package(Fftw REQUIRED)
|
||||
endif()
|
||||
|
||||
# ==================================== QUIP
|
||||
# ===========================================
|
||||
if(CP2K_USE_QUIP)
|
||||
find_package(Quip REQUIRED)
|
||||
endif()
|
||||
|
||||
# ==================================== libint
|
||||
# =========================================
|
||||
|
||||
if(CP2K_USE_LIBINT2)
|
||||
find_package(Libint2 REQUIRED)
|
||||
endif()
|
||||
|
||||
# ==================================== spglib
|
||||
# =========================================
|
||||
|
||||
if(CP2K_USE_SPGLIB)
|
||||
find_package(LibSPG REQUIRED)
|
||||
endif()
|
||||
|
||||
if(CP2K_USE_SPLA)
|
||||
find_package(SPLA REQUIRED)
|
||||
get_target_property(SPLA_INCLUDE_DIRS SPLA::spla
|
||||
INTERFACE_INCLUDE_DIRECTORIES)
|
||||
if(NOT SPLA_INCLUDE_DIRS)
|
||||
set(SPLA_INCLUDE_DIRS "/usr/include;/usr/include/spla")
|
||||
endif()
|
||||
|
||||
if(NOT SPLA_GPU_BACKEND AND CP2K_USE_GEMM_OFFLOADING)
|
||||
set(CP2K_USE_GEMM_OFFLOADING OFF)
|
||||
message(
|
||||
ERROR
|
||||
"SPLA should be compiled with GPU support if the gemm offloading is requested. Use -DCP2K_USE_GEMM_OFFLOADING=OFF othrwise"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
# =================================== SIRIUS
|
||||
# ==========================================
|
||||
|
||||
if(CP2K_USE_SIRIUS)
|
||||
find_package(sirius REQUIRED)
|
||||
get_target_property(SIRIUS_INCLUDE_DIRS sirius::sirius
|
||||
INTERFACE_INCLUDE_DIRECTORIES)
|
||||
if(NOT SIRIUS_INCLUDE_DIRS)
|
||||
set(SIRIUS_INCLUDE_DIRS "/usr/include;/usr/include/sirius")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CP2K_USE_SUPERLU)
|
||||
find_package(SuperLU REQUIRED)
|
||||
endif()
|
||||
|
||||
if(CP2K_USE_PARMETIS)
|
||||
find_package(Metis)
|
||||
endif()
|
||||
|
||||
if(CP2K_USE_PTSCOTCH)
|
||||
find_package(Ptscotch REQUIRED)
|
||||
endif()
|
||||
|
||||
if(CP2K_USE_PEXSI)
|
||||
# PEXSI 1.2 uses cmake as build system
|
||||
find_package(PEXSI REQUIRED)
|
||||
endif()
|
||||
|
||||
if(CP2K_USE_PLUMED)
|
||||
find_package(Plumed REQUIRED)
|
||||
endif()
|
||||
|
||||
# =================================================================================================
|
||||
# OPTION HANDLING
|
||||
|
||||
# make sure that the default build type is RELEASE
|
||||
set(default_build_type "Release")
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
message(
|
||||
STATUS
|
||||
"Setting build type to '${default_build_type}' as none was specified.")
|
||||
set(CMAKE_BUILD_TYPE
|
||||
"${default_build_type}"
|
||||
CACHE STRING
|
||||
"Choose the type of build, options are: Debug Release Coverage."
|
||||
FORCE)
|
||||
# set the possible values of build type for cmake-gui
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
|
||||
"Coverage")
|
||||
endif()
|
||||
|
||||
# compiler configuration could have impacted package discovery (above)
|
||||
include(CompilerConfiguration)
|
||||
include(CheckCompilerSupport)
|
||||
|
||||
# subdirectories
|
||||
add_subdirectory(src)
|
||||
|
||||
include(CustomTargets)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
get_target_property(CP2K_LIBS cp2k_link_libs INTERFACE_LINK_LIBRARIES)
|
||||
configure_file(cp2k.pc.in cp2k.pc @ONLY)
|
||||
|
||||
message(
|
||||
STATUS "--------------------------------------------------------------------")
|
||||
message(
|
||||
STATUS "- -")
|
||||
message(
|
||||
STATUS "- Summary of enabled dependencies -")
|
||||
message(
|
||||
STATUS "- -")
|
||||
message(
|
||||
STATUS "--------------------------------------------------------------------")
|
||||
|
||||
message(STATUS " ")
|
||||
message(STATUS "- BLAS AND LAPACK")
|
||||
message(STATUS " ")
|
||||
|
||||
message(STATUS " - vendor : " ${CP2K_BLAS_VENDOR})
|
||||
message(STATUS " - include directories : " ${CP2K_BLAS_INCLUDE_DIRS}
|
||||
${LAPACK_INCLUDE_DIR})
|
||||
message(STATUS " - libraries : " ${CP2K_BLAS_LINK_LIBRARIES} " "
|
||||
${CP2K_LAPACK_LINK_LIBRARIES})
|
||||
|
||||
message(STATUS " ")
|
||||
message(STATUS "- MPI")
|
||||
message(STATUS " - include directories : " ${MPI_INCLUDE_DIRS})
|
||||
message(STATUS " - libraries : " ${MPI_LIBRARIES})
|
||||
|
||||
message(STATUS " ")
|
||||
message(STATUS "- SCALAPACK:")
|
||||
message(STATUS " - libraries : " ${CP2K_SCALAPACK_LINK_LIBRARIES})
|
||||
|
||||
message(STATUS " - Hardware Acceleration:")
|
||||
message(STATUS " ")
|
||||
if(CP2K_USE_ACCEL MATCHES "CUDA")
|
||||
message(STATUS " ")
|
||||
message(STATUS "- CUDA:")
|
||||
message(STATUS " - GPU target architecture : " ${CP2K_WITH_GPU})
|
||||
message(STATUS " - GPU architecture number : " ${CP2K_ACC_ARCH_NUMBER})
|
||||
message(STATUS " - GPU profiling enabled : "
|
||||
${CP2K_WITH_CUDA_PROFILING})
|
||||
endif()
|
||||
|
||||
if(CP2K_USE_ACCEL MATCHES "HIP")
|
||||
message(STATUS " ")
|
||||
message(STATUS "- HIP:")
|
||||
message(STATUS " - GPU target architecture : " ${CP2K_WITH_GPU})
|
||||
message(STATUS " - GPU architecture number : " ${CP2K_ACC_ARCH_NUMBER})
|
||||
endif()
|
||||
|
||||
if((CP2K_USE_ACCEL MATCHES "CUDA") OR (CP2K_USE_ACCEL MATCHES "HIP"))
|
||||
message(STATUS " ")
|
||||
message(
|
||||
STATUS
|
||||
" Note : Enabling hardware acceleration enable acceleration of the grid, pw, and dbm modules by default"
|
||||
)
|
||||
message(STATUS " - GRID module : " ${CP2K_USE_GRID_GPU})
|
||||
message(STATUS " - PW module : " ${CP2K_USE_PW_GPU})
|
||||
message(STATUS " - DBM module : " ${CP2K_USE_DBM_GPU})
|
||||
endif()
|
||||
|
||||
if(CP2K_USE_LIBXC)
|
||||
message(STATUS " ")
|
||||
message(
|
||||
STATUS
|
||||
"- LIBXC (note to package managers : libxc can be build with cmake as well)"
|
||||
)
|
||||
message(STATUS " - include directories : " ${CP2K_LIBXC_INCLUDE_DIRS})
|
||||
message(STATUS " - libraries : " ${CP2K_LIBXC_LINK_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(CP2K_USE_FFTW3)
|
||||
message(STATUS " ")
|
||||
message(STATUS "- FFTW3")
|
||||
message(STATUS " - include directories : " ${CP2K_FFTW3_INCLUDE_DIRS})
|
||||
message(STATUS " - libraries : " ${CP2K_FFTW3_LINK_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(CP2K_USE_LIBXSMM)
|
||||
message(STATUS " ")
|
||||
message(STATUS "- libxsmm")
|
||||
message(STATUS " - include directories : " ${CP2K_LIBXSMM_INCLUDE_DIRS})
|
||||
message(STATUS " - libraries : " ${CP2K_LIBXSMM_LINK_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(CP2K_USE_SPLA)
|
||||
message(STATUS " ")
|
||||
message(STATUS "- SPLA :")
|
||||
message(STATUS " - include directories : " ${SPLA_INCLUDE_DIRS})
|
||||
message(STATUS " - lbraries : " "${SPLA_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
if(CP2K_USE_SIRIUS)
|
||||
message(STATUS " ")
|
||||
message(STATUS "- SIRIUS :")
|
||||
message(STATUS " - include directories : " ${SIRIUS_INCLUDE_DIRS})
|
||||
message(STATUS " - libraries : " ${SIRIUS_LIBRARIES})
|
||||
|
||||
message(STATUS " - dependencies : ")
|
||||
message(STATUS " - spla")
|
||||
message(STATUS " - SpFFT")
|
||||
message(STATUS " - SPGLIB")
|
||||
message(STATUS " - LibXC")
|
||||
message(STATUS " - fftw3")
|
||||
message(STATUS " - hdf5")
|
||||
message(STATUS " - GSL")
|
||||
if(CP2K_USE_VDWXC)
|
||||
message(STATUS " - VDWXC")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CP2K_USE_COSMA)
|
||||
message(STATUS " ")
|
||||
message(STATUS "- COSMA")
|
||||
message(STATUS " - include directories : " ${COSMA_INCLUDE_DIRS})
|
||||
message(STATUS " - libraries : " ${COSMA_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(CP2K_USE_QUIP)
|
||||
message(STATUS " ")
|
||||
message(STATUS "- QUIP")
|
||||
message(STATUS " - include directories : " ${CP2K_LIBQUIP_INCLUDE_DIRS})
|
||||
message(STATUS " - libraries : " ${CP2K_LIBQUIP_LINK_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(CP2K_USE_PEXSI)
|
||||
message(STATUS " ")
|
||||
message(STATUS "- PEXSI")
|
||||
endif()
|
||||
|
||||
if(CP2K_USE_LIBINT2)
|
||||
message(STATUS " ")
|
||||
message(STATUS "- libint2")
|
||||
message(STATUS " - include directories : " ${CP2K_LIBINT2_INCLUDE_DIRS})
|
||||
message(STATUS " - libraries : " ${CP2K_LIBINT2_LINK_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(CP2K_USE_VORI)
|
||||
message(STATUS " ")
|
||||
message(STATUS "- libvori")
|
||||
message(STATUS " - include directories : " ${CP2K_LIBVORI_INCLUDE_DIRS})
|
||||
message(STATUS " - libraries : " ${CP2K_LIBVORI_LINK_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(CP2K_USE_SPGLIB)
|
||||
message(STATUS " ")
|
||||
message(STATUS "- spglib")
|
||||
message(STATUS " - include directories : " ${CP2K_LIBSPG_INCLUDE_DIRS})
|
||||
message(STATUS " - libraries : " ${CP2K_LIBSPG_LINK_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(CP2K_USE_ELPA)
|
||||
message(STATUS "- ELPA")
|
||||
message(STATUS " - include directories : " ${CP2K_ELPA_INCLUDE_DIRS})
|
||||
message(STATUS " - libraries : " ${CP2K_ELPA_LINK_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(CP2K_USE_SUPERLU)
|
||||
message(STATUS " ")
|
||||
message(STATUS "- superlu")
|
||||
message(STATUS " - include directories : " ${CP2K_SUPERLU_INCLUDE_DIRS})
|
||||
message(STATUS " - libraries : " ${CP2K_SUPERLU_LINK_LIBRARIES})
|
||||
endif()
|
||||
|
||||
message(STATUS " ")
|
||||
message(
|
||||
STATUS "--------------------------------------------------------------------")
|
||||
message(
|
||||
STATUS "- -")
|
||||
message(
|
||||
STATUS "- List of dependencies not included in this build -")
|
||||
message(
|
||||
STATUS "- -")
|
||||
message(
|
||||
STATUS "--------------------------------------------------------------------")
|
||||
|
||||
message(STATUS " List of dependencies not included in this build :")
|
||||
|
||||
if(NOT CP2K_USE_SIRIUS)
|
||||
message(STATUS " - SIRIUS")
|
||||
endif()
|
||||
|
||||
if(NOT CP2K_USE_SPGLIB)
|
||||
message(STATUS " - SPGLIB")
|
||||
endif()
|
||||
|
||||
if(NOT CP2K_USE_COSMA)
|
||||
message(STATUS " - COSMA")
|
||||
endif()
|
||||
|
||||
if(NOT CP2K_USE_SPLA)
|
||||
message(STATUS " - SPLA")
|
||||
endif()
|
||||
|
||||
if(${CP2K_USE_ACCEL} MATCHES "NONE")
|
||||
message(STATUS " - GPU acceleration is disabled")
|
||||
endif()
|
||||
|
||||
if(NOT CP2K_USE_ELPA)
|
||||
message(STATUS " - ELPA")
|
||||
endif()
|
||||
|
||||
if(NOT CP2K_USE_PLUMMED)
|
||||
message(STATUS " - PLUMMED")
|
||||
endif()
|
||||
|
||||
if(NOT CP2K_USE_QUIP)
|
||||
message(STATUS " - QUIP")
|
||||
endif()
|
||||
|
||||
if(NOT CP2K_USE_LIBXSMM)
|
||||
message(STATUS " - LIBXSMM")
|
||||
endif()
|
||||
|
||||
if(NOT CP2K_USE_LIBINT2)
|
||||
message(STATUS " - LIBINT2")
|
||||
endif()
|
||||
|
||||
if(NOT CP2K_USE_LIBXC)
|
||||
message(STATUS " - LIBXC")
|
||||
endif()
|
||||
|
||||
if(NOT CP2K_USE_VORI)
|
||||
message(STATUS " - LIBVORI")
|
||||
endif()
|
||||
|
||||
if(NOT CP2K_USE_FFTW3)
|
||||
message(STATUS " - FFTW3")
|
||||
endif()
|
||||
|
||||
if(NOT CP2K_USE_PEXSI)
|
||||
message(STATUS " - PEXSI")
|
||||
endif()
|
||||
|
||||
if(NOT CP2K_USE_SUPERLU)
|
||||
message(STATUS " - SUPERLU")
|
||||
endif()
|
||||
|
||||
message(
|
||||
STATUS " ")
|
||||
message(
|
||||
STATUS " ")
|
||||
179
README_cmake.md
Normal file
179
README_cmake.md
Normal file
|
|
@ -0,0 +1,179 @@
|
|||
# Build cp2k with cmake
|
||||
|
||||
This document regroups information about the cp2k cmake system. CMake is used to
|
||||
detect cp2k dependencies and configure the compilation process. Dependencies
|
||||
should be installed independently either with a distribution package manager,
|
||||
easybuild, or spack to name a few.
|
||||
|
||||
It is easier to build and install all manually build dependencies in a single
|
||||
directory ideally where cp2k will also be installed. Cmake will have less
|
||||
difficulties to find the FindPACKAGE.cmake files and dependent libraries. CMake
|
||||
will also use environment variables such as ORNL_FFTW3_ROOT, etc. Usually a
|
||||
standard prefix is used in HPC environments. If known just add it in the
|
||||
cmake/cp2k_utils.cmake file.
|
||||
|
||||
The cmake build system requires a minimum set of dependencies :
|
||||
|
||||
- a c, C++, and fortran compiler (gcc, intel oneapi, AMD or nvidia SDK, xlf, etc...)
|
||||
- an MPI implementation
|
||||
- DBCSR.
|
||||
- openmp
|
||||
- any flavor of BLAS, LAPACK, SCALAPACK.
|
||||
- cmake of course
|
||||
|
||||
Major vendors implementations of BLAS, LAPACK, and scalapack are supported. The
|
||||
build system was tested with MKL, cray libsci, openblas, flexiblas but it should
|
||||
also work with blis, or ATLAS. Corresponding findPACKAGE.cmake are included but
|
||||
they still need testing.
|
||||
|
||||
Options turned on by default are CP2K_USE_LIBXSMM, CP2K_USE_FFTW3,
|
||||
CP2K_USE_LIBXC, CP2K_USE_COSMA, CP2K_USE_LIBINT2. Additionally MPI, DBCSR,
|
||||
OPENMP, SCALAPACK, and BLAS/LAPACK are mandatory and can not be turned off. the
|
||||
arguement `-DCP2K_USE_OPTION=ON, OFF` can be added to the cmake command line
|
||||
turn `ON` or `OFF` a specific option. The list of currently supported optional
|
||||
dependencies is
|
||||
|
||||
- CP2K_USE_SIRIUS = OFF : add SIRIUS support to cp2k
|
||||
|
||||
- CP2K_USE_FFTW3 = ON : add support of fftw3 (on by default)
|
||||
|
||||
- CP2K_USE_ELPA = OFF : add elpa support (off by default) WARNING : Expect the
|
||||
detection to fail at that stage
|
||||
|
||||
- CP2K_USE_PEXSI = OFF
|
||||
|
||||
- CP2K_USE_SUPERLU = OFF : detection should work but needs improvement
|
||||
|
||||
- CP2K_USE_COSMA = ON : Add cosma dropin replacement for sclapack pdgemnm
|
||||
|
||||
- CP2K_USE_LIBINT2 = ON : add libint2 support (detection works ok, module files
|
||||
may not be found at compilation time though)
|
||||
|
||||
- CP2K_USE_VORI = OFF : detection is fine compilation might fail at linking time
|
||||
(investigating why)
|
||||
|
||||
- CP2K_USE_QUIP = OFF
|
||||
|
||||
- CP2K_USE_SPGLIB = ON : everything alright
|
||||
|
||||
- CP2K_USE_LIBXC = ON : everything is fine, use pkgconfig by default (ideally
|
||||
the library should be built with cmake, if so we can get rid off the
|
||||
FindLibxc.cmake)
|
||||
|
||||
- CP2K_USE_SPLA = OFF : enable spla off-loading capabilities (use cmake modules
|
||||
to detect it)
|
||||
|
||||
- CP2K_USE_METIS = OFF :
|
||||
|
||||
- CP2K_USE_LIBXSMM = ON : use libxsmm library for small matrices operations.
|
||||
detection based on pkg-config
|
||||
|
||||
- CP2K_USE_ACCEL = NONE, CUDA, HIP : enable gpu support
|
||||
|
||||
- CP2K_BLAS_VENDOR = MKL, SCI, OpenBLAS, FlexiBLAS, Armpl, auto : default is
|
||||
auto. cmake will search for the most common blas / lapack implementations. If
|
||||
possible indicate which implementation you are using.
|
||||
|
||||
- CP2K_SCALAPACK_VENDOR - MKL, SCI, GENERIC : similar to the option previous
|
||||
option but for scalapack
|
||||
|
||||
- CP2K_BLAS_THREADING = sequential, openmp, etc... : leave the default value (or
|
||||
use it at your own peril)
|
||||
|
||||
- CP2K_BLAS_INTERFACE = 32 bits, 64 bits : size of the integers for the matrices
|
||||
and vectors sizes. default 32 bits
|
||||
|
||||
- CP2K_DEV_OPTIONS = OFF : enable developer options. the main purpose is for
|
||||
debugging
|
||||
|
||||
- CP2K_USE_GRID_GPU = ON : turn on of gpu support for collocate integrate
|
||||
- CP2K_USE_PW_GPU = ON, turn on or off gpu fft support
|
||||
- CP2K_USE_DBM_GPU = ON turn on or off dbm gpu support
|
||||
|
||||
It is also possible to compile CP2K with GPU support namely CUDA or HIP. To do
|
||||
so, add `-DCP2K_USE_ACCEL=CUDA,HIP -DCP2K_WITH_GPU=gpu_arch` to the cmake
|
||||
command line.
|
||||
|
||||
While compiling CP2K with CUDA support should not pose problems (finding
|
||||
libcublas and libcufft might fail though with the nvidia hpc sdk), we should
|
||||
expect issues when compiling the hip support.
|
||||
|
||||
ROCM 5.0.x is known to have a bug in the cmake configuration files. It is
|
||||
possible to go around this but at the expense of time. The build system was not
|
||||
tested with ROCM 5.1.x but this version shows performance regression and should
|
||||
be avoided. The Jiting capabilities of ROCM 5.2.x do not work properly which
|
||||
affects DBCSR. It is highly recommended to update ROCM to the latest version to
|
||||
avoid all these issues. CP2K can be built with ROCM 5.2.x but GPU support in
|
||||
dbcsr should be tunred off otherwise a crash should be expected.
|
||||
|
||||
## Threading with blas and lapack
|
||||
|
||||
CP2K expect by default a single threaded version of blas and lapack. The option
|
||||
`-DCP2K_BLAS_THREADING` can change this behavior. Be careful when tweaking this
|
||||
specific option as many implementations of blas / lapack are easier threaded or
|
||||
(exclusive) sequential but not both. I think the only exception to this is MKL.
|
||||
Also note that CP2K dependencies will most likely have the same issue (COSMA
|
||||
with cray-libsci for instance)
|
||||
|
||||
## typical examples of cmake use
|
||||
|
||||
The following list gives several examples of cmake command lines. Just add
|
||||
`-DCP2K_USE_SIRIUS=ON` to add support of SIRIUS in cp2k
|
||||
|
||||
```shell cmake -DCP2K_INSTALL_PREFIX=/myprefix ..```
|
||||
|
||||
then
|
||||
|
||||
```shell make```
|
||||
|
||||
- MKL
|
||||
|
||||
the command line is
|
||||
|
||||
```shell cmake -DCP2K_INSTALL_PREFIX=/myprefix -DCP2K_BLAS_VENDOR=MKL
|
||||
-DCP2K_SCALAPACK_VENDOR=MKL ..```
|
||||
|
||||
- Cray environments (with cray-libsci)
|
||||
|
||||
```shell
|
||||
MPICC=cc MPICXX=CC cmake -DCP2K_INSTALL_PREFIX=/myprefix
|
||||
-DCP2K_BLAS_VENDOR=SCI -DCP2K_SCALAPACK_VENDOR=SCI .. ```
|
||||
|
||||
## CUDA / HIP
|
||||
|
||||
Let us consider the case where openblas and netlib scalapack are installed
|
||||
(openmpi or mpich)
|
||||
|
||||
```shell
|
||||
cmake -DCP2K_INSTALL_PREFIX=/myprefix -DCP2K_BLAS_VENDOR=openblas
|
||||
-DCP2K_SCALAPACK_VENDOR=GENERIC -DCP2K_USE_ACCEL=CUDA -DCP2K_WITH_GPU=A100 ..```
|
||||
|
||||
if HIP is needed than
|
||||
|
||||
```shell
|
||||
cmake -DCP2K_INSTALL_PREFIX=/myprefix -DCP2K_BLAS_VENDOR=openblas
|
||||
-DCP2K_SCALAPACK_VENDOR=GENERIC -DCP2K_USE_ACCEL=HIP -DCP2K_WITH_GPU=Mi250 ..```
|
||||
|
||||
## troubleshooting
|
||||
|
||||
This build system is relatevily stable and was tested on Cray, IBM, and redhat
|
||||
like distributions. However it is not perfect and problems will show up, that's
|
||||
why the two build systems will be available. We encourage the user to test the
|
||||
build system just reporting the output of 'cmake ..' is already beneficial.
|
||||
|
||||
The best way to report these problems is to open an issue including the cmake
|
||||
command line, error message, and operating systems.
|
||||
|
||||
What is known to fail sometimes
|
||||
|
||||
- Nvidia hpc sdk : The location of the cuda maths libraries has changed
|
||||
recently. While CUDA support will be detected, the cuda maths libraries may not.
|
||||
|
||||
- HIP : CMAKE support of ROCM is still under development and is known to fail
|
||||
from time to time. Update to ROCM 5.3.x or above to solve the issue.
|
||||
|
||||
- BLAS / LAPACK / SCALAPACK : use the options 'CP2K_BLAS_VENDOR' and
|
||||
'CP2K_SCALPACK_VENDOR' if you know that 'MKL' or 'SCI' (cray libsci) are
|
||||
present. '-DCP2k_BLAS_VENDOR=OpenBLAS' will also help cmake to find OpenBLAS if
|
||||
it is used. Detecting the scalapack library might also fail if the user
|
||||
environment is not properly set up.
|
||||
19
cmake/CheckCompilerSupport.cmake
Normal file
19
cmake/CheckCompilerSupport.cmake
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
include(CheckFortranSourceCompiles)
|
||||
|
||||
set(CHECK_PROGRAMS f2008-norm2.f90 f2008-block_construct.f90
|
||||
f2008-contiguous.f90 f95-reshape-order-allocatable.f90)
|
||||
|
||||
foreach(prog ${CHECK_PROGRAMS})
|
||||
get_filename_component(prog_ext ${prog} EXT) # get the src extension to pass
|
||||
# along
|
||||
get_filename_component(prog_name ${prog} NAME_WE)
|
||||
|
||||
file(READ "${CMAKE_CURRENT_LIST_DIR}/compiler-tests/${prog}" prog_src)
|
||||
CHECK_Fortran_SOURCE_COMPILES("${prog_src}" "${prog_name}" SRC_EXT
|
||||
"${prog_ext}")
|
||||
|
||||
if(NOT ${prog_name})
|
||||
message(
|
||||
FATAL_ERROR "Your compiler does not support all required F2008 features")
|
||||
endif()
|
||||
endforeach()
|
||||
182
cmake/CheckFortranSourceRuns.cmake
Normal file
182
cmake/CheckFortranSourceRuns.cmake
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
CheckFortranSourceRuns
|
||||
----------------------
|
||||
|
||||
Check if given Fortran source compiles and links into an executable and can
|
||||
subsequently be run.
|
||||
|
||||
.. command:: check_fortran_source_runs
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
check_fortran_source_runs(<code> <resultVar>
|
||||
[SRC_EXT <extension>])
|
||||
|
||||
Check that the source supplied in ``<code>`` can be compiled as a Fortran source
|
||||
file, linked as an executable and then run. The ``<code>`` must be a Fortran program
|
||||
containing at least an ``end`` statement--for example:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
check_fortran_source_runs("real :: x[*]; call co_sum(x); end" F2018coarrayOK)
|
||||
|
||||
This command can help avoid costly build processes when a compiler lacks support
|
||||
for a necessary feature, or a particular vendor library is not compatible with
|
||||
the Fortran compiler version being used. Some of these failures only occur at runtime
|
||||
instead of linktime, and a trivial runtime example can catch the issue before the
|
||||
main build process.
|
||||
|
||||
If the ``<code>`` could be built and run
|
||||
successfully, the internal cache variable specified by ``<resultVar>`` will
|
||||
be set to 1, otherwise it will be set to an value that evaluates to boolean
|
||||
false (e.g. an empty string or an error message).
|
||||
|
||||
By default, the test source file will be given a ``.F90`` file extension. The
|
||||
``SRC_EXT`` option can be used to override this with ``.<extension>`` instead.
|
||||
|
||||
The underlying check is performed by the :command:`try_run` command. The
|
||||
compile and link commands can be influenced by setting any of the following
|
||||
variables prior to calling ``check_fortran_source_runs()``:
|
||||
|
||||
``CMAKE_REQUIRED_FLAGS``
|
||||
Additional flags to pass to the compiler. Note that the contents of
|
||||
:variable:`CMAKE_Fortran_FLAGS <CMAKE_<LANG>_FLAGS>` and its associated
|
||||
configuration-specific variable are automatically added to the compiler
|
||||
command before the contents of ``CMAKE_REQUIRED_FLAGS``.
|
||||
|
||||
``CMAKE_REQUIRED_DEFINITIONS``
|
||||
A :ref:`;-list <CMake Language Lists>` of compiler definitions of the form
|
||||
``-DFOO`` or ``-DFOO=bar``. A definition for the name specified by
|
||||
``<resultVar>`` will also be added automatically.
|
||||
|
||||
``CMAKE_REQUIRED_INCLUDES``
|
||||
A :ref:`;-list <CMake Language Lists>` of header search paths to pass to
|
||||
the compiler. These will be the only header search paths used by
|
||||
``try_run()``, i.e. the contents of the :prop_dir:`INCLUDE_DIRECTORIES`
|
||||
directory property will be ignored.
|
||||
|
||||
``CMAKE_REQUIRED_LINK_OPTIONS``
|
||||
A :ref:`;-list <CMake Language Lists>` of options to add to the link
|
||||
command (see :command:`try_run` for further details).
|
||||
|
||||
``CMAKE_REQUIRED_LIBRARIES``
|
||||
A :ref:`;-list <CMake Language Lists>` of libraries to add to the link
|
||||
command. These can be the name of system libraries or they can be
|
||||
:ref:`Imported Targets <Imported Targets>` (see :command:`try_run` for
|
||||
further details).
|
||||
|
||||
``CMAKE_REQUIRED_QUIET``
|
||||
If this variable evaluates to a boolean true value, all status messages
|
||||
associated with the check will be suppressed.
|
||||
|
||||
The check is only performed once, with the result cached in the variable
|
||||
named by ``<resultVar>``. Every subsequent CMake run will re-use this cached
|
||||
value rather than performing the check again, even if the ``<code>`` changes.
|
||||
In order to force the check to be re-evaluated, the variable named by
|
||||
``<resultVar>`` must be manually removed from the cache.
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
include_guard(GLOBAL)
|
||||
|
||||
macro(CHECK_Fortran_SOURCE_RUNS SOURCE VAR)
|
||||
if(NOT DEFINED "${VAR}")
|
||||
set(_SRC_EXT)
|
||||
set(_key)
|
||||
foreach(arg ${ARGN})
|
||||
if("${arg}" MATCHES "^(SRC_EXT)$")
|
||||
set(_key "${arg}")
|
||||
elseif(_key)
|
||||
list(APPEND _${_key} "${arg}")
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown argument:\n ${arg}\n")
|
||||
endif()
|
||||
endforeach()
|
||||
if(NOT _SRC_EXT)
|
||||
set(_SRC_EXT F90)
|
||||
endif()
|
||||
if(CMAKE_REQUIRED_LINK_OPTIONS)
|
||||
set(CHECK_Fortran_SOURCE_COMPILES_ADD_LINK_OPTIONS
|
||||
LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
|
||||
else()
|
||||
set(CHECK_Fortran_SOURCE_COMPILES_ADD_LINK_OPTIONS)
|
||||
endif()
|
||||
if(CMAKE_REQUIRED_LIBRARIES)
|
||||
set(CHECK_Fortran_SOURCE_COMPILES_ADD_LIBRARIES
|
||||
LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
|
||||
else()
|
||||
set(CHECK_Fortran_SOURCE_COMPILES_ADD_LIBRARIES)
|
||||
endif()
|
||||
if(CMAKE_REQUIRED_INCLUDES)
|
||||
set(CHECK_Fortran_SOURCE_COMPILES_ADD_INCLUDES
|
||||
"-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
|
||||
else()
|
||||
set(CHECK_Fortran_SOURCE_COMPILES_ADD_INCLUDES)
|
||||
endif()
|
||||
file(WRITE
|
||||
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT}"
|
||||
"${SOURCE}\n")
|
||||
|
||||
if(NOT CMAKE_REQUIRED_QUIET)
|
||||
message(CHECK_START "Performing Test ${VAR}")
|
||||
endif()
|
||||
try_run(
|
||||
${VAR}_EXITCODE ${VAR}_COMPILED ${CMAKE_BINARY_DIR}
|
||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT}
|
||||
COMPILE_DEFINITIONS
|
||||
-D${VAR} ${CMAKE_REQUIRED_DEFINITIONS}
|
||||
${CHECK_Fortran_SOURCE_COMPILES_ADD_LINK_OPTIONS}
|
||||
${CHECK_Fortran_SOURCE_COMPILES_ADD_LIBRARIES}
|
||||
CMAKE_FLAGS
|
||||
-DCOMPILE_DEFINITIONS:STRING=${CMAKE_REQUIRED_FLAGS}
|
||||
-DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH}
|
||||
"${CHECK_Fortran_SOURCE_COMPILES_ADD_INCLUDES}"
|
||||
COMPILE_OUTPUT_VARIABLE OUTPUT
|
||||
RUN_OUTPUT_VARIABLE RUN_OUTPUT)
|
||||
|
||||
# if it did not compile make the return value fail code of 1
|
||||
if(NOT ${VAR}_COMPILED)
|
||||
set(${VAR}_EXITCODE 1)
|
||||
endif()
|
||||
# if the return value was 0 then it worked
|
||||
if("${${VAR}_EXITCODE}" EQUAL 0)
|
||||
set(${VAR}
|
||||
1
|
||||
CACHE INTERNAL "Test ${VAR}")
|
||||
if(NOT CMAKE_REQUIRED_QUIET)
|
||||
message(CHECK_PASS "Success")
|
||||
endif()
|
||||
file(
|
||||
APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
||||
"Performing Fortran SOURCE FILE Test ${VAR} succeeded with the following output:\n"
|
||||
"${OUTPUT}\n"
|
||||
"...and run output:\n"
|
||||
"${RUN_OUTPUT}\n"
|
||||
"Return value: ${${VAR}}\n"
|
||||
"Source file was:\n${SOURCE}\n")
|
||||
else()
|
||||
if(CMAKE_CROSSCOMPILING AND "${${VAR}_EXITCODE}" MATCHES "FAILED_TO_RUN")
|
||||
set(${VAR} "${${VAR}_EXITCODE}")
|
||||
else()
|
||||
set(${VAR}
|
||||
""
|
||||
CACHE INTERNAL "Test ${VAR}")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_REQUIRED_QUIET)
|
||||
message(CHECK_FAIL "Failed")
|
||||
endif()
|
||||
file(
|
||||
APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
||||
"Performing Fortran SOURCE FILE Test ${VAR} failed with the following output:\n"
|
||||
"${OUTPUT}\n"
|
||||
"...and run output:\n"
|
||||
"${RUN_OUTPUT}\n"
|
||||
"Return value: ${${VAR}_EXITCODE}\n"
|
||||
"Source file was:\n${SOURCE}\n")
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
123
cmake/CompilerConfiguration.cmake
Normal file
123
cmake/CompilerConfiguration.cmake
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
|
||||
set(CMAKE_Fortran_FLAGS
|
||||
"-ffree-line-length-512 -ffree-form -std=f2008ts -fimplicit-none -Werror=aliasing -Werror=ampersand -Werror=c-binding-type -Werror=intrinsic-shadow -Werror=intrinsics-std -Werror=tabs -Werror=target-lifetime -Werror=underflow -Werror=unused-but-set-variable -Werror=unused-variable -Werror=conversion -Werror=zerotrip -Wuninitialized -Wno-maybe-uninitialized -Wunused-parameter"
|
||||
)
|
||||
|
||||
if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER 10)
|
||||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch"
|
||||
)# gcc 10+ has this automatically
|
||||
endif()
|
||||
|
||||
set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -g -funroll-loops")
|
||||
set(CMAKE_Fortran_FLAGS_COVERAGE
|
||||
"-O0 -g --coverage -fno-omit-frame-pointer -fcheck=all -ffpe-trap=invalid,zero,overflow -fbacktrace -finit-real=snan -finit-integer=-42 -finit-derived -Werror=realloc-lhs -finline-matmul-limit=0"
|
||||
)
|
||||
set(CMAKE_Fortran_FLAGS_DEBUG
|
||||
"-O2 -ggdb -fno-omit-frame-pointer -fcheck=all -ffpe-trap=invalid,zero,overflow -fbacktrace -finit-real=snan -finit-integer=-42 -finit-derived -finline-matmul-limit=0 -fsanitize=undefined -fsanitize=address -fsanitize-recover=all -Wall -Wextra -Werror=realloc-lhs -Wno-error=array-temporaries -Wno-error=compare-reals -Wno-error=function-elimination -Wno-error=surprising"
|
||||
)
|
||||
if((NOT (USE_MPI)) OR (NOT ("${MPI_Fortran_LIBRARY_VERSION_STRING}" MATCHES
|
||||
"Open MPI")))
|
||||
set(CMAKE_Fortran_FLAGS_COVERAGE
|
||||
"${CMAKE_Fortran_FLAGS_COVERAGE} -fsanitize=leak")
|
||||
set(CMAKE_Fortran_FLAGS_DEBUG
|
||||
"${CMAKE_Fortran_FLAGS_DEBUG} -fsanitize=leak")
|
||||
endif()
|
||||
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
|
||||
set(CMAKE_Fortran_FLAGS "-free -stand=f18 -fpp -heap-arrays")
|
||||
set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -g")
|
||||
set(CMAKE_Fortran_FLAGS_DEBUG "-O2 -debug")
|
||||
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "PGI")
|
||||
set(CMAKE_Fortran_FLAGS "-Mfreeform -Mextend -Mallocatable=03"
|
||||
)# -Mallocatable=03: enable F2003+ assignment semantics
|
||||
set(CMAKE_Fortran_FLAGS_RELEASE "-fast")
|
||||
set(CMAKE_Fortran_FLAGS_DEBUG "-g")
|
||||
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "NAG")
|
||||
set(CMAKE_Fortran_FLAGS "-f2008 -free -Warn=reallocation -Warn=subnormal")
|
||||
set(CMAKE_Fortran_FLAGS_RELEASE "-O2")
|
||||
set(CMAKE_Fortran_FLAGS_DEBUG "-g -C")
|
||||
if(NOT OpenMP_FOUND)
|
||||
set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -gline"
|
||||
)# -gline is only supported without OpenMP
|
||||
set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -C=all"
|
||||
)# some checks are not available with OpenMP
|
||||
endif()
|
||||
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Cray")
|
||||
set(CMAKE_Fortran_FLAGS "-f free -M3105 -ME7212") # -M3105: hide a
|
||||
# false-positive warning
|
||||
# about modified loop
|
||||
# variables due to loop
|
||||
# fusing, promote warning
|
||||
# 7212 to an error
|
||||
set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -G2")
|
||||
set(CMAKE_Fortran_FLAGS_DEBUG "-G2")
|
||||
set(CMAKE_Fortran_MODOUT_FLAG "-ef") # override to get lower-case module file
|
||||
# names
|
||||
else()
|
||||
message(
|
||||
WARNING
|
||||
"\
|
||||
Unknown Fortran compiler, trying without any additional (optimization) flags.\n\
|
||||
You will most likely have to specify extra options for free-form Fortran 2008 for your compiler!\n\
|
||||
Please open an issue at https://github.com/cp2k/dbcsr/issues with the reported compiler name and the required flags."
|
||||
)
|
||||
message("-- CMAKE_Fortran_COMPILER_ID: " ${CMAKE_Fortran_COMPILER_ID})
|
||||
message("-- CMAKE_Fortran_COMPILER full path: " ${CMAKE_Fortran_COMPILER})
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O3 -g -funroll-loops -Wall")
|
||||
set(CMAKE_C_FLAGS_COVERAGE "-O0 -g --coverage -Wall")
|
||||
set(CMAKE_C_FLAGS_DEBUG
|
||||
"-O2 -ggdb -Wall -fsanitize=undefined -fsanitize=address -fsanitize-recover=all"
|
||||
)
|
||||
if((NOT (USE_MPI)) OR (NOT ("${MPI_Fortran_LIBRARY_VERSION_STRING}" MATCHES
|
||||
"Open MPI")))
|
||||
set(CMAKE_C_FLAGS_COVERAGE "${CMAKE_C_FLAGS_COVERAGE} -fsanitize=leak")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fsanitize=leak")
|
||||
endif()
|
||||
elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O3 -funroll-loops")
|
||||
set(CMAKE_C_FLAGS_COVERAGE "-O0 -g --coverage")
|
||||
set(CMAKE_C_FLAGS_DEBUG "-O0 -g")
|
||||
elseif(CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O3 -funroll-loops")
|
||||
set(CMAKE_C_FLAGS_COVERAGE "-O0 -g --coverage")
|
||||
set(CMAKE_C_FLAGS_DEBUG "-O0 -g")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_COVERAGE "-lgcov") # Apple's Clang needs an extra
|
||||
elseif(CMAKE_C_COMPILER_ID STREQUAL "Intel")
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O3 -g")
|
||||
set(CMAKE_C_FLAGS_DEBUG "-O0 -debug")
|
||||
elseif(CMAKE_C_COMPILER_ID STREQUAL "PGI")
|
||||
set(CMAKE_C_FLAGS_RELEASE "-fast")
|
||||
set(CMAKE_C_FLAGS_DEBUG "-g")
|
||||
elseif(CMAKE_C_COMPILER_ID STREQUAL "Cray")
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O3")
|
||||
set(CMAKE_C_FLAGS_DEBUG "-G2")
|
||||
if(CMAKE_C_COMPILER_VERSION VERSION_LESS 9)
|
||||
# prevent deallocation failures due to tcmalloc's free with glibc's
|
||||
# aligned_alloc, see https://bugzilla.redhat.com/show_bug.cgi?id=1569391
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -h system_alloc")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -h system_alloc")
|
||||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -h system_alloc")
|
||||
# since the detection of the implicitly linked libraries occurs before we
|
||||
# can intervene, filter them out again
|
||||
list(FILTER CMAKE_C_IMPLICIT_LINK_LIBRARIES EXCLUDE REGEX "tcmalloc")
|
||||
list(FILTER CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES EXCLUDE REGEX "tcmalloc")
|
||||
endif()
|
||||
# OpenACC support with CCE is EOL: causes
|
||||
# https://github.com/cp2k/dbcsr/issues/261 eventually check compiler version
|
||||
# (similar to -h system_alloc)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -hnoacc -h nomessage=1234")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -hnoacc -h nomessage=1234")
|
||||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -hnoacc -M1234")
|
||||
else()
|
||||
message(
|
||||
WARNING
|
||||
"\
|
||||
Unknown C++ compiler, trying without any additional (optimization) flags.\n\
|
||||
You may have to specify flags for C++11/14 support manually.\n\
|
||||
Please open an issue at https://github.com/cp2k/dbcsr/issues with the reported compiler name and the required flags."
|
||||
)
|
||||
message("-- CMAKE_C_COMPILER_ID: " ${CMAKE_C_COMPILER_ID})
|
||||
message("-- CMAKE_C_COMPILER full path: " ${CMAKE_C_COMPILER})
|
||||
endif()
|
||||
29
cmake/CustomTargets.cmake
Normal file
29
cmake/CustomTargets.cmake
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# =================================================================================================
|
||||
# LCOV - COVERAGE REPORTS GENERATION
|
||||
find_program(
|
||||
LCOV_EXE lcov
|
||||
DOC "path to the lcov executable (required to generate coverage reports)")
|
||||
|
||||
find_program(
|
||||
GENHTML_EXE genhtml
|
||||
DOC "path to the genhtml executable (required to generate HTML coverage reports)"
|
||||
)
|
||||
|
||||
add_custom_target(
|
||||
cov-info
|
||||
COMMAND
|
||||
"${LCOV_EXE}" --directory "${CMAKE_BINARY_DIR}" --base-dir
|
||||
"${CMAKE_SOURCE_DIR}" --no-external --capture --output-file coverage.info
|
||||
COMMAND "${LCOV_EXE}" --list coverage.info
|
||||
VERBATIM
|
||||
BYPRODUCTS coverage.info
|
||||
COMMENT "Generate coverage.info using lcov")
|
||||
|
||||
add_custom_target(
|
||||
cov-genhtml
|
||||
COMMAND "${GENHTML_EXE}" coverage.info --output-directory cov-html
|
||||
COMMENT
|
||||
"Generate a HTML-based coverage report using lcov in ${CMAKE_BINARY_DIR}/cov-html"
|
||||
VERBATIM) # Note: this directory will not be cleaned by `cmake --build .. --
|
||||
# clean`
|
||||
add_dependencies(cov-genhtml cov-info)
|
||||
70
cmake/FindArmpl.cmake
Normal file
70
cmake/FindArmpl.cmake
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
# --------------------------------------------------------------------------------------------------
|
||||
# CP2K: A general program to perform molecular dynamics simulations Copyright
|
||||
# 2000-2022 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(PkgConfig)
|
||||
|
||||
cp2k_set_default_paths(ARMPL "Armpl")
|
||||
|
||||
foreach(_var armpl_ilp64 armpl_lp64 armpl_ilp64_mp armpl_lp64_mp)
|
||||
string(TOUPPER ${_var} _var_up)
|
||||
cp2k_find_libraries(${_var_up} ${_var})
|
||||
endforeach()
|
||||
|
||||
cp2k_include_dirs(ARMPL "armpl.h")
|
||||
|
||||
# Check for 64bit Integer support
|
||||
if(CP2K_BLAS_INTERFACE MATCHES "64bits")
|
||||
set(CP2K_BLAS_armpl_LIB "armpl_ilp64")
|
||||
else()
|
||||
set(CP2K_BLAS_armpl_LIB "armpl_lp64")
|
||||
endif()
|
||||
|
||||
# Check for OpenMP support, VIA BLAS_VENDOR of Arm_mp or Arm_ipl64_mp
|
||||
if(CP2K_BLAS_THREADING MATCHES "openmp")
|
||||
string(APPEND CP2K_BLAS_armpl_LIB "_mp")
|
||||
endif()
|
||||
|
||||
# check if found
|
||||
find_package_handle_standard_args(
|
||||
Armpl REQUIRED_VARS CP2K_ARMPL_INCLUDE_DIRS CP2K_ARMPL_LP64_LIBRARIES
|
||||
CP2K_ARMPL_LP64_MP_LIBRARIES)
|
||||
|
||||
# add target to link against
|
||||
if(CP2K_ARMPL_LP64_FOUND AND NOT TARGET ARMPL::armpl)
|
||||
add_library(CP2K_ARMPL::armpl INTERFACE IMPORTED)
|
||||
foreach(_var armpl_ilp64 armpl_lp64 armpl_ilp64_mp armpl_lp64_mp)
|
||||
string(TOUPPER "CP2K_${_var}_LINK_LIBRARIES" _var_up)
|
||||
if(_var_up)
|
||||
add_library(CP2K_ARMPL::${_var} INTERFACE IMPORTED)
|
||||
set_property(TARGET ARMPL::${_var} PROPERTY INTERFACE_INCLUDE_DIRECTORIES
|
||||
${CP2K_ARMPL_INCLUDE_DIRS})
|
||||
set_property(TARGET ARMPL::${_var} PROPERTY INTERFACE_LINK_LIBRARIES
|
||||
" ${${_var_up}}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# check that what version of the library we want actually exists
|
||||
if(NOT TARGET CP2K_ARMPL::${CP2K_BLAS_armpl_LIB})
|
||||
message(
|
||||
FATAL
|
||||
"ARMPL installation is incomplete. Some of the components are missing.")
|
||||
endif()
|
||||
|
||||
# now define an alias to the target library
|
||||
add_library(CP2K_ARMPL::blas INTERFACE ARMPL::${CP2K_BLAS_armpl_LIB})
|
||||
|
||||
endif()
|
||||
|
||||
mark_as_advanced(CP2K_ARMPL_FOUND CP2K_ARMPL_LINK_LIBRARIES
|
||||
CP2K_ARMPL_INCLUDE_DIRS)
|
||||
36
cmake/FindAtlas.cmake
Normal file
36
cmake/FindAtlas.cmake
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
# --------------------------------------------------------------------------------------------------
|
||||
# CP2K: A general program to perform molecular dynamics simulations Copyright
|
||||
# 2000-2022 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(ATLAS "Atlas")
|
||||
|
||||
cp2k_find_libraries(ATLAS "atlas")
|
||||
cp2k_include_dirs(FFTW3 "cblas.h atlas/cblas.h")
|
||||
# check if found
|
||||
find_package_handle_standard_args(Atlas REQUIRED_VARS CP2K_ATLAS_INCLUDE_DIRS
|
||||
CP2K_ATLAS_LINK_LIBRARIES)
|
||||
|
||||
# add target to link against
|
||||
if(CP2K_ATLAS_FOUND AND NOT TARGET CP2K_ATLAS::atlas)
|
||||
if(NOT TARGET CP2K_ATLAS::atlas)
|
||||
add_library(CP2K_ATLAS::atlas INTERFACE IMPORTED)
|
||||
endif()
|
||||
set_property(TARGET CP2K_ATLAS::atlas PROPERTY INTERFACE_LINK_LIBRARIES
|
||||
${CP2K_ATLAS_LINK_LIBRARIES})
|
||||
set_property(TARGET CP2K_ATLAS::atlas PROPERTY INTERFACE_INCLUDE_DIRECTORIES
|
||||
${CP2K_ATLAS_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
# prevent clutter in cache
|
||||
mark_as_advanced(CP2K_ATLAS_FOUND CP2K_ATLAS_LINK_LIBRARIES
|
||||
CP2K_ATLAS_INCLUDE_DIRS)
|
||||
129
cmake/FindBlas.cmake
Normal file
129
cmake/FindBlas.cmake
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
# --------------------------------------------------------------------------------------------------
|
||||
# CP2K: A general program to perform molecular dynamics simulations Copyright
|
||||
# 2000-2022 CP2K developers group <https://cp2k.org>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# --------------------------------------------------------------------------------------------------
|
||||
|
||||
# Copyright (c) 2022- ETH Zurich
|
||||
#
|
||||
# authors : Mathieu Taillefumier
|
||||
|
||||
if(NOT
|
||||
(CMAKE_C_COMPILER_LOADED
|
||||
OR CMAKE_CXX_COMPILER_LOADED
|
||||
OR CMAKE_Fortran_COMPILER_LOADED))
|
||||
message(FATAL_ERROR "FindBLAS requires Fortran, C, or C++ to be enabled.")
|
||||
endif()
|
||||
|
||||
set(CP2K_BLAS_VENDOR_LIST
|
||||
"auto"
|
||||
"MKL"
|
||||
"OpenBLAS"
|
||||
"SCI"
|
||||
"GenericBLAS"
|
||||
"Armpl"
|
||||
"FlexiBLAS"
|
||||
"Atlas")
|
||||
|
||||
set(__BLAS_VENDOR_LIST
|
||||
"MKL"
|
||||
"OpenBLAS"
|
||||
"SCI"
|
||||
"GenericBLAS"
|
||||
"Armpl"
|
||||
"FlexiBLAS"
|
||||
"Atlas")
|
||||
|
||||
set(CP2K_BLAS_VENDOR
|
||||
"auto"
|
||||
CACHE STRING "Blas library for computations on host")
|
||||
set_property(CACHE CP2K_BLAS_VENDOR PROPERTY STRINGS ${CP2K_BLAS_VENDOR_LIST})
|
||||
|
||||
if(NOT ${CP2K_BLAS_VENDOR} IN_LIST CP2K_BLAS_VENDOR_LIST)
|
||||
message(FATAL_ERROR "Invalid Host BLAS backend")
|
||||
endif()
|
||||
|
||||
set(CP2K_BLAS_THREAD_LIST "sequential" "thread" "gnu-thread" "intel-thread"
|
||||
"tbb-thread" "openmp")
|
||||
|
||||
set(CP2K_BLAS_THREADING
|
||||
"sequential"
|
||||
CACHE STRING "threaded blas library")
|
||||
set_property(CACHE CP2K_BLAS_THREADING PROPERTY STRINGS
|
||||
${CP2K_BLAS_THREAD_LIST})
|
||||
|
||||
if(NOT ${CP2K_BLAS_THREADING} IN_LIST CP2K_BLAS_THREAD_LIST)
|
||||
message(FATAL_ERROR "Invalid threaded BLAS backend")
|
||||
endif()
|
||||
|
||||
set(CP2K_BLAS_INTERFACE_BITS_LIST "32bits" "64bits")
|
||||
set(CP2K_BLAS_INTERFACE
|
||||
"32bits"
|
||||
CACHE STRING
|
||||
"32 bits integers are used for indices, matrices and vectors sizes")
|
||||
set_property(CACHE CP2K_BLAS_INTERFACE
|
||||
PROPERTY STRINGS ${CP2K_BLAS_INTERFACE_BITS_LIST})
|
||||
|
||||
if(NOT ${CP2K_BLAS_INTERFACE} IN_LIST CP2K_BLAS_INTERFACE_BITS_LIST)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Invalid parameters. Blas and lapack can exist in two flavors 32 or 64 bits interfaces (relevant mostly for mkl)"
|
||||
)
|
||||
endif()
|
||||
|
||||
set(CP2K_BLAS_FOUND FALSE)
|
||||
|
||||
# first check for a specific implementation if requested
|
||||
|
||||
if(NOT CP2K_BLAS_VENDOR MATCHES "auto")
|
||||
find_package(${CP2K_BLAS_VENDOR} REQUIRED)
|
||||
if(TARGET CP2K_${CP2K_BLAS_VENDOR}::blas)
|
||||
get_target_property(CP2K_BLAS_INCLUDE_DIRS CP2K_${CP2K_BLAS_VENDOR}::blas
|
||||
INTERFACE_INCLUDE_DIRECTORIES)
|
||||
get_target_property(CP2K_BLAS_LINK_LIBRARIES CP2K_${CP2K_BLAS_VENDOR}::blas
|
||||
INTERFACE_LINK_LIBRARIES)
|
||||
set(CP2K_BLAS_FOUND TRUE)
|
||||
endif()
|
||||
else()
|
||||
# search for any blas implementation
|
||||
foreach(_libs ${__BLAS_VENDOR_LIST})
|
||||
# i exclude the first item of the list
|
||||
find_package(${_libs})
|
||||
if(TARGET CP2K_${_libs}::blas)
|
||||
get_target_property(CP2K_BLAS_INCLUDE_DIRS CP2K_${_libs}::blas
|
||||
INTERFACE_INCLUDE_DIRECTORIES)
|
||||
get_target_property(CP2K_BLAS_LINK_LIBRARIES CP2K_${_libs}::blas
|
||||
INTERFACE_LINK_LIBRARIES)
|
||||
set(CP2K_BLAS_VENDOR "${_libs}")
|
||||
set(CP2K_BLAS_FOUND TRUE)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(CP2K_BLAS_INCLUDE_DIRS)
|
||||
find_package_handle_standard_args(
|
||||
Blas REQUIRED_VARS CP2K_BLAS_LINK_LIBRARIES CP2K_BLAS_INCLUDE_DIRS
|
||||
CP2K_BLAS_VENDOR)
|
||||
else()
|
||||
find_package_handle_standard_args(Blas REQUIRED_VARS CP2K_BLAS_LINK_LIBRARIES
|
||||
CP2K_BLAS_VENDOR)
|
||||
endif()
|
||||
|
||||
if(NOT TARGET CP2K_BLAS::blas)
|
||||
add_library(CP2K_BLAS::blas INTERFACE IMPORTED)
|
||||
endif()
|
||||
|
||||
set_target_properties(CP2K_BLAS::blas PROPERTIES INTERFACE_LINK_LIBRARIES
|
||||
"${CP2K_BLAS_LINK_LIBRARIES}")
|
||||
|
||||
if(CP2K_BLAS_INCLUDE_DIRS)
|
||||
set_target_properties(CP2K_BLAS::blas PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${CP2K_BLAS_INCLUDE_DIRS}")
|
||||
endif()
|
||||
|
||||
mark_as_advanced(CP2K_BLAS_INCLUDE_DIRS)
|
||||
mark_as_advanced(CP2K_BLAS_LINK_LIBRARIES)
|
||||
mark_as_advanced(CP2K_BLAS_VENDOR)
|
||||
mark_as_advanced(CP2K_BLAS_FOUND)
|
||||
60
cmake/FindBlis.cmake
Normal file
60
cmake/FindBlis.cmake
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
# --------------------------------------------------------------------------------------------------
|
||||
# CP2K: A general program to perform molecular dynamics simulations Copyright
|
||||
# 2000-2022 CP2K developers group <https://cp2k.org>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# --------------------------------------------------------------------------------------------------
|
||||
|
||||
# Copyright (c) 2022- ETH Zurich
|
||||
#
|
||||
# authors : Mathieu Taillefumier
|
||||
|
||||
find_package(PkgConfig)
|
||||
include(cp2k_utils)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
cp2k_set_default_paths(BLIS "BLIS")
|
||||
|
||||
if(DEFINED AOCL_ROOT)
|
||||
list(CP2K_BLIS_PREFIX "${AOCL_ROOT}" "$ENV{AOCL_ROOT}")
|
||||
endif()
|
||||
|
||||
# one day blis will have a pkg-config file
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(BLIS IMPORTED_TARGET GLOBAL blis)
|
||||
endif()
|
||||
|
||||
if(NOT CP2K_BLIS_FOUND)
|
||||
cp2k_find_libraries(BLIS "blis")
|
||||
endif()
|
||||
|
||||
if(NOT CP2K_BLIS_INCLUDE_DIRS)
|
||||
cp2k_include_dirs(BLIS "blis.h")
|
||||
endif()
|
||||
|
||||
# check if found
|
||||
if(CP2K_BLIS_INCLUDE_DIRS)
|
||||
find_package_handle_standard_args(
|
||||
BLIS REQUIRED_VARS CP2K_BLIS_FOUND CP2K_BLIS_INCLUDE_DIRS
|
||||
CP2K_BLIS_LINK_LIBRARIES)
|
||||
else()
|
||||
find_package_handle_standard_args(BLIS REQUIRED_VARS CP2K_BLIS_FOUND
|
||||
CP2K_BLIS_LINK_LIBRARIES)
|
||||
endif()
|
||||
|
||||
# add target to link against
|
||||
if(CP2K_BLIS_FOUND AND NOT TARGET CP2K_BLIS::blis)
|
||||
add_library(CP2K_BLIS::blis INTERFACE IMPORTED)
|
||||
endif()
|
||||
|
||||
set_property(TARGET CP2K_BLIS::blis PROPERTY INTERFACE_LINK_LIBRARIES
|
||||
${CP2K_BLIS_LINK_LIBRARIES})
|
||||
|
||||
if(BLIS_INCLUDE_DIRS)
|
||||
set_property(TARGET CP2K_BLIS::blis PROPERTY INTERFACE_INCLUDE_DIRECTORIES
|
||||
${CP2K_BLIS_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
# prevent clutter in cache
|
||||
mark_as_advanced(CP2K_BLIS_FOUND CP2K_BLIS_LINK_LIBRARIES
|
||||
CP2K_BLIS_INCLUDE_DIRS)
|
||||
49
cmake/FindElpa.cmake
Normal file
49
cmake/FindElpa.cmake
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
# --------------------------------------------------------------------------------------------------
|
||||
# CP2K: A general program to perform molecular dynamics simulations Copyright
|
||||
# 2000-2022 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(ELPA "Elpa")
|
||||
|
||||
find_package(PkgConfig)
|
||||
|
||||
if(PKG_CONFIG_FOUND)
|
||||
if(CP2K_ENABLE_ELPA_OPENMP_SUPPORT)
|
||||
pkg_search_module(CP2K_ELPA REQUIRED IMPORTED_TARGET GLOBAL elpa_openmp)
|
||||
else()
|
||||
pkg_search_module(CP2K_ELPA REQUIRED IMPORTED_TARGET GLOBAL elpa)
|
||||
endif()
|
||||
else()
|
||||
message(
|
||||
"ELPA : We need pkg-config to get all information about the elpa library")
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args(Elpa "DEFAULT_MSG" CP2K_ELPA_LINK_LIBRARIES
|
||||
CP2K_ELPA_INCLUDE_DIRS)
|
||||
|
||||
if(CP2K_ELPA_FOUND)
|
||||
if(NOT TARGET CP2K_elpa::elpa)
|
||||
add_library(CP2K_ELPA::elpa INTERFACE IMPORTED)
|
||||
endif()
|
||||
set_target_properties(
|
||||
CP2K_ELPA::elpa PROPERTIES INTERFACE_LINK_LIBRARIES
|
||||
"${CP2K_ELPA_LINK_LIBRARIES}")
|
||||
if(CP2K_ELPA_INCLUDE_DIRS)
|
||||
set_target_properties(
|
||||
CP2K_ELPA::elpa
|
||||
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${CP2K_ELPA_INCLUDE_DIRS};${CP2K_ELPA_INCLUDE_DIRS}/modules")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
mark_as_advanced(CP2K_ELPA_FOUND CP2K_ELPA_LINK_LIBRARIES
|
||||
CP2K_ELPA_INCLUDE_DIRS)
|
||||
98
cmake/FindFftw.cmake
Normal file
98
cmake/FindFftw.cmake
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
# --------------------------------------------------------------------------------------------------
|
||||
# CP2K: A general program to perform molecular dynamics simulations Copyright
|
||||
# 2000-2022 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(FFTW3 "Fftw")
|
||||
|
||||
# Check if we can use PkgConfig
|
||||
find_package(PkgConfig)
|
||||
|
||||
# First try with pkg
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_search_module(CP2K_FFTW3 fftw3)
|
||||
pkg_search_module(CP2K_FFTW3F fftw3f)
|
||||
pkg_search_module(CP2K_FFTW3L fftw3l)
|
||||
pkg_search_module(CP2K_FFTW3Q fftw3q)
|
||||
endif()
|
||||
|
||||
foreach(_lib fftw3 fftw3f fftw3l fftw3q)
|
||||
if(NOT CP2K_${__lib_up}_FOUND)
|
||||
cp2k_find_libraries("${__lib_up}" ${_lib})
|
||||
endif()
|
||||
|
||||
# OMP variant
|
||||
foreach(_subtype "mpi" "omp" "threads")
|
||||
string(TOUPPER "${_lib}_${_subtype}" _sub_lib)
|
||||
cp2k_find_libraries("${_sub_lib}" ${_lib}_${_subtype})
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
if(NOT CP2K_FFTW3_INCLUDE_DIRS)
|
||||
cp2k_include_dirs(FFTW3 "fftw3.h;fftw3/fftw3.h")
|
||||
endif()
|
||||
|
||||
if(CP2K_FFTW3_INCLUDE_DIRS)
|
||||
find_package_handle_standard_args(Fftw DEFAULT_MSG CP2K_FFTW3_INCLUDE_DIRS
|
||||
CP2K_FFTW3_LINK_LIBRARIES)
|
||||
else()
|
||||
find_package_handle_standard_args(Fftw DEFAULT_MSG CP2K_FFTW3_LINK_LIBRARIES)
|
||||
endif()
|
||||
|
||||
foreach(lib_name "fftw3" "fftw3l" "fftw3q" "fftw3f")
|
||||
string(TOUPPER "${lib_name}" __lib_name_up)
|
||||
|
||||
if(CP2K_${__lib_name_up}_FOUND AND NOT TARGET CP2K_FFTW3::${lib_name})
|
||||
add_library(CP2K_FFTW3::${lib_name} INTERFACE IMPORTED)
|
||||
# we do not recheck if the libraries are found when pkg_config is
|
||||
# successful.
|
||||
set_target_properties(
|
||||
CP2K_FFTW3::${lib_name}
|
||||
PROPERTIES INTERFACE_LINK_LIBRARIES
|
||||
"${CP2K_${__lib_name_up}_LINK_LIBRARIES}")
|
||||
|
||||
if(CP2K_FFTW3_INCLUDE_DIRS)
|
||||
set_target_properties(
|
||||
CP2K_FFTW3::${lib_name} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${CP2K_FFTW3_INCLUDE_DIRS}")
|
||||
endif()
|
||||
|
||||
foreach(sub_type "threads" "mpi" "omp")
|
||||
string(TOUPPER "${lib_name}_${sub_type}" __libs)
|
||||
if(CP2K_${__libs}_FOUND AND NOT TARGET
|
||||
CP2K_FFTW3::${lib_name}_${sub_type})
|
||||
add_library(CP2K_FFTW3::${lib_name}_${sub_type} INTERFACE IMPORTED)
|
||||
set_target_properties(
|
||||
CP2K_FFTW3::${lib_name}_${sub_type}
|
||||
PROPERTIES INTERFACE_LINK_LIBRARIES
|
||||
"${CP2K_${__libs}_LINK_LIBRARIES}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(CP2K_FFTW3_FOUND ON)
|
||||
mark_as_advanced(
|
||||
CP2K_FFTW3_FOUND
|
||||
CP2K_FFTW3_PREFIX
|
||||
CP2K_FFTW3_INCLUDE_DIRS
|
||||
CP2K_FFTW3_MPI
|
||||
FFTW3_OMP
|
||||
CP2K_FFTW3_THREADS
|
||||
CP2K_FFTW3Q_OMP
|
||||
CP2K_FFTW3Q_THREADS
|
||||
CP2K_FFTW3F_MPI
|
||||
CP2K_FFTW3_OMP
|
||||
CP2K_FFTW3F_THREADS
|
||||
CP2K_FFTW3L_MPI
|
||||
CP2K_FFTW3L_OMP
|
||||
CP2K_FFTW3L_THREADS)
|
||||
57
cmake/FindFlexiBLAS.cmake
Normal file
57
cmake/FindFlexiBLAS.cmake
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
# --------------------------------------------------------------------------------------------------
|
||||
# CP2K: A general program to perform molecular dynamics simulations Copyright
|
||||
# 2000-2022 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(FLEXIBLAS "FlexiBLAS")
|
||||
|
||||
# try first with pkg-config
|
||||
find_package(PkgConfig QUIET)
|
||||
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(CP2K_FLEXIBLAS IMPORTED_TARGET GLOBAL flexiblas)
|
||||
endif()
|
||||
|
||||
# manual; search
|
||||
if(NOT CP2K_FLEXIBLAS_FOUND)
|
||||
cp2k_find_libraries(FLEXIBLAS "flexiblas")
|
||||
endif()
|
||||
|
||||
# search for include directories anyway
|
||||
if(NOT CP2K_FLEXIBLAS_INCLUDE_DIRS)
|
||||
cp2k_include_dirs(FFTW3 "flexiblas.h")
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args(
|
||||
FlexiBLAS DEFAULT_MSG CP2K_FLEXIBLAS_INCLUDE_DIRS
|
||||
CP2K_FLEXIBLAS_LINK_LIBRARIES)
|
||||
|
||||
if(NOT CP2K_FLEXIBLAS_FOUND)
|
||||
set(CP2K_BLAS_VENDOR "FlexiBLAS")
|
||||
endif()
|
||||
|
||||
if(CP2K_FLEXIBLAS_FOUND AND NOT TARGET CP2K_FlexiBLAS::flexiblas)
|
||||
add_library(CP2K_FlexiBLAS::flexiblas INTERFACE IMPORTED)
|
||||
add_library(CP2K_FlexiBLAS::blas ALIAS CP2K_FlexiBLAS::flexiblas)
|
||||
set_target_properties(
|
||||
CP2K_FlexiBLAS::flexiblas PROPERTIES INTERFACE_LINK_LIBRARIES
|
||||
"${CP2K_FLEXIBLAS_LINK_LIBRARIES}")
|
||||
if(CP2K_FLEXIBLAS_INCLUDE_DIRS)
|
||||
set_target_properties(
|
||||
CP2K_FlexiBLAS::flexiblas PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${CP2K_FLEXIBLAS_INCLUDE_DIRS}")
|
||||
endif()
|
||||
set(CP2K_BLAS_VENDOR "flexiblas")
|
||||
endif()
|
||||
|
||||
mark_as_advanced(CP2K_FLEXIBLAS_FOUND CP2K_FLEXIBLAS_INCLUDE_DIRS
|
||||
CP2K_FLEXIBLAS_LINK_LIBRARIES CP2K_BLAS_VENDOR)
|
||||
51
cmake/FindGenericBLAS.cmake
Normal file
51
cmake/FindGenericBLAS.cmake
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
# --------------------------------------------------------------------------------------------------
|
||||
# CP2K: A general program to perform molecular dynamics simulations Copyright
|
||||
# 2000-2022 CP2K developers group <https://cp2k.org>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# --------------------------------------------------------------------------------------------------
|
||||
|
||||
# Copyright (c) 2022- ETH Zurich
|
||||
#
|
||||
# authors : Mathieu Taillefumier
|
||||
|
||||
if(NOT POLICY CMP0074)
|
||||
set(_GenericBLAS_PATHS ${GenericBLAS_ROOT} $ENV{GenericBLAS_ROOT})
|
||||
endif()
|
||||
|
||||
find_library(
|
||||
GenericBLAS_LIBRARIES
|
||||
NAMES "blas"
|
||||
HINTS ${_GenericBLAS_PATHS})
|
||||
find_library(
|
||||
# optinally look for cblas library - not required
|
||||
GenericBLAS_CBLAS_LIBRARIES
|
||||
NAMES "cblas"
|
||||
HINTS ${_GenericBLAS_PATHS})
|
||||
find_path(
|
||||
GenericBLAS_INCLUDE_DIRS
|
||||
NAMES "cblas.h"
|
||||
HINTS ${_GenericBLAS_PATHS})
|
||||
|
||||
# check if found
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(
|
||||
GenericBLAS REQUIRED_VARS GenericBLAS_INCLUDE_DIRS GenericBLAS_LIBRARIES)
|
||||
if(GenericBLAS_CBLAS_LIBRARIES)
|
||||
list(APPEND GenericBLAS_LIBRARIES ${GenericBLAS_CBLAS_LIBRARIES})
|
||||
endif()
|
||||
|
||||
# add target to link against
|
||||
if(GenericBLAS_FOUND)
|
||||
if(NOT TARGET GenericBLAS::blas)
|
||||
add_library(GenericBLAS::blas INTERFACE IMPORTED)
|
||||
endif()
|
||||
set_property(TARGET GenericBLAS::blas PROPERTY INTERFACE_LINK_LIBRARIES
|
||||
${GenericBLAS_LIBRARIES})
|
||||
set_property(TARGET GenericBLAS::blas PROPERTY INTERFACE_INCLUDE_DIRECTORIES
|
||||
${GenericBLAS_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
# prevent clutter in cache
|
||||
mark_as_advanced(GenericBLAS_FOUND GenericBLAS_LIBRARIES
|
||||
GenericBLAS_INCLUDE_DIRS GenericBLAS_CBLAS_LIBRARIES)
|
||||
71
cmake/FindLapack.cmake
Normal file
71
cmake/FindLapack.cmake
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
# --------------------------------------------------------------------------------------------------
|
||||
# CP2K: A general program to perform molecular dynamics simulations Copyright
|
||||
# 2000-2022 CP2K developers group <https://cp2k.org>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# --------------------------------------------------------------------------------------------------
|
||||
|
||||
# Copyright (c) 2022- ETH Zurich
|
||||
#
|
||||
# authors : Mathieu Taillefumier
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
# check for blas first. Most of the vendor libraries bundle lapack and blas in
|
||||
# the same library. (MKL, and OPENBLAS do)
|
||||
|
||||
find_package(PkgConfig)
|
||||
find_package(Blas REQUIRED)
|
||||
|
||||
if(CP2K_BLAS_FOUND)
|
||||
# LAPACK in the Intel MKL 10+ library?
|
||||
if(CP2K_BLAS_VENDOR MATCHES "MKL"
|
||||
OR CP2K_BLAS_VENDOR MATCHES "OpenBLAS"
|
||||
OR CP2K_BLAS_VENDOR MATCHES "Arm"
|
||||
OR CP2K_BLAS_VENDOR MATCHES "SCI"
|
||||
OR CP2K_BLAS_VENDOR MATCHES "FlexiBLAS")
|
||||
# we just need to create the interface that's all
|
||||
set(CP2K_LAPACK_FOUND TRUE)
|
||||
get_target_property(CP2K_LAPACK_INCLUDE_DIRS CP2K_BLAS::blas
|
||||
INTERFACE_INCLUDE_DIRECTORIES)
|
||||
get_target_property(CP2K_LAPACK_LIBRARIES CP2K_BLAS::blas
|
||||
INTERFACE_LINK_LIBRARIES)
|
||||
else()
|
||||
|
||||
# we might get lucky to find a pkgconfig package for lapack (fedora provides
|
||||
# one for instance)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(CP2K_LAPACK lapack)
|
||||
endif()
|
||||
|
||||
if(NOT CP2K_LAPACK_FOUND)
|
||||
find_library(
|
||||
CP2K_LAPACK_LIBRARIES
|
||||
NAMES "lapack" "lapack64"
|
||||
PATH_SUFFIXES "openblas" "openblas64" "openblas-pthread"
|
||||
"openblas-openmp" "lib" "lib64"
|
||||
NO_DEFAULT_PATH)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# check if found
|
||||
find_package_handle_standard_args(Lapack REQUIRED_VARS CP2K_LAPACK_LIBRARIES)
|
||||
|
||||
if(CP2K_LAPACK_FOUND)
|
||||
if(NOT TARGET CP2K_LAPACK::lapack)
|
||||
add_library(CP2K_LAPACK::lapack INTERFACE IMPORTED)
|
||||
set_property(TARGET CP2K_LAPACK::lapack PROPERTY INTERFACE_LINK_LIBRARIES
|
||||
${CP2K_LAPACK_LIBRARIES})
|
||||
if(CP2K_LAPACK_INCLUDE_DIRS)
|
||||
set_property(
|
||||
TARGET CP2K_LAPACK::lapack PROPERTY INTERFACE_INCLUDE_DIRECTORIES
|
||||
${CP2K_LAPACK_INCLUDE_DIRS})
|
||||
endif()
|
||||
add_library(CP2K_LAPACK::LAPACK ALIAS CP2K_LAPACK::lapack)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# prevent clutter in cache
|
||||
mark_as_advanced(CP2K_LAPACK_FOUND CP2K_LAPACK_LIBRARIES
|
||||
CP2K_LAPACK_INCLUDE_DIRS)
|
||||
53
cmake/FindLibSPG.cmake
Normal file
53
cmake/FindLibSPG.cmake
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
# --------------------------------------------------------------------------------------------------
|
||||
# CP2K: A general program to perform molecular dynamics simulations Copyright
|
||||
# 2000-2022 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(PkgConfig)
|
||||
|
||||
cp2k_set_default_paths(LIBSPG "LibSPG")
|
||||
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(CP2K_LIBSPG IMPORTED_TARGET spglib)
|
||||
endif()
|
||||
|
||||
if(NOT CP2K_LIBSPG_FOUND)
|
||||
cp2k_find_libraries(LIBSPG "symspg")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED CP2K_LIBSPG_INCLUDE_DIRS)
|
||||
cp2k_include_dirs(LIBXSMM "spglib.h")
|
||||
endif()
|
||||
|
||||
if(CP2K_LIBSPG_INCLUDE_DIRS)
|
||||
find_package_handle_standard_args(
|
||||
LibSPG DEFAULT_MSG CP2K_LIBSPG_LINK_LIBRARIES CP2K_LIBSPG_INCLUDE_DIRS)
|
||||
else()
|
||||
find_package_handle_standard_args(LibSPG DEFAULT_MSG
|
||||
CP2K_LIBSPG_LINK_LIBRARIES)
|
||||
endif()
|
||||
|
||||
if(CP2K_LIBSPG_FOUND AND NOT TARGET CP2K_LIBSPG::libspg)
|
||||
add_library(CP2K_LIBSPG::libspg INTERFACE IMPORTED)
|
||||
set_target_properties(
|
||||
CP2K_LIBSPG::libspg PROPERTIES INTERFACE_LINK_LIBRARIES
|
||||
"${CP2K_LIBSPG_LINK_LIBRARIES}")
|
||||
if(CP2K_LIBSPG_INCLUDE_DIRS)
|
||||
set_target_properties(
|
||||
CP2K_LIBSPG::libspg PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${CP2K_LIBSPG_INCLUDE_DIRS}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
mark_as_advanced(CP2K_LIBSPG_LINK_LIBRARIES)
|
||||
mark_as_advanced(CP2K_LIBSPG_INCLUDE_DIRS)
|
||||
mark_as_advanced(CP2K_LIBSPG_FOUND)
|
||||
48
cmake/FindLibVDWXC.cmake
Normal file
48
cmake/FindLibVDWXC.cmake
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
# --------------------------------------------------------------------------------------------------
|
||||
# CP2K: A general program to perform molecular dynamics simulations Copyright
|
||||
# 2000-2022 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(CheckSymbolExists)
|
||||
include(cp2k_utils)
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
cp2k_set_default_paths(LIBVDWXC "LibVDWXC")
|
||||
|
||||
pkg_search_module(CP2K_LIBVDWXC libvdwxc>=${LibVDWXC_FIND_VERSION})
|
||||
|
||||
if(NOT CP2K_LIBVDWXC_FOUND)
|
||||
cp2k_find_libraries(LIBVDWXC "vdwxc")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED CP2K_LIBVDWXC_INCLUDE_DIRS)
|
||||
cp2k_include_dirs(LIBVDWXC "vdwxc.h;vdwxc_mpi.h")
|
||||
endif()
|
||||
|
||||
# try linking in C (C++ fails because vdwxc_mpi.h includes mpi.h inside extern
|
||||
# "C"{...})
|
||||
set(CMAKE_REQUIRED_LIBRARIES "${CP2K_LIBVDWXC_LINK_LIBRARIES}")
|
||||
check_symbol_exists(vdwxc_init_mpi "${CP2K_LIBVDWXC_INCLUDE_DIRS}/vdwxc_mpi.h"
|
||||
HAVE_LIBVDW_WITH_MPI)
|
||||
|
||||
find_package_handle_standard_args(
|
||||
LibVDWXC DEFAULT_MSG CP2K_LIBVDWXC_LINK_LIBRARIES CP2K_LIBVDWXC_INCLUDE_DIRS)
|
||||
|
||||
if(LibVDWXC_FOUND AND NOT TARGET CP2K_libvdwxc::libvdwxc)
|
||||
add_library(CP2K_libvdwxc::libvdwxc INTERFACE IMPORTED)
|
||||
set_target_properties(
|
||||
CP2K_libvdwxc::libvdwxc
|
||||
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CP2K_LIBVDWXC_INCLUDE_DIRS}"
|
||||
INTERFACE_LINK_LIBRARIES "${CP2K_LIBVDWXC_LINK_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
mark_as_advanced(CP2K_LIBVDWXC_INCLUDE_DIRS CP2K_LIBVDWXC_LINK_LIBRARIES
|
||||
CP2K_LIBVDWXC_FOUND)
|
||||
40
cmake/FindLibVORI.cmake
Normal file
40
cmake/FindLibVORI.cmake
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
# --------------------------------------------------------------------------------------------------
|
||||
# CP2K: A general program to perform molecular dynamics simulations Copyright
|
||||
# 2000-2022 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(LIBVORI "LibVORI")
|
||||
cp2k_find_libraries(LIBVORI vori)
|
||||
# cp2k_include_dirs(LIBVORI )
|
||||
|
||||
if(CP2K_LIBVORI_INCLUDE_DIRS)
|
||||
find_package_handle_standard_args(
|
||||
LibVORI DEFAULT_MSG CP2K_LIBVORI_LINK_LIBRARIES CP2K_LIBVORI_INCLUDE_DIRS)
|
||||
else()
|
||||
find_package_handle_standard_args(LibVORI DEFAULT_MSG
|
||||
CP2K_LIBVORI_LINK_LIBRARIES)
|
||||
endif()
|
||||
|
||||
if(NOT TARGET CP2K_VORI::vori)
|
||||
add_library(CP2K_VORI::vori INTERFACE IMPORTED)
|
||||
set_target_properties(
|
||||
CP2K_VORI::vori PROPERTIES INTERFACE_LINK_LIBRARIES
|
||||
"${CP2K_LIBVORI_LINK_LIBRARIES}")
|
||||
if(CP2K_LIBVORI_INCLUDE_DIRS)
|
||||
set_target_properties(
|
||||
CP2K_VORI::vori PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${CP2K_LIBVORI_INCLUDE_DIRS}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
mark_as_advanced(CP2K_LIBVORI_PREFIX CP2K_LIBVORI_INCLUDE_DIRS
|
||||
CP2K_LIBVORI_LINK_LIBRARIES CP2K_LIBVORI_LIBRARIES)
|
||||
67
cmake/FindLibXC.cmake
Normal file
67
cmake/FindLibXC.cmake
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
# --------------------------------------------------------------------------------------------------
|
||||
# CP2K: A general program to perform molecular dynamics simulations Copyright
|
||||
# 2000-2022 CP2K developers group <https://cp2k.org>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# --------------------------------------------------------------------------------------------------
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
include(cp2k_utils)
|
||||
|
||||
cp2k_set_default_paths(LIBXC "LibXC")
|
||||
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(
|
||||
CP2K_LIBXC
|
||||
REQUIRED
|
||||
IMPORTED_TARGET
|
||||
GLOBAL
|
||||
libxc>=${LibXC_FIND_VERSION}
|
||||
libxcf03
|
||||
libxcf90)
|
||||
endif()
|
||||
|
||||
if(NOT CP2K_LIBXC_FOUND)
|
||||
foreach(_var xc xcf03 xcf90)
|
||||
string(TOUPPER LIB${_var} _var_up)
|
||||
cp2k_find_libraries(${_var_up} ${_var})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(NOT CP2K_LIBXC_INCLUDE_DIRS)
|
||||
cp2k_include_dirs(LIBXC "xc.h;libxc/xc.h")
|
||||
endif()
|
||||
|
||||
if(CP2K_LIBXC_INCLUDE_DIRS)
|
||||
find_package_handle_standard_args(
|
||||
LibXC DEFAULT_MSG CP2K_LIBXC_FOUND CP2K_LIBXC_LINK_LIBRARIES
|
||||
CP2K_LIBXC_INCLUDE_DIRS)
|
||||
else()
|
||||
find_package_handle_standard_args(LibXC DEFAULT_MSG CP2K_LIBXC_FOUND
|
||||
CP2K_LIBXC_LINK_LIBRARIES)
|
||||
endif()
|
||||
if(CP2K_LIBXC_FOUND AND NOT TARGET CP2K_CP2K_Libxc::xc)
|
||||
add_library(CP2K_Libxc::xc INTERFACE IMPORTED)
|
||||
if(LIBXC_INCLUDE_DIRS)
|
||||
set_target_properties(
|
||||
CP2K_Libxc::xc
|
||||
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CP2K_LIBXC_INCLUDE_DIRS}"
|
||||
INTERFACE_LINK_LIBRARIES "${CP2K_LIBXC_LINK_LIBRARIES}")
|
||||
else()
|
||||
set_target_properties(CP2K_Libxc::xc PROPERTIES INTERFACE_LINK_LIBRARIES
|
||||
"${CP2K_LIBXC_LIBRARIES}")
|
||||
endif()
|
||||
add_library(CP2K_Libxc::xcf90 INTERFACE IMPORTED)
|
||||
set_target_properties(
|
||||
CP2K_Libxc::xcf90 PROPERTIES INTERFACE_LINK_LIBRARIES
|
||||
"${CP2K_LIBXCF90_LINK_LIBRARIES}")
|
||||
add_library(CP2K_Libxc::xcf03 INTERFACE IMPORTED)
|
||||
set_target_properties(
|
||||
CP2K_Libxc::xcf03 PROPERTIES INTERFACE_LINK_LIBRARIES
|
||||
"${CP2K_LIBXCF03_LINK_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
mark_as_advanced(
|
||||
CP2K_LIBXC_FOUND CP2K_LIBXC_LINK_LIBRARIES CP2K_LIBXC_INCLUDE_DIRS
|
||||
CP2K_LIBXCF03_LINK_LIBRARIES CP2K_LIBXCF90_LINK_LIBRARIES)
|
||||
77
cmake/FindLibXSMM.cmake
Normal file
77
cmake/FindLibXSMM.cmake
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
# --------------------------------------------------------------------------------------------------
|
||||
# CP2K: A general program to perform molecular dynamics simulations Copyright
|
||||
# 2000-2022 CP2K developers group <https://cp2k.org>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# --------------------------------------------------------------------------------------------------
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
include(cp2k_utils)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
cp2k_set_default_paths(LIBXSMM "LibXSMM")
|
||||
set(CP2K_LIBXSMMEXT_PREFIX "${CP2K_LIBXSMM_PREFIX}")
|
||||
set(CP2K_LIBXSMMF_PREFIX "${CP2K_LIBXSMM_PREFIX}")
|
||||
set(CP2K_LIBXSMMNOBLAS_PREFIX "${CP2K_LIBXSMM_PREFIX}")
|
||||
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(CP2K_LIBXSMM IMPORTED_TARGET GLOBAL libxsmm)
|
||||
pkg_check_modules(CP2K_LIBXSMMEXT IMPORTED_TARGET GLOBAL libxsmmext)
|
||||
pkg_check_modules(CP2K_LIBXSMMF IMPORTED_TARGET GLOBAL libxsmmf)
|
||||
pkg_check_modules(CP2K_LIBXSMMNOBLAS IMPORTED_TARGET GLOBAL libxsmmnoblas)
|
||||
endif()
|
||||
|
||||
foreach(__lib libxsmm libxsmmf libxsmmext libxsmmnoblas)
|
||||
string(TOUPPER "${__lib}" __lib_search_up)
|
||||
if(NOT CP2K_${__lib_search_up}_FOUND)
|
||||
cp2k_find_libraries(${__lib_search_up} ${__lib})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(NOT CP2K_LIBXSMM_INCLUDE_DIRS)
|
||||
cp2k_include_dirs(LIBXSMM "libxsmm.h")
|
||||
|
||||
# force the include directory
|
||||
if(NOT CP2K_LIBXSMM_INCLUDE_DIRS)
|
||||
set(CP2K_LIBXSMM_INCLUDE_DIRS "${CP2K_LIBXSMM_PREFIX}/include")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CP2K_LIBXSMM_INCLUDE_DIRS)
|
||||
find_package_handle_standard_args(
|
||||
LibXSMM
|
||||
DEFAULT_MSG
|
||||
CP2K_LIBXSMM_INCLUDE_DIRS
|
||||
CP2K_LIBXSMMNOBLAS_LINK_LIBRARIES
|
||||
CP2K_LIBXSMMEXT_LINK_LIBRARIES
|
||||
CP2K_LIBXSMMF_LINK_LIBRARIES
|
||||
CP2K_LIBXSMM_LINK_LIBRARIES)
|
||||
else()
|
||||
find_package_handle_standard_args(
|
||||
LibXSMM DEFAULT_MSG CP2K_LIBXSMMNOBLAS_LINK_LIBRARIES
|
||||
CP2K_LIBXSMMEXT_LINK_LIBRARIES CP2K_LIBXSMMF_LINK_LIBRARIES
|
||||
CP2K_LIBXSMM_LINK_LIBRARIES)
|
||||
endif()
|
||||
|
||||
if(NOT TARGET CP2K_LibXSMM::libxsmm)
|
||||
foreach(__lib libxsmm libxsmmf libxsmmext libxsmmnoblas)
|
||||
string(TOUPPER "CP2K_${__lib}" __lib_search_up)
|
||||
if(${__lib_search_up}_FOUND AND NOT TARGET CP2K_LibXSMM::${__lib})
|
||||
add_library(CP2K_LibXSMM::${__lib} INTERFACE IMPORTED)
|
||||
set_target_properties(
|
||||
CP2K_LibXSMM::${__lib}
|
||||
PROPERTIES INTERFACE_LINK_LIBRARIES
|
||||
"${${__lib_search_up}_LINK_LIBRARIES}")
|
||||
set_target_properties(
|
||||
CP2K_LibXSMM::${__lib}
|
||||
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${CP2K_LIBXSMM_INCLUDE_DIRS};${CP2K_LIBXSMM_PREFIX}/include"
|
||||
)
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
mark_as_advanced(
|
||||
CP2K_LIBXSMM_INCLUDE_DIRS CP2K_LIBXSMMNOBLAS_LINK_LIBRARIES
|
||||
CP2K_LIBXSMMEXT_LINK_LIBRARIES CP2K_LIBXSMMF_LINK_LIBRARIES
|
||||
CP2K_LIBXSMM_LINK_LIBRARIES)
|
||||
56
cmake/FindLibint2.cmake
Normal file
56
cmake/FindLibint2.cmake
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
# --------------------------------------------------------------------------------------------------
|
||||
# CP2K: A general program to perform molecular dynamics simulations Copyright
|
||||
# 2000-2022 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(LIBINT2 "Libint2")
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(CP2K_LIBINT2 IMPORTED_TARGET GLOBAL libint2)
|
||||
endif()
|
||||
|
||||
if(NOT CP2K_LIBINT2_FOUND)
|
||||
cp2k_find_libraries(LIBINT2 int2)
|
||||
endif()
|
||||
|
||||
if(NOT CP2K_LIBINT2_INCLUDE_DIRS)
|
||||
cp2k_include_dirs(LIBINT2 "libint2.h;libint2/atom.h")
|
||||
endif()
|
||||
|
||||
find_file(
|
||||
CP2K_LIBINT2_MOD_FILE
|
||||
NAMES "libint_f.mod"
|
||||
PATHS "${CP2K_LIBINT2_PREFIX}/include;${CP2K_LIBINT2_PREFIX}/include/libint2")
|
||||
|
||||
if(NOT CP2K_LIBINT2_MOD_FILE)
|
||||
message(FATAL_ERROR "Libint2 : Fortran support is missing")
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args(
|
||||
Libint2 CP2K_LIBINT2_FOUND CP2K_LIBINT2_INCLUDE_DIRS
|
||||
CP2K_LIBINT2_LINK_LIBRARIES)
|
||||
|
||||
if(CP2K_LIBINT2_FOUND AND NOT TARGET CP2K_Libint2::int2)
|
||||
add_library(CP2K_Libint2::int2 INTERFACE IMPORTED)
|
||||
set_target_properties(
|
||||
CP2K_Libint2::int2
|
||||
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${CP2K_LIBINT2_INCLUDE_DIRS};${CP2K_LIBINT2_PREFIX}/include")
|
||||
set_target_properties(
|
||||
CP2K_Libint2::int2 PROPERTIES INTERFACE_LINK_LIBRARIES
|
||||
${CP2K_LIBINT2_LINK_LIBRARIES})
|
||||
endif()
|
||||
|
||||
mark_as_advanced(CP2K_LIBINT2_FOUND CP2K_LIBINT2_LINK_LIBRARIES
|
||||
CP2K_LIBINT2_INCLUDE_DIRS)
|
||||
459
cmake/FindMKL.cmake
Normal file
459
cmake/FindMKL.cmake
Normal file
|
|
@ -0,0 +1,459 @@
|
|||
#
|
||||
# CMake recipes https://github.com/eth-cscs/cmake-recipes
|
||||
#
|
||||
# Copyright (c) 2018-2019, ETH Zurich BSD 3-Clause License. All rights reserved.
|
||||
#
|
||||
# Author: Teodor Nikolov (teodor.nikolov22@gmail.com)
|
||||
#
|
||||
#[=======================================================================[.rst:
|
||||
FindMKL
|
||||
-------
|
||||
|
||||
The following conventions are used:
|
||||
|
||||
intel / INTEL - Bindings for everything except GNU Fortran
|
||||
gf / GF - GNU Fortran bindings
|
||||
seq / SEQ - sequential MKL
|
||||
omp / OMP - threaded MKL with OpenMP back end
|
||||
tbb / TBB - threaded MKL with TBB back end
|
||||
32bit / 32BIT - MKL 32 bit integer interface (used most often)
|
||||
64bit / 64BIT - MKL 64 bit integer interface
|
||||
mpich / MPICH - MPICH / IntelMPI BLACS back end
|
||||
ompi / OMPI - OpenMPI BLACS back end
|
||||
st / ST - static libraries
|
||||
dyn / DYN - dynamic libraries
|
||||
|
||||
The module attempts to define a target for each MKL configuration. The
|
||||
configuration will not be available if there are missing library files or a
|
||||
missing dependency.
|
||||
|
||||
MKL Link line advisor:
|
||||
https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor
|
||||
|
||||
Note: Mixing GCC and Intel OpenMP backends is a bad idea.
|
||||
|
||||
Search variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
``MKLROOT``
|
||||
Environment variable set to MKL's root directory
|
||||
|
||||
``MKL_ROOT``
|
||||
CMake variable set to MKL's root directory
|
||||
|
||||
Example usage
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
To Find MKL:
|
||||
|
||||
find_package(MKL REQUIRED)
|
||||
|
||||
To check if target is available:
|
||||
|
||||
if (TARGET MKL::scalapack_mpich_intel_32bit_omp_dyn)
|
||||
...
|
||||
endif()
|
||||
|
||||
To link to an available target (see list below):
|
||||
|
||||
target_link_libraries(... MKL::scalapack_mpich_intel_32bit_omp_dyn)
|
||||
|
||||
Note: dependencies are handled for you (MPI, OpenMP, ...)
|
||||
|
||||
the target MKL::blas, MKL::MKL, MKL::lapack also include all necessary libraries
|
||||
for linking.
|
||||
MKL::MKL is also used by the cmake module provided by intel.
|
||||
|
||||
MKL::scalapack_link gives all libraries needed for scalapack.
|
||||
|
||||
Imported targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
MKL (BLAS, LAPACK, FFT) targets:
|
||||
|
||||
MKL::[gf|intel]_[32bit|64bit]_[seq|omp|tbb]_[st|dyn] e.g.
|
||||
|
||||
MKL::mkl_intel_32bit_omp_dyn
|
||||
|
||||
BLACS targets:
|
||||
|
||||
MKL::blacs_[mpich|ompi]_[gf|intel]_[32bit|64bit]_[seq|omp|tbb]_[st|dyn] e.g.
|
||||
|
||||
MKL::blacs_intel_mpich_32bit_seq_st
|
||||
|
||||
|
||||
ScaLAPACK targets:
|
||||
|
||||
MKL::scalapack_[mpich|ompi]_[gf|intel]_[32bit|64bit]_[seq|omp|tbb]_[st|dyn] e.g.
|
||||
|
||||
MKL::scalapack_mpich_intel_64bit_omp_dyn
|
||||
|
||||
Result variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
MKL_FOUND
|
||||
|
||||
Not supported
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
- F95 interfaces
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
# Copyright (c) 2022- ETH Zurich
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this
|
||||
# list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
if(NOT
|
||||
(CMAKE_C_COMPILER_LOADED
|
||||
OR CMAKE_CXX_COMPILER_LOADED
|
||||
OR CMAKE_Fortran_COMPILER_LOADED))
|
||||
message(FATAL_ERROR "FindMKL requires Fortran, C, or C++ to be enabled.")
|
||||
endif()
|
||||
|
||||
# Dependencies
|
||||
#
|
||||
find_package(Threads)
|
||||
find_package(MPI COMPONENTS CXX C Fortran)
|
||||
find_package(OpenMP COMPONENTS CXX C Fortran)
|
||||
|
||||
# If MKL_ROOT is not set, set it via the env variable MKLROOT.
|
||||
#
|
||||
if(NOT DEFINED MKL_ROOT)
|
||||
set(MKL_ROOT
|
||||
$ENV{MKLROOT}
|
||||
CACHE PATH "MKL's root directory.")
|
||||
endif()
|
||||
|
||||
# Determine MKL's library folder
|
||||
#
|
||||
set(_mkl_libpath_suffix "intel64")
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4) # 32 bit
|
||||
set(_mkl_libpath_suffix "ia32")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND _mkl_libpath_suffix_list ${_mkl_libpath_suffix})
|
||||
string(APPEND _mkl_libpath_suffix "_win")
|
||||
list(APPEND _mkl_libpath_suffix_list ${_mkl_libpath_suffix})
|
||||
set(_mkl_libname_prefix "")
|
||||
set(_mkl_shared_lib "_dll.lib")
|
||||
set(_mkl_static_lib ".lib")
|
||||
elseif(APPLE)
|
||||
list(APPEND _mkl_libpath_suffix_list ${_mkl_libpath_suffix})
|
||||
string(APPEND _mkl_libpath_suffix "_mac")
|
||||
list(APPEND _mkl_libpath_suffix_list ${_mkl_libpath_suffix})
|
||||
set(_mkl_libname_prefix "lib")
|
||||
set(_mkl_shared_lib ".dylib")
|
||||
set(_mkl_static_lib ".a")
|
||||
else() # LINUX
|
||||
list(APPEND _mkl_libpath_suffix_list ${_mkl_libpath_suffix})
|
||||
string(APPEND _mkl_libpath_suffix "_lin")
|
||||
list(APPEND _mkl_libpath_suffix_list ${_mkl_libpath_suffix})
|
||||
set(_mkl_libname_prefix "lib")
|
||||
set(_mkl_shared_lib ".so")
|
||||
set(_mkl_static_lib ".a")
|
||||
endif()
|
||||
set(_mkl_search_paths "${MKL_ROOT}" "${MKL_ROOT}/lib" "${MKL_ROOT}/mkl/lib"
|
||||
"${MKL_ROOT}/compiler/lib")
|
||||
|
||||
# Functions: finds both static and shared MKL libraries
|
||||
#
|
||||
function(__mkl_find_library _varname _libname)
|
||||
find_library(
|
||||
${_varname}_DYN
|
||||
NAMES ${_mkl_libname_prefix}${_libname}${_mkl_shared_lib}
|
||||
HINTS ${_mkl_search_paths}
|
||||
PATH_SUFFIXES ${_mkl_libpath_suffix_list})
|
||||
mark_as_advanced(${_varname}_DYN)
|
||||
find_library(
|
||||
${_varname}_ST
|
||||
NAMES ${_mkl_libname_prefix}${_libname}${_mkl_static_lib}
|
||||
HINTS ${_mkl_search_paths}
|
||||
PATH_SUFFIXES ${_mkl_libpath_suffix_list})
|
||||
mark_as_advanced(${_varname}_ST)
|
||||
endfunction()
|
||||
|
||||
# Find MKL headers
|
||||
#
|
||||
find_path(CP2K_MKL_INCLUDE_DIRS mkl.h HINTS ${MKL_ROOT}/include
|
||||
${MKL_ROOT}/mkl/include)
|
||||
mark_as_advanced(CP2K_MKL_INCLUDE_DIRS)
|
||||
|
||||
# Group flags for static libraries on Linux (GNU, PGI, ICC -> same linker)
|
||||
#
|
||||
if(UNIX AND NOT APPLE)
|
||||
set(_mkl_linker_pre_flags_ST "-Wl,--start-group")
|
||||
set(_mkl_linker_post_flags_ST "-Wl,--end-group")
|
||||
endif()
|
||||
|
||||
# Core MKL
|
||||
#
|
||||
__mkl_find_library(MKL_CORE_LIB mkl_core)
|
||||
|
||||
# Interface
|
||||
#
|
||||
__mkl_find_library(MKL_INTERFACE_INTEL_32BIT_LIB mkl_intel_lp64)
|
||||
__mkl_find_library(MKL_INTERFACE_INTEL_64BIT_LIB mkl_intel_ilp64)
|
||||
if(NOT APPLE
|
||||
AND CMAKE_Fortran_COMPILER_LOADED
|
||||
AND CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
|
||||
__mkl_find_library(MKL_INTERFACE_GF_32BIT_LIB mkl_gf_lp64)
|
||||
__mkl_find_library(MKL_INTERFACE_GF_64BIT_LIB mkl_gf_ilp64)
|
||||
endif()
|
||||
|
||||
# Threading
|
||||
#
|
||||
__mkl_find_library(MKL_SEQ_LIB mkl_sequential)
|
||||
if(NOT APPLE
|
||||
AND (CMAKE_C_COMPILER_ID STREQUAL "GNU"
|
||||
OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
|
||||
OR CMAKE_Fortran_COMPILER_ID STREQUAL "GNU"))
|
||||
__mkl_find_library(MKL_OMP_LIB mkl_gnu_thread)
|
||||
else()
|
||||
__mkl_find_library(MKL_OMP_LIB mkl_intel_thread)
|
||||
endif()
|
||||
__mkl_find_library(MKL_TBB_LIB mkl_tbb_thread)
|
||||
|
||||
# BLACS
|
||||
#
|
||||
if(APPLE)
|
||||
__mkl_find_library(MKL_BLACS_MPICH_32BIT_LIB mkl_blacs_mpich_lp64)
|
||||
__mkl_find_library(MKL_BLACS_MPICH_64BIT_LIB mkl_blacs_mpich_ilp64)
|
||||
else()
|
||||
__mkl_find_library(MKL_BLACS_MPICH_32BIT_LIB mkl_blacs_intelmpi_lp64)
|
||||
__mkl_find_library(MKL_BLACS_MPICH_64BIT_LIB mkl_blacs_intelmpi_ilp64)
|
||||
endif()
|
||||
__mkl_find_library(MKL_BLACS_OMPI_32BIT_LIB mkl_blacs_openmpi_lp64)
|
||||
__mkl_find_library(MKL_BLACS_OMPI_64BIT_LIB mkl_blacs_openmpi_ilp64)
|
||||
|
||||
# ScaLAPACK
|
||||
#
|
||||
__mkl_find_library(MKL_SCALAPACK_32BIT_LIB mkl_scalapack_lp64)
|
||||
__mkl_find_library(MKL_SCALAPACK_64BIT_LIB mkl_scalapack_ilp64)
|
||||
|
||||
# Check if core libs were found
|
||||
#
|
||||
find_package_handle_standard_args(MKL REQUIRED_VARS CP2K_MKL_INCLUDE_DIRS
|
||||
Threads_FOUND)
|
||||
|
||||
# Sequential has no threading dependency. There is currently no TBB module
|
||||
# shipped with CMake. The dependency is not accounted for. (FIXME)
|
||||
#
|
||||
set(_mkl_dep_found_SEQ TRUE)
|
||||
set(_mkl_dep_found_TBB TRUE)
|
||||
if(TARGET OpenMP::OpenMP_CXX)
|
||||
set(_mkl_dep_OMP ${OpenMP_CXX_LIBRARIES})
|
||||
set(_mkl_dep_found_OMP TRUE)
|
||||
endif()
|
||||
|
||||
# Define all blas, blacs and scalapack
|
||||
#
|
||||
foreach(_libtype "ST" "DYN")
|
||||
set(_mkl_core_lib ${MKL_CORE_LIB_${_libtype}})
|
||||
foreach(_bits "32BIT" "64BIT")
|
||||
set(_mkl_scalapack_lib ${MKL_SCALAPACK_${_bits}_LIB_${_libtype}})
|
||||
foreach(_iface "INTEL" "GF")
|
||||
set(_mkl_interface_lib
|
||||
${MKL_INTERFACE_${_iface}_${_bits}_LIB_${_libtype}})
|
||||
foreach(_threading "SEQ" "OMP" "TBB")
|
||||
set(_mkl_threading_lib ${MKL_${_threading}_LIB_${_libtype}})
|
||||
|
||||
string(TOLOWER "${_iface}_${_bits}_${_threading}_${_libtype}"
|
||||
_tgt_config)
|
||||
set(_mkl_tgt CP2K_MKL::${_tgt_config})
|
||||
|
||||
if(MKL_FOUND
|
||||
AND _mkl_interface_lib
|
||||
AND _mkl_threading_lib
|
||||
AND _mkl_core_lib
|
||||
AND _mkl_dep_found_${_threading}
|
||||
AND NOT TARGET ${_mkl_tgt})
|
||||
set(_mkl_libs
|
||||
"${_mkl_linker_pre_flags_${_threading}}"
|
||||
"${_mkl_interface_lib}"
|
||||
"${_mkl_threading_lib}"
|
||||
"${_mkl_core_lib}"
|
||||
"${_mkl_linker_post_flags_${_threading}}"
|
||||
"${_mkl_dep_${_threading}}"
|
||||
"Threads::Threads")
|
||||
add_library(${_mkl_tgt} INTERFACE IMPORTED)
|
||||
set_target_properties(
|
||||
${_mkl_tgt}
|
||||
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CP2K_MKL_INCLUDE_DIRS}"
|
||||
INTERFACE_LINK_LIBRARIES "${_mkl_libs}")
|
||||
endif()
|
||||
|
||||
foreach(_mpi_impl "MPICH" "OMPI")
|
||||
set(_mkl_blacs_lib ${MKL_BLACS_${_mpi_impl}_${_bits}_LIB_${_libtype}})
|
||||
|
||||
string(
|
||||
TOLOWER "${_mpi_impl}_${_iface}_${_bits}_${_threading}_${_libtype}"
|
||||
_tgt_config)
|
||||
|
||||
set(_scalapack_tgt CP2K_MKL::scalapack_${_tgt_config})
|
||||
|
||||
if(_mkl_blacs_lib
|
||||
AND TARGET ${_mkl_tgt}
|
||||
AND TARGET MPI::MPI_CXX
|
||||
AND NOT TARGET CP2K_MKL::blacs_${_tgt_config})
|
||||
set(_blacs_libs
|
||||
"${_mkl_linker_pre_flags_${_libtype}}"
|
||||
"${_mkl_interface_lib}"
|
||||
"${_mkl_threading_lib}"
|
||||
"${_mkl_core_lib}"
|
||||
"${_mkl_blacs_lib}"
|
||||
"${_mkl_linker_post_flags_${_libtype}}"
|
||||
"MPI::MPI_CXX"
|
||||
"${_mkl_dep_${_threading}}"
|
||||
"Threads::Threads")
|
||||
add_library(CP2K_MKL::blacs_${_tgt_config} INTERFACE IMPORTED)
|
||||
set_target_properties(
|
||||
CP2K_MKL::blacs_${_tgt_config}
|
||||
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${CP2K_MKL_INCLUDE_DIRS}" INTERFACE_LINK_LIBRARIES
|
||||
"${_mkl_blacs_lib}")
|
||||
endif()
|
||||
|
||||
if(_mkl_scalapack_lib AND NOT TARGET
|
||||
CP2K_MKL::scalapack_${_tgt_config})
|
||||
set(_scalapack_libs "${_mkl_scalapack_lib}" "${_blacs_tgt}")
|
||||
add_library(CP2K_MKL::scalapack_${_tgt_config} INTERFACE IMPORTED)
|
||||
set_target_properties(
|
||||
CP2K_MKL::scalapack_${_tgt_config}
|
||||
PROPERTIES INTERFACE_LINK_LIBRARIES "${_scalapack_libs}")
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
endforeach()
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
if(MKL_FOUND AND NOT TARGET CP2K_MKL::blas)
|
||||
# BLAS in the Intel MKL 10+ library?
|
||||
|
||||
# the findMKL package finds all possible combination and define target for
|
||||
# each of them we just need to find which compiler we use, mpi etc...
|
||||
|
||||
if(CMAKE_Fortran_COMPILER_LOADED
|
||||
AND CMAKE_Fortran_COMPILER_ID STREQUAL "GNU"
|
||||
AND NOT APPLE)
|
||||
set(BLAS_mkl_INTFACE "gf")
|
||||
else()
|
||||
set(BLAS_mkl_INTFACE "intel")
|
||||
endif()
|
||||
|
||||
if(CP2K_BLAS_THREADING MATCHES "thread" OR CP2K_BLAS_THREADING MATCHES
|
||||
"gnu-thread")
|
||||
set(BLAS_mkl_thread__ "omp")
|
||||
endif()
|
||||
|
||||
if(CP2K_BLAS_THREADING MATCHES "sequential")
|
||||
set(BLAS_mkl_thread__ "seq")
|
||||
endif()
|
||||
|
||||
if(CP2K_BLAS_THREADING MATCHES "intel-thread")
|
||||
set(BLAS_mkl_thread__ "intel")
|
||||
endif()
|
||||
|
||||
if(CP2K_BLAS_THREADING MATCHES "tbb")
|
||||
set(BLAS_mkl_thread__ "tbb")
|
||||
endif()
|
||||
|
||||
if(CP2K_BLAS_INTERFACE MATCHES "64bits")
|
||||
set(BLAS_mkl_ILP_MODE "64bit")
|
||||
else()
|
||||
set(BLAS_mkl_ILP_MODE "32bit")
|
||||
endif()
|
||||
|
||||
get_target_property(
|
||||
MKL_BLAS_INCLUDE_DIRS
|
||||
CP2K_MKL::${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE}_${BLAS_mkl_thread__}_dyn
|
||||
INTERFACE_INCLUDE_DIRECTORIES)
|
||||
get_target_property(
|
||||
MKL_BLAS_LIBRARIES
|
||||
CP2K_MKL::${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE}_${BLAS_mkl_thread__}_dyn
|
||||
INTERFACE_LINK_LIBRARIES)
|
||||
if(NOT TARGET CP2K_MKL::blas)
|
||||
add_library(CP2K_MKL::blas INTERFACE IMPORTED)
|
||||
add_library(CP2K_MKL::MKL INTERFACE IMPORTED)
|
||||
# create a empty lapack
|
||||
add_library(CP2K_MKL::lapack INTERFACE IMPORTED)
|
||||
endif()
|
||||
set_target_properties(
|
||||
CP2K_MKL::blas
|
||||
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CP2K_MKL_INCLUDE_DIRS}"
|
||||
INTERFACE_LINK_LIBRARIES "${MKL_BLAS_LIBRARIES}")
|
||||
set_target_properties(
|
||||
CP2K_MKL::MKL
|
||||
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CP2K_MKL_INCLUDE_DIRS}"
|
||||
INTERFACE_LINK_LIBRARIES "${MKL_BLAS_LIBRARIES}")
|
||||
|
||||
if("${MPI_Fortran_LIBRARY_VERSION_STRING}" MATCHES "Open MPI")
|
||||
set(__mkl_mpi_ver_ "ompi")
|
||||
else()
|
||||
set(__mkl_mpi_ver_ "mpich")
|
||||
endif()
|
||||
|
||||
get_target_property(
|
||||
__mkl_scalapack_inc
|
||||
CP2K_MKL::scalapack_${__mkl_mpi_ver_}_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE}_${BLAS_mkl_thread__}_dyn
|
||||
INTERFACE_INCLUDE_DIRECTORIES)
|
||||
get_target_property(
|
||||
__mkl_scalapack_lib
|
||||
CP2K_MKL::scalapack_${__mkl_mpi_ver_}_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE}_${BLAS_mkl_thread__}_dyn
|
||||
INTERFACE_LINK_LIBRARIES)
|
||||
get_target_property(
|
||||
__mkl_blacs_inc
|
||||
CP2K_MKL::blacs_${__mkl_mpi_ver_}_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE}_${BLAS_mkl_thread__}_dyn
|
||||
INTERFACE_INCLUDE_DIRECTORIES)
|
||||
get_target_property(
|
||||
__mkl_blacs_lib
|
||||
CP2K_MKL::blacs_${__mkl_mpi_ver_}_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE}_${BLAS_mkl_thread__}_dyn
|
||||
INTERFACE_LINK_LIBRARIES)
|
||||
if(NOT TARGET CP2K_MKL::scalapack_link)
|
||||
add_library(CP2K_MKL::scalapack_link INTERFACE IMPORTED)
|
||||
set_target_properties(
|
||||
CP2K_MKL::scalapack_link
|
||||
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${__mkl_scalapack_inc}"
|
||||
INTERFACE_LINK_LIBRARIES
|
||||
"${__mkl_scalapack_lib};${__mkl_blacs_lib}")
|
||||
endif()
|
||||
unset(BLAS_mkl_ILP_MODE)
|
||||
unset(BLAS_mkl_INTFACE)
|
||||
unset(BLAS_mkl_thread__)
|
||||
unset(BLAS_mkl_OMP)
|
||||
unset(BLAS_mkl_OS_NAME)
|
||||
unset(__mkl_blacs_lib)
|
||||
unset(__mkl_blacs_inc)
|
||||
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_NKL_FOUND)
|
||||
mark_as_advanced(CP2K_MKL_SCALAPACK_VENDOR)
|
||||
endif()
|
||||
31
cmake/FindMetis.cmake
Normal file
31
cmake/FindMetis.cmake
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# --------------------------------------------------------------------------------------------------
|
||||
# CP2K: A general program to perform molecular dynamics simulations Copyright
|
||||
# 2000-2022 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(METIS "Metis")
|
||||
|
||||
cp2k_find_libraries(FLEXIBLAS "metis")
|
||||
cp2k_include_dirs(FFTW3 "metis.h")
|
||||
|
||||
# check that METIS has been found
|
||||
# ---------------------------------
|
||||
find_package_handle_standard_args(Metis DEFAULT_MSG CP2K_METIS_LINK_LIBRARIES
|
||||
CP2K_METIS_INCLUDE_DIRS CP2K_METIS_FOUND)
|
||||
|
||||
if(CP2K_METIS_FOUND AND NOT TARGET CP2K_metis::metis)
|
||||
add_library(CP2K_metis::metis INTERFACE IMPORTED)
|
||||
set_target_properties(
|
||||
CP2K_metis::metis
|
||||
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CP2K_METIS_INCLUDE_DIRS}"
|
||||
INTERFACE_LINK_LIBRARIES "${CP2K_METIS_LINK_LIBRARIES}")
|
||||
endif()
|
||||
59
cmake/FindOpenBLAS.cmake
Normal file
59
cmake/FindOpenBLAS.cmake
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
# --------------------------------------------------------------------------------------------------
|
||||
# CP2K: A general program to perform molecular dynamics simulations Copyright
|
||||
# 2000-2022 CP2K developers group <https://cp2k.org>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# --------------------------------------------------------------------------------------------------
|
||||
|
||||
# Copyright (c) 2022- ETH Zurich
|
||||
#
|
||||
# authors : Mathieu Taillefumier
|
||||
|
||||
include(cp2k_utils)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package(PkgConfig)
|
||||
|
||||
cp2k_set_default_paths(OPENBLAS "OpenBLAS")
|
||||
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(CP2K_OPENBLAS openblas)
|
||||
endif()
|
||||
|
||||
# try the openblas module of openblas library Maybe we are lucky it is installed
|
||||
# find_package(OPENBLAS QUIET)
|
||||
|
||||
if(NOT CP2K_OPENBLAS_FOUND)
|
||||
cp2k_find_libraries(OPENBLAS "openblas")
|
||||
cp2k_find_libraries(OPENBLAS64 "openblas64")
|
||||
cp2k_find_libraries(OPENBLAS_THREADS "openblas_threads")
|
||||
cp2k_find_libraries(OPENBLAS_THREADS "openblas64_threads")
|
||||
cp2k_find_libraries(OPENBLAS_THREADS "openblas64_omp")
|
||||
cp2k_find_libraries(OPENBLAS_THREADS "openblas_omp")
|
||||
endif()
|
||||
|
||||
cp2k_include_dirs(OPENBLAS "cblas.h")
|
||||
|
||||
# check if found
|
||||
find_package_handle_standard_args(
|
||||
OpenBLAS REQUIRED_VARS CP2K_OPENBLAS_INCLUDE_DIRS
|
||||
CP2K_OPENBLAS_LINK_LIBRARIES)
|
||||
|
||||
# add target to link against
|
||||
if(CP2K_OPENBLAS_FOUND AND NOT TARGET CP2K_OpenBLAS::openblas)
|
||||
add_library(CP2K_OpenBLAS::openblas INTERFACE IMPORTED)
|
||||
set_property(
|
||||
TARGET CP2K_OpenBLAS::openblas PROPERTY INTERFACE_LINK_LIBRARIES
|
||||
${CP2K_OPENBLAS_LINK_LIBRARIES})
|
||||
if(CP2K_OPENBLAS_INCLUDE_DIRS)
|
||||
set_property(
|
||||
TARGET CP2K_OpenBLAS::openblas PROPERTY INTERFACE_INCLUDE_DIRECTORIES
|
||||
${CP2K_OPENBLAS_INCLUDE_DIRS})
|
||||
endif()
|
||||
add_library(CP2K_OpenBLAS::blas ALIAS CP2K_OpenBLAS::openblas)
|
||||
set(CP2K_BLAS_VENDOR "OpenBLAS")
|
||||
endif()
|
||||
|
||||
# prevent clutter in cache
|
||||
mark_as_advanced(CP2K_BLAS_VENDOR CP2K_OPENBLAS_FOUND
|
||||
CP2K_OPENBLAS_LINK_LIBRARIES CP2K_OPENBLAS_INCLUDE_DIRS)
|
||||
36
cmake/FindPEXSI.cmake
Normal file
36
cmake/FindPEXSI.cmake
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
# --------------------------------------------------------------------------------------------------
|
||||
# CP2K: A general program to perform molecular dynamics simulations Copyright
|
||||
# 2000-2022 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(ptscotch)
|
||||
|
||||
cp2k_set_default_paths(PEXSI "PEXSI")
|
||||
|
||||
cp2k_find_libraries(PEXSI pexsi)
|
||||
cp2k_include_dirs(PEXSI "pexsi.h pexsi/pexsi.h")
|
||||
|
||||
find_package_handle_standard_args(PEXSI DEFAULT_MSG CP2K_PEXSI_INCLUDE_DIRS
|
||||
CP2K_PEXSI_LINK_LIBRARIES)
|
||||
|
||||
if(CP2K_PEXSI_FOUND AND NOT TARGET CP2K_PEXSI::pexsi)
|
||||
add_library(CP2K_PEXSI::pexsi INTERFACE IMPORTED)
|
||||
set_target_properties(CP2K_PEXSI PROPERTIES INTERFACE_LINK_LIBRARIES
|
||||
"${CP2K_PEXSI_LINK_LIBRARIES}")
|
||||
if(DEFINED CP2K_PEXSI_INCLUDE_DIRS)
|
||||
set_target_properties(CP2K_PEXSI PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${CP2K_PEXSI_INCLUDE_DIRS}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
mark_as_advanced(CP2K_PEXSI_LINK_LIBRARIES CP2K_PEXSI_INCLUDE_DIRS
|
||||
CP2K_PEXSI_FOUND)
|
||||
47
cmake/FindPlumed.cmake
Normal file
47
cmake/FindPlumed.cmake
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
# --------------------------------------------------------------------------------------------------
|
||||
# CP2K: A general program to perform molecular dynamics simulations Copyright
|
||||
# 2000-2022 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(PkgConfig)
|
||||
|
||||
cp2k_set_default_paths(PLUMED "Plumed")
|
||||
|
||||
# First try with pkg
|
||||
if(PKG_CONFIG_FOUND)
|
||||
# plumed has a pkg-config module
|
||||
pkg_check_module(CP2K_PLUMED IMPORTED_TARGET GLOBAL "plumed")
|
||||
endif()
|
||||
|
||||
if(NOT ${CP2K_PLUMED_FOUND})
|
||||
cp2k_find_libraries(PLUMED "plumed")
|
||||
endif()
|
||||
|
||||
cp2k_include_dirs(PLUMED "plumed.h plumed/plumed.h")
|
||||
|
||||
if(CP2K_PLUMED_INCLUDE_DIRS)
|
||||
find_package_handle_standard_args(Plumed DEFAULT_MSG CP2K_PLUMED_INCLUDE_DIRS
|
||||
CP2K_PLUMED_LINK_LIBRARIES)
|
||||
else()
|
||||
find_package_handle_standard_args(Plumed DEFAULT_MSG
|
||||
CP2K_PLUMED_LINK_LIBRARIES)
|
||||
endif()
|
||||
|
||||
if(CP2K_PLUMED_FOUND AND NOT TARGET CP2K_plumed::plumed)
|
||||
add_library(CP2K_plumed::plumed INTERFACE IMPORTED)
|
||||
set_target_properties(
|
||||
CP2K_plumed::plumed
|
||||
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CP2K_PLUMED_INCLUDE_DIRS}"
|
||||
INTERFACE_LINK_LIBRARIES "${CP2K_PLUMED_LINK_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
mark_as_advanced(CP2K_PLUMED_LINK_LIBRARIES CP2K_PLUMED_INCLUDE_DIRS
|
||||
CP2K_PLUMED_FOUND)
|
||||
72
cmake/FindPtscotch.cmake
Normal file
72
cmake/FindPtscotch.cmake
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
# --------------------------------------------------------------------------------------------------
|
||||
# CP2K: A general program to perform molecular dynamics simulations Copyright
|
||||
# 2000-2022 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(PTSCOTCH "Ptscotch")
|
||||
|
||||
find_package(Parmetis REQUIRED)
|
||||
find_package(Threads REQUIRED)
|
||||
find_package(MPI REQUIRED)
|
||||
|
||||
# look for libraries
|
||||
|
||||
foreach(
|
||||
_lib
|
||||
ptscotchparmetis
|
||||
ptscotch
|
||||
ptscotcherr
|
||||
scotchmetis
|
||||
scotch
|
||||
scotcherr
|
||||
ptesmumps)
|
||||
string(TOUPPER "${_lib}" _lib_up)
|
||||
cp2k_find_libraries("${_lib_up}" ${_lib})
|
||||
endforeach()
|
||||
|
||||
# search for include files
|
||||
cp2k_include_dirs(PTSCOTCH
|
||||
"ptscotch.h openmpi/include/ptscotch.h ptsctoch/ptscotch.h")
|
||||
|
||||
# check that PTSCOTCH has been found
|
||||
# ---------------------------------
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(
|
||||
Ptscotch
|
||||
DEFAULT_MSG
|
||||
CP2K_PTSCOTCH_LINK_LIBRARIES
|
||||
CP2K_PTSCOTCHPARMETIS_LINK_LIBRARIES
|
||||
CP2K_PTSCOTCHERR_LINK_LIBRARIES
|
||||
CP2K_SCOTCHMETIS_LINK_LIBRARIES
|
||||
CP2K_SCOTCH_LINK_LIBRARIES
|
||||
CP2K_SCOTCHERR_LINK_LIBRARIES
|
||||
CP2K_PTESMUMPS_LINK_LIBRARIES)
|
||||
|
||||
if(CP2K_PTSCOTCH_FOUND AND NOT TARGET CP2K_ptscotch::ptscotch)
|
||||
add_library(CP2K_ptscotch::ptscotch INTERFACE IMPORTED)
|
||||
set_target_properties(
|
||||
CP2K_ptscotch::ptscotch
|
||||
PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${PTSCOTCH_INCLUDE_DIRS}"
|
||||
INTERFACE_LINK_LIBRARIES
|
||||
"${CP2K_PTSCOTCH_LINK_LIBRARIES};
|
||||
${CP2K_PTSCOTCHPARMETIS_LINK_LIBRARIES};
|
||||
${CP2K_PTSCOTCHERR_LINK_LIBRARIES};
|
||||
${CP2K_SCOTCHMETIS_LINK_LIBRARIES};
|
||||
${CP2K_SCOTCH_LINK_LIBRARIES};
|
||||
${CP2K_SCOTCHERR_LINK_LIBRARIES};
|
||||
${CP2K_PTESMUMPS_LINK_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
mark_as_advanced(CP2K_PTSCOTCH_FOUND)
|
||||
mark_as_advanced(CP2K_PTSCOTCH_LIBRARIES)
|
||||
mark_as_advanced(CP2K_PTSCOTCH_INCLUDE_DIRS)
|
||||
31
cmake/FindQuip.cmake
Normal file
31
cmake/FindQuip.cmake
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# --------------------------------------------------------------------------------------------------
|
||||
# CP2K: A general program to perform molecular dynamics simulations Copyright
|
||||
# 2000-2022 CP2K developers group <https://cp2k.org>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# --------------------------------------------------------------------------------------------------
|
||||
|
||||
# Copyright (c) 2022- ETH Zurich
|
||||
#
|
||||
# authors : Mathieu Taillefumier
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package(PkgConfig)
|
||||
cp2k_set_default_paths(LIBQUIP)
|
||||
|
||||
pkg_search_module(CP2K_LIBQUIP quip "Quip")
|
||||
|
||||
if(CP2K_LIBQUIP_FOUND)
|
||||
cp2k_find_libraries(LIBQUIP "quip")
|
||||
cp2k_include_dirs(LIBQUIP "quip.h")
|
||||
endif()
|
||||
find_package_handle_standard_args(Quip DEFAULT_MSG CP2K_LIBQUIP_INCLUDE_DIRS
|
||||
CP2K_QUIP_LINK_LIBRARIES)
|
||||
|
||||
if(CP2K_LIBQUIP_FOUND AND NOT TARGET CP2K_quip::quip)
|
||||
add_library(CP2K_quip::quip INTERFACE IMPORTED)
|
||||
set_target_properties(
|
||||
CP2K_quip::quip
|
||||
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CP2K_LIBQUIP_INCLUDE_DIRS}"
|
||||
INTERFACE_LINK_LIBRARIES "${CP2K_LIBQUIP_LINK_LIBRARIES}")
|
||||
endif()
|
||||
87
cmake/FindSCALAPACK.cmake
Normal file
87
cmake/FindSCALAPACK.cmake
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
# --------------------------------------------------------------------------------------------------
|
||||
# CP2K: A general program to perform molecular dynamics simulations Copyright
|
||||
# 2000-2022 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(SCALAPACK "SCALAPACK")
|
||||
|
||||
# check if we have mkl as blas library or not and pick the scalapack from mkl
|
||||
# distro if found
|
||||
|
||||
if(CP2K_SCALAPACK_VENDOR STREQUAL "GENERIC")
|
||||
if(TARGET CP2K_MKL::scalapack_link)
|
||||
message("-----------------------------------------------------------------")
|
||||
message("- FindScalapack warning -")
|
||||
message("-----------------------------------------------------------------")
|
||||
message(" ")
|
||||
message(
|
||||
WARNING
|
||||
"You may want to use mkl implementation of scalapack. To do this add -DSCALAPACK_VENDOR=MKL to the cmake command line"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(TARGET CP2K_SCI::scalapack_link)
|
||||
message("-----------------------------------------------------------------")
|
||||
message("- FindScalapack warning -")
|
||||
message("-----------------------------------------------------------------")
|
||||
message(" ")
|
||||
message(
|
||||
WARNING
|
||||
"You may want to use Cray implementation of scalapack. To do this add -DSCALAPACK_VENDOR=SCI to the cmake command line"
|
||||
)
|
||||
message(" ")
|
||||
message(" ")
|
||||
endif()
|
||||
|
||||
# try to detect location with pkgconfig
|
||||
find_package(PkgConfig QUIET)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(CP2K_SCALAPACK "scalapack")
|
||||
endif()
|
||||
|
||||
# this should be enough for detecting scalapack compiled by hand. If scalapack
|
||||
# is vendor specific then we sahould have a target blas::scalapack available.
|
||||
# it removes the problem of modifying too many files when we add a vendor
|
||||
# specific blas/lapack/scalapack implementation
|
||||
|
||||
if(NOT CP2K_SCALAPACK_FOUND)
|
||||
cp2k_find_libraries(SCALAPACK "scalapack")
|
||||
endif()
|
||||
elseif(TARGET CP2K_MKL::scalapack_link)
|
||||
# we have mkl check for the different mkl target
|
||||
get_target_property(CP2K_SCALAPACK_LINK_LIBRARIES CP2K_MKL::scalapack_link
|
||||
INTERFACE_LINK_LIBRARIES)
|
||||
set(CP2K_SCALAPACK_FOUND yes)
|
||||
elseif(TARGET CP2K_SCI::scalapack_link)
|
||||
# we have mkl check for the different mkl target
|
||||
get_target_property(CP2K_SCALAPACK_LINK_LIBRARIES CP2K_SCI::scalapack_link
|
||||
INTERFACE_LINK_LIBRARIES)
|
||||
set(CP2K_SCALAPACK_FOUND yes)
|
||||
endif()
|
||||
|
||||
# check if found
|
||||
find_package_handle_standard_args(SCALAPACK
|
||||
REQUIRED_VARS CP2K_SCALAPACK_LINK_LIBRARIES)
|
||||
# prevent clutter in cache
|
||||
|
||||
# add target to link against
|
||||
if(CP2K_SCALAPACK_FOUND)
|
||||
|
||||
if(NOT TARGET CP2K_SCALAPACK::scalapack)
|
||||
add_library(CP2K_SCALAPACK::scalapack INTERFACE IMPORTED)
|
||||
endif()
|
||||
|
||||
set_property(
|
||||
TARGET CP2K_SCALAPACK::scalapack PROPERTY INTERFACE_LINK_LIBRARIES
|
||||
${CP2K_SCALAPACK_LINK_LIBRARIES})
|
||||
endif()
|
||||
mark_as_advanced(CP2K_SCALAPACK_FOUND CP2K_SCALAPACK_LINK_LIBRARIES)
|
||||
110
cmake/FindSCI.cmake
Normal file
110
cmake/FindSCI.cmake
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
# --------------------------------------------------------------------------------------------------
|
||||
# CP2K: A general program to perform molecular dynamics simulations Copyright
|
||||
# 2000-2022 CP2K developers group <https://cp2k.org>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# --------------------------------------------------------------------------------------------------
|
||||
|
||||
# Copyright (c) 2022- ETH Zurich
|
||||
#
|
||||
# authors : Mathieu Taillefumier
|
||||
|
||||
# set paths to look for library from ROOT variables.If new policy is set,
|
||||
# find_library() automatically uses them.
|
||||
include(FindPackageHandleStandardArgs)
|
||||
include(cp2k_utils)
|
||||
|
||||
cp2k_set_default_paths(LIBSCI "SCI")
|
||||
|
||||
# we might need to change the logic a little here since the cp2k_find_library
|
||||
# function expect to have CP2K_package_PREFIX set.
|
||||
|
||||
set(CP2K_LIBSCI_MP_PREFIX "${CP2K_LIBSCI_PREFIX}")
|
||||
set(CP2K_LIBSCI_MPI_PREFIX "${CP2K_LIBSCI_PREFIX}")
|
||||
set(CP2K_LIBSCI_MPI_MP_PREFIX "${CP2K_LIBSCI_PREFIX}")
|
||||
|
||||
set(_sci_lib "sci_gnu")
|
||||
|
||||
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
|
||||
set(_sci_lib "sci_intel")
|
||||
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
|
||||
set(_sci_lib "sci_cray")
|
||||
endif()
|
||||
|
||||
cp2k_find_libraries("LIBSCI" "${_sci_lib}")
|
||||
cp2k_find_libraries("LIBSCI_MP" "${_sci_lib}_mp")
|
||||
cp2k_find_libraries("LIBSCI_MPI" "${_sci_lib}_mpi")
|
||||
cp2k_find_libraries("LIBSCI_MPI_MP" "${_sci_lib}_mpi_mp")
|
||||
cp2k_include_dirs(LIBSCI "cblas.h")
|
||||
|
||||
# check if found
|
||||
find_package_handle_standard_args(SCI REQUIRED_VARS CP2K_LIBSCI_INCLUDE_DIRS
|
||||
CP2K_LIBSCI_LINK_LIBRARIES)
|
||||
|
||||
# add target to link against
|
||||
if(CP2K_LIBSCI_FOUND)
|
||||
if(NOT TARGET CP2K_SCI::sci)
|
||||
add_library(CP2K_SCI::sci INTERFACE IMPORTED)
|
||||
add_library(CP2K_SCI::sci_mpi INTERFACE IMPORTED)
|
||||
add_library(CP2K_SCI::sci_mp INTERFACE IMPORTED)
|
||||
add_library(CP2K_SCI::sci_mpi_mp INTERFACE IMPORTED)
|
||||
add_library(CP2K_SCI::scalapack_link INTERFACE IMPORTED)
|
||||
add_library(CP2K_SCI::blas INTERFACE IMPORTED)
|
||||
|
||||
if(CP2K_LIBSCI_INCLUDE_DIRS)
|
||||
set_property(TARGET CP2K_SCI::sci PROPERTY INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${CP2K_LIBSCI_INCLUDE_DIRS}")
|
||||
set_property(
|
||||
TARGET CP2K_SCI::sci_mp PROPERTY INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${CP2K_LIBSCI_INCLUDE_DIRS}")
|
||||
set_property(
|
||||
TARGET CP2K_SCI::sci_mpi PROPERTY INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${CP2K_LIBSCI_INCLUDE_DIRS}")
|
||||
set_property(
|
||||
TARGET CP2K_SCI::sci_mpi_mp PROPERTY INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${CP2K_LIBSCI_INCLUDE_DIRS}")
|
||||
endif()
|
||||
|
||||
set_property(TARGET CP2K_SCI::sci PROPERTY INTERFACE_LINK_LIBRARIES
|
||||
${CP2K_LIBSCI_LINK_LIBRARIES})
|
||||
set_property(
|
||||
TARGET CP2K_SCI::sci_mp PROPERTY INTERFACE_LINK_LIBRARIES
|
||||
${CP2K_LIBSCI_MP_LINK_LIBRARIES})
|
||||
set_property(
|
||||
TARGET CP2K_SCI::sci_mpi
|
||||
PROPERTY INTERFACE_LINK_LIBRARIES ${CP2K_LIBSCI_MPI_LINK_LIBRARIES}
|
||||
CP2K_SCI::sci)
|
||||
set_property(
|
||||
TARGET CP2K_SCI::sci_mpi_mp
|
||||
PROPERTY INTERFACE_LINK_LIBRARIES ${CP2K_LIBSCI_MPI_MP_LINK_LIBRARIES}
|
||||
CP2K_SCI::sci_mp)
|
||||
set_property(
|
||||
TARGET CP2K_SCI::scalapack_link PROPERTY INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${CP2K_LIBSCI_INCLUDE_DIRS}")
|
||||
endif()
|
||||
|
||||
if(CP2K_BLAS_THREADING MATCHES "sequential")
|
||||
set_property(TARGET CP2K_SCI::blas PROPERTY INTERFACE_LINK_LIBRARIES
|
||||
CP2K_SCI::sci)
|
||||
set_property(TARGET CP2K_SCI::scalapack_link
|
||||
PROPERTY INTERFACE_LINK_LIBRARIES CP2K_SCI::sci_mpi)
|
||||
else()
|
||||
set_property(TARGET CP2K_SCI::blas PROPERTY INTERFACE_LINK_LIBRARIES
|
||||
CP2K_SCI::sci_mp)
|
||||
set_property(TARGET CP2K_SCI::scalapack_link
|
||||
PROPERTY INTERFACE_LINK_LIBRARIES CP2K_SCI::sci_mpi_mp)
|
||||
endif()
|
||||
|
||||
set(CP2K_BLAS_VENDOR "SCI")
|
||||
|
||||
endif()
|
||||
|
||||
# prevent clutter in cache
|
||||
mark_as_advanced(
|
||||
CP2K_LIBSCI_FOUND
|
||||
CP2K_BLAS_VENDOR
|
||||
CP2K_LIBSCI_LINK_LIBRARIES
|
||||
CP2K_LIBSCI_MP_LINK_LIBRARIES
|
||||
CP2K_LIBSCI_MPI_LINK_LIBRARIES
|
||||
CP2K_LIBSCI_MPI_MP_LINK_LIBRARIES
|
||||
CP2K_LIBSCI_INCLUDE_DIRS)
|
||||
37
cmake/FindSuperLU.cmake
Normal file
37
cmake/FindSuperLU.cmake
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# --------------------------------------------------------------------------------------------------
|
||||
# CP2K: A general program to perform molecular dynamics simulations Copyright
|
||||
# 2000-2022 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(PkgConfig)
|
||||
cp2k_set_default_paths(SUPERLU "SuperLU")
|
||||
pkg_search_module(CP2K_SUPERLU IMPORTED_TARGET GLOBAL "superlu superlu_dist")
|
||||
|
||||
if(NOT CP2K_SUPERLU_FOUND)
|
||||
cp2k_find_libraries(SUPERLU "superlu;superlu_dist")
|
||||
endif()
|
||||
|
||||
if(NOT CP2K_SUPERLU_INCLUDE_DIRS)
|
||||
cp2k_include_dirs(SUPERLU
|
||||
"supermatrix.h;SuperLU/supermatrix.h;superlu/supermatrix.h")
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args(SuperLU DEFAULT_MSG CP2K_SUPERLU_INCLUDE_DIRS
|
||||
CP2K_SUPERLU_LINK_LIBRARIES)
|
||||
|
||||
if(CP2K_SUPERLU_FOUND AND NOT TARGET CP2K_superlu::superlu)
|
||||
add_library(CP2K_superlu::superlu INTERFACE IMPORTED)
|
||||
set_target_properties(
|
||||
CP2K_superlu::superlu
|
||||
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CP2K_SUPERLU_INCLUDE_DIRS}"
|
||||
INTERFACE_LINK_LIBRARIES "${CP2K_SUPERLU_LINK_LIBRARIES}")
|
||||
endif()
|
||||
181
cmake/GetGitRevisionDescription.cmake
Normal file
181
cmake/GetGitRevisionDescription.cmake
Normal file
|
|
@ -0,0 +1,181 @@
|
|||
# * Returns a version string from Git
|
||||
#
|
||||
# These functions force a re-configure on each git commit so that you can trust
|
||||
# the values of the variables in your build system.
|
||||
#
|
||||
# get_git_head_revision(<refspecvar> <hashvar> [<additional arguments to git
|
||||
# describe> ...])
|
||||
#
|
||||
# Returns the refspec and sha hash of the current head revision
|
||||
#
|
||||
# git_describe(<var> [<additional arguments to git describe> ...])
|
||||
#
|
||||
# Returns the results of git describe on the source tree, and adjusting the
|
||||
# output so that it tests false if an error occurs.
|
||||
#
|
||||
# git_get_exact_tag(<var> [<additional arguments to git describe> ...])
|
||||
#
|
||||
# Returns the results of git describe --exact-match on the source tree, and
|
||||
# adjusting the output so that it tests false if there was no exact matching
|
||||
# tag.
|
||||
#
|
||||
# git_local_changes(<var>)
|
||||
#
|
||||
# Returns either "CLEAN" or "DIRTY" with respect to uncommitted changes. Uses
|
||||
# the return code of "git diff-index --quiet HEAD --". Does not regard untracked
|
||||
# files.
|
||||
#
|
||||
# Requires CMake 2.6 or newer (uses the 'function' command)
|
||||
#
|
||||
# Original Author: 2009-2010 Ryan Pavlik <rpavlik@iastate.edu>
|
||||
# <abiryan@ryand.net> http://academic.cleardefinition.com Iowa State University
|
||||
# HCI Graduate Program/VRAC
|
||||
#
|
||||
# Copyright Iowa State University 2009-2010. Distributed under the Boost
|
||||
# Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy
|
||||
# at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
if(__get_git_revision_description)
|
||||
return()
|
||||
endif()
|
||||
set(__get_git_revision_description YES)
|
||||
|
||||
# We must run the following at "include" time, not at function call time, to
|
||||
# find the path to this module rather than the path to a calling list file
|
||||
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
|
||||
|
||||
function(get_git_head_revision _refspecvar _hashvar)
|
||||
set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
|
||||
while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories
|
||||
set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}")
|
||||
get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH)
|
||||
if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT)
|
||||
# We have reached the root directory, we are not in git
|
||||
set(${_refspecvar}
|
||||
"GITDIR-NOTFOUND"
|
||||
PARENT_SCOPE)
|
||||
set(${_hashvar}
|
||||
"GITDIR-NOTFOUND"
|
||||
PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
|
||||
endwhile()
|
||||
# check if this is a submodule
|
||||
if(NOT IS_DIRECTORY ${GIT_DIR})
|
||||
file(READ ${GIT_DIR} submodule)
|
||||
string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule})
|
||||
get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
|
||||
get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE}
|
||||
ABSOLUTE)
|
||||
endif()
|
||||
if(NOT IS_DIRECTORY "${GIT_DIR}")
|
||||
file(READ ${GIT_DIR} worktree)
|
||||
string(REGEX REPLACE "gitdir: (.*)worktrees(.*)\n$" "\\1" GIT_DIR
|
||||
${worktree})
|
||||
endif()
|
||||
set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
|
||||
if(NOT EXISTS "${GIT_DATA}")
|
||||
file(MAKE_DIRECTORY "${GIT_DATA}")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${GIT_DIR}/HEAD")
|
||||
return()
|
||||
endif()
|
||||
set(HEAD_FILE "${GIT_DATA}/HEAD")
|
||||
configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY)
|
||||
|
||||
configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
|
||||
"${GIT_DATA}/grabRef.cmake" @ONLY)
|
||||
include("${GIT_DATA}/grabRef.cmake")
|
||||
|
||||
set(${_refspecvar}
|
||||
"${HEAD_REF}"
|
||||
PARENT_SCOPE)
|
||||
set(${_hashvar}
|
||||
"${HEAD_HASH}"
|
||||
PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(git_describe _var)
|
||||
if(NOT GIT_FOUND)
|
||||
find_package(Git QUIET)
|
||||
endif()
|
||||
get_git_head_revision(refspec hash)
|
||||
if(NOT GIT_FOUND)
|
||||
set(${_var}
|
||||
"GIT-NOTFOUND"
|
||||
PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
if(NOT hash)
|
||||
set(${_var}
|
||||
"HEAD-HASH-NOTFOUND"
|
||||
PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# TODO sanitize if((${ARGN}" MATCHES "&&") OR (ARGN MATCHES "||") OR (ARGN
|
||||
# MATCHES "\\;")) message("Please report the following error to the project!")
|
||||
# message(FATAL_ERROR "Looks like someone's doing something nefarious with
|
||||
# git_describe! Passed arguments ${ARGN}") endif()
|
||||
|
||||
# message(STATUS "Arguments to execute_process: ${ARGN}")
|
||||
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" describe ${hash} ${ARGN}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
RESULT_VARIABLE res
|
||||
OUTPUT_VARIABLE out
|
||||
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT res EQUAL 0)
|
||||
set(out "${out}-${res}-NOTFOUND")
|
||||
endif()
|
||||
|
||||
set(${_var}
|
||||
"${out}"
|
||||
PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(git_get_exact_tag _var)
|
||||
git_describe(out --exact-match ${ARGN})
|
||||
set(${_var}
|
||||
"${out}"
|
||||
PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(git_local_changes _var)
|
||||
if(NOT GIT_FOUND)
|
||||
find_package(Git QUIET)
|
||||
endif()
|
||||
get_git_head_revision(refspec hash)
|
||||
if(NOT GIT_FOUND)
|
||||
set(${_var}
|
||||
"GIT-NOTFOUND"
|
||||
PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
if(NOT hash)
|
||||
set(${_var}
|
||||
"HEAD-HASH-NOTFOUND"
|
||||
PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" diff-index --quiet HEAD --
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
RESULT_VARIABLE res
|
||||
OUTPUT_VARIABLE out
|
||||
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(res EQUAL 0)
|
||||
set(${_var}
|
||||
"CLEAN"
|
||||
PARENT_SCOPE)
|
||||
else()
|
||||
set(${_var}
|
||||
"DIRTY"
|
||||
PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
41
cmake/GetGitRevisionDescription.cmake.in
Normal file
41
cmake/GetGitRevisionDescription.cmake.in
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#
|
||||
# Internal file for GetGitRevisionDescription.cmake
|
||||
#
|
||||
# Requires CMake 2.6 or newer (uses the 'function' command)
|
||||
#
|
||||
# Original Author:
|
||||
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||
# http://academic.cleardefinition.com
|
||||
# Iowa State University HCI Graduate Program/VRAC
|
||||
#
|
||||
# Copyright Iowa State University 2009-2010.
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
set(HEAD_HASH)
|
||||
|
||||
file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)
|
||||
|
||||
string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
|
||||
if(HEAD_CONTENTS MATCHES "ref")
|
||||
# named branch
|
||||
string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
|
||||
if(EXISTS "@GIT_DIR@/${HEAD_REF}")
|
||||
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
|
||||
else()
|
||||
configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY)
|
||||
file(READ "@GIT_DATA@/packed-refs" PACKED_REFS)
|
||||
if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}")
|
||||
set(HEAD_HASH "${CMAKE_MATCH_1}")
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
# detached HEAD
|
||||
configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
|
||||
endif()
|
||||
|
||||
if(NOT HEAD_HASH)
|
||||
file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
|
||||
string(STRIP "${HEAD_HASH}" HEAD_HASH)
|
||||
endif()
|
||||
14
cmake/compiler-tests/f2008-block_construct.f90
Normal file
14
cmake/compiler-tests/f2008-block_construct.f90
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
!--------------------------------------------------------------------------------------------------!
|
||||
! Copyright (C) by the DBCSR developers group - All rights reserved !
|
||||
! This file is part of the DBCSR library. !
|
||||
! !
|
||||
! For information on the license, see the LICENSE file. !
|
||||
! For further information please visit https://dbcsr.cp2k.org !
|
||||
! SPDX-License-Identifier: GPL-2.0+ !
|
||||
!--------------------------------------------------------------------------------------------------!
|
||||
|
||||
program main
|
||||
try: block
|
||||
exit try
|
||||
end block try
|
||||
end program
|
||||
22
cmake/compiler-tests/f2008-contiguous.f90
Normal file
22
cmake/compiler-tests/f2008-contiguous.f90
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
!--------------------------------------------------------------------------------------------------!
|
||||
! Copyright (C) by the DBCSR developers group - All rights reserved !
|
||||
! This file is part of the DBCSR library. !
|
||||
! !
|
||||
! For information on the license, see the LICENSE file. !
|
||||
! For further information please visit https://dbcsr.cp2k.org !
|
||||
! SPDX-License-Identifier: GPL-2.0+ !
|
||||
!--------------------------------------------------------------------------------------------------!
|
||||
|
||||
program main
|
||||
implicit none
|
||||
|
||||
! test whether the compiler supports the CONTIGUOUS keyword
|
||||
integer, allocatable, target :: targ(:)
|
||||
integer, contiguous, pointer :: ptr(:)
|
||||
|
||||
! allocated data is always contiguous
|
||||
allocate (targ(10))
|
||||
ptr => targ
|
||||
|
||||
! IS_CONTIGUOUS was implemented in gcc-9 and is therefore not tested for yet
|
||||
end program
|
||||
14
cmake/compiler-tests/f2008-norm2.f90
Normal file
14
cmake/compiler-tests/f2008-norm2.f90
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
!--------------------------------------------------------------------------------------------------!
|
||||
! Copyright (C) by the DBCSR developers group - All rights reserved !
|
||||
! This file is part of the DBCSR library. !
|
||||
! !
|
||||
! For information on the license, see the LICENSE file. !
|
||||
! For further information please visit https://dbcsr.cp2k.org !
|
||||
! SPDX-License-Identifier: GPL-2.0+ !
|
||||
!--------------------------------------------------------------------------------------------------!
|
||||
|
||||
program main
|
||||
implicit none
|
||||
real :: x(2) = [real :: 3, 4]
|
||||
if (abs(norm2(x) - 5.) > 1.0D-5) stop 1
|
||||
end program
|
||||
18
cmake/compiler-tests/f95-reshape-order-allocatable.f90
Normal file
18
cmake/compiler-tests/f95-reshape-order-allocatable.f90
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
!--------------------------------------------------------------------------------------------------!
|
||||
! Copyright (C) by the DBCSR developers group - All rights reserved !
|
||||
! This file is part of the DBCSR library. !
|
||||
! !
|
||||
! For information on the license, see the LICENSE file. !
|
||||
! For further information please visit https://dbcsr.cp2k.org !
|
||||
! SPDX-License-Identifier: GPL-2.0+ !
|
||||
!--------------------------------------------------------------------------------------------------!
|
||||
program test_reshape
|
||||
integer, dimension(4) :: x = [1, 2, 3, 4]
|
||||
integer, dimension(:), allocatable :: order
|
||||
|
||||
allocate (order(2))
|
||||
order(:) = [2, 1]
|
||||
|
||||
! PGI <= 19.10 does not accept allocatables for the order parameter
|
||||
print *, reshape(x, shape=[2, 2], order=order)
|
||||
end program
|
||||
85
cmake/cp2k_utils.cmake
Normal file
85
cmake/cp2k_utils.cmake
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
# --------------------------------------------------------------------------------------------------
|
||||
# CP2K: A general program to perform molecular dynamics simulations Copyright
|
||||
# 2000-2022 CP2K developers group <https://cp2k.org>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# --------------------------------------------------------------------------------------------------
|
||||
|
||||
# Copyright (c) 2022- ETH Zurich
|
||||
#
|
||||
# authors : Mathieu Taillefumier
|
||||
|
||||
function(cp2k_set_default_paths _varname _package_name)
|
||||
# find_library should work when ${PACKAGE_ROOT} is given to cmake
|
||||
# (-DPACKAGE_ROOT=bla) but I use only one variable syntax CP2K_PACKAGE_PREFIX
|
||||
set(CP2K_${_varname}_PREFIX_TMP "")
|
||||
if(DEFINED ${_package_name}_ROOT)
|
||||
set(CP2K_${_varname}_PREFIX_TMP "${${_varname}_ROOT}")
|
||||
endif()
|
||||
|
||||
# search common environment variables names
|
||||
if(NOT CP2K_${_varname}_PREFIX_TMP)
|
||||
foreach(
|
||||
__var
|
||||
${_varname}_ROOT
|
||||
CRAY_${_varname}_PREFIX_DIR
|
||||
CRAY_${_varname}_ROOT
|
||||
OLCF_${_varname}_ROOT
|
||||
${_varname}_PREFIX
|
||||
${_varname}ROOT
|
||||
EB${_varname}ROOT)
|
||||
if(DEFINED ENV{${__var}})
|
||||
set(CP2K_${_varname}_PREFIX_TMP $ENV{${__var}})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# search for the default path
|
||||
if(NOT CP2K_${_varname}_PREFIX_TMP)
|
||||
set(CP2K_${_varname}_PREFIX_TMP "/usr")
|
||||
endif()
|
||||
endif()
|
||||
set(CP2K_${_varname}_PREFIX
|
||||
"${CP2K_${_varname}_PREFIX_TMP}"
|
||||
PARENT_SCOPE)
|
||||
|
||||
unset(CP2K_${_varname}_PREFIX_TMP CACHE)
|
||||
# mark_as_advanced(CP2K_${_varname}_PREFIX)
|
||||
endfunction()
|
||||
|
||||
function(cp2k_find_libraries _package_name _library_name)
|
||||
string(TOUPPER ${_library_name} _library_name_upper)
|
||||
find_library(
|
||||
CP2K_${_package_name}_LIBRARIES_TMP
|
||||
NAMES "${_library_name}"
|
||||
PATHS "${CP2K_${_package_name}_PREFIX}"
|
||||
PATH_SUFFIXES "lib" "lib64")
|
||||
if(CP2K_${_package_name}_LIBRARIES_TMP)
|
||||
set(CP2K_${_package_name}_LINK_LIBRARIES
|
||||
"${CP2K_${_package_name}_LIBRARIES_TMP}"
|
||||
PARENT_SCOPE)
|
||||
set(CP2K_${_package_name}_LIBRARIES
|
||||
"${CP2K_${_package_name}_LIBRARIES_TMP}"
|
||||
PARENT_SCOPE)
|
||||
set(CP2K_${_package_name}_FOUND
|
||||
ON
|
||||
PARENT_SCOPE)
|
||||
endif()
|
||||
unset(CP2K_${_package_name}_LIBRARIES_TMP CACHE)
|
||||
# mark_as_advanced(CP2K_${_package_name}_LINK_LIBRARIES
|
||||
# CP2K_${_package_name}_LIBRARIES)
|
||||
endfunction()
|
||||
|
||||
function(cp2k_include_dirs _package_name _library_include_file)
|
||||
# string(TOUPPER ${_package_name} _library_name_upper)
|
||||
find_path(
|
||||
CP2K_${_package_name}_INCLUDE_DIRS_TMP
|
||||
NAMES "${_lib_include_file}"
|
||||
PATHS "${CP2K_${_package_name}_PREFIX}"
|
||||
HINTS "${CP2K_${_package_name}_PREFIX}"
|
||||
PATH_SUFFIXES "include" "include/${_pacakge_name}" "${_package_name}"
|
||||
NO_DEFAULT_PATH)
|
||||
set(CP2K_${_package_name}_INCLUDE_DIRS
|
||||
"${CP2K_${_package_name}_INCLUDE_DIRS_TMP}"
|
||||
PARENT_SCOPE)
|
||||
unset(CP2K_${_package_name}_INCLUDE_DIRS_TMP CACHE)
|
||||
endfunction()
|
||||
85
cmake/fypp-sources.cmake
Normal file
85
cmake/fypp-sources.cmake
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
add_custom_target(fypp) # common target for all fypp calls
|
||||
|
||||
# Use a system-provided fypp if available, otherwise the bundled one
|
||||
find_program(
|
||||
FYPP_EXECUTABLE fypp
|
||||
DOC "The FYPP preprocessor"
|
||||
PATHS ../tools/build_utils)
|
||||
if(NOT FYPP_EXECUTABLE)
|
||||
message(FATAL_ERROR "Failed to find the FYPP preprocessor.")
|
||||
else()
|
||||
message(STATUS "FYPP preprocessor found.")
|
||||
endif()
|
||||
|
||||
if((CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
|
||||
AND (CMAKE_GENERATOR STREQUAL "Ninja")
|
||||
AND (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16))
|
||||
set(fypp_flags --line-numbering --line-marker-format=gfortran5)
|
||||
elseif(CMAKE_BUILD_TYPE MATCHES COVERAGE)
|
||||
message(
|
||||
WARNING
|
||||
"Coverage build requested but your environment does not support Line Control directives in Fypp"
|
||||
)
|
||||
message(
|
||||
WARNING
|
||||
"You need CMake 3.16+, Ninja (CMake-patched) and gfortran 5+ for this to work!"
|
||||
)
|
||||
# otherwise the referenced lines in the Coverage report point to either the
|
||||
# original (unexpanded files) or to the Fypped sources which may then not be
|
||||
# picked up by the postprocessing tools. CMake 3.16+ and Ninja are needed
|
||||
# since older CMake (or CMake with make) are unable to parse Line Control
|
||||
# directives within line-continued USE stmts, see
|
||||
# https://gitlab.kitware.com/cmake/cmake/issues/18188
|
||||
endif()
|
||||
|
||||
function(ADD_FYPP_SOURCES OUTVAR)
|
||||
set(outfiles)
|
||||
|
||||
foreach(f ${ARGN})
|
||||
# first we might need to make the input file absolute
|
||||
get_filename_component(f "${f}" ABSOLUTE)
|
||||
get_filename_component(ext "${f}" EXT)
|
||||
# get the relative path of the file to the current source dir
|
||||
file(RELATIVE_PATH rf "${CMAKE_CURRENT_SOURCE_DIR}" "${f}")
|
||||
# set the output filename of fypped sources
|
||||
set(of "${CMAKE_CURRENT_BINARY_DIR}/${rf}")
|
||||
|
||||
# create the output directory if it doesn't exist
|
||||
get_filename_component(d "${of}" PATH)
|
||||
if(NOT IS_DIRECTORY "${d}")
|
||||
file(MAKE_DIRECTORY "${d}")
|
||||
endif()
|
||||
|
||||
if("${f}" MATCHES ".F$")
|
||||
# append the output file to the list of outputs
|
||||
list(APPEND outfiles "${of}")
|
||||
# now add the custom command to generate the output file
|
||||
add_custom_command(
|
||||
OUTPUT "${of}"
|
||||
COMMAND ${Python_EXECUTABLE} ${FYPP_EXECUTABLE} ARGS ${fypp_flags}
|
||||
"${f}" "${of}"
|
||||
MAIN_DEPENDENCY "${f}"
|
||||
VERBATIM)
|
||||
elseif("${f}" MATCHES ".h$")
|
||||
# append the output file to the list of outputs
|
||||
list(APPEND outfiles "${of}")
|
||||
# now add the custom command to generate the output file
|
||||
add_custom_command(
|
||||
OUTPUT "${of}"
|
||||
COMMAND ${Python_EXECUTABLE} ${FYPP_EXECUTABLE} ARGS "-F" "${f}" "${of}"
|
||||
DEPENDS "${f}")
|
||||
else()
|
||||
configure_file("${f}" "${of}" COPYONLY)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# build a custom target to fypp seperately (required for example by the doc
|
||||
# target)
|
||||
add_custom_target("fypp_${OUTVAR}" DEPENDS ${outfiles})
|
||||
add_dependencies(fypp "fypp_${OUTVAR}")
|
||||
|
||||
# set the output list in the calling scope
|
||||
set(${OUTVAR}
|
||||
${outfiles}
|
||||
PARENT_SCOPE)
|
||||
endfunction()
|
||||
19
cp2k.pc.in
Normal file
19
cp2k.pc.in
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# this template is filled-in by CMake `configure_file(... @ONLY)`
|
||||
# the `@....@` are filled in by CMake configure_file(),
|
||||
# from variables set in your CMakeLists.txt or by CMake itself
|
||||
#
|
||||
# Good tutoral for understanding .pc files:
|
||||
# https://people.freedesktop.org/~dbn/pkg-config-guide.html
|
||||
|
||||
prefix="@CMAKE_INSTALL_PREFIX@"
|
||||
exec_prefix="${prefix}"
|
||||
libdir="${prefix}/lib"
|
||||
includedir="${prefix}/include"
|
||||
|
||||
Name: @PROJECT_NAME@
|
||||
Description: @CMAKE_PROJECT_DESCRIPTION@
|
||||
URL: @CMAKE_PROJECT_HOMEPAGE_URL@
|
||||
Version: @PROJECT_VERSION@
|
||||
Cflags: -I"${includedir}"
|
||||
Libs: -L"${libdir}" -lcp2k
|
||||
#Libs.private: -L"${libdir}" @CP2K_LIBS@
|
||||
1634
src/CMakeLists.txt
Normal file
1634
src/CMakeLists.txt
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue