Commit e5bba30f authored by one's avatar one
Browse files

Initial commit

parents
# -*- conf -*-
# This is the only flake8 rule Spack violates somewhat flagrantly
# - E731: do not assign a lambda expression, use a def
#
# This is the only flake8 exception needed when using Black.
# - E203: white space around slice operators can be required, ignore : warn
#
# We still allow these in packages
# - F403: from/import * used; unable to detect undefined names
# - F405: undefined name or from *
# - F821: undefined name (needed with from/import *)
#
[flake8]
extend-ignore = E731,E203
max-line-length = 99
per-file-ignores =
*/package.py:F403,F405,F821
format = spack
[flake8:local-plugins]
report =
spack = flake8_formatter:SpackFormatter
paths =
./spack-core/share/spack/qa/
\ No newline at end of file
/spack-core
/pyrightconfig.json
###########################
# Python-specific ignores #
###########################
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
#lib/
#lib64/
parts/
sdist/
#var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# 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
# 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
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
########################
# Vim-specific ignores #
########################
# 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]
[._]sw[a-p]
# Session
Session.vim
Sessionx.vim
# Temporary
.netrwhist
*~
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~
##########################
# Emacs-specific ignores #
##########################
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
auto-save-list
tramp
.\#*
# Org-mode
.org-id-locations
# flymake-mode
*_flymake.*
# eshell files
/eshell/history
/eshell/lastdir
# zsh byte-compiled files
*.zwc
# elpa packages
/elpa/
# reftex files
*.rel
# AUCTeX auto folder
/auto/
# cask packages
.cask/
dist/
# Flycheck
flycheck_*.el
# server auth directory
/server/
# projectiles files
.projectile
# directory configuration
.dir-locals.el
# network security
/network-security.data
############################
# Eclipse-specific ignores #
############################
.metadata
#bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# PyDev specific (Python IDE for Eclipse)
*.pydevproject
# CDT-specific (C/C++ Development Tooling)
.cproject
# CDT- autotools
.autotools
# Java annotation processor (APT)
.factorypath
# PDT-specific (PHP Development Tools)
.buildpath
# sbteclipse plugin
.target
# Tern plugin
.tern-project
# TeXlipse plugin
.texlipse
# STS (Spring Tool Suite)
.springBeans
# Code Recommenders
.recommenders/
# Annotation Processing
.apt_generated/
.apt_generated_test/
# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet
# Uncomment this line if you wish to ignore the project description file.
# Typically, this file would be tracked if it contains build/dependency configurations:
#.project
##################################
# Visual Studio-specific ignores #
##################################
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
#################################
# Sublime Text-specific ignores #
#################################
# Cache files for Sublime Text
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache
# Workspace files are user-specific
*.sublime-workspace
# Project files should be checked into the repository, unless a significant
# proportion of contributors will probably not be using Sublime Text
# *.sublime-project
# SFTP configuration file
sftp-config.json
sftp-config-alt*.json
# Package control specific files
Package Control.last-run
Package Control.ca-list
Package Control.ca-bundle
Package Control.system-ca-bundle
Package Control.cache/
Package Control.ca-certs/
Package Control.merged-ca-bundle
Package Control.user-ca-bundle
oscrypto-ca-bundle.crt
bh_unicode_properties.cache
# Sublime-github package stores a github token in this file
# https://packagecontrol.io/packages/sublime-github
GitHub.sublime-settings
##############################
# JetBrains-specific ignores #
##############################
# Ignore the entire folder since it may conatin more files than
# just the ones listed below
.idea/
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
##########################
# macOS-specific ignores #
##########################
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
##########################
# Linux-specific ignores #
##########################
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
############################
# Windows-specific ignores #
############################
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
\ No newline at end of file
diff -Naru a/src/qs_kpp1_env_methods.F b/src/qs_kpp1_env_methods.F
--- a/src/qs_kpp1_env_methods.F 2022-10-03 01:14:25.720416300 +0530
+++ b/src/qs_kpp1_env_methods.F 2023-06-14 02:33:05.205287205 +0530
@@ -214,7 +214,6 @@
output_unit
LOGICAL :: gapw, gapw_xc, lsd, my_calc_forces
REAL(KIND=dp) :: alpha, energy_hartree, energy_hartree_1c
- REAL(KIND=dp), DIMENSION(:, :, :, :), POINTER :: vxg
TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
TYPE(cp_logger_type), POINTER :: logger
TYPE(cp_para_env_type), POINTER :: para_env
@@ -373,7 +372,8 @@
CALL xc_calc_2nd_deriv(v_xc, v_xc_tau, p_env%kpp1_env%deriv_set, p_env%kpp1_env%rho_set, &
rho1_r_pw, rho1_g_pw, tau1_r_pw, auxbas_pw_pool, xc_section, .FALSE., &
- NULL(vxg), lsd_singlets, do_excitations, do_triplet, do_tddft, &
+ lsd_singlets=lsd_singlets, do_excitations=do_excitations, &
+ do_triplet=do_triplet, do_tddft=do_tddft, &
compute_virial=calc_virial, virial_xc=virial)
DO ispin = 1, nspins
diff -Naru a/src/qs_kpp1_env_methods.F b/src/qs_kpp1_env_methods.F
--- a/src/qs_kpp1_env_methods.F 2021-11-20 14:35:36.103103400 +0530
+++ b/src/qs_kpp1_env_methods.F 2023-06-14 12:00:52.350584708 +0530
@@ -220,7 +220,6 @@
output_unit
LOGICAL :: gapw, gapw_xc, lsd, my_calc_forces
REAL(KIND=dp) :: alpha, energy_hartree, energy_hartree_1c
- REAL(KIND=dp), DIMENSION(:, :, :, :), POINTER :: vxg
TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
TYPE(cp_logger_type), POINTER :: logger
TYPE(cp_para_env_type), POINTER :: para_env
@@ -361,7 +360,8 @@
CALL xc_calc_2nd_deriv(v_xc, p_env%kpp1_env%deriv_set, p_env%kpp1_env%rho_set, &
rho1_r_pw, rho1_g_pw, auxbas_pw_pool, xc_section, .FALSE., &
- NULL(vxg), lsd_singlets, do_excitations, do_triplet, do_tddft, &
+ lsd_singlets=lsd_singlets, do_excitations=do_excitations, &
+ do_triplet=do_triplet, do_tddft=do_tddft, &
compute_virial=calc_virial, virial_xc=virial)
DO ispin = 1, nspins
From b75eb217115820059aba26d1ff1a8657e3841e7d Mon Sep 17 00:00:00 2001
From: Mathieu Taillefumier <mathieu.taillefumier@free.fr>
Date: Mon, 23 Oct 2023 15:50:44 +0200
Subject: [PATCH] cmake-fixes-2023.2
---
CMakeLists.txt | 63 +++++++-----
cmake/FindBlas.cmake | 174 +++++++++++++++++-----------------
cmake/FindLapack.cmake | 47 ++++-----
cmake/cp2k.pc.in | 19 ----
cmake/cp2kConfig.cmake.in | 195 ++++++++++++++++++++------------------
cmake/libcp2k.pc.in | 11 +++
src/CMakeLists.txt | 18 ++--
7 files changed, 276 insertions(+), 251 deletions(-)
delete mode 100644 cmake/cp2k.pc.in
create mode 100644 cmake/libcp2k.pc.in
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3f81c7b52..f2d85d033 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -49,7 +49,8 @@ if(NOT DEFINED CMAKE_CUDA_STANDARD)
endif()
# set language and standard
-set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_C_STANDARD 11)
find_package(PkgConfig)
@@ -108,6 +109,10 @@ option(CP2K_USE_LIBXSMM "Use libxsmm for small gemms (supports x86 platforms)"
OFF)
option(CP2K_BUILD_DBCSR "Duild dbcsr at the same time than cp2k." OFF)
option(BUILD_SHARED_LIBS "Build cp2k shared library" ON)
+option(
+ CP2K_USE_FFTW3_WITH_MKL
+ "If set to ON use the original implementation of fftw3 instead of the MKL implementation."
+ OFF)
cmake_dependent_option(CP2K_ENABLE_ELPA_OPENMP_SUPPORT
"Enable elpa openmp support" ON "CP2K_USE_ELPA" OFF)
@@ -115,8 +120,8 @@ 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)
-cmake_dependent_option(CP2K_ENABLE_F08_MPI "Enable MPI Fortran 2008 interface"
- OFF "CP2K_USE_MPI" OFF)
+cmake_dependent_option(CP2K_USE_MPI_F08 "Enable MPI Fortran 2008 interface" OFF
+ "CP2K_USE_MPI" OFF)
cmake_dependent_option(
DBCSR_USE_ACCEL
@@ -527,7 +532,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
@@ -620,27 +625,36 @@ endif()
# FFTW3
+set(CP2K_USE_FFTW3_ OFF)
if(CP2K_USE_FFTW3)
- find_package(Fftw REQUIRED)
- if(CP2K_ENABLE_FFTW3_THREADS_SUPPORT AND CP2K_ENABLE_FFTW3_OPENMP_SUPPORT)
- message(
- FATAL_ERROR
- "Fftw3 threads and openmp supports can not be used at the same time")
- endif()
+ if(CP2K_USE_FFTW3_WITH_MKL OR NOT CP2K_BLAS_VENDOR MATCHES "MKL")
+ find_package(Fftw REQUIRED)
+ if(CP2K_ENABLE_FFTW3_THREADS_SUPPORT AND CP2K_ENABLE_FFTW3_OPENMP_SUPPORT)
+ message(
+ FATAL_ERROR
+ "Fftw3 threads and openmp supports can not be used at the same time")
+ endif()
- if((CP2K_ENABLE_FFTW3_THREADS_SUPPORT) AND (NOT TARGET
- CP2K::FFTW3::fftw3_threads))
- message(
- FATAL_ERROR
- "fftw3 was compiled without multithreading support (--enable-threads option in fftw build system)."
- )
- endif()
+ if((CP2K_ENABLE_FFTW3_THREADS_SUPPORT) AND (NOT TARGET
+ CP2K::FFTW3::fftw3_threads))
+ message(
+ FATAL_ERROR
+ "fftw3 was compiled without multithreading support (--enable-threads option in 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)."
- )
+ 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()
+ # we use this variable later on to include the fftw target whenever mkl is
+ # found or not
+ set(CP2K_USE_FFTW3_ ON)
+ else()
+ message("-- Using the MKL implementation of FFTW3.")
endif()
endif()
@@ -748,7 +762,7 @@ add_subdirectory(src)
include(GNUInstallDirs)
get_target_property(CP2K_LIBS cp2k_link_libs INTERFACE_LINK_LIBRARIES)
-configure_file(cmake/cp2k.pc.in cp2k.pc @ONLY)
+configure_file(cmake/libcp2k.pc.in libcp2k.pc @ONLY)
message(
STATUS "--------------------------------------------------------------------")
@@ -1039,6 +1053,9 @@ install(FILES "${PROJECT_BINARY_DIR}/cp2kConfig.cmake"
"${PROJECT_BINARY_DIR}/cp2kConfigVersion.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/cp2k")
+install(FILES "${PROJECT_BINARY_DIR}/libcp2k.pc"
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
+
install(
DIRECTORY "${PROJECT_SOURCE_DIR}/cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/cp2k"
diff --git a/cmake/FindBlas.cmake b/cmake/FindBlas.cmake
index 6e5fb7824..335cbd964 100644
--- a/cmake/FindBlas.cmake
+++ b/cmake/FindBlas.cmake
@@ -15,104 +15,108 @@ if(NOT
OR CMAKE_Fortran_COMPILER_LOADED))
message(FATAL_ERROR "FindBLAS requires Fortran, C, or C++ to be enabled.")
endif()
+if(NOT CP2K_CONFIG_PACKAGE)
+ set(CP2K_BLAS_VENDOR_LIST
+ "auto"
+ "MKL"
+ "OpenBLAS"
+ "SCI"
+ "GenericBLAS"
+ "Armpl"
+ "FlexiBLAS"
+ "Atlas"
+ "NVHPCBlas"
+ "CUSTOM")
+
+ set(__BLAS_VENDOR_LIST ${CP2K_BLAS_VENDOR_LIST})
+ list(REMOVE_ITEM __BLAS_VENDOR_LIST "auto")
+ list(REMOVE_ITEM __BLAS_VENDOR_LIST "CUSTOM")
+
+ # 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_VENDOR_LIST
- "auto"
- "MKL"
- "OpenBLAS"
- "SCI"
- "GenericBLAS"
- "Armpl"
- "FlexiBLAS"
- "Atlas"
- "NVHPCBlas"
- "CUSTOM")
-
-set(__BLAS_VENDOR_LIST ${CP2K_BLAS_VENDOR_LIST})
-list(REMOVE_ITEM __BLAS_VENDOR_LIST "auto")
-list(REMOVE_ITEM __BLAS_VENDOR_LIST "CUSTOM")
-
-# 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_THREAD_LIST "sequential" "thread" "gnu-thread" "intel-thread"
+ "tbb-thread" "openmp")
-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_THREADING
+ "sequential"
+ CACHE STRING "threaded blas library")
+ set_property(CACHE CP2K_BLAS_THREADING PROPERTY STRINGS
+ ${CP2K_BLAS_THREAD_LIST})
-set(CP2K_BLAS_FOUND FALSE)
+ if(NOT ${CP2K_BLAS_THREADING} IN_LIST CP2K_BLAS_THREAD_LIST)
+ message(FATAL_ERROR "Invalid threaded BLAS backend")
+ endif()
-# first check for a specific implementation if requested
+ 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_VENDOR MATCHES "auto|CUSTOM")
- find_package(${CP2K_BLAS_VENDOR} REQUIRED)
- if(TARGET CP2K::BLAS::${CP2K_BLAS_VENDOR}::blas)
- get_target_property(
- CP2K_BLAS_INCLUDE_DIRS CP2K::BLAS::${CP2K_BLAS_VENDOR}::blas
- INTERFACE_INCLUDE_DIRECTORIES)
- get_target_property(
- CP2K_BLAS_LINK_LIBRARIES CP2K::BLAS::${CP2K_BLAS_VENDOR}::blas
- INTERFACE_LINK_LIBRARIES)
- set(CP2K_BLAS_FOUND TRUE)
- endif()
-else()
- if(CP2K_BLAS_VENDOR MATCHES "CUSTOM" AND NOT DEFINED CP2K_BLAS_LINK_LIBRARIES)
+ if(NOT ${CP2K_BLAS_INTERFACE} IN_LIST CP2K_BLAS_INTERFACE_BITS_LIST)
message(
FATAL_ERROR
- "Setting CP2K_BLAS_VENDOR=CUSTOM imply setting CP2K_BLAS_LINK_LIBRARIES\n and CP2K_LAPACK_LINK_LIBRARIES to the right libraries. See the README_cmake.md for more details"
+ "Invalid parameters. Blas and lapack can exist in two flavors 32 or 64 bits interfaces (relevant mostly for mkl)"
)
endif()
- if(DEFINED CP2K_BLAS_LINK_LIBRARIES)
- set(CP2K_BLAS_FOUND TRUE)
+ set(CP2K_BLAS_FOUND FALSE)
+
+ # first check for a specific implementation if requested
+
+ if(NOT CP2K_BLAS_VENDOR MATCHES "auto|CUSTOM")
+ find_package(${CP2K_BLAS_VENDOR} REQUIRED)
+ if(TARGET CP2K::BLAS::${CP2K_BLAS_VENDOR}::blas)
+ get_target_property(
+ CP2K_BLAS_INCLUDE_DIRS CP2K::BLAS::${CP2K_BLAS_VENDOR}::blas
+ INTERFACE_INCLUDE_DIRECTORIES)
+ get_target_property(
+ CP2K_BLAS_LINK_LIBRARIES CP2K::BLAS::${CP2K_BLAS_VENDOR}::blas
+ INTERFACE_LINK_LIBRARIES)
+ set(CP2K_BLAS_FOUND TRUE)
+ endif()
else()
- # search for any blas implementation and exit immediately if one is found.
- # we could also give a full list of found implementation and let the user
- # choose which implementation to use
- foreach(_libs ${__BLAS_VENDOR_LIST})
- # I exclude the first item of the list
- find_package(${_libs})
- if(TARGET CP2K::BLAS::${_libs}::blas)
- get_target_property(CP2K_BLAS_INCLUDE_DIRS CP2K::BLAS::${_libs}::blas
- INTERFACE_INCLUDE_DIRECTORIES)
- get_target_property(CP2K_BLAS_LINK_LIBRARIES CP2K::BLAS::${_libs}::blas
- INTERFACE_LINK_LIBRARIES)
- set(CP2K_BLAS_VENDOR "${_libs}")
- set(CP2K_BLAS_FOUND TRUE)
- break()
- endif()
- endforeach()
+ if(CP2K_BLAS_VENDOR MATCHES "CUSTOM" AND NOT DEFINED
+ CP2K_BLAS_LINK_LIBRARIES)
+ message(
+ FATAL_ERROR
+ "Setting CP2K_BLAS_VENDOR=CUSTOM imply setting CP2K_BLAS_LINK_LIBRARIES\n and CP2K_LAPACK_LINK_LIBRARIES to the right libraries. See the README_cmake.md for more details"
+ )
+ endif()
+
+ if(DEFINED CP2K_BLAS_LINK_LIBRARIES)
+ set(CP2K_BLAS_FOUND TRUE)
+ else()
+ # search for any blas implementation and exit immediately if one is found.
+ # we could also give a full list of found implementation and let the user
+ # choose which implementation to use
+ foreach(_libs ${__BLAS_VENDOR_LIST})
+ # I exclude the first item of the list
+ find_package(${_libs})
+ if(TARGET CP2K::BLAS::${_libs}::blas)
+ get_target_property(CP2K_BLAS_INCLUDE_DIRS CP2K::BLAS::${_libs}::blas
+ INTERFACE_INCLUDE_DIRECTORIES)
+ get_target_property(
+ CP2K_BLAS_LINK_LIBRARIES CP2K::BLAS::${_libs}::blas
+ INTERFACE_LINK_LIBRARIES)
+ set(CP2K_BLAS_VENDOR "${_libs}")
+ set(CP2K_BLAS_FOUND TRUE)
+ break()
+ endif()
+ endforeach()
+ endif()
endif()
+else()
+ set(CP2K_BLAS_FOUND ON)
endif()
-
# we exclude the CP2K_BLAS_INCLUDE_DIRS from the list of mandatory variables as
# having the fortran interface is usually enough. C, C++ and others languages
# might require this information though
diff --git a/cmake/FindLapack.cmake b/cmake/FindLapack.cmake
index 966e0d78d..77a1e0425 100644
--- a/cmake/FindLapack.cmake
+++ b/cmake/FindLapack.cmake
@@ -20,33 +20,34 @@ include(FindPackageHandleStandardArgs)
find_package(PkgConfig)
find_package(Blas REQUIRED)
-if(CP2K_BLAS_FOUND)
- # LAPACK in the Intel MKL 10+ library?
- if(CP2K_BLAS_VENDOR MATCHES "MKL|OpenBLAS|Armpl|SCI|FlexiBLAS|NVHPC")
- # 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_LINK_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_CONFIG_PACKAGE)
+ if(CP2K_BLAS_FOUND)
+ # LAPACK in the Intel MKL 10+ library?
+ if(CP2K_BLAS_VENDOR MATCHES "MKL|OpenBLAS|Armpl|SCI|FlexiBLAS|NVHPC")
+ # 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_LINK_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_LINK_LIBRARIES
- NAMES "lapack" "lapack64"
- PATH_SUFFIXES "openblas" "openblas64" "openblas-pthread"
- "openblas-openmp" "lib" "lib64"
- NO_DEFAULT_PATH)
+ if(NOT CP2K_LAPACK_FOUND)
+ find_library(
+ CP2K_LAPACK_LINK_LIBRARIES
+ NAMES "lapack" "lapack64"
+ PATH_SUFFIXES "openblas" "openblas64" "openblas-pthread"
+ "openblas-openmp" "lib" "lib64"
+ NO_DEFAULT_PATH)
+ endif()
endif()
endif()
endif()
-
# check if found
find_package_handle_standard_args(Lapack
REQUIRED_VARS CP2K_LAPACK_LINK_LIBRARIES)
diff --git a/cmake/cp2k.pc.in b/cmake/cp2k.pc.in
deleted file mode 100644
index 5b4a09566..000000000
--- a/cmake/cp2k.pc.in
+++ /dev/null
@@ -1,19 +0,0 @@
-# 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 -lcp2k_dbm -lcp2k_grid -lcp2k_offload
-#Libs.private: -L"${libdir}" @CP2K_LIBS@
\ No newline at end of file
diff --git a/cmake/cp2kConfig.cmake.in b/cmake/cp2kConfig.cmake.in
index a3acd4744..1c310e19b 100644
--- a/cmake/cp2kConfig.cmake.in
+++ b/cmake/cp2kConfig.cmake.in
@@ -5,112 +5,121 @@
#! SPDX-License-Identifier: GPL-2.0-or-later !
#!-------------------------------------------------------------------------------------------------!
-
cmake_minimum_required(VERSION 3.22)
+include(CMakeFindDependencyMacro)
+
+if(NOT TARGET cp2k::cp2k)
+ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/modules"
+ ${CMAKE_MODULE_PATH})
+
+ # store CXX compiler id. Used in MKL package.
+ set(CP2K_CXX_COMPILER_ID @CMAKE_CXX_COMPILER_ID@)
+ if(NOT ${CMAKE_CXX_COMPILER_ID})
+ set(CMAKE_CXX_COMPILER_ID ${CP2K_CXX_COMPILER_ID})
+ endif()
+
+ set(CP2K_BLAS_VENDOR @CP2K_BLAS_VENDOR@)
+ set(CP2K_SCALAPACK_VENDOR @CP2K_SCALAPACK_VENDOR@)
+ set(CP2K_BLAS_LINK_LIBRARIES @CP2K_BLAS_LINK_LIBRARIES@)
+ set(CP2K_LAPACK_LINK_LIBRARIES @CP2K_LAPACK_LINK_LIBRARIES@)
+ set(CP2K_SCALAPACK_LINK_LIBRARIES @CP2K_SCALAPACK_LINK_LIBRARIES@)
+
+ set(CP2K_CONFIG_PACKAGE ON)
+ find_dependency(Lapack REQUIRED)
+
+ # define lapack and blas TARGETS
+
+ if(@CP2K_USE_MPI@)
+ find_dependency(SCALAPACK REQUIRED)
+ endif()
+ unset(CP2K_CONFIG_PACKAGE)
+
+ set(cp2k_VERSION @cp2k_VERSION@)
+
+ find_dependency(DBCSR 2.5 REQUIRED)
+
+ if(@CP2K_USE_LIBXSMM@)
+ find_dependency(LibXSMM REQUIRED)
+ endif()
+
+ if(@CP2K_USE_HIP@)
+ # Find hip
+ find_dependency(hipfft REQUIRED IMPORTED CONFIG)
+ find_dependency(hipblas REQUIRED IMPORTED CONFIG)
+ endif()
+
+ if(@CP2K_USE_CUDA@)
+ find_dependency(CUDAToolkit REQUIRED)
+ endif()
+ if(@CP2K_USE_ELPA@)
+ find_dependency(Elpa REQUIRED)
+ endif()
+
+ if(@CP2K_USE_LIBXC@)
+ find_dependency(LibXC 6 REQUIRED EXACT)
+ endif()
+
+ if(@CP2K_USE_COSMA@)
+ find_dependency(cosma REQUIRED)
+ endif()
+
+ if(@CP2K_USE_MPI@)
+ find_dependency(MPI REQUIRED)
+ endif()
+
+ if(@CP2K_USE_FFTW3@ OR @CP2K_USE_FFTW3_WITH_MKL@)
+ find_dependency(Fftw REQUIRED)
+ endif()
+
+ # QUIP
+ if(@CP2K_USE_QUIP@)
+ find_dependency(Quip REQUIRED)
+ endif()
-# store CXX compiler id. Used in MKL package.
-set(SIRIUS_CXX_COMPILER_ID @CMAKE_CXX_COMPILER_ID@)
-if(NOT ${CMAKE_CXX_COMPILER_ID})
- set(CMAKE_CXX_COMPILER_ID ${SIRIUS_CXX_COMPILER_ID})
-endif()
-
-set(CP2K_BLAS_VENDOR @CP2K_BLAS_VENDOR@)
-set(CP2K_SCALAPACK_VENDOR @CP2K_SCALAPACK_VENDOR@)
-
-if (@CP2K_BLAS_VENDOR@ MATCHES "CUSTOM")
- set(CP2K_BLAS_LINK_LIBRARIES @CP2K_BLAS_LINK_LIBRARIES@)
- set(CP2K_LAPACK_LINK_LIBRARIES @CP2K_LAPACK_LINK_LIBRARIES@)
-endif()
-
-if (@CP2K_SCALAPACK_VENDOR@ MATCHES "CUSTOM")
- set(CP2K_SCALAPACK_LINK_LIBRARIES @CP2K_SCALAPACK_LINK_LIBRARIES@)
-endif()
-
-find_package(Lapack REQUIRED)
-find_package(DBCSR 2.4 REQUIRED)
-
-if(@CP2K_USE_LIBXSMM@
- find_package(LibXSMM REQUIRED)
-endif()
-
-if (@@CP2K_USE_HIP@)
- # Find hip
- find_package(hipfft REQUIRED IMPORTED CONFIG)
- find_package(hipblas REQUIRED IMPORTED CONFIG)
-endif()
-
-if (@@CP2K_USE_CUDA@)
- find_package(CUDAToolkit REQUIRED)
-endif()
-if(@CP2K_USE_ELPA@)
- find_package(Elpa REQUIRED)
-endif()
-
-if(@CP2K_USE_LIBXC@)
- find_package(LibXC 6 REQUIRED EXACT)
-endif()
-
-if(@CP2K_USE_COSMA@)
- find_package(cosma REQUIRED)
-endif()
+ # libint
-if (@@CP2K_USE_MPI@)
- find_package(MPI REQUIRED)
- find_package(SCALAPACK REQUIRED)
-endif()
+ if(@CP2K_USE_LIBINT2@)
+ find_dependency(Libint2 REQUIRED)
+ endif()
-if(@CP2K_USE_FFTW3@)
- find_package(Fftw REQUIRED)
-endif()
- # QUIP
-if(@CP2K_USE_QUIP@)
- find_package(Quip REQUIRED)
-endif()
+ # spglib
-# libint
+ if(@CP2K_USE_SPGLIB@)
+ find_dependency(LibSPG REQUIRED)
+ endif()
-if(@CP2K_USE_LIBINT2@)
- find_package(Libint2 REQUIRED)
-endif()
+ if(@CP2K_USE_SPLA@)
+ find_dependency(SPLA REQUIRED)
+ endif()
-# spglib
+ if(@CP2K_USE_SIRIUS@)
+ find_dependency(sirius REQUIRED)
+ endif()
-if(@CP2K_USE_SPGLIB@)
- find_package(LibSPG REQUIRED)
-endif()
+ if(@CP2K_USE_SUPERLU@)
+ find_dependency(SuperLU REQUIRED)
+ endif()
-if(@CP2K_USE_SPLA@)
- find_package(SPLA REQUIRED)
-endif()
+ if(@CP2K_USE_METIS@)
+ find_dependency(Metis)
+ endif()
-if(@CP2K_USE_SIRIUS@)
- find_package(sirius REQUIRED)
-endif()
-
-if(@CP2K_USE_SUPERLU@)
- find_package(SuperLU REQUIRED)
-endif()
+ if(@CP2K_USE_PEXSI@)
+ # PEXSI 1.2 uses cmake as build system
+ find_dependency(PEXSI REQUIRED)
+ endif()
-if(@CP2K_USE_PARMETIS@)
- find_package(Metis)
-endif()
+ if(@CP2K_USE_PLUMED@)
+ find_dependency(Plumed REQUIRED)
+ endif()
-if(@CP2K_USE_PTSCOTCH@)
- find_package(Ptscotch REQUIRED)
-endif()
+ if(@CP2K_USE_LIBTORCH@)
+ find_dependency(Torch REQUIRED)
+ endif()
-if(@CP2K_USE_PEXSI@)
- # PEXSI 1.2 uses cmake as build system
- find_package(PEXSI REQUIRED)
-endif()
+ include("${CMAKE_CURRENT_LIST_DIR}/cp2kTargets.cmake")
-if(@CP2K_USE_PLUMED@)
- find_package(Plumed REQUIRED)
-endif()
+ # Clean-up module path.
+ list(REMOVE_ITEM CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/modules")
-if(@CP2K_USE_LIBTORCH@)
- find_package(Torch REQUIRED)
endif()
-
-# Include SIRIUS target
-include("${CMAKE_CURRENT_LIST_DIR}/cp2kTargets.cmake")
diff --git a/cmake/libcp2k.pc.in b/cmake/libcp2k.pc.in
new file mode 100644
index 000000000..618af55e2
--- /dev/null
+++ b/cmake/libcp2k.pc.in
@@ -0,0 +1,11 @@
+prefix="@CMAKE_INSTALL_PREFIX@"
+exec_prefix="${prefix}"
+libdir="${prefix}/@CMAKE_INSTALL_LIBDIR@"
+includedir="${prefix}/@CMAKE_INSTALL_INCLUDEDIR@"
+
+Name: @PROJECT_NAME@
+Description: @CMAKE_PROJECT_DESCRIPTION@
+URL: @CMAKE_PROJECT_HOMEPAGE_URL@
+Version: @PROJECT_VERSION@
+Cflags: -I"${includedir}/cp2k" -I"${includedir}/cp2k/@CMAKE_Fortran_COMPILER_ID@-@CMAKE_Fortran_COMPILER_VERSION@"
+Libs: -L"${libdir}" -lcp2k
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index dbc955885..1178101ad 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1536,9 +1536,9 @@ target_link_libraries(
$<$<BOOL:${CP2K_USE_SPGLIB}>:CP2K::LIBSPG::libspg>
$<$<BOOL:${CP2K_USE_LIBXC}>:CP2K::Libxc::xc>
$<$<BOOL:${CP2K_USE_ELPA}>:CP2K::ELPA::elpa>
- $<$<BOOL:${CP2K_USE_FFTW3}>:CP2K::FFTW3::fftw3>
- $<$<BOOL:${CP2K_ENABLE_FFTW3_THREADS_SUPPORT}>:CP2K::FFTW3::fftw3_threads>
- $<$<BOOL:${CP2K_ENABLE_FFTW3_OPENMP_SUPPORT}>:CP2K::FFTW3::fftw3_omp>
+ $<$<BOOL:${CP2K_USE_FFTW3_}>:CP2K::FFTW3::fftw3>
+ $<$<AND:$<BOOL:${CP2K_ENABLE_FFTW3_THREADS_SUPPORT}>,$<BOOL:${CP2K_USE_FFTW3_}>>:CP2K::FFTW3::fftw3_threads>
+ $<$<AND:$<BOOL:${CP2K_ENABLE_FFTW3_OPENMP_SUPPORT}>,$<BOOL:${CP2K_USE_FFTW3_}>>:CP2K::FFTW3::fftw3_omp>
$<$<BOOL:${CP2K_USE_SPLA}>:SPLA::spla>
$<$<BOOL:${CP2K_USE_LIBINT2}>:CP2K::Libint2::int2>
$<$<BOOL:${CP2K_USE_TORCH}>:${TORCH_LIBRARIES}>
@@ -1555,7 +1555,7 @@ target_compile_definitions(
cp2k
PUBLIC $<$<BOOL:${CP2K_USE_MPI}>:__parallel>
$<$<BOOL:${CP2K_USE_MPI}>:__SCALAPACK>
- $<$<BOOL:${CP2K_ENABLE_F08_MPI}>:__MPI_08>
+ $<$<BOOL:${CP2K_USE_MPI_F08}>:__MPI_F08>
__COMPILE_DATE=\"${CP2K_TIMESTAMP}\"
__COMPILE_HOST=\"${CP2K_HOST_NAME}\"
__COMPILE_REVISION=\"${CP2K_GIT_HASH}\"
@@ -1577,7 +1577,7 @@ target_compile_definitions(
$<$<BOOL:${CP2K_USE_SPLA_GEMM_OFFLOADING}>:__OFFLOAD_GEMM>
$<$<BOOL:${CP2K_USE_ELPA}>:__ELPA>
$<$<BOOL:${CP2K_USE_LIBXC}>:__LIBXC>
- $<$<BOOL:${CP2K_USE_FFTW3}>:__FFTW3>
+ $<$<BOOL:${CP2K_USE_FFTW3_}>:__FFTW3>
$<$<BOOL:${CP2K_USE_LIBINT2}>:__LIBINT>
$<$<BOOL:${CP2K_USE_PEXSI}>:__LIBPEXSI>
$<$<BOOL:${CP2K_USE_LIBTORCH}>:__LIBTORCH>
@@ -1774,12 +1774,14 @@ install(
EXPORT cp2k_targets
FILE cp2kTargets.cmake
NAMESPACE cp2k::
- DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/cp2k")
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
-install(FILES start/libcp2k.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/cp2k")
+install(FILES start/libcp2k.h
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}")
install(
DIRECTORY "${PROJECT_BINARY_DIR}/src/mod_files"
- DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/cp2k"
+ DESTINATION
+ "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/${CMAKE_Fortran_COMPILER_ID}-${CMAKE_Fortran_COMPILER_VERSION}"
FILES_MATCHING
PATTERN "*.mod")
--
2.41.0
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4526160ad..8218a7a3d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -63,6 +63,18 @@ string(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
string(REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
string(REPLACE "-DNDEBUG" "" CMAKE_Fortran_FLAGS_RELEASE
${CMAKE_Fortran_FLAGS_RELEASE})
+string(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS_RELWITHDEBINFO
+ ${CMAKE_C_FLAGS_RELWITHDEBINFO})
+string(REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO
+ ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
+string(REPLACE "-DNDEBUG" "" CMAKE_Fortran_FLAGS_RELWITHDEBINFO
+ ${CMAKE_Fortran_FLAGS_RELWITHDEBINFO})
+string(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS_MINSIZEREL
+ ${CMAKE_C_FLAGS_MINSIZEREL})
+string(REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_MINSIZEREL
+ ${CMAKE_CXX_FLAGS_MINSIZEREL})
+string(REPLACE "-DNDEBUG" "" CMAKE_Fortran_FLAGS_MINSIZEREL
+ ${CMAKE_Fortran_FLAGS_MINSIZEREL})
find_package(PkgConfig)
diff --git a/src/qs_dispersion_d4.F b/src/qs_dispersion_d4.F
index 74df989b4..e513ed435 100644
--- a/src/qs_dispersion_d4.F
+++ b/src/qs_dispersion_d4.F
@@ -26,6 +26,7 @@ MODULE qs_dispersion_d4
#endif
USE kinds, ONLY: dp
USE particle_types, ONLY: particle_type
+ USE periodic_table, ONLY: get_ptable_info, ptable
USE qs_dispersion_types, ONLY: qs_dispersion_type
USE qs_force_types, ONLY: qs_force_type
USE message_passing, ONLY: mp_para_env_type
@@ -76,7 +77,8 @@ CONTAINS
TYPE(structure_type) :: mol
TYPE(realspace_cutoff) :: cutoff
- INTEGER :: iatom, natom, ind_atom
+ LOGICAL :: found
+ INTEGER :: iatom, natom, ind_atom, zatom
INTEGER, ALLOCATABLE, DIMENSION(:) :: el_num
REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :) :: gradient, xyz
REAL(KIND=dp), DIMENSION(3, 3) :: stress
@@ -94,7 +96,9 @@ CONTAINS
DO iatom = 1, natom
xyz(:, iatom) = particle_set(iatom)%r(:)
CALL get_atomic_kind(particle_set(iatom)%atomic_kind, kind_number=ikind)
- el_num(iatom) = ikind
+ CALL get_ptable_info(particle_set(iatom)%atomic_kind%element_symbol, &
+ ielement=zatom, found=found)
+ el_num(iatom) = zatom
END DO
!get information about cell / lattice
@@ -125,7 +129,7 @@ CONTAINS
IF (para_env%num_pe > 1 .AND. para_env%mepos > 0) virial = 0.00_dp
END IF
DO iatom = 1, natom
- ikind = el_num(iatom)
+ CALL get_atomic_kind(particle_set(iatom)%atomic_kind, kind_number=ikind)
ind_atom = atom_of_kind(iatom)
force(ikind)%dispersion(:, ind_atom) = force(ikind)%dispersion(:, ind_atom) + gradient(:, iatom)
END DO
diff --git a/tests/QS/regtest-dft-vdw-corr-4/TEST_FILES b/tests/QS/regtest-dft-vdw-corr-4/TEST_FILES
index 047421204..c817677df 100644
--- a/tests/QS/regtest-dft-vdw-corr-4/TEST_FILES
+++ b/tests/QS/regtest-dft-vdw-corr-4/TEST_FILES
@@ -3,7 +3,7 @@
# e.g. 0 means do not compare anything, running is enough
# 1 compares the last total energy in the file
# for details see cp2k/tools/do_regtest
-pbe_dftd4.inp 33 1.0E-14 -0.00141644869634
+pbe_dftd4.inp 33 1.0E-14 -0.00283102230260
pbe_dftd4_force.inp 72 1.0E-07 0.00007217
-pbe_dftd4_stress.inp 31 1.0E-07 -5.16289312880E-03
+pbe_dftd4_stress.inp 31 1.0E-07 -2.14003785359E-02
#EOF
# Copyright Spack Project Developers. See COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
import sys
from spack_repo.builtin.build_systems import cmake, makefile
from spack_repo.builtin.build_systems.cmake import CMakePackage, generator
from spack_repo.builtin.build_systems.cuda import CudaPackage
from spack_repo.builtin.build_systems.makefile import MakefilePackage
from spack_repo.builtin.build_systems.rocm import ROCmPackage
from spack.package import *
GPU_MAP = {
"35": "K40",
"37": "K80",
"60": "P100",
"70": "V100",
"80": "A100",
"90": "H100",
"gfx936": "Mi250",
"gfx906": "Mi50",
"gfx908": "Mi100",
"gfx90a": "Mi250",
"gfx90a:xnack-": "Mi250",
"gfx90a:xnack+": "Mi250",
"gfx942": "Mi300",
}
class Cp2k(MakefilePackage, CMakePackage, CudaPackage, ROCmPackage):
"""CP2K is a quantum chemistry and solid state physics software package
that can perform atomistic simulations of solid state, liquid, molecular,
periodic, material, crystal, and biological systems
"""
build_system(conditional("cmake", when="@2023.2:"), "makefile", default="cmake")
homepage = "https://www.cp2k.org"
url = "https://github.com/cp2k/cp2k/releases/download/v2025.2/cp2k-2025.2.tar.bz2"
git = "https://github.com/cp2k/cp2k.git"
list_url = "https://github.com/cp2k/cp2k/releases"
maintainers("dev-zero", "mtaillefumier", "RMeli", "abussy", "hfp")
tags = ["e4s"]
license("GPL-2.0-or-later")
version("2025.2", sha256="c8392a4e123304644ec8d241443796277c6ed7ae977452317e779f3c387c2e19")
version("2025.1", sha256="65c8ad5488897b0f995919b9fa77f2aba4b61677ba1e3c19bb093d5c08a8ce1d")
version("2024.3", sha256="a6eeee773b6b1fb417def576e4049a89a08a0ed5feffcd7f0b33c7d7b48f19ba")
version("2024.2", sha256="cc3e56c971dee9e89b705a1103765aba57bf41ad39a11c89d3de04c8b8cdf473")
version("2024.1", sha256="a7abf149a278dfd5283dc592a2c4ae803b37d040df25d62a5e35af5c4557668f")
version("2023.2", sha256="adbcc903c1a78cba98f49fe6905a62b49f12e3dfd7cedea00616d1a5f50550db")
version("2023.1", sha256="dff343b4a80c3a79363b805429bdb3320d3e1db48e0ff7d20a3dfd1c946a51ce")
version("2022.2", sha256="1a473dea512fe264bb45419f83de432d441f90404f829d89cbc3a03f723b8354")
version("2022.1", sha256="2c34f1a7972973c62d471cd35856f444f11ab22f2ff930f6ead20f3454fd228b")
version("9.1", sha256="fedb4c684a98ad857cd49b69a3ae51a73f85a9c36e9cb63e3b02320c74454ce6")
version("8.2", sha256="2e24768720efed1a5a4a58e83e2aca502cd8b95544c21695eb0de71ed652f20a")
version("8.1", sha256="7f37aead120730234a60b2989d0547ae5e5498d93b1e9b5eb548c041ee8e7772")
version("7.1", sha256="ccd711a09a426145440e666310dd01cc5772ab103493c4ae6a3470898cd0addb")
version("master", branch="master", submodules="True")
generator("ninja")
variant("mpi", default=True, description="Enable MPI support")
variant("openmp", default=True, description="Enable OpenMP support")
variant(
"smm",
default="libxsmm",
values=("libxsmm", "libsmm", "blas"),
description="Library for small matrix multiplications",
)
variant("opencl", default=False, description="Enable OpenCL backend")
variant("plumed", default=False, description="Enable PLUMED support")
variant(
"libint", default=True, description="Use libint, required for HFX (and possibly others)"
)
variant("libxc", default=True, description="Support additional functionals via libxc")
variant(
"pexsi",
default=False,
description="Enable the alternative PEXSI method for density matrix evaluation",
when="+mpi",
)
variant(
"elpa",
default=False,
description="Enable optimised diagonalisation routines from ELPA",
when="+mpi",
)
variant(
"dlaf",
default=False,
description="Enable DLA-Future eigensolver and Cholesky decomposition",
when="@2024.1: build_system=cmake +mpi",
)
# sirius support was introduced in 7, but effectively usable starting from CP2K 9
variant(
"sirius",
default=False,
description="Enable planewave electronic structure calculations via SIRIUS",
when="@9: +mpi",
)
variant("cosma", default=False, description="Use COSMA for p?gemm", when="@8: +mpi")
variant(
"libvori",
default=False,
description="Enable support for Voronoi integration and BQB compression",
when="@8:",
)
variant("spglib", default=False, description="Enable support for spglib")
variant(
"spla",
default=False,
description="Use SPLA off-loading functionality. Only relevant when CUDA or ROCM"
" are enabled",
)
variant("pytorch", default=False, description="Enable libtorch support")
variant(
"openpmd-api",
default=False,
description="Enable openPMD support",
when="@2026.1: build_system=cmake",
)
variant("quip", default=False, description="Enable quip support")
variant("dftd4", when="@2024.2:", default=False, description="Enable DFT-D4 support")
variant("mpi_f08", default=False, description="Use MPI F08 module", when="+mpi")
variant("smeagol", default=False, description="Enable libsmeagol support", when="@2025.2:")
variant("dbm_gpu", default=True, description="Enable DBM GPU backend", when="@2025.2:")
variant("grid_gpu", default=True, description="Enable grid GPU backend", when="@2025.2:")
variant(
"grid_gpu", default=False, description="Enable grid GPU backend", when="@2025.2: +opencl"
)
variant(
"pw_gpu", default=True, description="Enable FFT calculations on GPU", when="@2025.2: +cuda"
)
variant(
"pw_gpu",
default=False,
description="Enable FFT calculations on GPU",
when="@2025.2: +rocm",
)
variant(
"pw_gpu",
default=False,
description="Enable FFT calculations on GPU",
when="@2025.2: +opencl",
)
variant(
"hip_backend_cuda",
default=False,
description="Enable HIP backend on Nvidia GPU",
when="@2025.2: +cuda",
)
variant(
"enable_regtests",
default=False,
description="Configure cp2k to run the regtests afterwards."
" It build cp2k normally but put the executables in exe/cmake-build-* instead of the"
" conventional location. This option is only relevant when regtests need to be run.",
)
variant(
"grpp",
default=False,
description="Enable GRPP psuedo potentials",
when="@2025.2: build_system=cmake",
)
variant(
"hdf5",
default=False,
description="Enable HDF5 support",
when="@2025.2: build_system=cmake",
)
variant(
"trexio",
default=False,
description="Enable TrexIO support",
when="@2025.2: build_system=cmake",
)
variant(
"greenx",
default=False,
description="Enable green X support",
when="@2025.2: build_system=cmake",
)
variant("vdwxc", default=False, description="Enable VDW support in SIRIUS.", when="+sirius")
variant("deepmd", default=False, description="Enable DeepMD-kit support")
variant("tblite", default=False, description="Enable tblite support", when="@2025.2:")
variant("nlcg", default=False, description="Enable nlcg support in sirius", when="+sirius")
variant("vcsqnm", default=False, description="Enable VCSQNM support in sirius", when="+sirius")
conflicts("+deepmd", msg="DeepMD-kit is not yet available in Spack")
with when("+cuda"):
variant(
"cuda_arch_35_k20x",
default=False,
description=(
"CP2K (resp. DBCSR) has specific parameter sets for"
" different GPU models. Enable this when building"
" with cuda_arch=35 for a K20x instead of a K40"
),
)
variant(
"cuda_fft", default=False, description="Use CUDA also for FFTs in the PW part of CP2K"
)
variant(
"cuda_blas",
default=False,
when="@:7", # req in CP2K v8+
description="Use CUBLAS for general matrix operations in DBCSR",
)
with when("+hip_backend_cuda"):
depends_on("hipcc")
depends_on("hip+cuda")
depends_on("hipfft+cuda")
depends_on("hipblas+cuda")
HFX_LMAX_RANGE = range(4, 8)
variant(
"lmax",
description="Maximum supported angular momentum (HFX and others)",
default="5",
values=[str(x) for x in HFX_LMAX_RANGE],
multi=False,
)
depends_on("c", type="build")
depends_on("cxx", type="build")
depends_on("fortran", type="build")
depends_on("python@3", type="build")
depends_on("pkgconfig", type="build", when="build_system=cmake")
depends_on("blas")
depends_on("lapack")
depends_on("fftw-api@3")
depends_on("greenx", when="+greenx")
depends_on("hdf5+hl+fortran", when="+hdf5")
depends_on("trexio", when="+trexio")
depends_on("tblite build_system=cmake", when="+tblite")
# Force openmp propagation on some providers of blas / fftw-api
with when("+openmp"):
depends_on("fftw+openmp", when="^[virtuals=fftw-api] fftw")
depends_on("amdfftw+openmp", when="^[virtuals=fftw-api] amdfftw")
depends_on("cray-fftw+openmp", when="^[virtuals=fftw-api] cray-fftw")
depends_on("armpl-gcc threads=openmp", when="^[virtuals=blas] armpl-gcc")
depends_on("openblas threads=openmp", when="^[virtuals=blas] openblas")
depends_on("intel-oneapi-mkl threads=openmp", when="^[virtuals=fftw-api] intel-oneapi-mkl")
depends_on(
"intel-oneapi-mkl+gfortran threads=openmp",
when="^[virtuals=blas] intel-oneapi-mkl %gcc",
)
depends_on("intel-oneapi-mkl threads=openmp", when="^[virtuals=blas] intel-oneapi-mkl")
# The Cray compiler wrappers will automatically add libsci_mp with
# -fopenmp. Since CP2K unconditionally links blas/lapack/scalapack
# we have to be consistent.
depends_on("cray-libsci+openmp", when="^[virtuals=blas] cray-libsci")
with when("smm=libxsmm"):
# require libxsmm-1.11+ since 1.10 can leak file descriptors in Fortran
depends_on("libxsmm@1.11:")
depends_on("libxsmm@1.17:", when="@9.1:")
# use pkg-config (support added in libxsmm-1.10) to link to libxsmm
depends_on("pkgconfig", type="build")
# Several packages provide "opencl" (incl. ICD/loader), e.g., "cuda"
with when("+opencl"):
depends_on("opencl", when="+opencl")
opencl_loader_header_version = "2022.10.24"
depends_on(f"opencl-c-headers@{opencl_loader_header_version}:")
requires(f"%opencl=opencl-icd-loader@{opencl_loader_header_version}:")
# OpenCL backend implementation relies on LIBXSMM
requires("smm=libxsmm")
with when("+libint"):
depends_on("pkgconfig", type="build", when="@7.0:")
for lmax in HFX_LMAX_RANGE:
depends_on(f"libint@2.6.0:+fortran tune=cp2k-lmax-{lmax}", when=f"@7.0: lmax={lmax}")
# AOCC only works with libint@2.6.0
depends_on(
f"libint@=2.6.0+fortran tune=cp2k-lmax-{lmax}", when=f"@7.0: lmax={lmax} %aocc"
)
with when("+libxc"):
depends_on("pkgconfig", type="build", when="@7.0: ^libxc@:6")
depends_on("libxc@4.0.3:4", when="@7.0:8.1")
depends_on("libxc@5.1.3:5.1", when="@8.2:8")
depends_on("libxc@5.1.7:5.1", when="@9:2022.2")
depends_on("libxc@6.1:", when="@2023.1:")
depends_on("libxc@6.2:", when="@2023.2:")
depends_on("libxc@:6", when="@:2024.3")
depends_on("libxc@7 build_system=cmake", when="@2025.2:")
with when("+spla"):
depends_on("spla+cuda+fortran", when="+cuda")
depends_on("spla+rocm+fortran", when="+rocm")
with when("+mpi"):
depends_on("mpi@2:")
depends_on("mpi@3:", when="@2023.1:")
depends_on("scalapack")
depends_on("mpich+fortran", when="^[virtuals=mpi] mpich")
depends_on("intel-oneapi-mkl +cluster", when="^[virtuals=scalapack] intel-oneapi-mkl")
conflicts("~mpi_f08", when="^mpich@4.1:")
with when("+cosma"):
depends_on("cosma+scalapack")
depends_on("cosma@2.5.1:", when="@9:")
depends_on("cosma@2.6.3:", when="@2023.2:")
depends_on("cosma+cuda", when="+cuda")
depends_on("cosma+rocm", when="+rocm")
with when("+elpa"):
depends_on("elpa+openmp", when="+openmp")
depends_on("elpa~openmp", when="~openmp")
depends_on("elpa+cuda", when="+cuda")
depends_on("elpa~cuda", when="~cuda")
depends_on("elpa+rocm", when="+rocm")
depends_on("elpa~rocm", when="~rocm")
depends_on("elpa@2021.05:", when="@8.3:")
depends_on("elpa@2021.11.001:", when="@9.1:")
depends_on("elpa@2023.05.001:", when="@2023.2:")
with when("+dlaf"):
with when("@:2024.1"):
depends_on("dla-future@0.2.1: +scalapack")
depends_on("dla-future ~cuda", when="~cuda")
depends_on("dla-future ~rocm", when="~rocm")
depends_on("dla-future +cuda", when="+cuda")
depends_on("dla-future +rocm", when="+rocm")
with when("@2024.2:"):
depends_on("dla-future-fortran@0.1.0:")
depends_on("dla-future-fortran@0.2.0:", when="@2025.1:")
# Use a direct dependency on dla-future so that constraints can be expressed
# WARN: In the concretizer output, dla-future will appear as dependency of CP2K
# instead of dla-future-fortran
depends_on("dla-future ~cuda", when="~cuda")
depends_on("dla-future ~rocm", when="~rocm")
depends_on("dla-future +cuda", when="+cuda")
depends_on("dla-future +rocm", when="+rocm")
conflicts(
"+plumed",
when="@:2024.1 build_system=cmake",
msg="PLUMED support is broken in cp2k@:2024.1 with CMake",
)
with when("+plumed"):
depends_on("plumed+shared")
depends_on("plumed+mpi", when="+mpi")
depends_on("plumed~mpi", when="~mpi")
depends_on("libsmeagol", when="+smeagol")
# while we link statically against PEXSI, its own deps may be linked in
# dynamically, therefore can't set this as pure build-type dependency.
depends_on("pexsi+fortran@0.10.0:", when="+pexsi")
# only OpenMP should be consistently used, all other common things
# like ELPA, SCALAPACK are independent and Spack will ensure that
# a consistent/compatible combination is pulled into the dependency graph.
with when("+sirius"):
depends_on("sirius+fortran+shared+scalapack")
depends_on("sirius+cuda", when="+cuda")
depends_on("sirius+rocm", when="+rocm")
depends_on("sirius+openmp", when="+openmp")
depends_on("sirius~openmp", when="~openmp")
depends_on("sirius@7.3:", when="@9.1")
depends_on("sirius@7.4:", when="@2023.2")
depends_on("sirius@7.5:", when="@2024.1:")
depends_on("sirius@7.6:+pugixml", when="@2024.2:")
depends_on("sirius@7.7:+pugixml", when="@2025.2:")
depends_on("sirius+vdwxc", when="+vdwxc")
depends_on("sirius+nlcglib", when="@2025.2:+nlcg")
depends_on("sirius+vcsqnm", when="@2025.2:+vcsqnm")
depends_on("sirius@7.8.1:+dftd3+dftd4", when="@2025.2:+dftd4")
depends_on("sirius@7.5.0:+dlaf", when="+dlaf")
with when("+libvori"):
depends_on("libvori@201219:", when="@8.1")
depends_on("libvori@210412:", when="@8.2:")
depends_on("libvori@220621:", when="@2023.1:")
with when("+openpmd-api"):
depends_on("openpmd-api@0.16.1:")
# the bundled libcusmm uses numpy in the parameter prediction (v7+)
# which is written using Python 3
depends_on("py-numpy", when="@7:+cuda")
depends_on("python@3.6:", when="@7:+cuda")
depends_on("py-fypp")
depends_on("spglib", when="+spglib")
depends_on("dftd4@3.6.0: build_system=cmake", when="+dftd4")
with when("build_system=cmake"):
depends_on("cmake@3.22:", type="build")
# DBCSR as external dependency
depends_on("dbcsr@2.6: ~examples")
depends_on("dbcsr@2.8:", when="@2025.1:")
depends_on("dbcsr+openmp", when="+openmp")
depends_on("dbcsr+opencl", when="+opencl")
depends_on("dbcsr+mpi", when="+mpi")
depends_on("dbcsr+rocm", when="+rocm")
depends_on("dbcsr+cuda", when="+cuda")
depends_on("dbcsr smm=libxsmm", when="smm=libxsmm")
depends_on("dbcsr smm=blas", when="smm=blas")
with when("@2022: +rocm"):
depends_on("hipblas")
depends_on("hipfft")
# The CMake build system and AOCC are not compatible as of AOCC 5
requires("build_system=makefile", when="%aocc")
# CP2K needs compiler specific compilation flags, e.g. optflags
conflicts("%apple-clang")
conflicts("%clang")
conflicts("%nag")
conflicts(
"%aocc@:3.2",
msg="Please use AOCC 4.0+ that better support modern Fortran features CP2K requires",
)
conflicts("~openmp", when="@8:", msg="Building without OpenMP is not supported in CP2K 8+")
# We only support specific cuda_archs for which we have parameter files
# for optimal kernels. Note that we don't override the cuda_archs property
# from the parent class, since the parent class defines constraints for all
# versions. Instead just mark all unsupported cuda archs as conflicting.
supported_cuda_arch_list = ("35", "37", "60", "70", "80", "90")
supported_rocm_arch_list = (
"gfx936",
"gfx906",
"gfx908",
"gfx90a",
"gfx90a:xnack-",
"gfx90a:xnack+",
"gfx942",
)
cuda_msg = "cp2k only supports cuda_arch {0}".format(supported_cuda_arch_list)
rocm_msg = "cp2k only supports amdgpu_target {0}".format(supported_rocm_arch_list)
conflicts("+cuda", when="cuda_arch=none")
# ROCm already emits an error if +rocm amdgpu_target=none is given
with when("+cuda"):
for arch in CudaPackage.cuda_arch_values:
if arch not in supported_cuda_arch_list:
conflicts("+cuda", when="cuda_arch={0}".format(arch), msg=cuda_msg)
with when("+rocm"):
for arch in ROCmPackage.amdgpu_targets:
if arch not in supported_rocm_arch_list:
conflicts("+rocm", when="amdgpu_target={0}".format(arch), msg=rocm_msg)
# Fix 2- and 3-center integral calls to libint
patch(
"https://github.com/cp2k/cp2k/commit/5eaf864ed2bd21fb1b05a9173bb77a815ad4deda.patch?full_index=1",
sha256="3617abb877812c4b933f601438c70f95e21c6161bea177277b1d4125fd1c0bf9",
when="@8.2",
)
# Patch for compilers with stricter C99 checks
patch("posix_c_source.patch", when="@7.1%aocc@4.0:")
patch("posix_c_source.patch", when="@7.1%gcc@13:")
# Fix missing variable in OpenMP private clause
patch(
"https://github.com/cp2k/cp2k/commit/be86bd7f6cd6af7d68f8957dcdb67e7c3d586741.patch?full_index=1",
sha256="1bb5a8e80603684a743e7821d24d41b31b60ccbb7d4257df1d2da53a3630e5bf",
when="@2022.1:2022.2",
)
# Avoid using NULL() as subroutine argument as doing so breaks some versions of AOCC compiler
# These patches backport 2023.x fixes to previous versions
patch("backport_avoid_null_2022.x.patch", when="@2022.1:2022.2 %aocc@:4.0")
patch("backport_avoid_null_9.1.patch", when="@9.1 %aocc@:4.0")
patch("cmake-fixes-2023.2.patch", when="@2023.2 build_system=cmake")
# Allow compilation with build_type=RelWithDebInfo and build_type=MinSizeRel
# after NDEBUG support was dropped in https://github.com/cp2k/cp2k/pull/3172
# The patch applies https://github.com/cp2k/cp2k/pull/3251 to version 2024.1
patch("cmake-relwithdebinfo-2024.1.patch", when="@2024.1 build_system=cmake")
# Bugfix for D4 dispersion correction in CP2K 2024.3
# https://github.com/cp2k/cp2k/issues/3688
patch("d4-dispersion-bugfix-2024.3.patch", when="@2024.3")
# Fix segmentation faults caused by accessing unallocated arrays
# https://github.com/cp2k/cp2k/pull/3733
patch(
"https://github.com/cp2k/cp2k/commit/7a99649828ecf7d5dc53d952a1bf7be6970deabe.patch?full_index=1",
sha256="37f4f1a76634ff4a5617fe0c670e6acfe2afa2b2cfc5b2875e438a54baa4525e",
when="@2024.2:2024.3",
)
# Follow api change of sirius, deleted unrelated tools part.
# https://github.com/cp2k/cp2k/commit/9ae0441d1aa760e247a8a389793207ec65a35775
# https://github.com/electronic-structure/SIRIUS/pull/1048
patch("sirius-api-7.7.0.patch", when="@2024.2:2025.1 ^sirius@7.7.0")
# Fix missing S in data/BASIS_MOLOPT_UZH
# https://github.com/cp2k/cp2k/pull/4140
patch(
"https://github.com/cp2k/cp2k/commit/da03128481adf8f78a8a04ebeae0490480c03b89.patch?full_index=1",
sha256="0d542c414216866953c95e642d2590b3d313717dfaebbf12cfafedbdd3bf54a3",
when="@=2025.1",
)
def patch(self):
# Patch for an undefined constant due to incompatible changes in ELPA
if self.spec.satisfies("@9.1:2022.2 +elpa"):
if self.spec["elpa"].satisfies("@2022.05.001:"):
filter_file(
r"ELPA_2STAGE_REAL_INTEL_GPU",
"ELPA_2STAGE_REAL_INTEL_GPU_SYCL",
"src/fm/cp_fm_elpa.F",
)
# Patch for resolving .mod file conflicts in ROCm by implementing 'USE, INTRINSIC'
# This patch triggers compilation errors on some systems as rocm install these
# modules files in rocm/include/llvm and this directory is given to gcc
if self.spec.satisfies("+rocm"):
for directory, subdirectory, files in os.walk(os.getcwd()):
for i in files:
file_path = os.path.join(directory, i)
filter_file("USE ISO_C_BINDING", "USE,INTRINSIC :: ISO_C_BINDING", file_path)
filter_file(
"USE ISO_FORTRAN_ENV", "USE,INTRINSIC :: ISO_FORTRAN_ENV", file_path
)
filter_file("USE omp_lib", "USE,INTRINSIC :: omp_lib", file_path)
filter_file("USE OMP_LIB", "USE,INTRINSIC :: OMP_LIB", file_path)
filter_file("USE iso_c_binding", "USE,INTRINSIC :: iso_c_binding", file_path)
filter_file(
"USE iso_fortran_env", "USE,INTRINSIC :: iso_fortran_env", file_path
)
def url_for_version(self, version):
url = "https://github.com/cp2k/cp2k/releases/download/v{0}/cp2k-{0}.tar.bz2"
return url.format(version)
class MakefileBuilder(makefile.MakefileBuilder):
def edit(self, pkg, spec, prefix):
pkgconf = which("pkg-config")
fftw = spec["fftw-api:openmp" if "+openmp" in spec else "fftw-api"]
fftw_header_dir = fftw.headers.directories[0]
# some providers (mainly Intel) keep the fftw headers in a subdirectory, find it
for incdir in [join_path(f, "fftw") for f in fftw.headers.directories]:
if os.path.exists(incdir):
fftw_header_dir = incdir
break
optimization_flags = {
"gcc": ["-O2", "-funroll-loops", "-ftree-vectorize"],
"intel-oneapi-compilers": ["-O2", "-fp-model precise"],
"intel": ["-g", "-O2", "-fp-model precise"],
"nvhpc": ["-fast"],
"cce": ["-O2"],
"xl": ["-O3"],
"aocc": ["-O2"],
"rocmcc": ["-O1"],
}
dflags = ["-DNDEBUG"] if spec.satisfies("@:2023.2") else []
if fftw.name == "intel-oneapi-mkl":
cppflags = ["-D__FFTW3_MKL", "-I{0}".format(fftw_header_dir)]
else:
cppflags = ["-D__FFTW3", "-I{0}".format(fftw_header_dir)]
# CP2K requires MPI 3 starting at version 2023.1
# and __MPI_VERSION is not supported anymore.
if spec.satisfies("@:2022.2"):
if spec.satisfies("^mpi@3:"):
cppflags.append("-D__MPI_VERSION=3")
elif spec.satisfies("^mpi@2:"):
cppflags.append("-D__MPI_VERSION=2")
cflags = optimization_flags[spec.compiler.name][:]
cxxflags = optimization_flags[spec.compiler.name][:]
fcflags = optimization_flags[spec.compiler.name][:]
nvflags = ["-O3"]
ldflags = []
libs = []
dso_suffix = shared_library_suffix(spec)
# CP2K Makefile doesn't set C standard
if spec.satisfies("@2023.2:"):
# Use of DBL_DECIMAL_DIG
cflags.append(pkg.compiler.c11_flag)
else:
# C99-style for-loops with inline definition of iterating variable.
cflags.append(pkg.compiler.c99_flag)
if spec.satisfies("%intel") or spec.satisfies("%intel-oneapi-compilers"):
fcflags += ["-traceback"] # -heap-arrays 64
elif spec.satisfies("%gcc"):
fcflags += [
"-ffree-form",
"-ffree-line-length-none",
"-ggdb", # make sure we get proper Fortran backtraces
]
elif spec.satisfies("%aocc") or spec.satisfies("%rocmcc"):
fcflags += ["-ffree-form", "-Mbackslash"]
elif spec.satisfies("%nvhpc"):
fcflags += ["-Mfreeform", "-Mextend"]
elif spec.satisfies("%cce"):
fcflags += ["-emf", "-ffree", "-hflex_mp=strict"]
elif spec.satisfies("%xl"):
fcflags += ["-qpreprocess", "-qstrict", "-q64"]
ldflags += ["-Wl,--allow-multiple-definition"]
if "+mpi %gcc@10:" in spec and spec["mpi"].name in ["mpich", "cray-mpich"]:
fcflags += [
"-fallow-argument-mismatch"
] # https://github.com/pmodels/mpich/issues/4300
if spec.satisfies("@7.1%gcc@13:"):
fcflags.append("-fallow-argument-mismatch")
if spec.satisfies("+openmp"):
cflags.append(pkg.compiler.openmp_flag)
cxxflags.append(pkg.compiler.openmp_flag)
fcflags.append(pkg.compiler.openmp_flag)
ldflags.append(pkg.compiler.openmp_flag)
nvflags.append('-Xcompiler="{0}"'.format(pkg.compiler.openmp_flag))
elif spec.satisfies("%cce"): # Cray enables OpenMP by default
cflags += ["-hnoomp"]
cxxflags += ["-hnoomp"]
fcflags += ["-hnoomp"]
ldflags += ["-hnoomp"]
if spec.satisfies("@7:"): # recent versions of CP2K use C++14 CUDA code
cxxflags.append(pkg.compiler.cxx14_flag)
nvflags.append(pkg.compiler.cxx14_flag)
ldflags.append(fftw.libs.search_flags)
if spec.satisfies("^superlu-dist@4.3"):
ldflags.insert(0, "-Wl,--allow-multiple-definition")
if spec.satisfies("+libint"):
cppflags += ["-D__LIBINT"]
if spec.satisfies("@:6.9"):
cppflags += ["-D__LIBINT_MAX_AM=6", "-D__LIBDERIV_MAX_AM1=5"]
# libint-1.x.y has to be linked statically to work around
# inconsistencies in its Fortran interface definition
# (short-int vs int) which otherwise causes segfaults at
# runtime due to wrong offsets into the shared library
# symbols.
libs += [
join_path(spec["libint"].libs.directories[0], "libderiv.a"),
join_path(spec["libint"].libs.directories[0], "libint.a"),
]
else:
fcflags += pkgconf("--cflags", "libint2", output=str).split()
libs += pkgconf("--libs", "libint2", output=str).split()
if spec.satisfies("+libxc"):
cppflags += ["-D__LIBXC"]
if spec.satisfies("@:6.9"):
libxc = spec["libxc:fortran,static"]
cppflags += [libxc.headers.cpp_flags]
ldflags.append(libxc.libs.search_flags)
libs.append(str(libxc.libs))
else:
fcflags += pkgconf("--cflags", "libxcf03", output=str).split()
# some Fortran functions seem to be direct wrappers of the
# C functions such that we get a direct dependency on them,
# requiring `-lxc` to be present in addition to `-lxcf03`
libs += pkgconf("--libs", "libxcf03", "libxc", output=str).split()
if spec.satisfies("+pexsi"):
cppflags.append("-D__LIBPEXSI")
fcflags.append("-I" + join_path(spec["pexsi"].prefix, "fortran"))
libs += [
join_path(spec["pexsi"].libs.directories[0], "libpexsi.a"),
join_path(spec["superlu-dist"].libs.directories[0], "libsuperlu_dist.a"),
join_path(spec["parmetis"].libs.directories[0], f"libparmetis.{dso_suffix}"),
join_path(spec["metis"].libs.directories[0], f"libmetis.{dso_suffix}"),
]
if spec.satisfies("+elpa"):
elpa = spec["elpa"]
elpa_suffix = "_openmp" if "+openmp" in elpa else ""
elpa_incdir = elpa.headers.directories[0]
fcflags += ["-I{0}".format(join_path(elpa_incdir, "modules"))]
# Currently AOCC support only static libraries of ELPA
if spec.satisfies("%aocc"):
libs.append(
join_path(
elpa.prefix.lib, ("libelpa{elpa_suffix}.a".format(elpa_suffix=elpa_suffix))
)
)
else:
libs.append(elpa.libs.ld_flags)
if spec.satisfies("@:4"):
if elpa.satisfies("@:2014.5"):
cppflags.append("-D__ELPA")
elif elpa.satisfies("@2014.6:2015.10"):
cppflags.append("-D__ELPA2")
else:
cppflags.append("-D__ELPA3")
else:
cppflags.append(
"-D__ELPA={0}{1:02d}".format(elpa.version[0], int(elpa.version[1]))
)
fcflags += ["-I{0}".format(join_path(elpa_incdir, "elpa"))]
if "+cuda" in spec and "+cuda" in elpa:
cppflags += ["-D__ELPA_NVIDIA_GPU"]
if spec.satisfies("+sirius"):
sirius = spec["sirius"]
cppflags.append("-D__SIRIUS")
fcflags += ["-I{0}".format(sirius.prefix.include.sirius)]
libs += list(sirius.libs)
if spec.satisfies("+plumed"):
dflags.extend(["-D__PLUMED2"])
cppflags.extend(["-D__PLUMED2"])
libs += [join_path(spec["plumed"].prefix.lib, f"libplumed.{dso_suffix}")]
if spec.satisfies("+libvori"):
cppflags += ["-D__LIBVORI"]
libvori = spec["libvori"].libs
ldflags += [libvori.search_flags]
libs.append(libvori.ld_flags)
libs += ["-lstdc++"]
if spec.satisfies("+spglib"):
cppflags += ["-D__SPGLIB"]
spglib = spec["spglib"].libs
ldflags += [spglib.search_flags]
libs.append(spglib.ld_flags)
if spec.satisfies("+dftd4"):
cppflags += ["-D__DFTD4"]
dftd4 = spec["dftd4"].libs
ldflags += [dftd4.search_flags]
libs.append(dftd4.ld_flags)
if spec.satisfies("+smeagol"):
cppflags += ["-D__SMEAGOL"]
smeagol = spec["libsmeagol"].libs
ldflags += [smeagol.search_flags]
libs.append(smeagol.ld_flags)
cc = spack_cc if "~mpi" in spec else spec["mpi"].mpicc
cxx = spack_cxx if "~mpi" in spec else spec["mpi"].mpicxx
fc = spack_fc if "~mpi" in spec else spec["mpi"].mpifc
# Intel
if spec.satisfies("%intel") or spec.satisfies("%intel-oneapi-compilers"):
cppflags.extend(
[
"-D__INTEL",
"-D__HAS_IEEE_EXCEPTIONS",
"-D__HAS_ISO_C_BINDING",
"-D__USE_CP2K_TRACE",
]
)
fcflags.extend(["-free", "-fpp", "-diag-disable 8290,8291,10010,10212,11060"])
# FFTW, LAPACK, BLAS
lapack = spec["lapack"].libs
blas = spec["blas"].libs
ldflags.append((lapack + blas).search_flags)
libs += [str(x) for x in (fftw.libs, lapack, blas)]
if spec.satisfies("platform=darwin"):
cppflags.extend(["-D__NO_STATM_ACCESS"])
if spec["blas"].name == "intel-oneapi-mkl":
cppflags += ["-D__MKL"]
elif spec["blas"].name == "accelerate":
cppflags += ["-D__ACCELERATE"]
if spec.satisfies("+cosma"):
# add before ScaLAPACK to override the p?gemm symbols
cosma = spec["cosma"].libs
ldflags.append(cosma.search_flags)
libs += cosma
# MPI
if spec.satisfies("+mpi"):
cppflags.extend(["-D__parallel", "-D__SCALAPACK"])
if spec["mpi"].name == "intel-oneapi-mpi":
mpi = [join_path(spec["intel-oneapi-mpi"].libs.directories[0], "libmpi.so")]
else:
mpi = spec["mpi:cxx"].libs
if spec["scalapack"].name == "intel-oneapi-mkl":
mpi_impl = "openmpi" if spec["mpi"].name in ["openmpi", "hpcx-mpi"] else "intelmpi"
scalapack = [
join_path(
spec["intel-oneapi-mkl"].libs.directories[0], "libmkl_scalapack_lp64.so"
),
join_path(
spec["intel-oneapi-mkl"].libs.directories[0],
"libmkl_blacs_{0}_lp64.so".format(mpi_impl),
),
]
else:
scalapack = spec["scalapack"].libs
ldflags.append(scalapack.search_flags)
libs += scalapack
libs += mpi
libs += pkg.compiler.stdcxx_libs
if spec.satisfies("+mpi_f08"):
cppflags.append("-D__MPI_F08")
if spec.satisfies("^wannier90"):
cppflags.append("-D__WANNIER90")
wannier = join_path(spec["wannier90"].libs.directories[0], "libwannier.a")
libs.append(wannier)
gpuver = ""
if spec.satisfies("+cuda"):
libs += [
"-L{}".format(spec["cuda"].libs.directories[0]),
"-L{}/stubs".format(spec["cuda"].libs.directories[0]),
"-lcuda",
"-lcudart",
"-lnvrtc",
"-lstdc++",
]
if spec.satisfies("@9:"):
if spec.satisfies("@2022:"):
cppflags += ["-D__OFFLOAD_CUDA"]
acc_compiler_var = "OFFLOAD_CC"
acc_flags_var = "OFFLOAD_FLAGS"
cppflags += ["-D__DBCSR_ACC", "-D__GRID_CUDA", "-DOFFLOAD_TARGET=cuda"]
libs += ["-lcublas"]
if spec.satisfies("+cuda_fft"):
if spec.satisfies("@:9"):
cppflags += ["-D__PW_CUDA"]
libs += ["-lcufft"]
else:
if spec.satisfies("@2022:"):
cppflags += ["-D__NO_OFFLOAD_PW"]
else:
acc_compiler_var = "NVCC"
acc_flags_var = "NVFLAGS"
cppflags += ["-D__ACC"]
if spec.satisfies("+cuda_blas"):
cppflags += ["-D__DBCSR_ACC=2"]
libs += ["-lcublas"]
else:
cppflags += ["-D__DBCSR_ACC"]
if spec.satisfies("+cuda_fft"):
cppflags += ["-D__PW_CUDA"]
libs += ["-lcufft", "-lcublas"]
cuda_arch = spec.variants["cuda_arch"].value[0]
gpuver = GPU_MAP[cuda_arch]
if cuda_arch == "35" and spec.satisfies("+cuda_arch_35_k20x"):
gpuver = "K20X"
if spec.satisfies("@2022: +rocm"):
libs += [
"-L{}".format(spec["hip"].prefix.lib),
"-lamdhip64",
"-lhipblas",
"-lhipfft",
"-lstdc++",
]
acc_compiler_var = "hipcc"
acc_flags_var = "NVFLAGS"
cppflags += ["-D__ACC"]
cppflags += ["-D__DBCSR_ACC"]
cppflags += ["-D__HIP_PLATFORM_AMD__"]
cppflags += ["-D__GRID_HIP"]
gpuver = GPU_MAP[spec.variants["amdgpu_target"].value[0]]
if spec.satisfies("smm=libsmm"):
lib_dir = join_path("lib", self.makefile_architecture, self.makefile_version)
mkdirp(lib_dir)
try:
copy(env["LIBSMM_PATH"], join_path(lib_dir, "libsmm.a"))
except KeyError:
raise KeyError(
"Point environment variable LIBSMM_PATH to "
"the absolute path of the libsmm.a file"
)
except OSError:
raise OSError(
"The file LIBSMM_PATH pointed to does not "
"exist. Note that it must be absolute path."
)
cppflags.extend(["-D__HAS_smm_dnn", "-D__HAS_smm_vec"])
libs.append("-lsmm")
elif spec.satisfies("smm=libxsmm"):
cppflags += ["-D__LIBXSMM"]
cppflags += pkgconf("--cflags-only-other", "libxsmmf", output=str).split()
fcflags += pkgconf("--cflags-only-I", "libxsmmf", output=str).split()
libs += pkgconf("--libs", "libxsmmf", output=str).split()
dflags.extend(cppflags)
cflags.extend(cppflags)
cxxflags.extend(cppflags)
fcflags.extend(cppflags)
nvflags.extend(cppflags)
with open(self.makefile, "w") as mkf:
if spec.satisfies("+plumed"):
mkf.write(
"# include Plumed.inc as recommended by PLUMED to include libraries and flags"
)
mkf.write("include {0}\n".format(self.pkg["plumed"].plumed_inc))
mkf.write("\n# COMPILER, LINKER, TOOLS\n\n")
mkf.write("FC = {0}\nCC = {1}\nCXX = {2}\nLD = {3}\n".format(fc, cc, cxx, fc))
if spec.satisfies("%intel"):
intel_bin_dir = ancestor(pkg.compiler.cc)
# CPP is a commented command in Intel arch of CP2K
# This is the hack through which cp2k developers avoid doing :
#
# ${CPP} <file>.F > <file>.f90
#
# and use `-fpp` instead
mkf.write("CPP = # {0} -P\n".format(spack_cc))
mkf.write("AR = {0}/xiar -qs\n".format(intel_bin_dir))
else: # incl. spec.satisfies("%intel-oneapi-compilers")
mkf.write("CPP = # {0} -E\n".format(spack_cc))
mkf.write("AR = ar -qs\n") # r = qs is a GNU extension
if spec.satisfies("+cuda"):
mkf.write(
"{0} = {1}\n".format(
acc_compiler_var, join_path(spec["cuda"].prefix, "bin", "nvcc")
)
)
# Write compiler flags to file
def fflags(var, lst):
return "{0} = {1}\n\n".format(var, " \\\n\t".join(lst))
mkf.write("\n# FLAGS & LIBRARIES\n")
mkf.write(fflags("DFLAGS", dflags))
mkf.write(fflags("CPPFLAGS", cppflags))
mkf.write(fflags("CFLAGS", cflags))
mkf.write(fflags("CXXFLAGS", cxxflags))
if spec.satisfies("+cuda"):
mkf.write(fflags(acc_flags_var, nvflags))
if "+rocm" in spec:
mkf.write("OFFLOAD_TARGET = hip\n")
mkf.write(fflags("FCFLAGS", fcflags))
mkf.write(fflags("LDFLAGS", ldflags))
mkf.write(fflags("LIBS", libs))
if spec.satisfies("%intel") or spec.satisfies("%intel-oneapi-compilers"):
mkf.write(fflags("LDFLAGS_C", ldflags + ["-nofor-main"]))
if spec.satisfies("%aocc@5:"):
# ensure C based applications can be build properly
mkf.write(fflags("LDFLAGS_C", ldflags + ["-fno-fortran-main"]))
# This flag is required for the correct runtime behaviour of the code with aocc@5.0
mkf.write(fflags("FCFLAGS", fcflags + ["-mllvm -enable-newgvn=true"]))
mkf.write("# CP2K-specific flags\n\n")
mkf.write("GPUVER = {0}\n".format(gpuver))
mkf.write("DATA_DIR = {0}\n".format(prefix.share.data))
def build(self, pkg, spec, prefix):
if "+cuda" in spec and len(spec.variants["cuda_arch"].value) > 1:
raise InstallError("cp2k supports only one cuda_arch at a time")
# Apparently the Makefile bases its paths on PWD
# so we need to set PWD = self.build_directory
with set_env(PWD=self.build_directory):
super().build(pkg, spec, prefix)
with working_dir(self.build_directory):
make("libcp2k", *self.build_targets)
def install(self, pkg, spec, prefix):
exe_dir = join_path("exe", self.makefile_architecture)
lib_dir = join_path("lib", self.makefile_architecture, self.makefile_version)
install_tree(exe_dir, self.prefix.bin)
install_tree("data", self.prefix.share.data)
install_tree(lib_dir, self.prefix.lib)
mkdirp(self.prefix.include)
install("src/start/libcp2k.h", join_path(self.prefix.include, "libcp2k.h"))
@property
def build_directory(self):
build_dir = self.pkg.stage.source_path
if self.spec.satisfies("@:6"):
# prior to version 7.1 was the Makefile located in makefiles/
build_dir = join_path(build_dir, "makefiles")
return build_dir
@property
def build_targets(self):
return [
"ARCH={0}".format(self.makefile_architecture),
"VERSION={0}".format(self.makefile_version),
]
@property
def makefile(self):
makefile_basename = ".".join([self.makefile_architecture, self.makefile_version])
return join_path("arch", makefile_basename)
@property
def makefile_architecture(self):
return "{0.architecture}-{0.compiler.name}".format(self.spec)
@property
def makefile_version(self):
return "{prefix}{suffix}".format(
prefix="p" if "+mpi" in self.spec else "s",
suffix="smp" if "+openmp" in self.spec else "opt",
)
@property
def archive_files(self):
return [join_path(self.pkg.stage.source_path, self.makefile)]
def check(self):
data_dir = join_path(self.pkg.stage.source_path, "data")
# CP2K < 7 still uses $PWD to detect the current working dir
# and Makefile is in a subdir, account for both facts here:
with set_env(CP2K_DATA_DIR=data_dir, PWD=self.build_directory):
with working_dir(self.build_directory):
make("test", *self.build_targets)
@run_after("install", when="@9.1:")
def fix_package_config(self):
"""
Default build procedure generates libcp2k.pc with invalid paths,
because they are collected from temporary directory.
Ignoring invalid paths, most library-related switches are correct
except for fftw and openblas.
This procedure is appending two missing switches (tested with GROMACS 2022.2 + CP2K).
In case such approach causes issues in the future, it might be necessary
to generate and override entire libcp2k.pc.
"""
pkgconfig_file = join_path(self.prefix.lib.pkgconfig, "libcp2k.pc")
filter_file(r"(^includedir=).*", r"\1{0}".format(self.prefix.include), pkgconfig_file)
filter_file(r"(^libdir=).*", r"\1{0}".format(self.prefix.lib), pkgconfig_file)
with open(pkgconfig_file, "r+") as handle:
content = handle.read().rstrip()
content += " " + self.spec["blas"].libs.ld_flags
content += " " + self.spec["lapack"].libs.ld_flags
content += " " + self.spec["fftw-api"].libs.ld_flags
fftw = self.spec["fftw-api"]
if fftw.name in ["fftw", "amdfftw", "cray-fftw"] and fftw.satisfies("+openmp"):
content += " -lfftw3_omp"
content += "\n"
handle.seek(0)
handle.write(content)
class CMakeBuilder(cmake.CMakeBuilder):
def cmake_args(self):
spec = self.spec
args = []
if spec.satisfies("+opencl"):
args += [self.define("CP2K_USE_ACCEL", "OPENCL")]
if spec.satisfies("+cuda"):
if (len(spec.variants["cuda_arch"].value) > 1) or spec.satisfies("cuda_arch=none"):
raise InstallError("CP2K supports only one cuda_arch at a time.")
else:
gpu_ver = GPU_MAP[spec.variants["cuda_arch"].value[0]]
if spec.satisfies("+hip_backend_cuda"):
args += [
self.define("CP2K_USE_ACCEL", "HIP"),
self.define("CMAKE_HIP_PLATFORM", "nvidia"),
]
else:
args += [self.define("CP2K_USE_ACCEL", "CUDA")]
args += [self.define("CP2K_WITH_GPU", gpu_ver)]
if spec.satisfies("+rocm"):
if len(spec.variants["amdgpu_target"].value) > 1:
raise InstallError("CP2K supports only one amdgpu_target at a time.")
else:
gpu_ver = GPU_MAP[spec.variants["amdgpu_target"].value[0]]
args += [
self.define("CP2K_USE_ACCEL", "HIP"),
self.define("CP2K_WITH_GPU", gpu_ver),
]
args += [
"-DCP2K_USE_FFTW3=ON",
self.define_from_variant("CP2K_USE_MPI", "mpi"),
self.define_from_variant("CP2K_ENABLE_REGTESTS", "enable_regtests"),
self.define_from_variant("CP2K_USE_ELPA", "elpa"),
self.define_from_variant("CP2K_USE_DLAF", "dlaf"),
self.define_from_variant("CP2K_USE_LIBINT2", "libint"),
self.define_from_variant("CP2K_USE_SIRIUS", "sirius"),
self.define_from_variant("CP2K_USE_SPLA", "spla"),
self.define_from_variant("CP2K_USE_COSMA", "cosma"),
self.define_from_variant("CP2K_USE_LIBXC", "libxc"),
self.define_from_variant("CP2K_USE_LIBTORCH", "pytorch"),
self.define_from_variant("CP2K_USE_OPENPMD", "openpmd-api"),
self.define_from_variant("CP2K_USE_METIS", "pexsi"),
self.define_from_variant("CP2K_USE_SUPERLU", "pexsi"),
self.define_from_variant("CP2K_USE_PLUMED", "plumed"),
self.define_from_variant("CP2K_USE_SPGLIB", "spglib"),
self.define_from_variant("CP2K_USE_VORI", "libvori"),
self.define_from_variant("CP2K_USE_SPLA", "spla"),
self.define_from_variant("CP2K_USE_QUIP", "quip"),
self.define_from_variant("CP2K_USE_DFTD4", "dftd4"),
self.define_from_variant("CP2K_USE_MPI_F08", "mpi_f08"),
self.define_from_variant("CP2K_USE_LIBSMEAGOL", "smeagol"),
self.define_from_variant("CP2K_ENABLE_GRID_GPU", "grid_gpu"),
self.define_from_variant("CP2K_ENABLE_DBM_GPU", "dbm_gpu"),
self.define_from_variant("CP2K_ENABLE_PW_GPU", "pw_gpu"),
self.define_from_variant("CP2K_USE_GRPP", "grpp"),
self.define_from_variant("CP2K_USE_HDF5", "hdf5"),
self.define_from_variant("CP2K_USE_DEEPMD", "deepmd"),
self.define_from_variant("CP2K_USE_TREXIO", "trexio"),
self.define_from_variant("CP2K_USE_GREENX", "greenx"),
self.define_from_variant("CP2K_USE_LIBVDWXC", "vdwxc"),
self.define_from_variant("CP2K_USE_TBLITE", "tblite"),
]
if spec.satisfies("+sirius"):
args += [
self.define_from_variant("CP2K_USE_SIRIUS_DFTD4", "dftd4"),
self.define_from_variant("CP2K_USE_SIRIUS_VCSQNM", "vcsqnm"),
self.define_from_variant("CP2K_USE_SIRIUS_NLCG", "nlcg"),
]
if spec.satisfies("^[virtuals=fftw-api] fftw+openmp"):
args += ["-DCP2K_USE_FFTW3_WITH_OPENMP=ON"]
# we force the use elpa openmp threading support. might need to be revisited though
args += [
self.define(
"CP2K_ENABLE_ELPA_OPENMP_SUPPORT",
("+elpa +openmp" in spec) or ("^elpa +openmp" in spec),
)
]
if "spla" in spec and (spec.satisfies("+cuda") or spec.satisfies("+rocm")):
args += ["-DCP2K_USE_SPLA_GEMM_OFFLOADING=ON"]
if spec.satisfies("smm=libxsmm"):
args += ["-DCP2K_USE_LIBXSMM=ON"]
else:
args += ["-DCP2K_USE_LIBXSMM=OFF"]
lapack = spec["lapack"]
blas = spec["blas"]
if blas.name == "intel-oneapi-mkl":
args += ["-DCP2K_BLAS_VENDOR=MKL"]
if spec.satisfies("+openmp"):
mkl_thread = "thread" if spec.satisfies("%gcc") else "intel-thread"
args += [f"-DCP2K_BLAS_THREADING={mkl_thread}"]
else:
args += ["-DCP2K_BLAS_THREADING=sequential"]
if sys.platform == "darwin":
args += [
self.define("CP2K_BLAS_VENDOR", "CUSTOM"),
self.define("CP2K_SCALAPACK_VENDOR", "GENERIC"),
self.define(
"CP2K_SCALAPACK_LINK_LIBRARIES", spec["scalapack"].libs.joined(";")
),
]
else:
args += ["-DCP2K_SCALAPACK_VENDOR=MKL"]
else:
args.extend(
[
self.define("CP2K_LAPACK_FOUND", True),
self.define("CP2K_LAPACK_LINK_LIBRARIES", lapack.libs.joined(";")),
self.define("CP2K_BLAS_FOUND", True),
self.define("CP2K_BLAS_LINK_LIBRARIES", blas.libs.joined(";")),
self.define("CP2K_SCALAPACK_FOUND", True),
self.define("CP2K_SCALAPACK_INCLUDE_DIRS", spec["scalapack"].prefix.include),
self.define("CP2K_BLAS_VENDOR", "CUSTOM"),
self.define("CP2K_SCALAPACK_VENDOR", "GENERIC"),
self.define(
"CP2K_SCALAPACK_LINK_LIBRARIES", spec["scalapack"].libs.joined(";")
),
]
)
return args
--- a/src/sockets.c 2019-12-24 01:41:57.000000000 +0530
+++ b/src/sockets.c 2023-05-15 18:35:33.941236292 +0530
@@ -35,6 +35,7 @@
*/
#ifndef __NO_IPI_DRIVER
+#define _POSIX_C_SOURCE 200112L
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b9e660fbfd2..06ccb802a9b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -692,7 +692,7 @@ endif()
# SIRIUS
if(CP2K_USE_SIRIUS)
- find_package(sirius REQUIRED)
+ find_package(sirius 7.7.0 REQUIRED)
endif()
if(CP2K_USE_PLUMED)
diff --git a/src/sirius_interface.F b/src/sirius_interface.F
index f6dc257c5d4..a84223d2433 100644
--- a/src/sirius_interface.F
+++ b/src/sirius_interface.F
@@ -145,7 +145,7 @@ SUBROUTINE cp_sirius_create_env(pwdft_env)
magnetization, mass, pf, rl, zeff, alpha_u, beta_u, &
J0_u, J_u, U_u, occ_u, u_minus_J
REAL(KIND=dp), ALLOCATABLE, DIMENSION(:) :: beta, corden, ef, fe, locpot, rc, rp
- REAL(KIND=dp), DIMENSION(3) :: vr, vs
+ REAL(KIND=dp), DIMENSION(3) :: vr, vs, j_t
REAL(KIND=dp), DIMENSION(:), POINTER :: density
REAL(KIND=dp), DIMENSION(:, :), POINTER :: wavefunction, wfninfo
TYPE(atom_gthpot_type), POINTER :: gth_atompot
@@ -464,12 +464,14 @@ SUBROUTINE cp_sirius_create_env(pwdft_env)
CPABORT("CP2K/SIRIUS (hubbard): the occupation number can not be negative.")
END IF
+ j_t(:) = 0.0
IF (ABS(u_minus_j) < 1e-8) THEN
+ j_t(1) = J_u
CALL sirius_set_atom_type_hubbard(sctx, label, lu, nu, &
- occ_u, U_u, J_u, alpha_u, beta_u, J0_u)
+ occ_u, U_u, j_t, alpha_u, beta_u, J0_u)
ELSE
CALL sirius_set_atom_type_hubbard(sctx, label, lu, nu, &
- occ_u, u_minus_j, 0.0_dp, alpha_u, beta_u, J0_u)
+ occ_u, u_minus_j, j_t, alpha_u, beta_u, J0_u)
END IF
END IF
--- a/cmake/gmxDetectCpu.cmake
+++ b/cmake/gmxDetectCpu.cmake
@@ -83,7 +83,7 @@ function(gmx_run_cpu_detection TYPE)
set(GCC_INLINE_ASM_DEFINE "-DGMX_X86_GCC_INLINE_ASM=0")
endif()
- set(_compile_definitions "${GCC_INLINE_ASM_DEFINE} -I${PROJECT_SOURCE_DIR}/src -DGMX_CPUINFO_STANDALONE ${GMX_STDLIB_CXX_FLAGS} -DGMX_TARGET_X86=${GMX_TARGET_X86_VALUE}")
+ set(_compile_definitions ${GCC_INLINE_ASM_DEFINE} -I${PROJECT_SOURCE_DIR}/src -DGMX_CPUINFO_STANDALONE ${GMX_STDLIB_CXX_FLAGS} -DGMX_TARGET_X86=${GMX_TARGET_X86_VALUE})
set(LINK_LIBRARIES "${GMX_STDLIB_LIBRARIES}")
try_compile(CPU_DETECTION_COMPILED
"${PROJECT_BINARY_DIR}"
--- a/cmake/gmxDetectSimd.cmake
+++ b/cmake/gmxDetectSimd.cmake
@@ -77,7 +77,7 @@ function(gmx_suggest_simd _suggested_simd)
else()
set(GMX_TARGET_X86_VALUE 0)
endif()
- set(_compile_definitions "${GCC_INLINE_ASM_DEFINE} -I${CMAKE_SOURCE_DIR}/src -DGMX_CPUINFO_STANDALONE ${GMX_STDLIB_CXX_FLAGS} -DGMX_TARGET_X86=${GMX_TARGET_X86_VALUE}")
+ set(_compile_definitions ${GCC_INLINE_ASM_DEFINE} -I${CMAKE_SOURCE_DIR}/src -DGMX_CPUINFO_STANDALONE ${GMX_STDLIB_CXX_FLAGS} -DGMX_TARGET_X86=${GMX_TARGET_X86_VALUE})
# Prepare a default suggestion
set(OUTPUT_SIMD "None")
# Copyright Spack Project Developers. See COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
from spack_repo.builtin.build_systems import cmake
from spack_repo.builtin.build_systems.cmake import CMakePackage
from spack_repo.builtin.build_systems.cuda import CudaPackage
from spack_repo.builtin.build_systems.rocm import ROCmPackage
from spack.package import *
class Gromacs(CMakePackage, CudaPackage, ROCmPackage):
"""GROMACS is a molecular dynamics package primarily designed for simulations
of proteins, lipids and nucleic acids. It was originally developed in
the Biophysical Chemistry department of University of Groningen, and is now
maintained by contributors in universities and research centers across the world.
GROMACS is one of the fastest and most popular software packages
available and can run on CPUs as well as GPUs. It is free, open source
released under the GNU Lesser General Public License. Before the version 4.6,
GROMACS was released under the GNU General Public License.
"""
homepage = "https://www.gromacs.org"
url = "https://ftp.gromacs.org/gromacs/gromacs-2022.2.tar.gz"
list_url = "https://ftp.gromacs.org/gromacs"
git = "https://gitlab.com/gromacs/gromacs.git"
maintainers("mabraham", "eirrgang", "junghans")
license("GPL-2.0-or-later", when="@:4.5")
license("LGPL-2.1-or-later", when="@4.6:")
# Deprecation policy:
#
# GROMACS makes an annual major release and supports it with fixes
# in minor updates for about two years. Each such annual release
# series is supported in spack for those two years, then marked as
# deprecated in Spack. Deprecated versions can be removed after
# the next major release of GROMACS is supported in Spack. Users
# needing such an old version can either do a manual installation
# or get an older version of Spack.
#
# Exception: Version 2019.6 is the last version capable of tabulated
# interactions used in the so-called "group scheme." It will be marked
# as deprecated only after equivalent functionality is available in
# a major release of GROMACS, then removed as above.
#
# Exception: Otherwise, versions before 2022 will be removed when
# 2025 is supported.
version("main", branch="main")
version("2026.0", sha256="229726f436cc515bfd8c4aa7af3a97b18072f71b5ebd0b08daf6565571e2d9eb")
version("2025.4", sha256="ca17720b4a260eb73649211e9f6a940ee7543452129844213c3accb0a927a5c3")
version("2025.3", sha256="8bdfca0268f3f10a7ca3c06e59b62f73ea02420c67211c0ff3912f32d7833c65")
version("2025.2", sha256="0df09f9d45a99ef00e66b9baa9493a27e906813763a3b6c7672217c66b43ea11")
version("2025.1", sha256="0adf621a80fd8043f8defec84ce02811c0cdf42a052232890932d81f25c4d28a")
version("2025.0", sha256="a27ad35a646295bbec129abe684d9d03d1e2e0bd76b0d625e9055746aaefae82")
version("2024.6", sha256="7cbad81f51c71a144d646515a7249aa74940b3f68071f51410e3a9473f05b339")
version("2024.5", sha256="fecf06b186cddb942cfb42ee8da5f3eb2b9993e6acc0a2f18d14ac0b014424f3")
version("2024.4", sha256="ac618ece2e58afa86b536c5a2c4fcb937f0760318f12d18f10346b6bdebd86a8")
version("2024.3", sha256="bbda056ee59390be7d58d84c13a9ec0d4e3635617adf2eb747034922cba1f029")
version("2024.2", sha256="802a7e335f2e895770f57b159e4ec368ebb0ff2ce6daccf706c6e8025c36852b")
version("2024.1", sha256="937d8f12a36fffbf2af7add71adbb5aa5c5537892d46c9a76afbecab1aa0aac7")
version("2024", sha256="04d226d52066a8bc3a42e00d6213de737b4ec292e26703065924ff01956801e2")
# See exception documented above
version("2019.6", sha256="bebe396dc0db11a9d4cc205abc13b50d88225617642508168a2195324f06a358")
depends_on("c", type="build")
depends_on("cxx", type="build")
depends_on("fortran", type="build", when="@:4.5.5") # No core Fortran code since 4.6
depends_on("fortran", type="build", when="+cp2k") # Need Fortan compiler for CP2K
variant(
"mpi", default=True, description="Activate MPI support (disable for Thread-MPI support)"
)
variant("shared", default=True, description="Enables the build of shared libraries")
variant(
"double",
default=False,
description="Produces a double precision version of the executables",
)
variant(
"cufftmp",
default=False,
when="@2022: +cuda+mpi",
description="Enable multi-GPU FFT support with cuFFTMp",
)
variant(
"heffte",
default=False,
when="@2021: +mpi",
description="Enable multi-GPU FFT support with HeFFTe",
)
depends_on("heffte +cuda", when="+heffte +cuda")
depends_on("heffte +sycl", when="+heffte +sycl")
variant("opencl", default=False, description="Enable OpenCL support")
variant("sycl", default=False, when="@2021:", description="Enable SYCL support")
requires(
"^intel-oneapi-runtime",
"^hipsycl %clang",
policy="one_of",
when="+sycl",
msg="GROMACS SYCL support comes either from intel-oneapi-runtime or a "
+ "package that provides the virtual package `sycl`, such as AdaptiveCpp "
+ "plus a clang compiler.",
)
variant(
"intel-data-center-gpu-max",
default=False,
when="@2022: +sycl",
description="Enable support for Intel Data Center GPU Max",
)
variant(
"amdgpu_target",
description="AMD GPU architecture",
values=("none",) + ROCmPackage.amdgpu_targets,
default="none",
multi=False,
sticky=True,
when="+rocm",
)
variant("nosuffix", default=False, description="Disable default suffixes")
variant(
"build_type",
default="Release",
description="The build type to build",
values=(
"Debug",
"Release",
"RelWithDebInfo",
"MinSizeRel",
"Reference",
"RelWithAssert",
"Profile",
),
)
variant(
"nblib",
default=True,
when="@2021:",
description="Build and install the NB-LIB C++ API for GROMACS",
)
variant(
"gmxapi",
default=True,
when="@2019:",
description="Build and install the gmxlib python API for GROMACS",
)
variant(
"mdrun_only",
default=False,
description="Enables the build of a cut-down version"
" of libgromacs and/or the mdrun program",
)
conflicts(
"+mdrun_only", when="@2021:", msg="mdrun-only build option was removed for GROMACS 2021."
)
variant(
"nvshmem",
default=False,
when="@2024:+mpi+cuda",
description="Enable NVSHMEM support for Nvidia GPUs",
)
conflicts(
"+nvshmem",
when="+cufftmp",
msg=(
"The GROMACS support for NVSHMEM does not work with the GROMACS support "
"for cuFFTMp (even though cuFFTMp uses NVSHMEM in its implementation)"
),
)
variant("openmp", default=True, description="Enables OpenMP at configure time")
# When using apple-clang version 15.x or newer, need to use the llvm-openmp library
# We also protect with version 2025+ as there seems to be a CMake bug with
# Apple Clang and OpenMP that is fixed in 2025
depends_on("llvm-openmp", when="@2025: +openmp %apple-clang@15:", type=("build", "run"))
# But we need to block +openmp %apple-clang for GROMACS older than 2025
conflicts(
"+openmp",
when="@:2024 %apple-clang",
msg="OpenMP not available for the Apple clang compiler",
)
variant("openmp_max_threads", default="none", description="Max number of OpenMP threads")
conflicts(
"+openmp_max_threads", when="~openmp", msg="OpenMP is off but OpenMP Max threads is set"
)
variant(
"sve",
default=True,
description="Enable SVE on aarch64 if available",
when="target=neoverse_v1:,neoverse_v2:,neoverse_n2:",
)
variant(
"sve", default=True, description="Enable SVE on aarch64 if available", when="target=a64fx"
)
conflicts(
"+sve",
when="%clang@20",
msg="There is a severe performance regression in GROMACS with SVE and Clang 20; disable SVE (~sve) or use a different compiler. See https://gitlab.com/gromacs/gromacs/-/issues/5390",
)
variant(
"relaxed_double_precision",
default=False,
description="GMX_RELAXED_DOUBLE_PRECISION, use only for Fujitsu PRIMEHPC",
)
conflicts(
"+relaxed_double_precision",
when="@2021:",
msg="GMX_RELAXED_DOUBLE_PRECISION option removed for GROMACS 2021.",
)
variant("hwloc", default=True, description="Use the hwloc portable hardware locality library")
variant("cycle_subcounters", default=False, description="Enables cycle subcounters")
variant("cp2k", default=False, description="CP2K QM/MM interface integration")
conflicts(
"+cp2k", when="@:2021", msg="CP2K QM/MM support have been introduced in GROMACS 2022"
)
conflicts("+shared", when="+cp2k", msg="Enabling CP2K requires static build")
conflicts("%intel", when="@2022:", msg="GROMACS %intel support was removed in version 2022")
conflicts("%gcc@:8", when="@2023:", msg="GROMACS requires GCC 9 or later since version 2023")
conflicts(
"^intel-oneapi-mkl@:2021.2",
when="@2023:",
msg="GROMACS requires oneMKL 2021.3 or later since version 2023",
)
depends_on("mpi", when="+mpi")
# Plumed 2.10.0 needs Gromacs 2025.0, 2024.3, 2023.5, 2022.5
# Plumed 2.9.0 needs Gromacs 2023, 2022.5, 2021.7, 2020.7
# Plumed 2.8.3 needs Gromacs 2022.5, 2021.7, 2020.7, 2019.6
# Plumed 2.8.2 needs Gromacs 2022.5, 2021.7, 2020.7, 2019.6
# Plumed 2.8.1 needs Gromacs 2022.3, 2021.6, 2020.7, 2019.6
# Plumed 2.8.0 needs Gromacs 2021.4, 2020.6, 2019.6
# Plumed 2.7.6 needs Gromacs 2021.5, 2020.6, 2019.6
# Plumed 2.7.5 needs Gromacs 2021.5, 2020.6, 2019.6
# Plumed 2.7.4 needs Gromacs 2021.4, 2020.6, 2019.6
# Plumed 2.7.3 needs Gromacs 2021.4, 2020.6, 2019.6
# Plumed 2.7.2 needs Gromacs 2021, 2020.6, 2019.6
# Plumed 2.7.1 needs Gromacs 2021, 2020.5, 2019.6
# Plumed 2.7.0 needs Gromacs 2020.4, 2019.6
# Plumed 2.6.6 needs Gromacs 2020.4, 2019.6, 2018.8
# Plumed 2.6.5 needs Gromacs 2020.4, 2019.6, 2018.8
# Plumed 2.6.4 needs Gromacs 2020.4, 2019.6, 2018.8
# Plumed 2.6.3 needs Gromacs 2020.4, 2019.6, 2018.8
# Plumed 2.6.2 needs Gromacs 2020.4, 2019.6, 2018.8
# Plumed 2.6.1 needs Gromacs 2020.2, 2019.6, 2018.8
# Plumed 2.6.0 needs Gromacs 2019.4, 2018.8
# Plumed 2.5.7 needs Gromacs 2019.4, 2018.8, 2016.6
# Plumed 2.5.6 needs Gromacs 2019.4, 2018.8, 2016.6
# Plumed 2.5.5 needs Gromacs 2019.4, 2018.8, 2016.6
# Plumed 2.5.4 needs Gromacs 2019.4, 2018.8, 2016.6
# Plumed 2.5.3 needs Gromacs 2019.4, 2018.8, 2016.6
# Plumed 2.5.2 needs Gromacs 2019.2, 2018.6, 2016.6
# Plumed 2.5.1 needs Gromacs 2018.6, 2016.6
# Plumed 2.5.0 needs Gromacs 2018.4, 2016.5
# Above dependencies can be verified, and new versions added, by going to
# https://github.com/plumed/plumed2/tree/v2.9.0/patches
# and switching tags.
# Versions without minor release number, such as `2023` and `2021`,
# require exact specification using `@=`, starting from Spack v0.20.0,
# see https://github.com/spack/spack/releases/tag/v0.20.0
plumed_patches = {
"2025.0": "2.10.0",
"2024.3": "2.9.3:2.10.0",
"2024.2": "2.9.2",
"2023.5": "2.9.2:2.10.0",
"=2023": "2.9.0:2.9.1",
"2022.5": "2.8.2:2.10.0",
"2022.3": "2.8.1",
"2021.7": "2.8.2:2.9.4",
"2021.6": "2.8.1",
"2021.5": "2.7.5:2.7.6",
"2021.4": "2.7.3:2.8.0",
"=2021": "2.7.1:2.7.2",
"2020.7": "2.8.1:2.9.4",
"2020.6": "2.7.2:2.8.0",
"2020.5": "2.7.1",
"2020.4": "2.6.2:2.7.0",
"2020.2": "2.6.1",
"2019.6": "2.6.1:2.8.3",
"2019.4": "2.5.3:2.6.0",
"2019.2": "2.5.2",
"2018.8": "2.5.3:2.6",
"2018.6": "2.5.1:2.5.2",
"2018.4": "2.5.0",
"2016.6": "2.5.1:2.5",
"2016.5": "2.5.0",
}
variant(
"plumed",
default=False,
description="Enable PLUMED support",
when="@{0}".format(",".join(plumed_patches.keys())),
)
with when("+plumed"):
depends_on("plumed+mpi", when="+mpi")
depends_on("plumed~mpi", when="~mpi")
for gmx_ver, plumed_vers in plumed_patches.items():
depends_on("plumed@{0}".format(plumed_vers), when="@{0}+plumed".format(gmx_ver))
variant(
"intel_provided_gcc",
default=False,
description="Use this if Intel compiler is installed through spack. "
+ "The g++ location is written to icp{c,x}.cfg",
)
variant(
"itt",
default=False,
when="@2024:",
description="Enable Instrumentation and Tracing Technology (ITT)"
+ " profiling API (from Intel)",
)
depends_on("intel-oneapi-vtune", "+itt")
depends_on("fftw-api@3")
depends_on("cmake@2.8.8:3", type="build")
depends_on("cmake@3.4.3:3", type="build", when="@2018:")
depends_on("cmake@3.9.6:3", type="build", when="@2020")
depends_on("cmake@3.13.0:3", type="build", when="@2021")
depends_on("cmake@3.16.3:3", type="build", when="@2022:")
depends_on("cmake@3.18.4:3", type="build", when="@2023:")
depends_on("cmake@3.28.0:3", type="build", when="@2025:")
depends_on("cmake@3.28.0:3", type="build", when="@main")
depends_on("cmake@3.16.0:3", type="build", when="%fj")
depends_on("pkgconfig", type="build")
depends_on("cuda", when="+cuda")
depends_on("sycl", when="+sycl")
depends_on("lapack")
depends_on("blas")
depends_on("gcc", when="~intel_provided_gcc %intel")
# TODO this can be expanded to all clang-based compilers once
# the principle is demonstrated to work
with when("~intel_provided_gcc %oneapi"):
depends_on("gcc-runtime@5:", when="@2020")
depends_on("gcc-runtime@7:", when="@2021:2022")
depends_on("gcc-runtime@9:", when="@2023:2024")
depends_on("gcc-runtime@11:", when="@2025:")
depends_on("hwloc", when="+hwloc@2019:")
depends_on("cp2k@8.1:", when="+cp2k")
depends_on("nvhpc", when="+cufftmp")
depends_on("nvhpc", when="+nvshmem")
depends_on("heffte", when="+heffte")
requires(
"%intel",
"%oneapi",
policy="one_of",
when="+intel_provided_gcc",
msg="Only attempt to find gcc libs for Intel compiler if Intel compiler is used.",
)
# If the Intel suite is used for Lapack, it must be used for fftw and vice-versa
requires("^[virtuals=fftw-api] intel-oneapi-mkl", when="^[virtuals=lapack] intel-oneapi-mkl")
requires("^[virtuals=lapack] intel-oneapi-mkl", when="^[virtuals=fftw-api] intel-oneapi-mkl")
# 2025.0 CMake fix for PLUMED
patch(
"https://gitlab.com/gromacs/gromacs/-/merge_requests/4966.diff",
sha256="9372c235719ca04d6dd418fb5943f773e03f05246e3e059a8578089b14b2420c",
when="@2025.0",
)
# https://gitlab.com/gromacs/gromacs/-/issues/5289
# https://gitlab.com/gromacs/gromacs/-/merge_requests/4965
patch("pr4965-2025.0.patch", when="@2025.0")
filter_compiler_wrappers(
"*.cmake", relative_root=os.path.join("share", "cmake", "gromacs_mpi")
)
filter_compiler_wrappers("*.cmake", relative_root=os.path.join("share", "cmake", "gromacs"))
def patch(self):
# Otherwise build fails with GCC 11 (11.2)
if self.spec.satisfies("@2018:2020.6"):
filter_file(
"#include <vector>",
"#include <vector>\n#include <limits>",
"src/gromacs/awh/biasparams.h",
)
if self.spec.satisfies("@2018:2018.8"):
filter_file(
"#include <vector>",
"#include <vector>\n#include <limits>",
"src/gromacs/mdlib/minimize.cpp",
)
if self.spec.satisfies("@2019:2019.6,2020:2020.6"):
filter_file(
"#include <vector>",
"#include <vector>\n#include <limits>",
"src/gromacs/mdrun/minimize.cpp",
)
if self.spec.satisfies("@2020:2020.6"):
filter_file(
"#include <queue>",
"#include <queue>\n#include <limits>",
"src/gromacs/modularsimulator/modularsimulator.h",
)
# Ref: https://gitlab.com/gromacs/gromacs/-/merge_requests/3504
if self.spec.satisfies("@2023"):
filter_file(
" if (std::filesystem::equivalent(searchPath, buildBinPath))",
" if (std::error_code c; std::filesystem::equivalent(searchPath,"
" buildBinPath, c))",
"src/gromacs/commandline/cmdlineprogramcontext.cpp",
string=True,
)
if self.spec.satisfies("+plumed"):
self["plumed"].apply_patch(self)
if self.spec.satisfies("%nvhpc"):
# Disable obsolete workaround
filter_file("ifdef __PGI", "if 0", "src/gromacs/fileio/xdrf.h")
if self.spec.satisfies("+cuda"):
# Upstream supports building of last two major versions of Gromacs.
# Older versions of Gromacs need to be patched to build with more recent
# versions of CUDA library.
# Hardware version 3.0 is supported up to CUDA 10.2 (Gromacs 4.6-2020.3
# needs to be patched, 2020.4 is handling it correctly)
if self.spec.satisfies("@4.6:2020.3^cuda@11:"):
filter_file(
r"-gencode;arch=compute_30,code=sm_30;?", "", "cmake/gmxManageNvccConfig.cmake"
)
filter_file(
r"-gencode;arch=compute_30,code=compute_30;?",
"",
"cmake/gmxManageNvccConfig.cmake",
)
# Hardware version 2.0 is supported up to CUDA 8 (Gromacs 4.6-2016.3
# needs to be patched, 2016.4 is handling it correctly, removed in 2019)
if self.spec.satisfies("@4.6:2016.3^cuda@9:"):
filter_file(
r"-gencode;arch=compute_20,code=sm_20;?", "", "cmake/gmxManageNvccConfig.cmake"
)
filter_file(
r"-gencode;arch=compute_20,code=compute_20;?",
"",
"cmake/gmxManageNvccConfig.cmake",
)
if self.spec.satisfies("@4.6:5.0^cuda@9:"):
filter_file(
r"-gencode;arch=compute_20,code=sm_21;?", "", "cmake/gmxManageNvccConfig.cmake"
)
def setup_run_environment(self, env: EnvironmentModifications) -> None:
if self.spec.satisfies("+cufftmp"):
env.append_path(
"LD_LIBRARY_PATH",
join_path(
self.spec["nvhpc"].prefix,
f"Linux_{self.spec.target.family}",
self.spec["nvhpc"].version,
"comm_libs",
"nvshmem",
"lib",
),
)
class CMakeBuilder(cmake.CMakeBuilder):
@run_after("build")
def build_test_binaries(self):
"""Build the test binaries.
GROMACS usually excludes tests from the default build target, but building
the tests during spack's ``check`` phase takes a long time while producing
no visible output, even with ``--verbose``.
Here, we make sure the test binaries are built during the build phase
(as would normally be expected when configured with BUILD_TESTING)
when the ``--test`` flag is used.
Note: the GMX_DEVELOPER_BUILD option disables the EXCLUDE_FROM_ALL on the
test binaries, but the option incurs additional side effects that may
not be intended with ``--test``.
"""
if self.pkg.run_tests:
with working_dir(self.build_directory):
make("tests")
def check(self):
"""Run the ``check`` target (skipping the ``test`` target).
Override the standard CMakeBuilder behavior. GROMACS has both `test`
and `check` targets, but we are only interested in the latter.
"""
with working_dir(self.build_directory):
if self.generator == "Unix Makefiles":
make("check")
elif self.generator == "Ninja":
ninja("check")
def cmake_args(self):
options = []
# Warning: Use `define_from_variant()` with caution.
# GROMACS may use unexpected conventions for CMake variable values.
# For example: variables that accept boolean values like "OFF"
# may actually be STRING type, and undefined variables may trigger
# different defaults for dependent options than explicitly defined variables.
# `-DGMX_VAR=OFF` may not have the same meaning as `-DGMX_VAR=`.
# In other words, the mapping between package variants and the
# GMX CMake variables is often non-trivial.
if self.spec.satisfies("+mpi"):
options.append("-DGMX_MPI:BOOL=ON")
if self.pkg.version < Version("2020"):
# Ensures gmxapi builds properly
options.extend(
[
"-DCMAKE_C_COMPILER=%s" % self.spec["mpi"].mpicc,
"-DCMAKE_CXX_COMPILER=%s" % self.spec["mpi"].mpicxx,
"-DCMAKE_Fortran_COMPILER=%s" % self.spec["mpi"].mpifc,
]
)
elif self.pkg.version == Version("2021"):
# Work around https://gitlab.com/gromacs/gromacs/-/issues/3896
# Ensures gmxapi builds properly
options.extend(
[
"-DCMAKE_C_COMPILER=%s" % self.spec["mpi"].mpicc,
"-DCMAKE_CXX_COMPILER=%s" % self.spec["mpi"].mpicxx,
]
)
else:
options.extend(
[
"-DCMAKE_C_COMPILER=%s" % spack_cc,
"-DCMAKE_CXX_COMPILER=%s" % spack_cxx,
"-DMPI_C_COMPILER=%s" % self.spec["mpi"].mpicc,
"-DMPI_CXX_COMPILER=%s" % self.spec["mpi"].mpicxx,
]
)
else:
options.extend(
[
"-DCMAKE_C_COMPILER=%s" % spack_cc,
"-DCMAKE_CXX_COMPILER=%s" % spack_cxx,
"-DGMX_MPI:BOOL=OFF",
"-DGMX_THREAD_MPI:BOOL=ON",
]
)
if self.spec.satisfies("%aocc"):
options.append("-DCMAKE_CXX_FLAGS=--stdlib=libc++")
if self.spec.satisfies("@2020:"):
options.append("-DGMX_INSTALL_LEGACY_API=ON")
if self.spec.satisfies("%oneapi") or self.spec.satisfies("%intel"):
# If intel-oneapi-compilers was installed through spack the gcc is added to the
# configuration file.
if self.spec.satisfies("+intel_provided_gcc") and os.path.exists(
".".join([os.environ["SPACK_CXX"], "cfg"])
):
with open(".".join([os.environ["SPACK_CXX"], "cfg"]), "r") as f:
options.append("-DCMAKE_CXX_FLAGS={}".format(f.read()))
elif self.spec["cxx"].name == "gcc":
options.append("-DGMX_GPLUSPLUS_PATH=%s/g++" % self.spec["gcc"].prefix.bin)
if self.spec.satisfies("+double"):
options.append("-DGMX_DOUBLE:BOOL=ON")
if self.spec.satisfies("+nosuffix"):
options.append("-DGMX_DEFAULT_SUFFIX:BOOL=OFF")
if self.spec.satisfies("~shared"):
options.append("-DBUILD_SHARED_LIBS:BOOL=OFF")
options.append("-DGMXAPI:BOOL=OFF")
if self.spec.satisfies("+hwloc"):
options.append("-DGMX_HWLOC:BOOL=ON")
else:
options.append("-DGMX_HWLOC:BOOL=OFF")
if self.pkg.version >= Version("2021"):
if self.spec.satisfies("+cuda"):
options.append("-DGMX_GPU:STRING=CUDA")
elif self.spec.satisfies("+opencl"):
options.append("-DGMX_GPU:STRING=OpenCL")
elif self.spec.satisfies("+sycl"):
options.append("-DGMX_GPU:STRING=SYCL")
if self.spec.satisfies("^hipsycl") or self.spec.satisfies("^adaptivecpp"):
options.append("-DGMX_SYCL=ACPP")
options.append(f"-DACPP_TARGETS=hip:{self.spec.variants['amdgpu_target'].value}")
else:
options.append("-DGMX_GPU:STRING=OFF")
else:
if self.spec.satisfies("+cuda") or self.spec.satisfies("+opencl"):
options.append("-DGMX_GPU:BOOL=ON")
if self.spec.satisfies("+opencl"):
options.append("-DGMX_USE_OPENCL=ON")
else:
options.append("-DGMX_GPU:BOOL=OFF")
if self.spec.satisfies("+cuda"):
options.append("-DCUDA_TOOLKIT_ROOT_DIR:STRING=" + self.spec["cuda"].prefix)
if not self.spec.satisfies("cuda_arch=none"):
cuda_arch = self.spec.variants["cuda_arch"].value
options.append(f"-DGMX_CUDA_TARGET_SM:STRING={';'.join(cuda_arch)}")
options.append("-DGMX_EXTERNAL_LAPACK:BOOL=ON")
if self.spec["lapack"].libs:
options.append("-DGMX_LAPACK_USER={0}".format(self.spec["lapack"].libs.joined(";")))
options.append("-DGMX_EXTERNAL_BLAS:BOOL=ON")
if self.spec["blas"].libs:
options.append("-DGMX_BLAS_USER={0}".format(self.spec["blas"].libs.joined(";")))
if self.spec.satisfies("+cp2k"):
options.append("-DGMX_CP2K:BOOL=ON")
options.append("-DCP2K_DIR:STRING={0}".format(self.spec["cp2k"].prefix))
if self.spec.satisfies("+cufftmp"):
options.append("-DGMX_USE_CUFFTMP=ON")
options.append(
f"-DcuFFTMp_ROOT={self.spec['nvhpc'].prefix}/Linux_{self.spec.target.family}"
+ f"/{self.spec['nvhpc'].version}/math_libs"
)
if self.spec.satisfies("+heffte"):
options.append("-DGMX_USE_HEFFTE=on")
options.append(f"-DHeffte_ROOT={self.spec['heffte'].prefix}")
if self.spec.satisfies("+intel-data-center-gpu-max"):
options.append("-DGMX_GPU_NB_CLUSTER_SIZE=8")
options.append("-DGMX_GPU_NB_NUM_CLUSTER_PER_CELL_X=1")
if "+itt" in self.spec:
options.append("-DGMX_USE_ITT=on")
options.append(
"-DITTNOTIFY_INCLUDE_DIR=%s"
% self.spec["intel-oneapi-vtune"].package.headers.directories[0]
)
if self.spec.satisfies("~nblib"):
options.append("-DGMX_INSTALL_NBLIB_API=OFF")
if self.spec.satisfies("~gmxapi"):
options.append("-DGMXAPI=OFF")
# Activate SIMD based on properties of the target
target = self.spec.target
if target >= "zen4":
# AMD Family 17h (EPYC Genoa)
options.append("-DGMX_SIMD=AVX_512")
elif target >= "zen2":
# AMD Family 17h (EPYC Rome)
options.append("-DGMX_SIMD=AVX2_256")
elif target >= "zen":
# AMD Family 17h (EPYC Naples)
options.append("-DGMX_SIMD=AVX2_128")
elif target >= "bulldozer":
# AMD Family 15h
options.append("-DGMX_SIMD=AVX_128_FMA")
elif "vsx" in target:
# IBM Power 7 and beyond
if self.spec.satisfies("%nvhpc"):
options.append("-DGMX_SIMD=None")
else:
options.append("-DGMX_SIMD=IBM_VSX")
elif target.family == "aarch64":
# ARMv8
if self.spec.satisfies("%nvhpc"):
options.append("-DGMX_SIMD=None")
elif "sve" in target.features and "+sve" in self.spec:
options.append("-DGMX_SIMD=ARM_SVE")
else:
options.append("-DGMX_SIMD=ARM_NEON_ASIMD")
elif target == "mic_knl":
# Intel KNL
options.append("-DGMX_SIMD=AVX_512_KNL")
else:
# Other architectures
simd_features = [
("sse2", "SSE2"),
("sse4_1", "SSE4.1"),
("avx", "AVX_256"),
("axv128", "AVX2_128"),
("avx2", "AVX2_256"),
("avx512", "AVX_512"),
]
# Workaround NVIDIA compiler bug when avx512 is enabled
if self.spec.satisfies("%nvhpc") and ("avx512", "AVX_512") in simd_features:
simd_features.remove(("avx512", "AVX_512"))
feature_set = False
for feature, flag in reversed(simd_features):
if feature in target:
options.append("-DGMX_SIMD:STRING={0}".format(flag))
feature_set = True
break
# Fall back
if not feature_set:
options.append("-DGMX_SIMD:STRING=None")
# Use the 'rtdscp' assembly instruction only on
# appropriate architectures
options.append(self.define("GMX_USE_RDTSCP", str(target.family) in ("x86_64", "x86")))
if self.spec.satisfies("@:2020"):
options.append(self.define_from_variant("GMX_BUILD_MDRUN_ONLY", "mdrun_only"))
options.append(self.define_from_variant("GMX_OPENMP", "openmp"))
if self.spec.satisfies("@:2020"):
options.append(
self.define_from_variant(
"GMX_RELAXED_DOUBLE_PRECISION", "relaxed_double_precision"
)
)
if self.spec.satisfies("+cycle_subcounters"):
options.append("-DGMX_CYCLE_SUBCOUNTERS:BOOL=ON")
else:
options.append("-DGMX_CYCLE_SUBCOUNTERS:BOOL=OFF")
if "+openmp" in self.spec and self.spec.variants["openmp_max_threads"].value != "none":
options.append(
"-DGMX_OPENMP_MAX_THREADS=%s" % self.spec.variants["openmp_max_threads"].value
)
if self.spec.satisfies("+nvshmem"):
options.append("-DGMX_NVSHMEM:BOOL=ON")
nvshmem_root = join_path(
self.spec["nvhpc"].prefix,
f"Linux_{self.spec.target.family}",
self.spec["nvhpc"].version,
"comm_libs",
"nvshmem",
)
options.append(f"-DNVSHMEM_ROOT={nvshmem_root}")
if self.spec.satisfies("^[virtuals=lapack] intel-oneapi-mkl"):
# fftw-api@3 is provided by intel-oneapi-mkl
options.append("-DGMX_FFT_LIBRARY=mkl")
if self.spec.satisfies("@:2022"):
options.append(
"-DMKL_INCLUDE_DIR={0}".format(self.spec["mkl"].headers.directories[0])
)
# The 'blas' property provides a minimal set of libraries
# that is sufficient for fft. Using full mkl fails the cmake test
options.append("-DMKL_LIBRARIES={0}".format(self.spec["blas"].libs.joined(";")))
else:
# we rely on the fftw-api@3
options.append("-DGMX_FFT_LIBRARY=fftw3")
if self.spec.satisfies("^[virtuals=fftw-api] amdfftw"):
options.append("-DGMX_FFT_LIBRARY=fftw3")
options.append(
"-DFFTWF_INCLUDE_DIRS={0}".format(self.spec["amdfftw"].headers.directories[0])
)
options.append(
"-DFFTWF_LIBRARIES={0}".format(self.spec["amdfftw"].libs.joined(";"))
)
elif self.spec.satisfies("^armpl-gcc"):
options.append(
"-DFFTWF_INCLUDE_DIR={0}".format(self.spec["armpl-gcc"].headers.directories[0])
)
options.append(
"-DFFTWF_LIBRARY={0}".format(self.spec["armpl-gcc"].libs.joined(";"))
)
elif self.spec.satisfies("^acfl"):
options.append(
"-DFFTWF_INCLUDE_DIR={0}".format(self.spec["acfl"].headers.directories[0])
)
options.append("-DFFTWF_LIBRARY={0}".format(self.spec["acfl"].libs.joined(";")))
# Ensure that the GROMACS log files report how the code was patched
# during the build, so that any problems are easier to diagnose.
# Do not rely on GMX_USE_PLUMED=AUTO
if self.spec.satisfies("+plumed"):
options.append("-DGMX_USE_PLUMED=ON")
options.append("-DGMX_VERSION_STRING_OF_FORK=PLUMED-spack")
else:
options.append("-DGMX_USE_PLUMED=OFF")
options.append("-DGMX_VERSION_STRING_OF_FORK=spack")
return options
def setup_build_environment(self, env: EnvironmentModifications) -> None:
if self.spec.satisfies("+cufftmp"):
env.append_path(
"LD_LIBRARY_PATH",
join_path(
self.spec["nvhpc"].prefix,
f"Linux_{self.spec.target.family}",
self.spec["nvhpc"].version,
"comm_libs",
"nvshmem",
"lib",
),
)
diff --git a/src/gromacs/domdec/ga2la.cpp b/src/gromacs/domdec/ga2la.cpp
index f8de0a23f92f0bf50afbd996e4c062e9909b74e8..32999842220b671fc6e93ce9418f938f083666cd 100644
--- a/src/gromacs/domdec/ga2la.cpp
+++ b/src/gromacs/domdec/ga2la.cpp
@@ -80,8 +80,9 @@ gmx_ga2la_t::gmx_ga2la_t(int numAtomsTotal, int numAtomsLocal) :
}
else
{
- new (&(data_.hashed))
- gmx::HashedMap<Entry>(numAtomsLocal, gmx_omp_nthreads_get(ModuleMultiThread::Domdec));
+ // We would like to be able to use more than 1 thread for clearing the hashed map,
+ // but the gmx_omp_nthreads might not be initialized at this point. See #5289
+ new (&(data_.hashed)) gmx::HashedMap<Entry>(numAtomsLocal);
}
}
# Copyright Spack Project Developers. See COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import json
import os
from spack_repo.builtin.build_systems.cmake import CMakePackage
from spack_repo.builtin.build_systems.rocm import ROCmPackage
from spack.package import *
class Hipsycl(CMakePackage, ROCmPackage):
"""hipSYCL is an implementation of the SYCL standard programming model
over NVIDIA CUDA/AMD HIP"""
homepage = "https://github.com/AdaptiveCpp/AdaptiveCpp"
url = "https://github.com/AdaptiveCpp/AdaptiveCpp/archive/v0.8.0.tar.gz"
git = "https://github.com/AdaptiveCpp/AdaptiveCpp.git"
provides("sycl")
license("BSD-2-Clause")
version("stable", branch="stable", submodules=True)
version("25.10.0", commit="9f842c701a599107cc6d117d3539f971036363a1", submodules=True)
version("25.02.0", commit="883b0e11b11fc59f37fa69e40c18446fcad03c50", submodules=True)
version("24.10.0", commit="7677cf6eefd8ab46d66168cd07ab042109448124", submodules=True)
version("24.06.0", commit="fc51dae9006d6858fc9c33148cc5f935bb56b075", submodules=True)
version("24.02.0", commit="974adc33ea5a35dd8b5be68c7a744b37482b8b64", submodules=True)
version("23.10.0", commit="3952b468c9da89edad9dff953cdcab0a3c3bf78c", submodules=True)
version("0.9.4", commit="99d9e24d462b35e815e0e59c1b611936c70464ae", submodules=True)
version("0.9.3", commit="51507bad524c33afe8b124804091b10fa25618dc", submodules=True)
version("0.9.2", commit="49fd02499841ae884c61c738610e58c27ab51fdb", submodules=True)
version("0.9.1", commit="fe8465cd5399a932f7221343c07c9942b0fe644c", submodules=True)
version("0.8.0", commit="2daf8407e49dd32ebd1c266e8e944e390d28b22a", submodules=True)
version("develop", branch="develop", submodules=True)
variant("cuda", default=False, description="Enable CUDA backend for SYCL kernels")
variant("rocm", default=False, description="Enable ROCM backend for SYCL kernels")
depends_on("c", type="build")
depends_on("cxx", type="build")
depends_on("cmake@3.5:", type="build")
depends_on("boost +filesystem", when="@:0.8")
depends_on("boost@1.67.0:1.69.0 +filesystem +fiber +context cxxstd=17", when="@0.9.1:")
depends_on("python@3:")
depends_on("llvm@8: +clang", when="~cuda")
depends_on("llvm@9: +clang", when="+cuda")
# hipSYCL 0.8.0 supported only LLVM 8-10:
# (https://github.com/AdaptiveCpp/AdaptiveCpp/blob/v0.8.0/CMakeLists.txt#L29-L37)
# recent versions support only up to llvm18
# https://github.com/spack/spack/issues/46681
# https://github.com/spack/spack/issues/49506
# The following list was made based on the version tested in adaptivecpp github
depends_on("llvm@14:18", when="@develop")
depends_on("llvm@14:18", when="@stable")
depends_on("llvm@14:18", when="@24.10.0")
depends_on("llvm@14:18", when="@24.06.0")
depends_on("llvm@13:17", when="@24.02.0")
depends_on("llvm@13:17", when="@23.10.0")
depends_on("llvm@11:15", when="@0.9.4")
depends_on("llvm@11:14", when="@0.9.3")
depends_on("llvm@11:13", when="@0.9.2")
depends_on("llvm@11", when="@0.9.1")
# depends_on("llvm@10:11", when="@0.9.0") # missing in releases
depends_on("llvm@8:10", when="@0.8.0")
# https://github.com/spack/spack/issues/45029 and https://github.com/spack/spack/issues/43142
conflicts("^gcc@12", when="@23.10.0")
# https://github.com/OpenSYCL/OpenSYCL/pull/918 was introduced after 0.9.4
conflicts("^gcc@12.2.0", when="@:0.9.4")
# LLVM PTX backend requires cuda7:10.1 (https://tinyurl.com/v82k5qq)
depends_on("cuda@9:10.1", when="@0.8.1: +cuda ^llvm@9")
depends_on("cuda@9:", when="@0.8.1: +cuda ^llvm@10:")
# hipSYCL@:0.8.0 requires cuda@9:10.0 due to a known bug
depends_on("cuda@9:10.0", when="@:0.8.0 +cuda")
conflicts(
"%gcc@:4",
when="@:0.9.0",
msg="hipSYCL needs proper C++14 support to be built, %gcc is too old",
)
conflicts(
"%gcc@:8",
when="@0.9.1:",
msg="hipSYCL needs proper C++17 support to be built, %gcc is too old",
)
conflicts(
"^llvm build_type=Debug",
when="+cuda",
msg="LLVM debug builds don't work with hipSYCL CUDA backend; for "
"further info please refer to: "
"https://github.com/illuhad/hipSYCL/blob/master/doc/install-cuda.md",
)
def cmake_args(self):
spec = self.spec
args = [
"-DWITH_CPU_BACKEND:Bool=TRUE",
"-DWITH_ROCM_BACKEND:Bool={0}".format("TRUE" if spec.satisfies("+rocm") else "FALSE"),
"-DWITH_CUDA_BACKEND:Bool={0}".format("TRUE" if spec.satisfies("+cuda") else "FALSE"),
# prevent hipSYCL's cmake to look for other LLVM installations
# if the specified one isn't compatible
"-DDISABLE_LLVM_VERSION_CHECK:Bool=TRUE",
]
# LLVM directory containing all installed CMake files
# (e.g.: configs consumed by client projects)
llvm_cmake_dirs = find(spec["llvm"].prefix, "LLVMExports.cmake")
if len(llvm_cmake_dirs) != 1:
raise InstallError(
"concretized llvm dependency must provide "
"a unique directory containing CMake client "
"files, found: {0}".format(llvm_cmake_dirs)
)
args.append("-DLLVM_DIR:String={0}".format(os.path.dirname(llvm_cmake_dirs[0])))
# clang internal headers directory
llvm_clang_include_dirs = find(spec["llvm"].prefix, "__clang_cuda_runtime_wrapper.h")
if len(llvm_clang_include_dirs) != 1:
raise InstallError(
"concretized llvm dependency must provide a "
"unique directory containing clang internal "
"headers, found: {0}".format(llvm_clang_include_dirs)
)
args.append(
"-DCLANG_INCLUDE_PATH:String={0}".format(os.path.dirname(llvm_clang_include_dirs[0]))
)
# target clang++ executable
llvm_clang_bin = os.path.join(spec["llvm"].prefix.bin, "clang++")
if not is_exe(llvm_clang_bin):
raise InstallError(
"concretized llvm dependency must provide a "
"valid clang++ executable, found invalid: "
"{0}".format(llvm_clang_bin)
)
args.append("-DCLANG_EXECUTABLE_PATH:String={0}".format(llvm_clang_bin))
# explicit CUDA toolkit
if spec.satisfies("+cuda"):
args.append("-DCUDA_TOOLKIT_ROOT_DIR:String={0}".format(spec["cuda"].prefix))
if spec.satisfies("+rocm"):
args.append("-DWITH_ACCELERATED_CPU:STRING=OFF")
args.append("-DROCM_PATH:STRING={0}".format(os.environ.get("ROCM_PATH")))
# Work around HIP_CLANG_INCLUDE_PATH-NOTFOUND
args.append(
"-DHIP_CLANG_INCLUDE_PATH:String={0}".format(os.path.dirname(llvm_clang_include_dirs[0]))
)
if self.spec.satisfies("@24.02.0:"):
args.append("-DWITH_SSCP_COMPILER=OFF")
args.append("-DACPP_COMPILER_FEATURE_PROFILE=minimal")
return args
@run_after("install")
def filter_config_file(self):
def edit_config(filename, editor):
config_file_paths = find(self.prefix, filename)
if len(config_file_paths) != 1:
raise InstallError(
"installed hipSYCL must provide a unique compiler driver"
"configuration file ({0}), found: {1}".format(filename, config_file_paths)
)
config_file_path = config_file_paths[0]
with open(config_file_path) as f:
config = json.load(f)
config_modified = editor(config)
with open(config_file_path, "w") as f:
json.dump(config_modified, f, indent=2)
if self.spec.satisfies("@:23.10.0"):
configfiles = {"core": "syclcc.json", "cuda": "syclcc.json"}
else:
configfiles = {"core": "acpp-core.json", "cuda": "acpp-cuda.json"}
def adjust_core_config(config):
config["default-cpu-cxx"] = self.compiler.cxx
return config
edit_config(configfiles["core"], adjust_core_config)
if self.spec.satisfies("+cuda"):
# 1. Fix compiler: use the real one in place of the Spack wrapper
# 2. Fix stdlib: we need to make sure cuda-enabled binaries find
# the libc++.so and libc++abi.so dyn linked to the sycl
# ptx backend
rpaths = set()
if self.spec.satisfies("~rocm"):
so_paths = find_libraries(
"libc++", self.spec["llvm"].prefix, shared=True, recursive=True
)
if len(so_paths) != 1:
raise InstallError(
"concretized llvm dependency must provide a "
"unique directory containing libc++.so, "
"found: {0}".format(so_paths)
)
rpaths.add(os.path.dirname(so_paths[0]))
so_paths = find_libraries(
"libc++abi", self.spec["llvm"].prefix, shared=True, recursive=True
)
if len(so_paths) != 1:
raise InstallError(
"concretized llvm dependency must provide a "
"unique directory containing libc++abi, "
"found: {0}".format(so_paths)
)
rpaths.add(os.path.dirname(so_paths[0]))
def adjust_cuda_config(config):
config["default-cuda-link-line"] += " " + " ".join(
"-rpath {0}".format(p) for p in rpaths
)
return config
edit_config(configfiles["cuda"], adjust_cuda_config)
# Copyright Spack Project Developers. See COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
from spack_repo.builtin.build_systems.cmake import CMakePackage
from spack_repo.builtin.build_systems.cuda import CudaPackage
from spack_repo.builtin.build_systems.rocm import ROCmPackage
from spack.package import *
class Kokkos(CMakePackage, CudaPackage, ROCmPackage):
"""Kokkos implements a programming model in C++ for writing performance
portable applications targeting all major HPC platforms."""
homepage = "https://github.com/kokkos/kokkos"
git = "https://github.com/kokkos/kokkos.git"
url = "https://github.com/kokkos/kokkos/releases/download/4.4.01/kokkos-4.4.01.tar.gz"
tags = ["e4s"]
test_requires_compiler = True
maintainers("cedricchevalier19", "nmm0", "lucbv", "tpadioleau")
license("Apache-2.0 WITH LLVM-exception")
version("develop", branch="develop")
version("4.7.01", sha256="404cf33e76159e83b8b4ad5d86f6899d442b5da4624820ab457412116cdcd201")
version("4.7.00", sha256="126b774a24dde8c1085c4aede7564c0b7492d6a07d85380f2b387a712cea1ff5")
version("4.6.02", sha256="baf1ebbe67abe2bbb8bb6aed81b4247d53ae98ab8475e516d9c87e87fa2422ce")
version("4.6.01", sha256="b9d70e4653b87a06dbb48d63291bf248058c7c7db4bd91979676ad5609bb1a3a")
version("4.6.00", sha256="be72cf7fc6ef6b99c614f29b945960013a2aaa23859bfe1a560d8d9aa526ec9c")
version("4.5.01", sha256="52d003ffbbe05f30c89966e4009c017efb1662b02b2b73190670d3418719564c")
version("4.5.00", sha256="cbfb742feeb9e649db9eca0394e6ca9a22aa017a1e6aab8576990772a0e3135b")
version("4.4.01", sha256="3413f0cb39912128d91424ebd92e8832009e7eeaf6fa8da58e99b0d37860d972")
version("4.4.00", sha256="0b46372f38c48aa088411ac1b7c173a5c90f0fdb69ab40271827688fc134f58b")
version(
"4.3.01",
sha256="5998b7c732664d6b5e219ccc445cd3077f0e3968b4be480c29cd194b4f45ec70",
url="https://github.com/kokkos/kokkos/archive/4.3.01.tar.gz",
)
version(
"4.3.00",
sha256="53cf30d3b44dade51d48efefdaee7a6cf109a091b702a443a2eda63992e5fe0d",
url="https://github.com/kokkos/kokkos/archive/4.3.00.tar.gz",
)
version(
"4.2.01",
sha256="cbabbabba021d00923fb357d2e1b905dda3838bd03c885a6752062fe03c67964",
url="https://github.com/kokkos/kokkos/archive/4.2.01.tar.gz",
)
version(
"4.2.00",
sha256="ac08765848a0a6ac584a0a46cd12803f66dd2a2c2db99bb17c06ffc589bf5be8",
url="https://github.com/kokkos/kokkos/archive/4.2.00.tar.gz",
)
version(
"4.1.00",
sha256="cf725ea34ba766fdaf29c884cfe2daacfdc6dc2d6af84042d1c78d0f16866275",
url="https://github.com/kokkos/kokkos/archive/4.1.00.tar.gz",
)
version(
"4.0.01",
sha256="bb942de8afdd519fd6d5d3974706bfc22b6585a62dd565c12e53bdb82cd154f0",
url="https://github.com/kokkos/kokkos/archive/4.0.01.tar.gz",
)
version(
"4.0.00",
sha256="1829a423883d4b44223c7c3a53d3c51671145aad57d7d23e6a1a4bebf710dcf6",
url="https://github.com/kokkos/kokkos/archive/4.0.00.tar.gz",
)
version(
"3.7.02",
sha256="5024979f06bc8da2fb696252a66297f3e0e67098595a0cc7345312b3b4aa0f54",
url="https://github.com/kokkos/kokkos/archive/3.7.02.tar.gz",
)
depends_on("cxx", type="build") # Kokkos requires a C++ compiler
depends_on("cmake@3.16:", type="build")
conflicts("^cmake@3.28", when="@:4.2.01 +cuda")
conflicts("^cuda@13:", when="@:4.7.0")
devices_variants = {
"cuda": [False, "Whether to build CUDA backend"],
"openmp": [False, "Whether to build OpenMP backend"],
"threads": [False, "Whether to build the C++ threads backend"],
"serial": [False, "Whether to build serial backend"],
"rocm": [False, "Whether to build HIP backend"],
"sycl": [False, "Whether to build the SYCL backend"],
"openmptarget": [False, "Whether to build the OpenMPTarget backend"],
}
requires("+serial", when="~openmp ~threads", msg="Kokkos requires at least one host backend")
tpls_variants = {
"hpx": [False, "Whether to enable the HPX library"],
"hwloc": [False, "Whether to enable the HWLOC library"],
"numactl": [False, "Whether to enable the LIBNUMA library"],
"memkind": [False, "Whether to enable the MEMKIND library"],
}
options_variants = {
"aggressive_vectorization": [False, None, "Aggressively vectorize loops"],
"compiler_warnings": [False, None, "Print all compiler warnings"],
"complex_align": [True, None, "Align complex numbers"],
"cuda_constexpr": [False, "+cuda", "Activate experimental constexpr features"],
"cuda_lambda": [False, "+cuda", "Activate experimental lambda features"],
"cuda_ldg_intrinsic": [False, "+cuda", "Use CUDA LDG intrinsics"],
"cuda_relocatable_device_code": [False, "+cuda", "Enable RDC for CUDA"],
"hip_relocatable_device_code": [False, None, "Enable RDC for HIP"],
"sycl_relocatable_device_code": [False, "@4.5: +sycl", "Enable RDC for SYCL"],
"cuda_uvm": [False, "+cuda", "Enable unified virtual memory (UVM) for CUDA"],
"debug": [False, None, "Activate extra debug features - may increase compiletimes"],
"debug_bounds_check": [False, None, "Use bounds checking - will increase runtime"],
"debug_dualview_modify_check": [False, None, "Debug check on dual views"],
"deprecated_code": [False, None, "Whether to enable deprecated code"],
"examples": [False, None, "Whether to build examples"],
"hpx_async_dispatch": [False, None, "Whether HPX supports asynchronous dispath"],
"tuning": [False, None, "Create bindings for tuning tools"],
"tests": [False, None, "Build for tests"],
}
conflicts("~debug_dualview_modify_check", when="@4.7:") # always enable from 4.7.00
spack_micro_arch_map = {
"thunderx2": "THUNDERX2",
"zen": "ZEN",
"zen2": "ZEN2",
"zen3": "ZEN3",
"zen4": "ZEN4",
"zen5": "ZEN5",
"steamroller": "KAVERI",
"excavator": "CARIZO",
"power7": "POWER7",
"power8": "POWER8",
"power9": "POWER9",
"power8le": "POWER8",
"power9le": "POWER9",
"sandybridge": "SNB",
"haswell": "HSW",
"mic_knl": "KNL",
"cannonlake": "SKX",
"cascadelake": "SKX",
"westmere": "WSM",
"ivybridge": "SNB",
"broadwell": "BDW",
"skylake": "SKL",
"icelake": "ICL",
"skylake_avx512": "SKX",
"sapphirerapids": "SPR",
}
spack_cuda_arch_map = {
"30": "kepler30",
"32": "kepler32",
"35": "kepler35",
"37": "kepler37",
"50": "maxwell50",
"52": "maxwell52",
"53": "maxwell53",
"60": "pascal60",
"61": "pascal61",
"70": "volta70",
"72": "volta72",
"75": "turing75",
"80": "ampere80",
"86": "ampere86",
"87": "ampere87",
"89": "ada89",
"90": "hopper90",
"100": "blackwell100",
"120": "blackwell120",
}
cuda_arches = spack_cuda_arch_map.values()
conflicts("+cuda", when="cuda_arch=none")
# Kokkos support only one cuda_arch at a time
variant(
"cuda_arch",
description="CUDA architecture",
values=("none",) + CudaPackage.cuda_arch_values,
default="none",
multi=False,
sticky=True,
when="+cuda",
)
# Since Kokkos supports only one amdgpu_target at a time, the multi-value property is disabled.
variant(
"amdgpu_target",
description="AMD GPU architecture",
values=("none",) + ROCmPackage.amdgpu_targets,
default="none",
multi=False,
sticky=True,
when="+rocm",
)
amdgpu_arch_map = {
"gfx900": "vega900",
"gfx906": "vega906",
"gfx936": "vega906",
"gfx908": "vega908",
"gfx90a": "vega90A",
"gfx940": "amd_gfx940",
"gfx942": "amd_gfx942",
"gfx1030": "navi1030",
"gfx1100": "navi1100",
}
amdgpu_apu_arch_map = {"gfx942": "amd_gfx942_apu"}
amd_support_conflict_msg = (
"{0} is not supported; "
"Kokkos supports the following AMD GPU targets: " + ", ".join(amdgpu_arch_map.keys())
)
amd_apu_support_conflict_msg = (
"{0} is not supported; "
"Kokkos supports the following AMD GPU targets with unified memory: "
+ ", ".join(amdgpu_apu_arch_map.keys())
)
for arch in ROCmPackage.amdgpu_targets:
if arch not in amdgpu_arch_map:
conflicts(
"+rocm", when=f"amdgpu_target={arch}", msg=amd_support_conflict_msg.format(arch)
)
if arch not in amdgpu_apu_arch_map:
conflicts(
"+rocm+apu",
when=f"amdgpu_target={arch}",
msg=amd_apu_support_conflict_msg.format(arch),
)
intel_gpu_arches = (
"intel_gen",
"intel_gen9",
"intel_gen11",
"intel_gen12lp",
"intel_dg1",
"intel_dg2",
"intel_xehp",
"intel_pvc",
)
variant(
"intel_gpu_arch",
default="none",
values=("none",) + intel_gpu_arches,
description="Intel GPU architecture",
)
variant("apu", default=False, description="Enable APU support", when="@4.5: +rocm")
for dev, (dflt, desc) in devices_variants.items():
variant(dev, default=dflt, description=desc)
conflicts("+cuda", when="+rocm", msg="CUDA and ROCm are not compatible in Kokkos.")
depends_on("intel-oneapi-dpl", when="+sycl")
depends_on("rocthrust", when="@4.3: +rocm")
for opt, (dflt, when, desc) in options_variants.items():
variant(opt, default=dflt, description=desc, when=when)
for tpl, (dflt, desc) in tpls_variants.items():
variant(tpl, default=dflt, description=desc)
depends_on(tpl, when="+%s" % tpl)
variant("wrapper", default=False, description="Use nvcc-wrapper for CUDA build")
variant("cmake_lang", default=False, description="Use CMake language support for CUDA/HIP")
depends_on("kokkos-nvcc-wrapper", when="+wrapper")
depends_on("kokkos-nvcc-wrapper@develop", when="@develop+wrapper")
conflicts("+wrapper", when="~cuda")
conflicts("+wrapper", when="+cmake_lang")
cxxstds = ["11", "14", "17", "20"]
variant("cxxstd", default="17", values=cxxstds, multi=False, description="C++ standard")
variant("pic", default=False, description="Build position independent code")
conflicts("cxxstd=11")
conflicts("cxxstd=14", when="@4.0:")
conflicts("+cuda", when="cxxstd=17 ^cuda@:10")
conflicts("+cuda", when="cxxstd=20 ^cuda@:11")
# Expose a way to disable CudaMallocAsync that can cause problems
# with some MPI such as cray-mpich
variant("alloc_async", default=False, description="Use CudaMallocAsync", when="@4.2: +cuda")
# SYCL and OpenMPTarget require C++17 or higher
for cxxstdver in cxxstds[: cxxstds.index("17")]:
conflicts(
"+sycl", when="cxxstd={0}".format(cxxstdver), msg="SYCL requires C++17 or higher"
)
conflicts(
"+openmptarget",
when="cxxstd={0}".format(cxxstdver),
msg="OpenMPTarget requires C++17 or higher",
)
# HPX should use the same C++ standard
for cxxstd in cxxstds:
depends_on("hpx cxxstd={0}".format(cxxstd), when="+hpx cxxstd={0}".format(cxxstd))
# HPX version constraints
depends_on("hpx@1.7:", when="+hpx")
# Patches
patch("sycl_bhalft_test.patch", when="@4.2.00 +sycl")
# adds amd_gfx940 support to Kokkos 4.2.00 (upstreamed in https://github.com/kokkos/kokkos/pull/6671)
patch(
"https://github.com/rbberger/kokkos/commit/293319c5844f4d8eea51eb9cd1457115a5016d3f.patch?full_index=1",
sha256="145619e87dbf26b66ea23e76906576e2a854a3b09f2a2dd70363e61419fa6a6e",
when="@4.2.00",
)
# Remove unnecessary C and C++ languages dependency in scripts/spack_test/CMakeLists.txt (upstreamed in https://github.com/kokkos/kokkos/pull/8357)
patch(
"https://github.com/kokkos/kokkos/commit/05d4901538251fff7ae6e58c84db670ad326b5c8.patch?full_index=1",
sha256="89eb693ad4913c4fd06b25d786d56bfa631d7d612df80c0f5331852e358e0608",
when="@:4.4",
)
variant("shared", default=True, description="Build shared libraries")
for backend_name in ("cuda", "hip", "sycl"):
conflicts("+shared", when=f"+{backend_name}_relocatable_device_code")
# Filter spack-generated files that may include links to the
# spack compiler wrappers
filter_compiler_wrappers("kokkos_launch_compiler", relative_root="bin")
filter_compiler_wrappers(
"KokkosConfigCommon.cmake", relative_root=os.path.join("lib64", "cmake", "Kokkos")
)
# sanity check
sanity_check_is_file = [
join_path("include", "KokkosCore_config.h"),
join_path("include", "Kokkos_Core.hpp"),
]
sanity_check_is_dir = ["bin", "include"]
@classmethod
def get_microarch(cls, target):
"""Get the Kokkos microarch name for a Spack target (spec.target)."""
smam = cls.spack_micro_arch_map
# Find closest ancestor that has a known microarch optimization
if target.name not in smam:
for target in target.ancestors:
if target.name in smam:
break
else:
# No known microarch optimizatinos
return None
return smam[target.name]
def append_args(self, cmake_prefix, cmake_options, spack_options):
variant_to_cmake_option = {"rocm": "hip"}
for variant_name in cmake_options:
opt = variant_to_cmake_option.get(variant_name, variant_name)
optname = f"Kokkos_{cmake_prefix}_{opt.upper()}"
# Explicitly enable or disable
option = self.define_from_variant(optname, variant_name)
if option:
spack_options.append(option)
@property
def kokkos_cxx(self) -> str:
if self.spec.satisfies("+wrapper"):
return self["kokkos-nvcc-wrapper"].kokkos_cxx
# Assumes build-time globals have been set already
return spack_cxx
def cmake_args(self):
spec = self.spec
from_variant = self.define_from_variant
if spec.satisfies("~wrapper+cuda") and not (
spec.satisfies("%clang") or spec.satisfies("%cce") or spec.satisfies("+cmake_lang")
):
raise InstallError(
"Kokkos requires +wrapper when using +cuda without %clang, %cce or +cmake_lang"
)
options = [
from_variant("CMAKE_POSITION_INDEPENDENT_CODE", "pic"),
from_variant("CMAKE_CXX_STANDARD", "cxxstd"),
from_variant("BUILD_SHARED_LIBS", "shared"),
from_variant("Kokkos_ENABLE_COMPILE_AS_CMAKE_LANGUAGE", "cmake_lang"),
]
spack_microarches = []
if spec.satisfies("+cuda"):
cuda_arch = spec.variants["cuda_arch"].value
if cuda_arch != "none":
kokkos_arch_name = self.spack_cuda_arch_map[cuda_arch]
spack_microarches.append(kokkos_arch_name)
kokkos_microarch_name = self.get_microarch(spec.target)
if kokkos_microarch_name:
spack_microarches.append(kokkos_microarch_name)
if spec.satisfies("+rocm"):
amdgpu_target = spec.variants["amdgpu_target"].value
if amdgpu_target != "none":
if amdgpu_target in self.amdgpu_arch_map:
if spec.satisfies("+apu") and amdgpu_target in self.amdgpu_apu_arch_map:
spack_microarches.append(self.amdgpu_apu_arch_map[amdgpu_target])
else:
spack_microarches.append(self.amdgpu_arch_map[amdgpu_target])
else:
# Note that conflict declarations should prevent
# choosing an unsupported AMD GPU target
raise SpackError("Unsupported target: {0}".format(amdgpu_target))
if self.spec.variants["intel_gpu_arch"].value != "none":
spack_microarches.append(self.spec.variants["intel_gpu_arch"].value)
for arch in spack_microarches:
options.append(self.define("Kokkos_ARCH_" + arch.upper(), True))
self.append_args("ENABLE", self.devices_variants.keys(), options)
self.append_args("ENABLE", self.options_variants.keys(), options)
self.append_args("ENABLE", self.tpls_variants.keys(), options)
for tpl in self.tpls_variants:
if spec.variants[tpl].value:
options.append(self.define(tpl + "_DIR", spec[tpl].prefix))
if self.spec.satisfies("+wrapper"):
options.append(self.define("CMAKE_CXX_COMPILER", self.kokkos_cxx))
elif "+rocm" in self.spec:
if "+cmake_lang" in self.spec:
if self.spec.satisfies("%cxx=clang"):
options.append(self.define("CMAKE_HIP_COMPILER", self.compiler.cxx))
else:
options.append(
self.define(
"CMAKE_HIP_COMPILER",
join_path(self.spec["llvm-amdgpu"].prefix.bin, "amdclang++"),
)
)
options.append(from_variant("CMAKE_HIP_STANDARD", "cxxstd"))
options.append(
self.define(
"CMAKE_HIP_ARCHITECTURES", self.spec.variants["amdgpu_target"].value
)
)
options.append(self.define("CMAKE_HIP_EXTENSIONS", False))
else:
options.append(self.define("CMAKE_CXX_COMPILER", self.spec["hip"].hipcc))
options.append(self.define("Kokkos_ENABLE_ROCTHRUST", True))
elif "+cuda" in self.spec and "+cmake_lang" in self.spec:
if self.spec.satisfies("%cxx=clang"):
options.append(self.define("CMAKE_CUDA_COMPILER", self.compiler.cxx))
else:
options.append(
self.define(
"CMAKE_CUDA_COMPILER", join_path(self.spec["cuda"].prefix.bin, "nvcc")
)
)
options.append(
self.define("CMAKE_CUDA_ARCHITECTURES", self.spec.variants["cuda_arch"].value)
)
options.append(from_variant("CMAKE_CUDA_STANDARD", "cxxstd"))
options.append(self.define("CMAKE_CUDA_EXTENSIONS", False))
if self.spec.satisfies("%oneapi") or self.spec.satisfies("%intel"):
options.append(self.define("CMAKE_CXX_FLAGS", "-fp-model=precise"))
options.append(
self.define_from_variant("Kokkos_ENABLE_IMPL_CUDA_MALLOC_ASYNC", "alloc_async")
)
if self.version == Version("4.7.00"):
options.append(self.define("Kokkos_ENABLE_IMPL_VIEW_LEGACY", True))
# Remove duplicate options
return dedupe(options)
test_script_relative_path = join_path("scripts", "spack_test")
@run_after("install")
def setup_build_tests(self):
# Skip if unsupported version
cmake_source_path = join_path(self.stage.source_path, self.test_script_relative_path)
if not os.path.exists(cmake_source_path):
return
# Copy test
cmake_out_path = join_path(self.test_script_relative_path, "out")
cmake_args = [
cmake_source_path,
"-DSPACK_PACKAGE_SOURCE_DIR:PATH={0}".format(self.stage.source_path),
"-DSPACK_PACKAGE_TEST_ROOT_DIR:PATH={0}".format(
join_path(install_test_root(self), cmake_out_path)
),
"-DSPACK_PACKAGE_INSTALL_DIR:PATH={0}".format(self.prefix),
]
cmake(*cmake_args)
cache_extra_test_sources(self, cmake_out_path)
def test_run(self):
"""Test if kokkos builds and runs"""
cmake_path = join_path(
self.test_suite.current_test_cache_dir, self.test_script_relative_path, "out"
)
if not os.path.exists(cmake_path):
raise SkipTest(f"{cmake_path} is missing")
cmake = self.spec["cmake"].command
cmake_args = ["-DEXECUTABLE_OUTPUT_PATH=" + cmake_path]
if self.spec.satisfies("+rocm"):
prefix_paths = ";".join(get_cmake_prefix_path(self))
cmake_args.append("-DCMAKE_PREFIX_PATH={0}".format(prefix_paths))
cmake(cmake_path, *cmake_args)
make = which("make")
make()
make(cmake_path, "test")
diff -ruN spack-src/core/unit_test/TestNumericTraits.hpp spack-src-patched/core/unit_test/TestNumericTraits.hpp
--- spack-src/core/unit_test/TestNumericTraits.hpp 2023-11-20 13:26:46.000000000 -0800
+++ spack-src-patched/core/unit_test/TestNumericTraits.hpp 2023-11-28 12:06:44.216150685 -0800
@@ -110,8 +110,8 @@
KOKKOS_FUNCTION void operator()(Epsilon, int, int& e) const {
using Kokkos::Experimental::epsilon;
- auto const eps = epsilon<T>::value;
- auto const one = T(1);
+ T const eps = epsilon<T>::value;
+ T const one = 1;
// Avoid higher precision intermediate representation
compare() = one + eps;
e += (int)!(compare() != one);
diff --git a/cmake/modules/FindBLIS.cmake b/cmake/modules/FindBLIS.cmake
index 3d6fb5d..2577598 100644
--- a/cmake/modules/FindBLIS.cmake
+++ b/cmake/modules/FindBLIS.cmake
@@ -52,7 +52,7 @@ endif()
find_library(
BLIS_LIBRARIES
- NAMES "blis"
+ NAMES "blis-mt" "blis"
HINTS ${_BLIS_PATHS}
PATH_SUFFIXES "blis/lib" "blis/lib64" "blis"
)
# Copyright Spack Project Developers. See COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
from spack_repo.builtin.build_systems.cmake import CMakePackage
from spack.package import *
class Spla(CMakePackage):
"""Specialized Parallel Linear Algebra, providing distributed GEMM
functionality for specific matrix distributions with optional GPU
acceleration."""
homepage = "https://github.com/eth-cscs/spla"
url = "https://github.com/eth-cscs/spla/archive/v1.0.0.tar.gz"
git = "https://github.com/eth-cscs/spla.git"
maintainers("AdhocMan", "haampie")
license("BSD-3-Clause")
version("1.6.1", sha256="62b51e6ce05c41cfc1c6f6600410f9549a209c50f0331e1db41047f94493e02f")
version("1.6.0", sha256="917c24e2a768499967eba47b2cc2475df9fabee327b7821d24970b6a08055c09")
version("1.5.5", sha256="bc0c366e228344b1b2df55b9ce750d73c1165380e512da5a04d471db126d66ce")
version("1.5.4", sha256="de30e427d24c741e2e4fcae3d7668162056ac2574afed6522c0bb49d6f1d0f79")
version("1.5.3", sha256="527c06e316ce46ec87309a16bfa4138b1abad23fd276fe789c78a2de84f05637")
version("1.5.2", sha256="344c34986dfae182ec2e1eb539c9a57f75683aaa7a61a024fd0c594d81d97016")
version("1.5.1", sha256="2021a30b7cbb10bd660e5d94e1cc7bc6a428c87ea507e09d1e57e455685da421")
version("1.5.0", sha256="bea782d46ce615e1c40efc2bfb19d95e3b59f332fc9ca83ac7e6684b8ac2dd93")
version("1.4.0", sha256="364a9fe759fddec8a0839cf79f1cf0619fc36f4d4c15f1c2b1f437249d7840c6")
version("1.3.0", sha256="ff05a22bd655607ff941f3228ac8605a813e1eec6eaa49fbcf7b58a3a4cf5f00")
version("1.2.1", sha256="4d7237f752dc6257778c84ee19c9635072b1cb8ce8d9ab6e34a047f63a736b29")
version("1.2.0", sha256="96ddd13c155ef3d7e40f87a982cdb439cf9e720523e66b6d20125d346ffe8fca")
version("1.1.1", sha256="907c374d9c53b21b9f67ce648e7b2b09c320db234a1013d3f05919cd93c95a4b")
version("1.1.0", sha256="b0c4ebe4988abc2b3434e6c50e7eb0612f3f401bc1aa79ad58a6a92dc87fa65b")
version("1.0.0", sha256="a0eb269b84d7525b223dc650de12170bba30fbb3ae4f93eb2b5cbdce335e4da1")
version("develop", branch="develop")
version("master", branch="master")
variant("openmp", default=True, when="@:1.5.5", description="Build with OpenMP support")
variant("static", default=False, description="Build as static library")
variant("cuda", default=False, description="CUDA backend")
variant("rocm", default=False, description="ROCm backend")
variant("fortran", default=False, description="Build fortran module")
conflicts("+cuda", when="+rocm", msg="+cuda and +rocm are mutually exclusive")
conflicts(
"%gcc@13.0:",
when="@1.5.0:1.5.4",
msg="Version 1.5.0 to 1.5.4 is not compatible with GCC 13 and later.",
)
depends_on("c", type="build") # generated
depends_on("cxx", type="build") # generated
depends_on("fortran", type="build") # generated
depends_on("mpi")
depends_on("blas")
depends_on("cmake@3.10:", type="build")
depends_on("cmake@3.18:", type="build", when="@1.6.0:")
depends_on("cuda", when="+cuda")
depends_on("cuda@11:", when="@1.6.0: +cuda")
depends_on("llvm", when="+rocm")
depends_on("hip", when="+rocm")
depends_on("rocblas", when="+rocm")
conflicts("^rocblas@6.0.0:", when="@:1.5.5 +rocm")
conflicts("^hip@6.0.0:", when="@:1.6.0 +rocm") # v1.6.1 includes fix for hip 6.0
# Propagate openmp to blas
with when("+openmp"):
requires("^openblas threads=openmp", when="^[virtuals=blas] openblas")
requires("^amdblis threads=openmp", when="^[virtuals=blas] amdblis")
requires("^blis threads=openmp", when="^[virtuals=blas] blis")
requires("^intel-oneapi-mkl threads=openmp", when="^[virtuals=blas] intel-oneapi-mkl")
# Fix CMake find module for AMD BLIS,
# which uses a different library name for the multi-threaded version
patch("0001-amd_blis.patch", when="@1.3.0:1.4.0 ^amdblis")
def cmake_args(self):
spec = self.spec
args = [
self.define_from_variant("SPLA_FORTRAN", "fortran"),
self.define_from_variant("SPLA_STATIC", "static"),
]
if "+cuda" in spec:
args += ["-DSPLA_GPU_BACKEND=CUDA"]
elif "+rocm" in spec:
args += ["-DSPLA_GPU_BACKEND=ROCM"]
llvm_clang_include_dirs = find(spec["llvm"].prefix, "__clang_cuda_runtime_wrapper.h")
args.append(
"-DCLANG_INCLUDE_PATH:String={0}".format(os.path.dirname(llvm_clang_include_dirs[0]))
)
else:
args += ["-DSPLA_GPU_BACKEND=OFF"]
# v1.6.0: No longer has custom BLAS detection and only uses the FindBLAS CMake module.
if spec.satisfies("@:1.5.5"):
args += [self.define_from_variant("SPLA_OMP", "openmp")]
if spec["blas"].name == "openblas":
args += ["-DSPLA_HOST_BLAS=OPENBLAS"]
elif spec["blas"].name in ["amdblis", "blis"]:
args += ["-DSPLA_HOST_BLAS=BLIS"]
elif spec["blas"].name == "atlas":
args += ["-DSPLA_HOST_BLAS=ATLAS"]
elif spec["blas"].name == "intel-oneapi-mkl":
args += ["-DSPLA_HOST_BLAS=MKL"]
elif spec["blas"].name == "netlib-lapack":
args += ["-DSPLA_HOST_BLAS=GENERIC"]
elif spec["blas"].name == "cray-libsci":
args += ["-DSPLA_HOST_BLAS=CRAY_LIBSCI"]
else:
args += [self.define("BLAS_LIBRARIES", spec["blas"].libs.joined(";"))]
return args
repo:
namespace: 'hygon.tsoc'
api: v2.4
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment