Cmake improvements

This commit is contained in:
Taillefumier Mathieu 2022-11-22 14:57:45 +01:00 committed by GitHub
parent bbe71a2287
commit 851a0f1ab1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 366 additions and 5800 deletions

92
.gitignore vendored
View file

@ -16,7 +16,7 @@
# allow folks to create a .clang-format to hide their personal style settings
.clang-format
# Created by https://www.gitignore.io/api/python,fortran,c,c++,cuda,emacs,vim
# Created by https://www.gitignore.io/api/python,fortran,c,c++,cuda,emacs,vim,cmake
### C ###
# Prerequisites
@ -91,6 +91,23 @@ dkms.conf
# Executables
### CMake ###
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
### CMake Patch ###
# External projects
*-prefix/
### CUDA ###
*.i
*.ii
@ -146,6 +163,10 @@ flycheck_*.el
# directory configuration
.dir-locals.el
# network security
/network-security.data
### Fortran ###
# Prerequisites
@ -182,6 +203,7 @@ parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
@ -207,8 +229,10 @@ htmlcov/
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
@ -218,6 +242,7 @@ coverage.xml
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
@ -230,6 +255,7 @@ instance/
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
@ -240,10 +266,38 @@ profile_default/
ipython_config.py
# pyenv
.python-version
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# celery beat schedule file
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
@ -272,24 +326,26 @@ venv.bak/
.dmypy.json
dmypy.json
### Python Patch ###
.venv/
# Pyre type checker
.pyre/
### Python.VirtualEnv Stack ###
# Virtualenv
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
[Bb]in
[Ii]nclude
[Ll]ib
[Ll]ib64
[Ll]ocal
[Ss]cripts
pyvenv.cfg
pip-selfcheck.json
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
### Vim ###
# Swap
[._]*.s[a-v][a-z]
!*.svg # comment out if you don't need vector files
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
@ -297,6 +353,7 @@ pip-selfcheck.json
# Session
Session.vim
Sessionx.vim
# Temporary
.netrwhist
@ -305,5 +362,4 @@ tags
# Persistent undo
[._]*.un~
# End of https://www.gitignore.io/api/python,fortran,c,c++,cuda,emacs,vim
# End of https://www.gitignore.io/api/python,fortran,c,c++,cuda,emacs,vim,cmake

View file

