diff --git a/config.yaml b/config.yaml index 190b4f62f..d78a52a36 100644 --- a/config.yaml +++ b/config.yaml @@ -420,6 +420,14 @@ uenvs: santis: [gh200] daint: [gh200] eiger: [zen2] + "v7.5": + recipes: + gh200: v7.5/gh200 + zen2: v7.5/mc + deploy: + santis: [gh200] + daint: [gh200] + eiger: [zen2] sirius: "v7.5": recipes: diff --git a/recipes/quantumespresso/v7.5/gh200/compilers.yaml b/recipes/quantumespresso/v7.5/gh200/compilers.yaml new file mode 100644 index 000000000..cc5c10cc3 --- /dev/null +++ b/recipes/quantumespresso/v7.5/gh200/compilers.yaml @@ -0,0 +1,4 @@ +gcc: + version: "14" +nvhpc: + version: "26.1" diff --git a/recipes/quantumespresso/v7.5/gh200/config.yaml b/recipes/quantumespresso/v7.5/gh200/config.yaml new file mode 100644 index 000000000..79296277d --- /dev/null +++ b/recipes/quantumespresso/v7.5/gh200/config.yaml @@ -0,0 +1,10 @@ +name: quantumespresso +version: 2 +spack: + repo: https://github.com/spack/spack.git + commit: releases/v1.2 + packages: + repo: https://github.com/spack/spack-packages.git + commit: badd2122140f3850ac5e57a7ece1e885cc1436ce +store: /user-environment +description: QuantumESPRESSO on GH200 diff --git a/recipes/quantumespresso/v7.5/gh200/environments.yaml b/recipes/quantumespresso/v7.5/gh200/environments.yaml new file mode 100644 index 000000000..93982f208 --- /dev/null +++ b/recipes/quantumespresso/v7.5/gh200/environments.yaml @@ -0,0 +1,30 @@ +nvhpc-env: + compiler: [gcc, nvhpc] + network: + mpi: cray-mpich@9.1.0+cuda %c,cxx,fortran=nvhpc + specs: [ 'libfabric@2.3 +gdrcopy %c=gcc' ] + unify: when_possible + specs: + - quantum-espresso@7.5 +libxc +cuda +scalapack +elpa +openmp +mpigpu +gipaw +oscdft +wannier90_external hdf5=parallel %c,cxx,fortran=nvhpc + - nvpl-scalapack + - wannier90 + - fftw%nvhpc + - nvpl-blas threads=openmp + - nvpl-lapack threads=openmp + - libxc~cuda %c,fortran=nvhpc + - cmake + - elpa +cuda %c,cxx,fortran=nvhpc + - hdf5 %nvhpc + - cuda + packages: + - git + variants: + - +mpi + - +cuda + - cuda_arch=90 + views: + default: + link: roots + develop: + exclude: ['quantum-espresso', 'patchelf', 'git'] + link: roots diff --git a/recipes/quantumespresso/v7.5/gh200/extra/reframe.yaml b/recipes/quantumespresso/v7.5/gh200/extra/reframe.yaml new file mode 100644 index 000000000..81b9fff46 --- /dev/null +++ b/recipes/quantumespresso/v7.5/gh200/extra/reframe.yaml @@ -0,0 +1,24 @@ +develop: + features: + - cuda + - mpi + - qe-dev + cc: mpicc + cxx: mpic++ + ftn: mpifort + views: + - modules + activation: + - module load cmake fftw nvhpc nvpl-lapack nvpl-blas cray-mpich netlib-scalapack libxc cray-mpich cuda +modules: + features: + - cuda + - mpi + - qe + cc: mpicc + cxx: mpic++ + ftn: mpifort + views: + - modules + activation: + - module load quantum-espresso nvhpc diff --git a/recipes/quantumespresso/v7.5/gh200/modules.yaml b/recipes/quantumespresso/v7.5/gh200/modules.yaml new file mode 100644 index 000000000..623307b09 --- /dev/null +++ b/recipes/quantumespresso/v7.5/gh200/modules.yaml @@ -0,0 +1,23 @@ +modules: + # Paths to check when creating modules for all module sets + prefix_inspections: + bin: + - PATH + lib: + - LD_LIBRARY_PATH + lib64: + - LD_LIBRARY_PATH + + default: + arch_folder: false + # Where to install modules + roots: + tcl: /user-environment/modules + tcl: + all: + autoload: none + hash_length: 0 + exclude_implicits: true + exclude: ['%gcc@7.5.0', 'gcc %gcc@7.5.0'] + projections: + all: '{name}/{version}' diff --git a/recipes/quantumespresso/v7.5/gh200/repo b/recipes/quantumespresso/v7.5/gh200/repo new file mode 120000 index 000000000..3f5a289d6 --- /dev/null +++ b/recipes/quantumespresso/v7.5/gh200/repo @@ -0,0 +1 @@ +../repo \ No newline at end of file diff --git a/recipes/quantumespresso/v7.5/mc/compilers.yaml b/recipes/quantumespresso/v7.5/mc/compilers.yaml new file mode 100644 index 000000000..8bd185e43 --- /dev/null +++ b/recipes/quantumespresso/v7.5/mc/compilers.yaml @@ -0,0 +1,2 @@ +gcc: + version: "14.3" diff --git a/recipes/quantumespresso/v7.5/mc/config.yaml b/recipes/quantumespresso/v7.5/mc/config.yaml new file mode 100644 index 000000000..45f68b8b1 --- /dev/null +++ b/recipes/quantumespresso/v7.5/mc/config.yaml @@ -0,0 +1,10 @@ +name: quantumespresso +version: 2 +spack: + commit: releases/v1.2 + repo: https://github.com/spack/spack.git + packages: + repo: https://github.com/spack/spack-packages.git + commit: badd2122140f3850ac5e57a7ece1e885cc1436ce +store: /user-environment +description: QuantumESPRESSO on Zen2 diff --git a/recipes/quantumespresso/v7.5/mc/environments.yaml b/recipes/quantumespresso/v7.5/mc/environments.yaml new file mode 100644 index 000000000..314b800da --- /dev/null +++ b/recipes/quantumespresso/v7.5/mc/environments.yaml @@ -0,0 +1,22 @@ +gcc-env: + compiler: [gcc] + network: + mpi: cray-mpich@8.1.32 + unify: true + specs: + - quantum-espresso@7.5 +libxc +oscdft +wannier90_external +gipaw +scalapack +elpa +openmp hdf5=parallel + - netlib-scalapack + - wannier90 + - cmake + - libxc + - fftw + - hdf5 + - openblas threads=openmp + variants: + - +mpi + views: + default: + link: roots + develop: + exclude: ['quantum-espresso', 'patchelf', 'git'] + link: roots diff --git a/recipes/quantumespresso/v7.5/mc/extra/reframe.yaml b/recipes/quantumespresso/v7.5/mc/extra/reframe.yaml new file mode 100644 index 000000000..f1b085bd2 --- /dev/null +++ b/recipes/quantumespresso/v7.5/mc/extra/reframe.yaml @@ -0,0 +1,26 @@ +develop: + features: + - mpi + - qe-dev + cc: mpicc + cxx: mpic++ + ftn: mpifort + views: + - modules + activation: + - module load cmake fftw openblas cray-mpich netlib-scalapack libxc + extras: + version: v7.5 +modules: + features: + - mpi + - qe + cc: mpicc + cxx: mpic++ + ftn: mpifort + views: + - modules + activation: + - module load quantum-espresso + extras: + version: v7.5 diff --git a/recipes/quantumespresso/v7.5/mc/modules.yaml b/recipes/quantumespresso/v7.5/mc/modules.yaml new file mode 100644 index 000000000..623307b09 --- /dev/null +++ b/recipes/quantumespresso/v7.5/mc/modules.yaml @@ -0,0 +1,23 @@ +modules: + # Paths to check when creating modules for all module sets + prefix_inspections: + bin: + - PATH + lib: + - LD_LIBRARY_PATH + lib64: + - LD_LIBRARY_PATH + + default: + arch_folder: false + # Where to install modules + roots: + tcl: /user-environment/modules + tcl: + all: + autoload: none + hash_length: 0 + exclude_implicits: true + exclude: ['%gcc@7.5.0', 'gcc %gcc@7.5.0'] + projections: + all: '{name}/{version}' diff --git a/recipes/quantumespresso/v7.5/mc/repo b/recipes/quantumespresso/v7.5/mc/repo new file mode 120000 index 000000000..3f5a289d6 --- /dev/null +++ b/recipes/quantumespresso/v7.5/mc/repo @@ -0,0 +1 @@ +../repo \ No newline at end of file diff --git a/recipes/quantumespresso/v7.5/repo/packages/elpa/0001-add-cpp17-flag.patch b/recipes/quantumespresso/v7.5/repo/packages/elpa/0001-add-cpp17-flag.patch new file mode 100644 index 000000000..c8b18bcc7 --- /dev/null +++ b/recipes/quantumespresso/v7.5/repo/packages/elpa/0001-add-cpp17-flag.patch @@ -0,0 +1,25 @@ +From b5ae0e1984464513841f7125f18ac2cbcbf2e470 Mon Sep 17 00:00:00 2001 +From: Simon Pintarelli +Date: Wed, 27 May 2026 22:43:10 +0200 +Subject: [PATCH] add cpp17 flag + +--- + manual_cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/manual_cpp b/manual_cpp +index b3bdaf9..10c1345 100755 +--- a/manual_cpp ++++ b/manual_cpp +@@ -75,7 +75,7 @@ tmp_filename = tmp_filename[-250:] + + if (ext==".cu"): + # preprocess +- list_preprocess_call_cu = ["nvcc"] + cpp_args + ["-E"] + [file] + ["-o"] + [tmp_filename] ++ list_preprocess_call_cu = ["nvcc"] + cpp_args + ["-std=c++17"] + ["-E"] + [file] + ["-o"] + [tmp_filename] + check_call(list_preprocess_call_cu) + + # compile +-- +2.54.0 + diff --git a/recipes/quantumespresso/v7.5/repo/packages/elpa/fujitsu.patch b/recipes/quantumespresso/v7.5/repo/packages/elpa/fujitsu.patch new file mode 100644 index 000000000..d3600cf6b --- /dev/null +++ b/recipes/quantumespresso/v7.5/repo/packages/elpa/fujitsu.patch @@ -0,0 +1,65 @@ +From 8bda2149e4398bb6e6b66e601151966c91f9ec78 Mon Sep 17 00:00:00 2001 +From: m-shunji +Date: Wed, 13 Sep 2023 17:58:26 +0900 +Subject: [PATCH] Fix compile error in disabling openmp + +--- + src/elpa_impl_math_template.F90 | 6 +++--- + test/Fortran/test_autotune.F90 | 4 ++-- + 2 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/src/elpa_impl_math_template.F90 b/src/elpa_impl_math_template.F90 +index f87a0ad..b41c0c3 100644 +--- a/src/elpa_impl_math_template.F90 ++++ b/src/elpa_impl_math_template.F90 +@@ -888,10 +888,10 @@ + #endif + #ifdef COMPLEXCASE + #ifdef DOUBLE_PRECISION_COMPLEX +- & !bind(C, name="elpa_solve_tridiagonal_dc") ++ bind(C, name="elpa_solve_tridiagonal_dc") + #endif + #ifdef SINGLE_PRECISION_COMPLEX +- & !bind(C, name="elpa_solve_tridiagonal_fc") ++ bind(C, name="elpa_solve_tridiagonal_fc") + #endif + #endif + +@@ -913,4 +913,4 @@ + &ELPA_IMPL_SUFFIX& + & (self, d, e, q, error) + end subroutine +- +\ No newline at end of file ++ +diff --git a/test/Fortran/test_autotune.F90 b/test/Fortran/test_autotune.F90 +index 4662564..5355ab3 100644 +--- a/test/Fortran/test_autotune.F90 ++++ b/test/Fortran/test_autotune.F90 +@@ -312,8 +312,8 @@ program test + status = check_correctness_analytic(na, nev, ev, z, nblk, myid, np_rows, np_cols, my_prow, my_pcol, & + .true., .true., print_times=.false.) + a(:,:) = as(:,:) +- call e%autotune_print_state(tune_state) +- call e%autotune_save_state(tune_state, "saved_state_"//trim(iter_string)//".txt") ++ call e%autotune_print_state(tune_state, error_elpa) ++ call e%autotune_save_state(tune_state, "saved_state_"//trim(iter_string)//".txt", error_elpa) + end do + + !! set and print the autotuned-settings +-- +1.8.3.1 +diff --git a/manual_cpp b/manual_cpp +index 6f74a79..dbdfc65 100755 +--- a/manual_cpp ++++ b/manual_cpp +@@ -46,7 +46,7 @@ elif len(files) == 0: + elif len(files) == 1: + file, = files + +-tmp_filename = "manually_preprocessed_" + file.replace("/", "_") ++tmp_filename = "manually_preprocessed_" + file.replace("/", "_").replace("-", "_") + + try: + output = args.index("-o") + diff --git a/recipes/quantumespresso/v7.5/repo/packages/elpa/hipcc.patch b/recipes/quantumespresso/v7.5/repo/packages/elpa/hipcc.patch new file mode 100644 index 000000000..4d199689a --- /dev/null +++ b/recipes/quantumespresso/v7.5/repo/packages/elpa/hipcc.patch @@ -0,0 +1,23 @@ +diff --git a/hipcc_wrap b/hipcc_wrap +index 9c843ace84..344e7247e9 100755 +--- a/hipcc_wrap ++++ b/hipcc_wrap +@@ -1,4 +1,4 @@ +-#!/bin/sh ++#!/bin/bash + + ARGS=() + for arg in "$@"; do +diff --git a/test/shared/GPU/ROCm/test_rocmFunctions.hip b/test/shared/GPU/ROCm/test_rocmFunctions.hip +index ddb5956950..b04368d71a 100644 +--- a/test/shared/GPU/ROCm/test_rocmFunctions.hip ++++ b/test/shared/GPU/ROCm/test_rocmFunctions.hip +@@ -331,7 +331,7 @@ + #else /* HIPBLAS */ + #include "rocblas/rocblas.h" + #ifdef WITH_AMD_ROCSOLVER +-#include ++#include + #endif + #endif /* HIPBLAS */ + #include "hip/hip_runtime_api.h" diff --git a/recipes/quantumespresso/v7.5/repo/packages/elpa/package.py b/recipes/quantumespresso/v7.5/repo/packages/elpa/package.py new file mode 100644 index 000000000..32c18fe8a --- /dev/null +++ b/recipes/quantumespresso/v7.5/repo/packages/elpa/package.py @@ -0,0 +1,293 @@ +# 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.autotools import AutotoolsPackage +from spack_repo.builtin.build_systems.cuda import CudaPackage +from spack_repo.builtin.build_systems.rocm import ROCmPackage + +from spack.package import * + +# +# Please note that you can open issues on the github page of ELPA: +# https://github.com/marekandreas/elpa/issues +# + + +class Elpa(AutotoolsPackage, CudaPackage, ROCmPackage): + """Eigenvalue solvers for Petaflop-Applications (ELPA)""" + + homepage = "https://elpa.mpcdf.mpg.de/" + url = "https://elpa.mpcdf.mpg.de/software/tarball-archive/Releases/2015.11.001/elpa-2015.11.001.tar.gz" + git = "https://gitlab.mpcdf.mpg.de/elpa/elpa.git" + + license("LGPL-3.0-only") + + version("master", branch="master") + + version( + "2026.02.001", sha256="a379f27f4dbd27b2ee45017afec656d064301e97150c874649bdfd64957b75ed" + ) + version( + "2025.06.001", sha256="feeb1fea1ab4a8670b8d3240765ef0ada828062ef7ec9b735eecba2848515c94" + ) + version( + "2025.01.002", sha256="8febe408c590ba9b44bd8bce04605fd1b7da964afcd8fd5f1ce9edecb3d0b65d" + ) + version( + "2025.01.001", sha256="3ef0c6aed9a3e05db6efafe6e14d66eb88b2a1354d61e765b7cde0d3d5f3951e" + ) + version( + "2024.05.001", sha256="9caf41a3e600e2f6f4ce1931bd54185179dade9c171556d0c9b41bbc6940f2f6" + ) + version( + "2024.03.001", sha256="41c6cbf56d2dac26443faaba8a77307d261bf511682a64b96e24def77c813622" + ) + version( + "2023.11.001-patched", + sha256="62ee109afc06539507f459c08b958dc4db65b757dbd77f927678c77f7687415e", + url="https://elpa.mpcdf.mpg.de/software/tarball-archive/Releases/2023.11.001/elpa-2023.11.001-patched.tar.gz", + ) + version( + "2023.05.001", sha256="ec64be5d6522810d601a3b8e6a31720e3c3eb4af33a434d8a64570d76e6462b6" + ) + version( + "2022.11.001", sha256="75db3ac146f9a6a1598e3418ddcab2be2f40a30ef9ec4c00a3b5d3808c99c430" + ) + version( + "2021.11.001", sha256="fb361da6c59946661b73e51538d419028f763d7cb9dacf9d8cd5c9cd3fb7802f" + ) + version( + "2021.05.002_bugfix", + sha256="deabc48de5b9e4b2f073d749d335c8f354a7ce4245b643a23b7951cd6c90224b", + ) + version( + "2021.05.001", sha256="a4f1a4e3964f2473a5f8177f2091a9da5c6b5ef9280b8272dfefcbc3aad44d41" + ) + + variant("openmp", default=True, description="Activates OpenMP support") + variant("mpi", default=True, description="Activates MPI support") + + with when("@2021.11.001:"): + variant( + "autotune", default=False, description="Enables autotuning for matrix restribution" + ) + variant( + "gpu_streams", default=True, when="+cuda", description="Activates GPU streams support" + ) + variant( + "gpu_streams", default=True, when="+rocm", description="Activates GPU streams support" + ) + + patch("fujitsu.patch", when="%fj") + # wrong filename handling in elpa's custom preprocessor + patch( + "https://gitlab.mpcdf.mpg.de/elpa/elpa/-/commit/5a821b79dd2905c691fc0973c9f3044904ac2653.diff", + sha256="90f18c84e740a35d726e44078a111fac3b6278a0e750ce1f3ea154ee78e93298", + when="@:2025.01.001", + ) + patch("hipcc.patch", when="+rocm @2025.01.001:2025.06.001") + patch("0001-add-cpp17-flag.patch", when="+cuda %nvhpc") + + depends_on("c", type="build") # generated + depends_on("cxx", type="build") # generated + depends_on("fortran", type="build") # generated + + depends_on("autoconf@2.71:", type="build", when="@master") + depends_on("automake", type="build", when="@master") + + depends_on("blas") + depends_on("lapack") + depends_on("mpi", when="+mpi") + depends_on("scalapack", when="+mpi") + depends_on("rocblas", when="+rocm") + # elpa 2024.05.001 enables rocsolver by default + # https://github.com/marekandreas/elpa/commit/de90ce3d634be468e71c2827d788de52ceb606bf#diff-49473dca262eeab3b4a43002adb08b4db31020d190caaad1594b47f1d5daa810R2635-R2638 + depends_on("rocsolver", when="+rocm @2024.05.001:") + depends_on("libtool", type="build") + depends_on("python@3:", type="build") + depends_on("scalapack", when="+autotune") + + # Force openmp propagation on some providers of blas/lapack, as adviced by docs + # https://gitlab.mpcdf.mpg.de/elpa/elpa/-/blob/master/documentation/PERFORMANCE_TUNING.md?ref_type=heads#builds-with-openmp-enabled + with when("+openmp"): + requires("^openblas threads=openmp", when="^[virtuals=blas,lapack] openblas") + requires( + "^intel-oneapi-mkl threads=openmp", when="^[virtuals=blas,lapack] intel-oneapi-mkl" + ) + + # fails to build due to broken type-bound procedures in OMP parallel regions + conflicts( + "+openmp", + when="@2021.05.001: %gcc@:7", + msg="ELPA-2021.05.001+ requires GCC-8+ for OpenMP support", + ) + conflicts("+mpi", when="+rocm @:2024", msg="ROCm support and MPI are not yet compatible") + conflicts( + "+gpu_streams", + when="@:2023.11.001-patched +openmp", + msg="GPU streams currently not supported in combination with OpenMP", + ) + + def url_for_version(self, version): + return "https://elpa.mpcdf.mpg.de/software/tarball-archive/Releases/{0}/elpa-{0}.tar.gz".format( + str(version) + ) + + # override default implementation which returns static lib + @property + def libs(self): + libname = "libelpa_openmp" if "+openmp" in self.spec else "libelpa" + return find_libraries(libname, root=self.prefix, shared=True, recursive=True) + + @property + def headers(self): + suffix = "_openmp" if self.spec.satisfies("+openmp") else "" + + # upstream sometimes adds tarball suffixes not part of the internal version + elpa_version = str(self.spec.version) + for vsuffix in ("_bugfix", "-patched"): + if elpa_version.endswith(vsuffix): # implementation of py3.9 removesuffix + elpa_version = elpa_version[: -len(vsuffix)] + + incdir = os.path.join( + self.spec.prefix.include, + "elpa{suffix}-{version}".format(suffix=suffix, version=elpa_version), + ) + + hlist = find_all_headers(incdir) + hlist.directories = [incdir] + return hlist + + build_directory = "spack-build" + # parallel = False + + def flag_handler(self, name, flags): + spec = self.spec + if name == "cflags": + if spec.satisfies("^[virtuals=c] gcc") or spec.satisfies("^[virtuals=c] aocc"): + flags.append("-O3") + if name == "fflags": + if spec.satisfies("^[virtuals=fortran] aocc"): + flags.append("-O3") + elif spec.satisfies("^[virtuals=fortran] gcc"): + flags.append("-O3 -ffree-line-length-none") + if spec.satisfies("+autotune"): + flags.append("-fallow-argument-mismatch") + elif spec.satisfies("^[virtuals=fortran] fj") and spec.satisfies("+openmp"): + flags.append("-Kparallel") + if name == "ldflags": + flags += [spec["blas"].libs.search_flags, spec["lapack"].libs.search_flags, "-lstdc++"] + flags += [spec["lapack"].libs.link_flags, spec["blas"].libs.link_flags] + if self.spec.satisfies("@2024.05.001,2025.01.001 %aocc"): + # fix an issue where main library and test suite containing duplicate symbols + flags.append("-Wl,--allow-multiple-definition") + + return (flags, None, None) + + def configure_args(self): + spec = self.spec + options = [] + nvccflags = [] + + options += self.with_or_without("mpi") + + + # New options use the "-kernels" suffix + kernels = "-kernels" if spec.satisfies("@2023.11:") else "" + + # TODO: --disable-sse-assembly, --enable-sparc64, --enable-neon-arch64 + # Don't include vsx; as of 2022.05 it fails (reported upstream). + # Altivec SSE intrinsics are used anyway. + simd_features = ["sse", "avx", "avx2", "avx512", "sve128", "sve256", "sve512"] + + for feature in simd_features: + msg = "--enable-{0}" if feature in spec.target else "--disable-{0}" + options.append(msg.format(feature + kernels)) + + if spec.target.family != "x86_64": + options.append("--disable-sse-assembly") + + if spec.satisfies("%aocc") or spec.satisfies("%fj"): + options.append("--disable-shared") + options.append("--enable-static") + + # If no features are found, enable the generic ones + if not any(f in spec.target for f in simd_features): + options.append("--enable-generic" + kernels) + + if spec.satisfies("%fj"): + options.append("--disable-Fortran2008-features") + options.append("--enable-FUGAKU") + + cuda_flag = "nvidia-gpu" + if spec.satisfies("+cuda"): + prefix = spec["cuda"].prefix + # Can't yet be changed to the new option --enable-nvidia-gpu-kernels + # https://github.com/marekandreas/elpa/issues/55 + options.append(f"--enable-{cuda_flag}") + options.append("--with-cuda-path={0}".format(prefix)) + options.append("--with-cuda-sdk-path={0}".format(prefix)) + + if spec.satisfies("+gpu_streams"): + options.append("--enable-gpu-streams=nvidia") + + cuda_arch = spec.variants["cuda_arch"].value[0] + + if cuda_arch != "none": + options.append( + "--with-{0}-compute-capability=sm_{1}".format(cuda_flag.upper(), cuda_arch) + ) + + if spec.satisfies("^cuda@13:"): + nvccflags += ["-std=c++17"] + + options.append(f"NVCCFLAGS={' '.join(nvccflags)}") + else: + options.append(f"--disable-{cuda_flag}" + kernels) + + if spec.satisfies("+rocm"): + # Can't yet be changed to the new option --enable-amd-gpu-kernels + # https://github.com/marekandreas/elpa/issues/55 + options.append("--enable-amd-gpu") + if spec.satisfies("@2025.01.001:"): + options.append( + "HIPCC={0} {1} {2}".format( + spec["hip"].hipcc, + spec["rocblas"].headers.include_flags, + spec["rocsolver"].headers.include_flags, + ) + ) + else: + options.append("CXX={0}".format(spec["hip"].hipcc)) + + if spec.satisfies("+gpu_streams"): + options.append("--enable-gpu-streams=amd") + + elif self.spec.satisfies("@2021.05.001:"): + options.append("--disable-amd-gpu" + kernels) + + options += self.enable_or_disable("openmp") + + if self.spec.satisfies("+mpi"): + options += [ + "CC={0}".format(spec["mpi"].mpicc), + "CXX={0}".format(spec["mpi"].mpicxx), + "FC={0}".format(spec["mpi"].mpifc), + "SCALAPACK_LDFLAGS={0}".format(spec["scalapack"].libs.joined()), + ] + + if self.spec.satisfies("+autotune"): + options.append("--enable-autotune-redistribute-matrix") + # --enable-autotune-redistribute-matrix requires --enable-scalapack-tests as well + options.append("--enable-scalapack-tests") + + options.append("--disable-silent-rules") + options.append("--without-threading-support-check-during-build") + options.append("--disable-c-tests") + options.append("--disable-cpp-tests") + options.append("--disable-Fortran-tests") + + return options diff --git a/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/0001-add-blas-libraries-to-target.patch b/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/0001-add-blas-libraries-to-target.patch new file mode 100644 index 000000000..095273f25 --- /dev/null +++ b/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/0001-add-blas-libraries-to-target.patch @@ -0,0 +1,28 @@ +From 42c723156d61a15e94b9f36b893f7992e6c49b60 Mon Sep 17 00:00:00 2001 +From: Simon Pintarelli +Date: Thu, 13 Mar 2025 10:34:21 +0100 +Subject: [PATCH] add blas libraries to target + +--- + CMakeLists.txt | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index d394cb469..e50bcbb32 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -462,9 +462,9 @@ if(NOT QE_LAPACK_INTERNAL) + unset(CMAKE_REQUIRED_LINK_OPTIONS) + endif() + if(LAPACK_FOUND) +- target_link_libraries(qe_lapack INTERFACE ${LAPACK_LIBRARIES}) ++ target_link_libraries(qe_lapack INTERFACE "${LAPACK_LIBRARIES};${BLAS_LIBRARIES}") + target_link_options(qe_lapack INTERFACE ${LAPACK_LINKER_FLAGS}) +- set(CMAKE_REQUIRED_LIBRARIES "${LAPACK_LINKER_FLAGS};${LAPACK_LIBRARIES}") ++ set(CMAKE_REQUIRED_LIBRARIES "${LAPACK_LINKER_FLAGS};${LAPACK_LIBRARIES};${BLAS_LIBRARIES}") + if(QE_ENABLE_OPENMP) + target_link_libraries(qe_lapack INTERFACE ${OpenMP_Fortran_LIBRARIES}) + list(APPEND CMAKE_REQUIRED_LIBRARIES "${OpenMP_Fortran_LIBRARIES}") +-- +2.48.1 + diff --git a/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/0001-disable-cuda-check-in-laxlib.patch b/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/0001-disable-cuda-check-in-laxlib.patch new file mode 100644 index 000000000..0754e13d0 --- /dev/null +++ b/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/0001-disable-cuda-check-in-laxlib.patch @@ -0,0 +1,53 @@ +From 3b29ced9a6d62176a125ca27a2246320b56f729f Mon Sep 17 00:00:00 2001 +From: Simon Pintarelli +Date: Mon, 1 Sep 2025 19:11:03 +0200 +Subject: [PATCH] disable cuda check in laxlib + +--- + LAXlib/CMakeLists.txt | 30 +++++++++++++++--------------- + 1 file changed, 15 insertions(+), 15 deletions(-) + +diff --git a/LAXlib/CMakeLists.txt b/LAXlib/CMakeLists.txt +index 12e6da2bc..71bab5c0e 100644 +--- a/LAXlib/CMakeLists.txt ++++ b/LAXlib/CMakeLists.txt +@@ -24,21 +24,21 @@ target_link_libraries(qe_lax + qe_utilx + qe_devxlib) + if(QE_ENABLE_CUDA) +- if(CMAKE_Fortran_COMPILER_ID MATCHES "PGI" OR CMAKE_Fortran_COMPILER_ID MATCHES "NVHPC") +- set(CMAKE_REQUIRED_LINK_OPTIONS "${CUDA_FLAG}lib=cusolver;-fortranlibs") +- check_function_exists(cusolverDnZhegvdx cusolverDnZhegvdx_FOUND) +- if (NOT cusolverDnZhegvdx_FOUND) +- unset(cusolverDnZhegvdx_FOUND CACHE) +- message(FATAL_ERROR "The version of CUDAToolkit chosen by the PGI/NVHPC compiler internally" +- " doesn't contain cusolverDnZhegvdx. cuSOLVER features used by LAXLib are" +- " only supported since CUDAToolkit 10.1 release. Use a newer compiler" +- " or select a newer CUDAToolkit internal to the PGI/NVHPC compiler.") +- endif() +- else() +- if(CUDAToolkit_VERSION VERSION_LESS 10.1) +- message(FATAL_ERROR "cuSOLVER for LAXLib is only supported from CUDA compiler 10.1") +- endif() +- endif() ++ # if(CMAKE_Fortran_COMPILER_ID MATCHES "PGI" OR CMAKE_Fortran_COMPILER_ID MATCHES "NVHPC") ++ # set(CMAKE_REQUIRED_LINK_OPTIONS "${CUDA_FLAG}lib=cusolver;-fortranlibs") ++ # check_function_exists(cusolverDnZhegvdx cusolverDnZhegvdx_FOUND) ++ # if (NOT cusolverDnZhegvdx_FOUND) ++ # unset(cusolverDnZhegvdx_FOUND CACHE) ++ # message(FATAL_ERROR "The version of CUDAToolkit chosen by the PGI/NVHPC compiler internally" ++ # " doesn't contain cusolverDnZhegvdx. cuSOLVER features used by LAXLib are" ++ # " only supported since CUDAToolkit 10.1 release. Use a newer compiler" ++ # " or select a newer CUDAToolkit internal to the PGI/NVHPC compiler.") ++ # endif() ++ # else() ++ # if(CUDAToolkit_VERSION VERSION_LESS 10.1) ++ # message(FATAL_ERROR "cuSOLVER for LAXLib is only supported from CUDA compiler 10.1") ++ # endif() ++ # endif() + target_link_libraries(qe_lax + PRIVATE + CUDA::cusolver +-- +2.51.0 + diff --git a/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/0001-natx-100.patch b/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/0001-natx-100.patch new file mode 100644 index 000000000..dc2e493ee --- /dev/null +++ b/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/0001-natx-100.patch @@ -0,0 +1,25 @@ +From ae1b131558ebd51f5eb6209d2fe685a7da272d09 Mon Sep 17 00:00:00 2001 +From: Simon Pintarelli +Date: Tue, 7 Apr 2026 18:13:50 +0200 +Subject: [PATCH] natx=100 + +--- + Modules/parameters.f90 | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Modules/parameters.f90 b/Modules/parameters.f90 +index 25a7b6e..d0419b0 100644 +--- a/Modules/parameters.f90 ++++ b/Modules/parameters.f90 +@@ -19,7 +19,7 @@ MODULE parameters + !! max number of different types of atom + INTEGER, PARAMETER :: nsx = ntypx + !! max number of atomic species (CP) +- INTEGER, PARAMETER :: natx = 50 ++ INTEGER, PARAMETER :: natx = 100 + !! max number of atoms for DFT+U+V calculations + INTEGER, PARAMETER :: sc_size = 1 + !! Defines the supercell in DFT+U+V as composed by the unit cells located +-- +2.53.0 + diff --git a/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/configure_aocc.patch b/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/configure_aocc.patch new file mode 100644 index 000000000..c7ef8c631 --- /dev/null +++ b/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/configure_aocc.patch @@ -0,0 +1,72 @@ +diff --git a/install/configure b/install/configure_aocc +index 66337d1..d2c04af 100755 +--- a/install/configure ++++ b/install/configure_aocc +@@ -3199,6 +3199,7 @@ + ifort_version=`$mpif90 -V 2>&1 | grep "Intel(R)"` + pgf_version=`$mpif90 -V 2>&1 | grep "^pgf"` + nvfortran_version=`$mpif90 -V 2>&1 | grep "^nvfortran"` ++ aoccflang_version=`$mpif90 -v 2>&1 | grep "AMD clang version"` + gfortran_version=`$mpif90 -v 2>&1 | grep "gcc version"` + nagfor_version=`$mpif90 -v 2>&1 | grep "NAG Fortran"` + xlf_version=`$mpif90 -v 2>&1 | grep "xlf"` +@@ -3215,6 +3216,12 @@ case "$arch" in + version=`echo $nvfortran_version | cut -d ' ' -f2` + echo "${ECHO_T}nvfortran $version" + f90_in_mpif90="nvfortran" ++ elif test "$aoccflang_version" != "" ++ then ++ version=`echo $aoccflang_version | cut -d" " -f 5` ++ echo "${ECHO_T}mpif90 $version" ++ f90_in_mpif90="mpif90" ++ try_foxflags="-D__PGI" + elif test "$pgf_version" != "" + then + version=`echo $pgf_version | cut -d ' ' -f2` +@@ -3397,6 +3404,9 @@ ppc64-bg*:*xlf90_r ) + ppc64-bg*:*xlf90 ) + try_cc="bgxlc" + ;; ++*:mpif90 ) ++ try_cc="mpicc $try_cc" ++ ;; + ppc64:*xlf* | ppc64le:*xlf* ) + try_cc="xlc_r $try_cc" + ;; +@@ -3779,6 +3789,10 @@ necsx:* ) + ppc64le:* ) + try_cflags="-O3" + ;; ++x86_64:* ) ++ try_cflags=" -Mstack_arrays" ++ try_dflags="-D__OPENMP" ++ ;; + ppc64-bg:* ) + try_cflags="-O3 -q32" + ;; +@@ -3915,6 +3929,16 @@ crayxt*:cray* ) + try_dflags="$try_dflags -D__CRAY" + have_cpp=0 + ;; ++*:*mpif90 ) ++ try_fflags="-Mstack_arrays" ++ try_fflags_openmp="-fopenmp" ++ try_f90flags=" \$(FFLAGS) -cpp -Mpreprocess -Mstack_arrays" ++ try_foxflags="-D__PGI" ++ try_fflags_noopt="-O0" ++ try_ldflags="" ++ try_ldflags_openmp="-fopenmp" ++ try_ldflags_static="-static" ++ ;; + crayxt*:pgf* ) + # see comment above for pgf* + try_fflags_nomain="-Mnomain" +@@ -7815,7 +7839,7 @@ $as_echo "$as_me: WARNING: *** HDF5 version must be 1.8.16 or later" >&2;}; + if test $with_hdf5_libs -eq 1; then + hdf5_libs=$with_hdf5_libline + else +- hdf5_libs=`$with_hdf5_path/bin/h5pfc -show | awk -F'-L' '{$1=""; for (i=2; i<=NF;i++) $i="-L"$i; print $0}'` ++ hdf5_libs=`$with_hdf5_path/bin/h5pfc -show | awk -F'-L' '{$1=""; for (i=2; i<=NF;i++) $i="-L"$i; print $0}' | xargs` + fi + elif command -v h5pfc >/dev/null; then + if test $with_hdf5_libs -eq 1; then diff --git a/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/dspev_drv_elpa.patch b/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/dspev_drv_elpa.patch new file mode 100644 index 000000000..153bcf2ef --- /dev/null +++ b/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/dspev_drv_elpa.patch @@ -0,0 +1,42 @@ +diff -ruN LAXlib-orig/dspev_drv.f90 LAXlib/dspev_drv.f90 +--- a/LAXlib/dspev_drv.f90 2017-06-12 15:00:46.157372185 +0200 ++++ b/LAXlib/dspev_drv.f90 2017-06-12 15:01:19.937371580 +0200 +@@ -708,11 +708,11 @@ + + #if defined(__ELPA_2016) + ! -> ELPA 2016.11.001_pre +- ierr = elpa_get_communicators(ortho_comm, my_prow, my_pcol,mpi_comm_rows, mpi_comm_cols) +- success = solve_evp_real_1stage(n, n, s, lds, w, vv, lds,SIZE(s,2),nb ,mpi_comm_rows, mpi_comm_cols, ortho_comm) ++ !ierr = elpa_get_communicators(ortho_comm, my_prow, my_pcol,mpi_comm_rows, mpi_comm_cols) ++ !success = solve_evp_real_1stage(n, n, s, lds, w, vv, lds,SIZE(s,2),nb ,mpi_comm_rows, mpi_comm_cols, ortho_comm) + ! -> ELPA 2016.05.003 +- !ierr = get_elpa_row_col_comms(ortho_comm, my_prow, my_pcol,mpi_comm_rows, mpi_comm_cols) +- !success = solve_evp_real_1stage(n, n, s, lds, w, vv, lds,SIZE(s,2),nb ,mpi_comm_rows, mpi_comm_cols) ++ ierr = get_elpa_row_col_comms(ortho_comm, my_prow, my_pcol,mpi_comm_rows, mpi_comm_cols) ++ success = solve_evp_real_1stage(n, n, s, lds, w, vv, lds,SIZE(s,2),nb ,mpi_comm_rows, mpi_comm_cols) + #elif defined(__ELPA_2015) + ierr = get_elpa_row_col_comms(ortho_comm, my_prow, my_pcol,mpi_comm_rows, mpi_comm_cols) + ierr = solve_evp_real(n, n, s, lds, w, vv, lds,SIZE(s,2),nb ,mpi_comm_rows, mpi_comm_cols) +diff -ruN LAXlib-orig/zhpev_drv.f90 LAXlib/zhpev_drv.f90 +--- a/LAXlib/zhpev_drv.f90 2017-06-12 15:00:46.157372185 +0200 ++++ b/LAXlib/zhpev_drv.f90 2017-06-12 15:02:09.309370696 +0200 +@@ -1519,13 +1519,13 @@ + + #if defined(__ELPA_2016) + ! -> ELPA 2016.11.001_pre +- ierr = elpa_get_communicators(ortho_comm, my_prow, my_pcol,mpi_comm_rows, mpi_comm_cols) +- success = solve_evp_complex_1stage_double(n, n, h, size(h,1), w, v, size(h,1), size(h,2), nb, & +- mpi_comm_rows, mpi_comm_cols, ortho_comm) ++ !ierr = elpa_get_communicators(ortho_comm, my_prow, my_pcol,mpi_comm_rows, mpi_comm_cols) ++ !success = solve_evp_complex_1stage_double(n, n, h, size(h,1), w, v, size(h,1), size(h,2), nb, & ++ ! mpi_comm_rows, mpi_comm_cols, ortho_comm) + ! -> ELPA 2016.05.003 +- !ierr = get_elpa_row_col_comms(ortho_comm, my_prow, my_pcol,mpi_comm_rows, mpi_comm_cols) +- !success = solve_evp_complex(n, n, h, size(h,1), w, v, size(h,1), size(h,2), nb, & +- ! mpi_comm_rows, mpi_comm_cols) ++ ierr = get_elpa_row_col_comms(ortho_comm, my_prow, my_pcol,mpi_comm_rows, mpi_comm_cols) ++ success = solve_evp_complex(n, n, h, size(h,1), w, v, size(h,1), size(h,2), nb, & ++ mpi_comm_rows, mpi_comm_cols) + #elif defined(__ELPA_2015) + ierr = get_elpa_row_col_comms(ortho_comm, my_prow, my_pcol,mpi_comm_rows, mpi_comm_cols) + ierr = solve_evp_complex(n, n, h, size(h,1), w, v, size(h,1), size(h,2), nb, & diff --git a/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/fj-fox.patch b/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/fj-fox.patch new file mode 100644 index 000000000..d4fb79ab2 --- /dev/null +++ b/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/fj-fox.patch @@ -0,0 +1,10 @@ +--- spack-src/install/extlibs_makefile.org 2021-01-22 10:11:00.527343202 +0900 ++++ spack-src/install/extlibs_makefile 2021-01-22 10:15:24.319956918 +0900 +@@ -89,6 +89,7 @@ + mkdir ../FoX; \ + (gzip -dc ../archive/fox.tgz | (cd ../FoX; tar -xvf -)); \ + cd ../FoX/fox/; export FC=$(F90); export FCFLAGS="$(FOX_FLAGS)"; \ ++ sed -i 's/"-out " "-o "/"-o " "-out "/' configure; \ + ./configure --prefix=$(TOPDIR)/FoX ;\ + $(MAKE) install; cd ../; rm -fr fox;fi + # ELPA diff --git a/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/fj-intent.6.4.1.patch b/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/fj-intent.6.4.1.patch new file mode 100644 index 000000000..7266a9b56 --- /dev/null +++ b/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/fj-intent.6.4.1.patch @@ -0,0 +1,11 @@ +--- spack-src/PHonon/Gamma/dgradcorr.f90.org 2021-01-27 16:41:04.692204340 +0900 ++++ spack-src/PHonon/Gamma/dgradcorr.f90 2021-01-27 16:44:03.877839298 +0900 +@@ -22,7 +22,7 @@ + + REAL(DP), INTENT(IN) :: rho (dfft%nnr, nspin), grho (3, dfft%nnr, nspin), & + g (3, dfft%ngm) +- REAL(DP), INTENT(OUT):: drho (dfft%nnr,nspin),& ++ REAL(DP), INTENT(IN):: drho (dfft%nnr,nspin),& + dvxc_rr(dfft%nnr, nspin, nspin), dvxc_sr (dfft%nnr, nspin, nspin), & + dvxc_ss (dfft%nnr,nspin, nspin), dvxc_s (dfft%nnr, nspin, nspin) + REAL(DP), INTENT(INOUT) :: dvxc (dfft%nnr, nspin) diff --git a/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/fj.6.5.patch b/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/fj.6.5.patch new file mode 100644 index 000000000..503a0e9ec --- /dev/null +++ b/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/fj.6.5.patch @@ -0,0 +1,23 @@ +--- spack-src/install/configure.org 2021-01-22 12:21:20.196915072 +0900 ++++ spack-src/install/configure 2021-01-22 12:24:47.562530103 +0900 +@@ -3127,6 +3127,7 @@ + pgf_version=`$mpif90 -V 2>&1 | grep "^pgf"` + gfortran_version=`$mpif90 -v 2>&1 | grep "gcc version"` + nagfor_version=`$mpif90 -v 2>&1 | grep "NAG Fortran"` ++ frt_version=`$mpif90 -v 2>&1 | grep "Fujitsu Fortran Compiler"` + xlf_version=`$mpif90 -v 2>&1 | grep "xlf"` + # + if test "$ifort_version" != "" +@@ -3160,6 +3161,12 @@ + echo "${ECHO_T}xlf (version unknonw)" + f90_in_mpif90="xlf" + try_dflags="-D__XLF" ++ elif test "$frt_version" != "" ++ then ++ version=`echo $frt_version | cut -d" " -f 5` ++ echo "${ECHO_T}frt $version" ++ f90_in_mpif90="frt" ++ try_foxflags="-D__FUJITSU" + else + echo "${ECHO_T}unknown, assuming gfortran" + f90_in_mpif90="gfortran" diff --git a/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/fj.6.6.patch b/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/fj.6.6.patch new file mode 100644 index 000000000..7b2db5d8d --- /dev/null +++ b/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/fj.6.6.patch @@ -0,0 +1,23 @@ +--- spack-src/install/configure.org 2021-01-15 09:27:53.000000000 +0900 ++++ spack-src/install/configure 2021-01-15 09:26:53.000000000 +0900 +@@ -3200,6 +3200,7 @@ + nagfor_version=`$mpif90 -v 2>&1 | grep "NAG Fortran"` + xlf_version=`$mpif90 -v 2>&1 | grep "xlf"` + armflang_version=`$mpif90 -v 2>&1 | grep "Arm C/C++/Fortran Compiler version"` ++ frt_version=`$mpif90 -v 2>&1 | grep "Fujitsu Fortran Compiler"` + # + if test "$ifort_version" != "" + then +@@ -3237,6 +3238,12 @@ + f90_minor_version=`echo $version | cut -d. -f2` + f90_in_mpif90="armflang" + try_foxflags="-D__PGI" ++ elif test "$frt_version" != "" ++ then ++ version=`echo $frt_version | cut -d" " -f 5` ++ echo "${ECHO_T}frt $version" ++ f90_in_mpif90="frt" ++ try_foxflags="-D__FUJITSU" + else + echo "${ECHO_T}unknown, assuming gfortran" + f90_in_mpif90="gfortran" diff --git a/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/gipaw-eccee44.patch b/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/gipaw-eccee44.patch new file mode 100644 index 000000000..e2d817901 --- /dev/null +++ b/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/gipaw-eccee44.patch @@ -0,0 +1,8 @@ +--- spack-src/external/submodule_commit_hash_records.org 2023-11-15 18:38:47.485317449 -0300 ++++ spack-src/external/submodule_commit_hash_records 2023-11-15 18:39:02.661861757 -0300 +@@ -5,4 +5,4 @@ + 82005cbb65bdf5d32ca021848eec8f19da956a77 mbd + f72ab25fa4ea755c1b4b230ae8074b47d5509c70 pw2qmcpack + 1d6b187374a2d50b509e5e79e2cab01a79ff7ce1 wannier90 +-f5823521ad8fdd8b8e9e29197eedb354f9b9146d qe-gipaw ++eccee44d3caf1c930fb72ad9c741fbb743eabf45 qe-gipaw diff --git a/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/nvhpc.patch b/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/nvhpc.patch new file mode 100644 index 000000000..9b5714e60 --- /dev/null +++ b/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/nvhpc.patch @@ -0,0 +1,106 @@ +--- a/install/configure 2020-09-08 07:25:53.088725750 -0700 ++++ b/install/configure 2020-09-08 07:35:22.637773050 -0700 +@@ -2349,7 +2349,7 @@ + ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5' + ac_compiler_gnu=$ac_cv_fc_compiler_gnu + if test -n "$ac_tool_prefix"; then +- for ac_prog in gfortran g95 xlf95 f95 fort ifort ifc efc pgfortran pgf95 lf95 ftn nagfor xlf90 f90 pgf90 pghpf epcf90 g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77 ++ for ac_prog in gfortran g95 xlf95 f95 fort ifort ifc efc nvfortran pgfortran pgf95 lf95 ftn nagfor xlf90 f90 pgf90 pghpf epcf90 g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77 + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. + set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +@@ -2393,7 +2393,7 @@ + fi + if test -z "$FC"; then + ac_ct_FC=$FC +- for ac_prog in gfortran g95 xlf95 f95 fort ifort ifc efc pgfortran pgf95 lf95 ftn nagfor xlf90 f90 pgf90 pghpf epcf90 g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77 ++ for ac_prog in gfortran g95 xlf95 f95 fort ifort ifc efc nvfortran pgfortran pgf95 lf95 ftn nagfor xlf90 f90 pgf90 pghpf epcf90 g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77 + do + # Extract the first word of "$ac_prog", so it can be a program name with args. + set dummy $ac_prog; ac_word=$2 +@@ -2810,7 +2810,7 @@ + # candidate compilers and flags based on architecture + case $arch in + ia32 | ia64 | x86_64 ) +- try_f90="ifort pgf90 nagfor $try_f90" ++ try_f90="ifort nvfortran pgf90 nagfor $try_f90" + ;; + arm ) + try_f90="$try_f90" +@@ -3125,6 +3125,7 @@ + echo $ECHO_N "checking version of $mpif90... $ECHO_C" + ifort_version=`$mpif90 -V 2>&1 | grep "Intel(R)"` + pgf_version=`$mpif90 -V 2>&1 | grep "^pgf"` ++ nvfortran_version=`$mpif90 -V 2>&1 | grep "^nvfortran"` + gfortran_version=`$mpif90 -v 2>&1 | grep "gcc version"` + nagfor_version=`$mpif90 -v 2>&1 | grep "NAG Fortran"` + xlf_version=`$mpif90 -v 2>&1 | grep "xlf"` +@@ -3142,6 +3143,11 @@ + f90_in_mpif90="pgf90" + # flag to test MKL with PGI + MKL_FLAGS="-pgf90libs" ++ elif test "$nvfortran_version" != "" ++ then ++ version=`echo $nvfortran_version | cut -d ' ' -f2` ++ echo "${ECHO_T}nvfortran $version" ++ f90_in_mpif90="nvfortran" + elif test "$gfortran_version" != "" + then + version=`echo $gfortran_version | cut -d ' ' -f3` +@@ -3242,6 +3250,8 @@ + f90_flavor=ifort + elif $f90 -V 2>&1 | grep -q "^pgf" ; then + f90_flavor=pgf ++ elif $f90 -V 2>&1 | grep -q "^nvfortran" ; then ++ f90_flavor=nvfortran + elif $f90 -v 2>&1 | grep -q "gcc version" ; then + f90_flavor=gfortran + elif $f90 -V 2>&1 | grep -q "Cray Fortran" ; then +@@ -3300,6 +3310,9 @@ + *:pgf90 ) + try_cc="pgcc $try_cc" + ;; ++*:nvfortran ) ++ try_cc="nvc $try_cc" ++ ;; + cray*:* ) + try_cc="cc" + ;; +@@ -4166,6 +4179,19 @@ + try_dflags="$try_dflags -D__PGI" + have_cpp=1 + ;; ++*:nvfortran* ) ++ try_fflags_nomain="-Mnomain" ++ try_fflags="-fast" ++ try_fflags_openmp="-mp" ++ try_f90flags="-fast -Mcache_align -Mpreprocess -Mlarge_arrays" ++ try_foxflags="-fast -Mcache_align -Mpreprocess -Mlarge_arrays" ++ try_fflags_noopt="-O0" ++ try_ldflags="" ++ try_ldflags_openmp="-mp" ++ try_ldflags_static="-static" ++ try_dflags="$try_dflags -D__PGI" ++ have_cpp=1 ++ ;; + *:*gfortran ) + try_fflags="-O3 -g" + if test "$use_debug" -eq 1; then +@@ -5044,7 +5070,7 @@ + done + ;; + +- x86_64:pgf* ) ++ x86_64:pgf* | x8_64:nvfortran ) + try_libdirs="/opt/acml*/pathscale64/lib/" + try_libdirs="$ld_library_path $libdirs $try_libdirs" + +@@ -6245,7 +6271,7 @@ + if test "$have_blas" -eq 0 + then + case "$f90" in +- pgf* ) ++ pgf* | nvfortran ) + # check for PGI blas + unset ac_cv_search_dgemm # clear cached value + FFLAGS="$test_fflags" diff --git a/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/package.py b/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/package.py new file mode 100644 index 000000000..643d1ce65 --- /dev/null +++ b/recipes/quantumespresso/v7.5/repo/packages/quantum_espresso/package.py @@ -0,0 +1,721 @@ +# Copyright Spack Project Developers. See COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) +from spack_repo.builtin.build_systems import cmake, generic +from spack_repo.builtin.build_systems.cmake import CMakePackage +from spack_repo.builtin.build_systems.generic import Package + +from spack.package import * + + +class QuantumEspresso(CMakePackage, Package): + """Quantum ESPRESSO is an integrated suite of Open-Source computer codes + for electronic-structure calculations and materials modeling at the + nanoscale. It is based on density-functional theory, plane waves, and + pseudopotentials. + """ + + homepage = "https://quantum-espresso.org" + url = "https://gitlab.com/QEF/q-e/-/archive/qe-6.6/q-e-qe-6.6.tar.gz" + git = "https://gitlab.com/QEF/q-e.git" + + maintainers("ye-luo", "bellenlau", "tgorni") + + build_system(conditional("cmake", when="@6.8:"), "generic", default="cmake") + + license("GPL-2.0-only") + + version("develop", branch="develop") + version("7.5", sha256="7e1f7a9a21b63192f5135218bee20a5321b66582e4756536681b76e9c59b3cc8") + version("7.4.1", sha256="6ef9c53dbf0add2a5bf5ad2a372c0bff935ad56c4472baa001003e4f932cab97") + version("7.4", sha256="b15dcfe25f4fbf15ccd34c1194021e90996393478226e601d876f7dea481d104") + version("7.3.1", sha256="2c58b8fadfe4177de5a8b69eba447db5e623420b070dea6fd26c1533b081d844") + version("7.3", sha256="edc2a0f3315c69966df4f82ec86ab9f682187bc9430ef6d2bacad5f27f08972c") + version("7.2", sha256="b348a4a7348b66a73545d9ca317a2645755c98d343c1cfe8def475ad030808c0") + version("7.1", sha256="d56dea096635808843bd5a9be2dee3d1f60407c01dbeeda03f8256a3bcfc4eb6") + version("7.0", sha256="85beceb1aaa1678a49e774c085866d4612d9d64108e0ac49b23152c8622880ee") + version("6.8", sha256="654855c69864de7ece5ef2f2c0dea2d32698fe51192a8646b1555b0c57e033b2") + version( + "6.7", + sha256="fe0ce74ff736b10d2a20c9d59025c01f88f86b00d229c123b1791f1edd7b4315", + url="https://gitlab.com/QEF/q-e/-/archive/qe-6.7MaX-Release/q-e-qe-6.7MaX-Release.tar.gz", + ) + version("6.6", sha256="924656cb083f52e5d2fe71ade05881389dac64b45316f1bdd6dee1c6170a672c") + version("6.5", sha256="258b2a8a6280e86dad779e5c56356d8b35dc96d12ff33dabeee914bc03d6d602") + version("6.4.1", sha256="b0d7e9f617b848753ad923d8c6ca5490d5d82495f82b032b71a0ff2f2e9cfa08") + version("6.4", sha256="781366d03da75516fdcf9100a1caadb26ccdd1dedd942a6f8595ff0edca74bfe") + version("6.3", sha256="4067c8fffa957aabbd5cf2439e2fcb6cf3752325393c67a17d99fd09edf8689c") + version("6.2.1", sha256="11fe24b4a9d85834f8b6d429baebed8b360a685ecfae222887ed451e118a9156") + version("6.2.0", sha256="e204df367c8ea1a50c7534b44481841d835a542a23ae71c3e33ad712fc636c8b") + version("6.1.0", sha256="fd2c2eb346b3ca8f08138df5ef3f69b466c256d2119db40eea1b578b0a42c66e") + version("6.0.0", sha256="bc77d9553bf5a9253ae74058dffb1d6e5fb61093188e78d3b8d8564755136f19") + version("5.4", sha256="e3993fccae9cea04a5c6492e8b961a053a63727051cb5c4eb6008f62cda8f335") + version("5.3", sha256="3b26038efb9e3f8ac7a2b950c31d8c29169a3556c0b68c299eb88a4be8dc9048") + + depends_on("c", type="build") # generated + depends_on("cxx", type="build") # generated + depends_on("fortran", type="build") # generated + depends_on("gmake", type="build") + + resource( + name="environ", + git="https://github.com/environ-developers/Environ.git", + tag="v1.1", + when="@6.3:6.4 +environ", + destination=".", + ) + + resource( + name="environ", + git="https://github.com/environ-developers/Environ.git", + tag="v1.0", + when="@6.2.1:6.2 +environ", + destination=".", + ) + + with when("build_system=cmake"): + depends_on("cmake@3.14.0:", type="build") + + variant("libxc", default=False, description="Uses libxc") + depends_on("libxc", when="+libxc") + depends_on("libxc@5.1.2:~shared", when="@:7.5+libxc") + + variant("openmp", default=True, description="Enables OpenMP support") + # Need OpenMP threaded FFTW and BLAS libraries when configured + # with OpenMP support + with when("+openmp"): + requires("^fftw+openmp", when="^[virtuals=fftw-api] fftw") + requires("^amdfftw+openmp", when="^[virtuals=fftw-api] amdfftw") + requires("^openblas threads=openmp", when="^[virtuals=blas] openblas") + requires("^amdblis threads=openmp", when="^[virtuals=blas] amdblis") + requires("^intel-oneapi-mkl threads=openmp", when="^[virtuals=blas] intel-oneapi-mkl") + requires("^armpl-gcc threads=openmp", when="^[virtuals=blas] armpl-gcc") + requires("^acfl threads=openmp", when="^[virtuals=blas] acfl") + + # Add Cuda Fortran support + # depends on NVHPC compiler, not directly on CUDA toolkit + with when("%nvhpc"): + variant("cuda", default=False, description="Build with CUDA Fortran") + with when("+cuda"): + # GPUs are enabled since v6.6 + conflicts("@:6.5") + # cuda version >= 10.1 + # conflicts("cuda@:10.0.130") + # bugs with following nvhpcsdk versions and +openmp + with when("+openmp"): + conflicts( + "%nvhpc@21.11:22.3", + msg="bugs with NVHPCSDK from v21.11 to v22.3, OpenMP and GPU", + ) + # only cmake is supported + conflicts("build_system=generic", msg="Only CMake supported for GPU-enabled version") + + # NVTX variant for profiling + # requires linking to CUDA runtime APIs , handled by CMake + variant("nvtx", default=False, description="Enables NVTX markers for profiling") + variant("trace", default=False, description="enable execution tracing output") + with when("+nvtx~cuda"): + depends_on("cuda") + + # CLOCK variant to display program time in seconds + variant("clock", default=False, description="Display program time in seconds") + variant("oscdft", default=False, description="Enable OSCDFT") + + # Apply upstream patches by default. Variant useful for 3rd party + # patches which are incompatible with upstream patches + desc = "Apply recommended upstream patches. May need to be set " + desc = desc + "to False for third party patches or plugins" + variant("patch", default=True, description=desc) + + variant("mpi", default=True, description="Builds with mpi support") + with when("+mpi"): + depends_on("mpi") + variant("scalapack", default=True, description="Enables scalapack support") + with when("+cuda%nvhpc"): + # add mpi_gpu_aware variant, False by default + variant("mpigpu", default=False, description="Enables GPU-aware MPI operations") + + with when("+scalapack"): + depends_on("scalapack") + variant("elpa", default=False, description="Uses elpa as an eigenvalue solver") + + with when("+elpa"): + # CMake builds only support elpa without openmp + depends_on("elpa~openmp", when="build_system=cmake") + with when("build_system=generic"): + depends_on("elpa", when="+openmp") + depends_on("elpa~openmp", when="~openmp") + # Elpa is formally supported by @:5.4.0, but QE configure searches + # for it in the wrong folders (or tries to download it within + # the build directory). Instead of patching Elpa to provide the + # folder QE expects as a link, we issue a conflict here. + conflicts("@:5.4.0", msg="+elpa requires QE >= 6.0") + + variant("fox", default=False, description="Enables FoX library") + with when("+fox"): + conflicts("@:7.1", msg="+fox variant requires QE >= 7.2") + + # Support for HDF5 has been added starting in version 6.1.0 and is + # still experimental, therefore we default to False for the variant + variant( + "hdf5", + default="none", + description="Orbital and density data I/O with HDF5", + values=("parallel", "serial", "none"), + multi=False, + ) + + variant("wannier90_external", default=False, description="Enable external wannier90") + depends_on("wannier90", when="+wannier90_external") + + # Versions of HDF5 prior to 1.8.16 lead to QE runtime errors + depends_on("hdf5@1.8.16:+fortran+hl+mpi", when="hdf5=parallel") + depends_on("hdf5@1.8.16:+fortran+hl~mpi", when="hdf5=serial") + + # HDF5 support introduced in 6.1.0, but the configure had some limitations. + # In recent tests (Oct 2019), GCC and Intel work with the HDF5 Spack + # package for the default variant. This is only for hdf5=parallel variant. + # Support, for hdf5=serial was introduced in 6.4.1 but required a patch + # for the serial (no MPI) case. This patch was to work around an issue + # that only manifested itself inside the Spack environment. + conflicts( + "hdf5=parallel", when="@:6.0", msg="parallel HDF5 support only in QE 6.1.0 and later" + ) + + conflicts("hdf5=serial", when="@:6.4.0", msg="serial HDF5 support only in QE 6.4.1 and later") + + conflicts("hdf5=parallel", when="~mpi", msg="parallel HDF5 requires MPI support") + + # QMCPACK converter patch + # https://github.com/QMCPACK/qmcpack/tree/develop/external_codes/quantum_espresso + variant("qmcpack", default=False, description="Build QE-to-QMCPACK wave function converter") + + with when("+qmcpack"): + # Some QMCPACK converters are incompatible with upstream patches. + # HDF5 is a hard requirement. Need to do two HDF5 cases explicitly + # since Spack lacks support for expressing NOT operation. + conflicts( + "@6.4+patch", + msg="QE-to-QMCPACK wave function converter requires " + "deactivatation of upstream patches", + ) + conflicts( + "@6.3:6.4.0 hdf5=serial", + msg="QE-to-QMCPACK wave function converter only " "supported with parallel HDF5", + ) + conflicts("@:7.0 hdf5=none", msg="QE-to-QMCPACK wave function converter requires HDF5") + # QE > 7.0, the converter for QMCPACK can be built without hdf5 enabled in QE. + # The converter for QMCPACK itself still needs hdf5 library + with when("@7.0.1:"): + # when QE doesn't use hdf5 library, the converter plugin still needs it + depends_on("hdf5@1.8.16:+hl~mpi", when="hdf5=none") + conflicts( + "build_system=generic", msg="QE-to-QMCPACK wave function converter requires cmake" + ) + + # Enables building Electron-phonon Wannier 'epw.x' executable + # http://epw.org.uk/Main/About + variant("epw", default=True, description="Builds Electron-phonon Wannier executable") + conflicts("~epw", when="build_system=cmake", msg="epw cannot be turned off when using CMake") + + with when("+epw"): + # The first version of Q-E to feature integrated EPW is 6.0.0, + # as per http://epw.org.uk/Main/DownloadAndInstall . + # Complain if trying to install a version older than this. + conflicts("@:5", msg="EPW only available from version 6.0.0 and on") + + # Below goes some constraints as shown in the link above. + # Constraints may be relaxed as successful reports + # of different compiler+mpi combinations arrive + + # TODO: enable building EPW when ~mpi and build_system=generic + conflicts( + "~mpi", when="build_system=generic", msg="EPW needs MPI when build_system=generic" + ) + + # EPW doesn't gets along well with OpenMPI 2.x.x + conflicts("^openmpi@2.0.0:2", msg="OpenMPI version incompatible with EPW") + + variant( + "environ", + default=False, + when="build_system=generic", + description="Enables support for introducing environment effects " + "into atomistic first-principles simulations." + "See http://quantum-environ.org/about.html", + ) + + variant( + "gipaw", + default=False, + description="Builds Gauge-Including Projector Augmented-Waves executable", + ) + + # Dependencies not affected by variants + depends_on("blas") + depends_on("lapack") + depends_on("fftw-api@3") + depends_on("git@2.13:", type="build") + depends_on("m4", type="build") + + # 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") + + # CONFLICTS SECTION + # Omitted for now due to concretizer bug + # MKL with 64-bit integers not supported. + # conflicts( + # '^mkl+ilp64', + # msg='Quantum ESPRESSO does not support MKL 64-bit integer variant' + # ) + + # PATCHES SECTION + # THIRD-PARTY PATCHES + # NOTE: *SOME* third-party patches will require deactivation of + # upstream patches using `~patch` variant + + # gipaw + conflicts( + "@:6.2", + when="+gipaw", + msg="gipaw standard support available for QE 6.3 or greater version only", + ) + conflicts("~fox", when="@7.2: +gipaw", msg="gipaw plugin requires FoX") + conflicts("+gipaw build_system=cmake", when="@:7.1") + + # Only CMake will work for @6.8: %aocc + conflicts( + "build_system=generic", when="@6.8: %aocc", msg="Please use CMake to build with AOCC" + ) + + conflicts("~openmp", when="^amdlibflame", msg="amdlibflame requires OpenMP") + + # QMCPACK converter patches for QE 6.8, 6.7, 6.4.1, 6.4, and 6.3 + conflicts( + "@:6.2,6.5:6.6", + when="+qmcpack", + msg="QMCPACK converter NOT available for this version of QE", + ) + + # Internal compiler error gcc8 and a64fx, I check only 6.5 and 6.6 + conflicts( + "@5.3:", when="target=a64fx %gcc@8", msg="Internal compiler error with gcc8 and a64fx" + ) + + conflicts("@6.5:", when="+environ", msg="6.4.x is the latest QE series supported by Environ") + + conflicts( + "@:7.3.0", + when="build_system=generic %oneapi", + msg="Support for ifx has been added to configure in release 7.3.1", + ) + # Fixed in https://github.com/libmbd/libmbd/pull/60, which will be part of the next release + conflicts( + "@7.3.1", + when="%oneapi@2024.1:", + msg="ifx added f_c_string in the ISO_C_BINDING module since version 2024.1 which conflicts" + + "with the libmbd provided one.", + ) + + # 7.3 - a compile-time problem fixed in 7.3.1 + patch_url = "https://gitlab.com/QEF/q-e/-/commit/b98ff7539e5731728d2d49ac01021a57f2594027.diff" + patch_checksum = "04c125d249d1f076abe04bc4de39bd3b44a41a78d6233b638a17bd96f91443d5" + patch(patch_url, sha256=patch_checksum, when="@=7.3+elpa build_system=cmake") + + # QE 7.1 fix post-processing install part 1/2 + # see: https://gitlab.com/QEF/q-e/-/merge_requests/2005 + patch_url = "https://gitlab.com/QEF/q-e/-/commit/4ca3afd4c6f27afcf3f42415a85a353a7be1bd37.diff" + patch_checksum = "e54d33e36a2667bd1d7e358db9fa9d4d83085264cdd47e39ce88754452ae7700" + patch(patch_url, sha256=patch_checksum, when="@7.1 build_system=cmake") + + # QE 7.1 fix post-processing install part 2/2 + # see: https://gitlab.com/QEF/q-e/-/merge_requests/2007 + patch_url = "https://gitlab.com/QEF/q-e/-/commit/481a001293de2f9eec8481e02d64f679ffd83ede.diff" + patch_checksum = "5075f2df61ef5ff70f2ec3b52a113f5636fb07f5d3d4c0115931f9b95ed61c3e" + patch(patch_url, sha256=patch_checksum, when="@7.1 build_system=cmake") + + # No patch needed for QMCPACK converter beyond 7.0 + # 7.0 + patch_url = "https://raw.githubusercontent.com/QMCPACK/qmcpack/v3.13.0/external_codes/quantum_espresso/add_pw2qmcpack_to_qe-7.0.diff" + patch_checksum = "ef60641d8b953b4ba21d9c662b172611305bb63786996ad6e81e7609891677ff" + patch(patch_url, sha256=patch_checksum, when="@7.0+qmcpack") + + # 6.8 + patch_url = "https://raw.githubusercontent.com/QMCPACK/qmcpack/v3.13.0/external_codes/quantum_espresso/add_pw2qmcpack_to_qe-6.8.diff" + patch_checksum = "69f7fbd72aba810c35a0b034188e45bea8f9f11d3150c0715e1b3518d5c09248" + patch(patch_url, sha256=patch_checksum, when="@6.8+qmcpack") + + # 6.7 + patch_url = "https://raw.githubusercontent.com/QMCPACK/qmcpack/v3.13.0/external_codes/quantum_espresso/add_pw2qmcpack_to_qe-6.7.0.diff" + patch_checksum = "72564c168231dd4a1279a74e76919af701d47cee9a851db6e205753004fe9bb5" + patch(patch_url, sha256=patch_checksum, when="@6.7+qmcpack") + + # 6.6 + patch_url = "https://gitlab.com/QEF/q-e/-/commit/081409ea90cba0ddc07bea5ac29e3cd422c67d3d.diff" + patch_checksum = "f43b7411e535629d9ef564a2e1695359df2651ecbdbca563f7265412afc2228a" + patch(patch_url, sha256=patch_checksum, when="@6.6:7.3.1") + + # 6.4.1 + patch_url = "https://raw.githubusercontent.com/QMCPACK/qmcpack/v3.13.0/external_codes/quantum_espresso/add_pw2qmcpack_to_qe-6.4.1.diff" + patch_checksum = "57cb1b06ee2653a87c3acc0dd4f09032fcf6ce6b8cbb9677ae9ceeb6a78f85e2" + patch(patch_url, sha256=patch_checksum, when="@6.4.1+qmcpack") + # 6.4 + patch_url = "https://raw.githubusercontent.com/QMCPACK/qmcpack/v3.13.0/external_codes/quantum_espresso/add_pw2qmcpack_to_qe-6.4.diff" + patch_checksum = "ef08f5089951be902f0854a4dbddaa7b01f08924cdb27decfade6bef0e2b8994" + patch(patch_url, sha256=patch_checksum, when="@=6.4+qmcpack") + # 6.3 + patch_url = "https://raw.githubusercontent.com/QMCPACK/qmcpack/v3.13.0/external_codes/quantum_espresso/add_pw2qmcpack_to_qe-6.3.diff" + patch_checksum = "2ee346e24926479f5e96f8dc47812173a8847a58354bbc32cf2114af7a521c13" + patch(patch_url, sha256=patch_checksum, when="@6.3+qmcpack") + + # ELPA + patch("dspev_drv_elpa.patch", when="@6.1.0:+elpa ^elpa@2016.05.004") + patch("dspev_drv_elpa.patch", when="@6.1.0:+elpa ^elpa@2016.05.003") + + # QE UPSTREAM PATCHES + # QE 6.6 fix conpile error when FFT_LIBS is specified. + patch( + "https://gitlab.com/QEF/q-e/-/commit/cf1fedefc20d39f5cd7551ded700ea4c77ad6e8f.diff", + sha256="8f179663a8d031aff9b1820a32449942281195b6e7b1ceaab1f729651b43fa58", + when="+patch@6.6", + ) + # QE 6.5 INTENT(OUT) without settig value in tetra_weights_only(..., ef): + # For Fujitsu compiler + patch( + "https://gitlab.com/QEF/q-e/-/commit/8f096b53e75026701c681c508e2c24a9378c0950.diff", + sha256="f4f1cce4182b57ac797c8f6ec8460fe375ee96385fcd8f6a61e1460bc957eb67", + when="+patch@6.5", + ) + # QE 6.5 Fix INTENT + # For Fujitsu compiler + patch( + "https://gitlab.com/QEF/q-e/-/commit/c2a86201ed72693ffa50cc99b22f5d3365ae2c2b.diff", + sha256="b2dadc0bc008a3ad4b74ae85cc380dd2b63f2ae43a634e6f9d8db8077efcea6c", + when="+patch@6.5", + ) + # QE 6.3 requires multiple patches to fix MKL detection + # There may still be problems on Mac with MKL detection + patch( + "https://gitlab.com/QEF/q-e/commit/0796e1b7c55c9361ecb6515a0979280e78865e36.diff", + sha256="bc8c5b8523156cee002d97dab42a5976dffae20605da485a427b902a236d7e6b", + when="+patch@=6.3", + ) + + # QE 6.3 `make install` broken and a patch must be applied + patch( + "https://gitlab.com/QEF/q-e/commit/88e6558646dbbcfcafa5f3fa758217f6062ab91c.diff", + sha256="b776890d008e16cca28c31299c62f47de0ba606b900b17cbc27c041f45e564ca", + when="+patch@=6.3", + ) + + # QE 6.4.1 patch to work around configure issues that only appear in the + # Spack environment. We now are able to support: + # `spack install qe~mpi~scalapack hdf5=serial` + patch( + "https://gitlab.com/QEF/q-e/commit/5fb1195b0844e1052b7601f18ab5c700f9cbe648.diff", + sha256="b1aa3179ee1c069964fb9c21f3b832aebeae54947ce8d3cc1a74e7b154c3c10f", + when="+patch@6.4.1:6.5.0", + ) + + # QE 6.4.1 Fix intent for Fujitsu compiler + patch("fj-intent.6.4.1.patch", when="+patch@6.4.1") + # QE 6.4.1 Fix intent + patch( + "https://gitlab.com/QEF/q-e/-/commit/c2a86201ed72693ffa50cc99b22f5d3365ae2c2b.diff", + sha256="b2dadc0bc008a3ad4b74ae85cc380dd2b63f2ae43a634e6f9d8db8077efcea6c", + when="+patch@6.4.1", + ) + + # QE 6.4.1 Small fixes for XLF compilation + patch( + "https://gitlab.com/QEF/q-e/-/commit/cf088926d68792cbaea48960c222e336a3965df6.diff", + sha256="bbceba1fb08d01d548d4393bbcaeae966def13f75884268a0f84448457b8eaa3", + when="+patch@6.4.1:6.5.0", + ) + + # Patch automake configure for AOCC compilers + patch("configure_aocc.patch", when="@6.7 %aocc") + + # Configure updated to work with NVIDIA compilers + patch("nvhpc.patch", when="@6.5 %nvhpc") + + # Configure updated to work with Fujitsu compilers + patch("fj.6.5.patch", when="@6.5+patch %fj") + patch("fj.6.6.patch", when="@6.6:6.7+patch %fj") + + # extlibs_makefile updated to work with fujitsu compilers + patch("fj-fox.patch", when="+patch %fj") + + # gipaw.x will only be installed with cmake if the qe-gipaw version is >= 5c4a4ce. + patch("gipaw-eccee44.patch", when="@7.2+gipaw build_system=cmake") + + # blas libraries have been removed from qe_lapack target in 7.4.1 + patch("0001-add-blas-libraries-to-target.patch", when="@7.4.1 build_system=cmake") + + # LAXlib check in QE 7.5 fails + patch("0001-disable-cuda-check-in-laxlib.patch", when="@7.5+cuda %nvhpc") + + # set natx=100 + patch("0001-natx-100.patch") + +class CMakeBuilder(cmake.CMakeBuilder): + def cmake_args(self): + spec = self.spec + + cmake_args = [ + self.define_from_variant("QE_ENABLE_MPI", "mpi"), + self.define_from_variant("QE_ENABLE_OPENMP", "openmp"), + self.define_from_variant("QE_ENABLE_SCALAPACK", "scalapack"), + self.define_from_variant("QE_ENABLE_ELPA", "elpa"), + self.define_from_variant("QE_ENABLE_LIBXC", "libxc"), + self.define_from_variant("QE_ENABLE_CUDA", "cuda"), + self.define_from_variant("QE_ENABLE_PROFILE_NVTX", "nvtx"), + self.define_from_variant("QE_ENABLE_TRACE", "trace"), + self.define_from_variant("QE_CLOCK_SECONDS", "clock"), + self.define_from_variant("QE_ENABLE_MPI_GPU_AWARE", "mpigpu"), + self.define_from_variant("QE_ENABLE_OSCDFT", "oscdft"), + ] + + plugins = [] + + if "+fox" in spec: + cmake_args.append(self.define("QE_ENABLE_FOX", True)) + + if "+gipaw" in spec: + plugins.append("gipaw") + + if "+cuda" in self.spec: + cmake_args.append(self.define("QE_ENABLE_OPENACC", True)) + + # QE prefers taking MPI compiler wrappers as CMake compilers. + if "+mpi" in spec: + cmake_args.append(self.define("CMAKE_C_COMPILER", spec["mpi"].mpicc)) + cmake_args.append(self.define("CMAKE_Fortran_COMPILER", spec["mpi"].mpifc)) + + if not spec.satisfies("hdf5=none"): + cmake_args.append(self.define("QE_ENABLE_HDF5", True)) + + if "+qmcpack" in spec: + if spec.satisfies("@:7.0"): + cmake_args.append(self.define("QE_ENABLE_PW2QMCPACK", True)) + else: + plugins.append("pw2qmcpack") + + if "^armpl-gcc" in spec or "^acfl" in spec: + cmake_args.append(self.define("BLAS_LIBRARIES", spec["blas"].libs.joined(";"))) + cmake_args.append(self.define("LAPACK_LIBRARIES", spec["lapack"].libs.joined(";"))) + # Up to q-e@7.1 set BLA_VENDOR to All to force detection of vanilla scalapack + if spec.satisfies("@:7.1"): + cmake_args.append(self.define("BLA_VENDOR", "All")) + + if "^nvpl-blas" in spec: + cmake_args.append(self.define("BLAS_LIBRARIES", spec["blas"].libs.joined(";"))) + if "^nvpl-lapack" in spec: + cmake_args.append(self.define("LAPACK_LIBRARIES", spec["lapack"].libs.joined(";"))) + if "^nvpl-scalapack" in spec: + cmake_args.append(self.define("SCALAPACK_LIBRARIES", spec["scalapack"].libs.joined(";"))) + + if "+wannier90_external" in spec: + cmake_args.append(self.define("WANNIER90_ROOT", spec["wannier90"].prefix)) + + + if plugins: + cmake_args.append(self.define("QE_ENABLE_PLUGINS", plugins)) + return cmake_args + + +class GenericBuilder(generic.GenericBuilder): + def install(self, pkg, spec, prefix): + prefix_path = prefix.bin if "@:5.4.0" in spec else prefix + options = ["-prefix={0}".format(prefix_path)] + + # QE autoconf compiler variables has some limitations: + # 1. There is no explicit MPICC variable so we must re-purpose + # CC for the case of MPI. + # 2. F90 variable is set to be consistent with MPIF90 wrapper + # 3. If an absolute path for F90 is set, the build system breaks. + # + # Thus, due to 2. and 3. the F90 variable is not explictly set + # because it would be mostly pointless and could lead to erroneous + # behaviour. + if "+mpi" in spec: + mpi = spec["mpi"] + options.append("--enable-parallel=yes") + options.append("MPIF90={0}".format(mpi.mpifc)) + options.append("CC={0}".format(mpi.mpicc)) + else: + options.append("--enable-parallel=no") + options.append("CC={0}".format(env["SPACK_CC"])) + + options.append("F77={0}".format(env["SPACK_F77"])) + options.append("F90={0}".format(env["SPACK_FC"])) + + if "+openmp" in spec: + options.append("--enable-openmp") + + # QE external BLAS, FFT, SCALAPACK detection is a bit tricky. + # More predictable to pass in the correct link line to QE. + # If external detection of BLAS, LAPACK and FFT fails, QE + # is supposed to revert to internal versions of these libraries + # instead -- but more likely it will pickup versions of these + # libraries found in its the system path, e.g. Red Hat or + # Ubuntu's FFTW3 package. + + # FFT + # FFT detection gets derailed if you pass into the CPPFLAGS, instead + # you need to pass it in the FFTW_INCLUDE and FFT_LIBS directory. + # QE supports an internal FFTW2, but only an external FFTW3 interface. + + is_using_intel_libraries = spec["lapack"].name == "intel-oneapi-mkl" + if is_using_intel_libraries: + # A seperate FFT library is not needed when linking against MKL + options.append("FFTW_INCLUDE={0}".format(join_path(env["MKLROOT"], "include/fftw"))) + if "^fftw@3:" in spec: + fftw_prefix = spec["fftw"].prefix + options.append("FFTW_INCLUDE={0}".format(fftw_prefix.include)) + if "+openmp" in spec: + fftw_ld_flags = spec["fftw:openmp"].libs.ld_flags + else: + fftw_ld_flags = spec["fftw"].libs.ld_flags + options.append("FFT_LIBS={0}".format(fftw_ld_flags)) + + if "^amdfftw" in spec: + fftw_prefix = spec["amdfftw"].prefix + options.append("FFTW_INCLUDE={0}".format(fftw_prefix.include)) + if "+openmp" in spec: + fftw_ld_flags = spec["amdfftw:openmp"].libs.ld_flags + else: + fftw_ld_flags = spec["amdfftw"].libs.ld_flags + options.append("FFT_LIBS={0}".format(fftw_ld_flags)) + + # External BLAS and LAPACK requires the correct link line into + # BLAS_LIBS, do no use LAPACK_LIBS as the autoconf scripts indicate + # that this variable is largely ignored/obsolete. + + # For many Spack packages, lapack.libs = blas.libs, hence it will + # appear twice in in link line but this is harmless + lapack_blas = spec["lapack"].libs + spec["blas"].libs + + # qe-6.5 fails to detect MKL for FFT if BLAS_LIBS is set due to + # an unfortunate upsteam change in their autoconf/configure: + # - qe-6.5/install/m4/x_ac_qe_blas.m4 only sets 'have_blas' + # but no 'have_mkl' if BLAS_LIBS is set (which seems to be o.k.) + # - however, qe-6.5/install/m4/x_ac_qe_fft.m4 in 6.5 unfortunately + # relies on x_ac_qe_blas.m4 to detect MKL and set 'have_mkl' + # - qe-5.4 up to 6.4.1 had a different logic and worked fine with + # BLAS_LIBS being set + # However, MKL is correctly picked up by qe-6.5 for BLAS and FFT if + # MKLROOT is set (which SPACK does automatically for ^mkl) + if spec.satisfies("@:6.4"): # set even if MKL is selected + options.append("BLAS_LIBS={0}".format(lapack_blas.ld_flags)) + else: # behavior changed at 6.5 and later + if not is_using_intel_libraries: + options.append("BLAS_LIBS={0}".format(lapack_blas.ld_flags)) + + if "+scalapack" in spec: + if is_using_intel_libraries: + if "^[virtuals=mpi] openmpi" in spec: + scalapack_option = "yes" + else: # mpich + scalapack_option = "intel" + else: + scalapack_option = "yes" + options.append("--with-scalapack={0}".format(scalapack_option)) + scalapack_lib = spec["scalapack"].libs + options.append("SCALAPACK_LIBS={0}".format(scalapack_lib.ld_flags)) + + if "+libxc" in spec: + options.append("--with-libxc=yes") + options.append("--with-libxc-prefix={0}".format(spec["libxc"].prefix)) + + if "+elpa" in spec: + # Spec for elpa + elpa = spec["elpa"] + + # Compute the include directory from there: versions + # of espresso prior to 6.1 requires -I in front of the directory + elpa_include = "" if "@6.1:" in spec else "-I" + elpa_include += join_path(elpa.headers.directories[0], "modules") + + options.extend( + [ + "--with-elpa-include={0}".format(elpa_include), + "--with-elpa-version={0}".format(elpa.version.version[0]), + ] + ) + + elpa_suffix = "_openmp" if "+openmp" in elpa else "" + + # Currently AOCC support only static libraries of ELPA + if "%aocc" in spec: + options.extend( + [ + "--with-elpa-lib={0}".format( + join_path( + elpa.prefix.lib, + "libelpa{elpa_suffix}.a".format(elpa_suffix=elpa_suffix), + ) + ) + ] + ) + else: + options.extend(["--with-elpa-lib={0}".format(elpa.libs[0])]) + + if "+fox" in spec: + options.append("--with-fox=yes") + + if spec.variants["hdf5"].value != "none": + options.append("--with-hdf5={0}".format(spec["hdf5"].prefix)) + if spec.satisfies("@6.4.1,6.5"): + options.extend( + [ + "--with-hdf5-include={0}".format(spec["hdf5"].headers.directories[0]), + "--with-hdf5-libs={0}".format(spec["hdf5:hl,fortran"].libs.ld_flags), + ] + ) + + configure(*options) + + # Filter file must be applied after configure executes + # QE 6.1.0 to QE 6.4 have `-L` missing in front of zlib library + # This issue is backported through an internal patch in 6.4.1, but + # can't be applied to the '+qmcpack' variant + if spec.variants["hdf5"].value != "none": + if spec.satisfies("@6.1.0:6.4.0") or (spec.satisfies("@6.4.1") and "+qmcpack" in spec): + make_inc = join_path(self.pkg.stage.source_path, "make.inc") + zlib_libs = spec["zlib-api"].prefix.lib + " -lz" + filter_file(zlib_libs, format(spec["zlib-api"].libs.ld_flags), make_inc) + + # QE 6.8 and later has parallel builds fixed + if spec.satisfies("@:6.7"): + parallel_build_on = False + else: + parallel_build_on = True + + if "+epw" in spec: + make("all", "epw", parallel=parallel_build_on) + else: + make("all", parallel=parallel_build_on) + + if "+gipaw" in spec: + make("gipaw", parallel=False) + + if "+environ" in spec: + addsonpatch = Executable("./install/addsonpatch.sh") + environpatch = Executable("./Environ/patches/environpatch.sh") + makedeps = Executable("./install/makedeps.sh") + + addsonpatch("Environ", "Environ/src", "Modules", "-patch") + + environpatch("-patch") + + makedeps() + + make("pw", parallel=parallel_build_on) + + if "platform=darwin" in spec: + mkdirp(prefix.bin) + install("bin/*.x", prefix.bin) + else: + make("install")