gromacs: add CP2K (#31836)
This commit is contained in:
parent
1841e947f6
commit
b24a068f3d
3 changed files with 70 additions and 4 deletions
|
@ -23,6 +23,7 @@ class Cp2k(MakefilePackage, CudaPackage):
|
|||
|
||||
maintainers = ["dev-zero"]
|
||||
|
||||
version("2022.1", sha256="2c34f1a7972973c62d471cd35856f444f11ab22f2ff930f6ead20f3454fd228b")
|
||||
version("9.1", sha256="fedb4c684a98ad857cd49b69a3ae51a73f85a9c36e9cb63e3b02320c74454ce6")
|
||||
version("8.2", sha256="2e24768720efed1a5a4a58e83e2aca502cd8b95544c21695eb0de71ed652f20a")
|
||||
version("8.1", sha256="7f37aead120730234a60b2989d0547ae5e5498d93b1e9b5eb548c041ee8e7772")
|
||||
|
@ -732,10 +733,48 @@ def build(self, spec, prefix):
|
|||
with spack.util.environment.set_env(PWD=self.build_directory):
|
||||
super(Cp2k, self).build(spec, prefix)
|
||||
|
||||
with working_dir(self.build_directory):
|
||||
make("libcp2k", *self.build_targets)
|
||||
|
||||
def install(self, 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"))
|
||||
|
||||
@run_after("install")
|
||||
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.
|
||||
"""
|
||||
with open(join_path(self.prefix.lib.pkgconfig, "libcp2k.pc"), "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
|
||||
|
||||
if "^fftw+openmp" in self.spec:
|
||||
content += " -lfftw3_omp"
|
||||
|
||||
content += "\n"
|
||||
|
||||
handle.seek(0)
|
||||
handle.write(content)
|
||||
|
||||
def check(self):
|
||||
data_dir = join_path(self.stage.source_path, "data")
|
||||
|
|
|
@ -17,6 +17,7 @@ class Dbcsr(CMakePackage, CudaPackage, ROCmPackage):
|
|||
maintainers = ["dev-zero"]
|
||||
|
||||
version("develop", branch="develop")
|
||||
version("2.3.0", sha256="f750de586cffa66852b646f7f85eb831eeb64fa2d25ce50ed10e1df016dd3364")
|
||||
version("2.2.0", sha256="245b0382ddc7b80f85af8288f75bd03d56ec51cdfb6968acb4931529b35173ec")
|
||||
version("2.1.0", sha256="9e58fd998f224632f356e479d18b5032570d00d87b86736b6a6ac2d03f8d4b3c")
|
||||
version("2.0.1", sha256="61d5531b661e1dab043353a1d67939ddcde3893d3dc7b0ab3d05074d448b485c")
|
||||
|
@ -114,20 +115,23 @@ def cmake_args(self):
|
|||
]
|
||||
|
||||
# Switch necessary as a result of a bug.
|
||||
# In version 2.0, this switch doesn't exist yet.
|
||||
# The issue should be already fixed in 2.3 (not released yet).
|
||||
if "@2.1:2.2" in spec:
|
||||
args += ["-DBUILD_TESTING=ON"]
|
||||
|
||||
if self.spec.satisfies("+cuda"):
|
||||
cuda_arch = self.spec.variants["cuda_arch"].value[0]
|
||||
|
||||
gpuver = {
|
||||
gpu_map = {
|
||||
"35": "K40",
|
||||
"37": "K80",
|
||||
"60": "P100",
|
||||
"70": "V100",
|
||||
}[cuda_arch]
|
||||
}
|
||||
|
||||
if "@2.3:" in spec:
|
||||
gpu_map["80"] = "A100"
|
||||
|
||||
gpuver = gpu_map[cuda_arch]
|
||||
|
||||
if cuda_arch == "35" and self.spec.satisfies("+cuda_arch_35_k20x"):
|
||||
gpuver = "K20X"
|
||||
|
|
|
@ -124,6 +124,22 @@ class Gromacs(CMakePackage):
|
|||
variant("blas", default=False, description="Enables an external BLAS 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(
|
||||
"~lapack",
|
||||
when="+cp2k",
|
||||
msg="GROMACS and CP2K should use the same lapack, please disable bundled lapack",
|
||||
)
|
||||
conflicts(
|
||||
"~blas",
|
||||
when="+cp2k",
|
||||
msg="GROMACS and CP2K should use the same blas, please disable bundled blas",
|
||||
)
|
||||
|
||||
depends_on("mpi", when="+mpi")
|
||||
|
||||
# Plumed 2.8.0 needs Gromacs 2021.4, 2020.6, 2019.6
|
||||
|
@ -198,6 +214,9 @@ class Gromacs(CMakePackage):
|
|||
depends_on("hwloc@1.0:1", when="+hwloc@2016:2018")
|
||||
depends_on("hwloc", when="+hwloc@2019:")
|
||||
|
||||
depends_on("cp2k@8.1:", when="+cp2k")
|
||||
depends_on("dbcsr", when="+cp2k")
|
||||
|
||||
patch("gmxDetectCpu-cmake-3.14.patch", when="@2018:2019.3^cmake@3.14.0:")
|
||||
patch("gmxDetectSimd-cmake-3.14.patch", when="@5.0:2017^cmake@3.14.0:")
|
||||
|
||||
|
@ -374,6 +393,10 @@ def cmake_args(self):
|
|||
else:
|
||||
options.append("-DGMX_EXTERNAL_BLAS:BOOL=OFF")
|
||||
|
||||
if "+cp2k" in self.spec:
|
||||
options.append("-DGMX_CP2K:BOOL=ON")
|
||||
options.append("-DCP2K_DIR:STRING={0}".format(self.spec["cp2k"].prefix))
|
||||
|
||||
# Activate SIMD based on properties of the target
|
||||
target = self.spec.target
|
||||
if target >= "zen2":
|
||||
|
|
Loading…
Reference in a new issue