@ -52,8 +52,8 @@ if(GIT_DESC)
string(REGEX REPLACE "^([0-9\\-]+) .*" "\\1" VERSION_DATE
"${GIT_COMMIT_DATE}")
else()
set(VERSION_MAJOR 21)
set(VERSION_MINOR 10)
set(VERSION_MAJOR 22)
set(VERSION_MINOR 11)
set(VERSION_PATCH 00)
endif()
@ -101,7 +101,8 @@ endforeach()
# OPTIONS
option(CMAKE_POSITION_INDEPENDENT_CODE "Enable position independent code" ON)
option(CP2K_DEBUG_MODE "Enable several additional options for debugging cp2k."
OFF)
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)
@ -114,21 +115,20 @@ 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)
cmake_dependent_option(CP2K_ENABLE_FFTW3_OPENMP_SUPPORT
"Enable FFTW openmp support" ON "CP2K_USE_FFTW3" OFF)
cmake_dependent_option(CP2K_ENABLE_FFTW3_THREADS_SUPPORT
"Enable FFTW THREADS support" OFF "CP2K_USE_FFTW3" OFF)
set(CP2K_SCALAPACK_VENDOR_LIST "MKL" "SCI" "GENERIC")
set(CP2K_SCALAPACK_VENDOR
@ -168,9 +168,6 @@ 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")
@ -189,14 +186,13 @@ cmake_dependent_option(
#
# ##############################################################################
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
@ -213,15 +209,13 @@ 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.
# 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
@ -254,9 +248,8 @@ add_custom_target(
-DGIT_HASH_CACHE=${GIT_HASH_CACHE} -P ${CURRENT_LIST_DIR}/CheckGit.cmake
BYPRODUCTS ${post_configure_file})
# =================================== MPI
# 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
@ -285,10 +278,11 @@ if("${MPI_Fortran_LIBRARY_VERSION_STRING}" MATCHES "Open MPI v2.1"
" Please use a newer version of OpenMPI or switch to MPICH if you plan on using MPI-RMA."
)
endif()
# endif () =================================== BLAS & LAPACK, PkgConfig
# BLAS & LAPACK, PkgConfig
find_package(Lapack REQUIRED) # also calls find_package(BLAS)
# =================================== SMM (Small Matrix-Matrix multiplication)
# SMM (Small Matrix-Matrix multiplication)
if(CP2K_USE_LIBXSMM)
find_package(LibXSMM REQUIRED)
message(STATUS "-- Using libxsmm for Small Matrix Multiplication")
@ -298,9 +292,7 @@ endif()
# turn it off
find_package(SCALAPACK REQUIRED)
# ================================== CUDA / ROCM easy for cuda a moving target
# for hip
# ======================================
# 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)
@ -357,7 +349,7 @@ if(CP2K_USE_ACCEL MATCHES "CUDA")
endif()
set(CP2K_USE_CUDA ON)
message(STATUS "-- CUDA compiler and libraries found")
message(STATUS ``"-- CUDA compiler and libraries found")
elseif(CP2K_USE_ACCEL MATCHES "HIP")
enable_language(HIP)
# Find hip
@ -397,7 +389,7 @@ if(CP2K_USE_LIBXC)
endif()
if(CP2K_USE_COSMA)
find_package(cosma REQUIRED)
find_package(cosma REQUIRED HINTS "${COSMA_ROOT}" "$ENV(COSMA_ROOT)")
get_target_property(COSMA_INCLUDE_DIRS cosma::cosma
INTERFACE_INCLUDE_DIRECTORIES)
if(NOT COSMA_INCLUDE_DIRS)
@ -406,10 +398,11 @@ if(CP2K_USE_COSMA)
# 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(ERROR_ERROR
" COSMA needs tor be build with scalapack offloading support")
message(
FATAL
" COSTA_SCALAPACK and COSMA_SCALAPACK should probably be set properly")
FATAL_ERROR
" COSTA_SCALAPACK and COSMA_SCALAPACK should probably be set properly")
endif()
endif()
@ -417,28 +410,44 @@ if(CP2K_USE_VORI)
find_package(LibVORI REQUIRED)
endif()
# =================================== CP2K_FFTW3
# ===========================================
# FFTW3
if(CP2K_USE_FFTW3)
find_package(Fftw REQUIRED)
if(CP2K_ENABLE_FFTW3_THREADS_SUPPORT AND CP2K_ENABLE_FFTW3_OPENMP_SUPPORT)
message(
FATAL_ERROR
"Fftw3 threads and openmp supports can not be used at the same time")
endif()
if((CP2K_ENABLE_FFTW3_THREADS_SUPPORT) AND (NOT TARGET
CP2K_FFTW3::fftw3_threads))
message(
FATAL_ERROR
"fftw3 was compiled without multithreading support (--enable-threads option in fftw build system)."
)
endif()
if((CP2K_ENABLE_FFTW3_OPENMP_SUPPORT) AND (NOT TARGET CP2K_FFTW3::fftw3_omp))
message(
FATAL_ERROR
"fftw3 was compiled without openmp support (--enable-openmp option in fftw build system)."
)
endif()
endif()
# ==================================== QUIP
# ===========================================
# QUIP
if(CP2K_USE_QUIP)
find_package(Quip REQUIRED)
endif()
# ==================================== libint
# =========================================
# libint
if(CP2K_USE_LIBINT2)
find_package(Libint2 REQUIRED)
endif()
# ==================================== spglib
# =========================================
# spglib
if(CP2K_USE_SPGLIB)
find_package(LibSPG REQUIRED)
@ -455,13 +464,12 @@ if(CP2K_USE_SPLA)
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"
FATAL_ERROR
"SPLA should be compiled with GPU support if the gemm offloading is requested. Use -DCP2K_USE_GEMM_OFFLOADING=OFF otherwise"
)
endif()
endif()
# =================================== SIRIUS
# ==========================================
# SIRIUS
if(CP2K_USE_SIRIUS)
find_package(sirius REQUIRED)
@ -493,7 +501,6 @@ if(CP2K_USE_PLUMED)
find_package(Plumed REQUIRED)
endif()
# =================================================================================================
# OPTION HANDLING
# make sure that the default build type is RELEASE

View file

@ -13,7 +13,6 @@ include(FindPackageHandleStandardArgs)
include(cp2k_utils)
cp2k_set_default_paths(FFTW3 "Fftw")
# Check if we can use PkgConfig
find_package(PkgConfig)
@ -27,13 +26,19 @@ endif()
foreach(_lib fftw3 fftw3f fftw3l fftw3q)
if(NOT CP2K_${__lib_up}_FOUND)
cp2k_find_libraries("${__lib_up}" ${_lib})
set(CP2K_${__lib_up}_PREFIX "${CP2k_FFTW3_PREFIX}")
cp2k_find_libraries("${__lib_up}" "${_lib}")
unset(CP2K_${__lib_up}_PREFIX CACHE)
endif()
# OMP variant
foreach(_subtype "mpi" "omp" "threads")
string(TOUPPER "${_lib}_${_subtype}" _sub_lib)
cp2k_find_libraries("${_sub_lib}" ${_lib}_${_subtype})
# yeah not super deep
set(CP2K_${_sub_lib}_PREFIX "${CP2K_FFTW3_PREFIX}")
cp2k_find_libraries("${_sub_lib}" "${_lib}_${_subtype}")
unset(CP2K_${_sub_lib}_PREFIX CACHE)
endforeach()
endforeach()

View file

@ -17,9 +17,9 @@ if(PKG_CONFIG_FOUND)
REQUIRED
IMPORTED_TARGET
GLOBAL
libxc>=${LibXC_FIND_VERSION}
libxcf90
libxcf03
libxcf90)
libxc>=${LibXC_FIND_VERSION})
endif()
if(NOT CP2K_LIBXC_FOUND)
@ -41,27 +41,18 @@ 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(CP2K_LIBXC_FOUND)
if(NOT TARGET CP2K_CP2K_Libxc::xc)
add_library(CP2K_Libxc::xc INTERFACE IMPORTED)
endif()
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}")
CP2K_Libxc::xc PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"${CP2K_LIBXC_INCLUDE_DIRS}")
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}")
target_link_libraries(CP2K_Libxc::xc INTERFACE ${CP2K_LIBXC_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)
mark_as_advanced(CP2K_LIBXC_FOUND CP2K_LIBXC_LINK_LIBRARIES
CP2K_LIBXC_INCLUDE_DIRS)

View file

@ -17,7 +17,7 @@ find_package(PkgConfig)
cp2k_set_default_paths(OPENBLAS "OpenBLAS")
if(PKG_CONFIG_FOUND)
pkg_check_modules(CP2K_OPENBLAS openblas)
pkg_check_modules(CP2K_OPENBLAS IMPORTED_TARGET GLOBAL openblas)
endif()
# try the openblas module of openblas library Maybe we are lucky it is installed

View file

@ -16,8 +16,18 @@ find_package(ptscotch)
cp2k_set_default_paths(PEXSI "PEXSI")
cp2k_find_libraries(PEXSI pexsi)
cp2k_include_dirs(PEXSI "pexsi.h pexsi/pexsi.h")
cp2k_find_libraries(PEXSI "pexsi")
cp2k_include_dirs(PEXSI "pexsi.hpp")
find_file(CP2K_PEXSI_MOD_FILE NAMES "f_ppexsi_interface.mod" PATCHS
"${CP2K_PEXSI_PREFIX}/include")
if(NOT CP2K_PEXSI_MOD_FILE)
message(
FATAL_ERROR
"The pexsi library needs to be compiled with fortran support. Either recompile pexsi or disable it."
)
endif()
find_package_handle_standard_args(PEXSI DEFAULT_MSG CP2K_PEXSI_INCLUDE_DIRS
CP2K_PEXSI_LINK_LIBRARIES)

View file

@ -18,15 +18,14 @@ 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")
pkg_check_module(CP2K_PLUMED IMPORTED_TARGET GLOBAL plumed plumedInternals)
endif()
if(NOT ${CP2K_PLUMED_FOUND})
cp2k_find_libraries(PLUMED "plumed")
cp2k_include_dirs(PLUMED "plumed.h plumed/plumed.h")
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)
@ -35,8 +34,10 @@ else()
CP2K_PLUMED_LINK_LIBRARIES)
endif()
if(CP2K_PLUMED_FOUND AND NOT TARGET CP2K_plumed::plumed)
add_library(CP2K_plumed::plumed INTERFACE IMPORTED)
if(CP2K_PLUMED_FOUND)
if(NOT TARGET CP2K_plumed::plumed)
add_library(CP2K_plumed::plumed INTERFACE IMPORTED)
endif()
set_target_properties(
CP2K_plumed::plumed
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CP2K_PLUMED_INCLUDE_DIRS}"

View file

@ -25,7 +25,7 @@ if(CP2K_SCALAPACK_VENDOR STREQUAL "GENERIC")
message(" ")
message(
WARNING
"You may want to use mkl implementation of scalapack. To do this add -DSCALAPACK_VENDOR=MKL to the cmake command line"
"You may want to use mkl implementation of scalapack. To do this add -DCP2K_SCALAPACK_VENDOR=MKL to the cmake command line"
)
endif()
@ -36,7 +36,7 @@ if(CP2K_SCALAPACK_VENDOR STREQUAL "GENERIC")
message(" ")
message(
WARNING
"You may want to use Cray implementation of scalapack. To do this add -DSCALAPACK_VENDOR=SCI to the cmake command line"
"You may want to use Cray implementation of scalapack. To do this add -DCP2K_SCALAPACK_VENDOR=SCI to the cmake command line"
)
message(" ")
message(" ")

View file

@ -14,7 +14,7 @@ include(cp2k_utils)
find_package(PkgConfig)
cp2k_set_default_paths(SUPERLU "SuperLU")
pkg_search_module(CP2K_SUPERLU IMPORTED_TARGET GLOBAL "superlu superlu_dist")
pkg_search_module(CP2K_SUPERLU IMPORTED_TARGET GLOBAL "superlu_dist")
if(NOT CP2K_SUPERLU_FOUND)
cp2k_find_libraries(SUPERLU "superlu;superlu_dist")
@ -30,8 +30,10 @@ find_package_handle_standard_args(SuperLU DEFAULT_MSG CP2K_SUPERLU_INCLUDE_DIRS
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()
set_target_properties(
CP2K_superlu::superlu
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CP2K_SUPERLU_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${CP2K_SUPERLU_LINK_LIBRARIES}")
mark_as_advanced(CP2K_SUPERLU_LINK_LIBRARIES CP2K_SUPERLU_INCLUDE_DIRS
CP2K_SUPERLU_FOUND)

View file

@ -43,11 +43,11 @@ function(cp2k_set_default_paths _varname _package_name)
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}"
@ -64,13 +64,11 @@ function(cp2k_find_libraries _package_name _library_name)
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}"

View file

@ -575,6 +575,7 @@ list(
qs_loc_types.F
qs_loc_utils.F
qs_matrix_pools.F
qs_matrix_w.F
qs_mixing_utils.F
qs_mo_io.F
qs_moments.F
@ -1365,43 +1366,43 @@ endif()
add_library(cp2k_link_libs INTERFACE)
target_link_libraries(
cp2k_link_libs
INTERFACE $<$<BOOL:${CP2K_USE_PEXSI}>:PEXSI::pexsi>
$<$<BOOL:${CP2K_USE_SIRIUS}>:sirius::sirius>
$<$<BOOL:${CP2K_USE_VORI}>:CP2K_VORI::vori>
$<$<BOOL:${CP2K_USE_PEXSI}>:CP2K_PEXSI::pexsi>
$<$<BOOL:${CP2K_USE_PEXSI}>:CP2K_ptscotch::ptscotch>
$<$<BOOL:${CP2K_USE_SPGLIB}>:CP2K_LIBSPG::libspg>
$<$<BOOL:${CP2K_USE_LIBXC}>:CP2K_Libxc::xc
CP2K_Libxc::xcf90
CP2K_Libxc::xcf03>
$<$<BOOL:${CP2K_USE_ELPA}>:CP2K_ELPA::elpa>
$<$<BOOL:${CP2K_USE_FFTW3}>:CP2K_FFTW3::fftw3>
$<$<BOOL:${CP2K_USE_FFTW3}>:CP2K_FFTW3::fftw3_threads>
$<$<BOOL:${CP2K_USE_SPLA}>:SPLA::spla>
$<$<BOOL:${CP2K_USE_LIBINT2}>:CP2K_Libint2::int2>
$<$<BOOL:${CP2K_USE_COSMA}>:cosma::cosma_prefixed_pxgemm>
$<$<BOOL:${CP2K_USE_COSMA}>:cosma::cosma>
$<$<BOOL:${CP2K_USE_COSMA}>:costa::costa>
DBCSR::dbcsr
$<$<BOOL:${CP2K_USE_CUDA}>:CUDA::cufft>
$<$<BOOL:${CP2K_USE_CUDA}>:CUDA::cufftw>
$<$<BOOL:${CP2K_USE_CUDA}>:CUDA::cublas>
$<$<BOOL:${CP2K_USE_CUDA}>:CUDA::cudart>
$<$<BOOL:${CP2K_USE_HIP}>:hip::hipfft>
$<$<BOOL:${CP2K_USE_HIP}>:roc::hipblas>
$<$<BOOL:${CP2K_USE_HIP}>:hip::device>
CP2K_SCALAPACK::scalapack
$<$<BOOL:${CP2K_USE_LIBXSMM}>:CP2K_LibXSMM::libxsmmf>
$<$<BOOL:${CP2K_USE_LIBXSMM}>:CP2K_LibXSMM::libxsmmext>
$<$<BOOL:${CP2K_USE_LIBXSMM}>:CP2K_LibXSMM::libxsmm>
CP2K_LAPACK::lapack
CP2K_BLAS::blas
MPI::MPI_Fortran
MPI::MPI_C
MPI::MPI_CXX
OpenMP::OpenMP_Fortran
OpenMP::OpenMP_C
OpenMP::OpenMP_CXX)
INTERFACE
$<$<BOOL:${CP2K_USE_PEXSI}>:PEXSI::pexsi>
$<$<BOOL:${CP2K_USE_SIRIUS}>:sirius::sirius>
$<$<BOOL:${CP2K_USE_VORI}>:CP2K_VORI::vori>
$<$<BOOL:${CP2K_USE_PEXSI}>:CP2K_PEXSI::pexsi>
$<$<BOOL:${CP2K_USE_PEXSI}>:CP2K_ptscotch::ptscotch>
$<$<BOOL:${CP2K_USE_SPGLIB}>:CP2K_LIBSPG::libspg>
$<$<BOOL:${CP2K_USE_LIBXC}>:CP2K_Libxc::xc>
$<$<BOOL:${CP2K_USE_ELPA}>:CP2K_ELPA::elpa>
$<$<BOOL:${CP2K_USE_FFTW3}>:CP2K_FFTW3::fftw3>
$<$<BOOL:${CP2K_ENABLE_FFTW3_THREADS_SUPPORT}>:CP2K_FFTW3::fftw3_threads>
$<$<BOOL:${CP2K_ENABLE_FFTW3_OPENMP_SUPPORT}>:CP2K_FFTW3::fftw3_omp>
$<$<BOOL:${CP2K_USE_SPLA}>:SPLA::spla>
$<$<BOOL:${CP2K_USE_LIBINT2}>:CP2K_Libint2::int2>
$<$<BOOL:${CP2K_USE_COSMA}>:cosma::cosma_prefixed_pxgemm>
$<$<BOOL:${CP2K_USE_COSMA}>:cosma::cosma>
$<$<BOOL:${CP2K_USE_COSMA}>:costa::costa>
DBCSR::dbcsr
$<$<BOOL:${CP2K_USE_CUDA}>:CUDA::cufft>
$<$<BOOL:${CP2K_USE_CUDA}>:CUDA::cufftw>
$<$<BOOL:${CP2K_USE_CUDA}>:CUDA::cublas>
$<$<BOOL:${CP2K_USE_CUDA}>:CUDA::cudart>
$<$<BOOL:${CP2K_USE_HIP}>:hip::hipfft>
$<$<BOOL:${CP2K_USE_HIP}>:roc::hipblas>
$<$<BOOL:${CP2K_USE_HIP}>:hip::device>
CP2K_SCALAPACK::scalapack
$<$<BOOL:${CP2K_USE_LIBXSMM}>:CP2K_LibXSMM::libxsmmf>
$<$<BOOL:${CP2K_USE_LIBXSMM}>:CP2K_LibXSMM::libxsmmext>
$<$<BOOL:${CP2K_USE_LIBXSMM}>:CP2K_LibXSMM::libxsmm>
CP2K_LAPACK::lapack
CP2K_BLAS::blas
MPI::MPI_Fortran
MPI::MPI_C
MPI::MPI_CXX
OpenMP::OpenMP_Fortran
OpenMP::OpenMP_C
OpenMP::OpenMP_CXX)
# mix the target and variables pointing to the include directories.
@ -1416,6 +1417,11 @@ include_directories(
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/grid>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/dbm>)
if(DEFINED ENV{CPATH})
string(REPLACE ":" ";" INCLUDE_LIST $ENV{CPATH})
include_directories(${INCLUDE_LIST})
endif()
string(TIMESTAMP CP2K_TIMESTAMP "%Y-%m-%d %H:%M:%S")
target_link_libraries(cp2k PUBLIC cp2k_link_libs)

View file

@ -59,28 +59,34 @@ COPY ./tools/toolchain/scripts/arch_base.tmpl \
./scripts/
RUN ./scripts/generate_arch_files.sh && rm -rf ./build
COPY ./tools/build_utils/fypp /bin/fypp
# temporary solution we build dbcsr without using the cloned repo. It will eventually be moved inside the toolchain
COPY ./tools/docker/scripts/install_dbcsr.sh ./scripts/
RUN ./scripts/install_dbcsr.sh && rm -rf ./build
# Install CP2K using CMake.
WORKDIR /opt/cp2k
COPY ./src ./src
COPY ./exts ./exts
COPY ./tools/build_utils ./tools/build_utils
COPY ./cmake ./cmake
COPY ./CMakeLists.txt .
COPY ./cp2k.pc.in .
WORKDIR ./build
RUN /bin/bash -c " \
echo 'Compiling dbcsr...' && \
source /opt/cp2k-toolchain/install/setup && \
cmake ../exts/dbcsr && \
make -j"
RUN /bin/bash -c " \
echo 'Compiling cp2k...' && \
ls /opt/cp2k-toolchain/install/scalapack-2.2.1 && \
ls /opt/cp2k-toolchain/install/fftw-3.3.10/lib && \
source /opt/cp2k-toolchain/install/setup && \
export PKG_CONFIG_PATH=/opt/cp2k-toolchain/install/openblas-0.3.21/lib/pkgconfig && \
cmake -DCP2K_USE_LIBXSMM=NO -DSCALAPACK_ROOT=/opt/cp2k-toolchain/install/scalapack-2.1.0 .. && \
export PKG_CONFIG_PATH=/opt/cp2k-toolchain/install/libxsmm-1.17/lib:/opt/cp2k-toolchain/install/openblas-0.3.21/lib/pkgconfig:/opt/cp2k-toolchain/install/libxc-6.0.0/lib/pkgconfig:/opt/cp2k-toolchain/install/fftw-3.3.10/lib/pkgconfig:/opt/cp2k-toolchain/install/libint-v2.6.0-cp2k-lmax-5/lib/pkgconfig:/opt/cp2k-toolchain/install/plumed-2.8.0/lib/pkgconfig:/opt/cp2k-toolchain/install/superlu_dist-6.1.0/lib/pkgconfig && \
cmake -DCP2K_USE_COSMA=OFF -DCP2K_USE_LIBXSMM=NO -DSCALAPACK_ROOT=/opt/cp2k-toolchain/install/scalapack-2.2.1 -DCP2K_BLAS_VENDOR=OpenBLAS -DLibXC_ROOT=/opt/cp2k-toolchain/install/libxc-6.0.0 -DLibint2_ROOT=/opt/cp2k-toolchain/install/libint-v2.6.0-cp2k-lmax-5 -DDBCSR_ROOT=/opt/cp2k-toolchain/install/DBCSR-2.4.1 -DCP2K_USE_SPGLIB=ON -DCP2K_USE_LIBINT2=NO -DCP2K_USE_LIBXC=ON -DLibSPG_ROOT=/opt/cp2k-toolchain/install/spglib-1.16.2 .. && \
make -j"
COPY ./data ./data
COPY ./tests ./tests
COPY ./tools/regtesting ./tools/regtesting
RUN echo "\nSummary: Compilation works fine.\nStatus: OK\n"
#EOF

View file

@ -376,28 +376,34 @@ def install_cp2k_cmake() -> str:
# TODO: This is a draft and does not yet actually work.
return rf"""
COPY ./tools/build_utils/fypp /bin/fypp
# temporary solution we build dbcsr without using the cloned repo. It will eventually be moved inside the toolchain
COPY ./tools/docker/scripts/install_dbcsr.sh ./scripts/
RUN ./scripts/install_dbcsr.sh && rm -rf ./build
# Install CP2K using CMake.
WORKDIR /opt/cp2k
COPY ./src ./src
COPY ./exts ./exts
COPY ./tools/build_utils ./tools/build_utils
COPY ./cmake ./cmake
COPY ./CMakeLists.txt .
COPY ./cp2k.pc.in .
WORKDIR ./build
RUN /bin/bash -c " \
echo 'Compiling dbcsr...' && \
source /opt/cp2k-toolchain/install/setup && \
cmake ../exts/dbcsr && \
make -j"
RUN /bin/bash -c " \
echo 'Compiling cp2k...' && \
ls /opt/cp2k-toolchain/install/scalapack-2.2.1 && \
ls /opt/cp2k-toolchain/install/fftw-3.3.10/lib && \
source /opt/cp2k-toolchain/install/setup && \
export PKG_CONFIG_PATH=/opt/cp2k-toolchain/install/openblas-0.3.21/lib/pkgconfig && \
cmake -DCP2K_USE_LIBXSMM=NO -DSCALAPACK_ROOT=/opt/cp2k-toolchain/install/scalapack-2.1.0 .. && \
export PKG_CONFIG_PATH=/opt/cp2k-toolchain/install/libxsmm-1.17/lib:/opt/cp2k-toolchain/install/openblas-0.3.21/lib/pkgconfig:/opt/cp2k-toolchain/install/libxc-6.0.0/lib/pkgconfig:/opt/cp2k-toolchain/install/fftw-3.3.10/lib/pkgconfig:/opt/cp2k-toolchain/install/libint-v2.6.0-cp2k-lmax-5/lib/pkgconfig:/opt/cp2k-toolchain/install/plumed-2.8.0/lib/pkgconfig:/opt/cp2k-toolchain/install/superlu_dist-6.1.0/lib/pkgconfig && \
cmake -DCP2K_USE_COSMA=OFF -DCP2K_USE_LIBXSMM=NO -DSCALAPACK_ROOT=/opt/cp2k-toolchain/install/scalapack-2.2.1 -DCP2K_BLAS_VENDOR=OpenBLAS -DLibXC_ROOT=/opt/cp2k-toolchain/install/libxc-6.0.0 -DLibint2_ROOT=/opt/cp2k-toolchain/install/libint-v2.6.0-cp2k-lmax-5 -DDBCSR_ROOT=/opt/cp2k-toolchain/install/DBCSR-2.4.1 -DCP2K_USE_SPGLIB=ON -DCP2K_USE_LIBINT2=NO -DCP2K_USE_LIBXC=ON -DLibSPG_ROOT=/opt/cp2k-toolchain/install/spglib-1.16.2 .. && \
make -j"
COPY ./data ./data
COPY ./tests ./tests
COPY ./tools/regtesting ./tools/regtesting
RUN echo "\nSummary: Compilation works fine.\nStatus: OK\n"
#EOF
@ -763,7 +769,7 @@ class OutputFile:
output_path = Path(__file__).parent / self.filename
if self.check:
assert output_path.read_text(encoding="utf8") == self.content.getvalue()
print(f"File {output_path} is consisted with generator script.")
print(f"File {output_path} is consistent with generator script.")
else:
output_path.write_text(self.content.getvalue(), encoding="utf8")
print(f"Wrote {output_path}")

View file

@ -0,0 +1,113 @@
#!/bin/bash -e
# TODO: Review and if possible fix shellcheck errors.
# shellcheck disable=all
[ "${BASH_SOURCE[0]}" ] && SCRIPT_NAME="${BASH_SOURCE[0]}" || SCRIPT_NAME=$0
SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_NAME")" && pwd -P)"
DBCSR_ver="2.4.1"
DBCSR_sha256="e5c545ec16688027537f7865976b905c0783d038ec289e65635e63e961330601"
source "${SCRIPT_DIR}"/common_vars.sh
source "${SCRIPT_DIR}"/tool_kit.sh
source "${SCRIPT_DIR}"/signal_trap.sh
source "${INSTALLDIR}"/toolchain.conf
source "${INSTALLDIR}"/toolchain.env
[ -f "${BUILDDIR}/setup_dbcsr" ] && rm "${BUILDDIR}/setup_dbcsr"
DBCSR_CFLAGS=''
DBCSR_LDFLAGS=''
DBCSR_LIBS=''
! [ -d "${BUILDDIR}" ] && mkdir -p "${BUILDDIR}"
cd "${BUILDDIR}"
####case "$with_dbcsr" in
#### __INSTALL__)
echo "==================== Installing DBCSR ===================="
pkg_install_dir="${INSTALLDIR}/DBCSR-${DBCSR_ver}"
install_lock_file="$pkg_install_dir/install_successful"
if verify_checksums "${install_lock_file}"; then
echo "DBCSR-${DBCSR_ver} is already installed, skipping it."
else
if [ -f dbcsr-${DBCSR_ver}.tar.gz ]; then
echo "dbcsr-${DBCSR_ver}.tar.gz is found"
else
wget "https://github.com/cp2k/dbcsr/archive/refs/tags/v${DBCSR_ver}.tar.gz" -O "dbcsr-${DBCSR_ver}.tar.gz"
fi
echo "Installing from scratch into ${pkg_install_dir}"
[ -d dbcsr-${DBCSR_ver} ] && rm -rf dbcsr-${DBCSR_ver}
tar xzf dbcsr-${DBCSR_ver}.tar.gz
cd dbcsr-${DBCSR_ver}
mkdir build
cd build
# build compilation option list
COMPILATION_OPTIONS="-DCMAKE_INSTALL_PREFIX=${pkg_install_dir} -DUSE_OPENMP=ON -DBUILD_TESTING=NO -DWITH_EXAMPLES=NO"
if [ "$MPI_MODE" == "no" ]; then
COMPILATION_OPTIONS="${COMPILATION_OPTIONS} -DUSE_MPI=no"
fi
if [ "$ENABLE_CUDA" == "__TRUE__" ]; then
COMPILATION_OPTIONS="${COMPILATION_OPTIONS} -DUSE_ACCEL=nvidia -DWITH_GPU=P100"
fi
if [ "$ENABLE_HIP" == "__TRUE__" ]; then
COMPILATION_OPTIONS="${COMPILATION_OPTIONS} -DUSE_ACCEL=hip -DWITH_GPU=Mi250"
fi
cmake $COMPILATION_OPTIONS ..
make -j $(get_nprocs) #> make.log 2>&1
make install #> install.log 2>&1
cd ..
write_checksums "${install_lock_file}" "${SCRIPT_DIR}/$(basename ${SCRIPT_NAME})"
DBCSR_CFLAGS="-I'${pkg_install_dir}/include'"
DBCSR_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'"
fi
### ;;
### __SYSTEM__)
### echo "==================== Finding DBCSR from system paths ===================="
### check_lib -ldbcsr "dbcsr"
### add_include_from_paths DBCSR_CFLAGS "dbcsr.h" $INCLUDE_PATHS
### add_lib_from_paths DBCSR_LDFLAGS "dbcsr.*" $LIB_PATHS
### ;;
### __DONTUSE__)
### report_error ${LINENO} "It is not possible to compile cp2k without dbcsr"
### ;;
### *)
echo "==================== Linking DBCSR to user paths ===================="
#####pkg_install_dir="$with_dbcsr"
check_dir "${pkg_install_dir}/lib"
check_dir "${pkg_install_dir}/include"
DBCSR_CFLAGS="-I'${pkg_install_dir}/include'"
DBCSR_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'"
##;;
##esac
##if [ "$with_dbcsr" != "__DONTUSE__" ]; then
DBCSR_LIBS="-ldbcsr"
## if [ "$with_dbscr" != "__SYSTEM__" ]; then
## cat << EOF > "${BUILDDIR}/setup_dbcsr"
##prepend_path LD_LIBRARY_PATH "$pkg_install_dir/lib"
##prepend_path LD_RUN_PATH "$pkg_install_dir/lib"
##prepend_path LIBRARY_PATH "$pkg_install_dir/lib"
##prepend_path CPATH "$pkg_install_dir/include"
##EOF
## cat "${BUILDDIR}/setup_dbcsr" >> $SETUPFILE
## fi
cat << EOF >> "${BUILDDIR}/setup_dbcsr"
export DBCSR_CFLAGS="${DBCSR_CFLAGS}"
export DBCSR_LDFLAGS="${DBCSR_LDFLAGS}"
export DBCSR_LIBS="${DBCSR_LIBS}"
export CP_DFLAGS="\${CP_DFLAGS} IF_CUDA(-D__DBCSR_ACC -D__DBCSR|IF_HIP(-D__DBCSR_ACC -D__DBCSR|-D__DBCSR))"
export CP_CFLAGS="\${CP_CFLAGS} ${DBCSR_CFLAGS}"
export CP_LDFLAGS="\${CP_LDFLAGS} ${DBCSR_LDFLAGS}"
export CP_LIBS="${DBCSR_LIBS} \${CP_LIBS}"
export DBCSRROOT="$pkg_install_dir"
EOF
#else
# echo "DBCSR is a hard dependency for cp2k"
# exit 1
#fi
load "${BUILDDIR}/setup_dbcsr"
write_toolchain_env "${INSTALLDIR}"
cd "${ROOTDIR}"
report_timing "DBCSR"

View file

@ -6,12 +6,9 @@
[ "${BASH_SOURCE[0]}" ] && SCRIPT_NAME="${BASH_SOURCE[0]}" || SCRIPT_NAME=$0
SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_NAME")/.." && pwd -P)"
scalapack_ver="2.1.0"
scalapack_sha256="61d9216cf81d246944720cfce96255878a3f85dec13b9351f1fa0fd6768220a6"
scalapack_ver="2.2.1"
scalapack_sha256="4aede775fdb28fa44b331875730bcd5bab130caaec225fadeccf424c8fcb55aa"
scalapack_pkg="scalapack-${scalapack_ver}.tgz"
patches=(
"${SCRIPT_DIR}/stage4/scalapack-${scalapack_ver}-gcc10.patch"
)
source "${SCRIPT_DIR}"/common_vars.sh
source "${SCRIPT_DIR}"/tool_kit.sh
@ -45,20 +42,16 @@ case "$with_scalapack" in
[ -d scalapack-${scalapack_ver} ] && rm -rf scalapack-${scalapack_ver}
tar -xzf ${scalapack_pkg}
pushd "scalapack-${scalapack_ver}" > /dev/null
for patch in "${patches[@]}"; do
patch -p1 < "${patch}" >> patch.log 2>&1
done
popd > /dev/null
mkdir -p "scalapack-${scalapack_ver}/build"
pushd "scalapack-${scalapack_ver}/build" > /dev/null
cmake -DCMAKE_FIND_ROOT_PATH="$ROOTDIR" \
FFLAGS="-fallow-argument-mismatch" cmake -DCMAKE_FIND_ROOT_PATH="$ROOTDIR" \
-DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \
-DCMAKE_INSTALL_LIBDIR="lib" \
-DBUILD_SHARED_LIBS=NO \
-DCMAKE_BUILD_TYPE=Release .. \
-DBUILD_TESTING=NO \
-DSCALAPACK_BUILD_TESTS=NO \
> configure.log 2>&1 || tail -n ${LOG_LINES} configure.log
make -j $(get_nprocs) > make.log 2>&1 || tail -n ${LOG_LINES} make.log
make install >> make.log 2>&1 || tail -n ${LOG_LINES} make.log

File diff suppressed because it is too large Load diff